@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 2.0.2 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * The main installer/updater class. |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param string $upgrade_from The current invoicing version. |
27 | 27 | */ |
28 | - public function upgrade_db( $upgrade_from ) { |
|
28 | + public function upgrade_db($upgrade_from) { |
|
29 | 29 | |
30 | 30 | // Save the current invoicing version. |
31 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
31 | + update_option('wpinv_version', WPINV_VERSION); |
|
32 | 32 | |
33 | 33 | // Setup the invoice Custom Post Type. |
34 | 34 | GetPaid_Post_Types::register_post_types(); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | // Create any missing database tables. |
49 | 49 | $method = "upgrade_from_$upgrade_from"; |
50 | 50 | |
51 | - if ( method_exists( $this, $method ) ) { |
|
51 | + if (method_exists($this, $method)) { |
|
52 | 52 | $this->$method(); |
53 | 53 | } |
54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->create_invoice_items_table(); |
65 | 65 | |
66 | 66 | // Save default tax rates. |
67 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
67 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -75,28 +75,28 @@ discard block |
||
75 | 75 | global $wpdb; |
76 | 76 | |
77 | 77 | // Invoices. |
78 | - $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
79 | - if ( ! empty( $results ) ) { |
|
80 | - $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
78 | + $results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
79 | + if (!empty($results)) { |
|
80 | + $wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
81 | 81 | |
82 | 82 | // Clean post cache |
83 | - foreach ( $results as $row ) { |
|
84 | - clean_post_cache( $row->ID ); |
|
83 | + foreach ($results as $row) { |
|
84 | + clean_post_cache($row->ID); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
88 | 88 | |
89 | 89 | // Item meta key changes |
90 | 90 | $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
91 | - $results = $wpdb->get_results( $query ); |
|
91 | + $results = $wpdb->get_results($query); |
|
92 | 92 | |
93 | - if ( ! empty( $results ) ) { |
|
94 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
95 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
96 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
93 | + if (!empty($results)) { |
|
94 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
95 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
96 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
97 | 97 | |
98 | - foreach ( $results as $row ) { |
|
99 | - clean_post_cache( $row->post_id ); |
|
98 | + foreach ($results as $row) { |
|
99 | + clean_post_cache($row->post_id); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function upgrade_from_207() { |
131 | 131 | global $wpdb; |
132 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
132 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);"); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | */ |
139 | 139 | public function add_capabilities() { |
140 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
140 | + $GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | |
153 | 153 | // Checkout page. |
154 | 154 | 'checkout_page' => array( |
155 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
156 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
155 | + 'name' => _x('gp-checkout', 'Page slug', 'invoicing'), |
|
156 | + 'title' => _x('Checkout', 'Page title', 'invoicing'), |
|
157 | 157 | 'content' => ' |
158 | 158 | <!-- wp:shortcode --> |
159 | 159 | [wpinv_checkout] |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | |
165 | 165 | // Invoice history page. |
166 | 166 | 'invoice_history_page' => array( |
167 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
168 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
167 | + 'name' => _x('gp-invoices', 'Page slug', 'invoicing'), |
|
168 | + 'title' => _x('My Invoices', 'Page title', 'invoicing'), |
|
169 | 169 | 'content' => ' |
170 | 170 | <!-- wp:shortcode --> |
171 | 171 | [wpinv_history] |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | // Success page content. |
178 | 178 | 'success_page' => array( |
179 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
180 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
179 | + 'name' => _x('gp-receipt', 'Page slug', 'invoicing'), |
|
180 | + 'title' => _x('Payment Confirmation', 'Page title', 'invoicing'), |
|
181 | 181 | 'content' => ' |
182 | 182 | <!-- wp:shortcode --> |
183 | 183 | [wpinv_receipt] |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | |
189 | 189 | // Failure page content. |
190 | 190 | 'failure_page' => array( |
191 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
192 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
193 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
191 | + 'name' => _x('gp-transaction-failed', 'Page slug', 'invoicing'), |
|
192 | + 'title' => _x('Transaction Failed', 'Page title', 'invoicing'), |
|
193 | + 'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
194 | 194 | 'parent' => 'gp-checkout', |
195 | 195 | ), |
196 | 196 | |
197 | 197 | // Subscriptions history page. |
198 | 198 | 'invoice_subscription_page' => array( |
199 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
200 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
199 | + 'name' => _x('gp-subscriptions', 'Page slug', 'invoicing'), |
|
200 | + 'title' => _x('My Subscriptions', 'Page title', 'invoicing'), |
|
201 | 201 | 'content' => ' |
202 | 202 | <!-- wp:shortcode --> |
203 | 203 | [wpinv_subscriptions] |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | ) |
210 | 210 | ); |
211 | 211 | |
212 | - foreach ( $pages as $key => $page ) { |
|
213 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
212 | + foreach ($pages as $key => $page) { |
|
213 | + wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | global $wpdb; |
225 | 225 | |
226 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
226 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
227 | 227 | |
228 | 228 | // Create tables. |
229 | 229 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | KEY customer_and_status (customer_id, status) |
251 | 251 | ) $charset_collate;"; |
252 | 252 | |
253 | - dbDelta( $sql ); |
|
253 | + dbDelta($sql); |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | public function create_invoices_table() { |
262 | 262 | global $wpdb; |
263 | 263 | |
264 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
264 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
265 | 265 | |
266 | 266 | // Create tables. |
267 | 267 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | KEY `key` (`key`) |
302 | 302 | ) $charset_collate;"; |
303 | 303 | |
304 | - dbDelta( $sql ); |
|
304 | + dbDelta($sql); |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | public function create_invoice_items_table() { |
313 | 313 | global $wpdb; |
314 | 314 | |
315 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
315 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
316 | 316 | |
317 | 317 | // Create tables. |
318 | 318 | $charset_collate = $wpdb->get_charset_collate(); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | KEY post_id (post_id) |
339 | 339 | ) $charset_collate;"; |
340 | 340 | |
341 | - dbDelta( $sql ); |
|
341 | + dbDelta($sql); |
|
342 | 342 | |
343 | 343 | } |
344 | 344 | |
@@ -351,40 +351,40 @@ discard block |
||
351 | 351 | |
352 | 352 | $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
353 | 353 | $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
354 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
354 | + $migrated = $wpdb->get_col("SELECT post_id FROM $invoices_table"); |
|
355 | 355 | $invoices = array_unique( |
356 | 356 | get_posts( |
357 | 357 | array( |
358 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
358 | + 'post_type' => array('wpi_invoice', 'wpi_quote'), |
|
359 | 359 | 'posts_per_page' => -1, |
360 | 360 | 'fields' => 'ids', |
361 | - 'post_status' => array_keys( get_post_stati() ), |
|
361 | + 'post_status' => array_keys(get_post_stati()), |
|
362 | 362 | 'exclude' => (array) $migrated, |
363 | 363 | ) |
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | 367 | // Abort if we do not have any invoices. |
368 | - if ( empty( $invoices ) ) { |
|
368 | + if (empty($invoices)) { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' ); |
|
372 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php'); |
|
373 | 373 | |
374 | 374 | $invoice_rows = array(); |
375 | - foreach ( $invoices as $invoice ) { |
|
375 | + foreach ($invoices as $invoice) { |
|
376 | 376 | |
377 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
377 | + $invoice = new WPInv_Legacy_Invoice($invoice); |
|
378 | 378 | |
379 | - if ( empty( $invoice->ID ) ) { |
|
379 | + if (empty($invoice->ID)) { |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
383 | - $fields = array ( |
|
383 | + $fields = array( |
|
384 | 384 | 'post_id' => $invoice->ID, |
385 | 385 | 'number' => $invoice->get_number(), |
386 | 386 | 'key' => $invoice->get_key(), |
387 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
387 | + 'type' => str_replace('wpi_', '', $invoice->post_type), |
|
388 | 388 | 'mode' => $invoice->mode, |
389 | 389 | 'user_ip' => $invoice->get_ip(), |
390 | 390 | 'first_name' => $invoice->get_first_name(), |
@@ -413,27 +413,27 @@ discard block |
||
413 | 413 | 'custom_meta' => $invoice->payment_meta |
414 | 414 | ); |
415 | 415 | |
416 | - foreach ( $fields as $key => $val ) { |
|
417 | - if ( is_null( $val ) ) { |
|
416 | + foreach ($fields as $key => $val) { |
|
417 | + if (is_null($val)) { |
|
418 | 418 | $val = ''; |
419 | 419 | } |
420 | - $val = maybe_serialize( $val ); |
|
421 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
420 | + $val = maybe_serialize($val); |
|
421 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
422 | 422 | } |
423 | 423 | |
424 | - $fields = implode( ', ', $fields ); |
|
424 | + $fields = implode(', ', $fields); |
|
425 | 425 | $invoice_rows[] = "($fields)"; |
426 | 426 | |
427 | 427 | $item_rows = array(); |
428 | 428 | $item_columns = array(); |
429 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
429 | + foreach ($invoice->get_cart_details() as $details) { |
|
430 | 430 | $fields = array( |
431 | 431 | 'post_id' => $invoice->ID, |
432 | 432 | 'item_id' => $details['id'], |
433 | 433 | 'item_name' => $details['name'], |
434 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
434 | + 'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'], |
|
435 | 435 | 'vat_rate' => $details['vat_rate'], |
436 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
436 | + 'vat_class' => empty($details['vat_class']) ? '_standard' : $details['vat_class'], |
|
437 | 437 | 'tax' => $details['tax'], |
438 | 438 | 'item_price' => $details['item_price'], |
439 | 439 | 'custom_price' => $details['custom_price'], |
@@ -445,31 +445,31 @@ discard block |
||
445 | 445 | 'fees' => $details['fees'], |
446 | 446 | ); |
447 | 447 | |
448 | - $item_columns = array_keys ( $fields ); |
|
448 | + $item_columns = array_keys($fields); |
|
449 | 449 | |
450 | - foreach ( $fields as $key => $val ) { |
|
451 | - if ( is_null( $val ) ) { |
|
450 | + foreach ($fields as $key => $val) { |
|
451 | + if (is_null($val)) { |
|
452 | 452 | $val = ''; |
453 | 453 | } |
454 | - $val = maybe_serialize( $val ); |
|
455 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
454 | + $val = maybe_serialize($val); |
|
455 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
456 | 456 | } |
457 | 457 | |
458 | - $fields = implode( ', ', $fields ); |
|
458 | + $fields = implode(', ', $fields); |
|
459 | 459 | $item_rows[] = "($fields)"; |
460 | 460 | } |
461 | 461 | |
462 | - $item_rows = implode( ', ', $item_rows ); |
|
463 | - $item_columns = implode( ', ', $item_columns ); |
|
464 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
462 | + $item_rows = implode(', ', $item_rows); |
|
463 | + $item_columns = implode(', ', $item_columns); |
|
464 | + $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows"); |
|
465 | 465 | } |
466 | 466 | |
467 | - if ( empty( $invoice_rows ) ) { |
|
467 | + if (empty($invoice_rows)) { |
|
468 | 468 | return; |
469 | 469 | } |
470 | 470 | |
471 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
472 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
471 | + $invoice_rows = implode(', ', $invoice_rows); |
|
472 | + $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows"); |
|
473 | 473 | |
474 | 474 | } |
475 | 475 | |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | public static function rename_gateways_label() { |
481 | 481 | global $wpdb; |
482 | 482 | |
483 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
483 | + foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) { |
|
484 | 484 | |
485 | 485 | $wpdb->update( |
486 | 486 | $wpdb->prefix . 'getpaid_invoices', |
487 | - array( 'gateway' => $gateway ), |
|
488 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
487 | + array('gateway' => $gateway), |
|
488 | + array('gateway' => wpinv_get_gateway_admin_label($gateway)), |
|
489 | 489 | '%s', |
490 | 490 | '%s' |
491 | 491 | ); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ; |
|
30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | ?> |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | |
47 | 47 | <div class="bsui" style="margin-top: 1.5rem"> |
48 | 48 | |
49 | - <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?> |
|
50 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
49 | + <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?> |
|
50 | + <?php if (!$invoice->is_draft()) : ?> |
|
51 | 51 | <div class="form-group"> |
52 | - <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong> |
|
53 | - <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?> |
|
52 | + <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
53 | + <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?> |
|
54 | 54 | </div> |
55 | 55 | <?php endif; ?> |
56 | 56 | |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | |
59 | 59 | // Date created. |
60 | 60 | $label = sprintf( |
61 | - __( '%s Date:', 'invoicing' ), |
|
62 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
61 | + __('%s Date:', 'invoicing'), |
|
62 | + ucfirst($invoice->get_invoice_quote_type()) |
|
63 | 63 | ); |
64 | 64 | |
65 | - $info = sprintf( |
|
66 | - __( 'The date this %s was created.', 'invoicing' ), |
|
67 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
65 | + $info = sprintf( |
|
66 | + __('The date this %s was created.', 'invoicing'), |
|
67 | + strtolower($invoice->get_invoice_quote_type()) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | echo aui()->input( |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | 'type' => 'datepicker', |
73 | 73 | 'id' => 'wpinv_date_created', |
74 | 74 | 'name' => 'date_created', |
75 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
75 | + 'label' => $label . getpaid_get_help_tip($info), |
|
76 | 76 | 'label_type' => 'vertical', |
77 | 77 | 'placeholder' => 'YYYY-MM-DD 00:00', |
78 | 78 | 'class' => 'form-control-sm', |
79 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
79 | + 'value' => $invoice->get_date_created('edit'), |
|
80 | 80 | 'extra_attributes' => array( |
81 | 81 | 'data-enable-time' => 'true', |
82 | 82 | 'data-time_24hr' => 'true', |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | ); |
88 | 88 | |
89 | 89 | // Date paid. |
90 | - $date_paid = $invoice->get_date_completed( 'edit' ); |
|
91 | - if ( ! empty( $date_paid ) && $invoice->is_paid() ) { |
|
90 | + $date_paid = $invoice->get_date_completed('edit'); |
|
91 | + if (!empty($date_paid) && $invoice->is_paid()) { |
|
92 | 92 | |
93 | 93 | echo aui()->input( |
94 | 94 | array( |
95 | 95 | 'type' => 'text', |
96 | 96 | 'id' => 'wpinv_date_completed', |
97 | 97 | 'name' => 'wpinv_date_completed', |
98 | - 'label' => __( 'Date Completed:', 'invoicing' ), |
|
98 | + 'label' => __('Date Completed:', 'invoicing'), |
|
99 | 99 | 'label_type' => 'vertical', |
100 | 100 | 'class' => 'form-control-sm', |
101 | 101 | 'value' => $date_paid, |
@@ -109,18 +109,18 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | // Due date. |
112 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( ! $invoice->is_paid() || $invoice->is_draft() ) ) { |
|
112 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && (!$invoice->is_paid() || $invoice->is_draft())) { |
|
113 | 113 | |
114 | 114 | echo aui()->input( |
115 | 115 | array( |
116 | 116 | 'type' => 'datepicker', |
117 | 117 | 'id' => 'wpinv_due_date', |
118 | 118 | 'name' => 'wpinv_due_date', |
119 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
119 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
120 | 120 | 'label_type' => 'vertical', |
121 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
121 | + 'placeholder' => __('No due date', 'invoicing'), |
|
122 | 122 | 'class' => 'form-control-sm', |
123 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
123 | + 'value' => $invoice->get_due_date('edit'), |
|
124 | 124 | 'extra_attributes' => array( |
125 | 125 | 'data-enable-time' => 'true', |
126 | 126 | 'data-time_24hr' => 'true', |
@@ -132,39 +132,39 @@ discard block |
||
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
136 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
135 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
136 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
137 | 137 | |
138 | 138 | // Status. |
139 | 139 | $label = sprintf( |
140 | - __( '%s Status:', 'invoicing' ), |
|
141 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
140 | + __('%s Status:', 'invoicing'), |
|
141 | + ucfirst($invoice->get_invoice_quote_type()) |
|
142 | 142 | ); |
143 | 143 | |
144 | - $status = $invoice->get_status( 'edit' ); |
|
144 | + $status = $invoice->get_status('edit'); |
|
145 | 145 | echo aui()->select( |
146 | 146 | array( |
147 | 147 | 'id' => 'wpinv_status', |
148 | 148 | 'name' => 'wpinv_status', |
149 | 149 | 'label' => $label, |
150 | 150 | 'label_type' => 'vertical', |
151 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
152 | - 'value' => array_key_exists( $status, $invoice->get_all_statuses() ) ? $status : $invoice->get_default_status(), |
|
151 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
152 | + 'value' => array_key_exists($status, $invoice->get_all_statuses()) ? $status : $invoice->get_default_status(), |
|
153 | 153 | 'select2' => true, |
154 | 154 | 'data-allow-clear' => 'false', |
155 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ) |
|
155 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice) |
|
156 | 156 | ) |
157 | 157 | ); |
158 | 158 | |
159 | 159 | // Invoice number. |
160 | 160 | $label = sprintf( |
161 | - __( '%s Number:', 'invoicing' ), |
|
162 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
161 | + __('%s Number:', 'invoicing'), |
|
162 | + ucfirst($invoice->get_invoice_quote_type()) |
|
163 | 163 | ); |
164 | 164 | |
165 | - $info = sprintf( |
|
166 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
167 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
165 | + $info = sprintf( |
|
166 | + __('Each %s number must be unique.', 'invoicing'), |
|
167 | + strtolower($invoice->get_invoice_quote_type()) |
|
168 | 168 | ); |
169 | 169 | |
170 | 170 | echo aui()->input( |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | 'type' => 'text', |
173 | 173 | 'id' => 'wpinv_number', |
174 | 174 | 'name' => 'wpinv_number', |
175 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
175 | + 'label' => $label . getpaid_get_help_tip($info), |
|
176 | 176 | 'label_type' => 'vertical', |
177 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
177 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
178 | 178 | 'class' => 'form-control-sm', |
179 | - 'value' => $invoice->get_number( 'edit' ), |
|
179 | + 'value' => $invoice->get_number('edit'), |
|
180 | 180 | ) |
181 | 181 | ); |
182 | 182 | |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | 'type' => 'text', |
187 | 187 | 'id' => 'wpinv_cc', |
188 | 188 | 'name' => 'wpinv_cc', |
189 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
189 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
190 | 190 | 'label_type' => 'vertical', |
191 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
191 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
192 | 192 | 'class' => 'form-control-sm', |
193 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
193 | + 'value' => $invoice->get_email_cc('edit'), |
|
194 | 194 | ) |
195 | 195 | ); |
196 | 196 | |
197 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
197 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
198 | 198 | |
199 | 199 | // Apply a discount. |
200 | 200 | echo aui()->input( |
@@ -202,25 +202,25 @@ discard block |
||
202 | 202 | 'type' => 'text', |
203 | 203 | 'id' => 'wpinv_discount_code', |
204 | 204 | 'name' => 'wpinv_discount_code', |
205 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
206 | - 'placeholder' => __( 'Apply Discount', 'invoicing' ), |
|
205 | + 'label' => __('Discount Code:', 'invoicing'), |
|
206 | + 'placeholder' => __('Apply Discount', 'invoicing'), |
|
207 | 207 | 'label_type' => 'vertical', |
208 | 208 | 'class' => 'form-control-sm', |
209 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
209 | + 'value' => $invoice->get_discount_code('edit'), |
|
210 | 210 | ) |
211 | 211 | ); |
212 | 212 | |
213 | - } else if ( $invoice->get_discount_code( 'edit' ) ) { |
|
213 | + } else if ($invoice->get_discount_code('edit')) { |
|
214 | 214 | |
215 | 215 | echo aui()->input( |
216 | 216 | array( |
217 | 217 | 'type' => 'text', |
218 | 218 | 'id' => 'wpinv_discount_code', |
219 | 219 | 'name' => 'wpinv_discount_code', |
220 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
220 | + 'label' => __('Discount Code:', 'invoicing'), |
|
221 | 221 | 'label_type' => 'vertical', |
222 | 222 | 'class' => 'form-control-sm', |
223 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
223 | + 'value' => $invoice->get_discount_code('edit'), |
|
224 | 224 | 'extra_attributes' => array( |
225 | 225 | 'onclick' => 'this.select();', |
226 | 226 | 'readonly' => 'true', |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | |
231 | 231 | } |
232 | 232 | |
233 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
233 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
234 | 234 | |
235 | 235 | // Disable taxes. |
236 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
236 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
237 | 237 | |
238 | 238 | echo aui()->input( |
239 | 239 | array( |
240 | 240 | 'id' => 'wpinv_taxable', |
241 | 241 | 'name' => 'disable_taxes', |
242 | 242 | 'type' => 'checkbox', |
243 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
243 | + 'label' => __('Disable taxes', 'invoicing'), |
|
244 | 244 | 'value' => '1', |
245 | 245 | 'checked' => (bool) $invoice->get_disable_taxes(), |
246 | 246 | ) |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - if ( $invoice->is_type( 'invoice' ) ) { |
|
251 | + if ($invoice->is_type('invoice')) { |
|
252 | 252 | |
253 | 253 | // Send to customer. |
254 | 254 | echo aui()->input( |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | 'id' => 'wpinv_send_to_customer', |
257 | 257 | 'name' => 'send_to_customer', |
258 | 258 | 'type' => 'checkbox', |
259 | - 'label' => __( 'Send invoice to customer after saving', 'invoicing' ), |
|
259 | + 'label' => __('Send invoice to customer after saving', 'invoicing'), |
|
260 | 260 | 'value' => '1', |
261 | - 'checked' => $invoice->is_draft() && (bool) wpinv_get_option( 'email_user_invoice_active', true ), |
|
261 | + 'checked' => $invoice->is_draft() && (bool) wpinv_get_option('email_user_invoice_active', true), |
|
262 | 262 | ) |
263 | 263 | ); |
264 | 264 | |
265 | 265 | } |
266 | 266 | |
267 | - do_action( 'getpaid_metabox_after_invoice_details', $invoice ); |
|
267 | + do_action('getpaid_metabox_after_invoice_details', $invoice); |
|
268 | 268 | |
269 | 269 | ?> |
270 | 270 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string The rendered component. |
20 | 20 | */ |
21 | - public static function input($args = array()){ |
|
21 | + public static function input($args = array()) { |
|
22 | 22 | $defaults = array( |
23 | 23 | 'type' => 'text', |
24 | 24 | 'name' => '', |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Parse incoming $args into an array and merge it with $defaults |
54 | 54 | */ |
55 | - $args = wp_parse_args( $args, $defaults ); |
|
55 | + $args = wp_parse_args($args, $defaults); |
|
56 | 56 | $output = ''; |
57 | - if ( ! empty( $args['type'] ) ) { |
|
57 | + if (!empty($args['type'])) { |
|
58 | 58 | // hidden label option needs to be empty |
59 | 59 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
60 | 60 | |
61 | - $type = sanitize_html_class( $args['type'] ); |
|
61 | + $type = sanitize_html_class($args['type']); |
|
62 | 62 | |
63 | 63 | $help_text = ''; |
64 | 64 | $label = ''; |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | $label_args = array( |
67 | 67 | 'title'=> $args['label'], |
68 | 68 | 'for'=> $args['id'], |
69 | - 'class' => $args['label_class']." ", |
|
69 | + 'class' => $args['label_class'] . " ", |
|
70 | 70 | 'label_type' => $args['label_type'] |
71 | 71 | ); |
72 | 72 | |
73 | 73 | // floating labels need label after |
74 | - if( $args['label_type'] == 'floating' && $type != 'checkbox' ){ |
|
74 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
75 | 75 | $label_after = true; |
76 | 76 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Some special sauce for files |
80 | - if($type=='file' ){ |
|
80 | + if ($type == 'file') { |
|
81 | 81 | $label_after = true; // if type file we need the label after |
82 | 82 | $args['class'] .= ' custom-file-input '; |
83 | - }elseif($type=='checkbox'){ |
|
83 | + }elseif ($type == 'checkbox') { |
|
84 | 84 | $label_after = true; // if type file we need the label after |
85 | 85 | $args['class'] .= ' custom-control-input '; |
86 | - }elseif($type=='datepicker' || $type=='timepicker'){ |
|
86 | + }elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
87 | 87 | $type = 'text'; |
88 | 88 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
89 | 89 | $args['class'] .= ' bg-initial '; |
@@ -99,65 +99,65 @@ discard block |
||
99 | 99 | $output .= '<input type="' . $type . '" '; |
100 | 100 | |
101 | 101 | // name |
102 | - if(!empty($args['name'])){ |
|
103 | - $output .= ' name="'.esc_attr($args['name']).'" '; |
|
102 | + if (!empty($args['name'])) { |
|
103 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // id |
107 | - if(!empty($args['id'])){ |
|
108 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
107 | + if (!empty($args['id'])) { |
|
108 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // placeholder |
112 | - if(isset($args['placeholder']) && '' != $args['placeholder'] ){ |
|
113 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
112 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
113 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // title |
117 | - if(!empty($args['title'])){ |
|
118 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
117 | + if (!empty($args['title'])) { |
|
118 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // value |
122 | - if(!empty($args['value'])){ |
|
123 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
122 | + if (!empty($args['value'])) { |
|
123 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // checked, for radio and checkboxes |
127 | - if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){ |
|
127 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
128 | 128 | $output .= ' checked '; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // validation text |
132 | - if(!empty($args['validation_text'])){ |
|
133 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
132 | + if (!empty($args['validation_text'])) { |
|
133 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
134 | 134 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // validation_pattern |
138 | - if(!empty($args['validation_pattern'])){ |
|
139 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
138 | + if (!empty($args['validation_pattern'])) { |
|
139 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // step (for numbers) |
143 | - if(!empty($args['step'])){ |
|
144 | - $output .= ' step="'.$args['step'].'" '; |
|
143 | + if (!empty($args['step'])) { |
|
144 | + $output .= ' step="' . $args['step'] . '" '; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | // required |
148 | - if(!empty($args['required'])){ |
|
148 | + if (!empty($args['required'])) { |
|
149 | 149 | $output .= ' required '; |
150 | 150 | } |
151 | 151 | |
152 | 152 | // class |
153 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
154 | - $output .= ' class="form-control '.$class.'" '; |
|
153 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
154 | + $output .= ' class="form-control ' . $class . '" '; |
|
155 | 155 | |
156 | 156 | // data-attributes |
157 | 157 | $output .= AUI_Component_Helper::data_attributes($args); |
158 | 158 | |
159 | 159 | // extra attributes |
160 | - if(!empty($args['extra_attributes'])){ |
|
160 | + if (!empty($args['extra_attributes'])) { |
|
161 | 161 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
162 | 162 | } |
163 | 163 | |
@@ -166,40 +166,40 @@ discard block |
||
166 | 166 | |
167 | 167 | |
168 | 168 | // label |
169 | - if(!empty($args['label'])){ |
|
170 | - if($type == 'file'){$label_args['class'] .= 'custom-file-label';} |
|
171 | - elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';} |
|
172 | - $label = self::label( $label_args, $type ); |
|
169 | + if (!empty($args['label'])) { |
|
170 | + if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; } |
|
171 | + elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; } |
|
172 | + $label = self::label($label_args, $type); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // help text |
176 | - if(!empty($args['help_text'])){ |
|
176 | + if (!empty($args['help_text'])) { |
|
177 | 177 | $help_text = AUI_Component_Helper::help_text($args['help_text']); |
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | 181 | // set help text in the correct possition |
182 | - if($label_after){ |
|
182 | + if ($label_after) { |
|
183 | 183 | $output .= $label . $help_text; |
184 | 184 | } |
185 | 185 | |
186 | 186 | // some input types need a separate wrap |
187 | - if($type == 'file') { |
|
188 | - $output = self::wrap( array( |
|
187 | + if ($type == 'file') { |
|
188 | + $output = self::wrap(array( |
|
189 | 189 | 'content' => $output, |
190 | 190 | 'class' => 'form-group custom-file' |
191 | - ) ); |
|
192 | - }elseif($type == 'checkbox'){ |
|
191 | + )); |
|
192 | + }elseif ($type == 'checkbox') { |
|
193 | 193 | $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox'; |
194 | - $output = self::wrap( array( |
|
194 | + $output = self::wrap(array( |
|
195 | 195 | 'content' => $output, |
196 | - 'class' => 'custom-control '.$wrap_class |
|
197 | - ) ); |
|
196 | + 'class' => 'custom-control ' . $wrap_class |
|
197 | + )); |
|
198 | 198 | |
199 | - if($args['label_type']=='horizontal'){ |
|
199 | + if ($args['label_type'] == 'horizontal') { |
|
200 | 200 | $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>'; |
201 | 201 | } |
202 | - }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){ |
|
202 | + }elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
203 | 203 | |
204 | 204 | |
205 | 205 | // allow password field to toggle view |
@@ -213,49 +213,49 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // input group wraps |
216 | - if($args['input_group_left'] || $args['input_group_right']){ |
|
216 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
217 | 217 | $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
218 | - if($args['input_group_left']){ |
|
219 | - $output = self::wrap( array( |
|
218 | + if ($args['input_group_left']) { |
|
219 | + $output = self::wrap(array( |
|
220 | 220 | 'content' => $output, |
221 | - 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
221 | + 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
222 | 222 | 'input_group_left' => $args['input_group_left'], |
223 | 223 | 'input_group_left_inside' => $args['input_group_left_inside'] |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | } |
226 | - if($args['input_group_right']){ |
|
227 | - $output = self::wrap( array( |
|
226 | + if ($args['input_group_right']) { |
|
227 | + $output = self::wrap(array( |
|
228 | 228 | 'content' => $output, |
229 | - 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group', |
|
229 | + 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
|
230 | 230 | 'input_group_right' => $args['input_group_right'], |
231 | 231 | 'input_group_right_inside' => $args['input_group_right_inside'] |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - if(!$label_after){ |
|
237 | + if (!$label_after) { |
|
238 | 238 | $output .= $help_text; |
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
243 | - $output = self::wrap( array( |
|
242 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
243 | + $output = self::wrap(array( |
|
244 | 244 | 'content' => $output, |
245 | 245 | 'class' => 'col-sm-10', |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | |
249 | - if(!$label_after){ |
|
249 | + if (!$label_after) { |
|
250 | 250 | $output = $label . $output; |
251 | 251 | } |
252 | 252 | |
253 | 253 | // wrap |
254 | - if(!$args['no_wrap']){ |
|
254 | + if (!$args['no_wrap']) { |
|
255 | 255 | |
256 | - $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
256 | + $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
|
257 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
258 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
259 | 259 | $output = self::wrap(array( |
260 | 260 | 'content' => $output, |
261 | 261 | 'class' => $wrap_class, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return string The rendered component. |
280 | 280 | */ |
281 | - public static function textarea($args = array()){ |
|
281 | + public static function textarea($args = array()) { |
|
282 | 282 | $defaults = array( |
283 | 283 | 'name' => '', |
284 | 284 | 'class' => '', |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | /** |
307 | 307 | * Parse incoming $args into an array and merge it with $defaults |
308 | 308 | */ |
309 | - $args = wp_parse_args( $args, $defaults ); |
|
309 | + $args = wp_parse_args($args, $defaults); |
|
310 | 310 | $output = ''; |
311 | 311 | |
312 | 312 | // hidden label option needs to be empty |
313 | 313 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
314 | 314 | |
315 | 315 | // floating labels don't work with wysiwyg so set it as top |
316 | - if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){ |
|
316 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
317 | 317 | $args['label_type'] = 'top'; |
318 | 318 | } |
319 | 319 | |
320 | 320 | $label_after = $args['label_after']; |
321 | 321 | |
322 | 322 | // floating labels need label after |
323 | - if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){ |
|
323 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
324 | 324 | $label_after = true; |
325 | 325 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
326 | 326 | } |
327 | 327 | |
328 | 328 | // label |
329 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
330 | - }elseif(!empty($args['label']) && !$label_after){ |
|
329 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
330 | + }elseif (!empty($args['label']) && !$label_after) { |
|
331 | 331 | $label_args = array( |
332 | 332 | 'title'=> $args['label'], |
333 | 333 | 'for'=> $args['id'], |
334 | - 'class' => $args['label_class']." ", |
|
334 | + 'class' => $args['label_class'] . " ", |
|
335 | 335 | 'label_type' => $args['label_type'] |
336 | 336 | ); |
337 | - $output .= self::label( $label_args ); |
|
337 | + $output .= self::label($label_args); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // maybe horizontal label |
341 | - if($args['label_type']=='horizontal'){ |
|
341 | + if ($args['label_type'] == 'horizontal') { |
|
342 | 342 | $output .= '<div class="col-sm-10">'; |
343 | 343 | } |
344 | 344 | |
345 | - if(!empty($args['wysiwyg'])){ |
|
345 | + if (!empty($args['wysiwyg'])) { |
|
346 | 346 | ob_start(); |
347 | 347 | $content = $args['value']; |
348 | 348 | $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
@@ -356,65 +356,65 @@ discard block |
||
356 | 356 | ); |
357 | 357 | |
358 | 358 | // maybe set settings if array |
359 | - if(is_array($args['wysiwyg'])){ |
|
360 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
359 | + if (is_array($args['wysiwyg'])) { |
|
360 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
361 | 361 | } |
362 | 362 | |
363 | - wp_editor( $content, $editor_id, $settings ); |
|
363 | + wp_editor($content, $editor_id, $settings); |
|
364 | 364 | $output .= ob_get_clean(); |
365 | - }else{ |
|
365 | + } else { |
|
366 | 366 | |
367 | 367 | // open |
368 | 368 | $output .= '<textarea '; |
369 | 369 | |
370 | 370 | // name |
371 | - if(!empty($args['name'])){ |
|
372 | - $output .= ' name="'.sanitize_html_class($args['name']).'" '; |
|
371 | + if (!empty($args['name'])) { |
|
372 | + $output .= ' name="' . sanitize_html_class($args['name']) . '" '; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // id |
376 | - if(!empty($args['id'])){ |
|
377 | - $output .= ' id="'.sanitize_html_class($args['id']).'" '; |
|
376 | + if (!empty($args['id'])) { |
|
377 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // placeholder |
381 | - if(isset($args['placeholder']) && '' != $args['placeholder']){ |
|
382 | - $output .= ' placeholder="'.esc_attr($args['placeholder']).'" '; |
|
381 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
382 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // title |
386 | - if(!empty($args['title'])){ |
|
387 | - $output .= ' title="'.esc_attr($args['title']).'" '; |
|
386 | + if (!empty($args['title'])) { |
|
387 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | // validation text |
391 | - if(!empty($args['validation_text'])){ |
|
392 | - $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" '; |
|
391 | + if (!empty($args['validation_text'])) { |
|
392 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
393 | 393 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // validation_pattern |
397 | - if(!empty($args['validation_pattern'])){ |
|
398 | - $output .= ' pattern="'.$args['validation_pattern'].'" '; |
|
397 | + if (!empty($args['validation_pattern'])) { |
|
398 | + $output .= ' pattern="' . $args['validation_pattern'] . '" '; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | // required |
402 | - if(!empty($args['required'])){ |
|
402 | + if (!empty($args['required'])) { |
|
403 | 403 | $output .= ' required '; |
404 | 404 | } |
405 | 405 | |
406 | 406 | // rows |
407 | - if(!empty($args['rows'])){ |
|
408 | - $output .= ' rows="'.absint($args['rows']).'" '; |
|
407 | + if (!empty($args['rows'])) { |
|
408 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
412 | 412 | // class |
413 | 413 | $class = !empty($args['class']) ? $args['class'] : ''; |
414 | - $output .= ' class="form-control '.$class.'" '; |
|
414 | + $output .= ' class="form-control ' . $class . '" '; |
|
415 | 415 | |
416 | 416 | // extra attributes |
417 | - if(!empty($args['extra_attributes'])){ |
|
417 | + if (!empty($args['extra_attributes'])) { |
|
418 | 418 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
419 | 419 | } |
420 | 420 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | $output .= ' >'; |
423 | 423 | |
424 | 424 | // value |
425 | - if ( ! empty( $args['value'] ) ) { |
|
426 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
427 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
425 | + if (!empty($args['value'])) { |
|
426 | + if (!empty($args['allow_tags'])) { |
|
427 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
428 | 428 | } else { |
429 | - $output .= sanitize_textarea_field( $args['value'] ); |
|
429 | + $output .= sanitize_textarea_field($args['value']); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
@@ -435,32 +435,32 @@ discard block |
||
435 | 435 | |
436 | 436 | } |
437 | 437 | |
438 | - if(!empty($args['label']) && $label_after){ |
|
438 | + if (!empty($args['label']) && $label_after) { |
|
439 | 439 | $label_args = array( |
440 | 440 | 'title'=> $args['label'], |
441 | 441 | 'for'=> $args['id'], |
442 | - 'class' => $args['label_class']." ", |
|
442 | + 'class' => $args['label_class'] . " ", |
|
443 | 443 | 'label_type' => $args['label_type'] |
444 | 444 | ); |
445 | - $output .= self::label( $label_args ); |
|
445 | + $output .= self::label($label_args); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | // help text |
449 | - if(!empty($args['help_text'])){ |
|
449 | + if (!empty($args['help_text'])) { |
|
450 | 450 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
451 | 451 | } |
452 | 452 | |
453 | 453 | // maybe horizontal label |
454 | - if($args['label_type']=='horizontal'){ |
|
454 | + if ($args['label_type'] == 'horizontal') { |
|
455 | 455 | $output .= '</div>'; |
456 | 456 | } |
457 | 457 | |
458 | 458 | |
459 | 459 | // wrap |
460 | - if(!$args['no_wrap']){ |
|
461 | - $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group'; |
|
462 | - $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
460 | + if (!$args['no_wrap']) { |
|
461 | + $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
|
462 | + $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
|
463 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
464 | 464 | $output = self::wrap(array( |
465 | 465 | 'content' => $output, |
466 | 466 | 'class' => $wrap_class, |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | return $output; |
474 | 474 | } |
475 | 475 | |
476 | - public static function label($args = array(), $type = ''){ |
|
476 | + public static function label($args = array(), $type = '') { |
|
477 | 477 | //<label for="exampleInputEmail1">Email address</label> |
478 | 478 | $defaults = array( |
479 | 479 | 'title' => 'div', |
@@ -485,20 +485,20 @@ discard block |
||
485 | 485 | /** |
486 | 486 | * Parse incoming $args into an array and merge it with $defaults |
487 | 487 | */ |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | $output = ''; |
490 | 490 | |
491 | - if($args['title']){ |
|
491 | + if ($args['title']) { |
|
492 | 492 | |
493 | 493 | // maybe hide labels //@todo set a global option for visibility class |
494 | - if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){ |
|
494 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
495 | 495 | $class = $args['class']; |
496 | - }else{ |
|
497 | - $class = 'sr-only '.$args['class']; |
|
496 | + } else { |
|
497 | + $class = 'sr-only ' . $args['class']; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // maybe horizontal |
501 | - if($args['label_type']=='horizontal' && $type != 'checkbox'){ |
|
501 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
502 | 502 | $class .= ' col-sm-2 col-form-label'; |
503 | 503 | } |
504 | 504 | |
@@ -506,20 +506,20 @@ discard block |
||
506 | 506 | $output .= '<label '; |
507 | 507 | |
508 | 508 | // for |
509 | - if(!empty($args['for'])){ |
|
510 | - $output .= ' for="'.sanitize_text_field($args['for']).'" '; |
|
509 | + if (!empty($args['for'])) { |
|
510 | + $output .= ' for="' . sanitize_text_field($args['for']) . '" '; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | // class |
514 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
515 | - $output .= ' class="'.$class.'" '; |
|
514 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
515 | + $output .= ' class="' . $class . '" '; |
|
516 | 516 | |
517 | 517 | // close |
518 | 518 | $output .= '>'; |
519 | 519 | |
520 | 520 | |
521 | 521 | // title, don't escape fully as can contain html |
522 | - if(!empty($args['title'])){ |
|
522 | + if (!empty($args['title'])) { |
|
523 | 523 | $output .= wp_kses_post($args['title']); |
524 | 524 | } |
525 | 525 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return string |
542 | 542 | */ |
543 | - public static function wrap($args = array()){ |
|
543 | + public static function wrap($args = array()) { |
|
544 | 544 | $defaults = array( |
545 | 545 | 'type' => 'div', |
546 | 546 | 'class' => 'form-group', |
@@ -556,55 +556,55 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * Parse incoming $args into an array and merge it with $defaults |
558 | 558 | */ |
559 | - $args = wp_parse_args( $args, $defaults ); |
|
559 | + $args = wp_parse_args($args, $defaults); |
|
560 | 560 | $output = ''; |
561 | - if($args['type']){ |
|
561 | + if ($args['type']) { |
|
562 | 562 | |
563 | 563 | // open |
564 | - $output .= '<'.sanitize_html_class($args['type']); |
|
564 | + $output .= '<' . sanitize_html_class($args['type']); |
|
565 | 565 | |
566 | 566 | // element require |
567 | - if(!empty($args['element_require'])){ |
|
567 | + if (!empty($args['element_require'])) { |
|
568 | 568 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
569 | 569 | $args['class'] .= " aui-conditional-field"; |
570 | 570 | } |
571 | 571 | |
572 | 572 | // argument_id |
573 | - if( !empty($args['argument_id']) ){ |
|
574 | - $output .= ' data-argument="'.esc_attr($args['argument_id']).'"'; |
|
573 | + if (!empty($args['argument_id'])) { |
|
574 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | // class |
578 | - $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
579 | - $output .= ' class="'.$class.'" '; |
|
578 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
579 | + $output .= ' class="' . $class . '" '; |
|
580 | 580 | |
581 | 581 | // close wrap |
582 | 582 | $output .= ' >'; |
583 | 583 | |
584 | 584 | |
585 | 585 | // Input group left |
586 | - if(!empty($args['input_group_left'])){ |
|
586 | + if (!empty($args['input_group_left'])) { |
|
587 | 587 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
588 | - $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>'; |
|
589 | - $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>'; |
|
588 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
589 | + $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | // content |
593 | 593 | $output .= $args['content']; |
594 | 594 | |
595 | 595 | // Input group right |
596 | - if(!empty($args['input_group_right'])){ |
|
596 | + if (!empty($args['input_group_right'])) { |
|
597 | 597 | $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
598 | - $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>'; |
|
599 | - $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>'; |
|
598 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
599 | + $output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>'; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
603 | 603 | // close wrap |
604 | - $output .= '</'.sanitize_html_class($args['type']).'>'; |
|
604 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
605 | 605 | |
606 | 606 | |
607 | - }else{ |
|
607 | + } else { |
|
608 | 608 | $output = $args['content']; |
609 | 609 | } |
610 | 610 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return string The rendered component. |
620 | 620 | */ |
621 | - public static function select($args = array()){ |
|
621 | + public static function select($args = array()) { |
|
622 | 622 | $defaults = array( |
623 | 623 | 'class' => '', |
624 | 624 | 'wrap_class' => '', |
@@ -644,11 +644,11 @@ discard block |
||
644 | 644 | /** |
645 | 645 | * Parse incoming $args into an array and merge it with $defaults |
646 | 646 | */ |
647 | - $args = wp_parse_args( $args, $defaults ); |
|
647 | + $args = wp_parse_args($args, $defaults); |
|
648 | 648 | $output = ''; |
649 | 649 | |
650 | 650 | // for now lets hide floating labels |
651 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';} |
|
651 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; } |
|
652 | 652 | |
653 | 653 | // hidden label option needs to be empty |
654 | 654 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
@@ -657,47 +657,47 @@ discard block |
||
657 | 657 | $label_after = $args['label_after']; |
658 | 658 | |
659 | 659 | // floating labels need label after |
660 | - if( $args['label_type'] == 'floating' ){ |
|
660 | + if ($args['label_type'] == 'floating') { |
|
661 | 661 | $label_after = true; |
662 | 662 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
663 | 663 | } |
664 | 664 | |
665 | 665 | // Maybe setup select2 |
666 | 666 | $is_select2 = false; |
667 | - if(!empty($args['select2'])){ |
|
667 | + if (!empty($args['select2'])) { |
|
668 | 668 | $args['class'] .= ' aui-select2'; |
669 | 669 | $is_select2 = true; |
670 | - }elseif( strpos($args['class'], 'aui-select2') !== false){ |
|
670 | + }elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
671 | 671 | $is_select2 = true; |
672 | 672 | } |
673 | 673 | |
674 | 674 | // select2 tags |
675 | - if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason |
|
675 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
676 | 676 | $args['data-tags'] = 'true'; |
677 | 677 | $args['data-token-separators'] = "[',']"; |
678 | 678 | $args['multiple'] = true; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // select2 placeholder |
682 | - if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){ |
|
682 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
683 | 683 | $args['data-placeholder'] = esc_attr($args['placeholder']); |
684 | 684 | $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
685 | 685 | } |
686 | 686 | |
687 | 687 | // label |
688 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
689 | - }elseif(!empty($args['label']) && !$label_after){ |
|
688 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
689 | + }elseif (!empty($args['label']) && !$label_after) { |
|
690 | 690 | $label_args = array( |
691 | 691 | 'title'=> $args['label'], |
692 | 692 | 'for'=> $args['id'], |
693 | - 'class' => $args['label_class']." ", |
|
693 | + 'class' => $args['label_class'] . " ", |
|
694 | 694 | 'label_type' => $args['label_type'] |
695 | 695 | ); |
696 | 696 | $output .= self::label($label_args); |
697 | 697 | } |
698 | 698 | |
699 | 699 | // maybe horizontal label |
700 | - if($args['label_type']=='horizontal'){ |
|
700 | + if ($args['label_type'] == 'horizontal') { |
|
701 | 701 | $output .= '<div class="col-sm-10">'; |
702 | 702 | } |
703 | 703 | |
@@ -705,32 +705,32 @@ discard block |
||
705 | 705 | $output .= '<select '; |
706 | 706 | |
707 | 707 | // style |
708 | - if($is_select2){ |
|
708 | + if ($is_select2) { |
|
709 | 709 | $output .= " style='width:100%;' "; |
710 | 710 | } |
711 | 711 | |
712 | 712 | // element require |
713 | - if(!empty($args['element_require'])){ |
|
713 | + if (!empty($args['element_require'])) { |
|
714 | 714 | $output .= AUI_Component_Helper::element_require($args['element_require']); |
715 | 715 | $args['class'] .= " aui-conditional-field"; |
716 | 716 | } |
717 | 717 | |
718 | 718 | // class |
719 | 719 | $class = !empty($args['class']) ? $args['class'] : ''; |
720 | - $output .= AUI_Component_Helper::class_attr('custom-select '.$class); |
|
720 | + $output .= AUI_Component_Helper::class_attr('custom-select ' . $class); |
|
721 | 721 | |
722 | 722 | // name |
723 | - if(!empty($args['name'])){ |
|
724 | - $output .= AUI_Component_Helper::name($args['name'],$args['multiple']); |
|
723 | + if (!empty($args['name'])) { |
|
724 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | // id |
728 | - if(!empty($args['id'])){ |
|
728 | + if (!empty($args['id'])) { |
|
729 | 729 | $output .= AUI_Component_Helper::id($args['id']); |
730 | 730 | } |
731 | 731 | |
732 | 732 | // title |
733 | - if(!empty($args['title'])){ |
|
733 | + if (!empty($args['title'])) { |
|
734 | 734 | $output .= AUI_Component_Helper::title($args['title']); |
735 | 735 | } |
736 | 736 | |
@@ -741,17 +741,17 @@ discard block |
||
741 | 741 | $output .= AUI_Component_Helper::aria_attributes($args); |
742 | 742 | |
743 | 743 | // extra attributes |
744 | - if(!empty($args['extra_attributes'])){ |
|
744 | + if (!empty($args['extra_attributes'])) { |
|
745 | 745 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
746 | 746 | } |
747 | 747 | |
748 | 748 | // required |
749 | - if(!empty($args['required'])){ |
|
749 | + if (!empty($args['required'])) { |
|
750 | 750 | $output .= ' required '; |
751 | 751 | } |
752 | 752 | |
753 | 753 | // multiple |
754 | - if(!empty($args['multiple'])){ |
|
754 | + if (!empty($args['multiple'])) { |
|
755 | 755 | $output .= ' multiple '; |
756 | 756 | } |
757 | 757 | |
@@ -759,21 +759,21 @@ discard block |
||
759 | 759 | $output .= ' >'; |
760 | 760 | |
761 | 761 | // placeholder |
762 | - if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){ |
|
763 | - $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>'; |
|
764 | - }elseif($is_select2 && !empty($args['placeholder'])){ |
|
762 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
763 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
764 | + }elseif ($is_select2 && !empty($args['placeholder'])) { |
|
765 | 765 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
766 | 766 | } |
767 | 767 | |
768 | 768 | // Options |
769 | - if(!empty($args['options'])){ |
|
769 | + if (!empty($args['options'])) { |
|
770 | 770 | |
771 | - if(!is_array($args['options'])){ |
|
771 | + if (!is_array($args['options'])) { |
|
772 | 772 | $output .= $args['options']; // not the preferred way but an option |
773 | - }else{ |
|
774 | - foreach($args['options'] as $val => $name){ |
|
773 | + } else { |
|
774 | + foreach ($args['options'] as $val => $name) { |
|
775 | 775 | $selected = ''; |
776 | - if(is_array($name)){ |
|
776 | + if (is_array($name)) { |
|
777 | 777 | if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
778 | 778 | $option_label = isset($name['label']) ? $name['label'] : ''; |
779 | 779 | |
@@ -781,23 +781,23 @@ discard block |
||
781 | 781 | } else { |
782 | 782 | $option_label = isset($name['label']) ? $name['label'] : ''; |
783 | 783 | $option_value = isset($name['value']) ? $name['value'] : ''; |
784 | - if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){ |
|
784 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
785 | 785 | $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
786 | - } elseif(!empty($args['value'])) { |
|
787 | - $selected = selected($option_value,stripslashes_deep($args['value']), false); |
|
786 | + } elseif (!empty($args['value'])) { |
|
787 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
791 | 791 | } |
792 | - }else{ |
|
793 | - if(!empty($args['value'])){ |
|
794 | - if(is_array($args['value'])){ |
|
795 | - $selected = in_array($val,$args['value']) ? 'selected="selected"' : ''; |
|
796 | - } elseif(!empty($args['value'])) { |
|
797 | - $selected = selected( $args['value'], $val, false); |
|
792 | + } else { |
|
793 | + if (!empty($args['value'])) { |
|
794 | + if (is_array($args['value'])) { |
|
795 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
796 | + } elseif (!empty($args['value'])) { |
|
797 | + $selected = selected($args['value'], $val, false); |
|
798 | 798 | } |
799 | 799 | } |
800 | - $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>'; |
|
800 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 | } |
@@ -807,31 +807,31 @@ discard block |
||
807 | 807 | // closing tag |
808 | 808 | $output .= '</select>'; |
809 | 809 | |
810 | - if(!empty($args['label']) && $label_after){ |
|
810 | + if (!empty($args['label']) && $label_after) { |
|
811 | 811 | $label_args = array( |
812 | 812 | 'title'=> $args['label'], |
813 | 813 | 'for'=> $args['id'], |
814 | - 'class' => $args['label_class']." ", |
|
814 | + 'class' => $args['label_class'] . " ", |
|
815 | 815 | 'label_type' => $args['label_type'] |
816 | 816 | ); |
817 | 817 | $output .= self::label($label_args); |
818 | 818 | } |
819 | 819 | |
820 | 820 | // help text |
821 | - if(!empty($args['help_text'])){ |
|
821 | + if (!empty($args['help_text'])) { |
|
822 | 822 | $output .= AUI_Component_Helper::help_text($args['help_text']); |
823 | 823 | } |
824 | 824 | |
825 | 825 | // maybe horizontal label |
826 | - if($args['label_type']=='horizontal'){ |
|
826 | + if ($args['label_type'] == 'horizontal') { |
|
827 | 827 | $output .= '</div>'; |
828 | 828 | } |
829 | 829 | |
830 | 830 | |
831 | 831 | // wrap |
832 | - if(!$args['no_wrap']){ |
|
833 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
834 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
832 | + if (!$args['no_wrap']) { |
|
833 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
834 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
835 | 835 | $output = self::wrap(array( |
836 | 836 | 'content' => $output, |
837 | 837 | 'class' => $wrap_class, |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | * |
852 | 852 | * @return string The rendered component. |
853 | 853 | */ |
854 | - public static function radio($args = array()){ |
|
854 | + public static function radio($args = array()) { |
|
855 | 855 | $defaults = array( |
856 | 856 | 'class' => '', |
857 | 857 | 'wrap_class' => '', |
@@ -875,14 +875,14 @@ discard block |
||
875 | 875 | /** |
876 | 876 | * Parse incoming $args into an array and merge it with $defaults |
877 | 877 | */ |
878 | - $args = wp_parse_args( $args, $defaults ); |
|
878 | + $args = wp_parse_args($args, $defaults); |
|
879 | 879 | |
880 | 880 | // for now lets use horizontal for floating |
881 | - if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';} |
|
881 | + if ($args['label_type'] == 'floating') {$args['label_type'] = 'horizontal'; } |
|
882 | 882 | |
883 | 883 | $label_args = array( |
884 | 884 | 'title'=> $args['label'], |
885 | - 'class' => $args['label_class']." pt-0 ", |
|
885 | + 'class' => $args['label_class'] . " pt-0 ", |
|
886 | 886 | 'label_type' => $args['label_type'] |
887 | 887 | ); |
888 | 888 | |
@@ -891,39 +891,39 @@ discard block |
||
891 | 891 | |
892 | 892 | |
893 | 893 | // label before |
894 | - if(!empty($args['label'])){ |
|
895 | - $output .= self::label( $label_args, 'radio' ); |
|
894 | + if (!empty($args['label'])) { |
|
895 | + $output .= self::label($label_args, 'radio'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | // maybe horizontal label |
899 | - if($args['label_type']=='horizontal'){ |
|
899 | + if ($args['label_type'] == 'horizontal') { |
|
900 | 900 | $output .= '<div class="col-sm-10">'; |
901 | 901 | } |
902 | 902 | |
903 | - if(!empty($args['options'])){ |
|
903 | + if (!empty($args['options'])) { |
|
904 | 904 | $count = 0; |
905 | - foreach($args['options'] as $value => $label){ |
|
905 | + foreach ($args['options'] as $value => $label) { |
|
906 | 906 | $option_args = $args; |
907 | 907 | $option_args['value'] = $value; |
908 | 908 | $option_args['label'] = $label; |
909 | 909 | $option_args['checked'] = $value == $args['value'] ? true : false; |
910 | - $output .= self::radio_option($option_args,$count); |
|
910 | + $output .= self::radio_option($option_args, $count); |
|
911 | 911 | $count++; |
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | 915 | // help text |
916 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
916 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
917 | 917 | $output .= $help_text; |
918 | 918 | |
919 | 919 | // maybe horizontal label |
920 | - if($args['label_type']=='horizontal'){ |
|
920 | + if ($args['label_type'] == 'horizontal') { |
|
921 | 921 | $output .= '</div>'; |
922 | 922 | } |
923 | 923 | |
924 | 924 | // wrap |
925 | - $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group'; |
|
926 | - $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class; |
|
925 | + $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
|
926 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
927 | 927 | $output = self::wrap(array( |
928 | 928 | 'content' => $output, |
929 | 929 | 'class' => $wrap_class, |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @return string The rendered component. |
944 | 944 | */ |
945 | - public static function radio_option($args = array(),$count = ''){ |
|
945 | + public static function radio_option($args = array(), $count = '') { |
|
946 | 946 | $defaults = array( |
947 | 947 | 'class' => '', |
948 | 948 | 'id' => '', |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | /** |
961 | 961 | * Parse incoming $args into an array and merge it with $defaults |
962 | 962 | */ |
963 | - $args = wp_parse_args( $args, $defaults ); |
|
963 | + $args = wp_parse_args($args, $defaults); |
|
964 | 964 | |
965 | 965 | $output = ''; |
966 | 966 | |
@@ -971,27 +971,27 @@ discard block |
||
971 | 971 | $output .= ' class="form-check-input" '; |
972 | 972 | |
973 | 973 | // name |
974 | - if(!empty($args['name'])){ |
|
974 | + if (!empty($args['name'])) { |
|
975 | 975 | $output .= AUI_Component_Helper::name($args['name']); |
976 | 976 | } |
977 | 977 | |
978 | 978 | // id |
979 | - if(!empty($args['id'])){ |
|
980 | - $output .= AUI_Component_Helper::id($args['id'].$count); |
|
979 | + if (!empty($args['id'])) { |
|
980 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | // title |
984 | - if(!empty($args['title'])){ |
|
984 | + if (!empty($args['title'])) { |
|
985 | 985 | $output .= AUI_Component_Helper::title($args['title']); |
986 | 986 | } |
987 | 987 | |
988 | 988 | // value |
989 | - if(isset($args['value'])){ |
|
990 | - $output .= ' value="'.sanitize_text_field($args['value']).'" '; |
|
989 | + if (isset($args['value'])) { |
|
990 | + $output .= ' value="' . sanitize_text_field($args['value']) . '" '; |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | // checked, for radio and checkboxes |
994 | - if( $args['checked'] ){ |
|
994 | + if ($args['checked']) { |
|
995 | 995 | $output .= ' checked '; |
996 | 996 | } |
997 | 997 | |
@@ -1002,12 +1002,12 @@ discard block |
||
1002 | 1002 | $output .= AUI_Component_Helper::aria_attributes($args); |
1003 | 1003 | |
1004 | 1004 | // extra attributes |
1005 | - if(!empty($args['extra_attributes'])){ |
|
1005 | + if (!empty($args['extra_attributes'])) { |
|
1006 | 1006 | $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | // required |
1010 | - if(!empty($args['required'])){ |
|
1010 | + if (!empty($args['required'])) { |
|
1011 | 1011 | $output .= ' required '; |
1012 | 1012 | } |
1013 | 1013 | |
@@ -1015,13 +1015,13 @@ discard block |
||
1015 | 1015 | $output .= ' >'; |
1016 | 1016 | |
1017 | 1017 | // label |
1018 | - if(!empty($args['label']) && is_array($args['label'])){ |
|
1019 | - }elseif(!empty($args['label'])){ |
|
1020 | - $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio'); |
|
1018 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1019 | + }elseif (!empty($args['label'])) { |
|
1020 | + $output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio'); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | // wrap |
1024 | - if(!$args['no_wrap']){ |
|
1024 | + if (!$args['no_wrap']) { |
|
1025 | 1025 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
1026 | 1026 | $output = self::wrap(array( |
1027 | 1027 | 'content' => $output, |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Only add if the class does not already exist. |
21 | 21 | */ |
22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
99 | 99 | */ |
100 | 100 | public static function instance() { |
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
102 | 102 | |
103 | 103 | self::$instance = new AyeCode_UI_Settings; |
104 | 104 | |
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
106 | 106 | |
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
107 | + if (is_admin()) { |
|
108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
110 | 110 | |
111 | 111 | // Maybe show example page |
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
113 | 113 | } |
114 | 114 | |
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
116 | 116 | |
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
117 | + do_action('ayecode_ui_settings_loaded'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * Setup some constants. |
125 | 125 | */ |
126 | - public function constants(){ |
|
126 | + public function constants() { |
|
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -143,25 +143,25 @@ discard block |
||
143 | 143 | * |
144 | 144 | * We load super early in case there is a theme version that might change the colors |
145 | 145 | */ |
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
146 | + if ($this->settings['css']) { |
|
147 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
148 | 148 | } |
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
149 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // maybe load JS |
154 | - if ( $this->settings['js'] ) { |
|
154 | + if ($this->settings['js']) { |
|
155 | 155 | $priority = $this->is_bs3_compat() ? 100 : 1; |
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
156 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
157 | 157 | } |
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
158 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
159 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Maybe set the HTML font size |
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
163 | + if ($this->settings['html_font_size']) { |
|
164 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function load_admin_scripts(){ |
|
175 | + public function load_admin_scripts() { |
|
176 | 176 | $result = true; |
177 | 177 | |
178 | 178 | // check if specifically disabled |
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
179 | + if (!empty($this->settings['disable_admin'])) { |
|
180 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
181 | + foreach ($url_parts as $part) { |
|
182 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
183 | 183 | return false; // return early, no point checking further |
184 | 184 | } |
185 | 185 | } |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * Add a html font size to the footer. |
193 | 193 | */ |
194 | - public function html_font_size(){ |
|
194 | + public function html_font_size() { |
|
195 | 195 | $this->settings = $this->get_settings(); |
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
196 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return bool |
203 | 203 | */ |
204 | - public function is_aui_screen(){ |
|
204 | + public function is_aui_screen() { |
|
205 | 205 | $load = false; |
206 | 206 | // check if we should load or not |
207 | - if ( is_admin() ) { |
|
207 | + if (is_admin()) { |
|
208 | 208 | // Only enable on set pages |
209 | 209 | $aui_screens = array( |
210 | 210 | 'page', |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | 'settings_page_ayecode-ui-settings', |
213 | 213 | 'appearance_page_gutenberg-widgets' |
214 | 214 | ); |
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
215 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
216 | 216 | |
217 | 217 | $screen = get_current_screen(); |
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
221 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
222 | 222 | $load = true; |
223 | 223 | } |
224 | 224 | } |
@@ -231,25 +231,25 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function enqueue_style() { |
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
234 | + if (is_admin() && !$this->is_aui_screen()) { |
|
235 | 235 | // don't add wp-admin scripts if not requested to |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
238 | 238 | |
239 | 239 | $rtl = is_rtl() ? '-rtl' : ''; |
240 | 240 | |
241 | - if($this->settings[$css_setting]){ |
|
242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
241 | + if ($this->settings[$css_setting]) { |
|
242 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
243 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
244 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
245 | + wp_enqueue_style('ayecode-ui'); |
|
246 | 246 | |
247 | 247 | // flatpickr |
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
248 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
249 | 249 | |
250 | 250 | |
251 | 251 | // fix some wp-admin issues |
252 | - if(is_admin()){ |
|
252 | + if (is_admin()) { |
|
253 | 253 | $custom_css = " |
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | padding: 0; |
296 | 296 | } |
297 | 297 | "; |
298 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
298 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // custom changes |
302 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
302 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | } |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | function aui_init_flatpickr(){ |
559 | 559 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
560 | 560 | $aui_doing_init_flatpickr = true; |
561 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
561 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
562 | 562 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
563 | 563 | } |
564 | 564 | $aui_doing_init_flatpickr = false; |
@@ -858,10 +858,10 @@ discard block |
||
858 | 858 | /* |
859 | 859 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
860 | 860 | */ |
861 | - return str_replace( array( |
|
861 | + return str_replace(array( |
|
862 | 862 | '<script>', |
863 | 863 | '</script>' |
864 | - ), '', $output ); |
|
864 | + ), '', $output); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
@@ -875,13 +875,13 @@ discard block |
||
875 | 875 | ob_start(); |
876 | 876 | ?> |
877 | 877 | <script> |
878 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
878 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
879 | 879 | /* With Avada builder */ |
880 | 880 | |
881 | 881 | <?php } ?> |
882 | 882 | </script> |
883 | 883 | <?php |
884 | - return str_replace( array( |
|
884 | + return str_replace(array( |
|
885 | 885 | '<script>', |
886 | 886 | '</script>' |
887 | 887 | ), '', ob_get_clean()); |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * |
893 | 893 | * If this remains small then its best to use this than to add another JS file. |
894 | 894 | */ |
895 | - public function inline_script_file_browser(){ |
|
895 | + public function inline_script_file_browser() { |
|
896 | 896 | ob_start(); |
897 | 897 | ?> |
898 | 898 | <script> |
@@ -907,10 +907,10 @@ discard block |
||
907 | 907 | /* |
908 | 908 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
909 | 909 | */ |
910 | - return str_replace( array( |
|
910 | + return str_replace(array( |
|
911 | 911 | '<script>', |
912 | 912 | '</script>' |
913 | - ), '', $output ); |
|
913 | + ), '', $output); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | /** |
@@ -918,50 +918,50 @@ discard block |
||
918 | 918 | */ |
919 | 919 | public function enqueue_scripts() { |
920 | 920 | |
921 | - if( is_admin() && !$this->is_aui_screen()){ |
|
921 | + if (is_admin() && !$this->is_aui_screen()) { |
|
922 | 922 | // don't add wp-admin scripts if not requested to |
923 | - }else { |
|
923 | + } else { |
|
924 | 924 | |
925 | 925 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
926 | 926 | |
927 | 927 | // select2 |
928 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
928 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
929 | 929 | |
930 | 930 | // flatpickr |
931 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
931 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
932 | 932 | |
933 | 933 | // Bootstrap file browser |
934 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
935 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
934 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
935 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
936 | 936 | |
937 | 937 | $load_inline = false; |
938 | 938 | |
939 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
939 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
940 | 940 | // Bootstrap bundle |
941 | 941 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
942 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
942 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
943 | 943 | 'select2', |
944 | 944 | 'jquery' |
945 | - ), $this->latest, $this->is_bs3_compat() ); |
|
945 | + ), $this->latest, $this->is_bs3_compat()); |
|
946 | 946 | // if in admin then add to footer for compatibility. |
947 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
947 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
948 | 948 | $script = $this->inline_script(); |
949 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
950 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
949 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
950 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
951 | 951 | $url = $this->url . 'assets/js/popper.min.js'; |
952 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
953 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
952 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
953 | + wp_enqueue_script('bootstrap-js-popper'); |
|
954 | 954 | $load_inline = true; |
955 | 955 | } else { |
956 | 956 | $load_inline = true; |
957 | 957 | } |
958 | 958 | |
959 | 959 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
960 | - if ( $load_inline ) { |
|
961 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
962 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
960 | + if ($load_inline) { |
|
961 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
962 | + wp_enqueue_script('bootstrap-dummy'); |
|
963 | 963 | $script = $this->inline_script(); |
964 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
964 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
965 | 965 | } |
966 | 966 | } |
967 | 967 | |
@@ -970,9 +970,9 @@ discard block |
||
970 | 970 | /** |
971 | 971 | * Enqueue flatpickr if called. |
972 | 972 | */ |
973 | - public function enqueue_flatpickr(){ |
|
974 | - wp_enqueue_style( 'flatpickr' ); |
|
975 | - wp_enqueue_script( 'flatpickr' ); |
|
973 | + public function enqueue_flatpickr() { |
|
974 | + wp_enqueue_style('flatpickr'); |
|
975 | + wp_enqueue_script('flatpickr'); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | /** |
@@ -984,15 +984,15 @@ discard block |
||
984 | 984 | |
985 | 985 | $url = ''; |
986 | 986 | // check if we are inside a plugin |
987 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
987 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
988 | 988 | |
989 | 989 | // add check in-case user has changed wp-content dir name. |
990 | 990 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
991 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
992 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
991 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
992 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
993 | 993 | |
994 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
995 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
994 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
995 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | return $url; |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | * Register the database settings with WordPress. |
1003 | 1003 | */ |
1004 | 1004 | public function register_settings() { |
1005 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1005 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
@@ -1011,10 +1011,10 @@ discard block |
||
1011 | 1011 | */ |
1012 | 1012 | public function menu_item() { |
1013 | 1013 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
1014 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1014 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1015 | 1015 | $this, |
1016 | 1016 | 'settings_page' |
1017 | - ) ); |
|
1017 | + )); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | /** |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | * |
1023 | 1023 | * @return array |
1024 | 1024 | */ |
1025 | - public function theme_js_settings(){ |
|
1025 | + public function theme_js_settings() { |
|
1026 | 1026 | return array( |
1027 | 1027 | 'ayetheme' => 'popper', |
1028 | 1028 | 'listimia' => 'required', |
@@ -1038,17 +1038,17 @@ discard block |
||
1038 | 1038 | */ |
1039 | 1039 | public function get_settings() { |
1040 | 1040 | |
1041 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1041 | + $db_settings = get_option('ayecode-ui-settings'); |
|
1042 | 1042 | $js_default = 'core-popper'; |
1043 | 1043 | $js_default_backend = $js_default; |
1044 | 1044 | |
1045 | 1045 | // maybe set defaults (if no settings set) |
1046 | - if(empty($db_settings)){ |
|
1047 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1046 | + if (empty($db_settings)) { |
|
1047 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
1048 | 1048 | $theme_js_settings = self::theme_js_settings(); |
1049 | - if(isset($theme_js_settings[$active_theme])){ |
|
1049 | + if (isset($theme_js_settings[$active_theme])) { |
|
1050 | 1050 | $js_default = $theme_js_settings[$active_theme]; |
1051 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1051 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
1052 | 1052 | } |
1053 | 1053 | } |
1054 | 1054 | |
@@ -1061,14 +1061,14 @@ discard block |
||
1061 | 1061 | 'disable_admin' => '', // URL snippets to disable loading on admin |
1062 | 1062 | ); |
1063 | 1063 | |
1064 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1064 | + $settings = wp_parse_args($db_settings, $defaults); |
|
1065 | 1065 | |
1066 | 1066 | /** |
1067 | 1067 | * Filter the Bootstrap settings. |
1068 | 1068 | * |
1069 | 1069 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
1070 | 1070 | */ |
1071 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1071 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | |
@@ -1076,90 +1076,90 @@ discard block |
||
1076 | 1076 | * The settings page html output. |
1077 | 1077 | */ |
1078 | 1078 | public function settings_page() { |
1079 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1080 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1079 | + if (!current_user_can('manage_options')) { |
|
1080 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
1081 | 1081 | } |
1082 | 1082 | ?> |
1083 | 1083 | <div class="wrap"> |
1084 | 1084 | <h1><?php echo $this->name; ?></h1> |
1085 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
|
1085 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", 'aui'); ?></p> |
|
1086 | 1086 | <form method="post" action="options.php"> |
1087 | 1087 | <?php |
1088 | - settings_fields( 'ayecode-ui-settings' ); |
|
1089 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1088 | + settings_fields('ayecode-ui-settings'); |
|
1089 | + do_settings_sections('ayecode-ui-settings'); |
|
1090 | 1090 | ?> |
1091 | 1091 | |
1092 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
1092 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
1093 | 1093 | <table class="form-table wpbs-table-settings"> |
1094 | 1094 | <tr valign="top"> |
1095 | 1095 | <th scope="row"><label |
1096 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1096 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1097 | 1097 | <td> |
1098 | 1098 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
1099 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1100 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
1101 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1099 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1100 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
1101 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1102 | 1102 | </select> |
1103 | 1103 | </td> |
1104 | 1104 | </tr> |
1105 | 1105 | |
1106 | 1106 | <tr valign="top"> |
1107 | 1107 | <th scope="row"><label |
1108 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1108 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1109 | 1109 | <td> |
1110 | 1110 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
1111 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1112 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1113 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1114 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1111 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1112 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1113 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1114 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1115 | 1115 | </select> |
1116 | 1116 | </td> |
1117 | 1117 | </tr> |
1118 | 1118 | |
1119 | 1119 | <tr valign="top"> |
1120 | 1120 | <th scope="row"><label |
1121 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
1121 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
1122 | 1122 | <td> |
1123 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1124 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
|
1123 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1124 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p> |
|
1125 | 1125 | </td> |
1126 | 1126 | </tr> |
1127 | 1127 | |
1128 | 1128 | </table> |
1129 | 1129 | |
1130 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
1130 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
1131 | 1131 | <table class="form-table wpbs-table-settings"> |
1132 | 1132 | <tr valign="top"> |
1133 | 1133 | <th scope="row"><label |
1134 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1134 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1135 | 1135 | <td> |
1136 | 1136 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
1137 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1138 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
1139 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1137 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1138 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
1139 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1140 | 1140 | </select> |
1141 | 1141 | </td> |
1142 | 1142 | </tr> |
1143 | 1143 | |
1144 | 1144 | <tr valign="top"> |
1145 | 1145 | <th scope="row"><label |
1146 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1146 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1147 | 1147 | <td> |
1148 | 1148 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
1149 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1150 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1151 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1152 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1149 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1150 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1151 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1152 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1153 | 1153 | </select> |
1154 | 1154 | </td> |
1155 | 1155 | </tr> |
1156 | 1156 | |
1157 | 1157 | <tr valign="top"> |
1158 | 1158 | <th scope="row"><label |
1159 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
1159 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
1160 | 1160 | <td> |
1161 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
1162 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
1161 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
1162 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
1163 | 1163 | |
1164 | 1164 | </td> |
1165 | 1165 | </tr> |
@@ -1177,9 +1177,9 @@ discard block |
||
1177 | 1177 | <?php |
1178 | 1178 | } |
1179 | 1179 | |
1180 | - public function customizer_settings($wp_customize){ |
|
1180 | + public function customizer_settings($wp_customize) { |
|
1181 | 1181 | $wp_customize->add_section('aui_settings', array( |
1182 | - 'title' => __('AyeCode UI','aui'), |
|
1182 | + 'title' => __('AyeCode UI', 'aui'), |
|
1183 | 1183 | 'priority' => 120, |
1184 | 1184 | )); |
1185 | 1185 | |
@@ -1193,8 +1193,8 @@ discard block |
||
1193 | 1193 | 'type' => 'option', |
1194 | 1194 | 'transport' => 'refresh', |
1195 | 1195 | )); |
1196 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1197 | - 'label' => __('Primary Color','aui'), |
|
1196 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1197 | + 'label' => __('Primary Color', 'aui'), |
|
1198 | 1198 | 'section' => 'aui_settings', |
1199 | 1199 | 'settings' => 'aui_options[color_primary]', |
1200 | 1200 | ))); |
@@ -1206,8 +1206,8 @@ discard block |
||
1206 | 1206 | 'type' => 'option', |
1207 | 1207 | 'transport' => 'refresh', |
1208 | 1208 | )); |
1209 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1210 | - 'label' => __('Secondary Color','aui'), |
|
1209 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1210 | + 'label' => __('Secondary Color', 'aui'), |
|
1211 | 1211 | 'section' => 'aui_settings', |
1212 | 1212 | 'settings' => 'aui_options[color_secondary]', |
1213 | 1213 | ))); |
@@ -1233,12 +1233,12 @@ discard block |
||
1233 | 1233 | .collapse.show:not(.in){display: inherit;} |
1234 | 1234 | .fade.show{opacity: 1;} |
1235 | 1235 | |
1236 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
1236 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
1237 | 1237 | /* KLEO theme specific */ |
1238 | 1238 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: inherit !important;} |
1239 | 1239 | <?php } ?> |
1240 | 1240 | |
1241 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1241 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1242 | 1242 | /* With Avada builder */ |
1243 | 1243 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
1244 | 1244 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | <?php } ?> |
1247 | 1247 | </style> |
1248 | 1248 | <?php |
1249 | - return str_replace( array( |
|
1249 | + return str_replace(array( |
|
1250 | 1250 | '<style>', |
1251 | 1251 | '</style>' |
1252 | 1252 | ), '', ob_get_clean()); |
@@ -1266,16 +1266,16 @@ discard block |
||
1266 | 1266 | <?php |
1267 | 1267 | |
1268 | 1268 | // BS v3 compat |
1269 | - if( self::is_bs3_compat() ){ |
|
1269 | + if (self::is_bs3_compat()) { |
|
1270 | 1270 | echo self::bs3_compat_css(); |
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1274 | - echo self::css_primary($primary_color,$compatibility); |
|
1273 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
1274 | + echo self::css_primary($primary_color, $compatibility); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1278 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1277 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
1278 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | // Set admin bar z-index lower when modal is open. |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | /* |
1289 | 1289 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1290 | 1290 | */ |
1291 | - return str_replace( array( |
|
1291 | + return str_replace(array( |
|
1292 | 1292 | '<style>', |
1293 | 1293 | '</style>' |
1294 | 1294 | ), '', ob_get_clean()); |
@@ -1299,48 +1299,48 @@ discard block |
||
1299 | 1299 | * |
1300 | 1300 | * @return bool |
1301 | 1301 | */ |
1302 | - public static function is_bs3_compat(){ |
|
1302 | + public static function is_bs3_compat() { |
|
1303 | 1303 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
1304 | 1304 | } |
1305 | 1305 | |
1306 | - public static function css_primary($color_code,$compatibility){; |
|
1306 | + public static function css_primary($color_code, $compatibility) {; |
|
1307 | 1307 | $color_code = sanitize_hex_color($color_code); |
1308 | - if(!$color_code){return '';} |
|
1308 | + if (!$color_code) {return ''; } |
|
1309 | 1309 | /** |
1310 | 1310 | * c = color, b = background color, o = border-color, f = fill |
1311 | 1311 | */ |
1312 | 1312 | $selectors = array( |
1313 | 1313 | 'a' => array('c'), |
1314 | - '.btn-primary' => array('b','o'), |
|
1315 | - '.btn-primary.disabled' => array('b','o'), |
|
1316 | - '.btn-primary:disabled' => array('b','o'), |
|
1317 | - '.btn-outline-primary' => array('c','o'), |
|
1318 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1319 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1320 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1321 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1314 | + '.btn-primary' => array('b', 'o'), |
|
1315 | + '.btn-primary.disabled' => array('b', 'o'), |
|
1316 | + '.btn-primary:disabled' => array('b', 'o'), |
|
1317 | + '.btn-outline-primary' => array('c', 'o'), |
|
1318 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
1319 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1320 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1321 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
1322 | 1322 | '.btn-link' => array('c'), |
1323 | 1323 | '.dropdown-item.active' => array('b'), |
1324 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1325 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1324 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
1325 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
1326 | 1326 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1327 | 1327 | // '.custom-range::-moz-range-thumb' => array('b'), |
1328 | 1328 | // '.custom-range::-ms-thumb' => array('b'), |
1329 | 1329 | '.nav-pills .nav-link.active' => array('b'), |
1330 | 1330 | '.nav-pills .show>.nav-link' => array('b'), |
1331 | 1331 | '.page-link' => array('c'), |
1332 | - '.page-item.active .page-link' => array('b','o'), |
|
1332 | + '.page-item.active .page-link' => array('b', 'o'), |
|
1333 | 1333 | '.badge-primary' => array('b'), |
1334 | - '.alert-primary' => array('b','o'), |
|
1334 | + '.alert-primary' => array('b', 'o'), |
|
1335 | 1335 | '.progress-bar' => array('b'), |
1336 | - '.list-group-item.active' => array('b','o'), |
|
1337 | - '.bg-primary' => array('b','f'), |
|
1336 | + '.list-group-item.active' => array('b', 'o'), |
|
1337 | + '.bg-primary' => array('b', 'f'), |
|
1338 | 1338 | '.btn-link.btn-primary' => array('c'), |
1339 | 1339 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
1340 | 1340 | ); |
1341 | 1341 | |
1342 | 1342 | $important_selectors = array( |
1343 | - '.bg-primary' => array('b','f'), |
|
1343 | + '.bg-primary' => array('b', 'f'), |
|
1344 | 1344 | '.border-primary' => array('o'), |
1345 | 1345 | '.text-primary' => array('c'), |
1346 | 1346 | ); |
@@ -1357,116 +1357,116 @@ discard block |
||
1357 | 1357 | $output = ''; |
1358 | 1358 | |
1359 | 1359 | // build rules into each type |
1360 | - foreach($selectors as $selector => $types){ |
|
1361 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1362 | - $types = array_combine($types,$types); |
|
1363 | - if(isset($types['c'])){$color[] = $selector;} |
|
1364 | - if(isset($types['b'])){$background[] = $selector;} |
|
1365 | - if(isset($types['o'])){$border[] = $selector;} |
|
1366 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1360 | + foreach ($selectors as $selector => $types) { |
|
1361 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1362 | + $types = array_combine($types, $types); |
|
1363 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1364 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1365 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1366 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | // build rules into each type |
1370 | - foreach($important_selectors as $selector => $types){ |
|
1371 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1372 | - $types = array_combine($types,$types); |
|
1373 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1374 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1375 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1376 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1370 | + foreach ($important_selectors as $selector => $types) { |
|
1371 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1372 | + $types = array_combine($types, $types); |
|
1373 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1374 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1375 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1376 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | // add any color rules |
1380 | - if(!empty($color)){ |
|
1381 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1380 | + if (!empty($color)) { |
|
1381 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1382 | 1382 | } |
1383 | - if(!empty($color_i)){ |
|
1384 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1383 | + if (!empty($color_i)) { |
|
1384 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | // add any background color rules |
1388 | - if(!empty($background)){ |
|
1389 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1388 | + if (!empty($background)) { |
|
1389 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1390 | 1390 | } |
1391 | - if(!empty($background_i)){ |
|
1392 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1391 | + if (!empty($background_i)) { |
|
1392 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | // add any border color rules |
1396 | - if(!empty($border)){ |
|
1397 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1396 | + if (!empty($border)) { |
|
1397 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1398 | 1398 | } |
1399 | - if(!empty($border_i)){ |
|
1400 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1399 | + if (!empty($border_i)) { |
|
1400 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1401 | 1401 | } |
1402 | 1402 | |
1403 | 1403 | // add any fill color rules |
1404 | - if(!empty($fill)){ |
|
1405 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1404 | + if (!empty($fill)) { |
|
1405 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1406 | 1406 | } |
1407 | - if(!empty($fill_i)){ |
|
1408 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1407 | + if (!empty($fill_i)) { |
|
1408 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | |
1412 | 1412 | $prefix = $compatibility ? ".bsui " : ""; |
1413 | 1413 | |
1414 | 1414 | // darken |
1415 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1416 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1417 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1415 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1416 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1417 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1418 | 1418 | |
1419 | 1419 | // lighten |
1420 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1420 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1421 | 1421 | |
1422 | 1422 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1423 | - $op_25 = $color_code."40"; // 25% opacity |
|
1423 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1424 | 1424 | |
1425 | 1425 | |
1426 | 1426 | // button states |
1427 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1428 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1429 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1430 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1427 | + $output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1428 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1429 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1430 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1431 | 1431 | |
1432 | 1432 | |
1433 | 1433 | // dropdown's |
1434 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1434 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1435 | 1435 | |
1436 | 1436 | |
1437 | 1437 | // input states |
1438 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1438 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1439 | 1439 | |
1440 | 1440 | // page link |
1441 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1441 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1442 | 1442 | |
1443 | 1443 | return $output; |
1444 | 1444 | } |
1445 | 1445 | |
1446 | - public static function css_secondary($color_code,$compatibility){; |
|
1446 | + public static function css_secondary($color_code, $compatibility) {; |
|
1447 | 1447 | $color_code = sanitize_hex_color($color_code); |
1448 | - if(!$color_code){return '';} |
|
1448 | + if (!$color_code) {return ''; } |
|
1449 | 1449 | /** |
1450 | 1450 | * c = color, b = background color, o = border-color, f = fill |
1451 | 1451 | */ |
1452 | 1452 | $selectors = array( |
1453 | - '.btn-secondary' => array('b','o'), |
|
1454 | - '.btn-secondary.disabled' => array('b','o'), |
|
1455 | - '.btn-secondary:disabled' => array('b','o'), |
|
1456 | - '.btn-outline-secondary' => array('c','o'), |
|
1457 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1453 | + '.btn-secondary' => array('b', 'o'), |
|
1454 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
1455 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
1456 | + '.btn-outline-secondary' => array('c', 'o'), |
|
1457 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
1458 | 1458 | '.btn-outline-secondary.disabled' => array('c'), |
1459 | 1459 | '.btn-outline-secondary:disabled' => array('c'), |
1460 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1461 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1462 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1460 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1461 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1462 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
1463 | 1463 | '.badge-secondary' => array('b'), |
1464 | - '.alert-secondary' => array('b','o'), |
|
1464 | + '.alert-secondary' => array('b', 'o'), |
|
1465 | 1465 | '.btn-link.btn-secondary' => array('c'), |
1466 | 1466 | ); |
1467 | 1467 | |
1468 | 1468 | $important_selectors = array( |
1469 | - '.bg-secondary' => array('b','f'), |
|
1469 | + '.bg-secondary' => array('b', 'f'), |
|
1470 | 1470 | '.border-secondary' => array('o'), |
1471 | 1471 | '.text-secondary' => array('c'), |
1472 | 1472 | ); |
@@ -1483,77 +1483,77 @@ discard block |
||
1483 | 1483 | $output = ''; |
1484 | 1484 | |
1485 | 1485 | // build rules into each type |
1486 | - foreach($selectors as $selector => $types){ |
|
1487 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1488 | - $types = array_combine($types,$types); |
|
1489 | - if(isset($types['c'])){$color[] = $selector;} |
|
1490 | - if(isset($types['b'])){$background[] = $selector;} |
|
1491 | - if(isset($types['o'])){$border[] = $selector;} |
|
1492 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1486 | + foreach ($selectors as $selector => $types) { |
|
1487 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1488 | + $types = array_combine($types, $types); |
|
1489 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1490 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1491 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1492 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | // build rules into each type |
1496 | - foreach($important_selectors as $selector => $types){ |
|
1497 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1498 | - $types = array_combine($types,$types); |
|
1499 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1500 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1501 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1502 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1496 | + foreach ($important_selectors as $selector => $types) { |
|
1497 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1498 | + $types = array_combine($types, $types); |
|
1499 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1500 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1501 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1502 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | // add any color rules |
1506 | - if(!empty($color)){ |
|
1507 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1506 | + if (!empty($color)) { |
|
1507 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1508 | 1508 | } |
1509 | - if(!empty($color_i)){ |
|
1510 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1509 | + if (!empty($color_i)) { |
|
1510 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | // add any background color rules |
1514 | - if(!empty($background)){ |
|
1515 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1514 | + if (!empty($background)) { |
|
1515 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1516 | 1516 | } |
1517 | - if(!empty($background_i)){ |
|
1518 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1517 | + if (!empty($background_i)) { |
|
1518 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | // add any border color rules |
1522 | - if(!empty($border)){ |
|
1523 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1522 | + if (!empty($border)) { |
|
1523 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1524 | 1524 | } |
1525 | - if(!empty($border_i)){ |
|
1526 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1525 | + if (!empty($border_i)) { |
|
1526 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | // add any fill color rules |
1530 | - if(!empty($fill)){ |
|
1531 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1530 | + if (!empty($fill)) { |
|
1531 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1532 | 1532 | } |
1533 | - if(!empty($fill_i)){ |
|
1534 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1533 | + if (!empty($fill_i)) { |
|
1534 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | |
1538 | 1538 | $prefix = $compatibility ? ".bsui " : ""; |
1539 | 1539 | |
1540 | 1540 | // darken |
1541 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1542 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1543 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1541 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1542 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1543 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1544 | 1544 | |
1545 | 1545 | // lighten |
1546 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1546 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1547 | 1547 | |
1548 | 1548 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1549 | - $op_25 = $color_code."40"; // 25% opacity |
|
1549 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1550 | 1550 | |
1551 | 1551 | |
1552 | 1552 | // button states |
1553 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1554 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1555 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1556 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1553 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1554 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1555 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1556 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1557 | 1557 | |
1558 | 1558 | |
1559 | 1559 | return $output; |
@@ -1589,8 +1589,8 @@ discard block |
||
1589 | 1589 | /** |
1590 | 1590 | * Check if we should display examples. |
1591 | 1591 | */ |
1592 | - public function maybe_show_examples(){ |
|
1593 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1592 | + public function maybe_show_examples() { |
|
1593 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
1594 | 1594 | echo "<head>"; |
1595 | 1595 | wp_head(); |
1596 | 1596 | echo "</head>"; |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | * |
1607 | 1607 | * @return string |
1608 | 1608 | */ |
1609 | - public function get_examples(){ |
|
1609 | + public function get_examples() { |
|
1610 | 1610 | $output = ''; |
1611 | 1611 | |
1612 | 1612 | |
@@ -1712,74 +1712,74 @@ discard block |
||
1712 | 1712 | */ |
1713 | 1713 | public static function calendar_params() { |
1714 | 1714 | $params = array( |
1715 | - 'month_long_1' => __( 'January', 'aui' ), |
|
1716 | - 'month_long_2' => __( 'February', 'aui' ), |
|
1717 | - 'month_long_3' => __( 'March', 'aui' ), |
|
1718 | - 'month_long_4' => __( 'April', 'aui' ), |
|
1719 | - 'month_long_5' => __( 'May', 'aui' ), |
|
1720 | - 'month_long_6' => __( 'June', 'aui' ), |
|
1721 | - 'month_long_7' => __( 'July', 'aui' ), |
|
1722 | - 'month_long_8' => __( 'August', 'aui' ), |
|
1723 | - 'month_long_9' => __( 'September', 'aui' ), |
|
1724 | - 'month_long_10' => __( 'October', 'aui' ), |
|
1725 | - 'month_long_11' => __( 'November', 'aui' ), |
|
1726 | - 'month_long_12' => __( 'December', 'aui' ), |
|
1727 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1728 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1729 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1730 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1731 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1732 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1733 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1734 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1735 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1736 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1737 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1738 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1739 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1740 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1741 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1742 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1743 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1744 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1745 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1746 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
1747 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1748 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1749 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
1750 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
1751 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1752 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1753 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1754 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1755 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1756 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1757 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1758 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1759 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1760 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1761 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1762 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1763 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1764 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1765 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1766 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1767 | - 'am_lower' => __( 'am', 'aui' ), |
|
1768 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
1769 | - 'am_upper' => __( 'AM', 'aui' ), |
|
1770 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
1771 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1715 | + 'month_long_1' => __('January', 'aui'), |
|
1716 | + 'month_long_2' => __('February', 'aui'), |
|
1717 | + 'month_long_3' => __('March', 'aui'), |
|
1718 | + 'month_long_4' => __('April', 'aui'), |
|
1719 | + 'month_long_5' => __('May', 'aui'), |
|
1720 | + 'month_long_6' => __('June', 'aui'), |
|
1721 | + 'month_long_7' => __('July', 'aui'), |
|
1722 | + 'month_long_8' => __('August', 'aui'), |
|
1723 | + 'month_long_9' => __('September', 'aui'), |
|
1724 | + 'month_long_10' => __('October', 'aui'), |
|
1725 | + 'month_long_11' => __('November', 'aui'), |
|
1726 | + 'month_long_12' => __('December', 'aui'), |
|
1727 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'aui'), |
|
1728 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'aui'), |
|
1729 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'aui'), |
|
1730 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'aui'), |
|
1731 | + 'month_s_5' => _x('May', 'May abbreviation', 'aui'), |
|
1732 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'aui'), |
|
1733 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'aui'), |
|
1734 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'aui'), |
|
1735 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'aui'), |
|
1736 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'aui'), |
|
1737 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'aui'), |
|
1738 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'aui'), |
|
1739 | + 'day_s1_1' => _x('S', 'Sunday initial', 'aui'), |
|
1740 | + 'day_s1_2' => _x('M', 'Monday initial', 'aui'), |
|
1741 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'aui'), |
|
1742 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'aui'), |
|
1743 | + 'day_s1_5' => _x('T', 'Friday initial', 'aui'), |
|
1744 | + 'day_s1_6' => _x('F', 'Thursday initial', 'aui'), |
|
1745 | + 'day_s1_7' => _x('S', 'Saturday initial', 'aui'), |
|
1746 | + 'day_s2_1' => __('Su', 'aui'), |
|
1747 | + 'day_s2_2' => __('Mo', 'aui'), |
|
1748 | + 'day_s2_3' => __('Tu', 'aui'), |
|
1749 | + 'day_s2_4' => __('We', 'aui'), |
|
1750 | + 'day_s2_5' => __('Th', 'aui'), |
|
1751 | + 'day_s2_6' => __('Fr', 'aui'), |
|
1752 | + 'day_s2_7' => __('Sa', 'aui'), |
|
1753 | + 'day_s3_1' => __('Sun', 'aui'), |
|
1754 | + 'day_s3_2' => __('Mon', 'aui'), |
|
1755 | + 'day_s3_3' => __('Tue', 'aui'), |
|
1756 | + 'day_s3_4' => __('Wed', 'aui'), |
|
1757 | + 'day_s3_5' => __('Thu', 'aui'), |
|
1758 | + 'day_s3_6' => __('Fri', 'aui'), |
|
1759 | + 'day_s3_7' => __('Sat', 'aui'), |
|
1760 | + 'day_s5_1' => __('Sunday', 'aui'), |
|
1761 | + 'day_s5_2' => __('Monday', 'aui'), |
|
1762 | + 'day_s5_3' => __('Tuesday', 'aui'), |
|
1763 | + 'day_s5_4' => __('Wednesday', 'aui'), |
|
1764 | + 'day_s5_5' => __('Thursday', 'aui'), |
|
1765 | + 'day_s5_6' => __('Friday', 'aui'), |
|
1766 | + 'day_s5_7' => __('Saturday', 'aui'), |
|
1767 | + 'am_lower' => __('am', 'aui'), |
|
1768 | + 'pm_lower' => __('pm', 'aui'), |
|
1769 | + 'am_upper' => __('AM', 'aui'), |
|
1770 | + 'pm_upper' => __('PM', 'aui'), |
|
1771 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
1772 | 1772 | 'time_24hr' => false, |
1773 | - 'year' => __( 'Year', 'aui' ), |
|
1774 | - 'hour' => __( 'Hour', 'aui' ), |
|
1775 | - 'minute' => __( 'Minute', 'aui' ), |
|
1776 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1777 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1778 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1779 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1773 | + 'year' => __('Year', 'aui'), |
|
1774 | + 'hour' => __('Hour', 'aui'), |
|
1775 | + 'minute' => __('Minute', 'aui'), |
|
1776 | + 'weekAbbreviation' => __('Wk', 'aui'), |
|
1777 | + 'rangeSeparator' => __(' to ', 'aui'), |
|
1778 | + 'scrollTitle' => __('Scroll to increment', 'aui'), |
|
1779 | + 'toggleTitle' => __('Click to toggle', 'aui') |
|
1780 | 1780 | ); |
1781 | 1781 | |
1782 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1782 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
1783 | 1783 | } |
1784 | 1784 | |
1785 | 1785 | /** |
@@ -1792,47 +1792,47 @@ discard block |
||
1792 | 1792 | public static function flatpickr_locale() { |
1793 | 1793 | $params = self::calendar_params(); |
1794 | 1794 | |
1795 | - if ( is_string( $params ) ) { |
|
1796 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1795 | + if (is_string($params)) { |
|
1796 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
1797 | 1797 | } else { |
1798 | - foreach ( (array) $params as $key => $value ) { |
|
1799 | - if ( ! is_scalar( $value ) ) { |
|
1798 | + foreach ((array) $params as $key => $value) { |
|
1799 | + if (!is_scalar($value)) { |
|
1800 | 1800 | continue; |
1801 | 1801 | } |
1802 | 1802 | |
1803 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1803 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1804 | 1804 | } |
1805 | 1805 | } |
1806 | 1806 | |
1807 | 1807 | $day_s3 = array(); |
1808 | 1808 | $day_s5 = array(); |
1809 | 1809 | |
1810 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
1811 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1812 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1810 | + for ($i = 1; $i <= 7; $i++) { |
|
1811 | + $day_s3[] = addslashes($params['day_s3_' . $i]); |
|
1812 | + $day_s5[] = addslashes($params['day_s3_' . $i]); |
|
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | $month_s = array(); |
1816 | 1816 | $month_long = array(); |
1817 | 1817 | |
1818 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
1819 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1820 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1818 | + for ($i = 1; $i <= 12; $i++) { |
|
1819 | + $month_s[] = addslashes($params['month_s_' . $i]); |
|
1820 | + $month_long[] = addslashes($params['month_long_' . $i]); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | ob_start(); |
1824 | -if ( 0 ) { ?><script><?php } ?> |
|
1824 | +if (0) { ?><script><?php } ?> |
|
1825 | 1825 | { |
1826 | 1826 | weekdays: { |
1827 | - shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
|
1828 | - longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
|
1827 | + shorthand: ['<?php echo implode("','", $day_s3); ?>'], |
|
1828 | + longhand: ['<?php echo implode("','", $day_s5); ?>'], |
|
1829 | 1829 | }, |
1830 | 1830 | months: { |
1831 | - shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
|
1832 | - longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
|
1831 | + shorthand: ['<?php echo implode("','", $month_s); ?>'], |
|
1832 | + longhand: ['<?php echo implode("','", $month_long); ?>'], |
|
1833 | 1833 | }, |
1834 | 1834 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
1835 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
1835 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
1836 | 1836 | ordinal: function (nth) { |
1837 | 1837 | var s = nth % 100; |
1838 | 1838 | if (s > 3 && s < 21) |
@@ -1848,21 +1848,21 @@ discard block |
||
1848 | 1848 | return "th"; |
1849 | 1849 | } |
1850 | 1850 | }, |
1851 | - rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
|
1852 | - weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
|
1853 | - scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
|
1854 | - toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
|
1855 | - amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
|
1856 | - yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
|
1857 | - hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
|
1858 | - minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
|
1859 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
1851 | + rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>', |
|
1852 | + weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>', |
|
1853 | + scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>', |
|
1854 | + toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>', |
|
1855 | + amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'], |
|
1856 | + yearAriaLabel: '<?php echo addslashes($params['year']); ?>', |
|
1857 | + hourAriaLabel: '<?php echo addslashes($params['hour']); ?>', |
|
1858 | + minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>', |
|
1859 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
1860 | 1860 | } |
1861 | -<?php if ( 0 ) { ?></script><?php } ?> |
|
1861 | +<?php if (0) { ?></script><?php } ?> |
|
1862 | 1862 | <?php |
1863 | 1863 | $locale = ob_get_clean(); |
1864 | 1864 | |
1865 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
1865 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | /** |
@@ -1874,20 +1874,20 @@ discard block |
||
1874 | 1874 | */ |
1875 | 1875 | public static function select2_params() { |
1876 | 1876 | $params = array( |
1877 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
1878 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
1879 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
1880 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
1881 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
1882 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
1883 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
1884 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
1885 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
1886 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
1887 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
1877 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'aui'), |
|
1878 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'aui'), |
|
1879 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'aui'), |
|
1880 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'aui'), |
|
1881 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'aui'), |
|
1882 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'aui'), |
|
1883 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'aui'), |
|
1884 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'), |
|
1885 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'), |
|
1886 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'aui'), |
|
1887 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'aui') |
|
1888 | 1888 | ); |
1889 | 1889 | |
1890 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
1890 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | /** |
@@ -1900,17 +1900,17 @@ discard block |
||
1900 | 1900 | public static function select2_locale() { |
1901 | 1901 | $params = self::select2_params(); |
1902 | 1902 | |
1903 | - foreach ( (array) $params as $key => $value ) { |
|
1904 | - if ( ! is_scalar( $value ) ) { |
|
1903 | + foreach ((array) $params as $key => $value) { |
|
1904 | + if (!is_scalar($value)) { |
|
1905 | 1905 | continue; |
1906 | 1906 | } |
1907 | 1907 | |
1908 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1908 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1909 | 1909 | } |
1910 | 1910 | |
1911 | - $locale = json_encode( $params ); |
|
1911 | + $locale = json_encode($params); |
|
1912 | 1912 | |
1913 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
1913 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
1914 | 1914 | } |
1915 | 1915 | } |
1916 | 1916 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | 28 | |
29 | - $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' ); |
|
30 | - $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' ); |
|
29 | + $this->templates_dir = apply_filters('getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates'); |
|
30 | + $this->templates_url = apply_filters('getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates'); |
|
31 | 31 | |
32 | 32 | // Oxygen plugin |
33 | - if ( defined( 'CT_VERSION' ) ) { |
|
34 | - add_filter( 'wpinv_locate_template', array( $this, 'oxygen_override_template' ), 11, 4 ); |
|
33 | + if (defined('CT_VERSION')) { |
|
34 | + add_filter('wpinv_locate_template', array($this, 'oxygen_override_template'), 11, 4); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | public function is_elementor_preview() { |
63 | - return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
63 | + return isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return bool |
71 | 71 | */ |
72 | 72 | public function is_divi_preview() { |
73 | - return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
73 | + return isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'et_pb'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return bool |
81 | 81 | */ |
82 | 82 | public function is_beaver_preview() { |
83 | - return isset( $_REQUEST['fl_builder'] ); |
|
83 | + return isset($_REQUEST['fl_builder']); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return bool |
91 | 91 | */ |
92 | 92 | public function is_siteorigin_preview() { |
93 | - return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
93 | + return !empty($_REQUEST['siteorigin_panels_live_editor']); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return bool |
101 | 101 | */ |
102 | 102 | public function is_cornerstone_preview() { |
103 | - return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
103 | + return !empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint'; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return bool |
111 | 111 | */ |
112 | 112 | public function is_fusion_preview() { |
113 | - return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
113 | + return !empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce']); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @return bool |
121 | 121 | */ |
122 | 122 | public function is_oxygen_preview() { |
123 | - return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
123 | + return !empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_")); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,24 +130,24 @@ discard block |
||
130 | 130 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
131 | 131 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
132 | 132 | */ |
133 | - public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
133 | + public function locate_template($template_name, $template_path = '', $default_path = '') { |
|
134 | 134 | |
135 | 135 | // Load the defaults for the template path and default path. |
136 | - $template_path = empty( $template_path ) ? 'invoicing' : $template_path; |
|
137 | - $default_path = empty( $default_path ) ? $this->templates_dir : $default_path; |
|
138 | - $default_path = apply_filters( 'getpaid_template_default_template_path', $default_path, $template_name ); |
|
136 | + $template_path = empty($template_path) ? 'invoicing' : $template_path; |
|
137 | + $default_path = empty($default_path) ? $this->templates_dir : $default_path; |
|
138 | + $default_path = apply_filters('getpaid_template_default_template_path', $default_path, $template_name); |
|
139 | 139 | |
140 | 140 | // Is it overidden? |
141 | 141 | $template = locate_template( |
142 | - array( trailingslashit( $template_path ) . $template_name, 'wpinv-' . $template_name ) |
|
142 | + array(trailingslashit($template_path) . $template_name, 'wpinv-' . $template_name) |
|
143 | 143 | ); |
144 | 144 | |
145 | 145 | // If not, load the default template. |
146 | - if ( empty( $template ) ) { |
|
147 | - $template = trailingslashit( $default_path ) . $template_name; |
|
146 | + if (empty($template)) { |
|
147 | + $template = trailingslashit($default_path) . $template_name; |
|
148 | 148 | } |
149 | 149 | |
150 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path ); |
|
150 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path, $default_path); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | * @since 1.0.19 |
157 | 157 | * @return bool |
158 | 158 | */ |
159 | - protected function load_template( $template_name, $template_path, $args ) { |
|
159 | + protected function load_template($template_name, $template_path, $args) { |
|
160 | 160 | |
161 | - if ( is_array( $args ) ){ |
|
162 | - extract( $args ); |
|
161 | + if (is_array($args)) { |
|
162 | + extract($args); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Fires before loading a template. |
166 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
166 | + do_action('wpinv_before_template_part', $template_name, $template_path, $args); |
|
167 | 167 | |
168 | 168 | // Load the template. |
169 | - include( $template_path ); |
|
169 | + include($template_path); |
|
170 | 170 | |
171 | 171 | // Fires after loading a template. |
172 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $args ); |
|
172 | + do_action('wpinv_after_template_part', $template_name, $template_path, $args); |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
184 | 184 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
185 | 185 | */ |
186 | - public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
186 | + public function display_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
187 | 187 | |
188 | 188 | // Locate the template. |
189 | - $located = $this->locate_template( $template_name, $template_path, $default_path ); |
|
189 | + $located = $this->locate_template($template_name, $template_path, $default_path); |
|
190 | 190 | |
191 | 191 | // Abort if the file does not exist. |
192 | - if ( ! file_exists( $located ) ) { |
|
193 | - getpaid_doing_it_wrong( __METHOD__, sprintf( '<code>%s</code> does not exist.', $located ), '2.0.0' ); |
|
192 | + if (!file_exists($located)) { |
|
193 | + getpaid_doing_it_wrong(__METHOD__, sprintf('<code>%s</code> does not exist.', $located), '2.0.0'); |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
197 | - $this->load_template( $template_name, $located, $args ); |
|
197 | + $this->load_template($template_name, $located, $args); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
209 | 209 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
210 | 210 | */ |
211 | - public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
211 | + public function get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
212 | 212 | ob_start(); |
213 | - $this->display_template( $template_name, $args, $template_path, $default_path ); |
|
213 | + $this->display_template($template_name, $args, $template_path, $default_path); |
|
214 | 214 | return ob_get_clean(); |
215 | 215 | } |
216 | 216 | |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public static function get_theme_template_path() { |
224 | 224 | $template = get_template(); |
225 | - $theme_root = get_theme_root( $template ); |
|
225 | + $theme_root = get_theme_root($template); |
|
226 | 226 | |
227 | - return $theme_root . '/' . $template . '/' . untrailingslashit( wpinv_get_theme_template_dir_name() ); |
|
227 | + return $theme_root . '/' . $template . '/' . untrailingslashit(wpinv_get_theme_template_dir_name()); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -234,28 +234,28 @@ discard block |
||
234 | 234 | * @param string $template The template. |
235 | 235 | * @return string The theme template. |
236 | 236 | */ |
237 | - public static function oxygen_locate_template( $template ) { |
|
237 | + public static function oxygen_locate_template($template) { |
|
238 | 238 | |
239 | - if ( empty( $template ) ) { |
|
239 | + if (empty($template)) { |
|
240 | 240 | return ''; |
241 | 241 | } |
242 | 242 | |
243 | - $has_filter = has_filter( 'template', 'ct_oxygen_template_name' ); |
|
243 | + $has_filter = has_filter('template', 'ct_oxygen_template_name'); |
|
244 | 244 | |
245 | 245 | // Remove template filter |
246 | - if ( $has_filter ) { |
|
247 | - remove_filter( 'template', 'ct_oxygen_template_name' ); |
|
246 | + if ($has_filter) { |
|
247 | + remove_filter('template', 'ct_oxygen_template_name'); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | $template = self::get_theme_template_path() . '/' . $template; |
251 | 251 | |
252 | - if ( ! file_exists( $template ) ) { |
|
252 | + if (!file_exists($template)) { |
|
253 | 253 | $template = ''; |
254 | 254 | } |
255 | 255 | |
256 | 256 | // Add template filter |
257 | - if ( $has_filter ) { |
|
258 | - add_filter( 'template', 'ct_oxygen_template_name' ); |
|
257 | + if ($has_filter) { |
|
258 | + add_filter('template', 'ct_oxygen_template_name'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $template; |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param string $template_name Template name. |
269 | 269 | * @return string Located template. |
270 | 270 | */ |
271 | - public function oxygen_override_template( $located, $template_name ) { |
|
271 | + public function oxygen_override_template($located, $template_name) { |
|
272 | 272 | |
273 | - $oxygen_overide = self::oxygen_locate_template( $template_name ); |
|
274 | - if ( ! empty( $oxygen_overide ) ) { |
|
273 | + $oxygen_overide = self::oxygen_locate_template($template_name); |
|
274 | + if (!empty($oxygen_overide)) { |
|
275 | 275 | return $oxygen_overide; |
276 | 276 | } |
277 | 277 |
@@ -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 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( ! is_array( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (!is_array($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,47 +190,47 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = wpinv_clean( $option['desc'] ); |
|
199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
200 | + $tip = wpinv_clean($option['desc']); |
|
201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
202 | - unset( $option['desc'] ); |
|
202 | + unset($option['desc']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
208 | 208 | $name, |
209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
210 | 210 | $section, |
211 | 211 | $section, |
212 | 212 | array( |
213 | 213 | 'section' => $section, |
214 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
214 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
216 | 216 | 'name' => $name, |
217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
221 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
222 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
223 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
232 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
233 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
221 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
222 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
223 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
230 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
231 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
232 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
233 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
234 | 234 | ) |
235 | 235 | ); |
236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return array |
243 | 243 | */ |
244 | 244 | function wpinv_get_registered_settings() { |
245 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
245 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return array |
252 | 252 | */ |
253 | 253 | function getpaid_get_integration_settings() { |
254 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
254 | + return apply_filters('getpaid_integration_settings', array()); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -259,144 +259,144 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function wpinv_settings_sanitize( $input = array() ) { |
|
262 | +function wpinv_settings_sanitize($input = array()) { |
|
263 | 263 | |
264 | 264 | $wpinv_options = wpinv_get_options(); |
265 | 265 | $raw_referrer = wp_get_raw_referer(); |
266 | 266 | |
267 | - if ( empty( $raw_referrer ) ) { |
|
267 | + if (empty($raw_referrer)) { |
|
268 | 268 | return $input; |
269 | 269 | } |
270 | 270 | |
271 | - wp_parse_str( $raw_referrer, $referrer ); |
|
271 | + wp_parse_str($raw_referrer, $referrer); |
|
272 | 272 | |
273 | - if ( empty( $referrer['tab'] ) ) { |
|
273 | + if (empty($referrer['tab'])) { |
|
274 | 274 | return $input; |
275 | 275 | } |
276 | 276 | |
277 | 277 | $settings = wpinv_get_registered_settings(); |
278 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
279 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
278 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
279 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
280 | 280 | |
281 | 281 | $input = $input ? $input : array(); |
282 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
283 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
282 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
283 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
284 | 284 | |
285 | 285 | // Loop through each setting being saved and pass it through a sanitization filter |
286 | - foreach ( $input as $key => $value ) { |
|
286 | + foreach ($input as $key => $value) { |
|
287 | 287 | |
288 | 288 | // Get the setting type (checkbox, select, etc) |
289 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
289 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
290 | 290 | |
291 | - if ( $type ) { |
|
291 | + if ($type) { |
|
292 | 292 | // Field type specific filter |
293 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
293 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // General filter |
297 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
297 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
298 | 298 | |
299 | 299 | // Key specific filter. |
300 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
300 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | // Loop through the whitelist and unset any that are empty for the tab being saved |
304 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
305 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
304 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
305 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
306 | 306 | |
307 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
307 | + $found_settings = array_merge($main_settings, $section_settings); |
|
308 | 308 | |
309 | - if ( ! empty( $found_settings ) ) { |
|
310 | - foreach ( $found_settings as $key => $value ) { |
|
309 | + if (!empty($found_settings)) { |
|
310 | + foreach ($found_settings as $key => $value) { |
|
311 | 311 | |
312 | 312 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
313 | - if ( is_numeric( $key ) ) { |
|
313 | + if (is_numeric($key)) { |
|
314 | 314 | $key = $value['id']; |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
318 | - unset( $wpinv_options[ $key ] ); |
|
317 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
318 | + unset($wpinv_options[$key]); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | 323 | // Merge our new settings with the existing |
324 | - $output = array_merge( $wpinv_options, $input ); |
|
324 | + $output = array_merge($wpinv_options, $input); |
|
325 | 325 | |
326 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
326 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
327 | 327 | |
328 | 328 | return $output; |
329 | 329 | } |
330 | 330 | |
331 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
331 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
332 | 332 | |
333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
334 | 334 | return $input; |
335 | 335 | } |
336 | 336 | |
337 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
337 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
338 | 338 | // Shows an admin notice about upgrading previous order numbers |
339 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
339 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | return $input; |
343 | 343 | } |
344 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
344 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
345 | 345 | |
346 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
347 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
346 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
347 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
348 | 348 | return $input; |
349 | 349 | } |
350 | 350 | |
351 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
351 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
352 | 352 | $tax_rates = array(); |
353 | 353 | |
354 | - foreach ( $new_rates as $rate ) { |
|
354 | + foreach ($new_rates as $rate) { |
|
355 | 355 | |
356 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
357 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
358 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
359 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
360 | - $rate['global'] = empty( $rate['state'] ); |
|
356 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
357 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
358 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
359 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
360 | + $rate['global'] = empty($rate['state']); |
|
361 | 361 | $tax_rates[] = $rate; |
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
365 | + update_option('wpinv_tax_rates', $tax_rates); |
|
366 | 366 | |
367 | 367 | return $input; |
368 | 368 | } |
369 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
369 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
370 | 370 | |
371 | -function wpinv_sanitize_text_field( $input ) { |
|
372 | - return trim( $input ); |
|
371 | +function wpinv_sanitize_text_field($input) { |
|
372 | + return trim($input); |
|
373 | 373 | } |
374 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
374 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
375 | 375 | |
376 | 376 | function wpinv_get_settings_tabs() { |
377 | 377 | $tabs = array(); |
378 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
379 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
380 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
381 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
378 | + $tabs['general'] = __('General', 'invoicing'); |
|
379 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
380 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
381 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
382 | 382 | |
383 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
384 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
383 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
384 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
385 | 385 | } |
386 | 386 | |
387 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
388 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
389 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
387 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
388 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
389 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
390 | 390 | |
391 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
391 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
392 | 392 | } |
393 | 393 | |
394 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
394 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
395 | 395 | $tabs = false; |
396 | 396 | $sections = wpinv_get_registered_settings_sections(); |
397 | 397 | |
398 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
399 | - $tabs = $sections[ $tab ]; |
|
398 | + if ($tab && !empty($sections[$tab])) { |
|
399 | + $tabs = $sections[$tab]; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | return $tabs; |
@@ -405,91 +405,91 @@ discard block |
||
405 | 405 | function wpinv_get_registered_settings_sections() { |
406 | 406 | static $sections = false; |
407 | 407 | |
408 | - if ( false !== $sections ) { |
|
408 | + if (false !== $sections) { |
|
409 | 409 | return $sections; |
410 | 410 | } |
411 | 411 | |
412 | 412 | $sections = array( |
413 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
414 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
415 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
416 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
417 | - ) ), |
|
418 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
419 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
420 | - ) ), |
|
421 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
422 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
423 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
424 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
425 | - ) ), |
|
426 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
427 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
428 | - ) ), |
|
429 | - |
|
430 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
431 | - |
|
432 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
433 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
434 | - ) ), |
|
435 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
436 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
437 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
438 | - ) ), |
|
439 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
440 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
441 | - ) ), |
|
413 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
414 | + 'main' => __('General Settings', 'invoicing'), |
|
415 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
416 | + 'labels' => __('Label Texts', 'invoicing'), |
|
417 | + )), |
|
418 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
419 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
420 | + )), |
|
421 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
422 | + 'main' => __('Tax Settings', 'invoicing'), |
|
423 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
424 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
425 | + )), |
|
426 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
427 | + 'main' => __('Email Settings', 'invoicing'), |
|
428 | + )), |
|
429 | + |
|
430 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
431 | + |
|
432 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
433 | + 'main' => __('Privacy policy', 'invoicing'), |
|
434 | + )), |
|
435 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
436 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
437 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
438 | + )), |
|
439 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
440 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
441 | + )), |
|
442 | 442 | ); |
443 | 443 | |
444 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
444 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
445 | 445 | |
446 | 446 | return $sections; |
447 | 447 | } |
448 | 448 | |
449 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
449 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
450 | 450 | $pages_options = array(); |
451 | 451 | |
452 | - if( $default_label !== NULL && $default_label !== false ) { |
|
453 | - $pages_options = array( '' => $default_label ); // Blank option |
|
452 | + if ($default_label !== NULL && $default_label !== false) { |
|
453 | + $pages_options = array('' => $default_label); // Blank option |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | $pages = get_pages(); |
457 | - if ( $pages ) { |
|
458 | - foreach ( $pages as $page ) { |
|
457 | + if ($pages) { |
|
458 | + foreach ($pages as $page) { |
|
459 | 459 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
460 | - $pages_options[ $page->ID ] = $title; |
|
460 | + $pages_options[$page->ID] = $title; |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
464 | 464 | return $pages_options; |
465 | 465 | } |
466 | 466 | |
467 | -function wpinv_header_callback( $args ) { |
|
468 | - if ( !empty( $args['desc'] ) ) { |
|
467 | +function wpinv_header_callback($args) { |
|
468 | + if (!empty($args['desc'])) { |
|
469 | 469 | echo $args['desc']; |
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | -function wpinv_hidden_callback( $args ) { |
|
473 | +function wpinv_hidden_callback($args) { |
|
474 | 474 | global $wpinv_options; |
475 | 475 | |
476 | - if ( isset( $args['set_value'] ) ) { |
|
476 | + if (isset($args['set_value'])) { |
|
477 | 477 | $value = $args['set_value']; |
478 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
479 | - $value = $wpinv_options[ $args['id'] ]; |
|
478 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
479 | + $value = $wpinv_options[$args['id']]; |
|
480 | 480 | } else { |
481 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
481 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
482 | 482 | } |
483 | 483 | |
484 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
484 | + if (isset($args['faux']) && true === $args['faux']) { |
|
485 | 485 | $args['readonly'] = true; |
486 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
486 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
487 | 487 | $name = ''; |
488 | 488 | } else { |
489 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
489 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
490 | 490 | } |
491 | 491 | |
492 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
493 | 493 | |
494 | 494 | echo $html; |
495 | 495 | } |
@@ -497,61 +497,61 @@ discard block |
||
497 | 497 | /** |
498 | 498 | * Displays a checkbox settings callback. |
499 | 499 | */ |
500 | -function wpinv_checkbox_callback( $args ) { |
|
500 | +function wpinv_checkbox_callback($args) { |
|
501 | 501 | |
502 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
503 | - $std = wpinv_get_option( $args['id'], $std ); |
|
504 | - $id = esc_attr( $args['id'] ); |
|
502 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
503 | + $std = wpinv_get_option($args['id'], $std); |
|
504 | + $id = esc_attr($args['id']); |
|
505 | 505 | |
506 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
506 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
507 | 507 | ?> |
508 | 508 | <fieldset> |
509 | 509 | <label> |
510 | - <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
511 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
510 | + <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
511 | + <?php echo wp_kses_post($args['desc']); ?> |
|
512 | 512 | </label> |
513 | 513 | </fieldset> |
514 | 514 | <?php |
515 | 515 | } |
516 | 516 | |
517 | -function wpinv_multicheck_callback( $args ) { |
|
517 | +function wpinv_multicheck_callback($args) { |
|
518 | 518 | |
519 | 519 | global $wpinv_options; |
520 | 520 | |
521 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
522 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
521 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
522 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
523 | 523 | |
524 | - if ( ! empty( $args['options'] ) ) { |
|
524 | + if (!empty($args['options'])) { |
|
525 | 525 | |
526 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
527 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
526 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
527 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
528 | 528 | |
529 | 529 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
530 | - foreach( $args['options'] as $key => $option ): |
|
531 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
532 | - if ( in_array( $sanitize_key, $value ) ) { |
|
530 | + foreach ($args['options'] as $key => $option): |
|
531 | + $sanitize_key = wpinv_sanitize_key($key); |
|
532 | + if (in_array($sanitize_key, $value)) { |
|
533 | 533 | $enabled = $sanitize_key; |
534 | 534 | } else { |
535 | 535 | $enabled = NULL; |
536 | 536 | } |
537 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
538 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
537 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
538 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
539 | 539 | endforeach; |
540 | 540 | echo '</div>'; |
541 | 541 | echo '<p class="description">' . $args['desc'] . '</p>'; |
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
545 | -function wpinv_payment_icons_callback( $args ) { |
|
545 | +function wpinv_payment_icons_callback($args) { |
|
546 | 546 | global $wpinv_options; |
547 | 547 | |
548 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
548 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
549 | 549 | |
550 | - if ( ! empty( $args['options'] ) ) { |
|
551 | - foreach( $args['options'] as $key => $option ) { |
|
552 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
550 | + if (!empty($args['options'])) { |
|
551 | + foreach ($args['options'] as $key => $option) { |
|
552 | + $sanitize_key = wpinv_sanitize_key($key); |
|
553 | 553 | |
554 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
554 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
555 | 555 | $enabled = $option; |
556 | 556 | } else { |
557 | 557 | $enabled = NULL; |
@@ -559,67 +559,67 @@ discard block |
||
559 | 559 | |
560 | 560 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
561 | 561 | |
562 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
562 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
563 | 563 | |
564 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
565 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
564 | + if (wpinv_string_is_image_url($key)) { |
|
565 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
566 | 566 | } else { |
567 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
567 | + $card = strtolower(str_replace(' ', '', $option)); |
|
568 | 568 | |
569 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
570 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
569 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
570 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
571 | 571 | } else { |
572 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
572 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
573 | 573 | $content_dir = WP_CONTENT_DIR; |
574 | 574 | |
575 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
575 | + if (function_exists('wp_normalize_path')) { |
|
576 | 576 | // Replaces backslashes with forward slashes for Windows systems |
577 | - $image = wp_normalize_path( $image ); |
|
578 | - $content_dir = wp_normalize_path( $content_dir ); |
|
577 | + $image = wp_normalize_path($image); |
|
578 | + $content_dir = wp_normalize_path($content_dir); |
|
579 | 579 | } |
580 | 580 | |
581 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
581 | + $image = str_replace($content_dir, content_url(), $image); |
|
582 | 582 | } |
583 | 583 | |
584 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
584 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
585 | 585 | } |
586 | 586 | echo $option . '</label>'; |
587 | 587 | } |
588 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
588 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
593 | 593 | * Displays a radio settings field. |
594 | 594 | */ |
595 | -function wpinv_radio_callback( $args ) { |
|
595 | +function wpinv_radio_callback($args) { |
|
596 | 596 | |
597 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
598 | - $std = wpinv_get_option( $args['id'], $std ); |
|
597 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
598 | + $std = wpinv_get_option($args['id'], $std); |
|
599 | 599 | ?> |
600 | 600 | <fieldset> |
601 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
602 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
601 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
602 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
603 | 603 | <li> |
604 | 604 | <label> |
605 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
606 | - <?php echo wp_kses_post( $option ); ?> |
|
605 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
606 | + <?php echo wp_kses_post($option); ?> |
|
607 | 607 | </label> |
608 | 608 | </li> |
609 | 609 | <?php endforeach; ?> |
610 | 610 | </ul> |
611 | 611 | </fieldset> |
612 | 612 | <?php |
613 | - getpaid_settings_description_callback( $args ); |
|
613 | + getpaid_settings_description_callback($args); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
617 | 617 | * Displays a description if available. |
618 | 618 | */ |
619 | -function getpaid_settings_description_callback( $args ) { |
|
619 | +function getpaid_settings_description_callback($args) { |
|
620 | 620 | |
621 | - if ( ! empty( $args['desc'] ) ) { |
|
622 | - $description = wp_kses_post( $args['desc'] ); |
|
621 | + if (!empty($args['desc'])) { |
|
622 | + $description = wp_kses_post($args['desc']); |
|
623 | 623 | echo "<p class='description'>$description</p>"; |
624 | 624 | } |
625 | 625 | |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | </tr> |
636 | 636 | <tr class="bsui"> |
637 | 637 | <td colspan="2" class="p-0"> |
638 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
638 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
639 | 639 | |
640 | 640 | <?php |
641 | 641 | } |
@@ -643,22 +643,22 @@ discard block |
||
643 | 643 | function wpinv_gateway_select_callback($args) { |
644 | 644 | global $wpinv_options; |
645 | 645 | |
646 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
647 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
646 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
647 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
648 | 648 | |
649 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
649 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
650 | 650 | |
651 | - foreach ( $args['options'] as $key => $option ) : |
|
652 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
653 | - $selected = selected( $key, $args['selected'], false ); |
|
651 | + foreach ($args['options'] as $key => $option) : |
|
652 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
653 | + $selected = selected($key, $args['selected'], false); |
|
654 | 654 | } else { |
655 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
655 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
656 | 656 | } |
657 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
657 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
658 | 658 | endforeach; |
659 | 659 | |
660 | 660 | echo '</select>'; |
661 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
661 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -667,28 +667,28 @@ discard block |
||
667 | 667 | * @param array $args |
668 | 668 | * @return string |
669 | 669 | */ |
670 | -function wpinv_settings_attrs_helper( $args ) { |
|
670 | +function wpinv_settings_attrs_helper($args) { |
|
671 | 671 | |
672 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
673 | - $id = esc_attr( $args['id'] ); |
|
674 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
672 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
673 | + $id = esc_attr($args['id']); |
|
674 | + $placeholder = esc_attr($args['placeholder']); |
|
675 | 675 | |
676 | - if ( ! empty( $args['faux'] ) ) { |
|
676 | + if (!empty($args['faux'])) { |
|
677 | 677 | $args['readonly'] = true; |
678 | 678 | $name = ''; |
679 | 679 | } else { |
680 | - $value = wpinv_get_option( $args['id'], $value ); |
|
680 | + $value = wpinv_get_option($args['id'], $value); |
|
681 | 681 | $name = "wpinv_settings[$id]"; |
682 | 682 | } |
683 | 683 | |
684 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
685 | - $class = esc_attr( $args['class'] ); |
|
686 | - $style = esc_attr( $args['style'] ); |
|
687 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
684 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
685 | + $class = esc_attr($args['class']); |
|
686 | + $style = esc_attr($args['style']); |
|
687 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
688 | 688 | |
689 | 689 | $onchange = ''; |
690 | - if ( ! empty( $args['onchange'] ) ) { |
|
691 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
690 | + if (!empty($args['onchange'])) { |
|
691 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -697,11 +697,11 @@ discard block |
||
697 | 697 | /** |
698 | 698 | * Displays a text input settings callback. |
699 | 699 | */ |
700 | -function wpinv_text_callback( $args ) { |
|
700 | +function wpinv_text_callback($args) { |
|
701 | 701 | |
702 | - $desc = wp_kses_post( $args['desc'] ); |
|
703 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
702 | + $desc = wp_kses_post($args['desc']); |
|
703 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
704 | + $attr = wpinv_settings_attrs_helper($args); |
|
705 | 705 | |
706 | 706 | ?> |
707 | 707 | <label style="width: 100%;"> |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | /** |
716 | 716 | * Displays a number input settings callback. |
717 | 717 | */ |
718 | -function wpinv_number_callback( $args ) { |
|
718 | +function wpinv_number_callback($args) { |
|
719 | 719 | |
720 | - $desc = wp_kses_post( $args['desc'] ); |
|
721 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
722 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
723 | - $max = intval( $args['max'] ); |
|
724 | - $min = intval( $args['min'] ); |
|
725 | - $step = floatval( $args['step'] ); |
|
720 | + $desc = wp_kses_post($args['desc']); |
|
721 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
722 | + $attr = wpinv_settings_attrs_helper($args); |
|
723 | + $max = intval($args['max']); |
|
724 | + $min = intval($args['min']); |
|
725 | + $step = floatval($args['step']); |
|
726 | 726 | |
727 | 727 | ?> |
728 | 728 | <label style="width: 100%;"> |
@@ -733,47 +733,47 @@ discard block |
||
733 | 733 | |
734 | 734 | } |
735 | 735 | |
736 | -function wpinv_textarea_callback( $args ) { |
|
736 | +function wpinv_textarea_callback($args) { |
|
737 | 737 | global $wpinv_options; |
738 | 738 | |
739 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
739 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
740 | 740 | |
741 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
742 | - $value = $wpinv_options[ $args['id'] ]; |
|
741 | + if (isset($wpinv_options[$args['id']])) { |
|
742 | + $value = $wpinv_options[$args['id']]; |
|
743 | 743 | } else { |
744 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
744 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
745 | 745 | } |
746 | 746 | |
747 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
748 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
747 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
748 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
749 | 749 | |
750 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
751 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
750 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
751 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
752 | 752 | |
753 | 753 | echo $html; |
754 | 754 | } |
755 | 755 | |
756 | -function wpinv_password_callback( $args ) { |
|
756 | +function wpinv_password_callback($args) { |
|
757 | 757 | global $wpinv_options; |
758 | 758 | |
759 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
759 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
760 | 760 | |
761 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
762 | - $value = $wpinv_options[ $args['id'] ]; |
|
761 | + if (isset($wpinv_options[$args['id']])) { |
|
762 | + $value = $wpinv_options[$args['id']]; |
|
763 | 763 | } else { |
764 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
764 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
765 | 765 | } |
766 | 766 | |
767 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
768 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
769 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
767 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
768 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
769 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
770 | 770 | |
771 | 771 | echo $html; |
772 | 772 | } |
773 | 773 | |
774 | 774 | function wpinv_missing_callback($args) { |
775 | 775 | printf( |
776 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
776 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
777 | 777 | '<strong>' . $args['id'] . '</strong>' |
778 | 778 | ); |
779 | 779 | } |
@@ -781,20 +781,20 @@ discard block |
||
781 | 781 | /** |
782 | 782 | * Displays a number input settings callback. |
783 | 783 | */ |
784 | -function wpinv_select_callback( $args ) { |
|
784 | +function wpinv_select_callback($args) { |
|
785 | 785 | |
786 | - $desc = wp_kses_post( $args['desc'] ); |
|
787 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
788 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
789 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
790 | - $value = wpinv_get_option( $args['id'], $value ); |
|
786 | + $desc = wp_kses_post($args['desc']); |
|
787 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
788 | + $attr = wpinv_settings_attrs_helper($args); |
|
789 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
790 | + $value = wpinv_get_option($args['id'], $value); |
|
791 | 791 | |
792 | 792 | ?> |
793 | 793 | <label style="width: 100%;"> |
794 | 794 | <select <?php echo $attr; ?>> |
795 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
796 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
797 | - <?php endforeach;?> |
|
795 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
796 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
797 | + <?php endforeach; ?> |
|
798 | 798 | </select> |
799 | 799 | <?php echo $desc; ?> |
800 | 800 | </label> |
@@ -802,95 +802,95 @@ discard block |
||
802 | 802 | |
803 | 803 | } |
804 | 804 | |
805 | -function wpinv_color_select_callback( $args ) { |
|
805 | +function wpinv_color_select_callback($args) { |
|
806 | 806 | global $wpinv_options; |
807 | 807 | |
808 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
808 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
809 | 809 | |
810 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
811 | - $value = $wpinv_options[ $args['id'] ]; |
|
810 | + if (isset($wpinv_options[$args['id']])) { |
|
811 | + $value = $wpinv_options[$args['id']]; |
|
812 | 812 | } else { |
813 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
813 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
814 | 814 | } |
815 | 815 | |
816 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
816 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
817 | 817 | |
818 | - foreach ( $args['options'] as $option => $color ) { |
|
819 | - $selected = selected( $option, $value, false ); |
|
820 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
818 | + foreach ($args['options'] as $option => $color) { |
|
819 | + $selected = selected($option, $value, false); |
|
820 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | $html .= '</select>'; |
824 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
824 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
825 | 825 | |
826 | 826 | echo $html; |
827 | 827 | } |
828 | 828 | |
829 | -function wpinv_rich_editor_callback( $args ) { |
|
829 | +function wpinv_rich_editor_callback($args) { |
|
830 | 830 | global $wpinv_options, $wp_version; |
831 | 831 | |
832 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
832 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
833 | 833 | |
834 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
835 | - $value = $wpinv_options[ $args['id'] ]; |
|
834 | + if (isset($wpinv_options[$args['id']])) { |
|
835 | + $value = $wpinv_options[$args['id']]; |
|
836 | 836 | |
837 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
838 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
837 | + if (empty($args['allow_blank']) && empty($value)) { |
|
838 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
839 | 839 | } |
840 | 840 | } else { |
841 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
841 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
842 | 842 | } |
843 | 843 | |
844 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
844 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
845 | 845 | |
846 | 846 | $html = '<div class="getpaid-settings-editor-input">'; |
847 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
847 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
848 | 848 | ob_start(); |
849 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
849 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
850 | 850 | $html .= ob_get_clean(); |
851 | 851 | } else { |
852 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
852 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
853 | 853 | } |
854 | 854 | |
855 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
855 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
856 | 856 | |
857 | 857 | echo $html; |
858 | 858 | } |
859 | 859 | |
860 | -function wpinv_upload_callback( $args ) { |
|
860 | +function wpinv_upload_callback($args) { |
|
861 | 861 | global $wpinv_options; |
862 | 862 | |
863 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
863 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
864 | 864 | |
865 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
865 | + if (isset($wpinv_options[$args['id']])) { |
|
866 | 866 | $value = $wpinv_options[$args['id']]; |
867 | 867 | } else { |
868 | 868 | $value = isset($args['std']) ? $args['std'] : ''; |
869 | 869 | } |
870 | 870 | |
871 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
872 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
873 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
874 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
871 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
872 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
873 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
874 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
875 | 875 | |
876 | 876 | echo $html; |
877 | 877 | } |
878 | 878 | |
879 | -function wpinv_color_callback( $args ) { |
|
879 | +function wpinv_color_callback($args) { |
|
880 | 880 | global $wpinv_options; |
881 | 881 | |
882 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
882 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
883 | 883 | |
884 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
885 | - $value = $wpinv_options[ $args['id'] ]; |
|
884 | + if (isset($wpinv_options[$args['id']])) { |
|
885 | + $value = $wpinv_options[$args['id']]; |
|
886 | 886 | } else { |
887 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
887 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
888 | 888 | } |
889 | 889 | |
890 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
890 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
891 | 891 | |
892 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
893 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
892 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
893 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
894 | 894 | |
895 | 895 | echo $html; |
896 | 896 | } |
@@ -898,9 +898,9 @@ discard block |
||
898 | 898 | function wpinv_country_states_callback($args) { |
899 | 899 | global $wpinv_options; |
900 | 900 | |
901 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
901 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
902 | 902 | |
903 | - if ( isset( $args['placeholder'] ) ) { |
|
903 | + if (isset($args['placeholder'])) { |
|
904 | 904 | $placeholder = $args['placeholder']; |
905 | 905 | } else { |
906 | 906 | $placeholder = ''; |
@@ -908,16 +908,16 @@ discard block |
||
908 | 908 | |
909 | 909 | $states = wpinv_get_country_states(); |
910 | 910 | |
911 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
912 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
911 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
912 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
913 | 913 | |
914 | - foreach ( $states as $option => $name ) { |
|
915 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
916 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
914 | + foreach ($states as $option => $name) { |
|
915 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
916 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | $html .= '</select>'; |
920 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
920 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
921 | 921 | |
922 | 922 | echo $html; |
923 | 923 | } |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | </tr> |
933 | 933 | <tr class="bsui"> |
934 | 934 | <td colspan="2" class="p-0"> |
935 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
935 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
936 | 936 | |
937 | 937 | <?php |
938 | 938 | |
@@ -941,14 +941,14 @@ discard block |
||
941 | 941 | /** |
942 | 942 | * Displays a tax rate' edit row. |
943 | 943 | */ |
944 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
944 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
945 | 945 | ob_start(); |
946 | 946 | |
947 | - $key = sanitize_key( $key ); |
|
948 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
949 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
947 | + $key = sanitize_key($key); |
|
948 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
949 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
950 | 950 | |
951 | - if ( $echo ) { |
|
951 | + if ($echo) { |
|
952 | 952 | echo ob_get_clean(); |
953 | 953 | } else { |
954 | 954 | return ob_get_clean(); |
@@ -961,134 +961,134 @@ discard block |
||
961 | 961 | ob_start(); ?> |
962 | 962 | </td><tr> |
963 | 963 | <td colspan="2" class="wpinv_tools_tdbox"> |
964 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
965 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
964 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
965 | + <?php do_action('wpinv_tools_before'); ?> |
|
966 | 966 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
967 | 967 | <thead> |
968 | 968 | <tr> |
969 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
970 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
971 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
969 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
970 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
971 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
972 | 972 | </tr> |
973 | 973 | </thead> |
974 | 974 | |
975 | 975 | <tbody> |
976 | 976 | <tr> |
977 | - <td><?php _e( 'Check Pages', 'invoicing' );?></td> |
|
977 | + <td><?php _e('Check Pages', 'invoicing'); ?></td> |
|
978 | 978 | <td> |
979 | - <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
979 | + <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
980 | 980 | </td> |
981 | 981 | <td> |
982 | 982 | <a href="<?php |
983 | 983 | echo esc_url( |
984 | 984 | wp_nonce_url( |
985 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
985 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
986 | 986 | 'getpaid-nonce', |
987 | 987 | 'getpaid-nonce' |
988 | 988 | ) |
989 | 989 | ); |
990 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
990 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
991 | 991 | </td> |
992 | 992 | </tr> |
993 | 993 | <tr> |
994 | - <td><?php _e( 'Create Database Tables', 'invoicing' );?></td> |
|
994 | + <td><?php _e('Create Database Tables', 'invoicing'); ?></td> |
|
995 | 995 | <td> |
996 | - <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
996 | + <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
997 | 997 | </td> |
998 | 998 | <td> |
999 | 999 | <a href="<?php |
1000 | 1000 | echo esc_url( |
1001 | 1001 | wp_nonce_url( |
1002 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1002 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
1003 | 1003 | 'getpaid-nonce', |
1004 | 1004 | 'getpaid-nonce' |
1005 | 1005 | ) |
1006 | 1006 | ); |
1007 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
1007 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1008 | 1008 | </td> |
1009 | 1009 | </tr> |
1010 | 1010 | <tr> |
1011 | - <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td> |
|
1011 | + <td><?php _e('Migrate old invoices', 'invoicing'); ?></td> |
|
1012 | 1012 | <td> |
1013 | - <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1013 | + <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1014 | 1014 | </td> |
1015 | 1015 | <td> |
1016 | 1016 | <a href="<?php |
1017 | 1017 | echo esc_url( |
1018 | 1018 | wp_nonce_url( |
1019 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1019 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1020 | 1020 | 'getpaid-nonce', |
1021 | 1021 | 'getpaid-nonce' |
1022 | 1022 | ) |
1023 | 1023 | ); |
1024 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
1024 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1025 | 1025 | </td> |
1026 | 1026 | </tr> |
1027 | 1027 | |
1028 | 1028 | <tr> |
1029 | - <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td> |
|
1029 | + <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1030 | 1030 | <td> |
1031 | - <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1031 | + <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1032 | 1032 | </td> |
1033 | 1033 | <td> |
1034 | 1034 | <a href="<?php |
1035 | 1035 | echo esc_url( |
1036 | 1036 | wp_nonce_url( |
1037 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1037 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1038 | 1038 | 'getpaid-nonce', |
1039 | 1039 | 'getpaid-nonce' |
1040 | 1040 | ) |
1041 | 1041 | ); |
1042 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
1042 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1043 | 1043 | </td> |
1044 | 1044 | </tr> |
1045 | 1045 | |
1046 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1046 | + <?php do_action('wpinv_tools_row'); ?> |
|
1047 | 1047 | </tbody> |
1048 | 1048 | </table> |
1049 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1049 | + <?php do_action('wpinv_tools_after'); ?> |
|
1050 | 1050 | <?php |
1051 | 1051 | echo ob_get_clean(); |
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
1055 | -function wpinv_descriptive_text_callback( $args ) { |
|
1056 | - echo wp_kses_post( $args['desc'] ); |
|
1055 | +function wpinv_descriptive_text_callback($args) { |
|
1056 | + echo wp_kses_post($args['desc']); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | -function wpinv_raw_html_callback( $args ) { |
|
1059 | +function wpinv_raw_html_callback($args) { |
|
1060 | 1060 | echo $args['desc']; |
1061 | 1061 | } |
1062 | 1062 | |
1063 | -function wpinv_hook_callback( $args ) { |
|
1064 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1063 | +function wpinv_hook_callback($args) { |
|
1064 | + do_action('wpinv_' . $args['id'], $args); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | function wpinv_set_settings_cap() { |
1068 | 1068 | return wpinv_get_capability(); |
1069 | 1069 | } |
1070 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1070 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1071 | 1071 | |
1072 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1072 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1073 | 1073 | |
1074 | - if ( $key == 'tax_rate' ) { |
|
1075 | - $value = wpinv_sanitize_amount( $value ); |
|
1076 | - $value = absint( min( $value, 99 ) ); |
|
1074 | + if ($key == 'tax_rate') { |
|
1075 | + $value = wpinv_sanitize_amount($value); |
|
1076 | + $value = absint(min($value, 99)); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | return $value; |
1080 | 1080 | } |
1081 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1081 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1082 | 1082 | |
1083 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1084 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1085 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1083 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1084 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1085 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1086 | 1086 | |
1087 | - if ( $old != $new ) { |
|
1088 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1087 | + if ($old != $new) { |
|
1088 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1089 | 1089 | } |
1090 | 1090 | } |
1091 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1091 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1092 | 1092 | |
1093 | 1093 | /** |
1094 | 1094 | * Returns the merge tags help text. |
@@ -1097,16 +1097,16 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1100 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1101 | 1101 | |
1102 | 1102 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1103 | 1103 | $link = sprintf( |
1104 | 1104 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1105 | 1105 | $url, |
1106 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1106 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1107 | 1107 | ); |
1108 | 1108 | |
1109 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1109 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1110 | 1110 | |
1111 | 1111 | return "$description $link"; |
1112 | 1112 |
@@ -8,205 +8,205 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$pages = wpinv_get_pages( true ); |
|
13 | +$pages = wpinv_get_pages(true); |
|
14 | 14 | |
15 | 15 | $currencies = wpinv_get_currencies(); |
16 | 16 | |
17 | 17 | $currency_code_options = array(); |
18 | -foreach ( $currencies as $code => $name ) { |
|
19 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
18 | +foreach ($currencies as $code => $name) { |
|
19 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | $invoice_number_padd_options = array(); |
23 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
23 | +for ($i = 0; $i <= 20; $i++) { |
|
24 | 24 | $invoice_number_padd_options[$i] = $i; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $currency_symbol = wpinv_currency_symbol(); |
28 | 28 | |
29 | 29 | $last_number = $reset_number = ''; |
30 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
31 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
30 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
31 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
32 | 32 | |
33 | - if ( !empty( $last_invoice_number ) ) { |
|
34 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
33 | + if (!empty($last_invoice_number)) { |
|
34 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $nonce = wp_create_nonce('reset_invoice_count'); |
38 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
38 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $alert_wrapper_start = '<p style="color: #F00">'; |
42 | 42 | $alert_wrapper_close = '</p>'; |
43 | 43 | |
44 | 44 | return array( |
45 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
45 | + 'general' => apply_filters('wpinv_settings_general', |
|
46 | 46 | array( |
47 | 47 | 'main' => array( |
48 | 48 | 'location_settings' => array( |
49 | 49 | 'id' => 'location_settings', |
50 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
50 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
51 | 51 | 'desc' => '', |
52 | 52 | 'type' => 'header', |
53 | 53 | ), |
54 | 54 | 'default_country' => array( |
55 | 55 | 'id' => 'default_country', |
56 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
57 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
56 | + 'name' => __('Default Country', 'invoicing'), |
|
57 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
58 | 58 | 'type' => 'select', |
59 | 59 | 'options' => wpinv_get_country_list(), |
60 | 60 | 'std' => 'GB', |
61 | 61 | 'class' => 'wpi_select2', |
62 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
62 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
63 | 63 | ), |
64 | 64 | 'default_state' => array( |
65 | 65 | 'id' => 'default_state', |
66 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
67 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
66 | + 'name' => __('Default State / Province', 'invoicing'), |
|
67 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
68 | 68 | 'type' => 'country_states', |
69 | 69 | 'class' => 'wpi_select2', |
70 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
70 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
71 | 71 | ), |
72 | 72 | 'store_name' => array( |
73 | 73 | 'id' => 'store_name', |
74 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
75 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
74 | + 'name' => __('Store Name', 'invoicing'), |
|
75 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
76 | 76 | 'std' => get_option('blogname'), |
77 | 77 | 'type' => 'text', |
78 | 78 | ), |
79 | 79 | 'logo' => array( |
80 | 80 | 'id' => 'logo', |
81 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
82 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
81 | + 'name' => __('Logo URL', 'invoicing'), |
|
82 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
83 | 83 | 'type' => 'text', |
84 | 84 | ), |
85 | 85 | 'logo_width' => array( |
86 | 86 | 'id' => 'logo_width', |
87 | - 'name' => __( 'Logo width', 'invoicing' ), |
|
88 | - 'desc' => __( 'Logo width to use in invoice image.', 'invoicing' ), |
|
87 | + 'name' => __('Logo width', 'invoicing'), |
|
88 | + 'desc' => __('Logo width to use in invoice image.', 'invoicing'), |
|
89 | 89 | 'type' => 'number', |
90 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
90 | + 'placeholder' => __('Auto', 'invoicing'), |
|
91 | 91 | ), |
92 | 92 | 'logo_height' => array( |
93 | 93 | 'id' => 'logo_height', |
94 | - 'name' => __( 'Logo height', 'invoicing' ), |
|
95 | - 'desc' => __( 'Logo height to use in invoice image.', 'invoicing' ), |
|
94 | + 'name' => __('Logo height', 'invoicing'), |
|
95 | + 'desc' => __('Logo height to use in invoice image.', 'invoicing'), |
|
96 | 96 | 'type' => 'number', |
97 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
97 | + 'placeholder' => __('Auto', 'invoicing'), |
|
98 | 98 | ), |
99 | 99 | 'store_address' => array( |
100 | 100 | 'id' => 'store_address', |
101 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
102 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
101 | + 'name' => __('Store Address', 'invoicing'), |
|
102 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
103 | 103 | 'type' => 'textarea', |
104 | 104 | ), |
105 | 105 | 'page_settings' => array( |
106 | 106 | 'id' => 'page_settings', |
107 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
107 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
108 | 108 | 'desc' => '', |
109 | 109 | 'type' => 'header', |
110 | 110 | ), |
111 | 111 | 'checkout_page' => array( |
112 | 112 | 'id' => 'checkout_page', |
113 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
114 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
113 | + 'name' => __('Checkout Page', 'invoicing'), |
|
114 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
115 | 115 | 'type' => 'select', |
116 | 116 | 'options' => $pages, |
117 | 117 | 'class' => 'wpi_select2', |
118 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
118 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
119 | 119 | 'help-tip' => true, |
120 | 120 | ), |
121 | 121 | 'success_page' => array( |
122 | 122 | 'id' => 'success_page', |
123 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
124 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
123 | + 'name' => __('Success Page', 'invoicing'), |
|
124 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
125 | 125 | 'type' => 'select', |
126 | 126 | 'options' => $pages, |
127 | 127 | 'class' => 'wpi_select2', |
128 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
128 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
129 | 129 | 'help-tip' => true, |
130 | 130 | ), |
131 | 131 | 'failure_page' => array( |
132 | 132 | 'id' => 'failure_page', |
133 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
134 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
133 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
134 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
135 | 135 | 'type' => 'select', |
136 | 136 | 'options' => $pages, |
137 | 137 | 'class' => 'wpi_select2', |
138 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
138 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
139 | 139 | 'help-tip' => true, |
140 | 140 | ), |
141 | 141 | 'invoice_history_page' => array( |
142 | 142 | 'id' => 'invoice_history_page', |
143 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
144 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
143 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
144 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
145 | 145 | 'type' => 'select', |
146 | 146 | 'options' => $pages, |
147 | 147 | 'class' => 'wpi_select2', |
148 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
148 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
149 | 149 | 'help-tip' => true, |
150 | 150 | ), |
151 | 151 | 'invoice_subscription_page' => array( |
152 | 152 | 'id' => 'invoice_subscription_page', |
153 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
154 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
153 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
154 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
155 | 155 | 'type' => 'select', |
156 | 156 | 'options' => $pages, |
157 | 157 | 'class' => 'wpi_select2', |
158 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
158 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
159 | 159 | 'help-tip' => true, |
160 | 160 | ), |
161 | 161 | ), |
162 | 162 | 'currency_section' => array( |
163 | 163 | 'currency_settings' => array( |
164 | 164 | 'id' => 'currency_settings', |
165 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
165 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
166 | 166 | 'desc' => '', |
167 | 167 | 'type' => 'header', |
168 | 168 | ), |
169 | 169 | 'currency' => array( |
170 | 170 | 'id' => 'currency', |
171 | - 'name' => __( 'Currency', 'invoicing' ), |
|
172 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
171 | + 'name' => __('Currency', 'invoicing'), |
|
172 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
173 | 173 | 'type' => 'select', |
174 | 174 | 'class' => 'wpi_select2', |
175 | 175 | 'options' => $currency_code_options, |
176 | 176 | ), |
177 | 177 | 'currency_position' => array( |
178 | 178 | 'id' => 'currency_position', |
179 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
180 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
179 | + 'name' => __('Currency Position', 'invoicing'), |
|
180 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
181 | 181 | 'type' => 'select', |
182 | 182 | 'class' => 'wpi_select2', |
183 | 183 | 'options' => array( |
184 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
185 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
186 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
187 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
184 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
185 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
186 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
187 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
188 | 188 | ) |
189 | 189 | ), |
190 | 190 | 'thousands_separator' => array( |
191 | 191 | 'id' => 'thousands_separator', |
192 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
193 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
192 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
193 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
194 | 194 | 'type' => 'text', |
195 | 195 | 'size' => 'small', |
196 | 196 | 'std' => ',', |
197 | 197 | ), |
198 | 198 | 'decimal_separator' => array( |
199 | 199 | 'id' => 'decimal_separator', |
200 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
201 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
200 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
201 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
202 | 202 | 'type' => 'text', |
203 | 203 | 'size' => 'small', |
204 | 204 | 'std' => '.', |
205 | 205 | ), |
206 | 206 | 'decimals' => array( |
207 | 207 | 'id' => 'decimals', |
208 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
209 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
208 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
209 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
210 | 210 | 'type' => 'number', |
211 | 211 | 'size' => 'small', |
212 | 212 | 'std' => '2', |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | 'labels' => array( |
219 | 219 | 'labels' => array( |
220 | 220 | 'id' => 'labels_settings', |
221 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
221 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
222 | 222 | 'desc' => '', |
223 | 223 | 'type' => 'header', |
224 | 224 | ), |
225 | 225 | 'vat_invoice_notice_label' => array( |
226 | 226 | 'id' => 'vat_invoice_notice_label', |
227 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
228 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
227 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
228 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
229 | 229 | 'type' => 'text', |
230 | 230 | 'size' => 'regular', |
231 | 231 | ), |
232 | 232 | 'vat_invoice_notice' => array( |
233 | 233 | 'id' => 'vat_invoice_notice', |
234 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
235 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
234 | + 'name' => __('Invoice notice', 'invoicing'), |
|
235 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
236 | 236 | 'type' => 'text', |
237 | 237 | 'size' => 'regular', |
238 | 238 | ), |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | 'main' => array( |
245 | 245 | 'gateway_settings' => array( |
246 | 246 | 'id' => 'api_header', |
247 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
247 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
248 | 248 | 'desc' => '', |
249 | 249 | 'type' => 'header', |
250 | 250 | ), |
251 | 251 | 'gateways' => array( |
252 | 252 | 'id' => 'gateways', |
253 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
254 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
253 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
254 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
255 | 255 | 'type' => 'gateways', |
256 | - 'std' => array( 'manual'=>1 ), |
|
256 | + 'std' => array('manual'=>1), |
|
257 | 257 | 'options' => wpinv_get_payment_gateways(), |
258 | 258 | ), |
259 | 259 | 'default_gateway' => array( |
260 | 260 | 'id' => 'default_gateway', |
261 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
262 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
261 | + 'name' => __('Default Gateway', 'invoicing'), |
|
262 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
263 | 263 | 'type' => 'gateway_select', |
264 | 264 | 'std' => 'manual', |
265 | 265 | 'class' => 'wpi_select2', |
@@ -274,32 +274,32 @@ discard block |
||
274 | 274 | 'main' => array( |
275 | 275 | 'tax_settings' => array( |
276 | 276 | 'id' => 'tax_settings', |
277 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
277 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
278 | 278 | 'type' => 'header', |
279 | 279 | ), |
280 | 280 | |
281 | 281 | 'enable_taxes' => array( |
282 | 282 | 'id' => 'enable_taxes', |
283 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
284 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
283 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
284 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
285 | 285 | 'type' => 'checkbox', |
286 | 286 | 'std' => 0, |
287 | 287 | ), |
288 | 288 | |
289 | 289 | 'tax_subtotal_rounding' => array( |
290 | 290 | 'id' => 'tax_subtotal_rounding', |
291 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
292 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
291 | + 'name' => __('Rounding', 'invoicing'), |
|
292 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
293 | 293 | 'type' => 'checkbox', |
294 | 294 | 'std' => 1, |
295 | 295 | ), |
296 | 296 | |
297 | 297 | 'prices_include_tax' => array( |
298 | 298 | 'id' => 'prices_include_tax', |
299 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
299 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
300 | 300 | 'options' => array( |
301 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
302 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
301 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
302 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
303 | 303 | ), |
304 | 304 | 'type' => 'select', |
305 | 305 | 'std' => 'no', |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | |
308 | 308 | 'tax_base' => array( |
309 | 309 | 'id' => 'tax_base', |
310 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
310 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
311 | 311 | 'options' => array( |
312 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
313 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
312 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
313 | + 'base' => __('Shop base address', 'invoicing'), |
|
314 | 314 | ), |
315 | 315 | 'type' => 'select', |
316 | 316 | 'std' => 'billing', |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | |
319 | 319 | 'tax_display_totals' => array( |
320 | 320 | 'id' => 'tax_display_totals', |
321 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
321 | + 'name' => __('Display tax totals', 'invoicing'), |
|
322 | 322 | 'options' => array( |
323 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
324 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
323 | + 'single' => __('As a single total', 'invoicing'), |
|
324 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
325 | 325 | ), |
326 | 326 | 'type' => 'select', |
327 | 327 | 'std' => 'individual', |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | |
330 | 330 | 'tax_rate' => array( |
331 | 331 | 'id' => 'tax_rate', |
332 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
333 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
332 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
333 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
334 | 334 | 'type' => 'number', |
335 | 335 | 'size' => 'small', |
336 | 336 | 'min' => '0', |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | 'rates' => array( |
343 | 343 | 'tax_rates' => array( |
344 | 344 | 'id' => 'tax_rates', |
345 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
346 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
345 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
346 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
347 | 347 | 'type' => 'tax_rates', |
348 | 348 | ), |
349 | 349 | ), |
@@ -352,45 +352,45 @@ discard block |
||
352 | 352 | |
353 | 353 | 'vat_company_name' => array( |
354 | 354 | 'id' => 'vat_company_name', |
355 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
356 | - 'desc' => wp_sprintf(__( 'Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
355 | + 'name' => __('Company Name', 'invoicing'), |
|
356 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
357 | 357 | 'type' => 'text', |
358 | 358 | 'size' => 'regular', |
359 | 359 | ), |
360 | 360 | |
361 | 361 | 'vat_number' => array( |
362 | 362 | 'id' => 'vat_number', |
363 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
364 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
363 | + 'name' => __('VAT Number', 'invoicing'), |
|
364 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
365 | 365 | 'type' => 'text', |
366 | 366 | 'size' => 'regular', |
367 | 367 | ), |
368 | 368 | |
369 | 369 | 'vat_prevent_b2c_purchase' => array( |
370 | 370 | 'id' => 'vat_prevent_b2c_purchase', |
371 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
372 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
371 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
372 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
373 | 373 | 'type' => 'checkbox' |
374 | 374 | ), |
375 | 375 | |
376 | 376 | 'validate_vat_number' => array( |
377 | 377 | 'id' => 'validate_vat_number', |
378 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
379 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
378 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
379 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
380 | 380 | 'type' => 'checkbox' |
381 | 381 | ), |
382 | 382 | |
383 | 383 | 'vat_same_country_rule' => array( |
384 | 384 | 'id' => 'vat_same_country_rule', |
385 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
386 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
385 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
386 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
387 | 387 | 'type' => 'select', |
388 | 388 | 'options' => array( |
389 | - 'no' => __( 'Do not charge tax', 'invoicing' ), |
|
390 | - 'always' => __( 'Charge tax unless vat number is validated', 'invoicing' ), |
|
391 | - 'vat_too' => __( 'Charge tax even if vat number is validated', 'invoicing' ) |
|
389 | + 'no' => __('Do not charge tax', 'invoicing'), |
|
390 | + 'always' => __('Charge tax unless vat number is validated', 'invoicing'), |
|
391 | + 'vat_too' => __('Charge tax even if vat number is validated', 'invoicing') |
|
392 | 392 | ), |
393 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
393 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
394 | 394 | 'std' => 'vat_too', |
395 | 395 | ), |
396 | 396 | |
@@ -404,59 +404,59 @@ discard block |
||
404 | 404 | 'main' => array( |
405 | 405 | 'email_settings_header' => array( |
406 | 406 | 'id' => 'email_settings_header', |
407 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
407 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
408 | 408 | 'type' => 'header', |
409 | 409 | ), |
410 | 410 | 'email_from_name' => array( |
411 | 411 | 'id' => 'email_from_name', |
412 | - 'name' => __( 'From Name', 'invoicing' ), |
|
413 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
414 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
412 | + 'name' => __('From Name', 'invoicing'), |
|
413 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
414 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
415 | 415 | 'type' => 'text', |
416 | 416 | ), |
417 | 417 | 'email_from' => array( |
418 | 418 | 'id' => 'email_from', |
419 | - 'name' => __( 'From Email', 'invoicing' ), |
|
420 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
421 | - 'std' => get_option( 'admin_email' ), |
|
419 | + 'name' => __('From Email', 'invoicing'), |
|
420 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
421 | + 'std' => get_option('admin_email'), |
|
422 | 422 | 'type' => 'text', |
423 | 423 | ), |
424 | 424 | 'admin_email' => array( |
425 | 425 | 'id' => 'admin_email', |
426 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
427 | - 'desc' => __( 'Where should we send admin notifications?', 'invoicing' ), |
|
428 | - 'std' => get_option( 'admin_email' ), |
|
426 | + 'name' => __('Admin Email', 'invoicing'), |
|
427 | + 'desc' => __('Where should we send admin notifications?', 'invoicing'), |
|
428 | + 'std' => get_option('admin_email'), |
|
429 | 429 | 'type' => 'text', |
430 | 430 | ), |
431 | 431 | 'overdue_settings_header' => array( |
432 | 432 | 'id' => 'overdue_settings_header', |
433 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
433 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
434 | 434 | 'type' => 'header', |
435 | 435 | ), |
436 | 436 | 'overdue_active' => array( |
437 | 437 | 'id' => 'overdue_active', |
438 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
439 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
438 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
439 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
440 | 440 | 'type' => 'checkbox', |
441 | 441 | 'std' => false, |
442 | 442 | ), |
443 | 443 | 'email_template_header' => array( |
444 | 444 | 'id' => 'email_template_header', |
445 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
445 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
446 | 446 | 'type' => 'header', |
447 | 447 | ), |
448 | 448 | 'email_header_image' => array( |
449 | 449 | 'id' => 'email_header_image', |
450 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
451 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
450 | + 'name' => __('Header Image', 'invoicing'), |
|
451 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
452 | 452 | 'std' => '', |
453 | 453 | 'type' => 'text', |
454 | 454 | ), |
455 | 455 | 'email_footer_text' => array( |
456 | 456 | 'id' => 'email_footer_text', |
457 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
458 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
459 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ), |
|
457 | + 'name' => __('Footer Text', 'invoicing'), |
|
458 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
459 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'), |
|
460 | 460 | 'type' => 'textarea', |
461 | 461 | 'class' => 'regular-text', |
462 | 462 | 'rows' => 2, |
@@ -464,29 +464,29 @@ discard block |
||
464 | 464 | ), |
465 | 465 | 'email_base_color' => array( |
466 | 466 | 'id' => 'email_base_color', |
467 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
468 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
467 | + 'name' => __('Base Color', 'invoicing'), |
|
468 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
469 | 469 | 'std' => '#557da2', |
470 | 470 | 'type' => 'color', |
471 | 471 | ), |
472 | 472 | 'email_background_color' => array( |
473 | 473 | 'id' => 'email_background_color', |
474 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
475 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
474 | + 'name' => __('Background Color', 'invoicing'), |
|
475 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
476 | 476 | 'std' => '#f5f5f5', |
477 | 477 | 'type' => 'color', |
478 | 478 | ), |
479 | 479 | 'email_body_background_color' => array( |
480 | 480 | 'id' => 'email_body_background_color', |
481 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
482 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
481 | + 'name' => __('Body Background Color', 'invoicing'), |
|
482 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
483 | 483 | 'std' => '#fdfdfd', |
484 | 484 | 'type' => 'color', |
485 | 485 | ), |
486 | 486 | 'email_text_color' => array( |
487 | 487 | 'id' => 'email_text_color', |
488 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
489 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
488 | + 'name' => __('Body Text Color', 'invoicing'), |
|
489 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
490 | 490 | 'std' => '#505050', |
491 | 491 | 'type' => 'color', |
492 | 492 | ), |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | ), |
502 | 502 | |
503 | 503 | // Integrations. |
504 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ), |
|
504 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'), |
|
505 | 505 | |
506 | 506 | /** Privacy Settings */ |
507 | 507 | 'privacy' => apply_filters('wpinv_settings_privacy', |
@@ -509,17 +509,17 @@ discard block |
||
509 | 509 | 'main' => array( |
510 | 510 | 'invoicing_privacy_policy_settings' => array( |
511 | 511 | 'id' => 'invoicing_privacy_policy_settings', |
512 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
512 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
513 | 513 | 'type' => 'header', |
514 | 514 | ), |
515 | 515 | 'privacy_page' => array( |
516 | 516 | 'id' => 'privacy_page', |
517 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
518 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
517 | + 'name' => __('Privacy Page', 'invoicing'), |
|
518 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
519 | 519 | 'type' => 'select', |
520 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
520 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
521 | 521 | 'class' => 'wpi_select2', |
522 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
522 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
523 | 523 | ), |
524 | 524 | ), |
525 | 525 | ) |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | 'main' => array( |
531 | 531 | 'invoice_number_format_settings' => array( |
532 | 532 | 'id' => 'invoice_number_format_settings', |
533 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
533 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
534 | 534 | 'type' => 'header', |
535 | 535 | ), |
536 | 536 | 'sequential_invoice_number' => array( |
537 | 537 | 'id' => 'sequential_invoice_number', |
538 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
539 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
538 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
539 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
540 | 540 | 'type' => 'checkbox', |
541 | 541 | ), |
542 | 542 | 'invoice_sequence_start' => array( |
543 | 543 | 'id' => 'invoice_sequence_start', |
544 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
545 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
544 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
545 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
546 | 546 | 'type' => 'number', |
547 | 547 | 'size' => 'small', |
548 | 548 | 'std' => '1', |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | ), |
551 | 551 | 'invoice_number_padd' => array( |
552 | 552 | 'id' => 'invoice_number_padd', |
553 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
554 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
553 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
554 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
555 | 555 | 'type' => 'select', |
556 | 556 | 'options' => $invoice_number_padd_options, |
557 | 557 | 'std' => 5, |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | ), |
560 | 560 | 'invoice_number_prefix' => array( |
561 | 561 | 'id' => 'invoice_number_prefix', |
562 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
563 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
562 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
563 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
564 | 564 | 'type' => 'text', |
565 | 565 | 'size' => 'regular', |
566 | 566 | 'std' => 'INV-', |
@@ -568,41 +568,41 @@ discard block |
||
568 | 568 | ), |
569 | 569 | 'invoice_number_postfix' => array( |
570 | 570 | 'id' => 'invoice_number_postfix', |
571 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
572 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
571 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
572 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
573 | 573 | 'type' => 'text', |
574 | 574 | 'size' => 'regular', |
575 | 575 | 'std' => '' |
576 | 576 | ), |
577 | 577 | 'checkout_settings' => array( |
578 | 578 | 'id' => 'checkout_settings', |
579 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
579 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
580 | 580 | 'type' => 'header', |
581 | 581 | ), |
582 | 582 | 'login_to_checkout' => array( |
583 | 583 | 'id' => 'login_to_checkout', |
584 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
585 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
584 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
585 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
586 | 586 | 'type' => 'checkbox', |
587 | 587 | ), |
588 | 588 | |
589 | 589 | 'maxmind_license_key' => array( |
590 | 590 | 'id' => 'maxmind_license_key', |
591 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
591 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
592 | 592 | 'type' => 'text', |
593 | 593 | 'size' => 'regular', |
594 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
594 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
595 | 595 | ), |
596 | 596 | |
597 | 597 | 'uninstall_settings' => array( |
598 | 598 | 'id' => 'uninstall_settings', |
599 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
599 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
600 | 600 | 'type' => 'header', |
601 | 601 | ), |
602 | 602 | 'remove_data_on_unistall' => array( |
603 | 603 | 'id' => 'remove_data_on_unistall', |
604 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
605 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
604 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
605 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
606 | 606 | 'type' => 'checkbox', |
607 | 607 | 'std' => '' |
608 | 608 | ), |
@@ -611,13 +611,13 @@ discard block |
||
611 | 611 | 'custom-css' => array( |
612 | 612 | 'css_settings' => array( |
613 | 613 | 'id' => 'css_settings', |
614 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
614 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
615 | 615 | 'type' => 'header', |
616 | 616 | ), |
617 | 617 | 'template_custom_css' => array( |
618 | 618 | 'id' => 'template_custom_css', |
619 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
620 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
619 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
620 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
621 | 621 | 'type' => 'textarea', |
622 | 622 | 'class'=> 'regular-text', |
623 | 623 | 'rows' => 10, |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | 'main' => array( |
632 | 632 | 'tool_settings' => array( |
633 | 633 | 'id' => 'tool_settings', |
634 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
635 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
634 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
635 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
636 | 636 | 'type' => 'tools', |
637 | 637 | ), |
638 | 638 | ), |
@@ -7,24 +7,24 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$logo_width = wpinv_get_option( 'logo_width' ); |
|
13 | -$logo_height = wpinv_get_option( 'logo_height' ); |
|
12 | +$logo_width = wpinv_get_option('logo_width'); |
|
13 | +$logo_height = wpinv_get_option('logo_height'); |
|
14 | 14 | |
15 | 15 | ?> |
16 | -<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
16 | +<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
17 | 17 | |
18 | - <?php if ( $logo = wpinv_get_business_logo() ) : ?> |
|
18 | + <?php if ($logo = wpinv_get_business_logo()) : ?> |
|
19 | 19 | |
20 | - <?php if ( ! empty( $logo_width ) && ! empty( $logo_height ) ) : ?> |
|
21 | - <img class="logo" style="max-width:100%; width:<?php echo absint( $logo_width ); ?>px; height:<?php echo absint( $logo_height ); ?>px;" src="<?php echo esc_url( $logo ); ?>"> |
|
20 | + <?php if (!empty($logo_width) && !empty($logo_height)) : ?> |
|
21 | + <img class="logo" style="max-width:100%; width:<?php echo absint($logo_width); ?>px; height:<?php echo absint($logo_height); ?>px;" src="<?php echo esc_url($logo); ?>"> |
|
22 | 22 | <?php else: ?> |
23 | - <img class="logo" style="max-width:100%;" src="<?php echo esc_url( $logo ); ?>"> |
|
23 | + <img class="logo" style="max-width:100%;" src="<?php echo esc_url($logo); ?>"> |
|
24 | 24 | <?php endif; ?> |
25 | 25 | |
26 | 26 | <?php else: ?> |
27 | - <h1 class="h3"><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
27 | + <h1 class="h3"><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
28 | 28 | <?php endif; ?> |
29 | 29 | |
30 | 30 | </a> |
@@ -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 | * Returns an array of eu states. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | function getpaid_get_eu_states() { |
15 | - return wpinv_get_data( 'eu-states' ); |
|
15 | + return wpinv_get_data('eu-states'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | -function getpaid_is_eu_state( $country ) { |
|
24 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false; |
|
23 | +function getpaid_is_eu_state($country) { |
|
24 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return array |
31 | 31 | */ |
32 | 32 | function getpaid_get_gst_states() { |
33 | - return array( 'AU', 'NZ', 'CA', 'CN' ); |
|
33 | + return array('AU', 'NZ', 'CA', 'CN'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | -function getpaid_is_gst_country( $country ) { |
|
42 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false; |
|
41 | +function getpaid_is_gst_country($country) { |
|
42 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function wpinv_use_taxes() { |
51 | 51 | |
52 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
53 | - return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) ); |
|
52 | + $ret = wpinv_get_option('enable_taxes', false); |
|
53 | + return (bool) apply_filters('wpinv_use_taxes', !empty($ret)); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param WPInv_Invoice $invoice |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | -function wpinv_is_invoice_taxable( $invoice ) { |
|
63 | +function wpinv_is_invoice_taxable($invoice) { |
|
64 | 64 | return $invoice->is_taxable(); |
65 | 65 | } |
66 | 66 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param string $country |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | -function wpinv_is_country_taxable( $country ) { |
|
74 | - $is_eu = getpaid_is_eu_state( $country ); |
|
75 | - $is_exempt = ! $is_eu && wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat(); |
|
73 | +function wpinv_is_country_taxable($country) { |
|
74 | + $is_eu = getpaid_is_eu_state($country); |
|
75 | + $is_exempt = !$is_eu && wpinv_is_base_country($country) && wpinv_same_country_exempt_vat(); |
|
76 | 76 | |
77 | - return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); |
|
77 | + return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param WPInv_Item|GetPaid_Form_Item $item |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | -function wpinv_is_item_taxable( $item ) { |
|
87 | +function wpinv_is_item_taxable($item) { |
|
88 | 88 | return '_exempt' != $item->get_vat_rule(); |
89 | 89 | } |
90 | 90 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | function wpinv_use_store_address_as_tax_base() { |
97 | - $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base'; |
|
98 | - return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base ); |
|
97 | + $use_base = wpinv_get_option('tax_base', 'billing') == 'base'; |
|
98 | + return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function wpinv_prices_include_tax() { |
107 | - $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes'; |
|
108 | - return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive ); |
|
107 | + $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes'; |
|
108 | + return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | function wpinv_round_tax_per_tax_rate() { |
117 | - $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 ); |
|
118 | - return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) ); |
|
117 | + $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1); |
|
118 | + return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @return bool |
125 | 125 | */ |
126 | 126 | function wpinv_display_individual_tax_rates() { |
127 | - $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual'; |
|
128 | - return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual ); |
|
127 | + $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual'; |
|
128 | + return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @return float |
135 | 135 | */ |
136 | 136 | function wpinv_get_default_tax_rate() { |
137 | - $rate = wpinv_get_option( 'tax_rate', 0 ); |
|
138 | - return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) ); |
|
137 | + $rate = wpinv_get_option('tax_rate', 0); |
|
138 | + return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | function wpinv_same_country_exempt_vat() { |
147 | - return 'no' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ); |
|
147 | + return 'no' == wpinv_get_option('vat_same_country_rule', 'vat_too'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | * @param string $state |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) { |
|
167 | +function getpaid_get_item_tax_rates($item, $country = '', $state = '') { |
|
168 | 168 | |
169 | 169 | // Abort if the item is not taxable. |
170 | - if ( ! wpinv_is_item_taxable( $item ) ) { |
|
170 | + if (!wpinv_is_item_taxable($item)) { |
|
171 | 171 | return array(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Maybe use the store address. |
175 | - if ( wpinv_use_store_address_as_tax_base() ) { |
|
175 | + if (wpinv_use_store_address_as_tax_base()) { |
|
176 | 176 | $country = wpinv_get_default_country(); |
177 | 177 | $state = wpinv_get_default_state(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Retrieve tax rates. |
181 | - $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state ); |
|
181 | + $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state); |
|
182 | 182 | |
183 | 183 | // Fallback to the default tax rates if non were found. |
184 | - if ( empty( $tax_rates ) ) { |
|
184 | + if (empty($tax_rates)) { |
|
185 | 185 | $tax_rates = GetPaid_Tax::get_default_tax_rates(); |
186 | 186 | } |
187 | 187 | |
188 | - return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state ); |
|
188 | + return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | * @param array $rates |
196 | 196 | * @return array |
197 | 197 | */ |
198 | -function getpaid_filter_item_tax_rates( $item, $rates ) { |
|
198 | +function getpaid_filter_item_tax_rates($item, $rates) { |
|
199 | 199 | |
200 | 200 | $tax_class = $item->get_vat_class(); |
201 | 201 | |
202 | - foreach ( $rates as $i => $rate ) { |
|
202 | + foreach ($rates as $i => $rate) { |
|
203 | 203 | |
204 | - if ( $tax_class == '_reduced' ) { |
|
205 | - $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate']; |
|
204 | + if ($tax_class == '_reduced') { |
|
205 | + $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate']; |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( $tax_class == '_exempt' ) { |
|
209 | - $rates[ $i ]['rate'] = 0; |
|
208 | + if ($tax_class == '_exempt') { |
|
209 | + $rates[$i]['rate'] = 0; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
213 | 213 | |
214 | - return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item ); |
|
214 | + return apply_filters('getpaid_filter_item_tax_rates', $rates, $item); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | * @param array $rates |
222 | 222 | * @return array |
223 | 223 | */ |
224 | -function getpaid_calculate_item_taxes( $amount, $rates ) { |
|
224 | +function getpaid_calculate_item_taxes($amount, $rates) { |
|
225 | 225 | |
226 | 226 | $is_inclusive = wpinv_prices_include_tax(); |
227 | - $taxes = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive ); |
|
227 | + $taxes = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive); |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates ); |
|
229 | + return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @param float $recurring_tax_amount |
239 | 239 | * @return array |
240 | 240 | */ |
241 | -function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
|
241 | +function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) { |
|
242 | 242 | |
243 | - $initial_tax = $tax_amount; |
|
243 | + $initial_tax = $tax_amount; |
|
244 | 244 | $recurring_tax = 0; |
245 | 245 | |
246 | - if ( $item->is_recurring() ) { |
|
246 | + if ($item->is_recurring()) { |
|
247 | 247 | $recurring_tax = $recurring_tax_amount; |
248 | 248 | } |
249 | 249 | |
250 | 250 | return array( |
251 | - 'name' => sanitize_text_field( $tax_name ), |
|
251 | + 'name' => sanitize_text_field($tax_name), |
|
252 | 252 | 'initial_tax' => $initial_tax, |
253 | 253 | 'recurring_tax' => $recurring_tax, |
254 | 254 | ); |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * @param string $vat_number |
262 | 262 | * @return string |
263 | 263 | */ |
264 | -function wpinv_sanitize_vat_number( $vat_number ) { |
|
265 | - return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
264 | +function wpinv_sanitize_vat_number($vat_number) { |
|
265 | + return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -271,22 +271,22 @@ discard block |
||
271 | 271 | * @param string $vat_number |
272 | 272 | * @return bool |
273 | 273 | */ |
274 | -function wpinv_regex_validate_vat_number( $vat_number ) { |
|
274 | +function wpinv_regex_validate_vat_number($vat_number) { |
|
275 | 275 | |
276 | - $country = substr( $vat_number, 0, 2 ); |
|
277 | - $vatin = substr( $vat_number, 2 ); |
|
278 | - $regexes = wpinv_get_data( 'vat-number-regexes' ); |
|
276 | + $country = substr($vat_number, 0, 2); |
|
277 | + $vatin = substr($vat_number, 2); |
|
278 | + $regexes = wpinv_get_data('vat-number-regexes'); |
|
279 | 279 | |
280 | - if ( isset( $regexes[ $country ] ) ) { |
|
280 | + if (isset($regexes[$country])) { |
|
281 | 281 | |
282 | - $regex = $regexes[ $country ]; |
|
282 | + $regex = $regexes[$country]; |
|
283 | 283 | $regex = '/^(?:' . $regex . ')$/'; |
284 | - return 1 === preg_match( $regex, $vatin ); |
|
284 | + return 1 === preg_match($regex, $vatin); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Not an EU state, use filters to validate the number. |
289 | - return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number ); |
|
289 | + return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,29 +295,29 @@ discard block |
||
295 | 295 | * @param string $vat_number |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | -function wpinv_vies_validate_vat_number( $vat_number ) { |
|
298 | +function wpinv_vies_validate_vat_number($vat_number) { |
|
299 | 299 | |
300 | - $country = substr( $vat_number, 0, 2 ); |
|
301 | - $vatin = substr( $vat_number, 2 ); |
|
300 | + $country = substr($vat_number, 0, 2); |
|
301 | + $vatin = substr($vat_number, 2); |
|
302 | 302 | |
303 | 303 | $url = add_query_arg( |
304 | 304 | array( |
305 | - 'ms' => urlencode( $country ), |
|
306 | - 'iso' => urlencode( $country ), |
|
307 | - 'vat' => urlencode( $vatin ), |
|
305 | + 'ms' => urlencode($country), |
|
306 | + 'iso' => urlencode($country), |
|
307 | + 'vat' => urlencode($vatin), |
|
308 | 308 | ), |
309 | 309 | 'http://ec.europa.eu/taxation_customs/vies/viesquer.do' |
310 | 310 | ); |
311 | 311 | |
312 | - $response = wp_remote_get( $url ); |
|
313 | - $response = wp_remote_retrieve_body( $response ); |
|
312 | + $response = wp_remote_get($url); |
|
313 | + $response = wp_remote_retrieve_body($response); |
|
314 | 314 | |
315 | 315 | // Fallback gracefully if the VIES website is down. |
316 | - if ( empty( $response ) ) { |
|
316 | + if (empty($response)) { |
|
317 | 317 | return true; |
318 | 318 | } |
319 | 319 | |
320 | - return 1 !== preg_match( '/invalid VAT number/i', $response ); |
|
320 | + return 1 !== preg_match('/invalid VAT number/i', $response); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | * @param string $country |
329 | 329 | * @return bool |
330 | 330 | */ |
331 | -function wpinv_validate_vat_number( $vat_number, $country ) { |
|
331 | +function wpinv_validate_vat_number($vat_number, $country) { |
|
332 | 332 | |
333 | 333 | // In case the vat number does not have a country code... |
334 | - $vat_number = wpinv_sanitize_vat_number( $vat_number ); |
|
335 | - $_country = substr( $vat_number, 0, 2 ); |
|
336 | - $_country = $_country == wpinv_country_name( $_country ); |
|
334 | + $vat_number = wpinv_sanitize_vat_number($vat_number); |
|
335 | + $_country = substr($vat_number, 0, 2); |
|
336 | + $_country = $_country == wpinv_country_name($_country); |
|
337 | 337 | |
338 | - if ( $_country ) { |
|
339 | - $vat_number = strtoupper( $country ) . $vat_number; |
|
338 | + if ($_country) { |
|
339 | + $vat_number = strtoupper($country) . $vat_number; |
|
340 | 340 | } |
341 | 341 | |
342 | - return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number ); |
|
342 | + return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -348,40 +348,40 @@ discard block |
||
348 | 348 | * @return bool |
349 | 349 | */ |
350 | 350 | function wpinv_should_validate_vat_number() { |
351 | - $validate = wpinv_get_option( 'validate_vat_number' ); |
|
352 | - return ! empty( $validate ); |
|
351 | + $validate = wpinv_get_option('validate_vat_number'); |
|
352 | + return !empty($validate); |
|
353 | 353 | } |
354 | 354 | |
355 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
356 | - return wpinv_price( wpinv_get_sales_tax_for_year( $year ) ); |
|
355 | +function wpinv_sales_tax_for_year($year = null) { |
|
356 | + return wpinv_price(wpinv_get_sales_tax_for_year($year)); |
|
357 | 357 | } |
358 | 358 | |
359 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
359 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
360 | 360 | global $wpdb; |
361 | 361 | |
362 | 362 | // Start at zero |
363 | 363 | $tax = 0; |
364 | 364 | |
365 | - if ( ! empty( $year ) ) { |
|
365 | + if (!empty($year)) { |
|
366 | 366 | $args = array( |
367 | 367 | 'post_type' => 'wpi_invoice', |
368 | - 'post_status' => array( 'publish' ), |
|
368 | + 'post_status' => array('publish'), |
|
369 | 369 | 'posts_per_page' => -1, |
370 | 370 | 'year' => $year, |
371 | 371 | 'fields' => 'ids' |
372 | 372 | ); |
373 | 373 | |
374 | - $payments = get_posts( $args ); |
|
375 | - $payment_ids = implode( ',', $payments ); |
|
374 | + $payments = get_posts($args); |
|
375 | + $payment_ids = implode(',', $payments); |
|
376 | 376 | |
377 | - if ( count( $payments ) > 0 ) { |
|
377 | + if (count($payments) > 0) { |
|
378 | 378 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
379 | - $tax = $wpdb->get_var( $sql ); |
|
379 | + $tax = $wpdb->get_var($sql); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
384 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | function wpinv_is_cart_taxed() { |
@@ -390,33 +390,33 @@ discard block |
||
390 | 390 | |
391 | 391 | function wpinv_prices_show_tax_on_checkout() { |
392 | 392 | return false; // TODO |
393 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
393 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
394 | 394 | |
395 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
395 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_display_tax_rate() { |
399 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
399 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
400 | 400 | |
401 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
401 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | function wpinv_cart_needs_tax_address_fields() { |
405 | - if( !wpinv_is_cart_taxed() ) |
|
405 | + if (!wpinv_is_cart_taxed()) |
|
406 | 406 | return false; |
407 | 407 | |
408 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
408 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
409 | 409 | } |
410 | 410 | |
411 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
412 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
413 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
411 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
412 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
413 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
414 | 414 | } |
415 | 415 | |
416 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
416 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
417 | 417 | $currency = wpinv_get_currency(); |
418 | 418 | |
419 | - switch ( $currency ) { |
|
419 | + switch ($currency) { |
|
420 | 420 | case 'RIAL' : |
421 | 421 | case 'JPY' : |
422 | 422 | case 'TWD' : |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | break; |
426 | 426 | } |
427 | 427 | |
428 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
428 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | function wpinv_tax_amount() { |
432 | 432 | $output = 0.00; |
433 | 433 | |
434 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
434 | + return apply_filters('wpinv_tax_amount', $output); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -439,25 +439,25 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param string|bool|null $vat_rule |
441 | 441 | */ |
442 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
442 | +function getpaid_filter_vat_rule($vat_rule) { |
|
443 | 443 | |
444 | - if ( empty( $vat_rule ) ) { |
|
444 | + if (empty($vat_rule)) { |
|
445 | 445 | return 'digital'; |
446 | 446 | } |
447 | 447 | |
448 | 448 | return $vat_rule; |
449 | 449 | } |
450 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
450 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * Filters the VAT class to ensure that each item has a VAT class. |
454 | 454 | * |
455 | 455 | * @param string|bool|null $vat_rule |
456 | 456 | */ |
457 | -function getpaid_filter_vat_class( $vat_class ) { |
|
458 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
457 | +function getpaid_filter_vat_class($vat_class) { |
|
458 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
459 | 459 | } |
460 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
460 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
|
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Returns a list of all tax classes. |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | return apply_filters( |
470 | 470 | 'getpaid_tax_classes', |
471 | 471 | array( |
472 | - '_standard' => __( 'Standard Tax Rate', 'invoicing' ), |
|
473 | - '_reduced' => __( 'Reduced Tax Rate', 'invoicing' ), |
|
474 | - '_exempt' => __( 'Tax Exempt', 'invoicing' ), |
|
472 | + '_standard' => __('Standard Tax Rate', 'invoicing'), |
|
473 | + '_reduced' => __('Reduced Tax Rate', 'invoicing'), |
|
474 | + '_exempt' => __('Tax Exempt', 'invoicing'), |
|
475 | 475 | ) |
476 | 476 | ); |
477 | 477 | |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | return apply_filters( |
488 | 488 | 'getpaid_tax_rules', |
489 | 489 | array( |
490 | - 'physical' => __( 'Physical Item', 'invoicing' ), |
|
491 | - 'digital' => __( 'Digital Item', 'invoicing' ), |
|
490 | + 'physical' => __('Physical Item', 'invoicing'), |
|
491 | + 'digital' => __('Digital Item', 'invoicing'), |
|
492 | 492 | ) |
493 | 493 | ); |
494 | 494 | |
@@ -500,15 +500,15 @@ discard block |
||
500 | 500 | * @param string $tax_class |
501 | 501 | * @return string |
502 | 502 | */ |
503 | -function getpaid_get_tax_class_label( $tax_class ) { |
|
503 | +function getpaid_get_tax_class_label($tax_class) { |
|
504 | 504 | |
505 | 505 | $classes = getpaid_get_tax_classes(); |
506 | 506 | |
507 | - if ( isset( $classes[ $tax_class ] ) ) { |
|
508 | - return sanitize_text_field( $classes[ $tax_class ] ); |
|
507 | + if (isset($classes[$tax_class])) { |
|
508 | + return sanitize_text_field($classes[$tax_class]); |
|
509 | 509 | } |
510 | 510 | |
511 | - return sanitize_text_field( $tax_class ); |
|
511 | + return sanitize_text_field($tax_class); |
|
512 | 512 | |
513 | 513 | } |
514 | 514 | |
@@ -518,15 +518,15 @@ discard block |
||
518 | 518 | * @param string $tax_rule |
519 | 519 | * @return string |
520 | 520 | */ |
521 | -function getpaid_get_tax_rule_label( $tax_rule ) { |
|
521 | +function getpaid_get_tax_rule_label($tax_rule) { |
|
522 | 522 | |
523 | 523 | $rules = getpaid_get_tax_rules(); |
524 | 524 | |
525 | - if ( isset( $rules[ $tax_rule ] ) ) { |
|
526 | - return sanitize_text_field( $rules[ $tax_rule ] ); |
|
525 | + if (isset($rules[$tax_rule])) { |
|
526 | + return sanitize_text_field($rules[$tax_rule]); |
|
527 | 527 | } |
528 | 528 | |
529 | - return sanitize_text_field( $tax_rule ); |
|
529 | + return sanitize_text_field($tax_rule); |
|
530 | 530 | |
531 | 531 | } |
532 | 532 | |
@@ -537,11 +537,11 @@ discard block |
||
537 | 537 | * @param string $recurring |
538 | 538 | * @return string |
539 | 539 | */ |
540 | -function getpaid_get_taxable_amount( $item, $recurring = false ) { |
|
540 | +function getpaid_get_taxable_amount($item, $recurring = false) { |
|
541 | 541 | |
542 | 542 | $taxable_amount = $recurring ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
543 | 543 | $taxable_amount -= $recurring ? $item->recurring_item_discount : $item->item_discount; |
544 | - $taxable_amount = max( 0, $taxable_amount ); |
|
545 | - return apply_filters( 'getpaid_taxable_amount', $taxable_amount, $item, $recurring ); |
|
544 | + $taxable_amount = max(0, $taxable_amount); |
|
545 | + return apply_filters('getpaid_taxable_amount', $taxable_amount, $item, $recurring); |
|
546 | 546 | |
547 | 547 | } |