@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | class OxidInstaller extends BaseInstaller |
7 | 7 | { |
8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
8 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
9 | 9 | |
10 | 10 | protected $locations = array( |
11 | 11 | 'module' => 'modules/{$name}/', |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | 'out' => 'out/{$name}/', |
14 | 14 | ); |
15 | 15 | |
16 | - /** |
|
17 | - * getInstallPath |
|
18 | - * |
|
19 | - * @param PackageInterface $package |
|
20 | - * @param string $frameworkType |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | - { |
|
25 | - $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | - $type = $this->package->getType(); |
|
27 | - if ($type === 'oxid-module') { |
|
28 | - $this->prepareVendorDirectory($installPath); |
|
29 | - } |
|
30 | - return $installPath; |
|
31 | - } |
|
16 | + /** |
|
17 | + * getInstallPath |
|
18 | + * |
|
19 | + * @param PackageInterface $package |
|
20 | + * @param string $frameworkType |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | + { |
|
25 | + $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | + $type = $this->package->getType(); |
|
27 | + if ($type === 'oxid-module') { |
|
28 | + $this->prepareVendorDirectory($installPath); |
|
29 | + } |
|
30 | + return $installPath; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * prepareVendorDirectory |
|
35 | - * |
|
36 | - * Makes sure there is a vendormetadata.php file inside |
|
37 | - * the vendor folder if there is a vendor folder. |
|
38 | - * |
|
39 | - * @param string $installPath |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected function prepareVendorDirectory($installPath) |
|
43 | - { |
|
44 | - $matches = ''; |
|
45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | - if (!$hasVendorDirectory) { |
|
47 | - return; |
|
48 | - } |
|
33 | + /** |
|
34 | + * prepareVendorDirectory |
|
35 | + * |
|
36 | + * Makes sure there is a vendormetadata.php file inside |
|
37 | + * the vendor folder if there is a vendor folder. |
|
38 | + * |
|
39 | + * @param string $installPath |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected function prepareVendorDirectory($installPath) |
|
43 | + { |
|
44 | + $matches = ''; |
|
45 | + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | + if (!$hasVendorDirectory) { |
|
47 | + return; |
|
48 | + } |
|
49 | 49 | |
50 | - $vendorDirectory = $matches['vendor']; |
|
51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | - if (!file_exists($vendorPath)) { |
|
53 | - mkdir($vendorPath, 0755, true); |
|
54 | - } |
|
50 | + $vendorDirectory = $matches['vendor']; |
|
51 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | + if (!file_exists($vendorPath)) { |
|
53 | + mkdir($vendorPath, 0755, true); |
|
54 | + } |
|
55 | 55 | |
56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | - touch($vendorMetaDataPath); |
|
58 | - } |
|
56 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | + touch($vendorMetaDataPath); |
|
58 | + } |
|
59 | 59 | } |
@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | class ClanCatsFrameworkInstaller extends BaseInstaller |
5 | 5 | { |
6 | - protected $locations = array( |
|
7 | - 'ship' => 'CCF/orbit/{$name}/', |
|
8 | - 'theme' => 'CCF/app/themes/{$name}/', |
|
9 | - ); |
|
6 | + protected $locations = array( |
|
7 | + 'ship' => 'CCF/orbit/{$name}/', |
|
8 | + 'theme' => 'CCF/app/themes/{$name}/', |
|
9 | + ); |
|
10 | 10 | } |
11 | 11 | \ No newline at end of file |
@@ -799,7 +799,7 @@ |
||
799 | 799 | case 'trial_interval': |
800 | 800 | $value = absint( $value ); |
801 | 801 | break; |
802 | - case 'editable': |
|
802 | + case 'editable': |
|
803 | 803 | $value = (int) $value; |
804 | 804 | break; |
805 | 805 | } |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | function wpinv_can_checkout() { |
33 | - $can_checkout = true; // Always true for now |
|
33 | + $can_checkout = true; // Always true for now |
|
34 | 34 | |
35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function wpinv_get_success_page_uri() { |
39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | - $page_id = absint( $page_id ); |
|
39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | + $page_id = absint( $page_id ); |
|
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function wpinv_get_history_page_uri() { |
46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | - $page_id = absint( $page_id ); |
|
46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | + $page_id = absint( $page_id ); |
|
48 | 48 | |
49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function wpinv_is_success_page() { |
53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
55 | 55 | |
56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_invoice_history_page() { |
60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | - $ret = $ret ? is_page( $ret ) : false; |
|
62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | + $ret = $ret ? is_page( $ret ) : false; |
|
62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | function wpinv_is_subscriptions_history_page() { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_send_to_success_page( $args = null ) { |
72 | - $redirect = wpinv_get_success_page_uri(); |
|
72 | + $redirect = wpinv_get_success_page_uri(); |
|
73 | 73 | |
74 | 74 | if ( !empty( $args ) ) { |
75 | 75 | // Check for backward compatibility |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_send_to_failed_page( $args = null ) { |
92 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
92 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
93 | 93 | |
94 | 94 | if ( !empty( $args ) ) { |
95 | 95 | // Check for backward compatibility |
@@ -109,72 +109,72 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | function wpinv_get_checkout_uri( $args = array() ) { |
112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
112 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | 114 | |
115 | - if ( !empty( $args ) ) { |
|
116 | - // Check for backward compatibility |
|
117 | - if ( is_string( $args ) ) |
|
118 | - $args = str_replace( '?', '', $args ); |
|
115 | + if ( !empty( $args ) ) { |
|
116 | + // Check for backward compatibility |
|
117 | + if ( is_string( $args ) ) |
|
118 | + $args = str_replace( '?', '', $args ); |
|
119 | 119 | |
120 | - $args = wp_parse_args( $args ); |
|
120 | + $args = wp_parse_args( $args ); |
|
121 | 121 | |
122 | - $uri = add_query_arg( $args, $uri ); |
|
123 | - } |
|
122 | + $uri = add_query_arg( $args, $uri ); |
|
123 | + } |
|
124 | 124 | |
125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
125 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | 126 | |
127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
127 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
128 | 128 | |
129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | - } |
|
129 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | + } |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
133 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | function wpinv_send_back_to_checkout( $args = array() ) { |
137 | - $redirect = wpinv_get_checkout_uri(); |
|
137 | + $redirect = wpinv_get_checkout_uri(); |
|
138 | 138 | |
139 | - if ( ! empty( $args ) ) { |
|
140 | - // Check for backward compatibility |
|
141 | - if ( is_string( $args ) ) |
|
142 | - $args = str_replace( '?', '', $args ); |
|
139 | + if ( ! empty( $args ) ) { |
|
140 | + // Check for backward compatibility |
|
141 | + if ( is_string( $args ) ) |
|
142 | + $args = str_replace( '?', '', $args ); |
|
143 | 143 | |
144 | - $args = wp_parse_args( $args ); |
|
144 | + $args = wp_parse_args( $args ); |
|
145 | 145 | |
146 | - $redirect = add_query_arg( $args, $redirect ); |
|
147 | - } |
|
146 | + $redirect = add_query_arg( $args, $redirect ); |
|
147 | + } |
|
148 | 148 | |
149 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | - exit; |
|
149 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | + exit; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | function wpinv_get_success_page_url( $query_string = null ) { |
154 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | - $success_page = get_permalink( $success_page ); |
|
154 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | + $success_page = get_permalink( $success_page ); |
|
156 | 156 | |
157 | - if ( $query_string ) |
|
158 | - $success_page .= $query_string; |
|
157 | + if ( $query_string ) |
|
158 | + $success_page .= $query_string; |
|
159 | 159 | |
160 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
160 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
164 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
164 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
166 | 166 | |
167 | - if ( $extras ) |
|
168 | - $uri .= $extras; |
|
167 | + if ( $extras ) |
|
168 | + $uri .= $extras; |
|
169 | 169 | |
170 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
170 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_is_failed_transaction_page() { |
174 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
174 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
176 | 176 | |
177 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
177 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -320,36 +320,36 @@ discard block |
||
320 | 320 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
321 | 321 | |
322 | 322 | if ( $require_billing_details ) { |
323 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
324 | - $required_fields['first_name'] = array( |
|
325 | - 'error_id' => 'invalid_first_name', |
|
326 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
327 | - ); |
|
328 | - } |
|
329 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
330 | - $required_fields['address'] = array( |
|
331 | - 'error_id' => 'invalid_address', |
|
332 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
333 | - ); |
|
334 | - } |
|
335 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
336 | - $required_fields['city'] = array( |
|
337 | - 'error_id' => 'invalid_city', |
|
338 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
339 | - ); |
|
340 | - } |
|
341 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
342 | - $required_fields['state'] = array( |
|
343 | - 'error_id' => 'invalid_state', |
|
344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
345 | - ); |
|
346 | - } |
|
347 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
348 | - $required_fields['country'] = array( |
|
349 | - 'error_id' => 'invalid_country', |
|
350 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
351 | - ); |
|
352 | - } |
|
323 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
324 | + $required_fields['first_name'] = array( |
|
325 | + 'error_id' => 'invalid_first_name', |
|
326 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
327 | + ); |
|
328 | + } |
|
329 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
330 | + $required_fields['address'] = array( |
|
331 | + 'error_id' => 'invalid_address', |
|
332 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
333 | + ); |
|
334 | + } |
|
335 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
336 | + $required_fields['city'] = array( |
|
337 | + 'error_id' => 'invalid_city', |
|
338 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
339 | + ); |
|
340 | + } |
|
341 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
342 | + $required_fields['state'] = array( |
|
343 | + 'error_id' => 'invalid_state', |
|
344 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
345 | + ); |
|
346 | + } |
|
347 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
348 | + $required_fields['country'] = array( |
|
349 | + 'error_id' => 'invalid_country', |
|
350 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
351 | + ); |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -955,326 +955,326 @@ discard block |
||
955 | 955 | } |
956 | 956 | |
957 | 957 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
958 | - $pages_options = array(); |
|
958 | + $pages_options = array(); |
|
959 | 959 | |
960 | - if( $default_label !== NULL && $default_label !== false ) { |
|
961 | - $pages_options = array( '' => $default_label ); // Blank option |
|
962 | - } |
|
960 | + if( $default_label !== NULL && $default_label !== false ) { |
|
961 | + $pages_options = array( '' => $default_label ); // Blank option |
|
962 | + } |
|
963 | 963 | |
964 | - $pages = get_pages(); |
|
965 | - if ( $pages ) { |
|
966 | - foreach ( $pages as $page ) { |
|
967 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
964 | + $pages = get_pages(); |
|
965 | + if ( $pages ) { |
|
966 | + foreach ( $pages as $page ) { |
|
967 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
968 | 968 | $pages_options[ $page->ID ] = $title; |
969 | - } |
|
970 | - } |
|
969 | + } |
|
970 | + } |
|
971 | 971 | |
972 | - return $pages_options; |
|
972 | + return $pages_options; |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | function wpinv_header_callback( $args ) { |
976 | - if ( !empty( $args['desc'] ) ) { |
|
976 | + if ( !empty( $args['desc'] ) ) { |
|
977 | 977 | echo $args['desc']; |
978 | 978 | } |
979 | 979 | } |
980 | 980 | |
981 | 981 | function wpinv_hidden_callback( $args ) { |
982 | - global $wpinv_options; |
|
983 | - |
|
984 | - if ( isset( $args['set_value'] ) ) { |
|
985 | - $value = $args['set_value']; |
|
986 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
987 | - $value = $wpinv_options[ $args['id'] ]; |
|
988 | - } else { |
|
989 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
990 | - } |
|
991 | - |
|
992 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
993 | - $args['readonly'] = true; |
|
994 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
995 | - $name = ''; |
|
996 | - } else { |
|
997 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
998 | - } |
|
999 | - |
|
1000 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
982 | + global $wpinv_options; |
|
983 | + |
|
984 | + if ( isset( $args['set_value'] ) ) { |
|
985 | + $value = $args['set_value']; |
|
986 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
987 | + $value = $wpinv_options[ $args['id'] ]; |
|
988 | + } else { |
|
989 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
990 | + } |
|
991 | + |
|
992 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
993 | + $args['readonly'] = true; |
|
994 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
995 | + $name = ''; |
|
996 | + } else { |
|
997 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
998 | + } |
|
999 | + |
|
1000 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
1001 | 1001 | |
1002 | - echo $html; |
|
1002 | + echo $html; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | function wpinv_checkbox_callback( $args ) { |
1006 | - global $wpinv_options; |
|
1006 | + global $wpinv_options; |
|
1007 | 1007 | |
1008 | 1008 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1009 | 1009 | |
1010 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1011 | - $name = ''; |
|
1012 | - } else { |
|
1013 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
1014 | - } |
|
1010 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1011 | + $name = ''; |
|
1012 | + } else { |
|
1013 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
1014 | + } |
|
1015 | 1015 | |
1016 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
1017 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
1018 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1016 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
1017 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
1018 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1019 | 1019 | |
1020 | - echo $html; |
|
1020 | + echo $html; |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | function wpinv_multicheck_callback( $args ) { |
1024 | - global $wpinv_options; |
|
1024 | + global $wpinv_options; |
|
1025 | 1025 | |
1026 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1027 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
1026 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1027 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
1028 | 1028 | |
1029 | - if ( ! empty( $args['options'] ) ) { |
|
1030 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
1029 | + if ( ! empty( $args['options'] ) ) { |
|
1030 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
1031 | 1031 | foreach( $args['options'] as $key => $option ): |
1032 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1033 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
1034 | - $enabled = $sanitize_key; |
|
1035 | - } else { |
|
1036 | - $enabled = NULL; |
|
1037 | - } |
|
1038 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
1039 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
1040 | - endforeach; |
|
1041 | - echo '</div>'; |
|
1042 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
1043 | - } |
|
1032 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1033 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
1034 | + $enabled = $sanitize_key; |
|
1035 | + } else { |
|
1036 | + $enabled = NULL; |
|
1037 | + } |
|
1038 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
1039 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
1040 | + endforeach; |
|
1041 | + echo '</div>'; |
|
1042 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
1043 | + } |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | function wpinv_payment_icons_callback( $args ) { |
1047 | - global $wpinv_options; |
|
1047 | + global $wpinv_options; |
|
1048 | 1048 | |
1049 | 1049 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1050 | 1050 | |
1051 | - if ( ! empty( $args['options'] ) ) { |
|
1052 | - foreach( $args['options'] as $key => $option ) { |
|
1051 | + if ( ! empty( $args['options'] ) ) { |
|
1052 | + foreach( $args['options'] as $key => $option ) { |
|
1053 | 1053 | $sanitize_key = wpinv_sanitize_key( $key ); |
1054 | 1054 | |
1055 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
1056 | - $enabled = $option; |
|
1057 | - } else { |
|
1058 | - $enabled = NULL; |
|
1059 | - } |
|
1060 | - |
|
1061 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
1062 | - |
|
1063 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
1064 | - |
|
1065 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
1066 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1067 | - } else { |
|
1068 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
1069 | - |
|
1070 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
1071 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
1072 | - } else { |
|
1073 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
1074 | - $content_dir = WP_CONTENT_DIR; |
|
1075 | - |
|
1076 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
1077 | - // Replaces backslashes with forward slashes for Windows systems |
|
1078 | - $image = wp_normalize_path( $image ); |
|
1079 | - $content_dir = wp_normalize_path( $content_dir ); |
|
1080 | - } |
|
1081 | - |
|
1082 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
1083 | - } |
|
1084 | - |
|
1085 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1086 | - } |
|
1087 | - echo $option . '</label>'; |
|
1088 | - } |
|
1089 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1090 | - } |
|
1055 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
1056 | + $enabled = $option; |
|
1057 | + } else { |
|
1058 | + $enabled = NULL; |
|
1059 | + } |
|
1060 | + |
|
1061 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
1062 | + |
|
1063 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
1064 | + |
|
1065 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
1066 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1067 | + } else { |
|
1068 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
1069 | + |
|
1070 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
1071 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
1072 | + } else { |
|
1073 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
1074 | + $content_dir = WP_CONTENT_DIR; |
|
1075 | + |
|
1076 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
1077 | + // Replaces backslashes with forward slashes for Windows systems |
|
1078 | + $image = wp_normalize_path( $image ); |
|
1079 | + $content_dir = wp_normalize_path( $content_dir ); |
|
1080 | + } |
|
1081 | + |
|
1082 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
1083 | + } |
|
1084 | + |
|
1085 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1086 | + } |
|
1087 | + echo $option . '</label>'; |
|
1088 | + } |
|
1089 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1090 | + } |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | function wpinv_radio_callback( $args ) { |
1094 | - global $wpinv_options; |
|
1094 | + global $wpinv_options; |
|
1095 | 1095 | |
1096 | 1096 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1097 | 1097 | |
1098 | 1098 | foreach ( $args['options'] as $key => $option ) : |
1099 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1099 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1100 | 1100 | |
1101 | 1101 | $checked = false; |
1102 | 1102 | |
1103 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1104 | - $checked = true; |
|
1105 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1106 | - $checked = true; |
|
1103 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1104 | + $checked = true; |
|
1105 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1106 | + $checked = true; |
|
1107 | 1107 | |
1108 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
1109 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1110 | - endforeach; |
|
1108 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
1109 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1110 | + endforeach; |
|
1111 | 1111 | |
1112 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1112 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | function wpinv_gateways_callback( $args ) { |
1116 | - global $wpinv_options; |
|
1116 | + global $wpinv_options; |
|
1117 | 1117 | |
1118 | 1118 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1119 | 1119 | |
1120 | - foreach ( $args['options'] as $key => $option ) : |
|
1121 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1120 | + foreach ( $args['options'] as $key => $option ) : |
|
1121 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1122 | 1122 | |
1123 | 1123 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
1124 | - $enabled = '1'; |
|
1125 | - else |
|
1126 | - $enabled = null; |
|
1124 | + $enabled = '1'; |
|
1125 | + else |
|
1126 | + $enabled = null; |
|
1127 | 1127 | |
1128 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1129 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1130 | - endforeach; |
|
1128 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1129 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1130 | + endforeach; |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | function wpinv_gateway_select_callback($args) { |
1134 | - global $wpinv_options; |
|
1134 | + global $wpinv_options; |
|
1135 | 1135 | |
1136 | 1136 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1137 | 1137 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
1138 | 1138 | |
1139 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
1139 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
1140 | 1140 | |
1141 | - foreach ( $args['options'] as $key => $option ) : |
|
1142 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1141 | + foreach ( $args['options'] as $key => $option ) : |
|
1142 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1143 | 1143 | $selected = selected( $key, $args['selected'], false ); |
1144 | 1144 | } else { |
1145 | 1145 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
1146 | 1146 | } |
1147 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1148 | - endforeach; |
|
1147 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1148 | + endforeach; |
|
1149 | 1149 | |
1150 | - echo '</select>'; |
|
1151 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1150 | + echo '</select>'; |
|
1151 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | function wpinv_text_callback( $args ) { |
1155 | - global $wpinv_options; |
|
1155 | + global $wpinv_options; |
|
1156 | 1156 | |
1157 | 1157 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1158 | 1158 | |
1159 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1160 | - $value = $wpinv_options[ $args['id'] ]; |
|
1161 | - } else { |
|
1162 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1163 | - } |
|
1164 | - |
|
1165 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1166 | - $args['readonly'] = true; |
|
1167 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1168 | - $name = ''; |
|
1169 | - } else { |
|
1170 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1171 | - } |
|
1172 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1173 | - |
|
1174 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
1175 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1176 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1177 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1178 | - |
|
1179 | - echo $html; |
|
1159 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1160 | + $value = $wpinv_options[ $args['id'] ]; |
|
1161 | + } else { |
|
1162 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1163 | + } |
|
1164 | + |
|
1165 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1166 | + $args['readonly'] = true; |
|
1167 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1168 | + $name = ''; |
|
1169 | + } else { |
|
1170 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1171 | + } |
|
1172 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1173 | + |
|
1174 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
1175 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1176 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1177 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1178 | + |
|
1179 | + echo $html; |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | function wpinv_number_callback( $args ) { |
1183 | - global $wpinv_options; |
|
1183 | + global $wpinv_options; |
|
1184 | 1184 | |
1185 | 1185 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1186 | 1186 | |
1187 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1188 | - $value = $wpinv_options[ $args['id'] ]; |
|
1189 | - } else { |
|
1190 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1191 | - } |
|
1192 | - |
|
1193 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1194 | - $args['readonly'] = true; |
|
1195 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1196 | - $name = ''; |
|
1197 | - } else { |
|
1198 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1199 | - } |
|
1200 | - |
|
1201 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1202 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1203 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1204 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1205 | - |
|
1206 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1207 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1208 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1209 | - |
|
1210 | - echo $html; |
|
1187 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1188 | + $value = $wpinv_options[ $args['id'] ]; |
|
1189 | + } else { |
|
1190 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1191 | + } |
|
1192 | + |
|
1193 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1194 | + $args['readonly'] = true; |
|
1195 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1196 | + $name = ''; |
|
1197 | + } else { |
|
1198 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1199 | + } |
|
1200 | + |
|
1201 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1202 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1203 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1204 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1205 | + |
|
1206 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1207 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1208 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1209 | + |
|
1210 | + echo $html; |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | function wpinv_textarea_callback( $args ) { |
1214 | - global $wpinv_options; |
|
1214 | + global $wpinv_options; |
|
1215 | 1215 | |
1216 | 1216 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1217 | 1217 | |
1218 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1219 | - $value = $wpinv_options[ $args['id'] ]; |
|
1220 | - } else { |
|
1221 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1222 | - } |
|
1218 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1219 | + $value = $wpinv_options[ $args['id'] ]; |
|
1220 | + } else { |
|
1221 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1222 | + } |
|
1223 | 1223 | |
1224 | 1224 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
1225 | 1225 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
1226 | 1226 | |
1227 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1228 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1227 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1228 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1229 | 1229 | |
1230 | - echo $html; |
|
1230 | + echo $html; |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | function wpinv_password_callback( $args ) { |
1234 | - global $wpinv_options; |
|
1234 | + global $wpinv_options; |
|
1235 | 1235 | |
1236 | 1236 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1237 | 1237 | |
1238 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1239 | - $value = $wpinv_options[ $args['id'] ]; |
|
1240 | - } else { |
|
1241 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1242 | - } |
|
1238 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1239 | + $value = $wpinv_options[ $args['id'] ]; |
|
1240 | + } else { |
|
1241 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1242 | + } |
|
1243 | 1243 | |
1244 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1245 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1246 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1244 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1245 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1246 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1247 | 1247 | |
1248 | - echo $html; |
|
1248 | + echo $html; |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | function wpinv_missing_callback($args) { |
1252 | - printf( |
|
1253 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1254 | - '<strong>' . $args['id'] . '</strong>' |
|
1255 | - ); |
|
1252 | + printf( |
|
1253 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1254 | + '<strong>' . $args['id'] . '</strong>' |
|
1255 | + ); |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | function wpinv_select_callback($args) { |
1259 | - global $wpinv_options; |
|
1259 | + global $wpinv_options; |
|
1260 | 1260 | |
1261 | 1261 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1262 | 1262 | |
1263 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1264 | - $value = $wpinv_options[ $args['id'] ]; |
|
1265 | - } else { |
|
1266 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1267 | - } |
|
1263 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1264 | + $value = $wpinv_options[ $args['id'] ]; |
|
1265 | + } else { |
|
1266 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1267 | + } |
|
1268 | 1268 | |
1269 | 1269 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
1270 | 1270 | $value = $args['selected']; |
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if ( isset( $args['placeholder'] ) ) { |
|
1274 | - $placeholder = $args['placeholder']; |
|
1275 | - } else { |
|
1276 | - $placeholder = ''; |
|
1277 | - } |
|
1273 | + if ( isset( $args['placeholder'] ) ) { |
|
1274 | + $placeholder = $args['placeholder']; |
|
1275 | + } else { |
|
1276 | + $placeholder = ''; |
|
1277 | + } |
|
1278 | 1278 | |
1279 | 1279 | if( !empty( $args['onchange'] ) ) { |
1280 | 1280 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1284,142 +1284,142 @@ discard block |
||
1284 | 1284 | |
1285 | 1285 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
1286 | 1286 | |
1287 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1287 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1288 | 1288 | |
1289 | - foreach ( $args['options'] as $option => $name ) { |
|
1290 | - $selected = selected( $option, $value, false ); |
|
1291 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1292 | - } |
|
1289 | + foreach ( $args['options'] as $option => $name ) { |
|
1290 | + $selected = selected( $option, $value, false ); |
|
1291 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1292 | + } |
|
1293 | 1293 | |
1294 | - $html .= '</select>'; |
|
1295 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1294 | + $html .= '</select>'; |
|
1295 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1296 | 1296 | |
1297 | - echo $html; |
|
1297 | + echo $html; |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | function wpinv_color_select_callback( $args ) { |
1301 | - global $wpinv_options; |
|
1301 | + global $wpinv_options; |
|
1302 | 1302 | |
1303 | 1303 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1304 | 1304 | |
1305 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1306 | - $value = $wpinv_options[ $args['id'] ]; |
|
1307 | - } else { |
|
1308 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1309 | - } |
|
1305 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1306 | + $value = $wpinv_options[ $args['id'] ]; |
|
1307 | + } else { |
|
1308 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1309 | + } |
|
1310 | 1310 | |
1311 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1311 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1312 | 1312 | |
1313 | - foreach ( $args['options'] as $option => $color ) { |
|
1314 | - $selected = selected( $option, $value, false ); |
|
1315 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1316 | - } |
|
1313 | + foreach ( $args['options'] as $option => $color ) { |
|
1314 | + $selected = selected( $option, $value, false ); |
|
1315 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1316 | + } |
|
1317 | 1317 | |
1318 | - $html .= '</select>'; |
|
1319 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1318 | + $html .= '</select>'; |
|
1319 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1320 | 1320 | |
1321 | - echo $html; |
|
1321 | + echo $html; |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | function wpinv_rich_editor_callback( $args ) { |
1325 | - global $wpinv_options, $wp_version; |
|
1325 | + global $wpinv_options, $wp_version; |
|
1326 | 1326 | |
1327 | 1327 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1328 | 1328 | |
1329 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1330 | - $value = $wpinv_options[ $args['id'] ]; |
|
1329 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1330 | + $value = $wpinv_options[ $args['id'] ]; |
|
1331 | 1331 | |
1332 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1333 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1334 | - } |
|
1335 | - } else { |
|
1336 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1337 | - } |
|
1332 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1333 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1334 | + } |
|
1335 | + } else { |
|
1336 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1337 | + } |
|
1338 | 1338 | |
1339 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1339 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1340 | 1340 | |
1341 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1342 | - ob_start(); |
|
1343 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
1344 | - $html = ob_get_clean(); |
|
1345 | - } else { |
|
1346 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1347 | - } |
|
1341 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1342 | + ob_start(); |
|
1343 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
1344 | + $html = ob_get_clean(); |
|
1345 | + } else { |
|
1346 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1347 | + } |
|
1348 | 1348 | |
1349 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1349 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1350 | 1350 | |
1351 | - echo $html; |
|
1351 | + echo $html; |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | function wpinv_upload_callback( $args ) { |
1355 | - global $wpinv_options; |
|
1355 | + global $wpinv_options; |
|
1356 | 1356 | |
1357 | 1357 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1358 | 1358 | |
1359 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1360 | - $value = $wpinv_options[$args['id']]; |
|
1361 | - } else { |
|
1362 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
1363 | - } |
|
1359 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1360 | + $value = $wpinv_options[$args['id']]; |
|
1361 | + } else { |
|
1362 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1363 | + } |
|
1364 | 1364 | |
1365 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1366 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1367 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1368 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1365 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1366 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1367 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1368 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1369 | 1369 | |
1370 | - echo $html; |
|
1370 | + echo $html; |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | function wpinv_color_callback( $args ) { |
1374 | - global $wpinv_options; |
|
1374 | + global $wpinv_options; |
|
1375 | 1375 | |
1376 | 1376 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1377 | 1377 | |
1378 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1379 | - $value = $wpinv_options[ $args['id'] ]; |
|
1380 | - } else { |
|
1381 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1382 | - } |
|
1378 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1379 | + $value = $wpinv_options[ $args['id'] ]; |
|
1380 | + } else { |
|
1381 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1382 | + } |
|
1383 | 1383 | |
1384 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1384 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1385 | 1385 | |
1386 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1387 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1386 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1387 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1388 | 1388 | |
1389 | - echo $html; |
|
1389 | + echo $html; |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | function wpinv_country_states_callback($args) { |
1393 | - global $wpinv_options; |
|
1393 | + global $wpinv_options; |
|
1394 | 1394 | |
1395 | 1395 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1396 | 1396 | |
1397 | - if ( isset( $args['placeholder'] ) ) { |
|
1398 | - $placeholder = $args['placeholder']; |
|
1399 | - } else { |
|
1400 | - $placeholder = ''; |
|
1401 | - } |
|
1397 | + if ( isset( $args['placeholder'] ) ) { |
|
1398 | + $placeholder = $args['placeholder']; |
|
1399 | + } else { |
|
1400 | + $placeholder = ''; |
|
1401 | + } |
|
1402 | 1402 | |
1403 | - $states = wpinv_get_country_states(); |
|
1403 | + $states = wpinv_get_country_states(); |
|
1404 | 1404 | |
1405 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
1406 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1405 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
1406 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1407 | 1407 | |
1408 | - foreach ( $states as $option => $name ) { |
|
1409 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1410 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1411 | - } |
|
1408 | + foreach ( $states as $option => $name ) { |
|
1409 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1410 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1411 | + } |
|
1412 | 1412 | |
1413 | - $html .= '</select>'; |
|
1414 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1413 | + $html .= '</select>'; |
|
1414 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1415 | 1415 | |
1416 | - echo $html; |
|
1416 | + echo $html; |
|
1417 | 1417 | } |
1418 | 1418 | |
1419 | 1419 | function wpinv_tax_rates_callback($args) { |
1420 | - global $wpinv_options; |
|
1421 | - $rates = wpinv_get_tax_rates(); |
|
1422 | - ob_start(); ?> |
|
1420 | + global $wpinv_options; |
|
1421 | + $rates = wpinv_get_tax_rates(); |
|
1422 | + ob_start(); ?> |
|
1423 | 1423 | </td><tr> |
1424 | 1424 | <td colspan="2" class="wpinv_tax_tdbox"> |
1425 | 1425 | <p><?php echo $args['desc']; ?></p> |
@@ -1443,40 +1443,40 @@ discard block |
||
1443 | 1443 | <tr> |
1444 | 1444 | <td class="wpinv_tax_country"> |
1445 | 1445 | <?php |
1446 | - echo wpinv_html_select( array( |
|
1447 | - 'options' => wpinv_get_country_list( true ), |
|
1448 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1446 | + echo wpinv_html_select( array( |
|
1447 | + 'options' => wpinv_get_country_list( true ), |
|
1448 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1449 | 1449 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1450 | - 'selected' => $rate['country'], |
|
1451 | - 'show_option_all' => false, |
|
1452 | - 'show_option_none' => false, |
|
1453 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
1454 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1455 | - ) ); |
|
1456 | - ?> |
|
1450 | + 'selected' => $rate['country'], |
|
1451 | + 'show_option_all' => false, |
|
1452 | + 'show_option_none' => false, |
|
1453 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
1454 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1455 | + ) ); |
|
1456 | + ?> |
|
1457 | 1457 | </td> |
1458 | 1458 | <td class="wpinv_tax_state"> |
1459 | 1459 | <?php |
1460 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1461 | - if( !empty( $states ) ) { |
|
1462 | - echo wpinv_html_select( array( |
|
1463 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1464 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1460 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
1461 | + if( !empty( $states ) ) { |
|
1462 | + echo wpinv_html_select( array( |
|
1463 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
1464 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1465 | 1465 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1466 | - 'selected' => $rate['state'], |
|
1467 | - 'show_option_all' => false, |
|
1468 | - 'show_option_none' => false, |
|
1466 | + 'selected' => $rate['state'], |
|
1467 | + 'show_option_all' => false, |
|
1468 | + 'show_option_none' => false, |
|
1469 | 1469 | 'class' => 'wpi_select2', |
1470 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1471 | - ) ); |
|
1472 | - } else { |
|
1473 | - echo wpinv_html_text( array( |
|
1474 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1475 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1470 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1471 | + ) ); |
|
1472 | + } else { |
|
1473 | + echo wpinv_html_text( array( |
|
1474 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1475 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1476 | 1476 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1477 | - ) ); |
|
1478 | - } |
|
1479 | - ?> |
|
1477 | + ) ); |
|
1478 | + } |
|
1479 | + ?> |
|
1480 | 1480 | </td> |
1481 | 1481 | <td class="wpinv_tax_global"> |
1482 | 1482 | <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
@@ -1491,19 +1491,19 @@ discard block |
||
1491 | 1491 | <tr> |
1492 | 1492 | <td class="wpinv_tax_country"> |
1493 | 1493 | <?php |
1494 | - echo wpinv_html_select( array( |
|
1495 | - 'options' => wpinv_get_country_list( true ), |
|
1496 | - 'name' => 'tax_rates[0][country]', |
|
1497 | - 'show_option_all' => false, |
|
1498 | - 'show_option_none' => false, |
|
1499 | - 'class' => 'wpinv-tax-country wpi_select2', |
|
1500 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1501 | - ) ); ?> |
|
1494 | + echo wpinv_html_select( array( |
|
1495 | + 'options' => wpinv_get_country_list( true ), |
|
1496 | + 'name' => 'tax_rates[0][country]', |
|
1497 | + 'show_option_all' => false, |
|
1498 | + 'show_option_none' => false, |
|
1499 | + 'class' => 'wpinv-tax-country wpi_select2', |
|
1500 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1501 | + ) ); ?> |
|
1502 | 1502 | </td> |
1503 | 1503 | <td class="wpinv_tax_state"> |
1504 | 1504 | <?php echo wpinv_html_text( array( |
1505 | - 'name' => 'tax_rates[0][state]' |
|
1506 | - ) ); ?> |
|
1505 | + 'name' => 'tax_rates[0][state]' |
|
1506 | + ) ); ?> |
|
1507 | 1507 | </td> |
1508 | 1508 | <td class="wpinv_tax_global"> |
1509 | 1509 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
1519 | 1519 | </table> |
1520 | 1520 | <?php |
1521 | - echo ob_get_clean(); |
|
1521 | + echo ob_get_clean(); |
|
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | function wpinv_tools_callback($args) { |
@@ -1546,15 +1546,15 @@ discard block |
||
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | function wpinv_descriptive_text_callback( $args ) { |
1549 | - echo wp_kses_post( $args['desc'] ); |
|
1549 | + echo wp_kses_post( $args['desc'] ); |
|
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | function wpinv_hook_callback( $args ) { |
1553 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1553 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1554 | 1554 | } |
1555 | 1555 | |
1556 | 1556 | function wpinv_set_settings_cap() { |
1557 | - return 'manage_options'; |
|
1557 | + return 'manage_options'; |
|
1558 | 1558 | } |
1559 | 1559 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1560 | 1560 |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_is_base_country( $country ) { |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | function wpinv_get_default_state() { |
43 | - $state = wpinv_get_option( 'default_state', false ); |
|
43 | + $state = wpinv_get_option( 'default_state', false ); |
|
44 | 44 | |
45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
45 | + return apply_filters( 'wpinv_default_state', $state ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -115,260 +115,260 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | function wpinv_get_country_list( $first_empty = false ) { |
118 | - $countries = array( |
|
119 | - 'US' => __('United States', 'invoicing'), |
|
120 | - 'CA' => __('Canada', 'invoicing'), |
|
121 | - 'GB' => __('United Kingdom', 'invoicing'), |
|
122 | - 'AF' => __('Afghanistan', 'invoicing'), |
|
123 | - 'AX' => __('Aland Islands', 'invoicing'), |
|
124 | - 'AL' => __('Albania', 'invoicing'), |
|
125 | - 'DZ' => __('Algeria', 'invoicing'), |
|
126 | - 'AS' => __('American Samoa', 'invoicing'), |
|
127 | - 'AD' => __('Andorra', 'invoicing'), |
|
128 | - 'AO' => __('Angola', 'invoicing'), |
|
129 | - 'AI' => __('Anguilla', 'invoicing'), |
|
130 | - 'AQ' => __('Antarctica', 'invoicing'), |
|
131 | - 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
132 | - 'AR' => __('Argentina', 'invoicing'), |
|
133 | - 'AM' => __('Armenia', 'invoicing'), |
|
134 | - 'AW' => __('Aruba', 'invoicing'), |
|
135 | - 'AU' => __('Australia', 'invoicing'), |
|
136 | - 'AT' => __('Austria', 'invoicing'), |
|
137 | - 'AZ' => __('Azerbaijan', 'invoicing'), |
|
138 | - 'BS' => __('Bahamas', 'invoicing'), |
|
139 | - 'BH' => __('Bahrain', 'invoicing'), |
|
140 | - 'BD' => __('Bangladesh', 'invoicing'), |
|
141 | - 'BB' => __('Barbados', 'invoicing'), |
|
142 | - 'BY' => __('Belarus', 'invoicing'), |
|
143 | - 'BE' => __('Belgium', 'invoicing'), |
|
144 | - 'BZ' => __('Belize', 'invoicing'), |
|
145 | - 'BJ' => __('Benin', 'invoicing'), |
|
146 | - 'BM' => __('Bermuda', 'invoicing'), |
|
147 | - 'BT' => __('Bhutan', 'invoicing'), |
|
148 | - 'BO' => __('Bolivia', 'invoicing'), |
|
149 | - 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
150 | - 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
151 | - 'BW' => __('Botswana', 'invoicing'), |
|
152 | - 'BV' => __('Bouvet Island', 'invoicing'), |
|
153 | - 'BR' => __('Brazil', 'invoicing'), |
|
154 | - 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
155 | - 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
156 | - 'BG' => __('Bulgaria', 'invoicing'), |
|
157 | - 'BF' => __('Burkina Faso', 'invoicing'), |
|
158 | - 'BI' => __('Burundi', 'invoicing'), |
|
159 | - 'KH' => __('Cambodia', 'invoicing'), |
|
160 | - 'CM' => __('Cameroon', 'invoicing'), |
|
161 | - 'CV' => __('Cape Verde', 'invoicing'), |
|
162 | - 'KY' => __('Cayman Islands', 'invoicing'), |
|
163 | - 'CF' => __('Central African Republic', 'invoicing'), |
|
164 | - 'TD' => __('Chad', 'invoicing'), |
|
165 | - 'CL' => __('Chile', 'invoicing'), |
|
166 | - 'CN' => __('China', 'invoicing'), |
|
167 | - 'CX' => __('Christmas Island', 'invoicing'), |
|
168 | - 'CC' => __('Cocos Islands', 'invoicing'), |
|
169 | - 'CO' => __('Colombia', 'invoicing'), |
|
170 | - 'KM' => __('Comoros', 'invoicing'), |
|
171 | - 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
172 | - 'CG' => __('Congo, Republic of', 'invoicing'), |
|
173 | - 'CK' => __('Cook Islands', 'invoicing'), |
|
174 | - 'CR' => __('Costa Rica', 'invoicing'), |
|
175 | - 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
176 | - 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
177 | - 'CU' => __('Cuba', 'invoicing'), |
|
178 | - 'CW' => __('CuraÇao', 'invoicing'), |
|
179 | - 'CY' => __('Cyprus', 'invoicing'), |
|
180 | - 'CZ' => __('Czech Republic', 'invoicing'), |
|
181 | - 'DK' => __('Denmark', 'invoicing'), |
|
182 | - 'DJ' => __('Djibouti', 'invoicing'), |
|
183 | - 'DM' => __('Dominica', 'invoicing'), |
|
184 | - 'DO' => __('Dominican Republic', 'invoicing'), |
|
185 | - 'TP' => __('East Timor', 'invoicing'), |
|
186 | - 'EC' => __('Ecuador', 'invoicing'), |
|
187 | - 'EG' => __('Egypt', 'invoicing'), |
|
188 | - 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
189 | - 'SV' => __('El Salvador', 'invoicing'), |
|
190 | - 'ER' => __('Eritrea', 'invoicing'), |
|
191 | - 'EE' => __('Estonia', 'invoicing'), |
|
192 | - 'ET' => __('Ethiopia', 'invoicing'), |
|
193 | - 'FK' => __('Falkland Islands', 'invoicing'), |
|
194 | - 'FO' => __('Faroe Islands', 'invoicing'), |
|
195 | - 'FJ' => __('Fiji', 'invoicing'), |
|
196 | - 'FI' => __('Finland', 'invoicing'), |
|
197 | - 'FR' => __('France', 'invoicing'), |
|
198 | - 'GF' => __('French Guiana', 'invoicing'), |
|
199 | - 'PF' => __('French Polynesia', 'invoicing'), |
|
200 | - 'TF' => __('French Southern Territories', 'invoicing'), |
|
201 | - 'GA' => __('Gabon', 'invoicing'), |
|
202 | - 'GM' => __('Gambia', 'invoicing'), |
|
203 | - 'GE' => __('Georgia', 'invoicing'), |
|
204 | - 'DE' => __('Germany', 'invoicing'), |
|
205 | - 'GR' => __('Greece', 'invoicing'), |
|
206 | - 'GH' => __('Ghana', 'invoicing'), |
|
207 | - 'GI' => __('Gibraltar', 'invoicing'), |
|
208 | - 'GL' => __('Greenland', 'invoicing'), |
|
209 | - 'GD' => __('Grenada', 'invoicing'), |
|
210 | - 'GP' => __('Guadeloupe', 'invoicing'), |
|
211 | - 'GU' => __('Guam', 'invoicing'), |
|
212 | - 'GT' => __('Guatemala', 'invoicing'), |
|
213 | - 'GG' => __('Guernsey', 'invoicing'), |
|
214 | - 'GN' => __('Guinea', 'invoicing'), |
|
215 | - 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
216 | - 'GY' => __('Guyana', 'invoicing'), |
|
217 | - 'HT' => __('Haiti', 'invoicing'), |
|
218 | - 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
219 | - 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
220 | - 'HN' => __('Honduras', 'invoicing'), |
|
221 | - 'HK' => __('Hong Kong', 'invoicing'), |
|
222 | - 'HU' => __('Hungary', 'invoicing'), |
|
223 | - 'IS' => __('Iceland', 'invoicing'), |
|
224 | - 'IN' => __('India', 'invoicing'), |
|
225 | - 'ID' => __('Indonesia', 'invoicing'), |
|
226 | - 'IR' => __('Iran', 'invoicing'), |
|
227 | - 'IQ' => __('Iraq', 'invoicing'), |
|
228 | - 'IE' => __('Ireland', 'invoicing'), |
|
229 | - 'IM' => __('Isle of Man', 'invoicing'), |
|
230 | - 'IL' => __('Israel', 'invoicing'), |
|
231 | - 'IT' => __('Italy', 'invoicing'), |
|
232 | - 'JM' => __('Jamaica', 'invoicing'), |
|
233 | - 'JP' => __('Japan', 'invoicing'), |
|
234 | - 'JE' => __('Jersey', 'invoicing'), |
|
235 | - 'JO' => __('Jordan', 'invoicing'), |
|
236 | - 'KZ' => __('Kazakhstan', 'invoicing'), |
|
237 | - 'KE' => __('Kenya', 'invoicing'), |
|
238 | - 'KI' => __('Kiribati', 'invoicing'), |
|
239 | - 'KW' => __('Kuwait', 'invoicing'), |
|
240 | - 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
241 | - 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
242 | - 'LV' => __('Latvia', 'invoicing'), |
|
243 | - 'LB' => __('Lebanon', 'invoicing'), |
|
244 | - 'LS' => __('Lesotho', 'invoicing'), |
|
245 | - 'LR' => __('Liberia', 'invoicing'), |
|
246 | - 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
247 | - 'LI' => __('Liechtenstein', 'invoicing'), |
|
248 | - 'LT' => __('Lithuania', 'invoicing'), |
|
249 | - 'LU' => __('Luxembourg', 'invoicing'), |
|
250 | - 'MO' => __('Macau', 'invoicing'), |
|
251 | - 'MK' => __('Macedonia', 'invoicing'), |
|
252 | - 'MG' => __('Madagascar', 'invoicing'), |
|
253 | - 'MW' => __('Malawi', 'invoicing'), |
|
254 | - 'MY' => __('Malaysia', 'invoicing'), |
|
255 | - 'MV' => __('Maldives', 'invoicing'), |
|
256 | - 'ML' => __('Mali', 'invoicing'), |
|
257 | - 'MT' => __('Malta', 'invoicing'), |
|
258 | - 'MH' => __('Marshall Islands', 'invoicing'), |
|
259 | - 'MQ' => __('Martinique', 'invoicing'), |
|
260 | - 'MR' => __('Mauritania', 'invoicing'), |
|
261 | - 'MU' => __('Mauritius', 'invoicing'), |
|
262 | - 'YT' => __('Mayotte', 'invoicing'), |
|
263 | - 'MX' => __('Mexico', 'invoicing'), |
|
264 | - 'FM' => __('Micronesia', 'invoicing'), |
|
265 | - 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
266 | - 'MC' => __('Monaco', 'invoicing'), |
|
267 | - 'MN' => __('Mongolia', 'invoicing'), |
|
268 | - 'ME' => __('Montenegro', 'invoicing'), |
|
269 | - 'MS' => __('Montserrat', 'invoicing'), |
|
270 | - 'MA' => __('Morocco', 'invoicing'), |
|
271 | - 'MZ' => __('Mozambique', 'invoicing'), |
|
272 | - 'MM' => __('Myanmar', 'invoicing'), |
|
273 | - 'NA' => __('Namibia', 'invoicing'), |
|
274 | - 'NR' => __('Nauru', 'invoicing'), |
|
275 | - 'NP' => __('Nepal', 'invoicing'), |
|
276 | - 'NL' => __('Netherlands', 'invoicing'), |
|
277 | - 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
278 | - 'NC' => __('New Caledonia', 'invoicing'), |
|
279 | - 'NZ' => __('New Zealand', 'invoicing'), |
|
280 | - 'NI' => __('Nicaragua', 'invoicing'), |
|
281 | - 'NE' => __('Niger', 'invoicing'), |
|
282 | - 'NG' => __('Nigeria', 'invoicing'), |
|
283 | - 'NU' => __('Niue', 'invoicing'), |
|
284 | - 'NF' => __('Norfolk Island', 'invoicing'), |
|
285 | - 'KP' => __('North Korea', 'invoicing'), |
|
286 | - 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
287 | - 'NO' => __('Norway', 'invoicing'), |
|
288 | - 'OM' => __('Oman', 'invoicing'), |
|
289 | - 'PK' => __('Pakistan', 'invoicing'), |
|
290 | - 'PW' => __('Palau', 'invoicing'), |
|
291 | - 'PS' => __('Palestinian Territories', 'invoicing'), |
|
292 | - 'PA' => __('Panama', 'invoicing'), |
|
293 | - 'PG' => __('Papua New Guinea', 'invoicing'), |
|
294 | - 'PY' => __('Paraguay', 'invoicing'), |
|
295 | - 'PE' => __('Peru', 'invoicing'), |
|
296 | - 'PH' => __('Phillipines', 'invoicing'), |
|
297 | - 'PN' => __('Pitcairn Island', 'invoicing'), |
|
298 | - 'PL' => __('Poland', 'invoicing'), |
|
299 | - 'PT' => __('Portugal', 'invoicing'), |
|
300 | - 'PR' => __('Puerto Rico', 'invoicing'), |
|
301 | - 'QA' => __('Qatar', 'invoicing'), |
|
302 | - 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
303 | - 'RE' => __('Reunion Island', 'invoicing'), |
|
304 | - 'RO' => __('Romania', 'invoicing'), |
|
305 | - 'RU' => __('Russian Federation', 'invoicing'), |
|
306 | - 'RW' => __('Rwanda', 'invoicing'), |
|
307 | - 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
308 | - 'SH' => __('Saint Helena', 'invoicing'), |
|
309 | - 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
310 | - 'LC' => __('Saint Lucia', 'invoicing'), |
|
311 | - 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
312 | - 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
313 | - 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
314 | - 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
315 | - 'SM' => __('San Marino', 'invoicing'), |
|
316 | - 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
317 | - 'SA' => __('Saudi Arabia', 'invoicing'), |
|
318 | - 'SN' => __('Senegal', 'invoicing'), |
|
319 | - 'RS' => __('Serbia', 'invoicing'), |
|
320 | - 'SC' => __('Seychelles', 'invoicing'), |
|
321 | - 'SL' => __('Sierra Leone', 'invoicing'), |
|
322 | - 'SG' => __('Singapore', 'invoicing'), |
|
323 | - 'SK' => __('Slovak Republic', 'invoicing'), |
|
324 | - 'SI' => __('Slovenia', 'invoicing'), |
|
325 | - 'SB' => __('Solomon Islands', 'invoicing'), |
|
326 | - 'SO' => __('Somalia', 'invoicing'), |
|
327 | - 'ZA' => __('South Africa', 'invoicing'), |
|
328 | - 'GS' => __('South Georgia', 'invoicing'), |
|
329 | - 'KR' => __('South Korea', 'invoicing'), |
|
330 | - 'SS' => __('South Sudan', 'invoicing'), |
|
331 | - 'ES' => __('Spain', 'invoicing'), |
|
332 | - 'LK' => __('Sri Lanka', 'invoicing'), |
|
333 | - 'SD' => __('Sudan', 'invoicing'), |
|
334 | - 'SR' => __('Suriname', 'invoicing'), |
|
335 | - 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
336 | - 'SZ' => __('Swaziland', 'invoicing'), |
|
337 | - 'SE' => __('Sweden', 'invoicing'), |
|
338 | - 'CH' => __('Switzerland', 'invoicing'), |
|
339 | - 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
340 | - 'TW' => __('Taiwan', 'invoicing'), |
|
341 | - 'TJ' => __('Tajikistan', 'invoicing'), |
|
342 | - 'TZ' => __('Tanzania', 'invoicing'), |
|
343 | - 'TH' => __('Thailand', 'invoicing'), |
|
344 | - 'TL' => __('Timor-Leste', 'invoicing'), |
|
345 | - 'TG' => __('Togo', 'invoicing'), |
|
346 | - 'TK' => __('Tokelau', 'invoicing'), |
|
347 | - 'TO' => __('Tonga', 'invoicing'), |
|
348 | - 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
349 | - 'TN' => __('Tunisia', 'invoicing'), |
|
350 | - 'TR' => __('Turkey', 'invoicing'), |
|
351 | - 'TM' => __('Turkmenistan', 'invoicing'), |
|
352 | - 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
353 | - 'TV' => __('Tuvalu', 'invoicing'), |
|
354 | - 'UG' => __('Uganda', 'invoicing'), |
|
355 | - 'UA' => __('Ukraine', 'invoicing'), |
|
356 | - 'AE' => __('United Arab Emirates', 'invoicing'), |
|
357 | - 'UY' => __('Uruguay', 'invoicing'), |
|
358 | - 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
359 | - 'UZ' => __('Uzbekistan', 'invoicing'), |
|
360 | - 'VU' => __('Vanuatu', 'invoicing'), |
|
361 | - 'VE' => __('Venezuela', 'invoicing'), |
|
362 | - 'VN' => __('Vietnam', 'invoicing'), |
|
363 | - 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
364 | - 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
365 | - 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
366 | - 'EH' => __('Western Sahara', 'invoicing'), |
|
367 | - 'WS' => __('Western Samoa', 'invoicing'), |
|
368 | - 'YE' => __('Yemen', 'invoicing'), |
|
369 | - 'ZM' => __('Zambia', 'invoicing'), |
|
370 | - 'ZW' => __('Zimbabwe', 'invoicing'), |
|
371 | - ); |
|
118 | + $countries = array( |
|
119 | + 'US' => __('United States', 'invoicing'), |
|
120 | + 'CA' => __('Canada', 'invoicing'), |
|
121 | + 'GB' => __('United Kingdom', 'invoicing'), |
|
122 | + 'AF' => __('Afghanistan', 'invoicing'), |
|
123 | + 'AX' => __('Aland Islands', 'invoicing'), |
|
124 | + 'AL' => __('Albania', 'invoicing'), |
|
125 | + 'DZ' => __('Algeria', 'invoicing'), |
|
126 | + 'AS' => __('American Samoa', 'invoicing'), |
|
127 | + 'AD' => __('Andorra', 'invoicing'), |
|
128 | + 'AO' => __('Angola', 'invoicing'), |
|
129 | + 'AI' => __('Anguilla', 'invoicing'), |
|
130 | + 'AQ' => __('Antarctica', 'invoicing'), |
|
131 | + 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
132 | + 'AR' => __('Argentina', 'invoicing'), |
|
133 | + 'AM' => __('Armenia', 'invoicing'), |
|
134 | + 'AW' => __('Aruba', 'invoicing'), |
|
135 | + 'AU' => __('Australia', 'invoicing'), |
|
136 | + 'AT' => __('Austria', 'invoicing'), |
|
137 | + 'AZ' => __('Azerbaijan', 'invoicing'), |
|
138 | + 'BS' => __('Bahamas', 'invoicing'), |
|
139 | + 'BH' => __('Bahrain', 'invoicing'), |
|
140 | + 'BD' => __('Bangladesh', 'invoicing'), |
|
141 | + 'BB' => __('Barbados', 'invoicing'), |
|
142 | + 'BY' => __('Belarus', 'invoicing'), |
|
143 | + 'BE' => __('Belgium', 'invoicing'), |
|
144 | + 'BZ' => __('Belize', 'invoicing'), |
|
145 | + 'BJ' => __('Benin', 'invoicing'), |
|
146 | + 'BM' => __('Bermuda', 'invoicing'), |
|
147 | + 'BT' => __('Bhutan', 'invoicing'), |
|
148 | + 'BO' => __('Bolivia', 'invoicing'), |
|
149 | + 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
150 | + 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
151 | + 'BW' => __('Botswana', 'invoicing'), |
|
152 | + 'BV' => __('Bouvet Island', 'invoicing'), |
|
153 | + 'BR' => __('Brazil', 'invoicing'), |
|
154 | + 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
155 | + 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
156 | + 'BG' => __('Bulgaria', 'invoicing'), |
|
157 | + 'BF' => __('Burkina Faso', 'invoicing'), |
|
158 | + 'BI' => __('Burundi', 'invoicing'), |
|
159 | + 'KH' => __('Cambodia', 'invoicing'), |
|
160 | + 'CM' => __('Cameroon', 'invoicing'), |
|
161 | + 'CV' => __('Cape Verde', 'invoicing'), |
|
162 | + 'KY' => __('Cayman Islands', 'invoicing'), |
|
163 | + 'CF' => __('Central African Republic', 'invoicing'), |
|
164 | + 'TD' => __('Chad', 'invoicing'), |
|
165 | + 'CL' => __('Chile', 'invoicing'), |
|
166 | + 'CN' => __('China', 'invoicing'), |
|
167 | + 'CX' => __('Christmas Island', 'invoicing'), |
|
168 | + 'CC' => __('Cocos Islands', 'invoicing'), |
|
169 | + 'CO' => __('Colombia', 'invoicing'), |
|
170 | + 'KM' => __('Comoros', 'invoicing'), |
|
171 | + 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
172 | + 'CG' => __('Congo, Republic of', 'invoicing'), |
|
173 | + 'CK' => __('Cook Islands', 'invoicing'), |
|
174 | + 'CR' => __('Costa Rica', 'invoicing'), |
|
175 | + 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
176 | + 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
177 | + 'CU' => __('Cuba', 'invoicing'), |
|
178 | + 'CW' => __('CuraÇao', 'invoicing'), |
|
179 | + 'CY' => __('Cyprus', 'invoicing'), |
|
180 | + 'CZ' => __('Czech Republic', 'invoicing'), |
|
181 | + 'DK' => __('Denmark', 'invoicing'), |
|
182 | + 'DJ' => __('Djibouti', 'invoicing'), |
|
183 | + 'DM' => __('Dominica', 'invoicing'), |
|
184 | + 'DO' => __('Dominican Republic', 'invoicing'), |
|
185 | + 'TP' => __('East Timor', 'invoicing'), |
|
186 | + 'EC' => __('Ecuador', 'invoicing'), |
|
187 | + 'EG' => __('Egypt', 'invoicing'), |
|
188 | + 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
189 | + 'SV' => __('El Salvador', 'invoicing'), |
|
190 | + 'ER' => __('Eritrea', 'invoicing'), |
|
191 | + 'EE' => __('Estonia', 'invoicing'), |
|
192 | + 'ET' => __('Ethiopia', 'invoicing'), |
|
193 | + 'FK' => __('Falkland Islands', 'invoicing'), |
|
194 | + 'FO' => __('Faroe Islands', 'invoicing'), |
|
195 | + 'FJ' => __('Fiji', 'invoicing'), |
|
196 | + 'FI' => __('Finland', 'invoicing'), |
|
197 | + 'FR' => __('France', 'invoicing'), |
|
198 | + 'GF' => __('French Guiana', 'invoicing'), |
|
199 | + 'PF' => __('French Polynesia', 'invoicing'), |
|
200 | + 'TF' => __('French Southern Territories', 'invoicing'), |
|
201 | + 'GA' => __('Gabon', 'invoicing'), |
|
202 | + 'GM' => __('Gambia', 'invoicing'), |
|
203 | + 'GE' => __('Georgia', 'invoicing'), |
|
204 | + 'DE' => __('Germany', 'invoicing'), |
|
205 | + 'GR' => __('Greece', 'invoicing'), |
|
206 | + 'GH' => __('Ghana', 'invoicing'), |
|
207 | + 'GI' => __('Gibraltar', 'invoicing'), |
|
208 | + 'GL' => __('Greenland', 'invoicing'), |
|
209 | + 'GD' => __('Grenada', 'invoicing'), |
|
210 | + 'GP' => __('Guadeloupe', 'invoicing'), |
|
211 | + 'GU' => __('Guam', 'invoicing'), |
|
212 | + 'GT' => __('Guatemala', 'invoicing'), |
|
213 | + 'GG' => __('Guernsey', 'invoicing'), |
|
214 | + 'GN' => __('Guinea', 'invoicing'), |
|
215 | + 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
216 | + 'GY' => __('Guyana', 'invoicing'), |
|
217 | + 'HT' => __('Haiti', 'invoicing'), |
|
218 | + 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
219 | + 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
220 | + 'HN' => __('Honduras', 'invoicing'), |
|
221 | + 'HK' => __('Hong Kong', 'invoicing'), |
|
222 | + 'HU' => __('Hungary', 'invoicing'), |
|
223 | + 'IS' => __('Iceland', 'invoicing'), |
|
224 | + 'IN' => __('India', 'invoicing'), |
|
225 | + 'ID' => __('Indonesia', 'invoicing'), |
|
226 | + 'IR' => __('Iran', 'invoicing'), |
|
227 | + 'IQ' => __('Iraq', 'invoicing'), |
|
228 | + 'IE' => __('Ireland', 'invoicing'), |
|
229 | + 'IM' => __('Isle of Man', 'invoicing'), |
|
230 | + 'IL' => __('Israel', 'invoicing'), |
|
231 | + 'IT' => __('Italy', 'invoicing'), |
|
232 | + 'JM' => __('Jamaica', 'invoicing'), |
|
233 | + 'JP' => __('Japan', 'invoicing'), |
|
234 | + 'JE' => __('Jersey', 'invoicing'), |
|
235 | + 'JO' => __('Jordan', 'invoicing'), |
|
236 | + 'KZ' => __('Kazakhstan', 'invoicing'), |
|
237 | + 'KE' => __('Kenya', 'invoicing'), |
|
238 | + 'KI' => __('Kiribati', 'invoicing'), |
|
239 | + 'KW' => __('Kuwait', 'invoicing'), |
|
240 | + 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
241 | + 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
242 | + 'LV' => __('Latvia', 'invoicing'), |
|
243 | + 'LB' => __('Lebanon', 'invoicing'), |
|
244 | + 'LS' => __('Lesotho', 'invoicing'), |
|
245 | + 'LR' => __('Liberia', 'invoicing'), |
|
246 | + 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
247 | + 'LI' => __('Liechtenstein', 'invoicing'), |
|
248 | + 'LT' => __('Lithuania', 'invoicing'), |
|
249 | + 'LU' => __('Luxembourg', 'invoicing'), |
|
250 | + 'MO' => __('Macau', 'invoicing'), |
|
251 | + 'MK' => __('Macedonia', 'invoicing'), |
|
252 | + 'MG' => __('Madagascar', 'invoicing'), |
|
253 | + 'MW' => __('Malawi', 'invoicing'), |
|
254 | + 'MY' => __('Malaysia', 'invoicing'), |
|
255 | + 'MV' => __('Maldives', 'invoicing'), |
|
256 | + 'ML' => __('Mali', 'invoicing'), |
|
257 | + 'MT' => __('Malta', 'invoicing'), |
|
258 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
259 | + 'MQ' => __('Martinique', 'invoicing'), |
|
260 | + 'MR' => __('Mauritania', 'invoicing'), |
|
261 | + 'MU' => __('Mauritius', 'invoicing'), |
|
262 | + 'YT' => __('Mayotte', 'invoicing'), |
|
263 | + 'MX' => __('Mexico', 'invoicing'), |
|
264 | + 'FM' => __('Micronesia', 'invoicing'), |
|
265 | + 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
266 | + 'MC' => __('Monaco', 'invoicing'), |
|
267 | + 'MN' => __('Mongolia', 'invoicing'), |
|
268 | + 'ME' => __('Montenegro', 'invoicing'), |
|
269 | + 'MS' => __('Montserrat', 'invoicing'), |
|
270 | + 'MA' => __('Morocco', 'invoicing'), |
|
271 | + 'MZ' => __('Mozambique', 'invoicing'), |
|
272 | + 'MM' => __('Myanmar', 'invoicing'), |
|
273 | + 'NA' => __('Namibia', 'invoicing'), |
|
274 | + 'NR' => __('Nauru', 'invoicing'), |
|
275 | + 'NP' => __('Nepal', 'invoicing'), |
|
276 | + 'NL' => __('Netherlands', 'invoicing'), |
|
277 | + 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
278 | + 'NC' => __('New Caledonia', 'invoicing'), |
|
279 | + 'NZ' => __('New Zealand', 'invoicing'), |
|
280 | + 'NI' => __('Nicaragua', 'invoicing'), |
|
281 | + 'NE' => __('Niger', 'invoicing'), |
|
282 | + 'NG' => __('Nigeria', 'invoicing'), |
|
283 | + 'NU' => __('Niue', 'invoicing'), |
|
284 | + 'NF' => __('Norfolk Island', 'invoicing'), |
|
285 | + 'KP' => __('North Korea', 'invoicing'), |
|
286 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
287 | + 'NO' => __('Norway', 'invoicing'), |
|
288 | + 'OM' => __('Oman', 'invoicing'), |
|
289 | + 'PK' => __('Pakistan', 'invoicing'), |
|
290 | + 'PW' => __('Palau', 'invoicing'), |
|
291 | + 'PS' => __('Palestinian Territories', 'invoicing'), |
|
292 | + 'PA' => __('Panama', 'invoicing'), |
|
293 | + 'PG' => __('Papua New Guinea', 'invoicing'), |
|
294 | + 'PY' => __('Paraguay', 'invoicing'), |
|
295 | + 'PE' => __('Peru', 'invoicing'), |
|
296 | + 'PH' => __('Phillipines', 'invoicing'), |
|
297 | + 'PN' => __('Pitcairn Island', 'invoicing'), |
|
298 | + 'PL' => __('Poland', 'invoicing'), |
|
299 | + 'PT' => __('Portugal', 'invoicing'), |
|
300 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
301 | + 'QA' => __('Qatar', 'invoicing'), |
|
302 | + 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
303 | + 'RE' => __('Reunion Island', 'invoicing'), |
|
304 | + 'RO' => __('Romania', 'invoicing'), |
|
305 | + 'RU' => __('Russian Federation', 'invoicing'), |
|
306 | + 'RW' => __('Rwanda', 'invoicing'), |
|
307 | + 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
308 | + 'SH' => __('Saint Helena', 'invoicing'), |
|
309 | + 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
310 | + 'LC' => __('Saint Lucia', 'invoicing'), |
|
311 | + 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
312 | + 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
313 | + 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
314 | + 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
315 | + 'SM' => __('San Marino', 'invoicing'), |
|
316 | + 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
317 | + 'SA' => __('Saudi Arabia', 'invoicing'), |
|
318 | + 'SN' => __('Senegal', 'invoicing'), |
|
319 | + 'RS' => __('Serbia', 'invoicing'), |
|
320 | + 'SC' => __('Seychelles', 'invoicing'), |
|
321 | + 'SL' => __('Sierra Leone', 'invoicing'), |
|
322 | + 'SG' => __('Singapore', 'invoicing'), |
|
323 | + 'SK' => __('Slovak Republic', 'invoicing'), |
|
324 | + 'SI' => __('Slovenia', 'invoicing'), |
|
325 | + 'SB' => __('Solomon Islands', 'invoicing'), |
|
326 | + 'SO' => __('Somalia', 'invoicing'), |
|
327 | + 'ZA' => __('South Africa', 'invoicing'), |
|
328 | + 'GS' => __('South Georgia', 'invoicing'), |
|
329 | + 'KR' => __('South Korea', 'invoicing'), |
|
330 | + 'SS' => __('South Sudan', 'invoicing'), |
|
331 | + 'ES' => __('Spain', 'invoicing'), |
|
332 | + 'LK' => __('Sri Lanka', 'invoicing'), |
|
333 | + 'SD' => __('Sudan', 'invoicing'), |
|
334 | + 'SR' => __('Suriname', 'invoicing'), |
|
335 | + 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
336 | + 'SZ' => __('Swaziland', 'invoicing'), |
|
337 | + 'SE' => __('Sweden', 'invoicing'), |
|
338 | + 'CH' => __('Switzerland', 'invoicing'), |
|
339 | + 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
340 | + 'TW' => __('Taiwan', 'invoicing'), |
|
341 | + 'TJ' => __('Tajikistan', 'invoicing'), |
|
342 | + 'TZ' => __('Tanzania', 'invoicing'), |
|
343 | + 'TH' => __('Thailand', 'invoicing'), |
|
344 | + 'TL' => __('Timor-Leste', 'invoicing'), |
|
345 | + 'TG' => __('Togo', 'invoicing'), |
|
346 | + 'TK' => __('Tokelau', 'invoicing'), |
|
347 | + 'TO' => __('Tonga', 'invoicing'), |
|
348 | + 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
349 | + 'TN' => __('Tunisia', 'invoicing'), |
|
350 | + 'TR' => __('Turkey', 'invoicing'), |
|
351 | + 'TM' => __('Turkmenistan', 'invoicing'), |
|
352 | + 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
353 | + 'TV' => __('Tuvalu', 'invoicing'), |
|
354 | + 'UG' => __('Uganda', 'invoicing'), |
|
355 | + 'UA' => __('Ukraine', 'invoicing'), |
|
356 | + 'AE' => __('United Arab Emirates', 'invoicing'), |
|
357 | + 'UY' => __('Uruguay', 'invoicing'), |
|
358 | + 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
359 | + 'UZ' => __('Uzbekistan', 'invoicing'), |
|
360 | + 'VU' => __('Vanuatu', 'invoicing'), |
|
361 | + 'VE' => __('Venezuela', 'invoicing'), |
|
362 | + 'VN' => __('Vietnam', 'invoicing'), |
|
363 | + 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
364 | + 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
365 | + 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
366 | + 'EH' => __('Western Sahara', 'invoicing'), |
|
367 | + 'WS' => __('Western Samoa', 'invoicing'), |
|
368 | + 'YE' => __('Yemen', 'invoicing'), |
|
369 | + 'ZM' => __('Zambia', 'invoicing'), |
|
370 | + 'ZW' => __('Zimbabwe', 'invoicing'), |
|
371 | + ); |
|
372 | 372 | |
373 | 373 | if ( $first_empty ) { |
374 | 374 | $countries = array_merge( array( '' => '' ), $countries ); |
@@ -1537,30 +1537,30 @@ discard block |
||
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | function wpinv_get_states_field() { |
1540 | - if( empty( $_POST['country'] ) ) { |
|
1541 | - $_POST['country'] = wpinv_get_default_country(); |
|
1542 | - } |
|
1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
1540 | + if( empty( $_POST['country'] ) ) { |
|
1541 | + $_POST['country'] = wpinv_get_default_country(); |
|
1542 | + } |
|
1543 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
1544 | 1544 | |
1545 | - if( !empty( $states ) ) { |
|
1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
1545 | + if( !empty( $states ) ) { |
|
1546 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
1547 | 1547 | |
1548 | 1548 | $args = array( |
1549 | - 'name' => $sanitized_field_name, |
|
1550 | - 'id' => $sanitized_field_name, |
|
1551 | - 'class' => $sanitized_field_name . ' wpinv-select wpi_select2', |
|
1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1553 | - 'show_option_all' => false, |
|
1554 | - 'show_option_none' => false |
|
1555 | - ); |
|
1556 | - |
|
1557 | - $response = wpinv_html_select( $args ); |
|
1558 | - |
|
1559 | - } else { |
|
1560 | - $response = 'nostates'; |
|
1561 | - } |
|
1549 | + 'name' => $sanitized_field_name, |
|
1550 | + 'id' => $sanitized_field_name, |
|
1551 | + 'class' => $sanitized_field_name . ' wpinv-select wpi_select2', |
|
1552 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
1553 | + 'show_option_all' => false, |
|
1554 | + 'show_option_none' => false |
|
1555 | + ); |
|
1556 | + |
|
1557 | + $response = wpinv_html_select( $args ); |
|
1558 | + |
|
1559 | + } else { |
|
1560 | + $response = 'nostates'; |
|
1561 | + } |
|
1562 | 1562 | |
1563 | - return $response; |
|
1563 | + return $response; |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | 1566 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
16 | - exit; |
|
16 | + exit; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -21,294 +21,294 @@ discard block |
||
21 | 21 | */ |
22 | 22 | if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) { |
23 | 23 | |
24 | - /** |
|
25 | - * A Class to be able to change settings for Font Awesome. |
|
26 | - * |
|
27 | - * Class WP_Font_Awesome_Settings |
|
28 | - * @since 1.0.10 Now able to pass wp.org theme check. |
|
29 | - * @since 1.0.11 Font Awesome Pro now supported. |
|
30 | - * @since 1.0.11 Font Awesome Kits now supported. |
|
31 | - * @ver 1.0.11 |
|
32 | - * @todo decide how to implement textdomain |
|
33 | - */ |
|
34 | - class WP_Font_Awesome_Settings { |
|
35 | - |
|
36 | - /** |
|
37 | - * Class version version. |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - public $version = '1.0.11'; |
|
42 | - |
|
43 | - /** |
|
44 | - * Class textdomain. |
|
45 | - * |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - public $textdomain = 'font-awesome-settings'; |
|
49 | - |
|
50 | - /** |
|
51 | - * Latest version of Font Awesome at time of publish published. |
|
52 | - * |
|
53 | - * @var string |
|
54 | - */ |
|
55 | - public $latest = "5.8.2"; |
|
56 | - |
|
57 | - /** |
|
58 | - * The title. |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - public $name = 'Font Awesome'; |
|
63 | - |
|
64 | - /** |
|
65 | - * Holds the settings values. |
|
66 | - * |
|
67 | - * @var array |
|
68 | - */ |
|
69 | - private $settings; |
|
70 | - |
|
71 | - /** |
|
72 | - * WP_Font_Awesome_Settings instance. |
|
73 | - * |
|
74 | - * @access private |
|
75 | - * @since 1.0.0 |
|
76 | - * @var WP_Font_Awesome_Settings There can be only one! |
|
77 | - */ |
|
78 | - private static $instance = null; |
|
79 | - |
|
80 | - /** |
|
81 | - * Main WP_Font_Awesome_Settings Instance. |
|
82 | - * |
|
83 | - * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded. |
|
84 | - * |
|
85 | - * @since 1.0.0 |
|
86 | - * @static |
|
87 | - * @return WP_Font_Awesome_Settings - Main instance. |
|
88 | - */ |
|
89 | - public static function instance() { |
|
90 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
91 | - self::$instance = new WP_Font_Awesome_Settings; |
|
92 | - |
|
93 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
94 | - |
|
95 | - if ( is_admin() ) { |
|
96 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
97 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
98 | - } |
|
99 | - |
|
100 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
101 | - } |
|
102 | - |
|
103 | - return self::$instance; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Initiate the settings and add the required action hooks. |
|
108 | - * |
|
109 | - * @since 1.0.8 Settings name wrong - FIXED |
|
110 | - */ |
|
111 | - public function init() { |
|
112 | - $this->settings = $this->get_settings(); |
|
113 | - |
|
114 | - if ( $this->settings['type'] == 'CSS' ) { |
|
115 | - |
|
116 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
117 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
118 | - } |
|
119 | - |
|
120 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
121 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
122 | - } |
|
123 | - |
|
124 | - } else { |
|
125 | - |
|
126 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
128 | - } |
|
129 | - |
|
130 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
131 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - // remove font awesome if set to do so |
|
136 | - if ( $this->settings['dequeue'] == '1' ) { |
|
137 | - add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
138 | - } |
|
139 | - |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Adds the Font Awesome styles. |
|
144 | - */ |
|
145 | - public function enqueue_style() { |
|
146 | - // build url |
|
147 | - $url = $this->get_url(); |
|
148 | - |
|
149 | - wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
150 | - wp_register_style( 'font-awesome', $url, array(), null ); |
|
151 | - wp_enqueue_style( 'font-awesome' ); |
|
152 | - |
|
153 | - if ( $this->settings['shims'] ) { |
|
154 | - $url = $this->get_url( true ); |
|
155 | - wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
156 | - wp_register_style( 'font-awesome-shims', $url, array(), null ); |
|
157 | - wp_enqueue_style( 'font-awesome-shims' ); |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Adds the Font Awesome JS. |
|
163 | - */ |
|
164 | - public function enqueue_scripts() { |
|
165 | - // build url |
|
166 | - $url = $this->get_url(); |
|
167 | - |
|
168 | - $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
|
169 | - call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
170 | - wp_register_script( 'font-awesome', $url, array(), null ); |
|
171 | - wp_enqueue_script( 'font-awesome' ); |
|
172 | - |
|
173 | - if ( $this->settings['shims'] ) { |
|
174 | - $url = $this->get_url( true ); |
|
175 | - call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
176 | - wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
177 | - wp_enqueue_script( 'font-awesome-shims' ); |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Get the url of the Font Awesome files. |
|
183 | - * |
|
184 | - * @param bool $shims If this is a shim file or not. |
|
185 | - * |
|
186 | - * @return string The url to the file. |
|
187 | - */ |
|
188 | - public function get_url( $shims = false ) { |
|
189 | - $script = $shims ? 'v4-shims' : 'all'; |
|
190 | - $sub = $this->settings['pro'] ? 'pro' : 'use'; |
|
191 | - $type = $this->settings['type']; |
|
192 | - $version = $this->settings['version']; |
|
193 | - $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
194 | - $url = ''; |
|
195 | - |
|
196 | - if ( $type == 'KIT' && $kit_url ) { |
|
197 | - if ( $shims ) { |
|
198 | - // if its a kit then we don't add shims here |
|
199 | - return ''; |
|
200 | - } |
|
201 | - $url .= $kit_url; // CDN |
|
202 | - $url .= "?wpfas=true"; // set our var so our version is not removed |
|
203 | - } else { |
|
204 | - $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
|
205 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
206 | - $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
|
207 | - $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
|
208 | - $url .= "?wpfas=true"; // set our var so our version is not removed |
|
209 | - } |
|
210 | - |
|
211 | - return $url; |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Try and remove any other versions of Font Awesome added by other plugins/themes. |
|
216 | - * |
|
217 | - * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version. |
|
218 | - * |
|
219 | - * @param $url |
|
220 | - * @param $original_url |
|
221 | - * @param $_context |
|
222 | - * |
|
223 | - * @return string The filtered url. |
|
224 | - */ |
|
225 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
226 | - |
|
227 | - if ( $_context == 'display' |
|
228 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
229 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
230 | - ) {// it's a font-awesome-url (probably) |
|
231 | - |
|
232 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
233 | - if ( $this->settings['type'] == 'JS' ) { |
|
234 | - if ( $this->settings['js-pseudo'] ) { |
|
235 | - $url .= "' data-search-pseudo-elements defer='defer"; |
|
236 | - } else { |
|
237 | - $url .= "' defer='defer"; |
|
238 | - } |
|
239 | - } |
|
240 | - } else { |
|
241 | - $url = ''; // removing the url removes the file |
|
242 | - } |
|
243 | - |
|
244 | - } |
|
245 | - |
|
246 | - return $url; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Register the database settings with WordPress. |
|
251 | - */ |
|
252 | - public function register_settings() { |
|
253 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Add the WordPress settings menu item. |
|
258 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
259 | - */ |
|
260 | - public function menu_item() { |
|
261 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
262 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
263 | - $this, |
|
264 | - 'settings_page' |
|
265 | - ) ); |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * Get the current Font Awesome output settings. |
|
270 | - * |
|
271 | - * @return array The array of settings. |
|
272 | - */ |
|
273 | - public function get_settings() { |
|
274 | - |
|
275 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
276 | - |
|
277 | - $defaults = array( |
|
278 | - 'type' => 'CSS', // type to use, CSS or JS or KIT |
|
279 | - 'version' => '', // latest |
|
280 | - 'enqueue' => '', // front and backend |
|
281 | - 'shims' => '1', // default on for now, @todo maybe change to off in 2020 |
|
282 | - 'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive) |
|
283 | - 'dequeue' => '0', // if we should try to remove other versions added by other plugins/themes |
|
284 | - 'pro' => '0', // if pro CDN url should be used |
|
285 | - 'kit-url' => '', // the kit url |
|
286 | - ); |
|
287 | - |
|
288 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
289 | - |
|
290 | - /** |
|
291 | - * Filter the Font Awesome settings. |
|
292 | - * |
|
293 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
294 | - */ |
|
295 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * The settings page html output. |
|
301 | - */ |
|
302 | - public function settings_page() { |
|
303 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
304 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
305 | - } |
|
306 | - |
|
307 | - // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours |
|
308 | - if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
309 | - $this->get_latest_version( $force_api = true ); |
|
310 | - } |
|
311 | - ?> |
|
24 | + /** |
|
25 | + * A Class to be able to change settings for Font Awesome. |
|
26 | + * |
|
27 | + * Class WP_Font_Awesome_Settings |
|
28 | + * @since 1.0.10 Now able to pass wp.org theme check. |
|
29 | + * @since 1.0.11 Font Awesome Pro now supported. |
|
30 | + * @since 1.0.11 Font Awesome Kits now supported. |
|
31 | + * @ver 1.0.11 |
|
32 | + * @todo decide how to implement textdomain |
|
33 | + */ |
|
34 | + class WP_Font_Awesome_Settings { |
|
35 | + |
|
36 | + /** |
|
37 | + * Class version version. |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + public $version = '1.0.11'; |
|
42 | + |
|
43 | + /** |
|
44 | + * Class textdomain. |
|
45 | + * |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + public $textdomain = 'font-awesome-settings'; |
|
49 | + |
|
50 | + /** |
|
51 | + * Latest version of Font Awesome at time of publish published. |
|
52 | + * |
|
53 | + * @var string |
|
54 | + */ |
|
55 | + public $latest = "5.8.2"; |
|
56 | + |
|
57 | + /** |
|
58 | + * The title. |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + public $name = 'Font Awesome'; |
|
63 | + |
|
64 | + /** |
|
65 | + * Holds the settings values. |
|
66 | + * |
|
67 | + * @var array |
|
68 | + */ |
|
69 | + private $settings; |
|
70 | + |
|
71 | + /** |
|
72 | + * WP_Font_Awesome_Settings instance. |
|
73 | + * |
|
74 | + * @access private |
|
75 | + * @since 1.0.0 |
|
76 | + * @var WP_Font_Awesome_Settings There can be only one! |
|
77 | + */ |
|
78 | + private static $instance = null; |
|
79 | + |
|
80 | + /** |
|
81 | + * Main WP_Font_Awesome_Settings Instance. |
|
82 | + * |
|
83 | + * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded. |
|
84 | + * |
|
85 | + * @since 1.0.0 |
|
86 | + * @static |
|
87 | + * @return WP_Font_Awesome_Settings - Main instance. |
|
88 | + */ |
|
89 | + public static function instance() { |
|
90 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
91 | + self::$instance = new WP_Font_Awesome_Settings; |
|
92 | + |
|
93 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
94 | + |
|
95 | + if ( is_admin() ) { |
|
96 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
97 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
98 | + } |
|
99 | + |
|
100 | + do_action( 'wp_font_awesome_settings_loaded' ); |
|
101 | + } |
|
102 | + |
|
103 | + return self::$instance; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Initiate the settings and add the required action hooks. |
|
108 | + * |
|
109 | + * @since 1.0.8 Settings name wrong - FIXED |
|
110 | + */ |
|
111 | + public function init() { |
|
112 | + $this->settings = $this->get_settings(); |
|
113 | + |
|
114 | + if ( $this->settings['type'] == 'CSS' ) { |
|
115 | + |
|
116 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
117 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
118 | + } |
|
119 | + |
|
120 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
121 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
122 | + } |
|
123 | + |
|
124 | + } else { |
|
125 | + |
|
126 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
127 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
128 | + } |
|
129 | + |
|
130 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
131 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + // remove font awesome if set to do so |
|
136 | + if ( $this->settings['dequeue'] == '1' ) { |
|
137 | + add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
138 | + } |
|
139 | + |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Adds the Font Awesome styles. |
|
144 | + */ |
|
145 | + public function enqueue_style() { |
|
146 | + // build url |
|
147 | + $url = $this->get_url(); |
|
148 | + |
|
149 | + wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
150 | + wp_register_style( 'font-awesome', $url, array(), null ); |
|
151 | + wp_enqueue_style( 'font-awesome' ); |
|
152 | + |
|
153 | + if ( $this->settings['shims'] ) { |
|
154 | + $url = $this->get_url( true ); |
|
155 | + wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
156 | + wp_register_style( 'font-awesome-shims', $url, array(), null ); |
|
157 | + wp_enqueue_style( 'font-awesome-shims' ); |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Adds the Font Awesome JS. |
|
163 | + */ |
|
164 | + public function enqueue_scripts() { |
|
165 | + // build url |
|
166 | + $url = $this->get_url(); |
|
167 | + |
|
168 | + $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
|
169 | + call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
170 | + wp_register_script( 'font-awesome', $url, array(), null ); |
|
171 | + wp_enqueue_script( 'font-awesome' ); |
|
172 | + |
|
173 | + if ( $this->settings['shims'] ) { |
|
174 | + $url = $this->get_url( true ); |
|
175 | + call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
176 | + wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
177 | + wp_enqueue_script( 'font-awesome-shims' ); |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Get the url of the Font Awesome files. |
|
183 | + * |
|
184 | + * @param bool $shims If this is a shim file or not. |
|
185 | + * |
|
186 | + * @return string The url to the file. |
|
187 | + */ |
|
188 | + public function get_url( $shims = false ) { |
|
189 | + $script = $shims ? 'v4-shims' : 'all'; |
|
190 | + $sub = $this->settings['pro'] ? 'pro' : 'use'; |
|
191 | + $type = $this->settings['type']; |
|
192 | + $version = $this->settings['version']; |
|
193 | + $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
194 | + $url = ''; |
|
195 | + |
|
196 | + if ( $type == 'KIT' && $kit_url ) { |
|
197 | + if ( $shims ) { |
|
198 | + // if its a kit then we don't add shims here |
|
199 | + return ''; |
|
200 | + } |
|
201 | + $url .= $kit_url; // CDN |
|
202 | + $url .= "?wpfas=true"; // set our var so our version is not removed |
|
203 | + } else { |
|
204 | + $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
|
205 | + $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
206 | + $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
|
207 | + $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
|
208 | + $url .= "?wpfas=true"; // set our var so our version is not removed |
|
209 | + } |
|
210 | + |
|
211 | + return $url; |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Try and remove any other versions of Font Awesome added by other plugins/themes. |
|
216 | + * |
|
217 | + * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version. |
|
218 | + * |
|
219 | + * @param $url |
|
220 | + * @param $original_url |
|
221 | + * @param $_context |
|
222 | + * |
|
223 | + * @return string The filtered url. |
|
224 | + */ |
|
225 | + public function remove_font_awesome( $url, $original_url, $_context ) { |
|
226 | + |
|
227 | + if ( $_context == 'display' |
|
228 | + && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
229 | + && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
230 | + ) {// it's a font-awesome-url (probably) |
|
231 | + |
|
232 | + if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
233 | + if ( $this->settings['type'] == 'JS' ) { |
|
234 | + if ( $this->settings['js-pseudo'] ) { |
|
235 | + $url .= "' data-search-pseudo-elements defer='defer"; |
|
236 | + } else { |
|
237 | + $url .= "' defer='defer"; |
|
238 | + } |
|
239 | + } |
|
240 | + } else { |
|
241 | + $url = ''; // removing the url removes the file |
|
242 | + } |
|
243 | + |
|
244 | + } |
|
245 | + |
|
246 | + return $url; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Register the database settings with WordPress. |
|
251 | + */ |
|
252 | + public function register_settings() { |
|
253 | + register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Add the WordPress settings menu item. |
|
258 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
259 | + */ |
|
260 | + public function menu_item() { |
|
261 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
262 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
263 | + $this, |
|
264 | + 'settings_page' |
|
265 | + ) ); |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * Get the current Font Awesome output settings. |
|
270 | + * |
|
271 | + * @return array The array of settings. |
|
272 | + */ |
|
273 | + public function get_settings() { |
|
274 | + |
|
275 | + $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
276 | + |
|
277 | + $defaults = array( |
|
278 | + 'type' => 'CSS', // type to use, CSS or JS or KIT |
|
279 | + 'version' => '', // latest |
|
280 | + 'enqueue' => '', // front and backend |
|
281 | + 'shims' => '1', // default on for now, @todo maybe change to off in 2020 |
|
282 | + 'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive) |
|
283 | + 'dequeue' => '0', // if we should try to remove other versions added by other plugins/themes |
|
284 | + 'pro' => '0', // if pro CDN url should be used |
|
285 | + 'kit-url' => '', // the kit url |
|
286 | + ); |
|
287 | + |
|
288 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
289 | + |
|
290 | + /** |
|
291 | + * Filter the Font Awesome settings. |
|
292 | + * |
|
293 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
294 | + */ |
|
295 | + return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * The settings page html output. |
|
301 | + */ |
|
302 | + public function settings_page() { |
|
303 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
304 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
305 | + } |
|
306 | + |
|
307 | + // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours |
|
308 | + if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
309 | + $this->get_latest_version( $force_api = true ); |
|
310 | + } |
|
311 | + ?> |
|
312 | 312 | <style> |
313 | 313 | .wpfas-kit-show { |
314 | 314 | display: none; |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | <h1><?php echo $this->name; ?></h1> |
327 | 327 | <form method="post" action="options.php"> |
328 | 328 | <?php |
329 | - settings_fields( 'wp-font-awesome-settings' ); |
|
330 | - do_settings_sections( 'wp-font-awesome-settings' ); |
|
331 | - $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : ''; |
|
332 | - ?> |
|
329 | + settings_fields( 'wp-font-awesome-settings' ); |
|
330 | + do_settings_sections( 'wp-font-awesome-settings' ); |
|
331 | + $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : ''; |
|
332 | + ?> |
|
333 | 333 | <table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>"> |
334 | 334 | <tr valign="top"> |
335 | 335 | <th scope="row"><label |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" |
356 | 356 | placeholder="https://kit.fontawesome.com/123abc.js"/> |
357 | 357 | <span><?php |
358 | - echo sprintf( |
|
359 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
360 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
|
361 | - '</a>' |
|
362 | - ); |
|
363 | - ?></span> |
|
358 | + echo sprintf( |
|
359 | + __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
360 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
|
361 | + '</a>' |
|
362 | + ); |
|
363 | + ?></span> |
|
364 | 364 | </td> |
365 | 365 | </tr> |
366 | 366 | |
@@ -420,14 +420,14 @@ discard block |
||
420 | 420 | <input type="checkbox" name="wp-font-awesome-settings[pro]" |
421 | 421 | value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/> |
422 | 422 | <span><?php |
423 | - echo sprintf( |
|
424 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
425 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>', |
|
426 | - '</a>', |
|
427 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>', |
|
428 | - '</a>' |
|
429 | - ); |
|
430 | - ?></span> |
|
423 | + echo sprintf( |
|
424 | + __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
425 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>', |
|
426 | + '</a>', |
|
427 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>', |
|
428 | + '</a>' |
|
429 | + ); |
|
430 | + ?></span> |
|
431 | 431 | </td> |
432 | 432 | </tr> |
433 | 433 | |
@@ -470,88 +470,88 @@ discard block |
||
470 | 470 | |
471 | 471 | </table> |
472 | 472 | <?php |
473 | - submit_button(); |
|
474 | - ?> |
|
473 | + submit_button(); |
|
474 | + ?> |
|
475 | 475 | </form> |
476 | 476 | |
477 | 477 | <div id="wpfas-version"><?php echo $this->version; ?></div> |
478 | 478 | </div> |
479 | 479 | |
480 | 480 | <?php |
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Check a version number is valid and if so return it or else return an empty string. |
|
485 | - * |
|
486 | - * @param $version string The version number to check. |
|
487 | - * |
|
488 | - * @since 1.0.6 |
|
489 | - * |
|
490 | - * @return string Either a valid version number or an empty string. |
|
491 | - */ |
|
492 | - public function validate_version_number( $version ) { |
|
493 | - |
|
494 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
495 | - // valid |
|
496 | - } else { |
|
497 | - $version = '';// not validated |
|
498 | - } |
|
499 | - |
|
500 | - return $version; |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * Get the latest version of Font Awesome. |
|
506 | - * |
|
507 | - * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours. |
|
508 | - * |
|
509 | - * @since 1.0.7 |
|
510 | - * @return mixed|string The latest version number found. |
|
511 | - */ |
|
512 | - public function get_latest_version( $force_api = false ) { |
|
513 | - $latest_version = $this->latest; |
|
514 | - |
|
515 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
516 | - |
|
517 | - if ( $cache === false || $force_api ) { // its not set |
|
518 | - $api_ver = $this->get_latest_version_from_api(); |
|
519 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
520 | - $latest_version = $api_ver; |
|
521 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
522 | - } |
|
523 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
524 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
525 | - $latest_version = $cache; |
|
526 | - } |
|
527 | - } |
|
528 | - |
|
529 | - return $latest_version; |
|
530 | - } |
|
531 | - |
|
532 | - /** |
|
533 | - * Get the latest Font Awesome version from the github API. |
|
534 | - * |
|
535 | - * @since 1.0.7 |
|
536 | - * @return string The latest version number or `0` on API fail. |
|
537 | - */ |
|
538 | - public function get_latest_version_from_api() { |
|
539 | - $version = "0"; |
|
540 | - $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
541 | - if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
542 | - $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
543 | - if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
544 | - $version = $api_response['tag_name']; |
|
545 | - } |
|
546 | - } |
|
547 | - |
|
548 | - return $version; |
|
549 | - } |
|
550 | - |
|
551 | - } |
|
552 | - |
|
553 | - /** |
|
554 | - * Run the class if found. |
|
555 | - */ |
|
556 | - WP_Font_Awesome_Settings::instance(); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Check a version number is valid and if so return it or else return an empty string. |
|
485 | + * |
|
486 | + * @param $version string The version number to check. |
|
487 | + * |
|
488 | + * @since 1.0.6 |
|
489 | + * |
|
490 | + * @return string Either a valid version number or an empty string. |
|
491 | + */ |
|
492 | + public function validate_version_number( $version ) { |
|
493 | + |
|
494 | + if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
495 | + // valid |
|
496 | + } else { |
|
497 | + $version = '';// not validated |
|
498 | + } |
|
499 | + |
|
500 | + return $version; |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * Get the latest version of Font Awesome. |
|
506 | + * |
|
507 | + * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours. |
|
508 | + * |
|
509 | + * @since 1.0.7 |
|
510 | + * @return mixed|string The latest version number found. |
|
511 | + */ |
|
512 | + public function get_latest_version( $force_api = false ) { |
|
513 | + $latest_version = $this->latest; |
|
514 | + |
|
515 | + $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
516 | + |
|
517 | + if ( $cache === false || $force_api ) { // its not set |
|
518 | + $api_ver = $this->get_latest_version_from_api(); |
|
519 | + if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
520 | + $latest_version = $api_ver; |
|
521 | + set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
522 | + } |
|
523 | + } elseif ( $this->validate_version_number( $cache ) ) { |
|
524 | + if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
525 | + $latest_version = $cache; |
|
526 | + } |
|
527 | + } |
|
528 | + |
|
529 | + return $latest_version; |
|
530 | + } |
|
531 | + |
|
532 | + /** |
|
533 | + * Get the latest Font Awesome version from the github API. |
|
534 | + * |
|
535 | + * @since 1.0.7 |
|
536 | + * @return string The latest version number or `0` on API fail. |
|
537 | + */ |
|
538 | + public function get_latest_version_from_api() { |
|
539 | + $version = "0"; |
|
540 | + $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
541 | + if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
542 | + $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
543 | + if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
544 | + $version = $api_response['tag_name']; |
|
545 | + } |
|
546 | + } |
|
547 | + |
|
548 | + return $version; |
|
549 | + } |
|
550 | + |
|
551 | + } |
|
552 | + |
|
553 | + /** |
|
554 | + * Run the class if found. |
|
555 | + */ |
|
556 | + WP_Font_Awesome_Settings::instance(); |
|
557 | 557 | } |
558 | 558 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | */ |
5 | 5 | |
6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
7 | - exit; |
|
7 | + exit; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -12,112 +12,112 @@ discard block |
||
12 | 12 | */ |
13 | 13 | abstract class WPInv_Session { |
14 | 14 | |
15 | - /** |
|
16 | - * Customer ID. |
|
17 | - * |
|
18 | - * @var int $_customer_id Customer ID. |
|
19 | - */ |
|
20 | - protected $_customer_id; |
|
15 | + /** |
|
16 | + * Customer ID. |
|
17 | + * |
|
18 | + * @var int $_customer_id Customer ID. |
|
19 | + */ |
|
20 | + protected $_customer_id; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Session Data. |
|
24 | - * |
|
25 | - * @var array $_data Data array. |
|
26 | - */ |
|
27 | - protected $_data = array(); |
|
22 | + /** |
|
23 | + * Session Data. |
|
24 | + * |
|
25 | + * @var array $_data Data array. |
|
26 | + */ |
|
27 | + protected $_data = array(); |
|
28 | 28 | |
29 | - /** |
|
30 | - * Dirty when the session needs saving. |
|
31 | - * |
|
32 | - * @var bool $_dirty When something changes |
|
33 | - */ |
|
34 | - protected $_dirty = false; |
|
29 | + /** |
|
30 | + * Dirty when the session needs saving. |
|
31 | + * |
|
32 | + * @var bool $_dirty When something changes |
|
33 | + */ |
|
34 | + protected $_dirty = false; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Init hooks and session data. Extended by child classes. |
|
38 | - * |
|
39 | - * @since 3.3.0 |
|
40 | - */ |
|
41 | - public function init() {} |
|
36 | + /** |
|
37 | + * Init hooks and session data. Extended by child classes. |
|
38 | + * |
|
39 | + * @since 3.3.0 |
|
40 | + */ |
|
41 | + public function init() {} |
|
42 | 42 | |
43 | - /** |
|
44 | - * Cleanup session data. Extended by child classes. |
|
45 | - */ |
|
46 | - public function cleanup_sessions() {} |
|
43 | + /** |
|
44 | + * Cleanup session data. Extended by child classes. |
|
45 | + */ |
|
46 | + public function cleanup_sessions() {} |
|
47 | 47 | |
48 | - /** |
|
49 | - * Magic get method. |
|
50 | - * |
|
51 | - * @param mixed $key Key to get. |
|
52 | - * @return mixed |
|
53 | - */ |
|
54 | - public function __get( $key ) { |
|
55 | - return $this->get( $key ); |
|
56 | - } |
|
48 | + /** |
|
49 | + * Magic get method. |
|
50 | + * |
|
51 | + * @param mixed $key Key to get. |
|
52 | + * @return mixed |
|
53 | + */ |
|
54 | + public function __get( $key ) { |
|
55 | + return $this->get( $key ); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Magic set method. |
|
60 | - * |
|
61 | - * @param mixed $key Key to set. |
|
62 | - * @param mixed $value Value to set. |
|
63 | - */ |
|
64 | - public function __set( $key, $value ) { |
|
65 | - $this->set( $key, $value ); |
|
66 | - } |
|
58 | + /** |
|
59 | + * Magic set method. |
|
60 | + * |
|
61 | + * @param mixed $key Key to set. |
|
62 | + * @param mixed $value Value to set. |
|
63 | + */ |
|
64 | + public function __set( $key, $value ) { |
|
65 | + $this->set( $key, $value ); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Magic isset method. |
|
70 | - * |
|
71 | - * @param mixed $key Key to check. |
|
72 | - * @return bool |
|
73 | - */ |
|
74 | - public function __isset( $key ) { |
|
75 | - return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Magic isset method. |
|
70 | + * |
|
71 | + * @param mixed $key Key to check. |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | + public function __isset( $key ) { |
|
75 | + return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Magic unset method. |
|
80 | - * |
|
81 | - * @param mixed $key Key to unset. |
|
82 | - */ |
|
83 | - public function __unset( $key ) { |
|
84 | - if ( isset( $this->_data[ $key ] ) ) { |
|
85 | - unset( $this->_data[ $key ] ); |
|
86 | - $this->_dirty = true; |
|
87 | - } |
|
88 | - } |
|
78 | + /** |
|
79 | + * Magic unset method. |
|
80 | + * |
|
81 | + * @param mixed $key Key to unset. |
|
82 | + */ |
|
83 | + public function __unset( $key ) { |
|
84 | + if ( isset( $this->_data[ $key ] ) ) { |
|
85 | + unset( $this->_data[ $key ] ); |
|
86 | + $this->_dirty = true; |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Get a session variable. |
|
92 | - * |
|
93 | - * @param string $key Key to get. |
|
94 | - * @param mixed $default used if the session variable isn't set. |
|
95 | - * @return array|string value of session variable |
|
96 | - */ |
|
97 | - public function get( $key, $default = null ) { |
|
98 | - $key = sanitize_key( $key ); |
|
99 | - return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
100 | - } |
|
90 | + /** |
|
91 | + * Get a session variable. |
|
92 | + * |
|
93 | + * @param string $key Key to get. |
|
94 | + * @param mixed $default used if the session variable isn't set. |
|
95 | + * @return array|string value of session variable |
|
96 | + */ |
|
97 | + public function get( $key, $default = null ) { |
|
98 | + $key = sanitize_key( $key ); |
|
99 | + return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Set a session variable. |
|
104 | - * |
|
105 | - * @param string $key Key to set. |
|
106 | - * @param mixed $value Value to set. |
|
107 | - */ |
|
108 | - public function set( $key, $value ) { |
|
109 | - if ( $value !== $this->get( $key ) ) { |
|
110 | - $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
111 | - $this->_dirty = true; |
|
112 | - } |
|
113 | - } |
|
102 | + /** |
|
103 | + * Set a session variable. |
|
104 | + * |
|
105 | + * @param string $key Key to set. |
|
106 | + * @param mixed $value Value to set. |
|
107 | + */ |
|
108 | + public function set( $key, $value ) { |
|
109 | + if ( $value !== $this->get( $key ) ) { |
|
110 | + $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
111 | + $this->_dirty = true; |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Get customer ID. |
|
117 | - * |
|
118 | - * @return int |
|
119 | - */ |
|
120 | - public function get_customer_id() { |
|
121 | - return $this->_customer_id; |
|
122 | - } |
|
115 | + /** |
|
116 | + * Get customer ID. |
|
117 | + * |
|
118 | + * @return int |
|
119 | + */ |
|
120 | + public function get_customer_id() { |
|
121 | + return $this->_customer_id; |
|
122 | + } |
|
123 | 123 | } |
@@ -1355,10 +1355,10 @@ |
||
1355 | 1355 | $data['cart_details'][$key]['price'] = wpinv_round_amount( $item_total ); |
1356 | 1356 | } |
1357 | 1357 | |
1358 | - $total = $data['subtotal'] - $data['discount'] + $data['tax']; |
|
1359 | - if ( $total < 0 ) { |
|
1360 | - $total = 0; |
|
1361 | - } |
|
1358 | + $total = $data['subtotal'] - $data['discount'] + $data['tax']; |
|
1359 | + if ( $total < 0 ) { |
|
1360 | + $total = 0; |
|
1361 | + } |
|
1362 | 1362 | |
1363 | 1363 | $data['subtotal'] = wpinv_round_amount( $cart_subtotal ); |
1364 | 1364 | $data['discount'] = wpinv_round_amount( $cart_discount ); |