@@ -1,66 +1,66 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
7 | +function wpinv_get_option($key = '', $default = false) { |
|
8 | 8 | global $wpinv_options; |
9 | 9 | |
10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
12 | 12 | |
13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
14 | 14 | } |
15 | 15 | |
16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
16 | +function wpinv_update_option($key = '', $value = false) { |
|
17 | 17 | // If no key, exit |
18 | - if ( empty( $key ) ) { |
|
18 | + if (empty($key)) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | - if ( empty( $value ) ) { |
|
23 | - $remove_option = wpinv_delete_option( $key ); |
|
22 | + if (empty($value)) { |
|
23 | + $remove_option = wpinv_delete_option($key); |
|
24 | 24 | return $remove_option; |
25 | 25 | } |
26 | 26 | |
27 | 27 | // First let's grab the current settings |
28 | - $options = get_option( 'wpinv_settings' ); |
|
28 | + $options = get_option('wpinv_settings'); |
|
29 | 29 | |
30 | 30 | // Let other plugin alter the value |
31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
32 | 32 | |
33 | 33 | // Next let's try to update the value |
34 | - $options[ $key ] = $value; |
|
35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
34 | + $options[$key] = $value; |
|
35 | + $did_update = update_option('wpinv_settings', $options); |
|
36 | 36 | |
37 | 37 | // If it's updated, let's update the global variable |
38 | - if ( $did_update ) { |
|
38 | + if ($did_update) { |
|
39 | 39 | global $wpinv_options; |
40 | - $wpinv_options[ $key ] = $value; |
|
40 | + $wpinv_options[$key] = $value; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $did_update; |
44 | 44 | } |
45 | 45 | |
46 | -function wpinv_delete_option( $key = '' ) { |
|
46 | +function wpinv_delete_option($key = '') { |
|
47 | 47 | // If no key, exit |
48 | - if ( empty( $key ) ) { |
|
48 | + if (empty($key)) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // First let's grab the current settings |
53 | - $options = get_option( 'wpinv_settings' ); |
|
53 | + $options = get_option('wpinv_settings'); |
|
54 | 54 | |
55 | 55 | // Next let's try to update the value |
56 | - if( isset( $options[ $key ] ) ) { |
|
57 | - unset( $options[ $key ] ); |
|
56 | + if (isset($options[$key])) { |
|
57 | + unset($options[$key]); |
|
58 | 58 | } |
59 | 59 | |
60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
60 | + $did_update = update_option('wpinv_settings', $options); |
|
61 | 61 | |
62 | 62 | // If it updated, let's update the global variable |
63 | - if ( $did_update ){ |
|
63 | + if ($did_update) { |
|
64 | 64 | global $wpinv_options; |
65 | 65 | $wpinv_options = $options; |
66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_get_settings() { |
72 | - $settings = get_option( 'wpinv_settings' ); |
|
72 | + $settings = get_option('wpinv_settings'); |
|
73 | 73 | |
74 | - if ( empty( $settings ) ) { |
|
74 | + if (empty($settings)) { |
|
75 | 75 | // Update old settings with new single option |
76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
82 | 82 | |
83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
84 | 84 | |
85 | - update_option( 'wpinv_settings', $settings ); |
|
85 | + update_option('wpinv_settings', $settings); |
|
86 | 86 | |
87 | 87 | } |
88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
88 | + return apply_filters('wpinv_get_settings', $settings); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_register_settings() { |
92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
93 | - add_option( 'wpinv_settings' ); |
|
92 | + if (false == get_option('wpinv_settings')) { |
|
93 | + add_option('wpinv_settings'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $register_settings = wpinv_get_registered_settings(); |
97 | 97 | |
98 | - foreach ( $register_settings as $tab => $sections ) { |
|
99 | - foreach ( $sections as $section => $settings) { |
|
98 | + foreach ($register_settings as $tab => $sections) { |
|
99 | + foreach ($sections as $section => $settings) { |
|
100 | 100 | // Check for backwards compatibility |
101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
103 | 103 | $section = 'main'; |
104 | 104 | $settings = $sections; |
105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
112 | 112 | ); |
113 | 113 | |
114 | - foreach ( $settings as $option ) { |
|
114 | + foreach ($settings as $option) { |
|
115 | 115 | // For backwards compatibility |
116 | - if ( empty( $option['id'] ) ) { |
|
116 | + if (empty($option['id'])) { |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
121 | 121 | |
122 | 122 | add_settings_field( |
123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
124 | 124 | $name, |
125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
128 | 128 | array( |
129 | 129 | 'section' => $section, |
130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | } |
@@ -154,180 +154,180 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // Creates our settings in the options table |
157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
158 | 158 | } |
159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
160 | 160 | |
161 | 161 | function wpinv_get_registered_settings() { |
162 | - $pages = wpinv_get_pages( true ); |
|
162 | + $pages = wpinv_get_pages(true); |
|
163 | 163 | |
164 | 164 | $currencies = wpinv_get_currencies(); |
165 | 165 | |
166 | 166 | $currency_code_options = array(); |
167 | - foreach ( $currencies as $code => $name ) { |
|
168 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
167 | + foreach ($currencies as $code => $name) { |
|
168 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $due_payment_options = array(); |
172 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
173 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
172 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
173 | + for ($i = 1; $i <= 30; $i++) { |
|
174 | 174 | $due_payment_options[$i] = $i; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $invoice_number_padd_options = array(); |
178 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
178 | + for ($i = 0; $i <= 20; $i++) { |
|
179 | 179 | $invoice_number_padd_options[$i] = $i; |
180 | 180 | } |
181 | 181 | |
182 | 182 | $currency_symbol = wpinv_currency_symbol(); |
183 | 183 | |
184 | 184 | $last_number = ''; |
185 | - if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
186 | - $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number ); |
|
185 | + if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
186 | + $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number); |
|
187 | 187 | |
188 | - if ( !empty( $last_invoice_number ) ) { |
|
189 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
188 | + if (!empty($last_invoice_number)) { |
|
189 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | $alert_wrapper_start = '<p style="color: #F00">'; |
194 | 194 | $alert_wrapper_close = '</p>'; |
195 | 195 | $wpinv_settings = array( |
196 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
196 | + 'general' => apply_filters('wpinv_settings_general', |
|
197 | 197 | array( |
198 | 198 | 'main' => array( |
199 | 199 | 'location_settings' => array( |
200 | 200 | 'id' => 'location_settings', |
201 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
201 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
202 | 202 | 'desc' => '', |
203 | 203 | 'type' => 'header', |
204 | 204 | ), |
205 | 205 | 'default_country' => array( |
206 | 206 | 'id' => 'default_country', |
207 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
208 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
207 | + 'name' => __('Default Country', 'invoicing'), |
|
208 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
209 | 209 | 'type' => 'select', |
210 | 210 | 'options' => wpinv_get_country_list(), |
211 | 211 | 'std' => 'GB', |
212 | 212 | 'chosen' => true, |
213 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
213 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
214 | 214 | ), |
215 | 215 | 'default_state' => array( |
216 | 216 | 'id' => 'default_state', |
217 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
218 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
217 | + 'name' => __('Default State / Province', 'invoicing'), |
|
218 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
219 | 219 | 'type' => 'country_states', |
220 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
220 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
221 | 221 | ), |
222 | 222 | 'store_name' => array( |
223 | 223 | 'id' => 'store_name', |
224 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
225 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
224 | + 'name' => __('Store Name', 'invoicing'), |
|
225 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
226 | 226 | 'std' => get_option('blogname'), |
227 | 227 | 'type' => 'text', |
228 | 228 | ), |
229 | 229 | 'logo' => array( |
230 | 230 | 'id' => 'logo', |
231 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
232 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
231 | + 'name' => __('Logo URL', 'invoicing'), |
|
232 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
233 | 233 | 'type' => 'text', |
234 | 234 | ), |
235 | 235 | 'store_address' => array( |
236 | 236 | 'id' => 'store_address', |
237 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
238 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
237 | + 'name' => __('Store Address', 'invoicing'), |
|
238 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
239 | 239 | 'type' => 'textarea', |
240 | 240 | ), |
241 | 241 | 'page_settings' => array( |
242 | 242 | 'id' => 'page_settings', |
243 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
243 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
244 | 244 | 'desc' => '', |
245 | 245 | 'type' => 'header', |
246 | 246 | ), |
247 | 247 | 'checkout_page' => array( |
248 | 248 | 'id' => 'checkout_page', |
249 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
250 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
249 | + 'name' => __('Checkout Page', 'invoicing'), |
|
250 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
251 | 251 | 'type' => 'select', |
252 | 252 | 'options' => $pages, |
253 | 253 | 'chosen' => true, |
254 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
254 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
255 | 255 | ), |
256 | 256 | 'success_page' => array( |
257 | 257 | 'id' => 'success_page', |
258 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
259 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
258 | + 'name' => __('Success Page', 'invoicing'), |
|
259 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
260 | 260 | 'type' => 'select', |
261 | 261 | 'options' => $pages, |
262 | 262 | 'chosen' => true, |
263 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
263 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
264 | 264 | ), |
265 | 265 | 'failure_page' => array( |
266 | 266 | 'id' => 'failure_page', |
267 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
268 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ), |
|
267 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
268 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'), |
|
269 | 269 | 'type' => 'select', |
270 | 270 | 'options' => $pages, |
271 | 271 | 'chosen' => true, |
272 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
272 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
273 | 273 | ), |
274 | 274 | 'invoice_history_page' => array( |
275 | 275 | 'id' => 'invoice_history_page', |
276 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
277 | - 'desc' => __( 'This page shows an invoice history for the current user', 'invoicing' ), |
|
276 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
277 | + 'desc' => __('This page shows an invoice history for the current user', 'invoicing'), |
|
278 | 278 | 'type' => 'select', |
279 | 279 | 'options' => $pages, |
280 | 280 | 'chosen' => true, |
281 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
281 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
282 | 282 | ) |
283 | 283 | ), |
284 | 284 | 'currency_section' => array( |
285 | 285 | 'currency_settings' => array( |
286 | 286 | 'id' => 'currency_settings', |
287 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
287 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
288 | 288 | 'desc' => '', |
289 | 289 | 'type' => 'header', |
290 | 290 | ), |
291 | 291 | 'currency' => array( |
292 | 292 | 'id' => 'currency', |
293 | - 'name' => __( 'Currency', 'invoicing' ), |
|
294 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
293 | + 'name' => __('Currency', 'invoicing'), |
|
294 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
295 | 295 | 'type' => 'select', |
296 | 296 | 'options' => $currency_code_options, |
297 | 297 | 'chosen' => true, |
298 | 298 | ), |
299 | 299 | 'currency_position' => array( |
300 | 300 | 'id' => 'currency_position', |
301 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
302 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
301 | + 'name' => __('Currency Position', 'invoicing'), |
|
302 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
303 | 303 | 'type' => 'select', |
304 | 304 | 'options' => array( |
305 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
306 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
307 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
308 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
305 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
306 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
307 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
308 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
309 | 309 | ) |
310 | 310 | ), |
311 | 311 | 'thousands_separator' => array( |
312 | 312 | 'id' => 'thousands_separator', |
313 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
314 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
313 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
314 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
315 | 315 | 'type' => 'text', |
316 | 316 | 'size' => 'small', |
317 | 317 | 'std' => ',', |
318 | 318 | ), |
319 | 319 | 'decimal_separator' => array( |
320 | 320 | 'id' => 'decimal_separator', |
321 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
322 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
321 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
322 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
323 | 323 | 'type' => 'text', |
324 | 324 | 'size' => 'small', |
325 | 325 | 'std' => '.', |
326 | 326 | ), |
327 | 327 | 'decimals' => array( |
328 | 328 | 'id' => 'decimals', |
329 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
330 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
329 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
330 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
331 | 331 | 'type' => 'number', |
332 | 332 | 'size' => 'small', |
333 | 333 | 'std' => '2', |
@@ -339,29 +339,29 @@ discard block |
||
339 | 339 | 'labels' => array( |
340 | 340 | 'labels' => array( |
341 | 341 | 'id' => 'labels_settings', |
342 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
342 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
343 | 343 | 'desc' => '', |
344 | 344 | 'type' => 'header', |
345 | 345 | ), |
346 | 346 | 'vat_name' => array( |
347 | 347 | 'id' => 'vat_name', |
348 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
349 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
348 | + 'name' => __('VAT Name', 'invoicing'), |
|
349 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
350 | 350 | 'type' => 'text', |
351 | 351 | 'size' => 'regular', |
352 | 352 | 'std' => 'VAT' |
353 | 353 | ), |
354 | 354 | 'vat_invoice_notice_label' => array( |
355 | 355 | 'id' => 'vat_invoice_notice_label', |
356 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
357 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
356 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
357 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
358 | 358 | 'type' => 'text', |
359 | 359 | 'size' => 'regular', |
360 | 360 | ), |
361 | 361 | 'vat_invoice_notice' => array( |
362 | 362 | 'id' => 'vat_invoice_notice', |
363 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
364 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
363 | + 'name' => __('Invoice notice', 'invoicing'), |
|
364 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
365 | 365 | 'type' => 'text', |
366 | 366 | 'size' => 'regular', |
367 | 367 | ) |
@@ -373,22 +373,22 @@ discard block |
||
373 | 373 | 'main' => array( |
374 | 374 | 'gateway_settings' => array( |
375 | 375 | 'id' => 'api_header', |
376 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
376 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
377 | 377 | 'desc' => '', |
378 | 378 | 'type' => 'header', |
379 | 379 | ), |
380 | 380 | 'gateways' => array( |
381 | 381 | 'id' => 'gateways', |
382 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
383 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
382 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
383 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
384 | 384 | 'type' => 'gateways', |
385 | 385 | 'std' => array('manual'=>1), |
386 | 386 | 'options' => wpinv_get_payment_gateways(), |
387 | 387 | ), |
388 | 388 | 'default_gateway' => array( |
389 | 389 | 'id' => 'default_gateway', |
390 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
391 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
390 | + 'name' => __('Default Gateway', 'invoicing'), |
|
391 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
392 | 392 | 'type' => 'gateway_select', |
393 | 393 | 'std' => 'manual', |
394 | 394 | 'options' => wpinv_get_payment_gateways(), |
@@ -402,19 +402,19 @@ discard block |
||
402 | 402 | 'main' => array( |
403 | 403 | 'tax_settings' => array( |
404 | 404 | 'id' => 'tax_settings', |
405 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
405 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
406 | 406 | 'type' => 'header', |
407 | 407 | ), |
408 | 408 | 'enable_taxes' => array( |
409 | 409 | 'id' => 'enable_taxes', |
410 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
411 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
410 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
411 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
412 | 412 | 'type' => 'checkbox', |
413 | 413 | ), |
414 | 414 | 'tax_rate' => array( |
415 | 415 | 'id' => 'tax_rate', |
416 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
417 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
416 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
417 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
418 | 418 | 'type' => 'number', |
419 | 419 | 'size' => 'small', |
420 | 420 | 'min' => '0', |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | 'rates' => array( |
427 | 427 | 'tax_rates' => array( |
428 | 428 | 'id' => 'tax_rates', |
429 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
430 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
429 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
430 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
431 | 431 | 'type' => 'tax_rates', |
432 | 432 | ), |
433 | 433 | ) |
@@ -439,62 +439,62 @@ discard block |
||
439 | 439 | 'main' => array( |
440 | 440 | 'email_settings_header' => array( |
441 | 441 | 'id' => 'email_settings_header', |
442 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
442 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
443 | 443 | 'type' => 'header', |
444 | 444 | ), |
445 | 445 | 'email_from_name' => array( |
446 | 446 | 'id' => 'email_from_name', |
447 | - 'name' => __( 'From Name', 'invoicing' ), |
|
448 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
449 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
447 | + 'name' => __('From Name', 'invoicing'), |
|
448 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
449 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
450 | 450 | 'type' => 'text', |
451 | 451 | ), |
452 | 452 | 'email_from' => array( |
453 | 453 | 'id' => 'email_from', |
454 | - 'name' => __( 'From Email', 'invoicing' ), |
|
455 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
456 | - 'std' => get_option( 'admin_email' ), |
|
454 | + 'name' => __('From Email', 'invoicing'), |
|
455 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
456 | + 'std' => get_option('admin_email'), |
|
457 | 457 | 'type' => 'text', |
458 | 458 | ), |
459 | 459 | 'overdue_settings_header' => array( |
460 | 460 | 'id' => 'overdue_settings_header', |
461 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
461 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
462 | 462 | 'type' => 'header', |
463 | 463 | ), |
464 | 464 | 'overdue_active' => array( |
465 | 465 | 'id' => 'overdue_active', |
466 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
467 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
466 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
467 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
468 | 468 | 'type' => 'checkbox', |
469 | 469 | 'std' => false, |
470 | 470 | ), |
471 | 471 | 'overdue_days' => array( |
472 | 472 | 'id' => 'overdue_days', |
473 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
474 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
473 | + 'name' => __('Default Due Date', 'invoicing'), |
|
474 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
475 | 475 | 'type' => 'select', |
476 | 476 | 'options' => $due_payment_options, |
477 | 477 | 'chosen' => true, |
478 | 478 | 'std' => 0, |
479 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
479 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
480 | 480 | ), |
481 | 481 | 'email_template_header' => array( |
482 | 482 | 'id' => 'email_template_header', |
483 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
483 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
484 | 484 | 'type' => 'header', |
485 | 485 | ), |
486 | 486 | 'email_header_image' => array( |
487 | 487 | 'id' => 'email_header_image', |
488 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
489 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
488 | + 'name' => __('Header Image', 'invoicing'), |
|
489 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
490 | 490 | 'std' => '', |
491 | 491 | 'type' => 'text', |
492 | 492 | ), |
493 | 493 | 'email_footer_text' => array( |
494 | 494 | 'id' => 'email_footer_text', |
495 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
496 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
497 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
495 | + 'name' => __('Footer Text', 'invoicing'), |
|
496 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
497 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
498 | 498 | 'type' => 'textarea', |
499 | 499 | 'class' => 'regular-text', |
500 | 500 | 'rows' => 2, |
@@ -502,29 +502,29 @@ discard block |
||
502 | 502 | ), |
503 | 503 | 'email_base_color' => array( |
504 | 504 | 'id' => 'email_base_color', |
505 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
506 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
505 | + 'name' => __('Base Color', 'invoicing'), |
|
506 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
507 | 507 | 'std' => '#557da2', |
508 | 508 | 'type' => 'color', |
509 | 509 | ), |
510 | 510 | 'email_background_color' => array( |
511 | 511 | 'id' => 'email_background_color', |
512 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
513 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
512 | + 'name' => __('Background Color', 'invoicing'), |
|
513 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
514 | 514 | 'std' => '#f5f5f5', |
515 | 515 | 'type' => 'color', |
516 | 516 | ), |
517 | 517 | 'email_body_background_color' => array( |
518 | 518 | 'id' => 'email_body_background_color', |
519 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
520 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
519 | + 'name' => __('Body Background Color', 'invoicing'), |
|
520 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
521 | 521 | 'std' => '#fdfdfd', |
522 | 522 | 'type' => 'color', |
523 | 523 | ), |
524 | 524 | 'email_text_color' => array( |
525 | 525 | 'id' => 'email_text_color', |
526 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
527 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
526 | + 'name' => __('Body Text Color', 'invoicing'), |
|
527 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
528 | 528 | 'std' => '#505050', |
529 | 529 | 'type' => 'color', |
530 | 530 | ), |
@@ -543,19 +543,19 @@ discard block |
||
543 | 543 | 'main' => array( |
544 | 544 | 'invoice_number_format_settings' => array( |
545 | 545 | 'id' => 'invoice_number_format_settings', |
546 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
546 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
547 | 547 | 'type' => 'header', |
548 | 548 | ), |
549 | 549 | 'sequential_invoice_number' => array( |
550 | 550 | 'id' => 'sequential_invoice_number', |
551 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
552 | - 'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ), |
|
551 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
552 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'), |
|
553 | 553 | 'type' => 'checkbox', |
554 | 554 | ), |
555 | 555 | 'invoice_sequence_start' => array( |
556 | 556 | 'id' => 'invoice_sequence_start', |
557 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
558 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
557 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
558 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
559 | 559 | 'type' => 'number', |
560 | 560 | 'size' => 'small', |
561 | 561 | 'std' => '1', |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | ), |
564 | 564 | 'invoice_number_padd' => array( |
565 | 565 | 'id' => 'invoice_number_padd', |
566 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
567 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
566 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
567 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
568 | 568 | 'type' => 'select', |
569 | 569 | 'options' => $invoice_number_padd_options, |
570 | 570 | 'std' => 5, |
@@ -572,8 +572,8 @@ discard block |
||
572 | 572 | ), |
573 | 573 | 'invoice_number_prefix' => array( |
574 | 574 | 'id' => 'invoice_number_prefix', |
575 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
576 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
575 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
576 | + 'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
577 | 577 | 'type' => 'text', |
578 | 578 | 'size' => 'regular', |
579 | 579 | 'std' => 'WPINV-', |
@@ -581,32 +581,32 @@ discard block |
||
581 | 581 | ), |
582 | 582 | 'invoice_number_postfix' => array( |
583 | 583 | 'id' => 'invoice_number_postfix', |
584 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
585 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
584 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
585 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
586 | 586 | 'type' => 'text', |
587 | 587 | 'size' => 'regular', |
588 | 588 | 'std' => '' |
589 | 589 | ), |
590 | 590 | 'checkout_settings' => array( |
591 | 591 | 'id' => 'checkout_settings', |
592 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
592 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
593 | 593 | 'type' => 'header', |
594 | 594 | ), |
595 | 595 | 'login_to_checkout' => array( |
596 | 596 | 'id' => 'login_to_checkout', |
597 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
598 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
597 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
598 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
599 | 599 | 'type' => 'checkbox', |
600 | 600 | ), |
601 | 601 | 'uninstall_settings' => array( |
602 | 602 | 'id' => 'uninstall_settings', |
603 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
603 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
604 | 604 | 'type' => 'header', |
605 | 605 | ), |
606 | 606 | 'remove_data_on_unistall' => array( |
607 | 607 | 'id' => 'remove_data_on_unistall', |
608 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
609 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
608 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
609 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
610 | 610 | 'type' => 'checkbox', |
611 | 611 | 'std' => '' |
612 | 612 | ), |
@@ -614,74 +614,74 @@ discard block |
||
614 | 614 | 'fields' => array( |
615 | 615 | 'fields_settings' => array( |
616 | 616 | 'id' => 'fields_settings', |
617 | - 'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>', |
|
618 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
617 | + 'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>', |
|
618 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
619 | 619 | 'type' => 'header', |
620 | 620 | ), |
621 | 621 | 'fname_mandatory' => array( |
622 | 622 | 'id' => 'fname_mandatory', |
623 | - 'name' => __( 'First Name', 'invoicing' ), |
|
623 | + 'name' => __('First Name', 'invoicing'), |
|
624 | 624 | 'type' => 'checkbox', |
625 | 625 | 'std' => true, |
626 | 626 | ), |
627 | 627 | 'lname_mandatory' => array( |
628 | 628 | 'id' => 'lname_mandatory', |
629 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
629 | + 'name' => __('Last Name', 'invoicing'), |
|
630 | 630 | 'type' => 'checkbox', |
631 | 631 | 'std' => true, |
632 | 632 | ), |
633 | 633 | 'address_mandatory' => array( |
634 | 634 | 'id' => 'address_mandatory', |
635 | - 'name' => __( 'Address', 'invoicing' ), |
|
635 | + 'name' => __('Address', 'invoicing'), |
|
636 | 636 | 'type' => 'checkbox', |
637 | 637 | 'std' => true, |
638 | 638 | ), |
639 | 639 | 'city_mandatory' => array( |
640 | 640 | 'id' => 'city_mandatory', |
641 | - 'name' => __( 'City', 'invoicing' ), |
|
641 | + 'name' => __('City', 'invoicing'), |
|
642 | 642 | 'type' => 'checkbox', |
643 | 643 | 'std' => true, |
644 | 644 | ), |
645 | 645 | 'country_mandatory' => array( |
646 | 646 | 'id' => 'country_mandatory', |
647 | - 'name' => __( 'Country', 'invoicing' ), |
|
647 | + 'name' => __('Country', 'invoicing'), |
|
648 | 648 | 'type' => 'checkbox', |
649 | 649 | 'std' => true, |
650 | 650 | ), |
651 | 651 | 'state_mandatory' => array( |
652 | 652 | 'id' => 'state_mandatory', |
653 | - 'name' => __( 'State / Province', 'invoicing' ), |
|
653 | + 'name' => __('State / Province', 'invoicing'), |
|
654 | 654 | 'type' => 'checkbox', |
655 | 655 | 'std' => true, |
656 | 656 | ), |
657 | 657 | 'zip_mandatory' => array( |
658 | 658 | 'id' => 'zip_mandatory', |
659 | - 'name' => __( 'ZIP / Postcode', 'invoicing' ), |
|
659 | + 'name' => __('ZIP / Postcode', 'invoicing'), |
|
660 | 660 | 'type' => 'checkbox', |
661 | 661 | 'std' => true, |
662 | 662 | ), |
663 | 663 | 'phone_mandatory' => array( |
664 | 664 | 'id' => 'phone_mandatory', |
665 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
665 | + 'name' => __('Phone Number', 'invoicing'), |
|
666 | 666 | 'type' => 'checkbox', |
667 | 667 | 'std' => true, |
668 | 668 | ), |
669 | 669 | 'address_autofill_settings' => array( |
670 | 670 | 'id' => 'address_autofill_settings', |
671 | - 'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>', |
|
671 | + 'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>', |
|
672 | 672 | 'type' => 'header', |
673 | 673 | ), |
674 | 674 | 'address_autofill_active' => array( |
675 | 675 | 'id' => 'address_autofill_active', |
676 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
677 | - 'desc' => __( 'Enable google address auto complete', 'invoicing' ), |
|
676 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
677 | + 'desc' => __('Enable google address auto complete', 'invoicing'), |
|
678 | 678 | 'type' => 'checkbox', |
679 | 679 | 'std' => 0 |
680 | 680 | ), |
681 | 681 | 'address_autofill_api' => array( |
682 | 682 | 'id' => 'address_autofill_api', |
683 | - 'name' => __( 'Google Place API Key', 'invoicing' ), |
|
684 | - 'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ), |
|
683 | + 'name' => __('Google Place API Key', 'invoicing'), |
|
684 | + 'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'), |
|
685 | 685 | 'type' => 'text', |
686 | 686 | 'size' => 'regular', |
687 | 687 | 'std' => '' |
@@ -695,8 +695,8 @@ discard block |
||
695 | 695 | 'main' => array( |
696 | 696 | 'tool_settings' => array( |
697 | 697 | 'id' => 'tool_settings', |
698 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
699 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
698 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
699 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
700 | 700 | 'type' => 'tools', |
701 | 701 | ), |
702 | 702 | ), |
@@ -704,135 +704,135 @@ discard block |
||
704 | 704 | ) |
705 | 705 | ); |
706 | 706 | |
707 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
707 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
708 | 708 | } |
709 | 709 | |
710 | -function wpinv_settings_sanitize( $input = array() ) { |
|
710 | +function wpinv_settings_sanitize($input = array()) { |
|
711 | 711 | global $wpinv_options; |
712 | 712 | |
713 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
713 | + if (empty($_POST['_wp_http_referer'])) { |
|
714 | 714 | return $input; |
715 | 715 | } |
716 | 716 | |
717 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
717 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
718 | 718 | |
719 | 719 | $settings = wpinv_get_registered_settings(); |
720 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
721 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
720 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
721 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
722 | 722 | |
723 | 723 | $input = $input ? $input : array(); |
724 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
725 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
724 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
725 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
726 | 726 | |
727 | 727 | // Loop through each setting being saved and pass it through a sanitization filter |
728 | - foreach ( $input as $key => $value ) { |
|
728 | + foreach ($input as $key => $value) { |
|
729 | 729 | // Get the setting type (checkbox, select, etc) |
730 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
730 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
731 | 731 | |
732 | - if ( $type ) { |
|
732 | + if ($type) { |
|
733 | 733 | // Field type specific filter |
734 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
734 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | // General filter |
738 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
738 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | // Loop through the whitelist and unset any that are empty for the tab being saved |
742 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
743 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
742 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
743 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
744 | 744 | |
745 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
745 | + $found_settings = array_merge($main_settings, $section_settings); |
|
746 | 746 | |
747 | - if ( ! empty( $found_settings ) ) { |
|
748 | - foreach ( $found_settings as $key => $value ) { |
|
747 | + if (!empty($found_settings)) { |
|
748 | + foreach ($found_settings as $key => $value) { |
|
749 | 749 | |
750 | 750 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
751 | - if ( is_numeric( $key ) ) { |
|
751 | + if (is_numeric($key)) { |
|
752 | 752 | $key = $value['id']; |
753 | 753 | } |
754 | 754 | |
755 | - if ( empty( $input[ $key ] ) ) { |
|
756 | - unset( $wpinv_options[ $key ] ); |
|
755 | + if (empty($input[$key])) { |
|
756 | + unset($wpinv_options[$key]); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | } |
760 | 760 | |
761 | 761 | // Merge our new settings with the existing |
762 | - $output = array_merge( $wpinv_options, $input ); |
|
762 | + $output = array_merge($wpinv_options, $input); |
|
763 | 763 | |
764 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
764 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
765 | 765 | |
766 | 766 | return $output; |
767 | 767 | } |
768 | 768 | |
769 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
769 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
770 | 770 | global $wpinv_options, $wpi_session; |
771 | 771 | |
772 | - if ( !current_user_can( 'manage_options' ) ) { |
|
772 | + if (!current_user_can('manage_options')) { |
|
773 | 773 | return $input; |
774 | 774 | } |
775 | 775 | |
776 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
776 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
777 | 777 | // Shows an admin notice about upgrading previous order numbers |
778 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
778 | + $wpi_session->set('upgrade_sequential', '1'); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | return $input; |
782 | 782 | } |
783 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
783 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
784 | 784 | |
785 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
786 | - if( !current_user_can( 'manage_options' ) ) { |
|
785 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
786 | + if (!current_user_can('manage_options')) { |
|
787 | 787 | return $input; |
788 | 788 | } |
789 | 789 | |
790 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
790 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
791 | 791 | |
792 | 792 | $tax_rates = array(); |
793 | 793 | |
794 | - if ( !empty( $new_rates ) ) { |
|
795 | - foreach ( $new_rates as $rate ) { |
|
796 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
794 | + if (!empty($new_rates)) { |
|
795 | + foreach ($new_rates as $rate) { |
|
796 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
797 | 797 | continue; |
798 | 798 | } |
799 | 799 | |
800 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
800 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
801 | 801 | |
802 | 802 | $tax_rates[] = $rate; |
803 | 803 | } |
804 | 804 | } |
805 | 805 | |
806 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
806 | + update_option('wpinv_tax_rates', $tax_rates); |
|
807 | 807 | |
808 | 808 | return $input; |
809 | 809 | } |
810 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
810 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
811 | 811 | |
812 | -function wpinv_sanitize_text_field( $input ) { |
|
813 | - return trim( $input ); |
|
812 | +function wpinv_sanitize_text_field($input) { |
|
813 | + return trim($input); |
|
814 | 814 | } |
815 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
815 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
816 | 816 | |
817 | 817 | function wpinv_get_settings_tabs() { |
818 | 818 | $tabs = array(); |
819 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
820 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
821 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
822 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
823 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
824 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
825 | - |
|
826 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
819 | + $tabs['general'] = __('General', 'invoicing'); |
|
820 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
821 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
822 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
823 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
824 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
825 | + |
|
826 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
827 | 827 | } |
828 | 828 | |
829 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
829 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
830 | 830 | $tabs = false; |
831 | 831 | $sections = wpinv_get_registered_settings_sections(); |
832 | 832 | |
833 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
834 | - $tabs = $sections[ $tab ]; |
|
835 | - } else if ( $tab ) { |
|
833 | + if ($tab && !empty($sections[$tab])) { |
|
834 | + $tabs = $sections[$tab]; |
|
835 | + } else if ($tab) { |
|
836 | 836 | $tabs = false; |
837 | 837 | } |
838 | 838 | |
@@ -842,136 +842,136 @@ discard block |
||
842 | 842 | function wpinv_get_registered_settings_sections() { |
843 | 843 | static $sections = false; |
844 | 844 | |
845 | - if ( false !== $sections ) { |
|
845 | + if (false !== $sections) { |
|
846 | 846 | return $sections; |
847 | 847 | } |
848 | 848 | |
849 | 849 | $sections = array( |
850 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
851 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
852 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
853 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
854 | - ) ), |
|
855 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
856 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
857 | - ) ), |
|
858 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
859 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
860 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
861 | - ) ), |
|
862 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
863 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
864 | - ) ), |
|
865 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
866 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
867 | - 'fields' => __( 'Fields Settings', 'invoicing' ), |
|
868 | - ) ), |
|
869 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
870 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
871 | - ) ), |
|
850 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
851 | + 'main' => __('General Settings', 'invoicing'), |
|
852 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
853 | + 'labels' => __('Label Texts', 'invoicing'), |
|
854 | + )), |
|
855 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
856 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
857 | + )), |
|
858 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
859 | + 'main' => __('Tax Settings', 'invoicing'), |
|
860 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
861 | + )), |
|
862 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
863 | + 'main' => __('Email Settings', 'invoicing'), |
|
864 | + )), |
|
865 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
866 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
867 | + 'fields' => __('Fields Settings', 'invoicing'), |
|
868 | + )), |
|
869 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
870 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
871 | + )), |
|
872 | 872 | ); |
873 | 873 | |
874 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
874 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
875 | 875 | |
876 | 876 | return $sections; |
877 | 877 | } |
878 | 878 | |
879 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
879 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
880 | 880 | $pages_options = array(); |
881 | 881 | |
882 | - if( $default_label !== NULL && $default_label !== false ) { |
|
883 | - $pages_options = array( '' => $default_label ); // Blank option |
|
882 | + if ($default_label !== NULL && $default_label !== false) { |
|
883 | + $pages_options = array('' => $default_label); // Blank option |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | $pages = get_pages(); |
887 | - if ( $pages ) { |
|
888 | - foreach ( $pages as $page ) { |
|
887 | + if ($pages) { |
|
888 | + foreach ($pages as $page) { |
|
889 | 889 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
890 | - $pages_options[ $page->ID ] = $title; |
|
890 | + $pages_options[$page->ID] = $title; |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
894 | 894 | return $pages_options; |
895 | 895 | } |
896 | 896 | |
897 | -function wpinv_header_callback( $args ) { |
|
898 | - if ( !empty( $args['desc'] ) ) { |
|
897 | +function wpinv_header_callback($args) { |
|
898 | + if (!empty($args['desc'])) { |
|
899 | 899 | echo $args['desc']; |
900 | 900 | } |
901 | 901 | } |
902 | 902 | |
903 | -function wpinv_hidden_callback( $args ) { |
|
903 | +function wpinv_hidden_callback($args) { |
|
904 | 904 | global $wpinv_options; |
905 | 905 | |
906 | - if ( isset( $args['set_value'] ) ) { |
|
906 | + if (isset($args['set_value'])) { |
|
907 | 907 | $value = $args['set_value']; |
908 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
909 | - $value = $wpinv_options[ $args['id'] ]; |
|
908 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
909 | + $value = $wpinv_options[$args['id']]; |
|
910 | 910 | } else { |
911 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
911 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
912 | 912 | } |
913 | 913 | |
914 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
914 | + if (isset($args['faux']) && true === $args['faux']) { |
|
915 | 915 | $args['readonly'] = true; |
916 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
916 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
917 | 917 | $name = ''; |
918 | 918 | } else { |
919 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
919 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
920 | 920 | } |
921 | 921 | |
922 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
922 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
923 | 923 | |
924 | 924 | echo $html; |
925 | 925 | } |
926 | 926 | |
927 | -function wpinv_checkbox_callback( $args ) { |
|
927 | +function wpinv_checkbox_callback($args) { |
|
928 | 928 | global $wpinv_options; |
929 | 929 | |
930 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
930 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
931 | 931 | |
932 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
932 | + if (isset($args['faux']) && true === $args['faux']) { |
|
933 | 933 | $name = ''; |
934 | 934 | } else { |
935 | 935 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
936 | 936 | } |
937 | 937 | |
938 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
938 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
939 | 939 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
940 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
940 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
941 | 941 | |
942 | 942 | echo $html; |
943 | 943 | } |
944 | 944 | |
945 | -function wpinv_multicheck_callback( $args ) { |
|
945 | +function wpinv_multicheck_callback($args) { |
|
946 | 946 | global $wpinv_options; |
947 | 947 | |
948 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
948 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
949 | 949 | |
950 | - if ( ! empty( $args['options'] ) ) { |
|
951 | - foreach( $args['options'] as $key => $option ): |
|
952 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
953 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
950 | + if (!empty($args['options'])) { |
|
951 | + foreach ($args['options'] as $key => $option): |
|
952 | + $sanitize_key = wpinv_sanitize_key($key); |
|
953 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
954 | 954 | $enabled = $sanitize_key; |
955 | 955 | } else { |
956 | 956 | $enabled = NULL; |
957 | 957 | } |
958 | - echo '<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 ) . '/> '; |
|
959 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
958 | + echo '<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) . '/> '; |
|
959 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
960 | 960 | endforeach; |
961 | 961 | echo '<p class="description">' . $args['desc'] . '</p>'; |
962 | 962 | } |
963 | 963 | } |
964 | 964 | |
965 | -function wpinv_payment_icons_callback( $args ) { |
|
965 | +function wpinv_payment_icons_callback($args) { |
|
966 | 966 | global $wpinv_options; |
967 | 967 | |
968 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
968 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
969 | 969 | |
970 | - if ( ! empty( $args['options'] ) ) { |
|
971 | - foreach( $args['options'] as $key => $option ) { |
|
972 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
970 | + if (!empty($args['options'])) { |
|
971 | + foreach ($args['options'] as $key => $option) { |
|
972 | + $sanitize_key = wpinv_sanitize_key($key); |
|
973 | 973 | |
974 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
974 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
975 | 975 | $enabled = $option; |
976 | 976 | } else { |
977 | 977 | $enabled = NULL; |
@@ -979,196 +979,196 @@ discard block |
||
979 | 979 | |
980 | 980 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
981 | 981 | |
982 | - 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 ) . '/> '; |
|
982 | + 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) . '/> '; |
|
983 | 983 | |
984 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
985 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
984 | + if (wpinv_string_is_image_url($key)) { |
|
985 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
986 | 986 | } else { |
987 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
987 | + $card = strtolower(str_replace(' ', '', $option)); |
|
988 | 988 | |
989 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
990 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
989 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
990 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
991 | 991 | } else { |
992 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
992 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
993 | 993 | $content_dir = WP_CONTENT_DIR; |
994 | 994 | |
995 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
995 | + if (function_exists('wp_normalize_path')) { |
|
996 | 996 | // Replaces backslashes with forward slashes for Windows systems |
997 | - $image = wp_normalize_path( $image ); |
|
998 | - $content_dir = wp_normalize_path( $content_dir ); |
|
997 | + $image = wp_normalize_path($image); |
|
998 | + $content_dir = wp_normalize_path($content_dir); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
1001 | + $image = str_replace($content_dir, content_url(), $image); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1004 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1005 | 1005 | } |
1006 | 1006 | echo $option . '</label>'; |
1007 | 1007 | } |
1008 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1008 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | |
1012 | -function wpinv_radio_callback( $args ) { |
|
1012 | +function wpinv_radio_callback($args) { |
|
1013 | 1013 | global $wpinv_options; |
1014 | 1014 | |
1015 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1015 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1016 | 1016 | |
1017 | - foreach ( $args['options'] as $key => $option ) : |
|
1018 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1017 | + foreach ($args['options'] as $key => $option) : |
|
1018 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1019 | 1019 | |
1020 | 1020 | $checked = false; |
1021 | 1021 | |
1022 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1022 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
1023 | 1023 | $checked = true; |
1024 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1024 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
1025 | 1025 | $checked = true; |
1026 | 1026 | |
1027 | 1027 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
1028 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1028 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
1029 | 1029 | endforeach; |
1030 | 1030 | |
1031 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1031 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | -function wpinv_gateways_callback( $args ) { |
|
1034 | +function wpinv_gateways_callback($args) { |
|
1035 | 1035 | global $wpinv_options; |
1036 | 1036 | |
1037 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1037 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1038 | 1038 | |
1039 | - foreach ( $args['options'] as $key => $option ) : |
|
1040 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1039 | + foreach ($args['options'] as $key => $option) : |
|
1040 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1041 | 1041 | |
1042 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
1042 | + if (isset($wpinv_options['gateways'][$key])) |
|
1043 | 1043 | $enabled = '1'; |
1044 | 1044 | else |
1045 | 1045 | $enabled = null; |
1046 | 1046 | |
1047 | - 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) . '/> '; |
|
1048 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1047 | + 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) . '/> '; |
|
1048 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
1049 | 1049 | endforeach; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | function wpinv_gateway_select_callback($args) { |
1053 | 1053 | global $wpinv_options; |
1054 | 1054 | |
1055 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1055 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1056 | 1056 | |
1057 | 1057 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
1058 | 1058 | |
1059 | - foreach ( $args['options'] as $key => $option ) : |
|
1060 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1061 | - $selected = selected( $key, $args['selected'], false ); |
|
1059 | + foreach ($args['options'] as $key => $option) : |
|
1060 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1061 | + $selected = selected($key, $args['selected'], false); |
|
1062 | 1062 | } else { |
1063 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
1063 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
1064 | 1064 | } |
1065 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1065 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
1066 | 1066 | endforeach; |
1067 | 1067 | |
1068 | 1068 | echo '</select>'; |
1069 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1069 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | -function wpinv_text_callback( $args ) { |
|
1072 | +function wpinv_text_callback($args) { |
|
1073 | 1073 | global $wpinv_options; |
1074 | 1074 | |
1075 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1075 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1076 | 1076 | |
1077 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1078 | - $value = $wpinv_options[ $args['id'] ]; |
|
1077 | + if (isset($wpinv_options[$args['id']])) { |
|
1078 | + $value = $wpinv_options[$args['id']]; |
|
1079 | 1079 | } else { |
1080 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1080 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1083 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1084 | 1084 | $args['readonly'] = true; |
1085 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1085 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1086 | 1086 | $name = ''; |
1087 | 1087 | } else { |
1088 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1088 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1089 | 1089 | } |
1090 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1090 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1091 | 1091 | |
1092 | 1092 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
1093 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1094 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1095 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1093 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1094 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
1095 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1096 | 1096 | |
1097 | 1097 | echo $html; |
1098 | 1098 | } |
1099 | 1099 | |
1100 | -function wpinv_number_callback( $args ) { |
|
1100 | +function wpinv_number_callback($args) { |
|
1101 | 1101 | global $wpinv_options; |
1102 | 1102 | |
1103 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1103 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1104 | 1104 | |
1105 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1106 | - $value = $wpinv_options[ $args['id'] ]; |
|
1105 | + if (isset($wpinv_options[$args['id']])) { |
|
1106 | + $value = $wpinv_options[$args['id']]; |
|
1107 | 1107 | } else { |
1108 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1108 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1111 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1112 | 1112 | $args['readonly'] = true; |
1113 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1113 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1114 | 1114 | $name = ''; |
1115 | 1115 | } else { |
1116 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1116 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1120 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1121 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1122 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1119 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
1120 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
1121 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
1122 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1123 | 1123 | |
1124 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1125 | - $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 ) ) . '"/>'; |
|
1126 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1124 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1125 | + $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)) . '"/>'; |
|
1126 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1127 | 1127 | |
1128 | 1128 | echo $html; |
1129 | 1129 | } |
1130 | 1130 | |
1131 | -function wpinv_textarea_callback( $args ) { |
|
1131 | +function wpinv_textarea_callback($args) { |
|
1132 | 1132 | global $wpinv_options; |
1133 | 1133 | |
1134 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1134 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1135 | 1135 | |
1136 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1137 | - $value = $wpinv_options[ $args['id'] ]; |
|
1136 | + if (isset($wpinv_options[$args['id']])) { |
|
1137 | + $value = $wpinv_options[$args['id']]; |
|
1138 | 1138 | } else { |
1139 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1139 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1143 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
1142 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1143 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
1144 | 1144 | |
1145 | - $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>'; |
|
1146 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1145 | + $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>'; |
|
1146 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1147 | 1147 | |
1148 | 1148 | echo $html; |
1149 | 1149 | } |
1150 | 1150 | |
1151 | -function wpinv_password_callback( $args ) { |
|
1151 | +function wpinv_password_callback($args) { |
|
1152 | 1152 | global $wpinv_options; |
1153 | 1153 | |
1154 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1154 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1155 | 1155 | |
1156 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1157 | - $value = $wpinv_options[ $args['id'] ]; |
|
1156 | + if (isset($wpinv_options[$args['id']])) { |
|
1157 | + $value = $wpinv_options[$args['id']]; |
|
1158 | 1158 | } else { |
1159 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1159 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1163 | - $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 ) . '"/>'; |
|
1164 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1162 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1163 | + $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) . '"/>'; |
|
1164 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1165 | 1165 | |
1166 | 1166 | echo $html; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | function wpinv_missing_callback($args) { |
1170 | 1170 | printf( |
1171 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1171 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
1172 | 1172 | '<strong>' . $args['id'] . '</strong>' |
1173 | 1173 | ); |
1174 | 1174 | } |
@@ -1176,137 +1176,137 @@ discard block |
||
1176 | 1176 | function wpinv_select_callback($args) { |
1177 | 1177 | global $wpinv_options; |
1178 | 1178 | |
1179 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1179 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1180 | 1180 | |
1181 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1182 | - $value = $wpinv_options[ $args['id'] ]; |
|
1181 | + if (isset($wpinv_options[$args['id']])) { |
|
1182 | + $value = $wpinv_options[$args['id']]; |
|
1183 | 1183 | } else { |
1184 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1184 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1187 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1188 | 1188 | $value = $args['selected']; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - if ( isset( $args['placeholder'] ) ) { |
|
1191 | + if (isset($args['placeholder'])) { |
|
1192 | 1192 | $placeholder = $args['placeholder']; |
1193 | 1193 | } else { |
1194 | 1194 | $placeholder = ''; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - if ( isset( $args['chosen'] ) ) { |
|
1197 | + if (isset($args['chosen'])) { |
|
1198 | 1198 | $chosen = 'class="wpinv-chosen"'; |
1199 | 1199 | } else { |
1200 | 1200 | $chosen = ''; |
1201 | 1201 | } |
1202 | 1202 | |
1203 | - if( !empty( $args['onchange'] ) ) { |
|
1204 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
1203 | + if (!empty($args['onchange'])) { |
|
1204 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
1205 | 1205 | } else { |
1206 | 1206 | $onchange = ''; |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1209 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
1210 | 1210 | |
1211 | - foreach ( $args['options'] as $option => $name ) { |
|
1212 | - $selected = selected( $option, $value, false ); |
|
1213 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1211 | + foreach ($args['options'] as $option => $name) { |
|
1212 | + $selected = selected($option, $value, false); |
|
1213 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | $html .= '</select>'; |
1217 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1217 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1218 | 1218 | |
1219 | 1219 | echo $html; |
1220 | 1220 | } |
1221 | 1221 | |
1222 | -function wpinv_color_select_callback( $args ) { |
|
1222 | +function wpinv_color_select_callback($args) { |
|
1223 | 1223 | global $wpinv_options; |
1224 | 1224 | |
1225 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1225 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1226 | 1226 | |
1227 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1228 | - $value = $wpinv_options[ $args['id'] ]; |
|
1227 | + if (isset($wpinv_options[$args['id']])) { |
|
1228 | + $value = $wpinv_options[$args['id']]; |
|
1229 | 1229 | } else { |
1230 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1230 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1233 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
1234 | 1234 | |
1235 | - foreach ( $args['options'] as $option => $color ) { |
|
1236 | - $selected = selected( $option, $value, false ); |
|
1237 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1235 | + foreach ($args['options'] as $option => $color) { |
|
1236 | + $selected = selected($option, $value, false); |
|
1237 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | $html .= '</select>'; |
1241 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1241 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1242 | 1242 | |
1243 | 1243 | echo $html; |
1244 | 1244 | } |
1245 | 1245 | |
1246 | -function wpinv_rich_editor_callback( $args ) { |
|
1246 | +function wpinv_rich_editor_callback($args) { |
|
1247 | 1247 | global $wpinv_options, $wp_version; |
1248 | 1248 | |
1249 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1249 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1250 | 1250 | |
1251 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1252 | - $value = $wpinv_options[ $args['id'] ]; |
|
1251 | + if (isset($wpinv_options[$args['id']])) { |
|
1252 | + $value = $wpinv_options[$args['id']]; |
|
1253 | 1253 | |
1254 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1255 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1254 | + if (empty($args['allow_blank']) && empty($value)) { |
|
1255 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1256 | 1256 | } |
1257 | 1257 | } else { |
1258 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1258 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1261 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
1262 | 1262 | |
1263 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1263 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
1264 | 1264 | ob_start(); |
1265 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
1265 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
1266 | 1266 | $html = ob_get_clean(); |
1267 | 1267 | } else { |
1268 | - $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>'; |
|
1268 | + $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>'; |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1271 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1272 | 1272 | |
1273 | 1273 | echo $html; |
1274 | 1274 | } |
1275 | 1275 | |
1276 | -function wpinv_upload_callback( $args ) { |
|
1276 | +function wpinv_upload_callback($args) { |
|
1277 | 1277 | global $wpinv_options; |
1278 | 1278 | |
1279 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1279 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1280 | 1280 | |
1281 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1281 | + if (isset($wpinv_options[$args['id']])) { |
|
1282 | 1282 | $value = $wpinv_options[$args['id']]; |
1283 | 1283 | } else { |
1284 | 1284 | $value = isset($args['std']) ? $args['std'] : ''; |
1285 | 1285 | } |
1286 | 1286 | |
1287 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1288 | - $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 ) ) . '"/>'; |
|
1289 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1290 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1287 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1288 | + $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)) . '"/>'; |
|
1289 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
1290 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1291 | 1291 | |
1292 | 1292 | echo $html; |
1293 | 1293 | } |
1294 | 1294 | |
1295 | -function wpinv_color_callback( $args ) { |
|
1295 | +function wpinv_color_callback($args) { |
|
1296 | 1296 | global $wpinv_options; |
1297 | 1297 | |
1298 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1298 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1299 | 1299 | |
1300 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1301 | - $value = $wpinv_options[ $args['id'] ]; |
|
1300 | + if (isset($wpinv_options[$args['id']])) { |
|
1301 | + $value = $wpinv_options[$args['id']]; |
|
1302 | 1302 | } else { |
1303 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1303 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1306 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
1307 | 1307 | |
1308 | - $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 ) . '" />'; |
|
1309 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1308 | + $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) . '" />'; |
|
1309 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1310 | 1310 | |
1311 | 1311 | echo $html; |
1312 | 1312 | } |
@@ -1314,9 +1314,9 @@ discard block |
||
1314 | 1314 | function wpinv_country_states_callback($args) { |
1315 | 1315 | global $wpinv_options; |
1316 | 1316 | |
1317 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1317 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1318 | 1318 | |
1319 | - if ( isset( $args['placeholder'] ) ) { |
|
1319 | + if (isset($args['placeholder'])) { |
|
1320 | 1320 | $placeholder = $args['placeholder']; |
1321 | 1321 | } else { |
1322 | 1322 | $placeholder = ''; |
@@ -1324,17 +1324,17 @@ discard block |
||
1324 | 1324 | |
1325 | 1325 | $states = wpinv_get_country_states(); |
1326 | 1326 | |
1327 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
1328 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1329 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1327 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
1328 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1329 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
1330 | 1330 | |
1331 | - foreach ( $states as $option => $name ) { |
|
1332 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1333 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1331 | + foreach ($states as $option => $name) { |
|
1332 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
1333 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | $html .= '</select>'; |
1337 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1337 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1338 | 1338 | |
1339 | 1339 | echo $html; |
1340 | 1340 | } |
@@ -1349,25 +1349,25 @@ discard block |
||
1349 | 1349 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
1350 | 1350 | <thead> |
1351 | 1351 | <tr> |
1352 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
1353 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
1354 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
1355 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
1356 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
1357 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
1352 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
1353 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
1354 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
1355 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
1356 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
1357 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
1358 | 1358 | </tr> |
1359 | 1359 | </thead> |
1360 | 1360 | <tbody> |
1361 | - <?php if( !empty( $rates ) ) : ?> |
|
1362 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
1361 | + <?php if (!empty($rates)) : ?> |
|
1362 | + <?php foreach ($rates as $key => $rate) : ?> |
|
1363 | 1363 | <?php |
1364 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
1364 | + $sanitized_key = wpinv_sanitize_key($key); |
|
1365 | 1365 | ?> |
1366 | 1366 | <tr> |
1367 | 1367 | <td class="wpinv_tax_country"> |
1368 | 1368 | <?php |
1369 | - echo wpinv_html_select( array( |
|
1370 | - 'options' => wpinv_get_country_list( true ), |
|
1369 | + echo wpinv_html_select(array( |
|
1370 | + 'options' => wpinv_get_country_list(true), |
|
1371 | 1371 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
1372 | 1372 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1373 | 1373 | 'selected' => $rate['country'], |
@@ -1375,72 +1375,72 @@ discard block |
||
1375 | 1375 | 'show_option_none' => false, |
1376 | 1376 | 'class' => 'wpinv-tax-country', |
1377 | 1377 | 'chosen' => false, |
1378 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1379 | - ) ); |
|
1378 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1379 | + )); |
|
1380 | 1380 | ?> |
1381 | 1381 | </td> |
1382 | 1382 | <td class="wpinv_tax_state"> |
1383 | 1383 | <?php |
1384 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1385 | - if( !empty( $states ) ) { |
|
1386 | - echo wpinv_html_select( array( |
|
1387 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1384 | + $states = wpinv_get_country_states($rate['country']); |
|
1385 | + if (!empty($states)) { |
|
1386 | + echo wpinv_html_select(array( |
|
1387 | + 'options' => array_merge(array('' => ''), $states), |
|
1388 | 1388 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
1389 | 1389 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1390 | 1390 | 'selected' => $rate['state'], |
1391 | 1391 | 'show_option_all' => false, |
1392 | 1392 | 'show_option_none' => false, |
1393 | 1393 | 'chosen' => false, |
1394 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1395 | - ) ); |
|
1394 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
1395 | + )); |
|
1396 | 1396 | } else { |
1397 | - echo wpinv_html_text( array( |
|
1397 | + echo wpinv_html_text(array( |
|
1398 | 1398 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
1399 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1399 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
1400 | 1400 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1401 | - ) ); |
|
1401 | + )); |
|
1402 | 1402 | } |
1403 | 1403 | ?> |
1404 | 1404 | </td> |
1405 | 1405 | <td class="wpinv_tax_global"> |
1406 | - <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'] ) ); ?>/> |
|
1407 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1406 | + <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'])); ?>/> |
|
1407 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1408 | 1408 | </td> |
1409 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
1410 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
1411 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1409 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
1410 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
1411 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1412 | 1412 | </tr> |
1413 | 1413 | <?php endforeach; ?> |
1414 | 1414 | <?php else : ?> |
1415 | 1415 | <tr> |
1416 | 1416 | <td class="wpinv_tax_country"> |
1417 | 1417 | <?php |
1418 | - echo wpinv_html_select( array( |
|
1419 | - 'options' => wpinv_get_country_list( true ), |
|
1418 | + echo wpinv_html_select(array( |
|
1419 | + 'options' => wpinv_get_country_list(true), |
|
1420 | 1420 | 'name' => 'tax_rates[0][country]', |
1421 | 1421 | 'show_option_all' => false, |
1422 | 1422 | 'show_option_none' => false, |
1423 | 1423 | 'class' => 'wpinv-tax-country', |
1424 | 1424 | 'chosen' => false, |
1425 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1426 | - ) ); ?> |
|
1425 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1426 | + )); ?> |
|
1427 | 1427 | </td> |
1428 | 1428 | <td class="wpinv_tax_state"> |
1429 | - <?php echo wpinv_html_text( array( |
|
1429 | + <?php echo wpinv_html_text(array( |
|
1430 | 1430 | 'name' => 'tax_rates[0][state]' |
1431 | - ) ); ?> |
|
1431 | + )); ?> |
|
1432 | 1432 | </td> |
1433 | 1433 | <td class="wpinv_tax_global"> |
1434 | 1434 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
1435 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1435 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1436 | 1436 | </td> |
1437 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
1437 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
1438 | 1438 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
1439 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1439 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1440 | 1440 | </tr> |
1441 | 1441 | <?php endif; ?> |
1442 | 1442 | </tbody> |
1443 | - <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> |
|
1443 | + <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> |
|
1444 | 1444 | </table> |
1445 | 1445 | <?php |
1446 | 1446 | echo ob_get_clean(); |
@@ -1451,54 +1451,54 @@ discard block |
||
1451 | 1451 | ob_start(); ?> |
1452 | 1452 | </td><tr> |
1453 | 1453 | <td colspan="2" class="wpinv_tools_tdbox"> |
1454 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1455 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1454 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1455 | + <?php do_action('wpinv_tools_before'); ?> |
|
1456 | 1456 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1457 | 1457 | <thead> |
1458 | 1458 | <tr> |
1459 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
1460 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
1461 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
1459 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
1460 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
1461 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
1462 | 1462 | </tr> |
1463 | 1463 | </thead> |
1464 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1464 | + <?php do_action('wpinv_tools_row'); ?> |
|
1465 | 1465 | <tbody> |
1466 | 1466 | </tbody> |
1467 | 1467 | </table> |
1468 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1468 | + <?php do_action('wpinv_tools_after'); ?> |
|
1469 | 1469 | <?php |
1470 | 1470 | echo ob_get_clean(); |
1471 | 1471 | } |
1472 | 1472 | |
1473 | -function wpinv_descriptive_text_callback( $args ) { |
|
1474 | - echo wp_kses_post( $args['desc'] ); |
|
1473 | +function wpinv_descriptive_text_callback($args) { |
|
1474 | + echo wp_kses_post($args['desc']); |
|
1475 | 1475 | } |
1476 | 1476 | |
1477 | -function wpinv_hook_callback( $args ) { |
|
1478 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1477 | +function wpinv_hook_callback($args) { |
|
1478 | + do_action('wpinv_' . $args['id'], $args); |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | function wpinv_set_settings_cap() { |
1482 | 1482 | return 'manage_options'; |
1483 | 1483 | } |
1484 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1484 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1485 | 1485 | |
1486 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1487 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
1488 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
1486 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1487 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1488 | + $value = wpinv_sanitize_amount($value, 4); |
|
1489 | 1489 | $value = $value >= 100 ? 99 : $value; |
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | return $value; |
1493 | 1493 | } |
1494 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1494 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1495 | 1495 | |
1496 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1497 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1498 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1496 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1497 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1498 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1499 | 1499 | |
1500 | - if ( $old != $new ) { |
|
1501 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1500 | + if ($old != $new) { |
|
1501 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1502 | 1502 | } |
1503 | 1503 | } |
1504 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1505 | 1504 | \ No newline at end of file |
1505 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1506 | 1506 | \ No newline at end of file |
@@ -7,89 +7,89 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_item_quantities_enabled() { |
15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
15 | + $ret = wpinv_get_option('item_quantities', true); |
|
16 | 16 | |
17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
17 | + return (bool)apply_filters('wpinv_item_quantities_enabled', $ret); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | function wpinv_get_ip() { |
21 | 21 | $ip = '127.0.0.1'; |
22 | 22 | |
23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
29 | 29 | } |
30 | 30 | |
31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
31 | + return apply_filters('wpinv_get_ip', $ip); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | function wpinv_get_user_agent() { |
35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
37 | 37 | } else { |
38 | 38 | $user_agent = ''; |
39 | 39 | } |
40 | 40 | |
41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
42 | 42 | } |
43 | 43 | |
44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
45 | 45 | $is_negative = false; |
46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
48 | - if ( $decimals === NULL ) { |
|
48 | + if ($decimals === NULL) { |
|
49 | 49 | $decimals = wpinv_decimals(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Sanitize the amount |
53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
57 | - $amount = str_replace( '.', '', $amount ); |
|
53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
57 | + $amount = str_replace('.', '', $amount); |
|
58 | 58 | } |
59 | 59 | |
60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
63 | 63 | } |
64 | 64 | |
65 | - if( $amount < 0 ) { |
|
65 | + if ($amount < 0) { |
|
66 | 66 | $is_negative = true; |
67 | 67 | } |
68 | 68 | |
69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
70 | 70 | |
71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
72 | + $amount = number_format((double)$amount, absint($decimals), '.', ''); |
|
73 | 73 | |
74 | - if( $is_negative ) { |
|
74 | + if ($is_negative) { |
|
75 | 75 | $amount *= -1; |
76 | 76 | } |
77 | 77 | |
78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
79 | 79 | } |
80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
81 | 81 | |
82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
83 | - if ( $decimals === NULL ) { |
|
82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
83 | + if ($decimals === NULL) { |
|
84 | 84 | $decimals = wpinv_decimals(); |
85 | 85 | } |
86 | 86 | |
87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
87 | + $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
88 | 88 | |
89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
90 | 90 | } |
91 | 91 | |
92 | -function wpinv_get_invoice_statuses( $trashed = false ) { |
|
92 | +function wpinv_get_invoice_statuses($trashed = false) { |
|
93 | 93 | global $post; |
94 | 94 | $invoice_statuses = array(); |
95 | 95 | $invoice_statuses = array( |
@@ -103,32 +103,32 @@ discard block |
||
103 | 103 | 'wpi-renewal' => __('Renewal Payment', 'invoicing') |
104 | 104 | ); |
105 | 105 | |
106 | - if ( $trashed ) { |
|
107 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
106 | + if ($trashed) { |
|
107 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'wpinv_statuses', $invoice_statuses ); |
|
110 | + return apply_filters('wpinv_statuses', $invoice_statuses); |
|
111 | 111 | } |
112 | 112 | |
113 | -function wpinv_status_nicename( $status ) { |
|
113 | +function wpinv_status_nicename($status) { |
|
114 | 114 | $statuses = wpinv_get_invoice_statuses(); |
115 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
115 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
116 | 116 | |
117 | 117 | return $status; |
118 | 118 | } |
119 | 119 | |
120 | 120 | function wpinv_get_currency() { |
121 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
121 | + $currency = wpinv_get_option('currency', 'USD'); |
|
122 | 122 | |
123 | - return apply_filters( 'wpinv_currency', $currency ); |
|
123 | + return apply_filters('wpinv_currency', $currency); |
|
124 | 124 | } |
125 | 125 | |
126 | -function wpinv_currency_symbol( $currency = '' ) { |
|
127 | - if ( empty( $currency ) ) { |
|
126 | +function wpinv_currency_symbol($currency = '') { |
|
127 | + if (empty($currency)) { |
|
128 | 128 | $currency = wpinv_get_currency(); |
129 | 129 | } |
130 | 130 | |
131 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
131 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
132 | 132 | 'AED' => 'د.إ', |
133 | 133 | 'AFN' => '؋', |
134 | 134 | 'ALL' => 'L', |
@@ -291,208 +291,208 @@ discard block |
||
291 | 291 | 'YER' => '﷼', |
292 | 292 | 'ZAR' => 'R', |
293 | 293 | 'ZMW' => 'ZK', |
294 | - ) ); |
|
294 | + )); |
|
295 | 295 | |
296 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
296 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
297 | 297 | |
298 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
298 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | function wpinv_currency_position() { |
302 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
302 | + $position = wpinv_get_option('currency_position', 'left'); |
|
303 | 303 | |
304 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
304 | + return apply_filters('wpinv_currency_position', $position); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | function wpinv_thousands_separator() { |
308 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
308 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
309 | 309 | |
310 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
310 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | function wpinv_decimal_separator() { |
314 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
314 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
315 | 315 | |
316 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
316 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | function wpinv_decimals() { |
320 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
320 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
321 | 321 | |
322 | - return absint( $decimals ); |
|
322 | + return absint($decimals); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | function wpinv_get_currencies() { |
326 | 326 | $currencies = array( |
327 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
328 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
329 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
330 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
331 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
332 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
333 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
334 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
335 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
336 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
337 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
338 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
339 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
340 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
341 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
342 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
343 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
344 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
345 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
346 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
347 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
348 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
349 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
350 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
351 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
352 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
353 | - 'BYR' => __( 'Belarusian Ruble', 'invoicing' ), |
|
354 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
355 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
356 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
357 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
358 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
359 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
360 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
361 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
362 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
363 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
364 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
365 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
366 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
367 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
368 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
369 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
370 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
371 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
372 | - 'ETB' => __( 'Ethiopian irr', 'invoicing' ), |
|
373 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
374 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
375 | - 'GEL' => __( 'Georgian lari', 'invoicing' ), |
|
376 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
377 | - 'GHS' => __( 'Ghana cedi', 'invoicing' ), |
|
378 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
379 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
380 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
381 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
382 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
383 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
384 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
385 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
386 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
387 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
388 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
389 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
390 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
391 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
392 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
393 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
394 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
395 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
396 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
397 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
398 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
399 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
400 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
401 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
402 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
403 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
404 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
405 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
406 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
407 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
408 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
409 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
410 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
411 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
412 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
413 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
414 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
415 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
416 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
417 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
418 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
419 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
420 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
421 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
422 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
423 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
424 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
425 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
426 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
427 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
428 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
429 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
430 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
431 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
432 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
433 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
434 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
435 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
436 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
437 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
438 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
439 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
440 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
441 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
442 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
443 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
444 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
445 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
446 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
447 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
448 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
449 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
450 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
451 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
452 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
453 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
454 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
455 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
456 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
457 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
458 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
459 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
460 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
461 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
462 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
463 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
464 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
465 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
466 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
467 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
468 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
469 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
470 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
471 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
472 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
473 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
474 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
475 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
476 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
477 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
478 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
479 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
480 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
481 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
482 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
483 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
484 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
485 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
486 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
327 | + 'USD' => __('US Dollar', 'invoicing'), |
|
328 | + 'EUR' => __('Euro', 'invoicing'), |
|
329 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
330 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
331 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
332 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
333 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
334 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
335 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
336 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
337 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
338 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
339 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
340 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
341 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
342 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
343 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
344 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
345 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
346 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
347 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
348 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
349 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
350 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
351 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
352 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
353 | + 'BYR' => __('Belarusian Ruble', 'invoicing'), |
|
354 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
355 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
356 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
357 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
358 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
359 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
360 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
361 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
362 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
363 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
364 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
365 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
366 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
367 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
368 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
369 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
370 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
371 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
372 | + 'ETB' => __('Ethiopian irr', 'invoicing'), |
|
373 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
374 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
375 | + 'GEL' => __('Georgian lari', 'invoicing'), |
|
376 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
377 | + 'GHS' => __('Ghana cedi', 'invoicing'), |
|
378 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
379 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
380 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
381 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
382 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
383 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
384 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
385 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
386 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
387 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
388 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
389 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
390 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
391 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
392 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
393 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
394 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
395 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
396 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
397 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
398 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
399 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
400 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
401 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
402 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
403 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
404 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
405 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
406 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
407 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
408 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
409 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
410 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
411 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
412 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
413 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
414 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
415 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
416 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
417 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
418 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
419 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
420 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
421 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
422 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
423 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
424 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
425 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
426 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
427 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
428 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
429 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
430 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
431 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
432 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
433 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
434 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
435 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
436 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
437 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
438 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
439 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
440 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
441 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
442 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
443 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
444 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
445 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
446 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
447 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
448 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
449 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
450 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
451 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
452 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
453 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
454 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
455 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
456 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
457 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
458 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
459 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
460 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
461 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
462 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
463 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
464 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
465 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
466 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
467 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
468 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
469 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
470 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
471 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
472 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
473 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
474 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
475 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
476 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
477 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
478 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
479 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
480 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
481 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
482 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
483 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
484 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
485 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
486 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
487 | 487 | ); |
488 | 488 | |
489 | 489 | //asort( $currencies ); // this |
490 | 490 | |
491 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
491 | + return apply_filters('wpinv_currencies', $currencies); |
|
492 | 492 | } |
493 | 493 | |
494 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
495 | - if( empty( $currency ) ) { |
|
494 | +function wpinv_price($amount = '', $currency = '') { |
|
495 | + if (empty($currency)) { |
|
496 | 496 | $currency = wpinv_get_currency(); |
497 | 497 | } |
498 | 498 | |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | |
501 | 501 | $negative = $amount < 0; |
502 | 502 | |
503 | - if ( $negative ) { |
|
504 | - $amount = substr( $amount, 1 ); |
|
503 | + if ($negative) { |
|
504 | + $amount = substr($amount, 1); |
|
505 | 505 | } |
506 | 506 | |
507 | - $symbol = wpinv_currency_symbol( $currency ); |
|
507 | + $symbol = wpinv_currency_symbol($currency); |
|
508 | 508 | |
509 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
510 | - switch ( $currency ) { |
|
509 | + if ($position == 'left' || $position == 'left_space') { |
|
510 | + switch ($currency) { |
|
511 | 511 | case "GBP" : |
512 | 512 | case "BRL" : |
513 | 513 | case "EUR" : |
@@ -519,15 +519,15 @@ discard block |
||
519 | 519 | case "NZD" : |
520 | 520 | case "SGD" : |
521 | 521 | case "JPY" : |
522 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
522 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
523 | 523 | break; |
524 | 524 | default : |
525 | 525 | //$price = $currency . ' ' . $amount; |
526 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
526 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
527 | 527 | break; |
528 | 528 | } |
529 | 529 | } else { |
530 | - switch ( $currency ) { |
|
530 | + switch ($currency) { |
|
531 | 531 | case "GBP" : |
532 | 532 | case "BRL" : |
533 | 533 | case "EUR" : |
@@ -538,83 +538,83 @@ discard block |
||
538 | 538 | case "MXN" : |
539 | 539 | case "SGD" : |
540 | 540 | case "JPY" : |
541 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
541 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
542 | 542 | break; |
543 | 543 | default : |
544 | 544 | //$price = $amount . ' ' . $currency; |
545 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
545 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
546 | 546 | break; |
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
550 | - if ( $negative ) { |
|
550 | + if ($negative) { |
|
551 | 551 | $price = '-' . $price; |
552 | 552 | } |
553 | 553 | |
554 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
554 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
555 | 555 | |
556 | 556 | return $price; |
557 | 557 | } |
558 | 558 | |
559 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
559 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
560 | 560 | $thousands_sep = wpinv_thousands_separator(); |
561 | 561 | $decimal_sep = wpinv_decimal_separator(); |
562 | 562 | |
563 | - if ( $decimals === NULL ) { |
|
563 | + if ($decimals === NULL) { |
|
564 | 564 | $decimals = wpinv_decimals(); |
565 | 565 | } |
566 | 566 | |
567 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
568 | - $whole = substr( $amount, 0, $sep_found ); |
|
569 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
567 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
568 | + $whole = substr($amount, 0, $sep_found); |
|
569 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
570 | 570 | $amount = $whole . '.' . $part; |
571 | 571 | } |
572 | 572 | |
573 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
574 | - $amount = str_replace( ',', '', $amount ); |
|
573 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
574 | + $amount = str_replace(',', '', $amount); |
|
575 | 575 | } |
576 | 576 | |
577 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
578 | - $amount = str_replace( ' ', '', $amount ); |
|
577 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
578 | + $amount = str_replace(' ', '', $amount); |
|
579 | 579 | } |
580 | 580 | |
581 | - if ( empty( $amount ) ) { |
|
581 | + if (empty($amount)) { |
|
582 | 582 | $amount = 0; |
583 | 583 | } |
584 | 584 | |
585 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
586 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
585 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
586 | + $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep); |
|
587 | 587 | |
588 | - if ( $calculate ) { |
|
589 | - if ( $thousands_sep === "," ) { |
|
590 | - $formatted = str_replace( ",", "", $formatted ); |
|
588 | + if ($calculate) { |
|
589 | + if ($thousands_sep === ",") { |
|
590 | + $formatted = str_replace(",", "", $formatted); |
|
591 | 591 | } |
592 | 592 | |
593 | - if ( $decimal_sep === "," ) { |
|
594 | - $formatted = str_replace( ",", ".", $formatted ); |
|
593 | + if ($decimal_sep === ",") { |
|
594 | + $formatted = str_replace(",", ".", $formatted); |
|
595 | 595 | } |
596 | 596 | } |
597 | 597 | |
598 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
598 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
599 | 599 | } |
600 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
600 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
601 | 601 | |
602 | -function wpinv_sanitize_key( $key ) { |
|
602 | +function wpinv_sanitize_key($key) { |
|
603 | 603 | $raw_key = $key; |
604 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
604 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
605 | 605 | |
606 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
606 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
607 | 607 | } |
608 | 608 | |
609 | -function wpinv_get_file_extension( $str ) { |
|
610 | - $parts = explode( '.', $str ); |
|
611 | - return end( $parts ); |
|
609 | +function wpinv_get_file_extension($str) { |
|
610 | + $parts = explode('.', $str); |
|
611 | + return end($parts); |
|
612 | 612 | } |
613 | 613 | |
614 | -function wpinv_string_is_image_url( $str ) { |
|
615 | - $ext = wpinv_get_file_extension( $str ); |
|
614 | +function wpinv_string_is_image_url($str) { |
|
615 | + $ext = wpinv_get_file_extension($str); |
|
616 | 616 | |
617 | - switch ( strtolower( $ext ) ) { |
|
617 | + switch (strtolower($ext)) { |
|
618 | 618 | case 'jpeg'; |
619 | 619 | case 'jpg'; |
620 | 620 | $return = true; |
@@ -630,32 +630,32 @@ discard block |
||
630 | 630 | break; |
631 | 631 | } |
632 | 632 | |
633 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
633 | + return (bool)apply_filters('wpinv_string_is_image', $return, $str); |
|
634 | 634 | } |
635 | 635 | |
636 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
637 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
636 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
637 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
638 | 638 | |
639 | - if ( true === $should_log ) { |
|
639 | + if (true === $should_log) { |
|
640 | 640 | $label = ''; |
641 | - if ( $file && $file !== '' ) { |
|
642 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
641 | + if ($file && $file !== '') { |
|
642 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
643 | 643 | } |
644 | 644 | |
645 | - if ( $title && $title !== '' ) { |
|
645 | + if ($title && $title !== '') { |
|
646 | 646 | $label = $label !== '' ? $label . ' ' : ''; |
647 | 647 | $label .= $title . ' '; |
648 | 648 | } |
649 | 649 | |
650 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
650 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
651 | 651 | |
652 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
653 | - error_log( $label . print_r( $log, true ) ); |
|
652 | + if (is_array($log) || is_object($log)) { |
|
653 | + error_log($label . print_r($log, true)); |
|
654 | 654 | } else { |
655 | - error_log( $label . $log ); |
|
655 | + error_log($label . $log); |
|
656 | 656 | } |
657 | 657 | |
658 | - if ( $exit ) { |
|
658 | + if ($exit) { |
|
659 | 659 | exit; |
660 | 660 | } |
661 | 661 | } |
@@ -663,65 +663,65 @@ discard block |
||
663 | 663 | |
664 | 664 | function wpinv_is_ajax_disabled() { |
665 | 665 | $retval = false; |
666 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
666 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
667 | 667 | } |
668 | 668 | |
669 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
669 | +function wpinv_get_current_page_url($nocache = false) { |
|
670 | 670 | global $wp; |
671 | 671 | |
672 | - if ( get_option( 'permalink_structure' ) ) { |
|
673 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
672 | + if (get_option('permalink_structure')) { |
|
673 | + $base = trailingslashit(home_url($wp->request)); |
|
674 | 674 | } else { |
675 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
676 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
675 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
676 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | $scheme = is_ssl() ? 'https' : 'http'; |
680 | - $uri = set_url_scheme( $base, $scheme ); |
|
680 | + $uri = set_url_scheme($base, $scheme); |
|
681 | 681 | |
682 | - if ( is_front_page() ) { |
|
683 | - $uri = home_url( '/' ); |
|
684 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
682 | + if (is_front_page()) { |
|
683 | + $uri = home_url('/'); |
|
684 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
685 | 685 | $uri = wpinv_get_checkout_uri(); |
686 | 686 | } |
687 | 687 | |
688 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
688 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
689 | 689 | |
690 | - if ( $nocache ) { |
|
691 | - $uri = wpinv_add_cache_busting( $uri ); |
|
690 | + if ($nocache) { |
|
691 | + $uri = wpinv_add_cache_busting($uri); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | return $uri; |
695 | 695 | } |
696 | 696 | |
697 | 697 | function wpinv_get_php_arg_separator_output() { |
698 | - return ini_get( 'arg_separator.output' ); |
|
698 | + return ini_get('arg_separator.output'); |
|
699 | 699 | } |
700 | 700 | |
701 | -function wpinv_rgb_from_hex( $color ) { |
|
702 | - $color = str_replace( '#', '', $color ); |
|
701 | +function wpinv_rgb_from_hex($color) { |
|
702 | + $color = str_replace('#', '', $color); |
|
703 | 703 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
704 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
704 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
705 | 705 | |
706 | 706 | $rgb = array(); |
707 | - $rgb['R'] = hexdec( $color{0}.$color{1} ); |
|
708 | - $rgb['G'] = hexdec( $color{2}.$color{3} ); |
|
709 | - $rgb['B'] = hexdec( $color{4}.$color{5} ); |
|
707 | + $rgb['R'] = hexdec($color{0} . $color{1} ); |
|
708 | + $rgb['G'] = hexdec($color{2} . $color{3} ); |
|
709 | + $rgb['B'] = hexdec($color{4} . $color{5} ); |
|
710 | 710 | |
711 | 711 | return $rgb; |
712 | 712 | } |
713 | 713 | |
714 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
715 | - $base = wpinv_rgb_from_hex( $color ); |
|
714 | +function wpinv_hex_darker($color, $factor = 30) { |
|
715 | + $base = wpinv_rgb_from_hex($color); |
|
716 | 716 | $color = '#'; |
717 | 717 | |
718 | - foreach ( $base as $k => $v ) { |
|
718 | + foreach ($base as $k => $v) { |
|
719 | 719 | $amount = $v / 100; |
720 | - $amount = round( $amount * $factor ); |
|
720 | + $amount = round($amount * $factor); |
|
721 | 721 | $new_decimal = $v - $amount; |
722 | 722 | |
723 | - $new_hex_component = dechex( $new_decimal ); |
|
724 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
723 | + $new_hex_component = dechex($new_decimal); |
|
724 | + if (strlen($new_hex_component) < 2) { |
|
725 | 725 | $new_hex_component = "0" . $new_hex_component; |
726 | 726 | } |
727 | 727 | $color .= $new_hex_component; |
@@ -730,18 +730,18 @@ discard block |
||
730 | 730 | return $color; |
731 | 731 | } |
732 | 732 | |
733 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
734 | - $base = wpinv_rgb_from_hex( $color ); |
|
733 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
734 | + $base = wpinv_rgb_from_hex($color); |
|
735 | 735 | $color = '#'; |
736 | 736 | |
737 | - foreach ( $base as $k => $v ) { |
|
737 | + foreach ($base as $k => $v) { |
|
738 | 738 | $amount = 255 - $v; |
739 | 739 | $amount = $amount / 100; |
740 | - $amount = round( $amount * $factor ); |
|
740 | + $amount = round($amount * $factor); |
|
741 | 741 | $new_decimal = $v + $amount; |
742 | 742 | |
743 | - $new_hex_component = dechex( $new_decimal ); |
|
744 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
743 | + $new_hex_component = dechex($new_decimal); |
|
744 | + if (strlen($new_hex_component) < 2) { |
|
745 | 745 | $new_hex_component = "0" . $new_hex_component; |
746 | 746 | } |
747 | 747 | $color .= $new_hex_component; |
@@ -750,22 +750,22 @@ discard block |
||
750 | 750 | return $color; |
751 | 751 | } |
752 | 752 | |
753 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
754 | - $hex = str_replace( '#', '', $color ); |
|
753 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
754 | + $hex = str_replace('#', '', $color); |
|
755 | 755 | |
756 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
757 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
758 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
756 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
757 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
758 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
759 | 759 | |
760 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
760 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
761 | 761 | |
762 | 762 | return $brightness > 155 ? $dark : $light; |
763 | 763 | } |
764 | 764 | |
765 | -function wpinv_format_hex( $hex ) { |
|
766 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
765 | +function wpinv_format_hex($hex) { |
|
766 | + $hex = trim(str_replace('#', '', $hex)); |
|
767 | 767 | |
768 | - if ( strlen( $hex ) == 3 ) { |
|
768 | + if (strlen($hex) == 3) { |
|
769 | 769 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
770 | 770 | } |
771 | 771 | |
@@ -785,12 +785,12 @@ discard block |
||
785 | 785 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
786 | 786 | * @return string |
787 | 787 | */ |
788 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
789 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
790 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
788 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
789 | + if (function_exists('mb_strimwidth')) { |
|
790 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
791 | 791 | } |
792 | 792 | |
793 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
793 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -802,28 +802,28 @@ discard block |
||
802 | 802 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
803 | 803 | * @return int Returns the number of characters in string. |
804 | 804 | */ |
805 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
806 | - if ( function_exists( 'mb_strlen' ) ) { |
|
807 | - return mb_strlen( $str, $encoding ); |
|
805 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
806 | + if (function_exists('mb_strlen')) { |
|
807 | + return mb_strlen($str, $encoding); |
|
808 | 808 | } |
809 | 809 | |
810 | - return strlen( $str ); |
|
810 | + return strlen($str); |
|
811 | 811 | } |
812 | 812 | |
813 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
814 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
815 | - return mb_strtolower( $str, $encoding ); |
|
813 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
814 | + if (function_exists('mb_strtolower')) { |
|
815 | + return mb_strtolower($str, $encoding); |
|
816 | 816 | } |
817 | 817 | |
818 | - return strtolower( $str ); |
|
818 | + return strtolower($str); |
|
819 | 819 | } |
820 | 820 | |
821 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
822 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
823 | - return mb_strtoupper( $str, $encoding ); |
|
821 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
822 | + if (function_exists('mb_strtoupper')) { |
|
823 | + return mb_strtoupper($str, $encoding); |
|
824 | 824 | } |
825 | 825 | |
826 | - return strtoupper( $str ); |
|
826 | + return strtoupper($str); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
@@ -837,12 +837,12 @@ discard block |
||
837 | 837 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
838 | 838 | * @return int Returns the position of the first occurrence of search in the string. |
839 | 839 | */ |
840 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
841 | - if ( function_exists( 'mb_strpos' ) ) { |
|
842 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
840 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
841 | + if (function_exists('mb_strpos')) { |
|
842 | + return mb_strpos($str, $find, $offset, $encoding); |
|
843 | 843 | } |
844 | 844 | |
845 | - return strpos( $str, $find, $offset ); |
|
845 | + return strpos($str, $find, $offset); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
@@ -856,12 +856,12 @@ discard block |
||
856 | 856 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
857 | 857 | * @return int Returns the position of the last occurrence of search. |
858 | 858 | */ |
859 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
860 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
861 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
859 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
860 | + if (function_exists('mb_strrpos')) { |
|
861 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
862 | 862 | } |
863 | 863 | |
864 | - return strrpos( $str, $find, $offset ); |
|
864 | + return strrpos($str, $find, $offset); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | /** |
@@ -876,16 +876,16 @@ discard block |
||
876 | 876 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
877 | 877 | * @return string |
878 | 878 | */ |
879 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
880 | - if ( function_exists( 'mb_substr' ) ) { |
|
881 | - if ( $length === null ) { |
|
882 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
879 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
880 | + if (function_exists('mb_substr')) { |
|
881 | + if ($length === null) { |
|
882 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
883 | 883 | } else { |
884 | - return mb_substr( $str, $start, $length, $encoding ); |
|
884 | + return mb_substr($str, $start, $length, $encoding); |
|
885 | 885 | } |
886 | 886 | } |
887 | 887 | |
888 | - return substr( $str, $start, $length ); |
|
888 | + return substr($str, $start, $length); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -897,48 +897,48 @@ discard block |
||
897 | 897 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
898 | 898 | * @return string The width of string. |
899 | 899 | */ |
900 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
901 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
902 | - return mb_strwidth( $str, $encoding ); |
|
900 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
901 | + if (function_exists('mb_strwidth')) { |
|
902 | + return mb_strwidth($str, $encoding); |
|
903 | 903 | } |
904 | 904 | |
905 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
905 | + return wpinv_utf8_strlen($str, $encoding); |
|
906 | 906 | } |
907 | 907 | |
908 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
909 | - if ( function_exists( 'mb_strlen' ) ) { |
|
910 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
908 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
909 | + if (function_exists('mb_strlen')) { |
|
910 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
911 | 911 | $str_end = ""; |
912 | 912 | |
913 | - if ( $lower_str_end ) { |
|
914 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
913 | + if ($lower_str_end) { |
|
914 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
915 | 915 | } else { |
916 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
916 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | return $first_letter . $str_end; |
920 | 920 | } |
921 | 921 | |
922 | - return ucfirst( $str ); |
|
922 | + return ucfirst($str); |
|
923 | 923 | } |
924 | 924 | |
925 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
926 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
927 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
925 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
926 | + if (function_exists('mb_convert_case')) { |
|
927 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
928 | 928 | } |
929 | 929 | |
930 | - return ucwords( $str ); |
|
930 | + return ucwords($str); |
|
931 | 931 | } |
932 | 932 | |
933 | -function wpinv_period_in_days( $period, $unit ) { |
|
934 | - $period = absint( $period ); |
|
933 | +function wpinv_period_in_days($period, $unit) { |
|
934 | + $period = absint($period); |
|
935 | 935 | |
936 | - if ( $period > 0 ) { |
|
937 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
936 | + if ($period > 0) { |
|
937 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
938 | 938 | $period = $period * 7; |
939 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
939 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
940 | 940 | $period = $period * 30; |
941 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
941 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
942 | 942 | $period = $period * 365; |
943 | 943 | } |
944 | 944 | } |
@@ -9,58 +9,58 @@ |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // If uninstall not called from WordPress, then exit. |
12 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
12 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | global $wpdb, $wp_version; |
17 | 17 | |
18 | -$remove_data = get_option( 'wpinv_remove_data_on_invoice_unistall' ); |
|
18 | +$remove_data = get_option('wpinv_remove_data_on_invoice_unistall'); |
|
19 | 19 | |
20 | 20 | /* |
21 | 21 | * Only remove ALL product and page data if WPINV_REMOVE_ALL_DATA constant is set to true in user's |
22 | 22 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
23 | 23 | * and to ensure only the site owner can perform this action. |
24 | 24 | */ |
25 | -if ( defined( 'WPINV_REMOVE_ALL_DATA' ) ) { |
|
25 | +if (defined('WPINV_REMOVE_ALL_DATA')) { |
|
26 | 26 | $remove_data = true === WPINV_REMOVE_ALL_DATA ? true : false; |
27 | 27 | } |
28 | 28 | |
29 | -if ( $remove_data ) { |
|
29 | +if ($remove_data) { |
|
30 | 30 | // Load Invoicing file. |
31 | - include_once( 'invoicing.php' ); |
|
31 | + include_once('invoicing.php'); |
|
32 | 32 | |
33 | 33 | // Roles + caps. |
34 | - include_once( dirname( __FILE__ ) . '/includes/admin/install.php' ); |
|
34 | + include_once(dirname(__FILE__) . '/includes/admin/install.php'); |
|
35 | 35 | wpinv_remove_admin_caps(); |
36 | 36 | |
37 | - $settings = get_option( 'wpinv_settings' ); |
|
37 | + $settings = get_option('wpinv_settings'); |
|
38 | 38 | |
39 | 39 | // Delete pages. |
40 | - $wpi_pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page' ); |
|
41 | - foreach ( $wpi_pages as $page ) { |
|
42 | - if ( !empty( $page ) && !empty( $settings[ $page ] ) ) { |
|
43 | - wp_delete_post( $settings[ $page ], true ); |
|
40 | + $wpi_pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page'); |
|
41 | + foreach ($wpi_pages as $page) { |
|
42 | + if (!empty($page) && !empty($settings[$page])) { |
|
43 | + wp_delete_post($settings[$page], true); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Delete posts + data. |
48 | - $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );" ); |
|
49 | - $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); |
|
48 | + $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );"); |
|
49 | + $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;"); |
|
50 | 50 | |
51 | 51 | // Delete comments. |
52 | - $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';" ); |
|
53 | - $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" ); |
|
52 | + $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';"); |
|
53 | + $wpdb->query("DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;"); |
|
54 | 54 | |
55 | 55 | // Delete user meta. |
56 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';" ); |
|
56 | + $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';"); |
|
57 | 57 | |
58 | 58 | // Cleanup Cron Schedule |
59 | - wp_clear_scheduled_hook( 'wp_session_garbage_collection' ); |
|
60 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
59 | + wp_clear_scheduled_hook('wp_session_garbage_collection'); |
|
60 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
61 | 61 | |
62 | 62 | // Delete options. |
63 | - $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';" ); |
|
63 | + $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';"); |
|
64 | 64 | |
65 | 65 | // Clear any cached data that has been removed |
66 | 66 | wp_cache_flush(); |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -add_action( 'wpinv_paypal_cc_form', '__return_false' ); |
|
6 | -add_filter( 'wpinv_paypal_support_subscription', '__return_true' ); |
|
5 | +add_action('wpinv_paypal_cc_form', '__return_false'); |
|
6 | +add_filter('wpinv_paypal_support_subscription', '__return_true'); |
|
7 | 7 | |
8 | -function wpinv_process_paypal_payment( $purchase_data ) { |
|
9 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
10 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
8 | +function wpinv_process_paypal_payment($purchase_data) { |
|
9 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
10 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | // Collect payment data |
@@ -25,30 +25,30 @@ discard block |
||
25 | 25 | ); |
26 | 26 | |
27 | 27 | // Record the pending payment |
28 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
28 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
29 | 29 | |
30 | 30 | // Check payment |
31 | - if ( ! $invoice ) { |
|
31 | + if (!$invoice) { |
|
32 | 32 | // Record the error |
33 | - wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $payment ); |
|
33 | + wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $payment); |
|
34 | 34 | // Problems? send back |
35 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
35 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
36 | 36 | } else { |
37 | 37 | // Only send to PayPal if the pending payment is created successfully |
38 | - $listener_url = wpinv_get_ipn_url( 'paypal' ); |
|
38 | + $listener_url = wpinv_get_ipn_url('paypal'); |
|
39 | 39 | |
40 | 40 | // Get the success url |
41 | - $return_url = add_query_arg( array( |
|
41 | + $return_url = add_query_arg(array( |
|
42 | 42 | 'payment-confirm' => 'paypal', |
43 | 43 | 'invoice-id' => $invoice->ID |
44 | - ), get_permalink( wpinv_get_option( 'success_page', false ) ) ); |
|
44 | + ), get_permalink(wpinv_get_option('success_page', false))); |
|
45 | 45 | |
46 | 46 | // Get the PayPal redirect uri |
47 | - $paypal_redirect = trailingslashit( wpinv_get_paypal_redirect() ) . '?'; |
|
47 | + $paypal_redirect = trailingslashit(wpinv_get_paypal_redirect()) . '?'; |
|
48 | 48 | |
49 | 49 | // Setup PayPal arguments |
50 | 50 | $paypal_args = array( |
51 | - 'business' => wpinv_get_option( 'paypal_email', false ), |
|
51 | + 'business' => wpinv_get_option('paypal_email', false), |
|
52 | 52 | 'email' => $invoice->get_email(), |
53 | 53 | 'first_name' => $invoice->get_first_name(), |
54 | 54 | 'last_name' => $invoice->get_last_name(), |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | 'shipping' => '0', |
58 | 58 | 'no_note' => '1', |
59 | 59 | 'currency_code' => wpinv_get_currency(), |
60 | - 'charset' => get_bloginfo( 'charset' ), |
|
60 | + 'charset' => get_bloginfo('charset'), |
|
61 | 61 | 'custom' => $invoice->ID, |
62 | 62 | 'rm' => '2', |
63 | 63 | 'return' => $return_url, |
64 | - 'cancel_return' => wpinv_get_failed_transaction_uri( '?invoice-id=' . $invoice->ID ), |
|
64 | + 'cancel_return' => wpinv_get_failed_transaction_uri('?invoice-id=' . $invoice->ID), |
|
65 | 65 | 'notify_url' => $listener_url, |
66 | - 'cbt' => get_bloginfo( 'name' ), |
|
66 | + 'cbt' => get_bloginfo('name'), |
|
67 | 67 | 'bn' => 'WPInvoicing_SP', |
68 | 68 | 'lc' => 'US', // this will force paypal site to english |
69 | - 'landing_page' => apply_filters( 'wpinv_paypal_standard_landing_page', 'billing', $invoice ), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account. |
|
69 | + 'landing_page' => apply_filters('wpinv_paypal_standard_landing_page', 'billing', $invoice), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account. |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $paypal_args['address1'] = $invoice->get_address(); |
@@ -80,57 +80,57 @@ discard block |
||
80 | 80 | 'upload' => '1' |
81 | 81 | ); |
82 | 82 | |
83 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
83 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
84 | 84 | |
85 | 85 | // Add cart items |
86 | 86 | $i = 1; |
87 | - if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) { |
|
88 | - foreach ( $purchase_data['cart_details'] as $item ) { |
|
87 | + if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) { |
|
88 | + foreach ($purchase_data['cart_details'] as $item) { |
|
89 | 89 | $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1; |
90 | - $item_amount = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 ); |
|
90 | + $item_amount = wpinv_sanitize_amount($item['subtotal'] / $item['quantity'], 2); |
|
91 | 91 | |
92 | - if ( $item_amount <= 0 ) { |
|
92 | + if ($item_amount <= 0) { |
|
93 | 93 | $item_amount = 0; |
94 | 94 | } |
95 | 95 | |
96 | - $paypal_args['item_number_' . $i ] = $item['id']; |
|
97 | - $paypal_args['item_name_' . $i ] = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) ); |
|
98 | - $paypal_args['quantity_' . $i ] = $item['quantity']; |
|
99 | - $paypal_args['amount_' . $i ] = $item_amount; |
|
100 | - $paypal_args['discount_amount_' . $i ] = wpinv_sanitize_amount( $item['discount'], 2 ); |
|
96 | + $paypal_args['item_number_' . $i] = $item['id']; |
|
97 | + $paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8')); |
|
98 | + $paypal_args['quantity_' . $i] = $item['quantity']; |
|
99 | + $paypal_args['amount_' . $i] = $item_amount; |
|
100 | + $paypal_args['discount_amount_' . $i] = wpinv_sanitize_amount($item['discount'], 2); |
|
101 | 101 | |
102 | 102 | $i++; |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Add taxes to the cart |
107 | - if ( wpinv_use_taxes() ) { |
|
108 | - $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float)$invoice->get_tax(), 2 ); |
|
107 | + if (wpinv_use_taxes()) { |
|
108 | + $paypal_args['tax_cart'] = wpinv_sanitize_amount((float)$invoice->get_tax(), 2); |
|
109 | 109 | } |
110 | 110 | |
111 | - $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice ); |
|
111 | + $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice); |
|
112 | 112 | |
113 | 113 | // Build query |
114 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
114 | + $paypal_redirect .= http_build_query($paypal_args); |
|
115 | 115 | |
116 | 116 | // Fix for some sites that encode the entities |
117 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
117 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
118 | 118 | |
119 | 119 | // Get rid of cart contents |
120 | 120 | wpinv_empty_cart(); |
121 | 121 | |
122 | 122 | // Redirect to PayPal |
123 | - wp_redirect( $paypal_redirect ); |
|
123 | + wp_redirect($paypal_redirect); |
|
124 | 124 | exit; |
125 | 125 | } |
126 | 126 | } |
127 | -add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' ); |
|
127 | +add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment'); |
|
128 | 128 | |
129 | -function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) { |
|
130 | - if ( $invoice->is_recurring() && $item_id = $invoice->get_recurring() ) { |
|
131 | - $item = new WPInv_Item( $item_id ); |
|
129 | +function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) { |
|
130 | + if ($invoice->is_recurring() && $item_id = $invoice->get_recurring()) { |
|
131 | + $item = new WPInv_Item($item_id); |
|
132 | 132 | |
133 | - if ( empty( $item ) ) { |
|
133 | + if (empty($item)) { |
|
134 | 134 | return $paypal_args; |
135 | 135 | } |
136 | 136 | |
@@ -138,24 +138,24 @@ discard block |
||
138 | 138 | $interval = $item->get_recurring_interval(); |
139 | 139 | $bill_times = (int)$item->get_recurring_limit(); |
140 | 140 | |
141 | - $initial_amount = wpinv_sanitize_amount( $invoice->get_total(), 2 ); |
|
142 | - $recurring_amount = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 ); |
|
141 | + $initial_amount = wpinv_sanitize_amount($invoice->get_total(), 2); |
|
142 | + $recurring_amount = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2); |
|
143 | 143 | |
144 | 144 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
145 | 145 | $paypal_args['sra'] = '1'; |
146 | 146 | $paypal_args['src'] = '1'; |
147 | 147 | |
148 | 148 | // Set item description |
149 | - $paypal_args['item_name'] = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( array( 'id' => $item->ID ) ), ENT_COMPAT, 'UTF-8' ) ); |
|
149 | + $paypal_args['item_name'] = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name(array('id' => $item->ID)), ENT_COMPAT, 'UTF-8')); |
|
150 | 150 | |
151 | - if ( $invoice->is_free_trial() && $item->has_free_trial() ) { |
|
151 | + if ($invoice->is_free_trial() && $item->has_free_trial()) { |
|
152 | 152 | $paypal_args['a1'] = $initial_amount; |
153 | 153 | $paypal_args['p1'] = $item->get_trial_interval(); |
154 | 154 | $paypal_args['t1'] = $item->get_trial_period(); |
155 | 155 | |
156 | 156 | // Set the recurring amount |
157 | 157 | $paypal_args['a3'] = $recurring_amount; |
158 | - } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) { |
|
158 | + } else if ($initial_amount != $recurring_amount && $bill_times != 1) { |
|
159 | 159 | $paypal_args['a1'] = $initial_amount; |
160 | 160 | $paypal_args['p1'] = $interval; |
161 | 161 | $paypal_args['t1'] = $period; |
@@ -163,63 +163,63 @@ discard block |
||
163 | 163 | // Set the recurring amount |
164 | 164 | $paypal_args['a3'] = $recurring_amount; |
165 | 165 | |
166 | - if ( $bill_times > 1 ) { |
|
166 | + if ($bill_times > 1) { |
|
167 | 167 | $bill_times--; |
168 | 168 | } |
169 | 169 | } else { |
170 | - $paypal_args['a3'] = $initial_amount; |
|
170 | + $paypal_args['a3'] = $initial_amount; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | $paypal_args['p3'] = $interval; |
174 | 174 | $paypal_args['t3'] = $period; |
175 | 175 | |
176 | - if ( $bill_times > 1 ) { |
|
176 | + if ($bill_times > 1) { |
|
177 | 177 | // Make sure it's not over the max of 52 |
178 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
178 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // Remove cart items |
182 | 182 | $i = 1; |
183 | - if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) { |
|
184 | - foreach ( $purchase_data['cart_details'] as $item ) { |
|
185 | - if ( isset( $paypal_args['item_number_' . $i] ) ) { |
|
186 | - unset( $paypal_args['item_number_' . $i] ); |
|
183 | + if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) { |
|
184 | + foreach ($purchase_data['cart_details'] as $item) { |
|
185 | + if (isset($paypal_args['item_number_' . $i])) { |
|
186 | + unset($paypal_args['item_number_' . $i]); |
|
187 | 187 | } |
188 | - if ( isset( $paypal_args['item_name_' . $i] ) ) { |
|
189 | - unset( $paypal_args['item_name_' . $i] ); |
|
188 | + if (isset($paypal_args['item_name_' . $i])) { |
|
189 | + unset($paypal_args['item_name_' . $i]); |
|
190 | 190 | } |
191 | - if ( isset( $paypal_args['quantity_' . $i] ) ) { |
|
192 | - unset( $paypal_args['quantity_' . $i] ); |
|
191 | + if (isset($paypal_args['quantity_' . $i])) { |
|
192 | + unset($paypal_args['quantity_' . $i]); |
|
193 | 193 | } |
194 | - if ( isset( $paypal_args['amount_' . $i] ) ) { |
|
195 | - unset( $paypal_args['amount_' . $i] ); |
|
194 | + if (isset($paypal_args['amount_' . $i])) { |
|
195 | + unset($paypal_args['amount_' . $i]); |
|
196 | 196 | } |
197 | - if ( isset( $paypal_args['discount_amount_' . $i] ) ) { |
|
198 | - unset( $paypal_args['discount_amount_' . $i] ); |
|
197 | + if (isset($paypal_args['discount_amount_' . $i])) { |
|
198 | + unset($paypal_args['discount_amount_' . $i]); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $i++; |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - if ( isset( $paypal_args['tax_cart'] ) ) { |
|
206 | - unset( $paypal_args['tax_cart'] ); |
|
205 | + if (isset($paypal_args['tax_cart'])) { |
|
206 | + unset($paypal_args['tax_cart']); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( isset( $paypal_args['upload'] ) ) { |
|
210 | - unset( $paypal_args['upload'] ); |
|
209 | + if (isset($paypal_args['upload'])) { |
|
210 | + unset($paypal_args['upload']); |
|
211 | 211 | } |
212 | 212 | |
213 | - $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice ); |
|
213 | + $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | return $paypal_args; |
217 | 217 | } |
218 | -add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 ); |
|
218 | +add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3); |
|
219 | 219 | |
220 | 220 | function wpinv_process_paypal_ipn() { |
221 | 221 | // Check the request method is POST |
222 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
222 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | $post_data = ''; |
228 | 228 | |
229 | 229 | // Fallback just in case post_max_size is lower than needed |
230 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
231 | - $post_data = file_get_contents( 'php://input' ); |
|
230 | + if (ini_get('allow_url_fopen')) { |
|
231 | + $post_data = file_get_contents('php://input'); |
|
232 | 232 | } else { |
233 | 233 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
234 | - ini_set( 'post_max_size', '12M' ); |
|
234 | + ini_set('post_max_size', '12M'); |
|
235 | 235 | } |
236 | 236 | // Start the encoded data collection with notification command |
237 | 237 | $encoded_data = 'cmd=_notify-validate'; |
@@ -240,43 +240,43 @@ discard block |
||
240 | 240 | $arg_separator = wpinv_get_php_arg_separator_output(); |
241 | 241 | |
242 | 242 | // Verify there is a post_data |
243 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
243 | + if ($post_data || strlen($post_data) > 0) { |
|
244 | 244 | // Append the data |
245 | - $encoded_data .= $arg_separator.$post_data; |
|
245 | + $encoded_data .= $arg_separator . $post_data; |
|
246 | 246 | } else { |
247 | 247 | // Check if POST is empty |
248 | - if ( empty( $_POST ) ) { |
|
248 | + if (empty($_POST)) { |
|
249 | 249 | // Nothing to do |
250 | 250 | return; |
251 | 251 | } else { |
252 | 252 | // Loop through each POST |
253 | - foreach ( $_POST as $key => $value ) { |
|
253 | + foreach ($_POST as $key => $value) { |
|
254 | 254 | // Encode the value and append the data |
255 | - $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
255 | + $encoded_data .= $arg_separator . "$key=" . urlencode($value); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | // Convert collected post data to an array |
261 | - parse_str( $encoded_data, $encoded_data_array ); |
|
261 | + parse_str($encoded_data, $encoded_data_array); |
|
262 | 262 | |
263 | - foreach ( $encoded_data_array as $key => $value ) { |
|
264 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
265 | - $new_key = str_replace( '&', '&', $key ); |
|
266 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
263 | + foreach ($encoded_data_array as $key => $value) { |
|
264 | + if (false !== strpos($key, 'amp;')) { |
|
265 | + $new_key = str_replace('&', '&', $key); |
|
266 | + $new_key = str_replace('amp;', '&', $new_key); |
|
267 | 267 | |
268 | - unset( $encoded_data_array[ $key ] ); |
|
269 | - $encoded_data_array[ $new_key ] = $value; |
|
268 | + unset($encoded_data_array[$key]); |
|
269 | + $encoded_data_array[$new_key] = $value; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Get the PayPal redirect uri |
274 | - $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
274 | + $paypal_redirect = wpinv_get_paypal_redirect(true); |
|
275 | 275 | |
276 | - if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
276 | + if (!wpinv_get_option('disable_paypal_verification', false)) { |
|
277 | 277 | // Validate the IPN |
278 | 278 | |
279 | - $remote_post_vars = array( |
|
279 | + $remote_post_vars = array( |
|
280 | 280 | 'method' => 'POST', |
281 | 281 | 'timeout' => 45, |
282 | 282 | 'redirection' => 5, |
@@ -294,21 +294,21 @@ discard block |
||
294 | 294 | ); |
295 | 295 | |
296 | 296 | // Get response |
297 | - $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
297 | + $api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars); |
|
298 | 298 | |
299 | - if ( is_wp_error( $api_response ) ) { |
|
300 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
299 | + if (is_wp_error($api_response)) { |
|
300 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response))); |
|
301 | 301 | return; // Something went wrong |
302 | 302 | } |
303 | 303 | |
304 | - if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
305 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
304 | + if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) { |
|
305 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response))); |
|
306 | 306 | return; // Response not okay |
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Check if $post_data_array has been populated |
311 | - if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
311 | + if (!is_array($encoded_data_array) && !empty($encoded_data_array)) |
|
312 | 312 | return; |
313 | 313 | |
314 | 314 | $defaults = array( |
@@ -316,215 +316,215 @@ discard block |
||
316 | 316 | 'payment_status' => '' |
317 | 317 | ); |
318 | 318 | |
319 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
319 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
320 | 320 | |
321 | - $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
321 | + $invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
322 | 322 | |
323 | - wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ ); |
|
323 | + wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__); |
|
324 | 324 | |
325 | - if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
325 | + if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) { |
|
326 | 326 | // Allow PayPal IPN types to be processed separately |
327 | - do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
327 | + do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id); |
|
328 | 328 | } else { |
329 | 329 | // Fallback to web accept just in case the txn_type isn't present |
330 | - do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id ); |
|
330 | + do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id); |
|
331 | 331 | } |
332 | 332 | exit; |
333 | 333 | } |
334 | -add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' ); |
|
334 | +add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn'); |
|
335 | 335 | |
336 | -function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) { |
|
337 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
336 | +function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) { |
|
337 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
338 | 338 | return; |
339 | 339 | } |
340 | 340 | |
341 | - if( empty( $invoice_id ) ) { |
|
341 | + if (empty($invoice_id)) { |
|
342 | 342 | return; |
343 | 343 | } |
344 | 344 | |
345 | 345 | // Collect payment details |
346 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
346 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
347 | 347 | $paypal_amount = $data['mc_gross']; |
348 | - $payment_status = strtolower( $data['payment_status'] ); |
|
349 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
350 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
351 | - $payment_meta = wpinv_get_invoice_meta( $invoice_id ); |
|
348 | + $payment_status = strtolower($data['payment_status']); |
|
349 | + $currency_code = strtolower($data['mc_currency']); |
|
350 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
351 | + $payment_meta = wpinv_get_invoice_meta($invoice_id); |
|
352 | 352 | |
353 | - if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
353 | + if (wpinv_get_payment_gateway($invoice_id) != 'paypal') { |
|
354 | 354 | return; // this isn't a PayPal standard IPN |
355 | 355 | } |
356 | 356 | |
357 | 357 | // Verify payment recipient |
358 | - if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) { |
|
359 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
360 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
361 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
358 | + if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) { |
|
359 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
360 | + wpinv_update_payment_status($invoice_id, 'wpi-failed'); |
|
361 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing')); |
|
362 | 362 | return; |
363 | 363 | } |
364 | 364 | |
365 | 365 | // Verify payment currency |
366 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
367 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
368 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
369 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
366 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
367 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
368 | + wpinv_update_payment_status($invoice_id, 'wpi-failed'); |
|
369 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing')); |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
373 | + if (!wpinv_get_payment_user_email($invoice_id)) { |
|
374 | 374 | // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
375 | 375 | // No email associated with purchase, so store from PayPal |
376 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
376 | + wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']); |
|
377 | 377 | |
378 | 378 | // Setup and store the customer's details |
379 | 379 | $user_info = array( |
380 | 380 | 'user_id' => '-1', |
381 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
382 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
383 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
381 | + 'email' => sanitize_text_field($data['payer_email']), |
|
382 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
383 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
384 | 384 | 'discount' => '', |
385 | 385 | ); |
386 | - $user_info['address'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
387 | - $user_info['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
388 | - $user_info['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
389 | - $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
390 | - $user_info['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
386 | + $user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
387 | + $user_info['city'] = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
388 | + $user_info['state'] = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
389 | + $user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
390 | + $user_info['zip'] = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
391 | 391 | |
392 | 392 | $payment_meta['user_info'] = $user_info; |
393 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
393 | + wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta); |
|
394 | 394 | } |
395 | 395 | |
396 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
396 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
397 | 397 | // Process a refund |
398 | - wpinv_process_paypal_refund( $data, $invoice_id ); |
|
398 | + wpinv_process_paypal_refund($data, $invoice_id); |
|
399 | 399 | } else { |
400 | - if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
400 | + if (get_post_status($invoice_id) == 'publish') { |
|
401 | 401 | return; // Only paid payments once |
402 | 402 | } |
403 | 403 | |
404 | 404 | // Retrieve the total purchase amount (before PayPal) |
405 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
405 | + $payment_amount = wpinv_payment_total($invoice_id); |
|
406 | 406 | |
407 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
407 | + if (number_format((float)$paypal_amount, 2) < number_format((float)$payment_amount, 2)) { |
|
408 | 408 | // The prices don't match |
409 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
410 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
411 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
409 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
410 | + wpinv_update_payment_status($invoice_id, 'wpi-failed'); |
|
411 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing')); |
|
412 | 412 | return; |
413 | 413 | } |
414 | - if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
414 | + if ($purchase_key != wpinv_get_payment_key($invoice_id)) { |
|
415 | 415 | // Purchase keys don't match |
416 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
417 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
418 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
416 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id); |
|
417 | + wpinv_update_payment_status($invoice_id, 'wpi-failed'); |
|
418 | + wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing')); |
|
419 | 419 | return; |
420 | 420 | } |
421 | 421 | |
422 | - if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) { |
|
423 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ) ); |
|
424 | - wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] ); |
|
425 | - wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
426 | - } else if ( 'wpi-pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
422 | + if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) { |
|
423 | + wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id'])); |
|
424 | + wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']); |
|
425 | + wpinv_update_payment_status($invoice_id, 'publish'); |
|
426 | + } else if ('wpi-pending' == $payment_status && isset($data['pending_reason'])) { |
|
427 | 427 | // Look for possible pending reasons, such as an echeck |
428 | 428 | $note = ''; |
429 | 429 | |
430 | - switch( strtolower( $data['pending_reason'] ) ) { |
|
430 | + switch (strtolower($data['pending_reason'])) { |
|
431 | 431 | case 'echeck' : |
432 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
432 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing'); |
|
433 | 433 | break; |
434 | 434 | |
435 | 435 | case 'address' : |
436 | - $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
436 | + $note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing'); |
|
437 | 437 | break; |
438 | 438 | |
439 | 439 | case 'intl' : |
440 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
440 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing'); |
|
441 | 441 | break; |
442 | 442 | |
443 | 443 | case 'multi-currency' : |
444 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' ); |
|
444 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing'); |
|
445 | 445 | break; |
446 | 446 | |
447 | 447 | case 'paymentreview' : |
448 | 448 | case 'regulatory_review' : |
449 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' ); |
|
449 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing'); |
|
450 | 450 | break; |
451 | 451 | |
452 | 452 | case 'unilateral' : |
453 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
453 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing'); |
|
454 | 454 | break; |
455 | 455 | |
456 | 456 | case 'upgrade' : |
457 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
457 | + $note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing'); |
|
458 | 458 | break; |
459 | 459 | |
460 | 460 | case 'verify' : |
461 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
461 | + $note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing'); |
|
462 | 462 | break; |
463 | 463 | |
464 | 464 | case 'other' : |
465 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
465 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing'); |
|
466 | 466 | break; |
467 | 467 | } |
468 | 468 | |
469 | - if ( ! empty( $note ) ) { |
|
470 | - wpinv_insert_payment_note( $invoice_id, $note ); |
|
469 | + if (!empty($note)) { |
|
470 | + wpinv_insert_payment_note($invoice_id, $note); |
|
471 | 471 | } |
472 | 472 | } else { |
473 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
473 | + wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status)); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | } |
477 | -add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 ); |
|
477 | +add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2); |
|
478 | 478 | |
479 | 479 | // Process PayPal subscription sign ups |
480 | -add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' ); |
|
480 | +add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup'); |
|
481 | 481 | |
482 | 482 | // Process PayPal subscription payments |
483 | -add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' ); |
|
483 | +add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment'); |
|
484 | 484 | |
485 | 485 | // Process PayPal subscription cancellations |
486 | -add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' ); |
|
486 | +add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel'); |
|
487 | 487 | |
488 | 488 | // Process PayPal subscription end of term notices |
489 | -add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' ); |
|
489 | +add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot'); |
|
490 | 490 | |
491 | 491 | // Process PayPal payment failed |
492 | -add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' ); |
|
492 | +add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed'); |
|
493 | 493 | |
494 | 494 | |
495 | 495 | /** |
496 | 496 | * Process the subscription started IPN. |
497 | 497 | */ |
498 | -function wpinv_process_paypal_subscr_signup( $ipn_data ) { |
|
499 | - $parent_invoice_id = absint( $ipn_data['custom'] ); |
|
500 | - if( empty( $parent_invoice_id ) ) { |
|
498 | +function wpinv_process_paypal_subscr_signup($ipn_data) { |
|
499 | + $parent_invoice_id = absint($ipn_data['custom']); |
|
500 | + if (empty($parent_invoice_id)) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
504 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
505 | - if ( empty( $invoice ) ) { |
|
504 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
505 | + if (empty($invoice)) { |
|
506 | 506 | return; |
507 | 507 | } |
508 | 508 | |
509 | - if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) { |
|
510 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ) ); |
|
511 | - wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['invoice'] ); |
|
509 | + if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) { |
|
510 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice'])); |
|
511 | + wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['invoice']); |
|
512 | 512 | } |
513 | 513 | |
514 | - wpinv_update_payment_status( $parent_invoice_id, 'publish' ); |
|
514 | + wpinv_update_payment_status($parent_invoice_id, 'publish'); |
|
515 | 515 | sleep(1); |
516 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ) ); |
|
516 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id'])); |
|
517 | 517 | |
518 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
519 | - if ( false === $subscription ) { |
|
518 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
519 | + if (false === $subscription) { |
|
520 | 520 | return; |
521 | 521 | } |
522 | 522 | |
523 | - $cart_details = $invoice->cart_details; |
|
523 | + $cart_details = $invoice->cart_details; |
|
524 | 524 | |
525 | - if ( !empty( $cart_details ) ) { |
|
526 | - foreach ( $cart_details as $cart_item ) { |
|
527 | - $item = new WPInv_Item( $cart_item['id'] ); |
|
525 | + if (!empty($cart_details)) { |
|
526 | + foreach ($cart_details as $cart_item) { |
|
527 | + $item = new WPInv_Item($cart_item['id']); |
|
528 | 528 | |
529 | 529 | $status = $invoice->is_free_trial() && $item->has_free_trial() ? 'trialing' : 'active'; |
530 | 530 | |
@@ -533,15 +533,15 @@ discard block |
||
533 | 533 | 'status' => $status, |
534 | 534 | 'period' => $item->get_recurring_period(), |
535 | 535 | 'initial_amount' => $invoice->get_total(), |
536 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
536 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
537 | 537 | 'interval' => $item->get_recurring_interval(), |
538 | 538 | 'bill_times' => $item->get_recurring_limit(), |
539 | - 'expiration' => $invoice->get_new_expiration( $cart_item['id'] ), |
|
539 | + 'expiration' => $invoice->get_new_expiration($cart_item['id']), |
|
540 | 540 | 'profile_id' => $ipn_data['subscr_id'], |
541 | - 'created' => date_i18n( 'Y-m-d H:i:s', strtotime( $ipn_data['subscr_date'] ) ) |
|
541 | + 'created' => date_i18n('Y-m-d H:i:s', strtotime($ipn_data['subscr_date'])) |
|
542 | 542 | ); |
543 | 543 | |
544 | - if ( $item->has_free_trial() ) { |
|
544 | + if ($item->has_free_trial()) { |
|
545 | 545 | $args['trial_period'] = $item->get_trial_period(); |
546 | 546 | $args['trial_interval'] = $item->get_trial_interval(); |
547 | 547 | } else { |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | |
553 | - $subscription->update_subscription( $args ); |
|
553 | + $subscription->update_subscription($args); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | } |
@@ -558,39 +558,39 @@ discard block |
||
558 | 558 | /** |
559 | 559 | * Process the subscription payment received IPN. |
560 | 560 | */ |
561 | -function wpinv_process_paypal_subscr_payment( $ipn_data ) { |
|
562 | - $parent_invoice_id = absint( $ipn_data['custom'] ); |
|
561 | +function wpinv_process_paypal_subscr_payment($ipn_data) { |
|
562 | + $parent_invoice_id = absint($ipn_data['custom']); |
|
563 | 563 | |
564 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
565 | - if ( false === $subscription ) { |
|
564 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
565 | + if (false === $subscription) { |
|
566 | 566 | return; |
567 | 567 | } |
568 | 568 | |
569 | - $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id ); |
|
570 | - $signup_date = strtotime( $subscription->get_subscription_created() ); |
|
571 | - $today = date_i18n( 'Y-m-d', $signup_date ) == date_i18n( 'Y-m-d', strtotime( $ipn_data['payment_date'] ) ); |
|
569 | + $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id); |
|
570 | + $signup_date = strtotime($subscription->get_subscription_created()); |
|
571 | + $today = date_i18n('Y-m-d', $signup_date) == date_i18n('Y-m-d', strtotime($ipn_data['payment_date'])); |
|
572 | 572 | |
573 | 573 | // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet. |
574 | - if ( $today && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) { |
|
575 | - wpinv_update_payment_status( $parent_invoice_id, 'publish' ); |
|
574 | + if ($today && (!$transaction_id || $transaction_id == $parent_invoice_id)) { |
|
575 | + wpinv_update_payment_status($parent_invoice_id, 'publish'); |
|
576 | 576 | sleep(1); |
577 | 577 | |
578 | 578 | // This is the very first payment |
579 | - wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] ); |
|
580 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ) ); |
|
579 | + wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']); |
|
580 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id'])); |
|
581 | 581 | return; |
582 | 582 | } |
583 | 583 | |
584 | - if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) { |
|
584 | + if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) { |
|
585 | 585 | return; // Payment already recorded |
586 | 586 | } |
587 | 587 | |
588 | - $currency_code = strtolower( $ipn_data['mc_currency'] ); |
|
588 | + $currency_code = strtolower($ipn_data['mc_currency']); |
|
589 | 589 | |
590 | 590 | // verify details |
591 | - if ( $currency_code != strtolower( wpinv_get_currency() ) ) { |
|
591 | + if ($currency_code != strtolower(wpinv_get_currency())) { |
|
592 | 592 | // the currency code is invalid |
593 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) ); |
|
593 | + wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data))); |
|
594 | 594 | return; |
595 | 595 | } |
596 | 596 | |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | 'transaction_id' => $ipn_data['txn_id'] |
600 | 600 | ); |
601 | 601 | |
602 | - $invoice = wpinv_recurring_add_subscription_payment( $parent_invoice_id, $args ); |
|
602 | + $invoice = wpinv_recurring_add_subscription_payment($parent_invoice_id, $args); |
|
603 | 603 | |
604 | - if ( !empty( $invoice ) ) { |
|
604 | + if (!empty($invoice)) { |
|
605 | 605 | sleep(1); |
606 | - wpinv_insert_payment_note( $invoice->ID, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ) ); |
|
606 | + wpinv_insert_payment_note($invoice->ID, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id'])); |
|
607 | 607 | |
608 | 608 | $invoice->renew_subscription(); |
609 | 609 | } |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | /** |
613 | 613 | * Process the subscription canceled IPN. |
614 | 614 | */ |
615 | -function wpinv_process_paypal_subscr_cancel( $ipn_data ) { |
|
616 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
615 | +function wpinv_process_paypal_subscr_cancel($ipn_data) { |
|
616 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
617 | 617 | |
618 | - if( false === $subscription ) { |
|
618 | + if (false === $subscription) { |
|
619 | 619 | return; |
620 | 620 | } |
621 | 621 | |
@@ -625,10 +625,10 @@ discard block |
||
625 | 625 | /** |
626 | 626 | * Process the subscription expired IPN. |
627 | 627 | */ |
628 | -function wpinv_process_paypal_subscr_eot( $ipn_data ) { |
|
629 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
628 | +function wpinv_process_paypal_subscr_eot($ipn_data) { |
|
629 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
630 | 630 | |
631 | - if( false === $subscription ) { |
|
631 | + if (false === $subscription) { |
|
632 | 632 | return; |
633 | 633 | } |
634 | 634 | |
@@ -638,45 +638,45 @@ discard block |
||
638 | 638 | /** |
639 | 639 | * Process the subscription payment failed IPN. |
640 | 640 | */ |
641 | -function wpinv_process_paypal_subscr_failed( $ipn_data ) { |
|
642 | - $subscription = wpinv_get_paypal_subscription( $ipn_data ); |
|
641 | +function wpinv_process_paypal_subscr_failed($ipn_data) { |
|
642 | + $subscription = wpinv_get_paypal_subscription($ipn_data); |
|
643 | 643 | |
644 | - if( false === $subscription ) { |
|
644 | + if (false === $subscription) { |
|
645 | 645 | return; |
646 | 646 | } |
647 | 647 | |
648 | 648 | $subscription->failing_subscription(); |
649 | 649 | |
650 | - do_action( 'wpinv_recurring_payment_failed', $subscription ); |
|
650 | + do_action('wpinv_recurring_payment_failed', $subscription); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
654 | 654 | * Retrieve the subscription this IPN notice is for. |
655 | 655 | */ |
656 | -function wpinv_get_paypal_subscription( $ipn_data = array() ) { |
|
657 | - $parent_invoice_id = absint( $ipn_data['custom'] ); |
|
656 | +function wpinv_get_paypal_subscription($ipn_data = array()) { |
|
657 | + $parent_invoice_id = absint($ipn_data['custom']); |
|
658 | 658 | |
659 | - if( empty( $parent_invoice_id ) ) { |
|
659 | + if (empty($parent_invoice_id)) { |
|
660 | 660 | return false; |
661 | 661 | } |
662 | 662 | |
663 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
664 | - if ( empty( $invoice ) ) { |
|
663 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
664 | + if (empty($invoice)) { |
|
665 | 665 | return false; |
666 | 666 | } |
667 | 667 | |
668 | - $subscription = wpinv_get_subscription( $ipn_data['subscr_id'], true ); |
|
668 | + $subscription = wpinv_get_subscription($ipn_data['subscr_id'], true); |
|
669 | 669 | |
670 | - if ( empty( $subscription ) ) { |
|
671 | - $subs = wpinv_get_subscriptions( array( 'parent_invoice_id' => $parent_invoice_id, 'numberposts' => 1 ) ); |
|
672 | - $subscription = reset( $subs ); |
|
670 | + if (empty($subscription)) { |
|
671 | + $subs = wpinv_get_subscriptions(array('parent_invoice_id' => $parent_invoice_id, 'numberposts' => 1)); |
|
672 | + $subscription = reset($subs); |
|
673 | 673 | |
674 | - if ( $subscription && $subscription->ID > 0 ) { |
|
674 | + if ($subscription && $subscription->ID > 0) { |
|
675 | 675 | // Update the profile ID so it is set for future renewals |
676 | - $subscription->update_subscription( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) ); |
|
676 | + $subscription->update_subscription(array('profile_id' => sanitize_text_field($ipn_data['subscr_id']))); |
|
677 | 677 | } else { |
678 | 678 | $subscription = $invoice; |
679 | - $subscription->update_subscription( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) ); |
|
679 | + $subscription->update_subscription(array('profile_id' => sanitize_text_field($ipn_data['subscr_id']))); |
|
680 | 680 | // No subscription found with a matching payment ID, bail |
681 | 681 | //return false; |
682 | 682 | } |
@@ -686,39 +686,39 @@ discard block |
||
686 | 686 | |
687 | 687 | } |
688 | 688 | |
689 | -function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) { |
|
689 | +function wpinv_process_paypal_refund($data, $invoice_id = 0) { |
|
690 | 690 | // Collect payment details |
691 | 691 | |
692 | - if( empty( $invoice_id ) ) { |
|
692 | + if (empty($invoice_id)) { |
|
693 | 693 | return; |
694 | 694 | } |
695 | 695 | |
696 | - if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) { |
|
696 | + if (get_post_status($invoice_id) == 'wpi-refunded') { |
|
697 | 697 | return; // Only refund payments once |
698 | 698 | } |
699 | 699 | |
700 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
700 | + $payment_amount = wpinv_payment_total($invoice_id); |
|
701 | 701 | $refund_amount = $data['mc_gross'] * -1; |
702 | 702 | |
703 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
704 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Partial PayPal refund processed: %s', 'invoicing' ), $data['parent_txn_id'] ) ); |
|
703 | + if (number_format((float)$refund_amount, 2) < number_format((float)$payment_amount, 2)) { |
|
704 | + wpinv_insert_payment_note($invoice_id, sprintf(__('Partial PayPal refund processed: %s', 'invoicing'), $data['parent_txn_id'])); |
|
705 | 705 | return; // This is a partial refund |
706 | 706 | } |
707 | 707 | |
708 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
709 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ) ); |
|
710 | - wpinv_update_payment_status( $invoice_id, 'wpi-refunded' ); |
|
708 | + wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code'])); |
|
709 | + wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id'])); |
|
710 | + wpinv_update_payment_status($invoice_id, 'wpi-refunded'); |
|
711 | 711 | } |
712 | 712 | |
713 | -function wpinv_get_paypal_redirect( $ssl_check = false ) { |
|
714 | - if ( is_ssl() || ! $ssl_check ) { |
|
713 | +function wpinv_get_paypal_redirect($ssl_check = false) { |
|
714 | + if (is_ssl() || !$ssl_check) { |
|
715 | 715 | $protocol = 'https://'; |
716 | 716 | } else { |
717 | 717 | $protocol = 'http://'; |
718 | 718 | } |
719 | 719 | |
720 | 720 | // Check the current payment mode |
721 | - if ( wpinv_is_test_mode( 'paypal' ) ) { |
|
721 | + if (wpinv_is_test_mode('paypal')) { |
|
722 | 722 | // Test mode |
723 | 723 | $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
724 | 724 | } else { |
@@ -726,67 +726,67 @@ discard block |
||
726 | 726 | $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
727 | 727 | } |
728 | 728 | |
729 | - return apply_filters( 'wpinv_paypal_uri', $paypal_uri ); |
|
729 | + return apply_filters('wpinv_paypal_uri', $paypal_uri); |
|
730 | 730 | } |
731 | 731 | |
732 | -function wpinv_paypal_success_page_content( $content ) { |
|
732 | +function wpinv_paypal_success_page_content($content) { |
|
733 | 733 | global $wpi_invoice; |
734 | 734 | |
735 | 735 | $session = wpinv_get_checkout_session(); |
736 | 736 | |
737 | - if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] ) ) { |
|
737 | + if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) { |
|
738 | 738 | return $content; |
739 | 739 | } |
740 | 740 | |
741 | - $invoice_id = !empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] ); |
|
741 | + $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']); |
|
742 | 742 | |
743 | - if ( empty( $invoice_id ) ) { |
|
743 | + if (empty($invoice_id)) { |
|
744 | 744 | return $content; |
745 | 745 | } |
746 | 746 | |
747 | - $wpi_invoice = wpinv_get_invoice( $invoice_id ); |
|
747 | + $wpi_invoice = wpinv_get_invoice($invoice_id); |
|
748 | 748 | |
749 | - if ( !empty( $wpi_invoice ) && 'wpi-pending' == $wpi_invoice->status ) { |
|
749 | + if (!empty($wpi_invoice) && 'wpi-pending' == $wpi_invoice->status) { |
|
750 | 750 | // Payment is still pending so show processing indicator to fix the Race Condition, issue # |
751 | 751 | ob_start(); |
752 | - wpinv_get_template_part( 'wpinv-payment-processing' ); |
|
752 | + wpinv_get_template_part('wpinv-payment-processing'); |
|
753 | 753 | $content = ob_get_clean(); |
754 | 754 | } |
755 | 755 | |
756 | 756 | return $content; |
757 | 757 | } |
758 | -add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' ); |
|
758 | +add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content'); |
|
759 | 759 | |
760 | -function wpinv_paypal_get_transaction_id( $invoice_id ) { |
|
760 | +function wpinv_paypal_get_transaction_id($invoice_id) { |
|
761 | 761 | $transaction_id = ''; |
762 | - $notes = wpinv_get_invoice_notes( $invoice_id ); |
|
762 | + $notes = wpinv_get_invoice_notes($invoice_id); |
|
763 | 763 | |
764 | - foreach ( $notes as $note ) { |
|
765 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
764 | + foreach ($notes as $note) { |
|
765 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
766 | 766 | $transaction_id = $match[1]; |
767 | 767 | continue; |
768 | 768 | } |
769 | 769 | } |
770 | 770 | |
771 | - return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id ); |
|
771 | + return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id); |
|
772 | 772 | } |
773 | -add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 ); |
|
773 | +add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1); |
|
774 | 774 | |
775 | -function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) { |
|
776 | - if ( $invoice->is_free_trial() || $transaction_id == $invoice_id ) { // Free trial does not have transaction at PayPal. |
|
775 | +function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) { |
|
776 | + if ($invoice->is_free_trial() || $transaction_id == $invoice_id) { // Free trial does not have transaction at PayPal. |
|
777 | 777 | $transaction_url = $invoice->get_view_url(); |
778 | 778 | } else { |
779 | - $sandbox = wpinv_is_test_mode( 'paypal' ) ? '.sandbox' : ''; |
|
779 | + $sandbox = wpinv_is_test_mode('paypal') ? '.sandbox' : ''; |
|
780 | 780 | $transaction_url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=' . $transaction_id; |
781 | 781 | } |
782 | 782 | |
783 | - $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
783 | + $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>'; |
|
784 | 784 | |
785 | - return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $invoice ); |
|
785 | + return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $invoice); |
|
786 | 786 | } |
787 | -add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 ); |
|
787 | +add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3); |
|
788 | 788 | |
789 | 789 | function wpinv_gateway_paypal_button_label($label) { |
790 | - return __( 'Proceed to PayPal', 'invoicing' ); |
|
790 | + return __('Proceed to PayPal', 'invoicing'); |
|
791 | 791 | } |
792 | -add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 ); |
|
793 | 792 | \ No newline at end of file |
793 | +add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1); |
|
794 | 794 | \ No newline at end of file |