@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) |
|
182 | + if (isset($name)) |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | $templates[] = $slug . '.php'; |
185 | 185 | |
186 | 186 | // Allow template parts to be filtered |
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
188 | 188 | |
189 | 189 | // Return the part that is found |
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
194 | 194 | // No file found yet |
195 | 195 | $located = false; |
196 | 196 | |
197 | 197 | // Try to find a template file |
198 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + foreach ((array) $template_names as $template_name) { |
|
199 | 199 | |
200 | 200 | // Continue if template is empty |
201 | - if ( empty( $template_name ) ) |
|
201 | + if (empty($template_name)) |
|
202 | 202 | continue; |
203 | 203 | |
204 | 204 | // Trim off any slashes from the template name |
205 | - $template_name = ltrim( $template_name, '/' ); |
|
205 | + $template_name = ltrim($template_name, '/'); |
|
206 | 206 | |
207 | 207 | // try locating this template file by looping through the template paths |
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
210 | + if (file_exists($template_path . $template_name)) { |
|
211 | 211 | $located = $template_path . $template_name; |
212 | 212 | break; |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
216 | + if (!empty($located)) { |
|
217 | 217 | break; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ((true == $load) && !empty($located)) |
|
222 | + load_template($located, $require_once); |
|
223 | 223 | |
224 | 224 | return $located; |
225 | 225 | } |
@@ -228,127 +228,127 @@ discard block |
||
228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
229 | 229 | |
230 | 230 | $file_paths = array( |
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
233 | 233 | 100 => wpinv_get_templates_dir() |
234 | 234 | ); |
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
237 | 237 | |
238 | 238 | // sort the file paths based on priority |
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
239 | + ksort($file_paths, SORT_NUMERIC); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map('trailingslashit', $file_paths); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | 246 | $pages = array(); |
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
247 | + $pages[] = wpinv_get_option('success_page'); |
|
248 | + $pages[] = wpinv_get_option('failure_page'); |
|
249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
257 | 257 | } |
258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
259 | 259 | |
260 | -function wpinv_add_body_classes( $class ) { |
|
261 | - $classes = (array)$class; |
|
260 | +function wpinv_add_body_classes($class) { |
|
261 | + $classes = (array) $class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
263 | + if (wpinv_is_checkout()) { |
|
264 | 264 | $classes[] = 'wpinv-checkout'; |
265 | 265 | $classes[] = 'wpinv-page'; |
266 | 266 | } |
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
268 | + if (wpinv_is_success_page()) { |
|
269 | 269 | $classes[] = 'wpinv-success'; |
270 | 270 | $classes[] = 'wpinv-page'; |
271 | 271 | } |
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
273 | + if (wpinv_is_failed_transaction_page()) { |
|
274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
275 | 275 | $classes[] = 'wpinv-page'; |
276 | 276 | } |
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
278 | + if (wpinv_is_invoice_history_page()) { |
|
279 | 279 | $classes[] = 'wpinv-history'; |
280 | 280 | $classes[] = 'wpinv-page'; |
281 | 281 | } |
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
283 | + if (wpinv_is_subscriptions_history_page()) { |
|
284 | 284 | $classes[] = 'wpinv-subscription'; |
285 | 285 | $classes[] = 'wpinv-page'; |
286 | 286 | } |
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
288 | + if (wpinv_is_test_mode()) { |
|
289 | 289 | $classes[] = 'wpinv-test-mode'; |
290 | 290 | $classes[] = 'wpinv-page'; |
291 | 291 | } |
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique($classes); |
|
294 | 294 | } |
295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
296 | 296 | |
297 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
298 | - $current = date( 'Y' ); |
|
299 | - $start_year = $current - absint( $years_before ); |
|
300 | - $end_year = $current + absint( $years_after ); |
|
301 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
297 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
298 | + $current = date('Y'); |
|
299 | + $start_year = $current - absint($years_before); |
|
300 | + $end_year = $current + absint($years_after); |
|
301 | + $selected = empty($selected) ? date('Y') : $selected; |
|
302 | 302 | $options = array(); |
303 | 303 | |
304 | - while ( $start_year <= $end_year ) { |
|
305 | - $options[ absint( $start_year ) ] = $start_year; |
|
304 | + while ($start_year <= $end_year) { |
|
305 | + $options[absint($start_year)] = $start_year; |
|
306 | 306 | $start_year++; |
307 | 307 | } |
308 | 308 | |
309 | - $output = wpinv_html_select( array( |
|
309 | + $output = wpinv_html_select(array( |
|
310 | 310 | 'name' => $name, |
311 | 311 | 'selected' => $selected, |
312 | 312 | 'options' => $options, |
313 | 313 | 'show_option_all' => false, |
314 | 314 | 'show_option_none' => false |
315 | - ) ); |
|
315 | + )); |
|
316 | 316 | |
317 | 317 | return $output; |
318 | 318 | } |
319 | 319 | |
320 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
320 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
321 | 321 | |
322 | 322 | $options = array( |
323 | - '1' => __( 'January', 'invoicing' ), |
|
324 | - '2' => __( 'February', 'invoicing' ), |
|
325 | - '3' => __( 'March', 'invoicing' ), |
|
326 | - '4' => __( 'April', 'invoicing' ), |
|
327 | - '5' => __( 'May', 'invoicing' ), |
|
328 | - '6' => __( 'June', 'invoicing' ), |
|
329 | - '7' => __( 'July', 'invoicing' ), |
|
330 | - '8' => __( 'August', 'invoicing' ), |
|
331 | - '9' => __( 'September', 'invoicing' ), |
|
332 | - '10' => __( 'October', 'invoicing' ), |
|
333 | - '11' => __( 'November', 'invoicing' ), |
|
334 | - '12' => __( 'December', 'invoicing' ), |
|
323 | + '1' => __('January', 'invoicing'), |
|
324 | + '2' => __('February', 'invoicing'), |
|
325 | + '3' => __('March', 'invoicing'), |
|
326 | + '4' => __('April', 'invoicing'), |
|
327 | + '5' => __('May', 'invoicing'), |
|
328 | + '6' => __('June', 'invoicing'), |
|
329 | + '7' => __('July', 'invoicing'), |
|
330 | + '8' => __('August', 'invoicing'), |
|
331 | + '9' => __('September', 'invoicing'), |
|
332 | + '10' => __('October', 'invoicing'), |
|
333 | + '11' => __('November', 'invoicing'), |
|
334 | + '12' => __('December', 'invoicing'), |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | // If no month is selected, default to the current month |
338 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
338 | + $selected = empty($selected) ? date('n') : $selected; |
|
339 | 339 | |
340 | - $output = wpinv_html_select( array( |
|
340 | + $output = wpinv_html_select(array( |
|
341 | 341 | 'name' => $name, |
342 | 342 | 'selected' => $selected, |
343 | 343 | 'options' => $options, |
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | |
348 | 348 | return $output; |
349 | 349 | } |
350 | 350 | |
351 | -function wpinv_html_select( $args = array() ) { |
|
351 | +function wpinv_html_select($args = array()) { |
|
352 | 352 | $defaults = array( |
353 | 353 | 'options' => array(), |
354 | 354 | 'name' => null, |
@@ -357,8 +357,8 @@ discard block |
||
357 | 357 | 'selected' => 0, |
358 | 358 | 'placeholder' => null, |
359 | 359 | 'multiple' => false, |
360 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
361 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
360 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
361 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
362 | 362 | 'data' => array(), |
363 | 363 | 'onchange' => null, |
364 | 364 | 'required' => false, |
@@ -366,74 +366,74 @@ discard block |
||
366 | 366 | 'readonly' => false, |
367 | 367 | ); |
368 | 368 | |
369 | - $args = wp_parse_args( $args, $defaults ); |
|
369 | + $args = wp_parse_args($args, $defaults); |
|
370 | 370 | |
371 | 371 | $data_elements = ''; |
372 | - foreach ( $args['data'] as $key => $value ) { |
|
373 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
372 | + foreach ($args['data'] as $key => $value) { |
|
373 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
374 | 374 | } |
375 | 375 | |
376 | - if( $args['multiple'] ) { |
|
376 | + if ($args['multiple']) { |
|
377 | 377 | $multiple = ' MULTIPLE'; |
378 | 378 | } else { |
379 | 379 | $multiple = ''; |
380 | 380 | } |
381 | 381 | |
382 | - if( $args['placeholder'] ) { |
|
382 | + if ($args['placeholder']) { |
|
383 | 383 | $placeholder = $args['placeholder']; |
384 | 384 | } else { |
385 | 385 | $placeholder = ''; |
386 | 386 | } |
387 | 387 | |
388 | 388 | $options = ''; |
389 | - if( !empty( $args['onchange'] ) ) { |
|
390 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
389 | + if (!empty($args['onchange'])) { |
|
390 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
391 | 391 | } |
392 | 392 | |
393 | - if( !empty( $args['required'] ) ) { |
|
393 | + if (!empty($args['required'])) { |
|
394 | 394 | $options .= ' required="required"'; |
395 | 395 | } |
396 | 396 | |
397 | - if( !empty( $args['disabled'] ) ) { |
|
397 | + if (!empty($args['disabled'])) { |
|
398 | 398 | $options .= ' disabled'; |
399 | 399 | } |
400 | 400 | |
401 | - if( !empty( $args['readonly'] ) ) { |
|
401 | + if (!empty($args['readonly'])) { |
|
402 | 402 | $options .= ' readonly'; |
403 | 403 | } |
404 | 404 | |
405 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
406 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
405 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
406 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
407 | 407 | |
408 | - if ( $args['show_option_all'] ) { |
|
409 | - if( $args['multiple'] ) { |
|
410 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
408 | + if ($args['show_option_all']) { |
|
409 | + if ($args['multiple']) { |
|
410 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
411 | 411 | } else { |
412 | - $selected = selected( $args['selected'], 0, false ); |
|
412 | + $selected = selected($args['selected'], 0, false); |
|
413 | 413 | } |
414 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
414 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
415 | 415 | } |
416 | 416 | |
417 | - if ( !empty( $args['options'] ) ) { |
|
417 | + if (!empty($args['options'])) { |
|
418 | 418 | |
419 | - if ( $args['show_option_none'] ) { |
|
420 | - if( $args['multiple'] ) { |
|
421 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
419 | + if ($args['show_option_none']) { |
|
420 | + if ($args['multiple']) { |
|
421 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
422 | 422 | } else { |
423 | - $selected = selected( $args['selected'] === "", true, false ); |
|
423 | + $selected = selected($args['selected'] === "", true, false); |
|
424 | 424 | } |
425 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
425 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
426 | 426 | } |
427 | 427 | |
428 | - foreach( $args['options'] as $key => $option ) { |
|
428 | + foreach ($args['options'] as $key => $option) { |
|
429 | 429 | |
430 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
431 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
430 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
431 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
432 | 432 | } else { |
433 | - $selected = selected( $args['selected'], $key, false ); |
|
433 | + $selected = selected($args['selected'], $key, false); |
|
434 | 434 | } |
435 | 435 | |
436 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
436 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | return $output; |
443 | 443 | } |
444 | 444 | |
445 | -function wpinv_item_dropdown( $args = array() ) { |
|
445 | +function wpinv_item_dropdown($args = array()) { |
|
446 | 446 | $defaults = array( |
447 | 447 | 'name' => 'wpi_item', |
448 | 448 | 'id' => 'wpi_item', |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | 'multiple' => false, |
451 | 451 | 'selected' => 0, |
452 | 452 | 'number' => -1, |
453 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
454 | - 'data' => array( 'search-type' => 'item' ), |
|
453 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
454 | + 'data' => array('search-type' => 'item'), |
|
455 | 455 | 'show_option_all' => false, |
456 | 456 | 'show_option_none' => false, |
457 | 457 | 'show_recurring' => false, |
458 | 458 | ); |
459 | 459 | |
460 | - $args = wp_parse_args( $args, $defaults ); |
|
460 | + $args = wp_parse_args($args, $defaults); |
|
461 | 461 | |
462 | 462 | $item_args = array( |
463 | 463 | 'post_type' => 'wpi_item', |
@@ -466,44 +466,44 @@ discard block |
||
466 | 466 | 'posts_per_page' => $args['number'] |
467 | 467 | ); |
468 | 468 | |
469 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
469 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
470 | 470 | |
471 | - $items = get_posts( $item_args ); |
|
471 | + $items = get_posts($item_args); |
|
472 | 472 | $options = array(); |
473 | - if ( $items ) { |
|
474 | - foreach ( $items as $item ) { |
|
475 | - $title = esc_html( $item->post_title ); |
|
473 | + if ($items) { |
|
474 | + foreach ($items as $item) { |
|
475 | + $title = esc_html($item->post_title); |
|
476 | 476 | |
477 | - if ( !empty( $args['show_recurring'] ) ) { |
|
478 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
477 | + if (!empty($args['show_recurring'])) { |
|
478 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
479 | 479 | } |
480 | 480 | |
481 | - $options[ absint( $item->ID ) ] = $title; |
|
481 | + $options[absint($item->ID)] = $title; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | 485 | // This ensures that any selected items are included in the drop down |
486 | - if( is_array( $args['selected'] ) ) { |
|
487 | - foreach( $args['selected'] as $item ) { |
|
488 | - if( ! in_array( $item, $options ) ) { |
|
489 | - $title = get_the_title( $item ); |
|
490 | - if ( !empty( $args['show_recurring'] ) ) { |
|
491 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
486 | + if (is_array($args['selected'])) { |
|
487 | + foreach ($args['selected'] as $item) { |
|
488 | + if (!in_array($item, $options)) { |
|
489 | + $title = get_the_title($item); |
|
490 | + if (!empty($args['show_recurring'])) { |
|
491 | + $title .= wpinv_get_item_suffix($item, false); |
|
492 | 492 | } |
493 | 493 | $options[$item] = $title; |
494 | 494 | } |
495 | 495 | } |
496 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
497 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
498 | - $title = get_the_title( $args['selected'] ); |
|
499 | - if ( !empty( $args['show_recurring'] ) ) { |
|
500 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
496 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
497 | + if (!in_array($args['selected'], $options)) { |
|
498 | + $title = get_the_title($args['selected']); |
|
499 | + if (!empty($args['show_recurring'])) { |
|
500 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
501 | 501 | } |
502 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
502 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | - $output = wpinv_html_select( array( |
|
506 | + $output = wpinv_html_select(array( |
|
507 | 507 | 'name' => $args['name'], |
508 | 508 | 'selected' => $args['selected'], |
509 | 509 | 'id' => $args['id'], |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | 'show_option_all' => $args['show_option_all'], |
515 | 515 | 'show_option_none' => $args['show_option_none'], |
516 | 516 | 'data' => $args['data'], |
517 | - ) ); |
|
517 | + )); |
|
518 | 518 | |
519 | 519 | return $output; |
520 | 520 | } |
@@ -534,16 +534,16 @@ discard block |
||
534 | 534 | ); |
535 | 535 | |
536 | 536 | $options = array(); |
537 | - if ( $items ) { |
|
538 | - foreach ( $items as $item ) { |
|
539 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
537 | + if ($items) { |
|
538 | + foreach ($items as $item) { |
|
539 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | 543 | return $options; |
544 | 544 | } |
545 | 545 | |
546 | -function wpinv_html_checkbox( $args = array() ) { |
|
546 | +function wpinv_html_checkbox($args = array()) { |
|
547 | 547 | $defaults = array( |
548 | 548 | 'name' => null, |
549 | 549 | 'current' => null, |
@@ -554,17 +554,17 @@ discard block |
||
554 | 554 | ) |
555 | 555 | ); |
556 | 556 | |
557 | - $args = wp_parse_args( $args, $defaults ); |
|
557 | + $args = wp_parse_args($args, $defaults); |
|
558 | 558 | |
559 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
559 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
560 | 560 | $options = ''; |
561 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
561 | + if (!empty($args['options']['disabled'])) { |
|
562 | 562 | $options .= ' disabled="disabled"'; |
563 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
563 | + } elseif (!empty($args['options']['readonly'])) { |
|
564 | 564 | $options .= ' readonly'; |
565 | 565 | } |
566 | 566 | |
567 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
567 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
568 | 568 | |
569 | 569 | return $output; |
570 | 570 | } |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | /** |
573 | 573 | * Displays a hidden field. |
574 | 574 | */ |
575 | -function getpaid_hidden_field( $name, $value ) { |
|
576 | - $name = sanitize_text_field( $name ); |
|
577 | - $value = esc_attr( $value ); |
|
575 | +function getpaid_hidden_field($name, $value) { |
|
576 | + $name = sanitize_text_field($name); |
|
577 | + $value = esc_attr($value); |
|
578 | 578 | |
579 | 579 | echo "<input type='hidden' name='$name' value='$value' />"; |
580 | 580 | } |
@@ -582,31 +582,31 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * Displays a submit field. |
584 | 584 | */ |
585 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
586 | - $name = sanitize_text_field( $name ); |
|
587 | - $value = esc_attr( $value ); |
|
588 | - $class = esc_attr( $class ); |
|
585 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
586 | + $name = sanitize_text_field($name); |
|
587 | + $value = esc_attr($value); |
|
588 | + $class = esc_attr($class); |
|
589 | 589 | |
590 | 590 | echo "<input type='submit' name='$name' value='$value' class='btn $class' />"; |
591 | 591 | } |
592 | 592 | |
593 | -function wpinv_html_text( $args = array() ) { |
|
593 | +function wpinv_html_text($args = array()) { |
|
594 | 594 | // Backwards compatibility |
595 | - if ( func_num_args() > 1 ) { |
|
595 | + if (func_num_args() > 1) { |
|
596 | 596 | $args = func_get_args(); |
597 | 597 | |
598 | 598 | $name = $args[0]; |
599 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
600 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
601 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
599 | + $value = isset($args[1]) ? $args[1] : ''; |
|
600 | + $label = isset($args[2]) ? $args[2] : ''; |
|
601 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | $defaults = array( |
605 | 605 | 'id' => '', |
606 | - 'name' => isset( $name ) ? $name : 'text', |
|
607 | - 'value' => isset( $value ) ? $value : null, |
|
608 | - 'label' => isset( $label ) ? $label : null, |
|
609 | - 'desc' => isset( $desc ) ? $desc : null, |
|
606 | + 'name' => isset($name) ? $name : 'text', |
|
607 | + 'value' => isset($value) ? $value : null, |
|
608 | + 'label' => isset($label) ? $label : null, |
|
609 | + 'desc' => isset($desc) ? $desc : null, |
|
610 | 610 | 'placeholder' => '', |
611 | 611 | 'class' => 'regular-text', |
612 | 612 | 'disabled' => false, |
@@ -616,41 +616,41 @@ discard block |
||
616 | 616 | 'data' => false |
617 | 617 | ); |
618 | 618 | |
619 | - $args = wp_parse_args( $args, $defaults ); |
|
619 | + $args = wp_parse_args($args, $defaults); |
|
620 | 620 | |
621 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
621 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
622 | 622 | $options = ''; |
623 | - if( $args['required'] ) { |
|
623 | + if ($args['required']) { |
|
624 | 624 | $options .= ' required="required"'; |
625 | 625 | } |
626 | - if( $args['readonly'] ) { |
|
626 | + if ($args['readonly']) { |
|
627 | 627 | $options .= ' readonly'; |
628 | 628 | } |
629 | - if( $args['readonly'] ) { |
|
629 | + if ($args['readonly']) { |
|
630 | 630 | $options .= ' readonly'; |
631 | 631 | } |
632 | 632 | |
633 | 633 | $data = ''; |
634 | - if ( !empty( $args['data'] ) ) { |
|
635 | - foreach ( $args['data'] as $key => $value ) { |
|
636 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
634 | + if (!empty($args['data'])) { |
|
635 | + foreach ($args['data'] as $key => $value) { |
|
636 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
641 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
642 | - if ( ! empty( $args['desc'] ) ) { |
|
643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
640 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
641 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
642 | + if (!empty($args['desc'])) { |
|
643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
644 | 644 | } |
645 | 645 | |
646 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
646 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
647 | 647 | |
648 | 648 | $output .= '</span>'; |
649 | 649 | |
650 | 650 | return $output; |
651 | 651 | } |
652 | 652 | |
653 | -function wpinv_html_textarea( $args = array() ) { |
|
653 | +function wpinv_html_textarea($args = array()) { |
|
654 | 654 | $defaults = array( |
655 | 655 | 'name' => 'textarea', |
656 | 656 | 'value' => null, |
@@ -661,31 +661,31 @@ discard block |
||
661 | 661 | 'placeholder' => '', |
662 | 662 | ); |
663 | 663 | |
664 | - $args = wp_parse_args( $args, $defaults ); |
|
664 | + $args = wp_parse_args($args, $defaults); |
|
665 | 665 | |
666 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
666 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
667 | 667 | $disabled = ''; |
668 | - if( $args['disabled'] ) { |
|
668 | + if ($args['disabled']) { |
|
669 | 669 | $disabled = ' disabled="disabled"'; |
670 | 670 | } |
671 | 671 | |
672 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
673 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
674 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
672 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
673 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
674 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
675 | 675 | |
676 | - if ( ! empty( $args['desc'] ) ) { |
|
677 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
676 | + if (!empty($args['desc'])) { |
|
677 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
678 | 678 | } |
679 | 679 | $output .= '</span>'; |
680 | 680 | |
681 | 681 | return $output; |
682 | 682 | } |
683 | 683 | |
684 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
684 | +function wpinv_html_ajax_user_search($args = array()) { |
|
685 | 685 | $defaults = array( |
686 | 686 | 'name' => 'user_id', |
687 | 687 | 'value' => null, |
688 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
688 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
689 | 689 | 'label' => null, |
690 | 690 | 'desc' => null, |
691 | 691 | 'class' => '', |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | 'data' => false |
695 | 695 | ); |
696 | 696 | |
697 | - $args = wp_parse_args( $args, $defaults ); |
|
697 | + $args = wp_parse_args($args, $defaults); |
|
698 | 698 | |
699 | 699 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
700 | 700 | |
701 | 701 | $output = '<span class="wpinv_user_search_wrap">'; |
702 | - $output .= wpinv_html_text( $args ); |
|
703 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
702 | + $output .= wpinv_html_text($args); |
|
703 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
704 | 704 | $output .= '</span>'; |
705 | 705 | |
706 | 706 | return $output; |
@@ -711,20 +711,20 @@ discard block |
||
711 | 711 | * |
712 | 712 | * @param string $template the template that is currently being used. |
713 | 713 | */ |
714 | -function wpinv_template( $template ) { |
|
714 | +function wpinv_template($template) { |
|
715 | 715 | global $post; |
716 | 716 | |
717 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
717 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
718 | 718 | |
719 | 719 | // If the user can view this invoice, display it. |
720 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
720 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
721 | 721 | |
722 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
722 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
723 | 723 | |
724 | 724 | // Else display an error message. |
725 | 725 | } else { |
726 | 726 | |
727 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
727 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
728 | 728 | |
729 | 729 | } |
730 | 730 | |
@@ -732,24 +732,24 @@ discard block |
||
732 | 732 | |
733 | 733 | return $template; |
734 | 734 | } |
735 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
735 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
736 | 736 | |
737 | 737 | function wpinv_get_business_address() { |
738 | 738 | $business_address = wpinv_store_address(); |
739 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
739 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
740 | 740 | |
741 | 741 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
742 | 742 | |
743 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
743 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
747 | 747 | * Displays the company address. |
748 | 748 | */ |
749 | 749 | function wpinv_display_from_address() { |
750 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
750 | + wpinv_get_template('invoice/company-address.php'); |
|
751 | 751 | } |
752 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
752 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Generates a watermark text for an invoice. |
@@ -757,9 +757,9 @@ discard block |
||
757 | 757 | * @param WPInv_Invoice $invoice |
758 | 758 | * @return string |
759 | 759 | */ |
760 | -function wpinv_watermark( $invoice ) { |
|
761 | - $watermark = wpinv_get_watermark( $invoice ); |
|
762 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
760 | +function wpinv_watermark($invoice) { |
|
761 | + $watermark = wpinv_get_watermark($invoice); |
|
762 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -768,37 +768,37 @@ discard block |
||
768 | 768 | * @param WPInv_Invoice $invoice |
769 | 769 | * @return string |
770 | 770 | */ |
771 | -function wpinv_get_watermark( $invoice ) { |
|
771 | +function wpinv_get_watermark($invoice) { |
|
772 | 772 | return $invoice->get_status_nicename(); |
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
776 | 776 | * @deprecated |
777 | 777 | */ |
778 | -function wpinv_display_invoice_details( $invoice ) { |
|
779 | - return getpaid_invoice_meta( $invoice ); |
|
778 | +function wpinv_display_invoice_details($invoice) { |
|
779 | + return getpaid_invoice_meta($invoice); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
783 | 783 | * Displays invoice meta. |
784 | 784 | */ |
785 | -function getpaid_invoice_meta( $invoice ) { |
|
785 | +function getpaid_invoice_meta($invoice) { |
|
786 | 786 | |
787 | - $invoice = new WPInv_Invoice( $invoice ); |
|
787 | + $invoice = new WPInv_Invoice($invoice); |
|
788 | 788 | |
789 | 789 | // Ensure that we have an invoice. |
790 | - if ( 0 == $invoice->get_id() ) { |
|
790 | + if (0 == $invoice->get_id()) { |
|
791 | 791 | return; |
792 | 792 | } |
793 | 793 | |
794 | 794 | // Get the invoice meta. |
795 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
795 | + $meta = getpaid_get_invoice_meta($invoice); |
|
796 | 796 | |
797 | 797 | // Display the meta. |
798 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
798 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
799 | 799 | |
800 | 800 | } |
801 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
801 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
802 | 802 | |
803 | 803 | /** |
804 | 804 | * Retrieves the address markup to use on Invoices. |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | * @param string $separator How to separate address lines. |
811 | 811 | * @return string |
812 | 812 | */ |
813 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
813 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
814 | 814 | |
815 | 815 | // Retrieve the address markup... |
816 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
817 | - $format = wpinv_get_full_address_format( $country ); |
|
816 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
817 | + $format = wpinv_get_full_address_format($country); |
|
818 | 818 | |
819 | 819 | // ... and the replacements. |
820 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
820 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
821 | 821 | |
822 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
822 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
823 | 823 | |
824 | 824 | // Remove unavailable tags. |
825 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
825 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
826 | 826 | |
827 | 827 | // Clean up white space. |
828 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
829 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
828 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
829 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
830 | 830 | |
831 | 831 | // Break newlines apart and remove empty lines/trim commas and white space. |
832 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
832 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
833 | 833 | |
834 | 834 | // Add html breaks. |
835 | - $formatted_address = implode( $separator, $formatted_address ); |
|
835 | + $formatted_address = implode($separator, $formatted_address); |
|
836 | 836 | |
837 | 837 | // We're done! |
838 | 838 | return $formatted_address; |
@@ -844,119 +844,119 @@ discard block |
||
844 | 844 | * |
845 | 845 | * @param WPInv_Invoice $invoice |
846 | 846 | */ |
847 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
848 | - if ( ! empty( $invoice ) ) { |
|
849 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
847 | +function wpinv_display_to_address($invoice = 0) { |
|
848 | + if (!empty($invoice)) { |
|
849 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
850 | 850 | } |
851 | 851 | } |
852 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
852 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
853 | 853 | |
854 | 854 | |
855 | 855 | /** |
856 | 856 | * Displays invoice line items. |
857 | 857 | */ |
858 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
858 | +function wpinv_display_line_items($invoice_id = 0) { |
|
859 | 859 | |
860 | 860 | // Prepare the invoice. |
861 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
861 | + $invoice = new WPInv_Invoice($invoice_id); |
|
862 | 862 | |
863 | 863 | // Abort if there is no invoice. |
864 | - if ( 0 == $invoice->get_id() ) { |
|
864 | + if (0 == $invoice->get_id()) { |
|
865 | 865 | return; |
866 | 866 | } |
867 | 867 | |
868 | 868 | // Line item columns. |
869 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
870 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
869 | + $columns = getpaid_invoice_item_columns($invoice); |
|
870 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
871 | 871 | |
872 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
872 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
873 | 873 | } |
874 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
874 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
875 | 875 | |
876 | 876 | /** |
877 | 877 | * Displays invoice subscriptions. |
878 | 878 | * |
879 | 879 | * @param WPInv_Invoice $invoice |
880 | 880 | */ |
881 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
881 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
882 | 882 | |
883 | 883 | // Subscriptions. |
884 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
884 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
885 | 885 | |
886 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
886 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
887 | 887 | return; |
888 | 888 | } |
889 | 889 | |
890 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
890 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
891 | 891 | |
892 | 892 | // Display related subscriptions. |
893 | - if ( is_array( $subscriptions ) ) { |
|
894 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
895 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
893 | + if (is_array($subscriptions)) { |
|
894 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
895 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
896 | 896 | } |
897 | 897 | |
898 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
899 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
900 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
898 | + if ($main_subscription->get_total_payments() > 1) { |
|
899 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
900 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | } |
904 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
905 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
904 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
905 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
906 | 906 | |
907 | 907 | /** |
908 | 908 | * Displays invoice notices on invoices. |
909 | 909 | */ |
910 | 910 | function wpinv_display_invoice_notice() { |
911 | 911 | |
912 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
913 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
912 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
913 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
914 | 914 | |
915 | - if ( empty( $label ) && empty( $notice ) ) { |
|
915 | + if (empty($label) && empty($notice)) { |
|
916 | 916 | return; |
917 | 917 | } |
918 | 918 | |
919 | 919 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
920 | 920 | |
921 | - if ( ! empty( $label ) ) { |
|
922 | - $label = sanitize_text_field( $label ); |
|
921 | + if (!empty($label)) { |
|
922 | + $label = sanitize_text_field($label); |
|
923 | 923 | echo "<h5>$label</h5>"; |
924 | 924 | } |
925 | 925 | |
926 | - if ( ! empty( $notice ) ) { |
|
927 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
926 | + if (!empty($notice)) { |
|
927 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | echo '</div>'; |
931 | 931 | } |
932 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
932 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
933 | 933 | |
934 | 934 | /** |
935 | 935 | * @param WPInv_Invoice $invoice |
936 | 936 | */ |
937 | -function wpinv_display_invoice_notes( $invoice ) { |
|
937 | +function wpinv_display_invoice_notes($invoice) { |
|
938 | 938 | |
939 | 939 | // Retrieve the notes. |
940 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
940 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
941 | 941 | |
942 | 942 | // Abort if we have non. |
943 | - if ( empty( $notes ) ) { |
|
943 | + if (empty($notes)) { |
|
944 | 944 | return; |
945 | 945 | } |
946 | 946 | |
947 | 947 | // Echo the note. |
948 | 948 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
949 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __( 'Notes', 'invoicing' ) .'</h2>'; |
|
949 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __('Notes', 'invoicing') . '</h2>'; |
|
950 | 950 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
951 | 951 | |
952 | - foreach( $notes as $note ) { |
|
953 | - wpinv_get_invoice_note_line_item( $note ); |
|
952 | + foreach ($notes as $note) { |
|
953 | + wpinv_get_invoice_note_line_item($note); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | echo '</ul>'; |
957 | 957 | echo '</div>'; |
958 | 958 | } |
959 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
959 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
960 | 960 | |
961 | 961 | /** |
962 | 962 | * Loads scripts on our invoice templates. |
@@ -964,31 +964,31 @@ discard block |
||
964 | 964 | function wpinv_display_style() { |
965 | 965 | |
966 | 966 | // Make sure that all scripts have been loaded. |
967 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
968 | - do_action( 'wp_enqueue_scripts' ); |
|
967 | + if (!did_action('wp_enqueue_scripts')) { |
|
968 | + do_action('wp_enqueue_scripts'); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | // Register the invoices style. |
972 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
972 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
973 | 973 | |
974 | 974 | // Load required styles |
975 | - wp_print_styles( 'wpinv-single-style' ); |
|
976 | - wp_print_styles( 'ayecode-ui' ); |
|
975 | + wp_print_styles('wpinv-single-style'); |
|
976 | + wp_print_styles('ayecode-ui'); |
|
977 | 977 | |
978 | 978 | // Maybe load custom css. |
979 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
979 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
980 | 980 | |
981 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
982 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
983 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
981 | + if (isset($custom_css) && !empty($custom_css)) { |
|
982 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
983 | + $custom_css = str_replace('>', '>', $custom_css); |
|
984 | 984 | echo '<style type="text/css">'; |
985 | 985 | echo $custom_css; |
986 | 986 | echo '</style>'; |
987 | 987 | } |
988 | 988 | |
989 | 989 | } |
990 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
991 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
990 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
991 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
992 | 992 | |
993 | 993 | |
994 | 994 | /** |
@@ -1000,41 +1000,41 @@ discard block |
||
1000 | 1000 | // Retrieve the current invoice. |
1001 | 1001 | $invoice_id = getpaid_get_current_invoice_id(); |
1002 | 1002 | |
1003 | - if ( empty( $invoice_id ) ) { |
|
1003 | + if (empty($invoice_id)) { |
|
1004 | 1004 | |
1005 | 1005 | return aui()->alert( |
1006 | 1006 | array( |
1007 | 1007 | 'type' => 'warning', |
1008 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
1008 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
1009 | 1009 | ) |
1010 | 1010 | ); |
1011 | 1011 | |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | // Can the user view this invoice? |
1015 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
1015 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
1016 | 1016 | |
1017 | 1017 | return aui()->alert( |
1018 | 1018 | array( |
1019 | 1019 | 'type' => 'warning', |
1020 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
1020 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
1021 | 1021 | ) |
1022 | 1022 | ); |
1023 | 1023 | |
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | // Ensure that it is not yet paid for. |
1027 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1027 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1028 | 1028 | |
1029 | 1029 | // Maybe mark it as viewed. |
1030 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
1030 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
1031 | 1031 | |
1032 | - if ( $invoice->is_paid() ) { |
|
1032 | + if ($invoice->is_paid()) { |
|
1033 | 1033 | |
1034 | 1034 | return aui()->alert( |
1035 | 1035 | array( |
1036 | 1036 | 'type' => 'success', |
1037 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
1037 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
1038 | 1038 | ) |
1039 | 1039 | ); |
1040 | 1040 | |
@@ -1044,15 +1044,15 @@ discard block |
||
1044 | 1044 | $wpi_checkout_id = $invoice_id; |
1045 | 1045 | |
1046 | 1046 | // Retrieve appropriate payment form. |
1047 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
1048 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1047 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
1048 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1049 | 1049 | |
1050 | - if ( ! $payment_form->exists() ) { |
|
1050 | + if (!$payment_form->exists()) { |
|
1051 | 1051 | |
1052 | 1052 | return aui()->alert( |
1053 | 1053 | array( |
1054 | 1054 | 'type' => 'warning', |
1055 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1055 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1056 | 1056 | ) |
1057 | 1057 | ); |
1058 | 1058 | |
@@ -1061,29 +1061,29 @@ discard block |
||
1061 | 1061 | // Set the invoice. |
1062 | 1062 | $payment_form->invoice = $invoice; |
1063 | 1063 | |
1064 | - if ( ! $payment_form->is_default() ) { |
|
1064 | + if (!$payment_form->is_default()) { |
|
1065 | 1065 | |
1066 | 1066 | $items = array(); |
1067 | 1067 | $item_ids = array(); |
1068 | 1068 | |
1069 | - foreach ( $invoice->get_items() as $item ) { |
|
1070 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1069 | + foreach ($invoice->get_items() as $item) { |
|
1070 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1071 | 1071 | $item_ids[] = $item->get_id(); |
1072 | 1072 | $items[] = $item; |
1073 | 1073 | } |
1074 | 1074 | } |
1075 | 1075 | |
1076 | - foreach ( $payment_form->get_items() as $item ) { |
|
1077 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1076 | + foreach ($payment_form->get_items() as $item) { |
|
1077 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1078 | 1078 | $item_ids[] = $item->get_id(); |
1079 | 1079 | $items[] = $item; |
1080 | 1080 | } |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - $payment_form->set_items( $items ); |
|
1083 | + $payment_form->set_items($items); |
|
1084 | 1084 | |
1085 | 1085 | } else { |
1086 | - $payment_form->set_items( $invoice->get_items() ); |
|
1086 | + $payment_form->set_items($invoice->get_items()); |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | // Generate the html. |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | function wpinv_empty_cart_message() { |
1095 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1095 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | /** |
@@ -1109,76 +1109,76 @@ discard block |
||
1109 | 1109 | ) |
1110 | 1110 | ); |
1111 | 1111 | } |
1112 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1112 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1113 | 1113 | |
1114 | 1114 | /** |
1115 | 1115 | * Filters the receipt page. |
1116 | 1116 | */ |
1117 | -function wpinv_filter_success_page_content( $content ) { |
|
1117 | +function wpinv_filter_success_page_content($content) { |
|
1118 | 1118 | |
1119 | 1119 | // Maybe abort early. |
1120 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1120 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1121 | 1121 | return $content; |
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | // Ensure this is our page. |
1125 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1125 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1126 | 1126 | |
1127 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1128 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1127 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1128 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1129 | 1129 | |
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | return $content; |
1133 | 1133 | } |
1134 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1134 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1135 | 1135 | |
1136 | -function wpinv_invoice_link( $invoice_id ) { |
|
1137 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1136 | +function wpinv_invoice_link($invoice_id) { |
|
1137 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1138 | 1138 | |
1139 | - if ( empty( $invoice ) ) { |
|
1139 | + if (empty($invoice)) { |
|
1140 | 1140 | return NULL; |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1143 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1144 | 1144 | |
1145 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1145 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1149 | - if ( empty( $note ) ) { |
|
1148 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1149 | + if (empty($note)) { |
|
1150 | 1150 | return NULL; |
1151 | 1151 | } |
1152 | 1152 | |
1153 | - if ( is_int( $note ) ) { |
|
1154 | - $note = get_comment( $note ); |
|
1153 | + if (is_int($note)) { |
|
1154 | + $note = get_comment($note); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1157 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1158 | 1158 | return NULL; |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - $note_classes = array( 'note' ); |
|
1162 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1161 | + $note_classes = array('note'); |
|
1162 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1163 | 1163 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1164 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1165 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1164 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1165 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1166 | 1166 | |
1167 | 1167 | ob_start(); |
1168 | 1168 | ?> |
1169 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1169 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1170 | 1170 | <div class="note_content"> |
1171 | 1171 | |
1172 | - <?php echo wptexturize( wp_kses_post( $note->comment_content ) ); ?> |
|
1172 | + <?php echo wptexturize(wp_kses_post($note->comment_content)); ?> |
|
1173 | 1173 | |
1174 | - <?php if ( ! is_admin() ) : ?> |
|
1174 | + <?php if (!is_admin()) : ?> |
|
1175 | 1175 | <em class="small form-text text-muted mt-0"> |
1176 | 1176 | <?php |
1177 | 1177 | printf( |
1178 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1178 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1179 | 1179 | $note->comment_author, |
1180 | - getpaid_format_date_value( $note->comment_date ), |
|
1181 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1180 | + getpaid_format_date_value($note->comment_date), |
|
1181 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1182 | 1182 | ); |
1183 | 1183 | ?> |
1184 | 1184 | </em> |
@@ -1186,21 +1186,21 @@ discard block |
||
1186 | 1186 | |
1187 | 1187 | </div> |
1188 | 1188 | |
1189 | - <?php if ( is_admin() ) : ?> |
|
1189 | + <?php if (is_admin()) : ?> |
|
1190 | 1190 | |
1191 | 1191 | <p class="meta px-4 py-2"> |
1192 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1192 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1193 | 1193 | <?php |
1194 | 1194 | printf( |
1195 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1195 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1196 | 1196 | $note->comment_author, |
1197 | - getpaid_format_date_value( $note->comment_date ), |
|
1198 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1197 | + getpaid_format_date_value($note->comment_date), |
|
1198 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1199 | 1199 | ); |
1200 | 1200 | ?> |
1201 | 1201 | </abbr> |
1202 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1203 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
1202 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1203 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
1204 | 1204 | <?php } ?> |
1205 | 1205 | </p> |
1206 | 1206 | |
@@ -1209,9 +1209,9 @@ discard block |
||
1209 | 1209 | </li> |
1210 | 1210 | <?php |
1211 | 1211 | $note_content = ob_get_clean(); |
1212 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1212 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1213 | 1213 | |
1214 | - if ( $echo ) { |
|
1214 | + if ($echo) { |
|
1215 | 1215 | echo $note_content; |
1216 | 1216 | } else { |
1217 | 1217 | return $note_content; |
@@ -1225,21 +1225,21 @@ discard block |
||
1225 | 1225 | * @return string |
1226 | 1226 | */ |
1227 | 1227 | function wpinv_get_policy_text() { |
1228 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1228 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1229 | 1229 | |
1230 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
1230 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1231 | 1231 | |
1232 | - if(!$privacy_page_id){ |
|
1233 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1232 | + if (!$privacy_page_id) { |
|
1233 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1236 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1237 | 1237 | |
1238 | 1238 | $find_replace = array( |
1239 | 1239 | '[wpinv_privacy_policy]' => $privacy_link, |
1240 | 1240 | ); |
1241 | 1241 | |
1242 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1242 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1243 | 1243 | |
1244 | 1244 | return wp_kses_post(wpautop($privacy_text)); |
1245 | 1245 | } |
@@ -1247,21 +1247,21 @@ discard block |
||
1247 | 1247 | function wpinv_oxygen_fix_conflict() { |
1248 | 1248 | global $ct_ignore_post_types; |
1249 | 1249 | |
1250 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1250 | + if (!is_array($ct_ignore_post_types)) { |
|
1251 | 1251 | $ct_ignore_post_types = array(); |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1254 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1255 | 1255 | |
1256 | - foreach ( $post_types as $post_type ) { |
|
1256 | + foreach ($post_types as $post_type) { |
|
1257 | 1257 | $ct_ignore_post_types[] = $post_type; |
1258 | 1258 | |
1259 | 1259 | // Ignore post type |
1260 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1260 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1264 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1263 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1264 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -1269,10 +1269,10 @@ discard block |
||
1269 | 1269 | * |
1270 | 1270 | * @param GetPaid_Payment_Form $form |
1271 | 1271 | */ |
1272 | -function getpaid_display_payment_form( $form ) { |
|
1272 | +function getpaid_display_payment_form($form) { |
|
1273 | 1273 | |
1274 | - if ( is_numeric( $form ) ) { |
|
1275 | - $form = new GetPaid_Payment_Form( $form ); |
|
1274 | + if (is_numeric($form)) { |
|
1275 | + $form = new GetPaid_Payment_Form($form); |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | $form->display(); |
@@ -1282,58 +1282,58 @@ discard block |
||
1282 | 1282 | /** |
1283 | 1283 | * Helper function to display a item payment form on the frontend. |
1284 | 1284 | */ |
1285 | -function getpaid_display_item_payment_form( $items ) { |
|
1285 | +function getpaid_display_item_payment_form($items) { |
|
1286 | 1286 | |
1287 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1288 | - $form->set_items( $items ); |
|
1287 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1288 | + $form->set_items($items); |
|
1289 | 1289 | |
1290 | - if ( 0 == count( $form->get_items() ) ) { |
|
1290 | + if (0 == count($form->get_items())) { |
|
1291 | 1291 | echo aui()->alert( |
1292 | 1292 | array( |
1293 | 1293 | 'type' => 'warning', |
1294 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1294 | + 'content' => __('No published items found', 'invoicing'), |
|
1295 | 1295 | ) |
1296 | 1296 | ); |
1297 | 1297 | return; |
1298 | 1298 | } |
1299 | 1299 | |
1300 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1301 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
1300 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1301 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
1302 | 1302 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
1303 | 1303 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
1304 | 1304 | |
1305 | - $form->display( $extra_items ); |
|
1305 | + $form->display($extra_items); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | /** |
1309 | 1309 | * Helper function to display an invoice payment form on the frontend. |
1310 | 1310 | */ |
1311 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1311 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1312 | 1312 | |
1313 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1313 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1314 | 1314 | |
1315 | - if ( empty( $invoice ) ) { |
|
1315 | + if (empty($invoice)) { |
|
1316 | 1316 | echo aui()->alert( |
1317 | 1317 | array( |
1318 | 1318 | 'type' => 'warning', |
1319 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1319 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1320 | 1320 | ) |
1321 | 1321 | ); |
1322 | 1322 | return; |
1323 | 1323 | } |
1324 | 1324 | |
1325 | - if ( $invoice->is_paid() ) { |
|
1325 | + if ($invoice->is_paid()) { |
|
1326 | 1326 | echo aui()->alert( |
1327 | 1327 | array( |
1328 | 1328 | 'type' => 'warning', |
1329 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1329 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1330 | 1330 | ) |
1331 | 1331 | ); |
1332 | 1332 | return; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1336 | - $form->set_items( $invoice->get_items() ); |
|
1335 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1336 | + $form->set_items($invoice->get_items()); |
|
1337 | 1337 | |
1338 | 1338 | $form->display(); |
1339 | 1339 | } |
@@ -1341,23 +1341,23 @@ discard block |
||
1341 | 1341 | /** |
1342 | 1342 | * Helper function to convert item string to array. |
1343 | 1343 | */ |
1344 | -function getpaid_convert_items_to_array( $items ) { |
|
1345 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1344 | +function getpaid_convert_items_to_array($items) { |
|
1345 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1346 | 1346 | $prepared = array(); |
1347 | 1347 | |
1348 | - foreach ( $items as $item ) { |
|
1349 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1348 | + foreach ($items as $item) { |
|
1349 | + $data = array_map('trim', explode('|', $item)); |
|
1350 | 1350 | |
1351 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1351 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1352 | 1352 | continue; |
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | $quantity = 1; |
1356 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1356 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1357 | 1357 | $quantity = (float) $data[1]; |
1358 | 1358 | } |
1359 | 1359 | |
1360 | - $prepared[ $data[0] ] = $quantity; |
|
1360 | + $prepared[$data[0]] = $quantity; |
|
1361 | 1361 | |
1362 | 1362 | } |
1363 | 1363 | |
@@ -1367,13 +1367,13 @@ discard block |
||
1367 | 1367 | /** |
1368 | 1368 | * Helper function to convert item array to string. |
1369 | 1369 | */ |
1370 | -function getpaid_convert_items_to_string( $items ) { |
|
1370 | +function getpaid_convert_items_to_string($items) { |
|
1371 | 1371 | $prepared = array(); |
1372 | 1372 | |
1373 | - foreach ( $items as $item => $quantity ) { |
|
1373 | + foreach ($items as $item => $quantity) { |
|
1374 | 1374 | $prepared[] = "$item|$quantity"; |
1375 | 1375 | } |
1376 | - return implode( ',', $prepared ); |
|
1376 | + return implode(',', $prepared); |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | /** |
@@ -1381,21 +1381,21 @@ discard block |
||
1381 | 1381 | * |
1382 | 1382 | * Provide a label and one of $form, $items or $invoice. |
1383 | 1383 | */ |
1384 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1385 | - $label = sanitize_text_field( $label ); |
|
1384 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1385 | + $label = sanitize_text_field($label); |
|
1386 | 1386 | |
1387 | - if ( ! empty( $form ) ) { |
|
1388 | - $form = esc_attr( $form ); |
|
1387 | + if (!empty($form)) { |
|
1388 | + $form = esc_attr($form); |
|
1389 | 1389 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1390 | 1390 | } |
1391 | 1391 | |
1392 | - if ( ! empty( $items ) ) { |
|
1393 | - $items = esc_attr( $items ); |
|
1392 | + if (!empty($items)) { |
|
1393 | + $items = esc_attr($items); |
|
1394 | 1394 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1395 | 1395 | } |
1396 | 1396 | |
1397 | - if ( ! empty( $invoice ) ) { |
|
1398 | - $invoice = esc_attr( $invoice ); |
|
1397 | + if (!empty($invoice)) { |
|
1398 | + $invoice = esc_attr($invoice); |
|
1399 | 1399 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1400 | 1400 | } |
1401 | 1401 | |
@@ -1406,18 +1406,18 @@ discard block |
||
1406 | 1406 | * |
1407 | 1407 | * @param WPInv_Invoice $invoice |
1408 | 1408 | */ |
1409 | -function getpaid_the_invoice_description( $invoice ) { |
|
1409 | +function getpaid_the_invoice_description($invoice) { |
|
1410 | 1410 | $description = $invoice->get_description(); |
1411 | 1411 | |
1412 | - if ( empty( $description ) ) { |
|
1412 | + if (empty($description)) { |
|
1413 | 1413 | return; |
1414 | 1414 | } |
1415 | 1415 | |
1416 | - $description = wp_kses_post( wpautop( $description ) ); |
|
1416 | + $description = wp_kses_post(wpautop($description)); |
|
1417 | 1417 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>$description</em></small>"; |
1418 | 1418 | } |
1419 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1420 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1419 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1420 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1421 | 1421 | |
1422 | 1422 | /** |
1423 | 1423 | * Render element on a form. |
@@ -1425,60 +1425,60 @@ discard block |
||
1425 | 1425 | * @param array $element |
1426 | 1426 | * @param GetPaid_Payment_Form $form |
1427 | 1427 | */ |
1428 | -function getpaid_payment_form_element( $element, $form ) { |
|
1428 | +function getpaid_payment_form_element($element, $form) { |
|
1429 | 1429 | |
1430 | 1430 | // Set up the args. |
1431 | - $element_type = trim( $element['type'] ); |
|
1431 | + $element_type = trim($element['type']); |
|
1432 | 1432 | $element['form'] = $form; |
1433 | - extract( $element ); |
|
1433 | + extract($element); |
|
1434 | 1434 | |
1435 | 1435 | // Try to locate the appropriate template. |
1436 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1436 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1437 | 1437 | |
1438 | 1438 | // Abort if this is not our element. |
1439 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1439 | + if (empty($located) || !file_exists($located)) { |
|
1440 | 1440 | return; |
1441 | 1441 | } |
1442 | 1442 | |
1443 | 1443 | // Generate the class and id of the element. |
1444 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1445 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1444 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1445 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1446 | 1446 | |
1447 | 1447 | // Echo the opening wrapper. |
1448 | 1448 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
1449 | 1449 | |
1450 | 1450 | // Fires before displaying a given element type's content. |
1451 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1451 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1452 | 1452 | |
1453 | 1453 | // Include the template for the element. |
1454 | 1454 | include $located; |
1455 | 1455 | |
1456 | 1456 | // Fires after displaying a given element type's content. |
1457 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1457 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1458 | 1458 | |
1459 | 1459 | // Echo the closing wrapper. |
1460 | 1460 | echo '</div>'; |
1461 | 1461 | } |
1462 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1462 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1463 | 1463 | |
1464 | 1464 | /** |
1465 | 1465 | * Render an element's edit page. |
1466 | 1466 | * |
1467 | 1467 | * @param WP_Post $post |
1468 | 1468 | */ |
1469 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1469 | +function getpaid_payment_form_edit_element_template($post) { |
|
1470 | 1470 | |
1471 | 1471 | // Retrieve all elements. |
1472 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1472 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1473 | 1473 | |
1474 | - foreach ( $all_elements as $element ) { |
|
1474 | + foreach ($all_elements as $element) { |
|
1475 | 1475 | |
1476 | 1476 | // Try to locate the appropriate template. |
1477 | - $element = sanitize_key( $element ); |
|
1478 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1477 | + $element = sanitize_key($element); |
|
1478 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1479 | 1479 | |
1480 | 1480 | // Continue if this is not our element. |
1481 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1481 | + if (empty($located) || !file_exists($located)) { |
|
1482 | 1482 | continue; |
1483 | 1483 | } |
1484 | 1484 | |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | } |
1490 | 1490 | |
1491 | 1491 | } |
1492 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1492 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1493 | 1493 | |
1494 | 1494 | /** |
1495 | 1495 | * Render an element's preview. |
@@ -1498,16 +1498,16 @@ discard block |
||
1498 | 1498 | function getpaid_payment_form_render_element_preview_template() { |
1499 | 1499 | |
1500 | 1500 | // Retrieve all elements. |
1501 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1501 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1502 | 1502 | |
1503 | - foreach ( $all_elements as $element ) { |
|
1503 | + foreach ($all_elements as $element) { |
|
1504 | 1504 | |
1505 | 1505 | // Try to locate the appropriate template. |
1506 | - $element = sanitize_key( $element ); |
|
1507 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1506 | + $element = sanitize_key($element); |
|
1507 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1508 | 1508 | |
1509 | 1509 | // Continue if this is not our element. |
1510 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1510 | + if (empty($located) || !file_exists($located)) { |
|
1511 | 1511 | continue; |
1512 | 1512 | } |
1513 | 1513 | |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | } |
1519 | 1519 | |
1520 | 1520 | } |
1521 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1521 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1522 | 1522 | |
1523 | 1523 | /** |
1524 | 1524 | * Shows a list of gateways that support recurring payments. |
@@ -1526,17 +1526,17 @@ discard block |
||
1526 | 1526 | function wpinv_get_recurring_gateways_text() { |
1527 | 1527 | $gateways = array(); |
1528 | 1528 | |
1529 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1530 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1531 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1529 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1530 | + if (wpinv_gateway_support_subscription($key)) { |
|
1531 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1532 | 1532 | } |
1533 | 1533 | } |
1534 | 1534 | |
1535 | - if ( empty( $gateways ) ) { |
|
1536 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
1535 | + if (empty($gateways)) { |
|
1536 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
1539 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
1540 | 1540 | |
1541 | 1541 | } |
1542 | 1542 | |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | * @return GetPaid_Template |
1547 | 1547 | */ |
1548 | 1548 | function getpaid_template() { |
1549 | - return getpaid()->get( 'template' ); |
|
1549 | + return getpaid()->get('template'); |
|
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | /** |
@@ -1555,8 +1555,8 @@ discard block |
||
1555 | 1555 | * @param array args |
1556 | 1556 | * @return string |
1557 | 1557 | */ |
1558 | -function getpaid_paginate_links( $args ) { |
|
1559 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1558 | +function getpaid_paginate_links($args) { |
|
1559 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1560 | 1560 | } |
1561 | 1561 | |
1562 | 1562 | /** |
@@ -1566,21 +1566,21 @@ discard block |
||
1566 | 1566 | * @param string state |
1567 | 1567 | * @return string |
1568 | 1568 | */ |
1569 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state' ) { |
|
1569 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state') { |
|
1570 | 1570 | |
1571 | - $states = wpinv_get_country_states( $country ); |
|
1572 | - $uniqid = uniqid( '_' ); |
|
1571 | + $states = wpinv_get_country_states($country); |
|
1572 | + $uniqid = uniqid('_'); |
|
1573 | 1573 | |
1574 | - if ( ! empty( $states ) ) { |
|
1574 | + if (!empty($states)) { |
|
1575 | 1575 | |
1576 | - return aui()->select( array( |
|
1576 | + return aui()->select(array( |
|
1577 | 1577 | 'options' => $states, |
1578 | - 'name' => esc_attr( $field_name ), |
|
1579 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1580 | - 'value' => sanitize_text_field( $state ), |
|
1578 | + 'name' => esc_attr($field_name), |
|
1579 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1580 | + 'value' => sanitize_text_field($state), |
|
1581 | 1581 | 'placeholder' => $placeholder, |
1582 | 1582 | 'required' => $required, |
1583 | - 'label' => wp_kses_post( $label ), |
|
1583 | + 'label' => wp_kses_post($label), |
|
1584 | 1584 | 'label_type' => 'vertical', |
1585 | 1585 | 'help_text' => $help_text, |
1586 | 1586 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1595,14 +1595,14 @@ discard block |
||
1595 | 1595 | |
1596 | 1596 | return aui()->input( |
1597 | 1597 | array( |
1598 | - 'name' => esc_attr( $field_name ), |
|
1599 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1598 | + 'name' => esc_attr($field_name), |
|
1599 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1600 | 1600 | 'placeholder' => $placeholder, |
1601 | 1601 | 'required' => $required, |
1602 | - 'label' => wp_kses_post( $label ), |
|
1602 | + 'label' => wp_kses_post($label), |
|
1603 | 1603 | 'label_type' => 'vertical', |
1604 | 1604 | 'help_text' => $help_text, |
1605 | - 'value' => sanitize_text_field( $state ), |
|
1605 | + 'value' => sanitize_text_field($state), |
|
1606 | 1606 | 'class' => 'getpaid-address-field wpinv_state', |
1607 | 1607 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1608 | 1608 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1620,16 +1620,16 @@ discard block |
||
1620 | 1620 | * @param array $element |
1621 | 1621 | * @return string |
1622 | 1622 | */ |
1623 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1623 | +function getpaid_get_form_element_grid_class($element) { |
|
1624 | 1624 | |
1625 | 1625 | $class = "col-12"; |
1626 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1626 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1627 | 1627 | |
1628 | - if ( $width == 'half' ) { |
|
1628 | + if ($width == 'half') { |
|
1629 | 1629 | $class .= " col-md-6"; |
1630 | 1630 | } |
1631 | 1631 | |
1632 | - if ( $width == 'third' ) { |
|
1632 | + if ($width == 'third') { |
|
1633 | 1633 | $class .= " col-md-4"; |
1634 | 1634 | } |
1635 | 1635 | |
@@ -1644,15 +1644,15 @@ discard block |
||
1644 | 1644 | * |
1645 | 1645 | * @return string |
1646 | 1646 | */ |
1647 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
1647 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
1648 | 1648 | |
1649 | 1649 | return add_query_arg( |
1650 | 1650 | array( |
1651 | 1651 | 'getpaid_embed' => 1, |
1652 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
1653 | - 'item' => $items ? urlencode( $items ) : false |
|
1652 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
1653 | + 'item' => $items ? urlencode($items) : false |
|
1654 | 1654 | ), |
1655 | - home_url( 'index.php' ) |
|
1655 | + home_url('index.php') |
|
1656 | 1656 | ); |
1657 | 1657 | |
1658 | 1658 | } |
@@ -1662,13 +1662,13 @@ discard block |
||
1662 | 1662 | * |
1663 | 1663 | * @return string |
1664 | 1664 | */ |
1665 | -function getpaid_filter_embed_template( $template ) { |
|
1665 | +function getpaid_filter_embed_template($template) { |
|
1666 | 1666 | |
1667 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
1668 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
1667 | + if (isset($_GET['getpaid_embed'])) { |
|
1668 | + wpinv_get_template('payment-forms/embed.php'); |
|
1669 | 1669 | exit; |
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | return $template; |
1673 | 1673 | } |
1674 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
1674 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Main Checkout Class. |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param GetPaid_Payment_Form_Submission $submission |
24 | 24 | */ |
25 | - public function __construct( $submission ) { |
|
25 | + public function __construct($submission) { |
|
26 | 26 | $this->payment_form_submission = $submission; |
27 | 27 | } |
28 | 28 | |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | // Prepare the invoice. |
39 | 39 | $items = $this->get_submission_items(); |
40 | 40 | $invoice = $this->get_submission_invoice(); |
41 | - $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
41 | + $invoice = $this->process_submission_invoice($invoice, $items); |
|
42 | 42 | $prepared = $this->prepare_submission_data_for_saving(); |
43 | 43 | |
44 | - $this->prepare_billing_info( $invoice ); |
|
44 | + $this->prepare_billing_info($invoice); |
|
45 | 45 | |
46 | - $shipping = $this->prepare_shipping_info( $invoice ); |
|
46 | + $shipping = $this->prepare_shipping_info($invoice); |
|
47 | 47 | |
48 | 48 | // Save the invoice. |
49 | - $invoice->set_is_viewed( true ); |
|
49 | + $invoice->set_is_viewed(true); |
|
50 | 50 | $invoice->recalculate_total(); |
51 | 51 | $invoice->save(); |
52 | 52 | |
53 | - do_action( 'getpaid_checkout_invoice_updated', $invoice ); |
|
53 | + do_action('getpaid_checkout_invoice_updated', $invoice); |
|
54 | 54 | |
55 | 55 | // Send to the gateway. |
56 | - $this->post_process_submission( $invoice, $prepared, $shipping ); |
|
56 | + $this->post_process_submission($invoice, $prepared, $shipping); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -66,34 +66,34 @@ discard block |
||
66 | 66 | $data = $submission->get_data(); |
67 | 67 | |
68 | 68 | // Do we have an error? |
69 | - if ( ! empty( $submission->last_error ) ) { |
|
70 | - wp_send_json_error( $submission->last_error ); |
|
69 | + if (!empty($submission->last_error)) { |
|
70 | + wp_send_json_error($submission->last_error); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // We need a billing email. |
74 | - if ( ! $submission->has_billing_email() ) { |
|
75 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
74 | + if (!$submission->has_billing_email()) { |
|
75 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Non-recurring gateways should not be allowed to process recurring invoices. |
79 | - if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
80 | - wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) ); |
|
79 | + if ($submission->should_collect_payment_details() && $submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) { |
|
80 | + wp_send_json_error(__('The selected payment gateway does not support subscription payments.', 'invoicing')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // Ensure the gateway is active. |
84 | - if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
85 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
84 | + if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) { |
|
85 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Clear any existing errors. |
89 | 89 | wpinv_clear_errors(); |
90 | 90 | |
91 | 91 | // Allow themes and plugins to hook to errors |
92 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
92 | + do_action('getpaid_checkout_error_checks', $submission); |
|
93 | 93 | |
94 | 94 | // Do we have any errors? |
95 | - if ( wpinv_get_errors() ) { |
|
96 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
95 | + if (wpinv_get_errors()) { |
|
96 | + wp_send_json_error(getpaid_get_errors_html()); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | $items = $this->payment_form_submission->get_items(); |
109 | 109 | |
110 | 110 | // Ensure that we have items. |
111 | - if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) { |
|
112 | - wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) ); |
|
111 | + if (empty($items) && !$this->payment_form_submission->has_fees()) { |
|
112 | + wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing')); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return $items; |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | protected function get_submission_invoice() { |
124 | 124 | $submission = $this->payment_form_submission; |
125 | 125 | |
126 | - if ( ! $submission->has_invoice() ) { |
|
126 | + if (!$submission->has_invoice()) { |
|
127 | 127 | $invoice = new WPInv_Invoice(); |
128 | - $invoice->set_created_via( 'payment_form' ); |
|
128 | + $invoice->set_created_via('payment_form'); |
|
129 | 129 | return $invoice; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $invoice = $submission->get_invoice(); |
133 | 133 | |
134 | 134 | // Make sure that it is neither paid or refunded. |
135 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
136 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
135 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
136 | + wp_send_json_error(__('This invoice has already been paid for.', 'invoicing')); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | return $invoice; |
@@ -146,29 +146,29 @@ discard block |
||
146 | 146 | * @param GetPaid_Form_Item[] $items |
147 | 147 | * @return WPInv_Invoice |
148 | 148 | */ |
149 | - protected function process_submission_invoice( $invoice, $items ) { |
|
149 | + protected function process_submission_invoice($invoice, $items) { |
|
150 | 150 | |
151 | 151 | $submission = $this->payment_form_submission; |
152 | 152 | |
153 | 153 | // Set-up the invoice details. |
154 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
155 | - $invoice->set_user_id( $this->get_submission_customer() ); |
|
156 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
157 | - $invoice->set_items( $items ); |
|
158 | - $invoice->set_fees( $submission->get_fees() ); |
|
159 | - $invoice->set_taxes( $submission->get_taxes() ); |
|
160 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
161 | - $invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) ); |
|
162 | - $invoice->set_currency( $submission->get_currency() ); |
|
163 | - |
|
164 | - $address_confirmed = $submission->get_field( 'confirm-address' ); |
|
165 | - $invoice->set_address_confirmed( ! empty( $address_confirmed ) ); |
|
166 | - |
|
167 | - if ( $submission->has_discount_code() ) { |
|
168 | - $invoice->set_discount_code( $submission->get_discount_code() ); |
|
154 | + $invoice->set_email(sanitize_email($submission->get_billing_email())); |
|
155 | + $invoice->set_user_id($this->get_submission_customer()); |
|
156 | + $invoice->set_payment_form(absint($submission->get_payment_form()->get_id())); |
|
157 | + $invoice->set_items($items); |
|
158 | + $invoice->set_fees($submission->get_fees()); |
|
159 | + $invoice->set_taxes($submission->get_taxes()); |
|
160 | + $invoice->set_discounts($submission->get_discounts()); |
|
161 | + $invoice->set_gateway($submission->get_field('wpi-gateway')); |
|
162 | + $invoice->set_currency($submission->get_currency()); |
|
163 | + |
|
164 | + $address_confirmed = $submission->get_field('confirm-address'); |
|
165 | + $invoice->set_address_confirmed(!empty($address_confirmed)); |
|
166 | + |
|
167 | + if ($submission->has_discount_code()) { |
|
168 | + $invoice->set_discount_code($submission->get_discount_code()); |
|
169 | 169 | } |
170 | 170 | |
171 | - getpaid_maybe_add_default_address( $invoice ); |
|
171 | + getpaid_maybe_add_default_address($invoice); |
|
172 | 172 | return $invoice; |
173 | 173 | } |
174 | 174 | |
@@ -181,33 +181,33 @@ discard block |
||
181 | 181 | $submission = $this->payment_form_submission; |
182 | 182 | |
183 | 183 | // If this is an existing invoice... |
184 | - if ( $submission->has_invoice() ) { |
|
184 | + if ($submission->has_invoice()) { |
|
185 | 185 | return $submission->get_invoice()->get_user_id(); |
186 | 186 | } |
187 | 187 | |
188 | 188 | // (Maybe) create the user. |
189 | 189 | $user = get_current_user_id(); |
190 | 190 | |
191 | - if ( empty( $user ) ) { |
|
192 | - $user = get_user_by( 'email', $submission->get_billing_email() ); |
|
191 | + if (empty($user)) { |
|
192 | + $user = get_user_by('email', $submission->get_billing_email()); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( empty( $user ) ) { |
|
196 | - $user = wpinv_create_user( $submission->get_billing_email() ); |
|
195 | + if (empty($user)) { |
|
196 | + $user = wpinv_create_user($submission->get_billing_email()); |
|
197 | 197 | |
198 | 198 | // (Maybe) send new user notification. |
199 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
200 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) { |
|
201 | - wp_send_new_user_notifications( $user, 'user' ); |
|
199 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
200 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification), $user)) { |
|
201 | + wp_send_new_user_notifications($user, 'user'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | } |
205 | 205 | |
206 | - if ( is_wp_error( $user ) ) { |
|
207 | - wp_send_json_error( $user->get_error_message() ); |
|
206 | + if (is_wp_error($user)) { |
|
207 | + wp_send_json_error($user->get_error_message()); |
|
208 | 208 | } |
209 | 209 | |
210 | - if ( is_numeric( $user ) ) { |
|
210 | + if (is_numeric($user)) { |
|
211 | 211 | return $user; |
212 | 212 | } |
213 | 213 | |
@@ -231,24 +231,24 @@ discard block |
||
231 | 231 | ); |
232 | 232 | |
233 | 233 | // Raw submission details. |
234 | - $data = $submission->get_data(); |
|
234 | + $data = $submission->get_data(); |
|
235 | 235 | |
236 | 236 | // Loop through the submitted details. |
237 | - foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
|
237 | + foreach ($submission->get_payment_form()->get_elements() as $field) { |
|
238 | 238 | |
239 | 239 | // Skip premade fields. |
240 | - if ( ! empty( $field['premade'] ) ) { |
|
240 | + if (!empty($field['premade'])) { |
|
241 | 241 | continue; |
242 | 242 | } |
243 | 243 | |
244 | 244 | // Ensure address is provided. |
245 | - if ( $field['type'] == 'address' ) { |
|
246 | - $address_type = isset( $field['address_type'] ) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing'; |
|
245 | + if ($field['type'] == 'address') { |
|
246 | + $address_type = isset($field['address_type']) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing'; |
|
247 | 247 | |
248 | - foreach ( $field['fields'] as $address_field ) { |
|
248 | + foreach ($field['fields'] as $address_field) { |
|
249 | 249 | |
250 | - if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) { |
|
251 | - wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) ); |
|
250 | + if (!empty($address_field['visible']) && !empty($address_field['required']) && '' === trim($_POST[$address_type][$address_field['name']])) { |
|
251 | + wp_send_json_error(__('Please fill all required fields.', 'invoicing')); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
@@ -256,49 +256,49 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | // If it is required and not set, abort. |
259 | - if ( ! $submission->is_required_field_set( $field ) ) { |
|
260 | - wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) ); |
|
259 | + if (!$submission->is_required_field_set($field)) { |
|
260 | + wp_send_json_error(__('Please fill all required fields.', 'invoicing')); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | // Handle misc fields. |
264 | - if ( isset( $data[ $field['id'] ] ) ) { |
|
264 | + if (isset($data[$field['id']])) { |
|
265 | 265 | |
266 | 266 | // Uploads. |
267 | - if ( $field['type'] == 'file_upload' ) { |
|
268 | - $max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] ); |
|
267 | + if ($field['type'] == 'file_upload') { |
|
268 | + $max_file_num = empty($field['max_file_num']) ? 1 : absint($field['max_file_num']); |
|
269 | 269 | |
270 | - if ( count( $data[ $field['id'] ] ) > $max_file_num ) { |
|
271 | - wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) ); |
|
270 | + if (count($data[$field['id']]) > $max_file_num) { |
|
271 | + wp_send_json_error(__('Maximum number of allowed files exceeded.', 'invoicing')); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | $value = array(); |
275 | 275 | |
276 | - foreach ( $data[ $field['id'] ] as $url => $name ) { |
|
276 | + foreach ($data[$field['id']] as $url => $name) { |
|
277 | 277 | $value[] = sprintf( |
278 | 278 | '<a href="%s" target="_blank">%s</a>', |
279 | - esc_url_raw( $url ), |
|
280 | - esc_html( $name ) |
|
279 | + esc_url_raw($url), |
|
280 | + esc_html($name) |
|
281 | 281 | ); |
282 | 282 | } |
283 | 283 | |
284 | - $value = implode( ' | ', $value ); |
|
284 | + $value = implode(' | ', $value); |
|
285 | 285 | |
286 | - } else if ( $field['type'] == 'checkbox' ) { |
|
287 | - $value = isset( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' ); |
|
286 | + } else if ($field['type'] == 'checkbox') { |
|
287 | + $value = isset($data[$field['id']]) ? __('Yes', 'invoicing') : __('No', 'invoicing'); |
|
288 | 288 | } else { |
289 | - $value = wp_kses_post( $data[ $field['id'] ] ); |
|
289 | + $value = wp_kses_post($data[$field['id']]); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | $label = $field['id']; |
293 | 293 | |
294 | - if ( isset( $field['label'] ) ) { |
|
294 | + if (isset($field['label'])) { |
|
295 | 295 | $label = $field['label']; |
296 | 296 | } |
297 | 297 | |
298 | - if ( ! empty( $field['add_meta'] ) ) { |
|
299 | - $prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value ); |
|
298 | + if (!empty($field['add_meta'])) { |
|
299 | + $prepared['meta'][wpinv_clean($label)] = wp_kses_post_deep($value); |
|
300 | 300 | } |
301 | - $prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value ); |
|
301 | + $prepared['all'][wpinv_clean($label)] = wp_kses_post_deep($value); |
|
302 | 302 | |
303 | 303 | } |
304 | 304 | |
@@ -315,30 +315,30 @@ discard block |
||
315 | 315 | * @param WPInv_Invoice $invoice |
316 | 316 | * @param string $type |
317 | 317 | */ |
318 | - public function prepare_address_details( $invoice, $type = 'billing' ) { |
|
318 | + public function prepare_address_details($invoice, $type = 'billing') { |
|
319 | 319 | |
320 | 320 | $data = $this->payment_form_submission->get_data(); |
321 | - $type = sanitize_key( $type ); |
|
321 | + $type = sanitize_key($type); |
|
322 | 322 | $address = array(); |
323 | 323 | $prepared = array(); |
324 | 324 | |
325 | - if ( ! empty( $data[ $type ] ) ) { |
|
326 | - $address = $data[ $type ]; |
|
325 | + if (!empty($data[$type])) { |
|
326 | + $address = $data[$type]; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | // Clean address details. |
330 | - foreach ( $address as $key => $value ) { |
|
331 | - $key = sanitize_key( $key ); |
|
332 | - $key = str_replace( 'wpinv_', '', $key ); |
|
333 | - $value = wpinv_clean( $value ); |
|
334 | - $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice ); |
|
330 | + foreach ($address as $key => $value) { |
|
331 | + $key = sanitize_key($key); |
|
332 | + $key = str_replace('wpinv_', '', $key); |
|
333 | + $value = wpinv_clean($value); |
|
334 | + $prepared[$key] = apply_filters("getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | // Filter address details. |
338 | - $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice ); |
|
338 | + $prepared = apply_filters("getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice); |
|
339 | 339 | |
340 | 340 | // Remove non-whitelisted values. |
341 | - return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY ); |
|
341 | + return array_filter($prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY); |
|
342 | 342 | |
343 | 343 | } |
344 | 344 | |
@@ -348,12 +348,12 @@ discard block |
||
348 | 348 | * @return array |
349 | 349 | * @param WPInv_Invoice $invoice |
350 | 350 | */ |
351 | - protected function prepare_billing_info( &$invoice ) { |
|
351 | + protected function prepare_billing_info(&$invoice) { |
|
352 | 352 | |
353 | - $billing_address = $this->prepare_address_details( $invoice, 'billing' ); |
|
353 | + $billing_address = $this->prepare_address_details($invoice, 'billing'); |
|
354 | 354 | |
355 | 355 | // Update the invoice with the billing details. |
356 | - $invoice->set_props( $billing_address ); |
|
356 | + $invoice->set_props($billing_address); |
|
357 | 357 | |
358 | 358 | } |
359 | 359 | |
@@ -363,15 +363,15 @@ discard block |
||
363 | 363 | * @return array |
364 | 364 | * @param WPInv_Invoice $invoice |
365 | 365 | */ |
366 | - protected function prepare_shipping_info( $invoice ) { |
|
366 | + protected function prepare_shipping_info($invoice) { |
|
367 | 367 | |
368 | 368 | $data = $this->payment_form_submission->get_data(); |
369 | 369 | |
370 | - if ( empty( $data['same-shipping-address'] ) ) { |
|
371 | - return $this->prepare_address_details( $invoice, 'shipping' ); |
|
370 | + if (empty($data['same-shipping-address'])) { |
|
371 | + return $this->prepare_address_details($invoice, 'shipping'); |
|
372 | 372 | } |
373 | 373 | |
374 | - return $this->prepare_address_details( $invoice, 'billing' ); |
|
374 | + return $this->prepare_address_details($invoice, 'billing'); |
|
375 | 375 | |
376 | 376 | } |
377 | 377 | |
@@ -382,41 +382,41 @@ discard block |
||
382 | 382 | * @param array $prepared_payment_form_data |
383 | 383 | * @param array $shipping |
384 | 384 | */ |
385 | - protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) { |
|
385 | + protected function post_process_submission($invoice, $prepared_payment_form_data, $shipping) { |
|
386 | 386 | |
387 | 387 | // Ensure the invoice exists. |
388 | - if ( ! $invoice->exists() ) { |
|
389 | - wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) ); |
|
388 | + if (!$invoice->exists()) { |
|
389 | + wp_send_json_error(__('An error occured while saving your invoice. Please try again.', 'invoicing')); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | // Save payment form data. |
393 | - $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice ); |
|
394 | - delete_post_meta( $invoice->get_id(), 'payment_form_data' ); |
|
395 | - delete_post_meta( $invoice->get_id(), 'additional_meta_data' ); |
|
396 | - if ( ! empty( $prepared_payment_form_data ) ) { |
|
393 | + $prepared_payment_form_data = apply_filters('getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice); |
|
394 | + delete_post_meta($invoice->get_id(), 'payment_form_data'); |
|
395 | + delete_post_meta($invoice->get_id(), 'additional_meta_data'); |
|
396 | + if (!empty($prepared_payment_form_data)) { |
|
397 | 397 | |
398 | - if ( ! empty( $prepared_payment_form_data['all'] ) ) { |
|
399 | - update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] ); |
|
398 | + if (!empty($prepared_payment_form_data['all'])) { |
|
399 | + update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all']); |
|
400 | 400 | } |
401 | 401 | |
402 | - if ( ! empty( $prepared_payment_form_data['meta'] ) ) { |
|
403 | - update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] ); |
|
402 | + if (!empty($prepared_payment_form_data['meta'])) { |
|
403 | + update_post_meta($invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta']); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | } |
407 | 407 | |
408 | 408 | // Save payment form data. |
409 | - if ( ! empty( $shipping ) ) { |
|
410 | - update_post_meta( $invoice->get_id(), 'shipping_address', $shipping ); |
|
409 | + if (!empty($shipping)) { |
|
410 | + update_post_meta($invoice->get_id(), 'shipping_address', $shipping); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | // Backwards compatibility. |
414 | - add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) ); |
|
414 | + add_filter('wp_redirect', array($this, 'send_redirect_response')); |
|
415 | 415 | |
416 | - $this->process_payment( $invoice ); |
|
416 | + $this->process_payment($invoice); |
|
417 | 417 | |
418 | 418 | // If we are here, there was an error. |
419 | - wpinv_send_back_to_checkout( $invoice ); |
|
419 | + wpinv_send_back_to_checkout($invoice); |
|
420 | 420 | |
421 | 421 | } |
422 | 422 | |
@@ -425,41 +425,41 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @param WPInv_Invoice $invoice |
427 | 427 | */ |
428 | - protected function process_payment( $invoice ) { |
|
428 | + protected function process_payment($invoice) { |
|
429 | 429 | |
430 | 430 | // Clear any checkout errors. |
431 | 431 | wpinv_clear_errors(); |
432 | 432 | |
433 | 433 | // No need to send free invoices to the gateway. |
434 | - if ( $invoice->is_free() ) { |
|
435 | - $this->process_free_payment( $invoice ); |
|
434 | + if ($invoice->is_free()) { |
|
435 | + $this->process_free_payment($invoice); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | $submission = $this->payment_form_submission; |
439 | 439 | |
440 | 440 | // Fires before sending to the gateway. |
441 | - do_action( 'getpaid_checkout_before_gateway', $invoice, $submission ); |
|
441 | + do_action('getpaid_checkout_before_gateway', $invoice, $submission); |
|
442 | 442 | |
443 | 443 | // Allow the sumission data to be modified before it is sent to the gateway. |
444 | 444 | $submission_data = $submission->get_data(); |
445 | - $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice ); |
|
446 | - $submission_data = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice ); |
|
445 | + $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice); |
|
446 | + $submission_data = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice); |
|
447 | 447 | |
448 | 448 | // Validate the currency. |
449 | - if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) { |
|
450 | - wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) ); |
|
449 | + if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) { |
|
450 | + wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support this currency', 'invoicing')); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | // Check to see if we have any errors. |
454 | - if ( wpinv_get_errors() ) { |
|
455 | - wpinv_send_back_to_checkout( $invoice ); |
|
454 | + if (wpinv_get_errors()) { |
|
455 | + wpinv_send_back_to_checkout($invoice); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | // Send info to the gateway for payment processing |
459 | - do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission ); |
|
459 | + do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission); |
|
460 | 460 | |
461 | 461 | // Backwards compatibility. |
462 | - wpinv_send_to_gateway( $submission_gateway, $invoice ); |
|
462 | + wpinv_send_to_gateway($submission_gateway, $invoice); |
|
463 | 463 | |
464 | 464 | } |
465 | 465 | |
@@ -468,12 +468,12 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @param WPInv_Invoice $invoice |
470 | 470 | */ |
471 | - protected function process_free_payment( $invoice ) { |
|
471 | + protected function process_free_payment($invoice) { |
|
472 | 472 | |
473 | - $invoice->set_gateway( 'none' ); |
|
474 | - $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true ); |
|
473 | + $invoice->set_gateway('none'); |
|
474 | + $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true); |
|
475 | 475 | $invoice->mark_paid(); |
476 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
476 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
477 | 477 | |
478 | 478 | } |
479 | 479 | |
@@ -481,9 +481,9 @@ discard block |
||
481 | 481 | * Sends a redrect response to payment details. |
482 | 482 | * |
483 | 483 | */ |
484 | - public function send_redirect_response( $url ) { |
|
485 | - $url = urlencode( $url ); |
|
486 | - wp_send_json_success( $url ); |
|
484 | + public function send_redirect_response($url) { |
|
485 | + $url = urlencode($url); |
|
486 | + wp_send_json_success($url); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | } |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | * @var GetPaid_Payment_Form $form The current payment form |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -if ( ! getpaid_has_published_discount() ) { |
|
13 | +if (!getpaid_has_published_discount()) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | -$placeholder = esc_attr( $input_label ); |
|
18 | -$label = esc_html( $button_label ); |
|
17 | +$placeholder = esc_attr($input_label); |
|
18 | +$label = esc_html($button_label); |
|
19 | 19 | |
20 | -if ( ! empty( $description ) ) { |
|
20 | +if (!empty($description)) { |
|
21 | 21 | $description = "<small class='form-text text-muted'>$description</small>"; |
22 | 22 | } else { |
23 | 23 | $description = ''; |
24 | 24 | } |
25 | 25 | |
26 | 26 | $discount_code = ''; |
27 | -if ( ! empty( $form->invoice ) ) { |
|
28 | - $discount_code = esc_attr( $form->invoice->get_discount_code() ); |
|
27 | +if (!empty($form->invoice)) { |
|
28 | + $discount_code = esc_attr($form->invoice->get_discount_code()); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | ?> |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | <input name="discount" placeholder="<?php echo $placeholder; ?>" value="<?php echo $discount_code; ?>" class="form-control mr-2 mb-2 getpaid-discount-field-input" style="flex: 1;" type="text"> |
37 | 37 | <a href="#" class="btn btn-secondary submit-button mb-2 getpaid-discount-button"><?php echo $label; ?></a> |
38 | 38 | </div> |
39 | - <?php echo wp_kses_post( $description ); ?> |
|
39 | + <?php echo wp_kses_post($description); ?> |
|
40 | 40 | <div class="getpaid-custom-payment-form-errors alert alert-danger d-none"></div> |
41 | 41 | </div> |
42 | 42 | </div> |
@@ -7,11 +7,11 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$tag = isset( $element['level'] ) ? trim( $element['level'] ) : 'h3'; |
|
13 | -$text = isset( $element['text'] ) ? wp_kses_post( trim( $element['text'] ) ) : ''; |
|
12 | +$tag = isset($element['level']) ? trim($element['level']) : 'h3'; |
|
13 | +$text = isset($element['text']) ? wp_kses_post(trim($element['text'])) : ''; |
|
14 | 14 | |
15 | -if ( ! empty( $text ) ) { |
|
15 | +if (!empty($text)) { |
|
16 | 16 | echo "<$tag>$text</$tag>"; |
17 | 17 | } |
@@ -7,10 +7,10 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$text = isset( $element['text'] ) ? wp_kses_post( trim( $element['text'] ) ) : ''; |
|
12 | +$text = isset($element['text']) ? wp_kses_post(trim($element['text'])) : ''; |
|
13 | 13 | |
14 | -if ( ! empty( $text ) ) { |
|
14 | +if (!empty($text)) { |
|
15 | 15 | echo "<p>$text</p>"; |
16 | 16 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
74 | 74 | */ |
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
75 | + public function __construct($form = 0) { |
|
76 | + parent::__construct($form); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if (is_numeric($form) && $form > 0) { |
|
79 | + $this->set_id($form); |
|
80 | + } elseif ($form instanceof self) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
82 | + $this->set_id($form->get_id()); |
|
83 | 83 | $this->invoice = $form->invoice; |
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
85 | + } elseif (!empty($form->ID)) { |
|
86 | + $this->set_id($form->ID); |
|
87 | 87 | } else { |
88 | - $this->set_object_read( true ); |
|
88 | + $this->set_object_read(true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
95 | - $this->post = get_post( $this->get_id() ); |
|
96 | - $this->data_store->read( $this ); |
|
94 | + if ($this->get_id() > 0) { |
|
95 | + $this->post = get_post($this->get_id()); |
|
96 | + $this->data_store->read($this); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param string $context View or edit context. |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
123 | + public function get_version($context = 'view') { |
|
124 | + return $this->get_prop('version', $context); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $context View or edit context. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
134 | + public function get_date_created($context = 'view') { |
|
135 | + return $this->get_prop('date_created', $context); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param string $context View or edit context. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
146 | - $date = $this->get_date_created( $context ); |
|
145 | + public function get_date_created_gmt($context = 'view') { |
|
146 | + $date = $this->get_date_created($context); |
|
147 | 147 | |
148 | - if ( $date ) { |
|
149 | - $date = get_gmt_from_date( $date ); |
|
148 | + if ($date) { |
|
149 | + $date = get_gmt_from_date($date); |
|
150 | 150 | } |
151 | 151 | return $date; |
152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $context View or edit context. |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
161 | + public function get_date_modified($context = 'view') { |
|
162 | + return $this->get_prop('date_modified', $context); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $context View or edit context. |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | - $date = $this->get_date_modified( $context ); |
|
172 | + public function get_date_modified_gmt($context = 'view') { |
|
173 | + $date = $this->get_date_modified($context); |
|
174 | 174 | |
175 | - if ( $date ) { |
|
176 | - $date = get_gmt_from_date( $date ); |
|
175 | + if ($date) { |
|
176 | + $date = get_gmt_from_date($date); |
|
177 | 177 | } |
178 | 178 | return $date; |
179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param string $context View or edit context. |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
188 | + public function get_name($context = 'view') { |
|
189 | + return $this->get_prop('name', $context); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @param string $context View or edit context. |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
199 | + public function get_title($context = 'view') { |
|
200 | + return $this->get_name($context); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param string $context View or edit context. |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
210 | + public function get_author($context = 'view') { |
|
211 | + return (int) $this->get_prop('author', $context); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
221 | + public function get_elements($context = 'view') { |
|
222 | + $elements = $this->get_prop('elements', $context); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
224 | + if (empty($elements) || !is_array($elements)) { |
|
225 | + return wpinv_get_data('sample-payment-form'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Ensure that all required elements exist. |
229 | 229 | $_elements = array(); |
230 | - foreach ( $elements as $element ) { |
|
230 | + foreach ($elements as $element) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
233 | 233 | |
234 | 234 | $_elements[] = array( |
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
236 | 236 | 'id' => 'gtscicd', |
237 | 237 | 'name' => 'gtscicd', |
238 | 238 | 'type' => 'gateway_select', |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | * @param string $return objects or arrays. |
258 | 258 | * @return GetPaid_Form_Item[] |
259 | 259 | */ |
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
260 | + public function get_items($context = 'view', $return = 'objects') { |
|
261 | + $items = $this->get_prop('items', $context); |
|
262 | 262 | |
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
263 | + if (empty($items) || !is_array($items)) { |
|
264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Convert the items. |
268 | 268 | $prepared = array(); |
269 | 269 | |
270 | - foreach ( $items as $key => $value ) { |
|
270 | + foreach ($items as $key => $value) { |
|
271 | 271 | |
272 | 272 | // Form items. |
273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
273 | + if ($value instanceof GetPaid_Form_Item) { |
|
274 | 274 | |
275 | - if ( $value->can_purchase() ) { |
|
275 | + if ($value->can_purchase()) { |
|
276 | 276 | $prepared[] = $value; |
277 | 277 | } |
278 | 278 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // $item_id => $quantity (buy buttons) |
284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | - $item = new GetPaid_Form_Item( $key ); |
|
284 | + if (is_numeric($key) && is_numeric($value)) { |
|
285 | + $item = new GetPaid_Form_Item($key); |
|
286 | 286 | |
287 | - if ( $item->can_purchase() ) { |
|
287 | + if ($item->can_purchase()) { |
|
288 | 288 | |
289 | 289 | $value = (float) $value; |
290 | - $item->set_quantity( $value ); |
|
291 | - if ( 0 == $value ) { |
|
292 | - $item->set_quantity( 1 ); |
|
293 | - $item->set_allow_quantities( true ); |
|
290 | + $item->set_quantity($value); |
|
291 | + if (0 == $value) { |
|
292 | + $item->set_quantity(1); |
|
293 | + $item->set_allow_quantities(true); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $prepared[] = $item; |
@@ -300,33 +300,33 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Items saved via payment forms editor. |
303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
303 | + if (is_array($value) && isset($value['id'])) { |
|
304 | 304 | |
305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
305 | + $item = new GetPaid_Form_Item($value['id']); |
|
306 | 306 | |
307 | - if ( ! $item->can_purchase() ) { |
|
307 | + if (!$item->can_purchase()) { |
|
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Sub-total (Cart items). |
312 | - if ( isset( $value['subtotal'] ) ) { |
|
313 | - $item->set_price( $value['subtotal'] ); |
|
312 | + if (isset($value['subtotal'])) { |
|
313 | + $item->set_price($value['subtotal']); |
|
314 | 314 | } |
315 | 315 | |
316 | - if ( isset( $value['quantity'] ) ) { |
|
317 | - $item->set_quantity( $value['quantity'] ); |
|
316 | + if (isset($value['quantity'])) { |
|
317 | + $item->set_quantity($value['quantity']); |
|
318 | 318 | } |
319 | 319 | |
320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
320 | + if (isset($value['allow_quantities'])) { |
|
321 | + $item->set_allow_quantities($value['allow_quantities']); |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( isset( $value['required'] ) ) { |
|
325 | - $item->set_is_required( $value['required'] ); |
|
324 | + if (isset($value['required'])) { |
|
325 | + $item->set_is_required($value['required']); |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( isset( $value['description'] ) ) { |
|
329 | - $item->set_custom_description( $value['description'] ); |
|
328 | + if (isset($value['description'])) { |
|
329 | + $item->set_custom_description($value['description']); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $prepared[] = $item; |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | // $item_id => array( 'price' => 10 ) (item variations) |
338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
339 | - $item = new GetPaid_Form_Item( $key ); |
|
338 | + if (is_numeric($key) && is_array($value)) { |
|
339 | + $item = new GetPaid_Form_Item($key); |
|
340 | 340 | |
341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
342 | - $item->set_price( $value['price'] ); |
|
341 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
342 | + $item->set_price($value['price']); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $item->can_purchase() ) { |
|
345 | + if ($item->can_purchase()) { |
|
346 | 346 | $prepared[] = $item; |
347 | 347 | } |
348 | 348 | |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | - if ( 'objects' == $return && 'view' == $context ) { |
|
354 | + if ('objects' == $return && 'view' == $context) { |
|
355 | 355 | return $prepared; |
356 | 356 | } |
357 | 357 | |
358 | 358 | $items = array(); |
359 | - foreach ( $prepared as $item ) { |
|
359 | + foreach ($prepared as $item) { |
|
360 | 360 | $items[] = $item->prepare_data_for_use(); |
361 | 361 | } |
362 | 362 | |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | * @param int $item_id The item id to return. |
371 | 371 | * @return GetPaid_Form_Item|bool |
372 | 372 | */ |
373 | - public function get_item( $item_id ) { |
|
373 | + public function get_item($item_id) { |
|
374 | 374 | |
375 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
375 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
376 | 376 | return false; |
377 | 377 | } |
378 | 378 | |
379 | - foreach( $this->get_items() as $item ) { |
|
380 | - if ( $item->get_id() == (int) $item_id ) { |
|
379 | + foreach ($this->get_items() as $item) { |
|
380 | + if ($item->get_id() == (int) $item_id) { |
|
381 | 381 | return $item; |
382 | 382 | } |
383 | 383 | } |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | * @param string $element_type The element type to return. |
394 | 394 | * @return array|bool |
395 | 395 | */ |
396 | - public function get_element_type( $element_type ) { |
|
396 | + public function get_element_type($element_type) { |
|
397 | 397 | |
398 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
398 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
399 | 399 | return false; |
400 | 400 | } |
401 | 401 | |
402 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
402 | + foreach ($this->get_prop('elements') as $element) { |
|
403 | 403 | |
404 | - if ( $element['type'] == $element_type ) { |
|
404 | + if ($element['type'] == $element_type) { |
|
405 | 405 | return $element; |
406 | 406 | } |
407 | 407 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @param string $context View or edit context. |
419 | 419 | * @return float |
420 | 420 | */ |
421 | - public function get_earned( $context = 'view' ) { |
|
422 | - return $this->get_prop( 'earned', $context ); |
|
421 | + public function get_earned($context = 'view') { |
|
422 | + return $this->get_prop('earned', $context); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param string $context View or edit context. |
430 | 430 | * @return float |
431 | 431 | */ |
432 | - public function get_refunded( $context = 'view' ) { |
|
433 | - return $this->get_prop( 'refunded', $context ); |
|
432 | + public function get_refunded($context = 'view') { |
|
433 | + return $this->get_prop('refunded', $context); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $context View or edit context. |
441 | 441 | * @return float |
442 | 442 | */ |
443 | - public function get_cancelled( $context = 'view' ) { |
|
444 | - return $this->get_prop( 'cancelled', $context ); |
|
443 | + public function get_cancelled($context = 'view') { |
|
444 | + return $this->get_prop('cancelled', $context); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * @param string $context View or edit context. |
452 | 452 | * @return float |
453 | 453 | */ |
454 | - public function get_failed( $context = 'view' ) { |
|
455 | - return $this->get_prop( 'failed', $context ); |
|
454 | + public function get_failed($context = 'view') { |
|
455 | + return $this->get_prop('failed', $context); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * @return string |
464 | 464 | */ |
465 | 465 | public function get_currency() { |
466 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
466 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /* |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @since 1.0.19 |
484 | 484 | */ |
485 | - public function set_version( $value ) { |
|
486 | - $this->set_prop( 'version', $value ); |
|
485 | + public function set_version($value) { |
|
486 | + $this->set_prop('version', $value); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | * @param string $value Value to set. |
494 | 494 | * @return bool Whether or not the date was set. |
495 | 495 | */ |
496 | - public function set_date_created( $value ) { |
|
497 | - $date = strtotime( $value ); |
|
496 | + public function set_date_created($value) { |
|
497 | + $date = strtotime($value); |
|
498 | 498 | |
499 | - if ( $date ) { |
|
500 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
499 | + if ($date) { |
|
500 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
501 | 501 | return true; |
502 | 502 | } |
503 | 503 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * @param string $value Value to set. |
513 | 513 | * @return bool Whether or not the date was set. |
514 | 514 | */ |
515 | - public function set_date_modified( $value ) { |
|
516 | - $date = strtotime( $value ); |
|
515 | + public function set_date_modified($value) { |
|
516 | + $date = strtotime($value); |
|
517 | 517 | |
518 | - if ( $date ) { |
|
519 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
518 | + if ($date) { |
|
519 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
520 | 520 | return true; |
521 | 521 | } |
522 | 522 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @since 1.0.19 |
531 | 531 | * @param string $value New name. |
532 | 532 | */ |
533 | - public function set_name( $value ) { |
|
534 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
533 | + public function set_name($value) { |
|
534 | + $this->set_prop('name', sanitize_text_field($value)); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | * @since 1.0.19 |
541 | 541 | * @param string $value New name. |
542 | 542 | */ |
543 | - public function set_title( $value ) { |
|
544 | - $this->set_name( $value ); |
|
543 | + public function set_title($value) { |
|
544 | + $this->set_name($value); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | * @since 1.0.19 |
551 | 551 | * @param int $value New author. |
552 | 552 | */ |
553 | - public function set_author( $value ) { |
|
554 | - $this->set_prop( 'author', (int) $value ); |
|
553 | + public function set_author($value) { |
|
554 | + $this->set_prop('author', (int) $value); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -561,9 +561,9 @@ discard block |
||
561 | 561 | * @sinve 2.3.4 Array values sanitized. |
562 | 562 | * @param array $value Form elements. |
563 | 563 | */ |
564 | - public function set_elements( $value ) { |
|
565 | - if ( is_array( $value ) ) { |
|
566 | - $this->set_prop( 'elements', wp_kses_post_deep( $value ) ); |
|
564 | + public function set_elements($value) { |
|
565 | + if (is_array($value)) { |
|
566 | + $this->set_prop('elements', wp_kses_post_deep($value)); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
@@ -574,18 +574,18 @@ discard block |
||
574 | 574 | * |
575 | 575 | * @return mixed |
576 | 576 | */ |
577 | - public function sanitize_array_values($value){ |
|
577 | + public function sanitize_array_values($value) { |
|
578 | 578 | |
579 | 579 | // sanitize |
580 | - if(!empty($value )){ |
|
580 | + if (!empty($value)) { |
|
581 | 581 | |
582 | - foreach($value as $key => $val_arr){ |
|
582 | + foreach ($value as $key => $val_arr) { |
|
583 | 583 | |
584 | - if(is_array($val_arr)){ |
|
584 | + if (is_array($val_arr)) { |
|
585 | 585 | // check if we have sub array items. |
586 | 586 | $sub_arr = array(); |
587 | - foreach($val_arr as $key2 => $val2){ |
|
588 | - if(is_array($val2)){ |
|
587 | + foreach ($val_arr as $key2 => $val2) { |
|
588 | + if (is_array($val2)) { |
|
589 | 589 | $sub_arr[$key2] = $this->sanitize_array_values($val2); |
590 | 590 | unset($val_arr[$key][$key2]); |
591 | 591 | } |
@@ -595,14 +595,14 @@ discard block |
||
595 | 595 | $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
596 | 596 | |
597 | 597 | // sanitize array elements |
598 | - $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
598 | + $value[$key] = array_map('sanitize_text_field', $val_arr); |
|
599 | 599 | |
600 | 600 | // add back the description if set |
601 | - if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
601 | + if (isset($val_arr['description'])) { $value[$key]['description'] = $help_text; } |
|
602 | 602 | |
603 | 603 | // add back sub array items after its been sanitized. |
604 | - if ( ! empty( $sub_arr ) ) { |
|
605 | - $value[$key] = array_merge($value[$key],$sub_arr); |
|
604 | + if (!empty($sub_arr)) { |
|
605 | + $value[$key] = array_merge($value[$key], $sub_arr); |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
@@ -619,9 +619,9 @@ discard block |
||
619 | 619 | * @since 1.0.19 |
620 | 620 | * @param array $value Form elements. |
621 | 621 | */ |
622 | - public function set_items( $value ) { |
|
623 | - if ( is_array( $value ) ) { |
|
624 | - $this->set_prop( 'items', $value ); |
|
622 | + public function set_items($value) { |
|
623 | + if (is_array($value)) { |
|
624 | + $this->set_prop('items', $value); |
|
625 | 625 | } |
626 | 626 | } |
627 | 627 | |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | * @since 1.0.19 |
632 | 632 | * @param float $value Amount earned. |
633 | 633 | */ |
634 | - public function set_earned( $value ) { |
|
635 | - $value = max( (float) $value, 0 ); |
|
636 | - $this->set_prop( 'earned', $value ); |
|
634 | + public function set_earned($value) { |
|
635 | + $value = max((float) $value, 0); |
|
636 | + $this->set_prop('earned', $value); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -642,9 +642,9 @@ discard block |
||
642 | 642 | * @since 1.0.19 |
643 | 643 | * @param float $value Amount refunded. |
644 | 644 | */ |
645 | - public function set_refunded( $value ) { |
|
646 | - $value = max( (float) $value, 0 ); |
|
647 | - $this->set_prop( 'refunded', $value ); |
|
645 | + public function set_refunded($value) { |
|
646 | + $value = max((float) $value, 0); |
|
647 | + $this->set_prop('refunded', $value); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | /** |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | * @since 1.0.19 |
654 | 654 | * @param float $value Amount cancelled. |
655 | 655 | */ |
656 | - public function set_cancelled( $value ) { |
|
657 | - $value = max( (float) $value, 0 ); |
|
658 | - $this->set_prop( 'cancelled', $value ); |
|
656 | + public function set_cancelled($value) { |
|
657 | + $value = max((float) $value, 0); |
|
658 | + $this->set_prop('cancelled', $value); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | * @since 1.0.19 |
665 | 665 | * @param float $value Amount cancelled. |
666 | 666 | */ |
667 | - public function set_failed( $value ) { |
|
668 | - $value = max( (float) $value, 0 ); |
|
669 | - $this->set_prop( 'failed', $value ); |
|
667 | + public function set_failed($value) { |
|
668 | + $value = max((float) $value, 0); |
|
669 | + $this->set_prop('failed', $value); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -675,11 +675,11 @@ discard block |
||
675 | 675 | * @deprecated |
676 | 676 | * @return int item id |
677 | 677 | */ |
678 | - public function create( $data = array() ) { |
|
678 | + public function create($data = array()) { |
|
679 | 679 | |
680 | 680 | // Set the properties. |
681 | - if ( is_array( $data ) ) { |
|
682 | - $this->set_props( $data ); |
|
681 | + if (is_array($data)) { |
|
682 | + $this->set_props($data); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | // Save the item. |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * @deprecated |
694 | 694 | * @return int item id |
695 | 695 | */ |
696 | - public function update( $data = array() ) { |
|
697 | - return $this->create( $data ); |
|
696 | + public function update($data = array()) { |
|
697 | + return $this->create($data); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /* |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | */ |
715 | 715 | public function is_default() { |
716 | 716 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
717 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
717 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -726,11 +726,11 @@ discard block |
||
726 | 726 | public function is_active() { |
727 | 727 | $is_active = 0 !== (int) $this->get_id(); |
728 | 728 | |
729 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
729 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
730 | 730 | $is_active = false; |
731 | 731 | } |
732 | 732 | |
733 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
733 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
@@ -739,8 +739,8 @@ discard block |
||
739 | 739 | * @since 1.0.19 |
740 | 740 | * @return bool |
741 | 741 | */ |
742 | - public function has_item( $item_id ) { |
|
743 | - return false !== $this->get_item( $item_id ); |
|
742 | + public function has_item($item_id) { |
|
743 | + return false !== $this->get_item($item_id); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | * @since 1.0.19 |
750 | 750 | * @return bool |
751 | 751 | */ |
752 | - public function has_element_type( $element_type ) { |
|
753 | - return false !== $this->get_element_type( $element_type ); |
|
752 | + public function has_element_type($element_type) { |
|
753 | + return false !== $this->get_element_type($element_type); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -761,13 +761,13 @@ discard block |
||
761 | 761 | */ |
762 | 762 | public function is_recurring() { |
763 | 763 | |
764 | - if ( ! empty( $this->invoice ) ) { |
|
764 | + if (!empty($this->invoice)) { |
|
765 | 765 | return $this->invoice->is_recurring(); |
766 | 766 | } |
767 | 767 | |
768 | - foreach ( $this->get_items() as $item ) { |
|
768 | + foreach ($this->get_items() as $item) { |
|
769 | 769 | |
770 | - if ( $item->is_recurring() ) { |
|
770 | + if ($item->is_recurring()) { |
|
771 | 771 | return true; |
772 | 772 | } |
773 | 773 | |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @since 1.0.19 |
783 | 783 | */ |
784 | - public function get_html( $extra_markup = '' ) { |
|
784 | + public function get_html($extra_markup = '') { |
|
785 | 785 | |
786 | 786 | // Return the HTML. |
787 | 787 | return wpinv_get_template_html( |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @since 1.0.19 |
801 | 801 | */ |
802 | - public function display( $extra_markup = '' ) { |
|
803 | - echo $this->get_html( $extra_markup ); |
|
802 | + public function display($extra_markup = '') { |
|
803 | + echo $this->get_html($extra_markup); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | - add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
|
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
133 | + |
|
134 | + add_filter('query_vars', array($this, 'custom_query_vars')); |
|
135 | + add_action('init', array($this, 'add_rewrite_rule'), 10, 0); |
|
136 | + add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1); |
|
137 | 137 | |
138 | 138 | // Fires after registering actions. |
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
139 | + do_action('wpinv_actions', $this); |
|
140 | + do_action('getpaid_actions', $this); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | /* Internationalize the text strings used. */ |
146 | 146 | $this->load_textdomain(); |
147 | 147 | |
148 | - do_action( 'wpinv_loaded' ); |
|
148 | + do_action('wpinv_loaded'); |
|
149 | 149 | |
150 | 150 | // Fix oxygen page builder conflict |
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
151 | + if (function_exists('ct_css_output')) { |
|
152 | 152 | wpinv_oxygen_fix_conflict(); |
153 | 153 | } |
154 | 154 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | load_plugin_textdomain( |
170 | 170 | 'invoicing', |
171 | 171 | false, |
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
172 | + plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/' |
|
173 | 173 | ); |
174 | 174 | |
175 | 175 | } |
@@ -180,78 +180,78 @@ discard block |
||
180 | 180 | public function includes() { |
181 | 181 | |
182 | 182 | // Start with the settings. |
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
184 | 184 | |
185 | 185 | // Packages/libraries. |
186 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
186 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
188 | 188 | |
189 | 189 | // Load functions. |
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
205 | 205 | |
206 | 206 | // Register autoloader. |
207 | 207 | try { |
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
208 | + spl_autoload_register(array($this, 'autoload'), true); |
|
209 | + } catch (Exception $e) { |
|
210 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
211 | 211 | } |
212 | 212 | |
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
234 | - |
|
235 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
216 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
234 | + |
|
235 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
236 | 236 | GetPaid_Post_Types_Admin::init(); |
237 | 237 | |
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
244 | 244 | // load the user class only on the users.php page |
245 | 245 | global $pagenow; |
246 | - if($pagenow=='users.php'){ |
|
246 | + if ($pagenow == 'users.php') { |
|
247 | 247 | new WPInv_Admin_Users(); |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Register cli commands |
252 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
254 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
252 | + if (defined('WP_CLI') && WP_CLI) { |
|
253 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
254 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |
@@ -264,21 +264,21 @@ discard block |
||
264 | 264 | * @since 1.0.19 |
265 | 265 | * @return void |
266 | 266 | */ |
267 | - public function autoload( $class_name ) { |
|
267 | + public function autoload($class_name) { |
|
268 | 268 | |
269 | 269 | // Normalize the class name... |
270 | - $class_name = strtolower( $class_name ); |
|
270 | + $class_name = strtolower($class_name); |
|
271 | 271 | |
272 | 272 | // ... and make sure it is our class. |
273 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
273 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Next, prepare the file name from the class. |
278 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
278 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
279 | 279 | |
280 | 280 | // Base path of the classes. |
281 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
281 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
282 | 282 | |
283 | 283 | // And an array of possible locations in order of importance. |
284 | 284 | $locations = array( |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | "$plugin_path/includes/admin/meta-boxes", |
294 | 294 | ); |
295 | 295 | |
296 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
296 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
297 | 297 | |
298 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
299 | - include trailingslashit( $location ) . $file_name; |
|
298 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
299 | + include trailingslashit($location) . $file_name; |
|
300 | 300 | break; |
301 | 301 | } |
302 | 302 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | public function init() { |
311 | 311 | |
312 | 312 | // Fires before getpaid inits. |
313 | - do_action( 'before_getpaid_init', $this ); |
|
313 | + do_action('before_getpaid_init', $this); |
|
314 | 314 | |
315 | 315 | // Maybe upgrade. |
316 | 316 | $this->maybe_upgrade_database(); |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | ) |
328 | 328 | ); |
329 | 329 | |
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
330 | + foreach ($gateways as $id => $class) { |
|
331 | + $this->gateways[$id] = new $class(); |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
334 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
335 | 335 | GetPaid_Installer::rename_gateways_label(); |
336 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
336 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // Fires after getpaid inits. |
340 | - do_action( 'getpaid_init', $this ); |
|
340 | + do_action('getpaid_init', $this); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | public function maybe_process_ipn() { |
348 | 348 | |
349 | 349 | // Ensure that this is an IPN request. |
350 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
350 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
351 | 351 | return; |
352 | 352 | } |
353 | 353 | |
354 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
354 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
355 | 355 | |
356 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
356 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
357 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
358 | 358 | exit; |
359 | 359 | |
360 | 360 | } |
@@ -362,33 +362,33 @@ discard block |
||
362 | 362 | public function enqueue_scripts() { |
363 | 363 | |
364 | 364 | // Fires before adding scripts. |
365 | - do_action( 'getpaid_enqueue_scripts' ); |
|
365 | + do_action('getpaid_enqueue_scripts'); |
|
366 | 366 | |
367 | 367 | $localize = array(); |
368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
368 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
369 | 369 | $localize['thousands'] = wpinv_thousands_separator(); |
370 | 370 | $localize['decimals'] = wpinv_decimal_separator(); |
371 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
371 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
372 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
373 | 373 | $localize['UseTaxes'] = wpinv_use_taxes(); |
374 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
374 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
375 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
376 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
377 | 377 | |
378 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
378 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
379 | 379 | |
380 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
380 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
381 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
382 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | public function wpinv_actions() { |
386 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
386 | + if (isset($_REQUEST['wpi_action'])) { |
|
387 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
388 | 388 | } |
389 | 389 | |
390 | - if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) { |
|
391 | - include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
390 | + if (defined('WP_ALL_IMPORT_ROOT_DIR')) { |
|
391 | + include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
@@ -400,24 +400,24 @@ discard block |
||
400 | 400 | */ |
401 | 401 | public function maybe_do_authenticated_action() { |
402 | 402 | |
403 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
403 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
404 | 404 | |
405 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
406 | - $data = wp_unslash( $_REQUEST ); |
|
407 | - if ( is_user_logged_in() ) { |
|
408 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
405 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
406 | + $data = wp_unslash($_REQUEST); |
|
407 | + if (is_user_logged_in()) { |
|
408 | + do_action("getpaid_authenticated_action_$key", $data); |
|
409 | 409 | } |
410 | 410 | |
411 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
411 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
412 | 412 | |
413 | 413 | } |
414 | 414 | |
415 | 415 | } |
416 | 416 | |
417 | - public function pre_get_posts( $wp_query ) { |
|
417 | + public function pre_get_posts($wp_query) { |
|
418 | 418 | |
419 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
420 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
419 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
420 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | return $wp_query; |
@@ -432,18 +432,18 @@ discard block |
||
432 | 432 | |
433 | 433 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
434 | 434 | // So we disable our widgets when editing a page with UX Builder. |
435 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
435 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
436 | 436 | return; |
437 | 437 | } |
438 | 438 | |
439 | 439 | $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
440 | 440 | |
441 | - if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
441 | + if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
442 | 442 | // don't initiate in these conditions. |
443 | - }else{ |
|
443 | + } else { |
|
444 | 444 | |
445 | 445 | // Only load allowed widgets. |
446 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
446 | + $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array(); |
|
447 | 447 | $widgets = apply_filters( |
448 | 448 | 'getpaid_widget_classes', |
449 | 449 | array( |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | ); |
459 | 459 | |
460 | 460 | // For each widget... |
461 | - foreach ( $widgets as $widget ) { |
|
461 | + foreach ($widgets as $widget) { |
|
462 | 462 | |
463 | 463 | // Abort early if it is excluded for this page. |
464 | - if ( in_array( $widget, $exclude ) ) { |
|
464 | + if (in_array($widget, $exclude)) { |
|
465 | 465 | continue; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
469 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
470 | - register_widget( $widget ); |
|
469 | + if (is_subclass_of($widget, 'WP_Widget')) { |
|
470 | + register_widget($widget); |
|
471 | 471 | } else { |
472 | 472 | new $widget(); |
473 | 473 | } |
@@ -485,29 +485,29 @@ discard block |
||
485 | 485 | */ |
486 | 486 | public function maybe_upgrade_database() { |
487 | 487 | |
488 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
488 | + $wpi_version = get_option('wpinv_version', 0); |
|
489 | 489 | |
490 | - if ( $wpi_version == WPINV_VERSION ) { |
|
490 | + if ($wpi_version == WPINV_VERSION) { |
|
491 | 491 | return; |
492 | 492 | } |
493 | 493 | |
494 | 494 | $installer = new GetPaid_Installer(); |
495 | 495 | |
496 | - if ( empty( $wpi_version ) ) { |
|
497 | - return $installer->upgrade_db( 0 ); |
|
496 | + if (empty($wpi_version)) { |
|
497 | + return $installer->upgrade_db(0); |
|
498 | 498 | } |
499 | 499 | |
500 | - $upgrades = array( |
|
500 | + $upgrades = array( |
|
501 | 501 | '0.0.5' => '004', |
502 | 502 | '1.0.3' => '102', |
503 | 503 | '2.0.0' => '118', |
504 | 504 | '2.0.8' => '207', |
505 | 505 | ); |
506 | 506 | |
507 | - foreach ( $upgrades as $key => $method ) { |
|
507 | + foreach ($upgrades as $key => $method) { |
|
508 | 508 | |
509 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
510 | - return $installer->upgrade_db( $method ); |
|
509 | + if (version_compare($wpi_version, $key, '<')) { |
|
510 | + return $installer->upgrade_db($method); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | } |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | */ |
522 | 522 | public function maybe_flush_permalinks() { |
523 | 523 | |
524 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
524 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
525 | 525 | |
526 | - if ( ! empty( $flush ) ) { |
|
526 | + if (!empty($flush)) { |
|
527 | 527 | flush_rewrite_rules(); |
528 | - delete_option( 'wpinv_flush_permalinks' ); |
|
528 | + delete_option('wpinv_flush_permalinks'); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | } |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * @since 1.0.19 |
537 | 537 | * @param int[] $excluded_posts_ids |
538 | 538 | */ |
539 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
539 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
540 | 540 | |
541 | 541 | // Ensure that we have an array. |
542 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
542 | + if (!is_array($excluded_posts_ids)) { |
|
543 | 543 | $excluded_posts_ids = array(); |
544 | 544 | } |
545 | 545 | |
@@ -547,24 +547,24 @@ discard block |
||
547 | 547 | $our_pages = array(); |
548 | 548 | |
549 | 549 | // Checkout page. |
550 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
550 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
551 | 551 | |
552 | 552 | // Success page. |
553 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
553 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
554 | 554 | |
555 | 555 | // Failure page. |
556 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
556 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
557 | 557 | |
558 | 558 | // History page. |
559 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
559 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
560 | 560 | |
561 | 561 | // Subscriptions page. |
562 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
562 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
563 | 563 | |
564 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
564 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
565 | 565 | |
566 | 566 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
567 | - return array_unique( $excluded_posts_ids ); |
|
567 | + return array_unique($excluded_posts_ids); |
|
568 | 568 | |
569 | 569 | } |
570 | 570 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * @since 2.0.0 |
575 | 575 | */ |
576 | 576 | public function wp_footer() { |
577 | - wpinv_get_template( 'frontend-footer.php' ); |
|
577 | + wpinv_get_template('frontend-footer.php'); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -583,14 +583,14 @@ discard block |
||
583 | 583 | * @since 2.0.0 |
584 | 584 | */ |
585 | 585 | public function wp_head() { |
586 | - wpinv_get_template( 'frontend-head.php' ); |
|
586 | + wpinv_get_template('frontend-head.php'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
590 | 590 | * Custom query vars. |
591 | 591 | * |
592 | 592 | */ |
593 | - public function custom_query_vars( $vars ) { |
|
593 | + public function custom_query_vars($vars) { |
|
594 | 594 | $vars[] = 'getpaid-ipn'; |
595 | 595 | return $vars; |
596 | 596 | } |
@@ -601,28 +601,28 @@ discard block |
||
601 | 601 | */ |
602 | 602 | public function add_rewrite_rule() { |
603 | 603 | $tag = 'getpaid-ipn'; |
604 | - add_rewrite_tag( "%$tag%", '([^&]+)' ); |
|
605 | - add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' ); |
|
604 | + add_rewrite_tag("%$tag%", '([^&]+)'); |
|
605 | + add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top'); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
609 | 609 | * Processes non-query string ipns. |
610 | 610 | * |
611 | 611 | */ |
612 | - public function maybe_process_new_ipn( $query ) { |
|
612 | + public function maybe_process_new_ipn($query) { |
|
613 | 613 | |
614 | - if ( is_admin() || ! $query->is_main_query() ) { |
|
614 | + if (is_admin() || !$query->is_main_query()) { |
|
615 | 615 | return; |
616 | 616 | } |
617 | 617 | |
618 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
618 | + $gateway = get_query_var('getpaid-ipn'); |
|
619 | 619 | |
620 | - if ( ! empty( $gateway ) ){ |
|
620 | + if (!empty($gateway)) { |
|
621 | 621 | |
622 | - $gateway = sanitize_text_field( $gateway ); |
|
622 | + $gateway = sanitize_text_field($gateway); |
|
623 | 623 | nocache_headers(); |
624 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
625 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
624 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
625 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
626 | 626 | exit; |
627 | 627 | |
628 | 628 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | function __construct($name, $slug) { |
61 | 61 | $this->name = $name; |
62 | 62 | $this->slug = $slug; |
63 | - if (!empty($_GET['id'])){ |
|
63 | + if (!empty($_GET['id'])) { |
|
64 | 64 | $this->isWizard = false; |
65 | 65 | } |
66 | 66 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | function is_active_addon($post_type = null) { |
77 | 77 | |
78 | - if ( ! class_exists( 'PMXI_Plugin' ) ) { |
|
78 | + if (!class_exists('PMXI_Plugin')) { |
|
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - if ($addon_active){ |
|
90 | + if ($addon_active) { |
|
91 | 91 | |
92 | 92 | $current_theme = wp_get_theme(); |
93 | 93 | |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | |
98 | 98 | $addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false; |
99 | 99 | |
100 | - if ( ! $addon_active and $parent_theme ){ |
|
100 | + if (!$addon_active and $parent_theme) { |
|
101 | 101 | $parent_theme_name = $parent_theme->get('Name'); |
102 | 102 | $addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false; |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - if ( $addon_active and ! empty($this->active_plugins) ){ |
|
106 | + if ($addon_active and !empty($this->active_plugins)) { |
|
107 | 107 | |
108 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
108 | + include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
109 | 109 | |
110 | 110 | foreach ($this->active_plugins as $plugin) { |
111 | - if ( ! is_plugin_active($plugin) ) { |
|
111 | + if (!is_plugin_active($plugin)) { |
|
112 | 112 | $addon_active = false; |
113 | 113 | break; |
114 | 114 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | $this->when_to_run = "always"; |
138 | 138 | } |
139 | 139 | |
140 | - @$this->active_post_types = ( ! empty($conditions['post_types'])) ? $conditions['post_types'] : array(); |
|
141 | - @$this->active_themes = ( ! empty($conditions['themes'])) ? $conditions['themes'] : array(); |
|
142 | - @$this->active_plugins = ( ! empty($conditions['plugins'])) ? $conditions['plugins'] : array(); |
|
140 | + @$this->active_post_types = (!empty($conditions['post_types'])) ? $conditions['post_types'] : array(); |
|
141 | + @$this->active_themes = (!empty($conditions['themes'])) ? $conditions['themes'] : array(); |
|
142 | + @$this->active_plugins = (!empty($conditions['plugins'])) ? $conditions['plugins'] : array(); |
|
143 | 143 | |
144 | 144 | add_filter('pmxi_addons', array($this, 'wpai_api_register')); |
145 | 145 | add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse')); |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | add_filter('pmxi_options_options', array($this, 'wpai_api_options')); |
149 | 149 | add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1); |
150 | 150 | add_filter('pmxi_custom_types', array($this, 'filter_post_types'), 10, 2); |
151 | - add_filter('pmxi_post_list_order', array($this,'sort_post_types'), 10, 1); |
|
152 | - add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1 ); |
|
153 | - add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2); |
|
151 | + add_filter('pmxi_post_list_order', array($this, 'sort_post_types'), 10, 1); |
|
152 | + add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1); |
|
153 | + add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2); |
|
154 | 154 | add_action('admin_init', array($this, 'admin_notice_ignore')); |
155 | 155 | } |
156 | 156 | |
157 | 157 | function parse($data) { |
158 | 158 | |
159 | - if ( ! $this->is_active_addon($data['import']->options['custom_type'])) return false; |
|
159 | + if (!$this->is_active_addon($data['import']->options['custom_type'])) return false; |
|
160 | 160 | |
161 | 161 | $parsedData = $this->helper_parse($data, $this->options_array()); |
162 | 162 | return $parsedData; |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | |
167 | 167 | function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') { |
168 | 168 | |
169 | - $field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text); |
|
169 | + $field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text); |
|
170 | 170 | |
171 | 171 | $this->fields[$field_slug] = $field; |
172 | 172 | |
173 | - if ( ! empty($enum_values) ){ |
|
173 | + if (!empty($enum_values)) { |
|
174 | 174 | foreach ($enum_values as $key => $value) { |
175 | 175 | if (is_array($value)) |
176 | 176 | { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | else |
182 | 182 | { |
183 | 183 | foreach ($value as $n => $param) { |
184 | - if (is_array($param) and ! empty($this->fields[$param['slug']])){ |
|
184 | + if (is_array($param) and !empty($this->fields[$param['slug']])) { |
|
185 | 185 | $this->fields[$param['slug']]['is_sub_field'] = true; |
186 | 186 | } |
187 | 187 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | } |
196 | 196 | |
197 | - function add_acf_field($field){ |
|
197 | + function add_acf_field($field) { |
|
198 | 198 | $this->fields[$field->post_name] = array( |
199 | 199 | 'type' => 'acf', |
200 | 200 | 'field_obj' => $field |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | |
204 | 204 | private $acfGroups = array(); |
205 | 205 | |
206 | - function use_acf_group($acf_group){ |
|
206 | + function use_acf_group($acf_group) { |
|
207 | 207 | $this->add_text( |
208 | 208 | '<div class="postbox acf_postbox default acf_signle_group rad4"> |
209 | - <h3 class="hndle" style="margin-top:0;"><span>'.$acf_group['title'].'</span></h3> |
|
209 | + <h3 class="hndle" style="margin-top:0;"><span>'.$acf_group['title'] . '</span></h3> |
|
210 | 210 | <div class="inside">'); |
211 | 211 | $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC')); |
212 | - if (!empty($acf_fields)){ |
|
212 | + if (!empty($acf_fields)) { |
|
213 | 213 | foreach ($acf_fields as $field) { |
214 | 214 | $this->add_acf_field($field); |
215 | 215 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2); |
220 | 220 | } |
221 | 221 | |
222 | - function acf_is_show_group($is_show, $acf_group){ |
|
222 | + function acf_is_show_group($is_show, $acf_group) { |
|
223 | 223 | return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true; |
224 | 224 | } |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param string $default_value - default option value |
232 | 232 | * |
233 | 233 | */ |
234 | - function add_option($slug, $default_value = ''){ |
|
234 | + function add_option($slug, $default_value = '') { |
|
235 | 235 | $this->options[$slug] = $default_value; |
236 | 236 | } |
237 | 237 | |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | |
240 | 240 | $options_list = array(); |
241 | 241 | |
242 | - if ( ! empty( $this->fields ) ) { |
|
242 | + if (!empty($this->fields)) { |
|
243 | 243 | |
244 | 244 | foreach ($this->fields as $field_slug => $field_params) { |
245 | 245 | if (in_array($field_params['type'], array('title', 'plain_text', 'acf'))) continue; |
246 | 246 | $default_value = ''; |
247 | - if (!empty($field_params['enum_values'])){ |
|
247 | + if (!empty($field_params['enum_values'])) { |
|
248 | 248 | foreach ($field_params['enum_values'] as $key => $value) { |
249 | 249 | $default_value = $key; |
250 | 250 | break; |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | |
256 | 256 | } |
257 | 257 | |
258 | - if ( ! empty($this->options) ){ |
|
258 | + if (!empty($this->options)) { |
|
259 | 259 | foreach ($this->options as $slug => $value) { |
260 | 260 | $options_arr[$slug] = $value; |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | 264 | $options_arr[$this->slug] = $options_list; |
265 | - $options_arr['rapid_addon'] = plugin_basename( __FILE__ ); |
|
265 | + $options_arr['rapid_addon'] = plugin_basename(__FILE__); |
|
266 | 266 | |
267 | 267 | return $options_arr; |
268 | 268 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | } |
297 | 297 | |
298 | - function wpai_api_post_saved($functions){ |
|
298 | + function wpai_api_post_saved($functions) { |
|
299 | 299 | $functions[$this->slug] = array($this, 'post_saved'); |
300 | 300 | return $functions; |
301 | 301 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | } |
310 | 310 | |
311 | - function post_saved( $importData ){ |
|
311 | + function post_saved($importData) { |
|
312 | 312 | |
313 | 313 | if (is_callable($this->post_saved_function)) |
314 | 314 | call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']); |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | // print_r($import_options); |
328 | 328 | // echo "</pre>"; |
329 | 329 | |
330 | - if ( ! empty($parsedData) ) { |
|
330 | + if (!empty($parsedData)) { |
|
331 | 331 | |
332 | 332 | $this->logger = $importData['logger']; |
333 | 333 | |
334 | 334 | $post_id = $importData['pid']; |
335 | 335 | $index = $importData['i']; |
336 | 336 | $data = array(); |
337 | - if (!empty($this->fields)){ |
|
337 | + if (!empty($this->fields)) { |
|
338 | 338 | foreach ($this->fields as $field_slug => $field_params) { |
339 | 339 | if (in_array($field_params['type'], array('title', 'plain_text'))) continue; |
340 | 340 | switch ($field_params['type']) { |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | $image_url_or_path = $parsedData[$field_slug][$index]; |
347 | 347 | |
348 | - if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) { |
|
348 | + if (!array_key_exists($field_slug, $import_options['download_image'])) { |
|
349 | 349 | continue 2; |
350 | 350 | } |
351 | 351 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | |
366 | 366 | $image_url_or_path = $parsedData[$field_slug][$index]; |
367 | 367 | |
368 | - if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) { |
|
368 | + if (!array_key_exists($field_slug, $import_options['download_image'])) { |
|
369 | 369 | continue 2; |
370 | 370 | } |
371 | 371 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | if (!empty($mapping_rules) and is_array($mapping_rules)) { |
395 | 395 | foreach ($mapping_rules as $rule_number => $map_to) { |
396 | - if (isset($map_to[trim($data[$field_slug])])){ |
|
396 | + if (isset($map_to[trim($data[$field_slug])])) { |
|
397 | 397 | $data[$field_slug] = trim($map_to[trim($data[$field_slug])]); |
398 | 398 | break; |
399 | 399 | } |
@@ -442,14 +442,14 @@ discard block |
||
442 | 442 | |
443 | 443 | echo $this->helper_metabox_bottom(); |
444 | 444 | |
445 | - if ( ! empty($this->image_sections) ){ |
|
445 | + if (!empty($this->image_sections)) { |
|
446 | 446 | $is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type); |
447 | 447 | foreach ($this->image_sections as $k => $section) { |
448 | 448 | $section_options = array(); |
449 | 449 | foreach ($this->image_options as $slug => $value) { |
450 | 450 | $section_options[$section['slug'] . $slug] = $value; |
451 | 451 | } |
452 | - if ( ! $is_images_section_enabled and ! $k ){ |
|
452 | + if (!$is_images_section_enabled and !$k) { |
|
453 | 453 | $section_options[$section['slug'] . 'is_featured'] = 1; |
454 | 454 | } |
455 | 455 | PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | |
459 | 459 | } |
460 | 460 | |
461 | - function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){ |
|
461 | + function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false) { |
|
462 | 462 | |
463 | 463 | if (!isset($current_values[$this->slug][$field_slug])) { |
464 | 464 | $current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : ''; |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | $field_params['name'], |
472 | 472 | array( |
473 | 473 | 'tooltip' => $field_params['tooltip'], |
474 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
475 | - 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
474 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
475 | + 'field_value' => ($current_values[$this->slug][$field_slug] == '' && $this->isWizard) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
476 | 476 | ) |
477 | 477 | ); |
478 | 478 | |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | $field_params['name'], |
484 | 484 | array( |
485 | 485 | 'tooltip' => $field_params['tooltip'], |
486 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
487 | - 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
486 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
487 | + 'field_value' => ($current_values[$this->slug][$field_slug] == '' && $this->isWizard) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
488 | 488 | ) |
489 | 489 | ); |
490 | 490 | |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | $field_params['name'], |
496 | 496 | array( |
497 | 497 | 'tooltip' => $field_params['tooltip'], |
498 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
499 | - 'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
498 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
499 | + 'field_value' => ($current_values[$this->slug][$field_slug] == '' && $this->isWizard) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug] |
|
500 | 500 | ) |
501 | 501 | ); |
502 | 502 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $field_params['name'], |
510 | 510 | array( |
511 | 511 | 'tooltip' => $field_params['tooltip'], |
512 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
512 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
513 | 513 | 'field_value' => $current_values[$this->slug][$field_slug], |
514 | 514 | 'download_image' => $current_values[$this->slug]['download_image'][$field_slug], |
515 | 515 | 'field_key' => $field_slug, |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | $field_params['name'], |
529 | 529 | array( |
530 | 530 | 'tooltip' => $field_params['tooltip'], |
531 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
531 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
532 | 532 | 'field_value' => $current_values[$this->slug][$field_slug], |
533 | 533 | 'enum_values' => $field_params['enum_values'], |
534 | 534 | 'mapping' => true, |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | ) |
541 | 541 | ); |
542 | 542 | |
543 | - } else if($field_params['type'] == 'accordion') { |
|
543 | + } else if ($field_params['type'] == 'accordion') { |
|
544 | 544 | |
545 | 545 | PMXI_API::add_field( |
546 | 546 | 'accordion', |
547 | 547 | $field_params['name'], |
548 | 548 | array( |
549 | 549 | 'tooltip' => $field_params['tooltip'], |
550 | - 'field_name' => $this->slug."[".$field_slug."]", |
|
550 | + 'field_name' => $this->slug . "[" . $field_slug . "]", |
|
551 | 551 | 'field_key' => $field_slug, |
552 | 552 | 'addon_prefix' => $this->slug, |
553 | 553 | 'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values), |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | ) |
556 | 556 | ); |
557 | 557 | |
558 | - } else if($field_params['type'] == 'acf') { |
|
558 | + } else if ($field_params['type'] == 'acf') { |
|
559 | 559 | $fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array(); |
560 | 560 | $fieldData['ID'] = $field_params['field_obj']->ID; |
561 | 561 | $fieldData['id'] = $field_params['field_obj']->ID; |
@@ -563,19 +563,19 @@ discard block |
||
563 | 563 | $fieldData['key'] = $field_params['field_obj']->post_name; |
564 | 564 | if (empty($fieldData['name'])) $fieldData['name'] = $field_params['field_obj']->post_excerpt; |
565 | 565 | if (function_exists('pmai_render_field')) { |
566 | - echo pmai_render_field($fieldData, ( ! empty($current_values) ) ? $current_values : array() ); |
|
566 | + echo pmai_render_field($fieldData, (!empty($current_values)) ? $current_values : array()); |
|
567 | 567 | } |
568 | - } else if($field_params['type'] == 'title'){ |
|
568 | + } else if ($field_params['type'] == 'title') { |
|
569 | 569 | ?> |
570 | - <h4 class="wpallimport-add-on-options-title"><?php _e($field_params['name'], 'wp_all_import_plugin'); ?><?php if ( ! empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4> |
|
570 | + <h4 class="wpallimport-add-on-options-title"><?php _e($field_params['name'], 'wp_all_import_plugin'); ?><?php if (!empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4> |
|
571 | 571 | <?php |
572 | 572 | |
573 | - } else if($field_params['type'] == 'plain_text'){ |
|
573 | + } else if ($field_params['type'] == 'plain_text') { |
|
574 | 574 | if ($field_params['is_html']): |
575 | 575 | echo $field_params['name']; |
576 | 576 | else: |
577 | 577 | ?> |
578 | - <p style="margin: 0 0 12px 0;"><?php echo $field_params['name'];?></p> |
|
578 | + <p style="margin: 0 0 12px 0;"><?php echo $field_params['name']; ?></p> |
|
579 | 579 | <?php |
580 | 580 | endif; |
581 | 581 | } |
@@ -587,19 +587,19 @@ discard block |
||
587 | 587 | * Helper function for nested radio fields |
588 | 588 | * |
589 | 589 | */ |
590 | - function get_sub_fields($field_params, $field_slug, $current_values){ |
|
590 | + function get_sub_fields($field_params, $field_slug, $current_values) { |
|
591 | 591 | $sub_fields = array(); |
592 | - if ( ! empty($field_params['enum_values']) ){ |
|
592 | + if (!empty($field_params['enum_values'])) { |
|
593 | 593 | foreach ($field_params['enum_values'] as $key => $value) { |
594 | 594 | $sub_fields[$key] = array(); |
595 | - if (is_array($value)){ |
|
596 | - if ($field_params['type'] == 'accordion'){ |
|
595 | + if (is_array($value)) { |
|
596 | + if ($field_params['type'] == 'accordion') { |
|
597 | 597 | $sub_fields[$key][] = $this->convert_field($value, $current_values); |
598 | 598 | } |
599 | 599 | else |
600 | 600 | { |
601 | 601 | foreach ($value as $k => $sub_field) { |
602 | - if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']])) |
|
602 | + if (is_array($sub_field) and !empty($this->fields[$sub_field['slug']])) |
|
603 | 603 | { |
604 | 604 | $sub_fields[$key][] = $this->convert_field($sub_field, $current_values); |
605 | 605 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | return $sub_fields; |
612 | 612 | } |
613 | 613 | |
614 | - function convert_field($sub_field, $current_values){ |
|
614 | + function convert_field($sub_field, $current_values) { |
|
615 | 615 | $field = array(); |
616 | 616 | if (!isset($current_values[$this->slug][$sub_field['slug']])) { |
617 | 617 | $current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : ''; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | 'label' => $this->fields[$sub_field['slug']]['name'], |
624 | 624 | 'params' => array( |
625 | 625 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
626 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
626 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
627 | 627 | 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']], |
628 | 628 | 'is_main_field' => $sub_field['is_main_field'] |
629 | 629 | ) |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | 'label' => $this->fields[$sub_field['slug']]['name'], |
636 | 636 | 'params' => array( |
637 | 637 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
638 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
638 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
639 | 639 | 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']], |
640 | 640 | 'is_main_field' => $sub_field['is_main_field'] |
641 | 641 | ) |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | 'label' => $this->fields[$sub_field['slug']]['name'], |
648 | 648 | 'params' => array( |
649 | 649 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
650 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
650 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
651 | 651 | 'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']], |
652 | 652 | 'is_main_field' => $sub_field['is_main_field'] |
653 | 653 | ) |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | 'label' => $this->fields[$sub_field['slug']]['name'], |
660 | 660 | 'params' => array( |
661 | 661 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
662 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
662 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
663 | 663 | 'field_value' => $current_values[$this->slug][$sub_field['slug']], |
664 | 664 | 'download_image' => null, |
665 | 665 | 'field_key' => $sub_field['slug'], |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | ) |
669 | 669 | ); |
670 | 670 | |
671 | - if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) { |
|
671 | + if (array_key_exists('download_image', $current_values[$this->slug]) && array_key_exists($sub_field['slug'], $current_values[$this->slug]['download_image'])) { |
|
672 | 672 | $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']]; |
673 | 673 | } |
674 | 674 | break; |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | 'label' => $this->fields[$sub_field['slug']]['name'], |
679 | 679 | 'params' => array( |
680 | 680 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
681 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
681 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
682 | 682 | 'field_value' => $current_values[$this->slug][$sub_field['slug']], |
683 | 683 | 'download_image' => null, |
684 | 684 | 'field_key' => $sub_field['slug'], |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | ) |
688 | 688 | ); |
689 | 689 | |
690 | - if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) { |
|
690 | + if (array_key_exists('download_image', $current_values[$this->slug]) && array_key_exists($sub_field['slug'], $current_values[$this->slug]['download_image'])) { |
|
691 | 691 | $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']]; |
692 | 692 | } |
693 | 693 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'label' => $this->fields[$sub_field['slug']]['name'], |
699 | 699 | 'params' => array( |
700 | 700 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
701 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
701 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
702 | 702 | 'field_value' => $current_values[$this->slug][$sub_field['slug']], |
703 | 703 | 'enum_values' => $this->fields[$sub_field['slug']]['enum_values'], |
704 | 704 | 'mapping' => true, |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | 'label' => $this->fields[$sub_field['slug']]['name'], |
718 | 718 | 'params' => array( |
719 | 719 | 'tooltip' => $this->fields[$sub_field['slug']]['tooltip'], |
720 | - 'field_name' => $this->slug."[".$sub_field['slug']."]", |
|
720 | + 'field_name' => $this->slug . "[" . $sub_field['slug'] . "]", |
|
721 | 721 | 'field_key' => $sub_field['slug'], |
722 | 722 | 'addon_prefix' => $this->slug, |
723 | 723 | 'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values), |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | * |
739 | 739 | * |
740 | 740 | */ |
741 | - function add_options( $main_field = false, $title = '', $fields = array() ){ |
|
741 | + function add_options($main_field = false, $title = '', $fields = array()) { |
|
742 | 742 | |
743 | - if ( ! empty($fields) ) |
|
743 | + if (!empty($fields)) |
|
744 | 744 | { |
745 | 745 | |
746 | - if ($main_field){ |
|
746 | + if ($main_field) { |
|
747 | 747 | |
748 | 748 | $main_field['is_main_field'] = true; |
749 | 749 | $fields[] = $main_field; |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | |
757 | 757 | } |
758 | 758 | |
759 | - function add_title($title = '', $tooltip = ''){ |
|
759 | + function add_title($title = '', $tooltip = '') { |
|
760 | 760 | |
761 | 761 | if (empty($title)) return; |
762 | 762 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | } |
766 | 766 | |
767 | - function add_text($text = '', $is_html = false){ |
|
767 | + function add_text($text = '', $is_html = false) { |
|
768 | 768 | |
769 | 769 | if (empty($text)) return; |
770 | 770 | |
@@ -862,10 +862,10 @@ discard block |
||
862 | 862 | margin: 45px 0 15px 0; |
863 | 863 | } |
864 | 864 | </style> |
865 | - <div class="wpallimport-collapsed wpallimport-section wpallimport-addon '.$this->slug.' closed"> |
|
865 | + <div class="wpallimport-collapsed wpallimport-section wpallimport-addon '.$this->slug . ' closed"> |
|
866 | 866 | <div class="wpallimport-content-section"> |
867 | 867 | <div class="wpallimport-collapsed-header"> |
868 | - <h3>'.__($name,'pmxi_plugin').'</h3> |
|
868 | + <h3>'.__($name, 'pmxi_plugin') . '</h3> |
|
869 | 869 | </div> |
870 | 870 | <div class="wpallimport-collapsed-content" style="padding: 0;"> |
871 | 871 | <div class="wpallimport-collapsed-content-inner"> |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * simply add an additional section for attachments |
892 | 892 | * |
893 | 893 | */ |
894 | - function import_files( $slug, $title, $callback = NULL ){ |
|
895 | - $this->import_images( $slug, $title, 'files', $callback); |
|
894 | + function import_files($slug, $title, $callback = NULL) { |
|
895 | + $this->import_images($slug, $title, 'files', $callback); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -900,9 +900,9 @@ discard block |
||
900 | 900 | * simply add an additional section |
901 | 901 | * |
902 | 902 | */ |
903 | - function import_images( $slug, $title, $type = 'images', $callback = NULL ){ |
|
903 | + function import_images($slug, $title, $type = 'images', $callback = NULL) { |
|
904 | 904 | |
905 | - if ( empty($title) or empty($slug) ) return; |
|
905 | + if (empty($title) or empty($slug)) return; |
|
906 | 906 | |
907 | 907 | if (is_array($slug)) { |
908 | 908 | $section_slug = 'pmxi_' . md5(serialize($slug)); |
@@ -920,17 +920,17 @@ discard block |
||
920 | 920 | $this->add_option($section_slug . $option_slug, $value); |
921 | 921 | } |
922 | 922 | |
923 | - if (count($this->image_sections) > 1){ |
|
923 | + if (count($this->image_sections) > 1) { |
|
924 | 924 | add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2); |
925 | 925 | } |
926 | 926 | |
927 | 927 | add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2); |
928 | 928 | |
929 | 929 | if ($callback && is_callable($callback)) { |
930 | - add_action( $section_slug, $callback, 10, 4); |
|
930 | + add_action($section_slug, $callback, 10, 4); |
|
931 | 931 | } else { |
932 | 932 | if (function_exists($slug)) { |
933 | - add_action( $section_slug, $slug, 10, 4); |
|
933 | + add_action($section_slug, $slug, 10, 4); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | } |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | * filter to allow import images for free edition of WP All Import |
940 | 940 | * |
941 | 941 | */ |
942 | - function is_allow_import_images($is_allow, $post_type){ |
|
942 | + function is_allow_import_images($is_allow, $post_type) { |
|
943 | 943 | return ($this->is_active_addon($post_type)) ? true : $is_allow; |
944 | 944 | } |
945 | 945 | |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | * filter to control additional images sections |
949 | 949 | * |
950 | 950 | */ |
951 | - function additional_sections($sections){ |
|
952 | - if ( ! empty($this->image_sections) ){ |
|
951 | + function additional_sections($sections) { |
|
952 | + if (!empty($this->image_sections)) { |
|
953 | 953 | foreach ($this->image_sections as $add_section) { |
954 | 954 | $sections[] = $add_section; |
955 | 955 | } |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * remove the 'Don't touch existing images, append new images' when more than one image section is in use. |
963 | 963 | * |
964 | 964 | */ |
965 | - function filter_is_show_add_new_images($is_show, $post_type){ |
|
965 | + function filter_is_show_add_new_images($is_show, $post_type) { |
|
966 | 966 | return ($this->is_active_addon($post_type)) ? false : $is_show; |
967 | 967 | } |
968 | 968 | |
@@ -971,12 +971,12 @@ discard block |
||
971 | 971 | * disable the default images section |
972 | 972 | * |
973 | 973 | */ |
974 | - function disable_default_images($post_type = false){ |
|
974 | + function disable_default_images($post_type = false) { |
|
975 | 975 | |
976 | 976 | add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2); |
977 | 977 | |
978 | 978 | } |
979 | - function is_enable_default_images_section($is_enabled, $post_type){ |
|
979 | + function is_enable_default_images_section($is_enabled, $post_type) { |
|
980 | 980 | |
981 | 981 | return ($this->is_active_addon($post_type)) ? false : true; |
982 | 982 | |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | |
989 | 989 | $data = array(); // parsed data |
990 | 990 | |
991 | - if ( ! empty($import->options[$this->slug])){ |
|
991 | + if (!empty($import->options[$this->slug])) { |
|
992 | 992 | |
993 | 993 | $this->logger = $parsingData['logger']; |
994 | 994 | |
@@ -997,9 +997,9 @@ discard block |
||
997 | 997 | $tmp_files = array(); |
998 | 998 | |
999 | 999 | foreach ($options[$this->slug] as $option_name => $option_value) { |
1000 | - if ( isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') { |
|
1000 | + if (isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') { |
|
1001 | 1001 | if ($import->options[$this->slug][$option_name] == "xpath") { |
1002 | - if ($import->options[$this->slug]['xpaths'][$option_name] == ""){ |
|
1002 | + if ($import->options[$this->slug]['xpaths'][$option_name] == "") { |
|
1003 | 1003 | $count and $data[$option_name] = array_fill(0, $count, ""); |
1004 | 1004 | } else { |
1005 | 1005 | $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse(); |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | if ($import_options['update_all_data'] == 'yes') return true; |
1040 | 1040 | |
1041 | - if ( ! $import_options['is_update_custom_fields'] ) return false; |
|
1041 | + if (!$import_options['is_update_custom_fields']) return false; |
|
1042 | 1042 | |
1043 | 1043 | if ($import_options['update_custom_fields_logic'] == "full_update") return true; |
1044 | - if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']) ) return true; |
|
1045 | - if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) )) return true; |
|
1044 | + if ($import_options['update_custom_fields_logic'] == "only" and !empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list'])) return true; |
|
1045 | + if ($import_options['update_custom_fields_logic'] == "all_except" and (empty($import_options['custom_fields_list']) or !in_array($meta_key, $import_options['custom_fields_list']))) return true; |
|
1046 | 1046 | |
1047 | 1047 | return false; |
1048 | 1048 | |
@@ -1058,11 +1058,11 @@ discard block |
||
1058 | 1058 | |
1059 | 1059 | if ($import_options['update_all_data'] == 'yes') return true; |
1060 | 1060 | |
1061 | - if ( ! $import_options['is_update_categories'] ) return false; |
|
1061 | + if (!$import_options['is_update_categories']) return false; |
|
1062 | 1062 | |
1063 | 1063 | if ($import_options['update_categories_logic'] == "full_update") return true; |
1064 | - if ($import_options['update_categories_logic'] == "only" and ! empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list']) ) return true; |
|
1065 | - if ($import_options['update_categories_logic'] == "all_except" and ( empty($import_options['taxonomies_list']) or ! in_array($tax_name, $import_options['taxonomies_list']) )) return true; |
|
1064 | + if ($import_options['update_categories_logic'] == "only" and !empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list'])) return true; |
|
1065 | + if ($import_options['update_categories_logic'] == "all_except" and (empty($import_options['taxonomies_list']) or !in_array($tax_name, $import_options['taxonomies_list']))) return true; |
|
1066 | 1066 | |
1067 | 1067 | return false; |
1068 | 1068 | |
@@ -1083,8 +1083,8 @@ discard block |
||
1083 | 1083 | |
1084 | 1084 | |
1085 | 1085 | function admin_notice_ignore() { |
1086 | - if (isset($_GET[$this->slug.'_ignore']) && '0' == $_GET[$this->slug.'_ignore'] ) { |
|
1087 | - update_option($this->slug.'_ignore', 'true'); |
|
1086 | + if (isset($_GET[$this->slug . '_ignore']) && '0' == $_GET[$this->slug . '_ignore']) { |
|
1087 | + update_option($this->slug . '_ignore', 'true'); |
|
1088 | 1088 | } |
1089 | 1089 | } |
1090 | 1090 | |
@@ -1094,10 +1094,10 @@ discard block |
||
1094 | 1094 | if ($this->notice_text) { |
1095 | 1095 | $notice_text = $this->notice_text; |
1096 | 1096 | } else { |
1097 | - $notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.'; |
|
1097 | + $notice_text = $this->name . ' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.'; |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | - if (!get_option(sanitize_key($this->slug).'_notice_ignore')) { |
|
1100 | + if (!get_option(sanitize_key($this->slug) . '_notice_ignore')) { |
|
1101 | 1101 | |
1102 | 1102 | ?> |
1103 | 1103 | |
@@ -1105,9 +1105,9 @@ discard block |
||
1105 | 1105 | <p><?php _e( |
1106 | 1106 | sprintf( |
1107 | 1107 | $notice_text, |
1108 | - '?'.$this->slug.'_ignore=0' |
|
1108 | + '?' . $this->slug . '_ignore=0' |
|
1109 | 1109 | ), |
1110 | - 'rapid_addon_'.$this->slug |
|
1110 | + 'rapid_addon_' . $this->slug |
|
1111 | 1111 | ); ?></p> |
1112 | 1112 | </div> |
1113 | 1113 | |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | $is_show_notice = false; |
1128 | 1128 | |
1129 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
1129 | + include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
1130 | 1130 | |
1131 | - if ( ! class_exists( 'PMXI_Plugin' ) ) { |
|
1131 | + if (!class_exists('PMXI_Plugin')) { |
|
1132 | 1132 | $is_show_notice = true; |
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | // Supported Themes |
1136 | - if ( ! $is_show_notice and ! empty($conditions['themes']) ){ |
|
1136 | + if (!$is_show_notice and !empty($conditions['themes'])) { |
|
1137 | 1137 | |
1138 | 1138 | $themeInfo = wp_get_theme(); |
1139 | 1139 | $parentInfo = $themeInfo->parent(); |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | $is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true; |
1143 | 1143 | |
1144 | - if ( $is_show_notice and $parentInfo ){ |
|
1144 | + if ($is_show_notice and $parentInfo) { |
|
1145 | 1145 | $parent_theme = $parentInfo->get('Name'); |
1146 | 1146 | $is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true; |
1147 | 1147 | } |
@@ -1149,22 +1149,22 @@ discard block |
||
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | // Required Plugins |
1152 | - if ( ! $is_show_notice and ! empty($conditions['plugins']) ){ |
|
1152 | + if (!$is_show_notice and !empty($conditions['plugins'])) { |
|
1153 | 1153 | |
1154 | 1154 | $requires_counter = 0; |
1155 | 1155 | foreach ($conditions['plugins'] as $plugin) { |
1156 | - if ( is_plugin_active($plugin) ) $requires_counter++; |
|
1156 | + if (is_plugin_active($plugin)) $requires_counter++; |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | - if ($requires_counter != count($conditions['plugins'])){ |
|
1159 | + if ($requires_counter != count($conditions['plugins'])) { |
|
1160 | 1160 | $is_show_notice = true; |
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | } |
1164 | 1164 | |
1165 | - if ( $is_show_notice ){ |
|
1165 | + if ($is_show_notice) { |
|
1166 | 1166 | |
1167 | - if ( $notice_text != '' ) { |
|
1167 | + if ($notice_text != '') { |
|
1168 | 1168 | $this->notice_text = $notice_text; |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1173,34 +1173,34 @@ discard block |
||
1173 | 1173 | |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - function log( $m = false){ |
|
1176 | + function log($m = false) { |
|
1177 | 1177 | |
1178 | 1178 | $m and $this->logger and call_user_func($this->logger, $m); |
1179 | 1179 | |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - public function remove_post_type( $type = '' ) { |
|
1183 | - if ( ! empty( $type ) ) { |
|
1184 | - $this->add_option( 'post_types_to_remove', $type ); |
|
1182 | + public function remove_post_type($type = '') { |
|
1183 | + if (!empty($type)) { |
|
1184 | + $this->add_option('post_types_to_remove', $type); |
|
1185 | 1185 | } |
1186 | 1186 | } |
1187 | 1187 | |
1188 | - public function filter_post_types( $custom_types = array(), $custom_type = '' ) { |
|
1188 | + public function filter_post_types($custom_types = array(), $custom_type = '') { |
|
1189 | 1189 | $options = $this->options_array(); |
1190 | 1190 | $option_key = 'post_types_to_remove'; |
1191 | 1191 | |
1192 | - if ( array_key_exists( $option_key, $options ) ) { |
|
1193 | - $type = $options[ $option_key ]; |
|
1192 | + if (array_key_exists($option_key, $options)) { |
|
1193 | + $type = $options[$option_key]; |
|
1194 | 1194 | |
1195 | - if ( ! empty( $type ) ) { |
|
1196 | - if ( ! is_array( $type ) ) { |
|
1197 | - if ( array_key_exists( $type, $custom_types ) ) { |
|
1198 | - unset( $custom_types[ $type ] ); |
|
1195 | + if (!empty($type)) { |
|
1196 | + if (!is_array($type)) { |
|
1197 | + if (array_key_exists($type, $custom_types)) { |
|
1198 | + unset($custom_types[$type]); |
|
1199 | 1199 | } |
1200 | 1200 | } else { |
1201 | - foreach ( $type as $key => $post_type ) { |
|
1202 | - if ( array_key_exists( $post_type, $custom_types ) ) { |
|
1203 | - unset( $custom_types[ $post_type ] ); |
|
1201 | + foreach ($type as $key => $post_type) { |
|
1202 | + if (array_key_exists($post_type, $custom_types)) { |
|
1203 | + unset($custom_types[$post_type]); |
|
1204 | 1204 | } |
1205 | 1205 | } |
1206 | 1206 | } |
@@ -1209,26 +1209,26 @@ discard block |
||
1209 | 1209 | return $custom_types; |
1210 | 1210 | } |
1211 | 1211 | |
1212 | - public function sort_post_types( array $order ) { |
|
1212 | + public function sort_post_types(array $order) { |
|
1213 | 1213 | $options = $this->options_array(); |
1214 | 1214 | $option_key = 'post_type_move'; |
1215 | 1215 | |
1216 | - if ( array_key_exists( $option_key, $options ) ) { |
|
1217 | - $move_rules = maybe_unserialize( $options[ $option_key ] ); |
|
1216 | + if (array_key_exists($option_key, $options)) { |
|
1217 | + $move_rules = maybe_unserialize($options[$option_key]); |
|
1218 | 1218 | |
1219 | - foreach ( $move_rules as $rule ) { |
|
1219 | + foreach ($move_rules as $rule) { |
|
1220 | 1220 | $move_this = $rule['move_this']; |
1221 | 1221 | $move_to = $rule['move_to']; |
1222 | - if ( $move_to > count( $order ) ) { |
|
1223 | - if ( ( $rm_key = array_search( $move_this, $order ) ) !== false ) { |
|
1224 | - unset( $order[ $rm_key ] ); |
|
1222 | + if ($move_to > count($order)) { |
|
1223 | + if (($rm_key = array_search($move_this, $order)) !== false) { |
|
1224 | + unset($order[$rm_key]); |
|
1225 | 1225 | } |
1226 | - array_push( $order, $move_this ); |
|
1226 | + array_push($order, $move_this); |
|
1227 | 1227 | } else { |
1228 | - if ( ( $rm_key = array_search( $move_this, $order ) ) !== false ) { |
|
1229 | - unset( $order[ $rm_key ] ); |
|
1228 | + if (($rm_key = array_search($move_this, $order)) !== false) { |
|
1229 | + unset($order[$rm_key]); |
|
1230 | 1230 | } |
1231 | - array_splice( $order, $move_to, 0, $move_this ); |
|
1231 | + array_splice($order, $move_to, 0, $move_this); |
|
1232 | 1232 | } |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1238,57 +1238,57 @@ discard block |
||
1238 | 1238 | return $order; |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - public function move_post_type( $move_this = null, $move_to = null ) { |
|
1241 | + public function move_post_type($move_this = null, $move_to = null) { |
|
1242 | 1242 | $move_rules = array(); |
1243 | 1243 | |
1244 | - if ( ! is_array( $move_this ) && ! is_array( $move_to ) ) { |
|
1244 | + if (!is_array($move_this) && !is_array($move_to)) { |
|
1245 | 1245 | $move_rules[] = array( |
1246 | 1246 | 'move_this' => $move_this, |
1247 | 1247 | 'move_to' => $move_to |
1248 | 1248 | ); |
1249 | 1249 | } else { |
1250 | - foreach ( $move_this as $key => $move_post ) { |
|
1250 | + foreach ($move_this as $key => $move_post) { |
|
1251 | 1251 | $move_rules[] = array( |
1252 | 1252 | 'move_this' => $move_post, |
1253 | - 'move_to' => $move_to[ $key ] |
|
1253 | + 'move_to' => $move_to[$key] |
|
1254 | 1254 | ); |
1255 | 1255 | } |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - $this->add_option( 'post_type_move', $move_rules ); |
|
1258 | + $this->add_option('post_type_move', $move_rules); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | - public function set_post_type_image( $post_type = null, $image = null ) { |
|
1261 | + public function set_post_type_image($post_type = null, $image = null) { |
|
1262 | 1262 | $post_type_image_rules = array(); |
1263 | 1263 | |
1264 | - if ( ! is_array( $post_type ) ) { |
|
1264 | + if (!is_array($post_type)) { |
|
1265 | 1265 | |
1266 | - $post_type_image_rules[ $post_type ] = array( |
|
1266 | + $post_type_image_rules[$post_type] = array( |
|
1267 | 1267 | 'post_type' => $post_type, |
1268 | 1268 | 'image' => $image |
1269 | 1269 | ); |
1270 | 1270 | |
1271 | 1271 | } else { |
1272 | 1272 | |
1273 | - if ( count( $post_type ) == count( $image ) ) { |
|
1273 | + if (count($post_type) == count($image)) { |
|
1274 | 1274 | |
1275 | - foreach ( $post_type as $key => $post_name ) { |
|
1276 | - $post_type_image_rules[ $post_name ] = array( |
|
1275 | + foreach ($post_type as $key => $post_name) { |
|
1276 | + $post_type_image_rules[$post_name] = array( |
|
1277 | 1277 | 'post_type' => $post_name, |
1278 | - 'image' => $image[ $key ] |
|
1278 | + 'image' => $image[$key] |
|
1279 | 1279 | ); |
1280 | 1280 | } |
1281 | 1281 | } |
1282 | 1282 | } |
1283 | 1283 | |
1284 | - $this->add_option( 'post_type_image', $post_type_image_rules ); |
|
1284 | + $this->add_option('post_type_image', $post_type_image_rules); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | - public function post_type_image( $image ) { |
|
1287 | + public function post_type_image($image) { |
|
1288 | 1288 | $options = $this->options_array(); |
1289 | 1289 | $option_key = 'post_type_image'; |
1290 | - if ( array_key_exists( $option_key, $options ) ) { |
|
1291 | - $post_type_image_rules = maybe_unserialize( $options[ $option_key ] ); |
|
1290 | + if (array_key_exists($option_key, $options)) { |
|
1291 | + $post_type_image_rules = maybe_unserialize($options[$option_key]); |
|
1292 | 1292 | return $post_type_image_rules; |
1293 | 1293 | } |
1294 | 1294 | return $image; |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | * @package GetPaid |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | -include plugin_dir_path( __FILE__ ) . 'rapid-addon.php'; |
|
10 | +include plugin_dir_path(__FILE__) . 'rapid-addon.php'; |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * WP All Import class. |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | public function __construct() { |
35 | 35 | |
36 | 36 | // Init each store separately. |
37 | - foreach ( array_keys( $this->datastores ) as $key ) { |
|
38 | - $this->init_store( $key ); |
|
37 | + foreach (array_keys($this->datastores) as $key) { |
|
38 | + $this->init_store($key); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | } |
@@ -43,51 +43,51 @@ discard block |
||
43 | 43 | /** |
44 | 44 | * Inits a store. |
45 | 45 | */ |
46 | - public function init_store( $key ) { |
|
46 | + public function init_store($key) { |
|
47 | 47 | |
48 | 48 | // Register the add-on. |
49 | - $this->add_ons[ $key ] = new RapidAddon( 'GetPaid', 'getpaid_wp_al_import_' . $key ); |
|
49 | + $this->add_ons[$key] = new RapidAddon('GetPaid', 'getpaid_wp_al_import_' . $key); |
|
50 | 50 | |
51 | 51 | // Create import function. |
52 | - $import_function = function ( $post_id, $data, $import_options, $_post ) use ( $key ) { |
|
53 | - $this->import_store( $key, $post_id, $data, $import_options, $_post ); |
|
52 | + $import_function = function($post_id, $data, $import_options, $_post) use ($key) { |
|
53 | + $this->import_store($key, $post_id, $data, $import_options, $_post); |
|
54 | 54 | }; |
55 | 55 | |
56 | - $this->add_ons[ $key ]->set_import_function( $import_function ); |
|
56 | + $this->add_ons[$key]->set_import_function($import_function); |
|
57 | 57 | |
58 | 58 | // Register store fields. |
59 | - $this->add_store_fields( $key ); |
|
59 | + $this->add_store_fields($key); |
|
60 | 60 | |
61 | 61 | // Only load on the correct post type. |
62 | - $this->add_ons[ $key ]->run( array( 'post_types' => array( 'wpi_' . $key ) ) ); |
|
62 | + $this->add_ons[$key]->run(array('post_types' => array('wpi_' . $key))); |
|
63 | 63 | |
64 | 64 | // Disable images. |
65 | - $this->add_ons[ $key ]->disable_default_images(); |
|
65 | + $this->add_ons[$key]->disable_default_images(); |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Retrieves store fields. |
71 | 71 | */ |
72 | - public function get_store_fields( $key ) { |
|
72 | + public function get_store_fields($key) { |
|
73 | 73 | |
74 | 74 | // Fetch from data/invoice-schema.php, from data/discount-schema.php, from data/item-schema.php |
75 | - $fields = wpinv_get_data( $key . '-schema' ); |
|
75 | + $fields = wpinv_get_data($key . '-schema'); |
|
76 | 76 | |
77 | - if ( empty( $fields ) ) { |
|
77 | + if (empty($fields)) { |
|
78 | 78 | return array(); |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Clean the fields. |
82 | 82 | $prepared = array(); |
83 | - foreach ( $fields as $id => $field ) { |
|
83 | + foreach ($fields as $id => $field) { |
|
84 | 84 | |
85 | 85 | // Skip read only fields. |
86 | - if ( ! empty( $field['readonly'] ) ) { |
|
86 | + if (!empty($field['readonly'])) { |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | |
90 | - $prepared[ $id ] = $field; |
|
90 | + $prepared[$id] = $field; |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Registers store fields. |
100 | 100 | */ |
101 | - public function add_store_fields( $key ) { |
|
101 | + public function add_store_fields($key) { |
|
102 | 102 | |
103 | - foreach ( $this->get_store_fields( $key ) as $field_id => $data ) { |
|
104 | - $this->add_ons[ $key ]->add_field( $field_id, $data['description'], 'text' ); |
|
103 | + foreach ($this->get_store_fields($key) as $field_id => $data) { |
|
104 | + $this->add_ons[$key]->add_field($field_id, $data['description'], 'text'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -109,36 +109,36 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Handles store imports. |
111 | 111 | */ |
112 | - public function import_store( $key, $post_id, $data, $import_options, $_post ) { |
|
112 | + public function import_store($key, $post_id, $data, $import_options, $_post) { |
|
113 | 113 | |
114 | 114 | // Is the store class set? |
115 | - if ( ! isset( $this->datastores[ $key ] ) ) { |
|
115 | + if (!isset($this->datastores[$key])) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | 119 | /**@var GetPaid_Data */ |
120 | - $data_store = new $this->datastores[ $key ]( $post_id ); |
|
120 | + $data_store = new $this->datastores[$key]($post_id); |
|
121 | 121 | |
122 | 122 | // Abort if the invoice/item/discount does not exist. |
123 | - if ( ! $data_store->exists() ) { |
|
123 | + if (!$data_store->exists()) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Prepare data props. |
128 | 128 | $prepared = array(); |
129 | 129 | |
130 | - foreach ( array_keys( $this->get_store_fields( $key ) ) as $field ) { |
|
130 | + foreach (array_keys($this->get_store_fields($key)) as $field) { |
|
131 | 131 | // Make sure the user has allowed this field to be updated. |
132 | - if ( empty( $_post['ID'] ) || $this->add_ons[ $key ]->can_update_meta( $field, $import_options ) ) { |
|
132 | + if (empty($_post['ID']) || $this->add_ons[$key]->can_update_meta($field, $import_options)) { |
|
133 | 133 | |
134 | 134 | // Update the custom field with the imported data. |
135 | - $prepared[ $field ] = $data[ $field ]; |
|
135 | + $prepared[$field] = $data[$field]; |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Only update if we have something to update. |
140 | - if ( ! empty( $prepared ) ) { |
|
141 | - $data_store->set_props( $prepared ); |
|
140 | + if (!empty($prepared)) { |
|
141 | + $data_store->set_props($prepared); |
|
142 | 142 | $data_store->save(); |
143 | 143 | } |
144 | 144 |