@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,28 +117,28 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) ); |
|
133 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
134 | - |
|
135 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
136 | - add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
|
137 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('the_seo_framework_sitemap_supported_post_types', array($this, 'exclude_invoicing_post_types')); |
|
133 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
134 | + |
|
135 | + add_filter('query_vars', array($this, 'custom_query_vars')); |
|
136 | + add_action('init', array($this, 'add_rewrite_rule'), 10, 0); |
|
137 | + add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1); |
|
138 | 138 | |
139 | 139 | // Fires after registering actions. |
140 | - do_action( 'wpinv_actions', $this ); |
|
141 | - do_action( 'getpaid_actions', $this ); |
|
140 | + do_action('wpinv_actions', $this); |
|
141 | + do_action('getpaid_actions', $this); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | /* Internationalize the text strings used. */ |
147 | 147 | $this->load_textdomain(); |
148 | 148 | |
149 | - do_action( 'wpinv_loaded' ); |
|
149 | + do_action('wpinv_loaded'); |
|
150 | 150 | |
151 | 151 | // Fix oxygen page builder conflict |
152 | - if ( function_exists( 'ct_css_output' ) ) { |
|
152 | + if (function_exists('ct_css_output')) { |
|
153 | 153 | wpinv_oxygen_fix_conflict(); |
154 | 154 | } |
155 | 155 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | load_plugin_textdomain( |
171 | 171 | 'invoicing', |
172 | 172 | false, |
173 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
173 | + plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/' |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | } |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | |
207 | 207 | // Register autoloader. |
208 | 208 | try { |
209 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
210 | - } catch ( Exception $e ) { |
|
211 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
209 | + spl_autoload_register(array($this, 'autoload'), true); |
|
210 | + } catch (Exception $e) { |
|
211 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php'; |
235 | 235 | require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
236 | 236 | |
237 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
237 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
238 | 238 | GetPaid_Post_Types_Admin::init(); |
239 | 239 | |
240 | 240 | require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'; |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'; |
246 | 246 | // load the user class only on the users.php page |
247 | 247 | global $pagenow; |
248 | - if ( $pagenow == 'users.php' ) { |
|
248 | + if ($pagenow == 'users.php') { |
|
249 | 249 | new WPInv_Admin_Users(); |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | // Register cli commands |
254 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
254 | + if (defined('WP_CLI') && WP_CLI) { |
|
255 | 255 | require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'; |
256 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
256 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | } |
@@ -266,21 +266,21 @@ discard block |
||
266 | 266 | * @since 1.0.19 |
267 | 267 | * @return void |
268 | 268 | */ |
269 | - public function autoload( $class_name ) { |
|
269 | + public function autoload($class_name) { |
|
270 | 270 | |
271 | 271 | // Normalize the class name... |
272 | - $class_name = strtolower( $class_name ); |
|
272 | + $class_name = strtolower($class_name); |
|
273 | 273 | |
274 | 274 | // ... and make sure it is our class. |
275 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
275 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
276 | 276 | return; |
277 | 277 | } |
278 | 278 | |
279 | 279 | // Next, prepare the file name from the class. |
280 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
280 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
281 | 281 | |
282 | 282 | // Base path of the classes. |
283 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
283 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
284 | 284 | |
285 | 285 | // And an array of possible locations in order of importance. |
286 | 286 | $locations = array( |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | "$plugin_path/includes/admin/meta-boxes", |
296 | 296 | ); |
297 | 297 | |
298 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
298 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
299 | 299 | |
300 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
301 | - include trailingslashit( $location ) . $file_name; |
|
300 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
301 | + include trailingslashit($location) . $file_name; |
|
302 | 302 | break; |
303 | 303 | } |
304 | 304 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | public function init() { |
312 | 312 | |
313 | 313 | // Fires before getpaid inits. |
314 | - do_action( 'before_getpaid_init', $this ); |
|
314 | + do_action('before_getpaid_init', $this); |
|
315 | 315 | |
316 | 316 | // Maybe upgrade. |
317 | 317 | $this->maybe_upgrade_database(); |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | |
331 | - foreach ( $gateways as $id => $class ) { |
|
332 | - $this->gateways[ $id ] = new $class(); |
|
331 | + foreach ($gateways as $id => $class) { |
|
332 | + $this->gateways[$id] = new $class(); |
|
333 | 333 | } |
334 | 334 | |
335 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
335 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
336 | 336 | GetPaid_Installer::rename_gateways_label(); |
337 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
337 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // Fires after getpaid inits. |
341 | - do_action( 'getpaid_init', $this ); |
|
341 | + do_action('getpaid_init', $this); |
|
342 | 342 | |
343 | 343 | } |
344 | 344 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | public function maybe_process_ipn() { |
349 | 349 | |
350 | 350 | // Ensure that this is an IPN request. |
351 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
351 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - $gateway = sanitize_text_field( $_GET['wpi-gateway'] ); |
|
355 | + $gateway = sanitize_text_field($_GET['wpi-gateway']); |
|
356 | 356 | |
357 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
358 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
357 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
358 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
359 | 359 | exit; |
360 | 360 | |
361 | 361 | } |
@@ -363,33 +363,33 @@ discard block |
||
363 | 363 | public function enqueue_scripts() { |
364 | 364 | |
365 | 365 | // Fires before adding scripts. |
366 | - do_action( 'getpaid_enqueue_scripts' ); |
|
366 | + do_action('getpaid_enqueue_scripts'); |
|
367 | 367 | |
368 | 368 | $localize = array(); |
369 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
369 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
370 | 370 | $localize['thousands'] = wpinv_thousands_separator(); |
371 | 371 | $localize['decimals'] = wpinv_decimal_separator(); |
372 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
373 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
372 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
373 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
374 | 374 | $localize['UseTaxes'] = wpinv_use_taxes(); |
375 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
376 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
377 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
375 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
376 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
377 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
378 | 378 | |
379 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
379 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
380 | 380 | |
381 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
382 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
383 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
381 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
382 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
383 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | public function wpinv_actions() { |
387 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
388 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
387 | + if (isset($_REQUEST['wpi_action'])) { |
|
388 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
389 | 389 | } |
390 | 390 | |
391 | - if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) { |
|
392 | - include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
391 | + if (defined('WP_ALL_IMPORT_ROOT_DIR')) { |
|
392 | + include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -401,24 +401,24 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public function maybe_do_authenticated_action() { |
403 | 403 | |
404 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
404 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
405 | 405 | |
406 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
407 | - $data = wp_unslash( $_REQUEST ); |
|
408 | - if ( is_user_logged_in() ) { |
|
409 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
406 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
407 | + $data = wp_unslash($_REQUEST); |
|
408 | + if (is_user_logged_in()) { |
|
409 | + do_action("getpaid_authenticated_action_$key", $data); |
|
410 | 410 | } |
411 | 411 | |
412 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
412 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | 416 | } |
417 | 417 | |
418 | - public function pre_get_posts( $wp_query ) { |
|
418 | + public function pre_get_posts($wp_query) { |
|
419 | 419 | |
420 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
421 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
420 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
421 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | return $wp_query; |
@@ -433,18 +433,18 @@ discard block |
||
433 | 433 | |
434 | 434 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
435 | 435 | // So we disable our widgets when editing a page with UX Builder. |
436 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
436 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
437 | 437 | return; |
438 | 438 | } |
439 | 439 | |
440 | - $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array(); |
|
440 | + $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
|
441 | 441 | |
442 | - if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) { |
|
442 | + if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
443 | 443 | // don't initiate in these conditions. |
444 | 444 | } else { |
445 | 445 | |
446 | 446 | // Only load allowed widgets. |
447 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
447 | + $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array(); |
|
448 | 448 | $widgets = apply_filters( |
449 | 449 | 'getpaid_widget_classes', |
450 | 450 | array( |
@@ -460,16 +460,16 @@ discard block |
||
460 | 460 | ); |
461 | 461 | |
462 | 462 | // For each widget... |
463 | - foreach ( $widgets as $widget ) { |
|
463 | + foreach ($widgets as $widget) { |
|
464 | 464 | |
465 | 465 | // Abort early if it is excluded for this page. |
466 | - if ( in_array( $widget, $exclude ) ) { |
|
466 | + if (in_array($widget, $exclude)) { |
|
467 | 467 | continue; |
468 | 468 | } |
469 | 469 | |
470 | 470 | // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
471 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
472 | - register_widget( $widget ); |
|
471 | + if (is_subclass_of($widget, 'WP_Widget')) { |
|
472 | + register_widget($widget); |
|
473 | 473 | } else { |
474 | 474 | new $widget(); |
475 | 475 | } |
@@ -485,19 +485,19 @@ discard block |
||
485 | 485 | */ |
486 | 486 | public function maybe_upgrade_database() { |
487 | 487 | |
488 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
488 | + $wpi_version = get_option('wpinv_version', 0); |
|
489 | 489 | |
490 | - if ( $wpi_version == WPINV_VERSION ) { |
|
490 | + if ($wpi_version == WPINV_VERSION) { |
|
491 | 491 | return; |
492 | 492 | } |
493 | 493 | |
494 | 494 | $installer = new GetPaid_Installer(); |
495 | 495 | |
496 | - if ( empty( $wpi_version ) ) { |
|
497 | - return $installer->upgrade_db( 0 ); |
|
496 | + if (empty($wpi_version)) { |
|
497 | + return $installer->upgrade_db(0); |
|
498 | 498 | } |
499 | 499 | |
500 | - $upgrades = array( |
|
500 | + $upgrades = array( |
|
501 | 501 | '0.0.5' => '004', |
502 | 502 | '1.0.3' => '102', |
503 | 503 | '2.0.0' => '118', |
@@ -505,10 +505,10 @@ discard block |
||
505 | 505 | '2.6.16' => '2615', |
506 | 506 | ); |
507 | 507 | |
508 | - foreach ( $upgrades as $key => $method ) { |
|
508 | + foreach ($upgrades as $key => $method) { |
|
509 | 509 | |
510 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
511 | - return $installer->upgrade_db( $method ); |
|
510 | + if (version_compare($wpi_version, $key, '<')) { |
|
511 | + return $installer->upgrade_db($method); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | */ |
522 | 522 | public function maybe_flush_permalinks() { |
523 | 523 | |
524 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
524 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
525 | 525 | |
526 | - if ( ! empty( $flush ) ) { |
|
526 | + if (!empty($flush)) { |
|
527 | 527 | flush_rewrite_rules(); |
528 | - delete_option( 'wpinv_flush_permalinks' ); |
|
528 | + delete_option('wpinv_flush_permalinks'); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | } |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * @since 1.0.19 |
537 | 537 | * @param int[] $excluded_posts_ids |
538 | 538 | */ |
539 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) { |
|
539 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
540 | 540 | |
541 | 541 | // Ensure that we have an array. |
542 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
542 | + if (!is_array($excluded_posts_ids)) { |
|
543 | 543 | $excluded_posts_ids = array(); |
544 | 544 | } |
545 | 545 | |
@@ -547,24 +547,24 @@ discard block |
||
547 | 547 | $our_pages = array(); |
548 | 548 | |
549 | 549 | // Checkout page. |
550 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
550 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
551 | 551 | |
552 | 552 | // Success page. |
553 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
553 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
554 | 554 | |
555 | 555 | // Failure page. |
556 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
556 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
557 | 557 | |
558 | 558 | // History page. |
559 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
559 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
560 | 560 | |
561 | 561 | // Subscriptions page. |
562 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
562 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
563 | 563 | |
564 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
564 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
565 | 565 | |
566 | 566 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
567 | - return array_unique( $excluded_posts_ids ); |
|
567 | + return array_unique($excluded_posts_ids); |
|
568 | 568 | |
569 | 569 | } |
570 | 570 | |
@@ -574,15 +574,15 @@ discard block |
||
574 | 574 | * @since 1.0.19 |
575 | 575 | * @param string[] $post_types |
576 | 576 | */ |
577 | - public function exclude_invoicing_post_types( $post_types ) { |
|
577 | + public function exclude_invoicing_post_types($post_types) { |
|
578 | 578 | |
579 | 579 | // Ensure that we have an array. |
580 | - if ( ! is_array( $post_types ) ) { |
|
580 | + if (!is_array($post_types)) { |
|
581 | 581 | $post_types = array(); |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Remove our post types. |
585 | - return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) ); |
|
585 | + return array_diff($post_types, array_keys(getpaid_get_invoice_post_types())); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | * @since 2.0.0 |
592 | 592 | */ |
593 | 593 | public function wp_footer() { |
594 | - wpinv_get_template( 'frontend-footer.php' ); |
|
594 | + wpinv_get_template('frontend-footer.php'); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -600,14 +600,14 @@ discard block |
||
600 | 600 | * @since 2.0.0 |
601 | 601 | */ |
602 | 602 | public function wp_head() { |
603 | - wpinv_get_template( 'frontend-head.php' ); |
|
603 | + wpinv_get_template('frontend-head.php'); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
607 | 607 | * Custom query vars. |
608 | 608 | * |
609 | 609 | */ |
610 | - public function custom_query_vars( $vars ) { |
|
610 | + public function custom_query_vars($vars) { |
|
611 | 611 | $vars[] = 'getpaid-ipn'; |
612 | 612 | return $vars; |
613 | 613 | } |
@@ -618,28 +618,28 @@ discard block |
||
618 | 618 | */ |
619 | 619 | public function add_rewrite_rule() { |
620 | 620 | $tag = 'getpaid-ipn'; |
621 | - add_rewrite_tag( "%$tag%", '([^&]+)' ); |
|
622 | - add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' ); |
|
621 | + add_rewrite_tag("%$tag%", '([^&]+)'); |
|
622 | + add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top'); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
626 | 626 | * Processes non-query string ipns. |
627 | 627 | * |
628 | 628 | */ |
629 | - public function maybe_process_new_ipn( $query ) { |
|
629 | + public function maybe_process_new_ipn($query) { |
|
630 | 630 | |
631 | - if ( is_admin() || ! $query->is_main_query() ) { |
|
631 | + if (is_admin() || !$query->is_main_query()) { |
|
632 | 632 | return; |
633 | 633 | } |
634 | 634 | |
635 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
635 | + $gateway = get_query_var('getpaid-ipn'); |
|
636 | 636 | |
637 | - if ( ! empty( $gateway ) ) { |
|
637 | + if (!empty($gateway)) { |
|
638 | 638 | |
639 | - $gateway = sanitize_text_field( $gateway ); |
|
639 | + $gateway = sanitize_text_field($gateway); |
|
640 | 640 | nocache_headers(); |
641 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
642 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
641 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
642 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
643 | 643 | exit; |
644 | 644 | |
645 | 645 | } |
@@ -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,13 +48,13 @@ discard block |
||
48 | 48 | // Create any missing database tables. |
49 | 49 | $method = "upgrade_from_$upgrade_from"; |
50 | 50 | |
51 | - $installed = get_option( 'gepaid_installed_on' ); |
|
51 | + $installed = get_option('gepaid_installed_on'); |
|
52 | 52 | |
53 | - if ( empty( $installed ) ) { |
|
54 | - update_option( 'gepaid_installed_on', time() ); |
|
53 | + if (empty($installed)) { |
|
54 | + update_option('gepaid_installed_on', time()); |
|
55 | 55 | } |
56 | 56 | |
57 | - if ( method_exists( $this, $method ) ) { |
|
57 | + if (method_exists($this, $method)) { |
|
58 | 58 | $this->$method(); |
59 | 59 | } |
60 | 60 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->create_invoice_items_table(); |
71 | 71 | |
72 | 72 | // Save default tax rates. |
73 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
73 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,27 +81,27 @@ discard block |
||
81 | 81 | global $wpdb; |
82 | 82 | |
83 | 83 | // Invoices. |
84 | - $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' )" ); |
|
85 | - if ( ! empty( $results ) ) { |
|
86 | - $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' )" ); |
|
84 | + $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' )"); |
|
85 | + if (!empty($results)) { |
|
86 | + $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' )"); |
|
87 | 87 | |
88 | 88 | // Clean post cache |
89 | - foreach ( $results as $row ) { |
|
90 | - clean_post_cache( $row->ID ); |
|
89 | + foreach ($results as $row) { |
|
90 | + clean_post_cache($row->ID); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Item meta key changes |
95 | 95 | $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' )"; |
96 | - $results = $wpdb->get_results( $query ); |
|
96 | + $results = $wpdb->get_results($query); |
|
97 | 97 | |
98 | - if ( ! empty( $results ) ) { |
|
99 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
100 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
101 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
98 | + if (!empty($results)) { |
|
99 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
100 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
101 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
102 | 102 | |
103 | - foreach ( $results as $row ) { |
|
104 | - clean_post_cache( $row->post_id ); |
|
103 | + foreach ($results as $row) { |
|
104 | + clean_post_cache($row->post_id); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function upgrade_from_207() { |
135 | 135 | global $wpdb; |
136 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
136 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);"); |
|
137 | 137 | $this->upgrade_from_2615(); |
138 | 138 | } |
139 | 139 | |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function upgrade_from_2615() { |
145 | 145 | global $wpdb; |
146 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';" ); |
|
147 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';" ); |
|
146 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';"); |
|
147 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';"); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | */ |
154 | 154 | public function add_capabilities() { |
155 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
155 | + $GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | |
168 | 168 | // Checkout page. |
169 | 169 | 'checkout_page' => array( |
170 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
171 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
170 | + 'name' => _x('gp-checkout', 'Page slug', 'invoicing'), |
|
171 | + 'title' => _x('Checkout', 'Page title', 'invoicing'), |
|
172 | 172 | 'content' => ' |
173 | 173 | <!-- wp:shortcode --> |
174 | 174 | [wpinv_checkout] |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | |
180 | 180 | // Invoice history page. |
181 | 181 | 'invoice_history_page' => array( |
182 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
183 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
182 | + 'name' => _x('gp-invoices', 'Page slug', 'invoicing'), |
|
183 | + 'title' => _x('My Invoices', 'Page title', 'invoicing'), |
|
184 | 184 | 'content' => ' |
185 | 185 | <!-- wp:shortcode --> |
186 | 186 | [wpinv_history] |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | |
192 | 192 | // Success page content. |
193 | 193 | 'success_page' => array( |
194 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
195 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
194 | + 'name' => _x('gp-receipt', 'Page slug', 'invoicing'), |
|
195 | + 'title' => _x('Payment Confirmation', 'Page title', 'invoicing'), |
|
196 | 196 | 'content' => ' |
197 | 197 | <!-- wp:shortcode --> |
198 | 198 | [wpinv_receipt] |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | |
204 | 204 | // Failure page content. |
205 | 205 | 'failure_page' => array( |
206 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
207 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
208 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
206 | + 'name' => _x('gp-transaction-failed', 'Page slug', 'invoicing'), |
|
207 | + 'title' => _x('Transaction Failed', 'Page title', 'invoicing'), |
|
208 | + 'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
209 | 209 | 'parent' => 'gp-checkout', |
210 | 210 | ), |
211 | 211 | |
212 | 212 | // Subscriptions history page. |
213 | 213 | 'invoice_subscription_page' => array( |
214 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
215 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
214 | + 'name' => _x('gp-subscriptions', 'Page slug', 'invoicing'), |
|
215 | + 'title' => _x('My Subscriptions', 'Page title', 'invoicing'), |
|
216 | 216 | 'content' => ' |
217 | 217 | <!-- wp:shortcode --> |
218 | 218 | [wpinv_subscriptions] |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function create_pages() { |
234 | 234 | |
235 | - foreach ( self::get_pages() as $key => $page ) { |
|
236 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
235 | + foreach (self::get_pages() as $key => $page) { |
|
236 | + wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | KEY customer_and_status (customer_id, status) |
274 | 274 | ) $charset_collate;"; |
275 | 275 | |
276 | - dbDelta( $sql ); |
|
276 | + dbDelta($sql); |
|
277 | 277 | |
278 | 278 | } |
279 | 279 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | KEY `key` (`key`) |
325 | 325 | ) $charset_collate;"; |
326 | 326 | |
327 | - dbDelta( $sql ); |
|
327 | + dbDelta($sql); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | KEY post_id (post_id) |
362 | 362 | ) $charset_collate;"; |
363 | 363 | |
364 | - dbDelta( $sql ); |
|
364 | + dbDelta($sql); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
@@ -374,32 +374,32 @@ discard block |
||
374 | 374 | |
375 | 375 | $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
376 | 376 | $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
377 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
377 | + $migrated = $wpdb->get_col("SELECT post_id FROM $invoices_table"); |
|
378 | 378 | $invoices = array_unique( |
379 | 379 | get_posts( |
380 | 380 | array( |
381 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
381 | + 'post_type' => array('wpi_invoice', 'wpi_quote'), |
|
382 | 382 | 'posts_per_page' => -1, |
383 | 383 | 'fields' => 'ids', |
384 | - 'post_status' => array_keys( get_post_stati() ), |
|
384 | + 'post_status' => array_keys(get_post_stati()), |
|
385 | 385 | 'exclude' => (array) $migrated, |
386 | 386 | ) |
387 | 387 | ) |
388 | 388 | ); |
389 | 389 | |
390 | 390 | // Abort if we do not have any invoices. |
391 | - if ( empty( $invoices ) ) { |
|
391 | + if (empty($invoices)) { |
|
392 | 392 | return; |
393 | 393 | } |
394 | 394 | |
395 | 395 | require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php'; |
396 | 396 | |
397 | 397 | $invoice_rows = array(); |
398 | - foreach ( $invoices as $invoice ) { |
|
398 | + foreach ($invoices as $invoice) { |
|
399 | 399 | |
400 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
400 | + $invoice = new WPInv_Legacy_Invoice($invoice); |
|
401 | 401 | |
402 | - if ( empty( $invoice->ID ) ) { |
|
402 | + if (empty($invoice->ID)) { |
|
403 | 403 | return; |
404 | 404 | } |
405 | 405 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | 'post_id' => $invoice->ID, |
408 | 408 | 'number' => $invoice->get_number(), |
409 | 409 | 'key' => $invoice->get_key(), |
410 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
410 | + 'type' => str_replace('wpi_', '', $invoice->post_type), |
|
411 | 411 | 'mode' => $invoice->mode, |
412 | 412 | 'user_ip' => $invoice->get_ip(), |
413 | 413 | 'first_name' => $invoice->get_first_name(), |
@@ -436,27 +436,27 @@ discard block |
||
436 | 436 | 'custom_meta' => $invoice->payment_meta, |
437 | 437 | ); |
438 | 438 | |
439 | - foreach ( $fields as $key => $val ) { |
|
440 | - if ( is_null( $val ) ) { |
|
439 | + foreach ($fields as $key => $val) { |
|
440 | + if (is_null($val)) { |
|
441 | 441 | $val = ''; |
442 | 442 | } |
443 | - $val = maybe_serialize( $val ); |
|
444 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
443 | + $val = maybe_serialize($val); |
|
444 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
445 | 445 | } |
446 | 446 | |
447 | - $fields = implode( ', ', $fields ); |
|
447 | + $fields = implode(', ', $fields); |
|
448 | 448 | $invoice_rows[] = "($fields)"; |
449 | 449 | |
450 | 450 | $item_rows = array(); |
451 | 451 | $item_columns = array(); |
452 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
452 | + foreach ($invoice->get_cart_details() as $details) { |
|
453 | 453 | $fields = array( |
454 | 454 | 'post_id' => $invoice->ID, |
455 | 455 | 'item_id' => $details['id'], |
456 | 456 | 'item_name' => $details['name'], |
457 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
457 | + 'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'], |
|
458 | 458 | 'vat_rate' => $details['vat_rate'], |
459 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
459 | + 'vat_class' => empty($details['vat_class']) ? '_standard' : $details['vat_class'], |
|
460 | 460 | 'tax' => $details['tax'], |
461 | 461 | 'item_price' => $details['item_price'], |
462 | 462 | 'custom_price' => $details['custom_price'], |
@@ -468,31 +468,31 @@ discard block |
||
468 | 468 | 'fees' => $details['fees'], |
469 | 469 | ); |
470 | 470 | |
471 | - $item_columns = array_keys( $fields ); |
|
471 | + $item_columns = array_keys($fields); |
|
472 | 472 | |
473 | - foreach ( $fields as $key => $val ) { |
|
474 | - if ( is_null( $val ) ) { |
|
473 | + foreach ($fields as $key => $val) { |
|
474 | + if (is_null($val)) { |
|
475 | 475 | $val = ''; |
476 | 476 | } |
477 | - $val = maybe_serialize( $val ); |
|
478 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
477 | + $val = maybe_serialize($val); |
|
478 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
479 | 479 | } |
480 | 480 | |
481 | - $fields = implode( ', ', $fields ); |
|
481 | + $fields = implode(', ', $fields); |
|
482 | 482 | $item_rows[] = "($fields)"; |
483 | 483 | } |
484 | 484 | |
485 | - $item_rows = implode( ', ', $item_rows ); |
|
486 | - $item_columns = implode( ', ', $item_columns ); |
|
487 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
485 | + $item_rows = implode(', ', $item_rows); |
|
486 | + $item_columns = implode(', ', $item_columns); |
|
487 | + $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows"); |
|
488 | 488 | } |
489 | 489 | |
490 | - if ( empty( $invoice_rows ) ) { |
|
490 | + if (empty($invoice_rows)) { |
|
491 | 491 | return; |
492 | 492 | } |
493 | 493 | |
494 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
495 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
494 | + $invoice_rows = implode(', ', $invoice_rows); |
|
495 | + $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows"); |
|
496 | 496 | |
497 | 497 | } |
498 | 498 | |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | public static function rename_gateways_label() { |
504 | 504 | global $wpdb; |
505 | 505 | |
506 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
506 | + foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) { |
|
507 | 507 | |
508 | 508 | $wpdb->update( |
509 | 509 | $wpdb->prefix . 'getpaid_invoices', |
510 | - array( 'gateway' => $gateway ), |
|
511 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
510 | + array('gateway' => $gateway), |
|
511 | + array('gateway' => wpinv_get_gateway_admin_label($gateway)), |
|
512 | 512 | '%s', |
513 | 513 | '%s' |
514 | 514 | ); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package GetPaid |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Generates a users select dropdown. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param array $args |
17 | 17 | * @see wp_dropdown_users |
18 | 18 | */ |
19 | -function wpinv_dropdown_users( $args = '' ) { |
|
19 | +function wpinv_dropdown_users($args = '') { |
|
20 | 20 | |
21 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
21 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
22 | 22 | $args['show'] = 'display_name_with_login'; |
23 | 23 | } |
24 | 24 | |
25 | - return wp_dropdown_users( $args ); |
|
25 | + return wp_dropdown_users($args); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @return string capability to check against |
33 | 33 | * @param string $capalibilty Optional. The alternative capability to check against. |
34 | 34 | */ |
35 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
35 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
37 | + if (current_user_can('manage_options')) { |
|
38 | 38 | return 'manage_options'; |
39 | 39 | }; |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return bool |
49 | 49 | */ |
50 | 50 | function wpinv_current_user_can_manage_invoicing() { |
51 | - return current_user_can( wpinv_get_capability() ); |
|
51 | + return current_user_can(wpinv_get_capability()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | * @since 1.0.19 |
58 | 58 | * @return int|WP_Error |
59 | 59 | */ |
60 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
60 | +function wpinv_create_user($email, $prefix = '') { |
|
61 | 61 | |
62 | 62 | // Prepare user values. |
63 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
64 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
63 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
64 | + $prefix = empty($prefix) ? $email : $prefix; |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
67 | 67 | 'user_pass' => wp_generate_password(), |
68 | 68 | 'user_email' => $email, |
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
72 | - return wp_insert_user( $args ); |
|
72 | + return wp_insert_user($args); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * @since 1.0.19 |
80 | 80 | * @return bool|WP_User |
81 | 81 | */ |
82 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
82 | +function wpinv_generate_user_name($prefix = '') { |
|
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
86 | - $prefix = trim( $prefix, '.' ); |
|
85 | + $prefix = strtok($prefix, '@'); |
|
86 | + $prefix = trim($prefix, '.'); |
|
87 | 87 | |
88 | 88 | // Sanitize the username. |
89 | - $prefix = sanitize_user( $prefix, true ); |
|
89 | + $prefix = sanitize_user($prefix, true); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
91 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
92 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
93 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
98 | 98 | |
99 | - while ( username_exists( $username ) ) { |
|
99 | + while (username_exists($username)) { |
|
100 | 100 | $username = "{$prefix}{$postfix}"; |
101 | - $postfix ++; |
|
101 | + $postfix++; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $username; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $tabs = array( |
116 | 116 | |
117 | 117 | 'gp-invoices' => array( |
118 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
118 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
119 | 119 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
120 | 120 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
121 | 121 | ), |
122 | 122 | |
123 | 123 | 'gp-subscriptions' => array( |
124 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
124 | + 'label' => __('Subscriptions', 'invoicing'), |
|
125 | 125 | 'content' => '[wpinv_subscriptions]', |
126 | 126 | 'icon' => 'fas fa-redo', |
127 | 127 | ), |
128 | 128 | |
129 | 129 | 'gp-edit-address' => array( |
130 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
130 | + 'label' => __('Billing Address', 'invoicing'), |
|
131 | 131 | 'callback' => 'getpaid_display_address_edit_tab', |
132 | 132 | 'icon' => 'fas fa-credit-card', |
133 | 133 | ), |
134 | 134 | |
135 | 135 | ); |
136 | 136 | |
137 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
137 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
138 | 138 | |
139 | 139 | // Make sure address editing is last on the list. |
140 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
140 | + if (isset($tabs['gp-edit-address'])) { |
|
141 | 141 | $address = $tabs['gp-edit-address']; |
142 | - unset( $tabs['gp-edit-address'] ); |
|
142 | + unset($tabs['gp-edit-address']); |
|
143 | 143 | $tabs['gp-edit-address'] = $address; |
144 | 144 | } |
145 | 145 | |
@@ -153,19 +153,19 @@ discard block |
||
153 | 153 | * @param array $tab |
154 | 154 | * @return array |
155 | 155 | */ |
156 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
156 | +function getpaid_prepare_user_content_tab($tab) { |
|
157 | 157 | |
158 | - if ( ! empty( $tab['callback'] ) ) { |
|
159 | - return call_user_func( $tab['callback'] ); |
|
158 | + if (!empty($tab['callback'])) { |
|
159 | + return call_user_func($tab['callback']); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! empty( $tab['content'] ) ) { |
|
163 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
162 | + if (!empty($tab['content'])) { |
|
163 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $notice = aui()->alert( |
167 | 167 | array( |
168 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
168 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
169 | 169 | 'type' => 'error', |
170 | 170 | ) |
171 | 171 | ); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @param string $default |
182 | 182 | * @return array |
183 | 183 | */ |
184 | -function getpaid_get_tab_url( $tab, $default ) { |
|
184 | +function getpaid_get_tab_url($tab, $default) { |
|
185 | 185 | global $getpaid_tab_url; |
186 | 186 | |
187 | - if ( empty( $getpaid_tab_url ) ) { |
|
187 | + if (empty($getpaid_tab_url)) { |
|
188 | 188 | return $default; |
189 | 189 | } |
190 | 190 | |
191 | - return sprintf( $getpaid_tab_url, $tab ); |
|
191 | + return sprintf($getpaid_tab_url, $tab); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | */ |
201 | 201 | function getpaid_display_address_edit_tab() { |
202 | 202 | |
203 | - if ( 0 === get_current_user_id() ) { |
|
203 | + if (0 === get_current_user_id()) { |
|
204 | 204 | return '<div class="bsui">' . aui()->alert( |
205 | 205 | array( |
206 | 206 | 'type' => 'error', |
207 | - 'content' => __( 'Your must be logged in to view this section', 'invoicing' ), |
|
207 | + 'content' => __('Your must be logged in to view this section', 'invoicing'), |
|
208 | 208 | 'dismissible' => false, |
209 | 209 | ) |
210 | 210 | ) . '</div>'; |
@@ -218,19 +218,19 @@ discard block |
||
218 | 218 | |
219 | 219 | <?php |
220 | 220 | |
221 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
221 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
222 | 222 | |
223 | 223 | // Display the country. |
224 | - if ( 'country' == $key ) { |
|
224 | + if ('country' == $key) { |
|
225 | 225 | |
226 | 226 | aui()->select( |
227 | 227 | array( |
228 | 228 | 'options' => wpinv_get_country_list(), |
229 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
230 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
231 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
229 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
230 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
231 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
232 | 232 | 'placeholder' => $label, |
233 | - 'label' => wp_kses_post( $label ), |
|
233 | + 'label' => wp_kses_post($label), |
|
234 | 234 | 'label_type' => 'vertical', |
235 | 235 | 'class' => 'getpaid-address-field', |
236 | 236 | ), |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | // Display the state. |
243 | - elseif ( 'state' == $key ) { |
|
243 | + elseif ('state' == $key) { |
|
244 | 244 | |
245 | 245 | getpaid_get_states_select_markup( |
246 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
247 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
246 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
247 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
248 | 248 | $label, |
249 | 249 | $label, |
250 | 250 | '', |
251 | 251 | false, |
252 | 252 | '', |
253 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
253 | + 'getpaid_address[' . esc_attr($key) . ']', |
|
254 | 254 | true |
255 | 255 | ); |
256 | 256 | |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | |
259 | 259 | aui()->input( |
260 | 260 | array( |
261 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
262 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
261 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
262 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
263 | 263 | 'placeholder' => $label, |
264 | - 'label' => wp_kses_post( $label ), |
|
264 | + 'label' => wp_kses_post($label), |
|
265 | 265 | 'label_type' => 'vertical', |
266 | 266 | 'type' => 'text', |
267 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
267 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
268 | 268 | 'class' => 'getpaid-address-field', |
269 | 269 | ), |
270 | 270 | true |
@@ -278,32 +278,32 @@ discard block |
||
278 | 278 | 'name' => 'getpaid_address[email_cc]', |
279 | 279 | 'id' => 'wpinv-email_cc', |
280 | 280 | 'placeholder' => '[email protected], [email protected]', |
281 | - 'label' => __( 'Other email addresses', 'invoicing' ), |
|
281 | + 'label' => __('Other email addresses', 'invoicing'), |
|
282 | 282 | 'label_type' => 'vertical', |
283 | 283 | 'type' => 'text', |
284 | - 'value' => sanitize_text_field( get_user_meta( get_current_user_id(), '_wpinv_email_cc', true ) ), |
|
284 | + 'value' => sanitize_text_field(get_user_meta(get_current_user_id(), '_wpinv_email_cc', true)), |
|
285 | 285 | 'class' => 'getpaid-address-field', |
286 | - 'help_text' => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ), |
|
286 | + 'help_text' => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'), |
|
287 | 287 | ), |
288 | 288 | true |
289 | 289 | ); |
290 | 290 | |
291 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
291 | + do_action('getpaid_display_address_edit_tab'); |
|
292 | 292 | |
293 | 293 | aui()->input( |
294 | 294 | array( |
295 | 295 | 'name' => 'getpaid_profile_edit_submit_button', |
296 | 296 | 'id' => 'getpaid_profile_edit_submit_button', |
297 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
298 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
297 | + 'value' => __('Save Address', 'invoicing'), |
|
298 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
299 | 299 | 'type' => 'submit', |
300 | 300 | 'class' => 'btn btn-primary btn-block submit-button', |
301 | 301 | ), |
302 | 302 | true |
303 | 303 | ); |
304 | 304 | |
305 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
306 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
305 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
306 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
307 | 307 | ?> |
308 | 308 | |
309 | 309 | </form> |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | return ob_get_clean(); |
315 | 315 | } |
316 | -add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' ); |
|
316 | +add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Saves the billing address edit tab. |
@@ -321,30 +321,30 @@ discard block |
||
321 | 321 | * @since 2.1.4 |
322 | 322 | * @param array $data |
323 | 323 | */ |
324 | -function getpaid_save_address_edit_tab( $data ) { |
|
324 | +function getpaid_save_address_edit_tab($data) { |
|
325 | 325 | |
326 | - if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) { |
|
326 | + if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) { |
|
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | 330 | $data = $data['getpaid_address']; |
331 | 331 | $user_id = get_current_user_id(); |
332 | 332 | |
333 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
333 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
334 | 334 | |
335 | - if ( isset( $data[ $field ] ) ) { |
|
336 | - $value = sanitize_text_field( $data[ $field ] ); |
|
337 | - update_user_meta( $user_id, '_wpinv_' . $field, $value ); |
|
335 | + if (isset($data[$field])) { |
|
336 | + $value = sanitize_text_field($data[$field]); |
|
337 | + update_user_meta($user_id, '_wpinv_' . $field, $value); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | - if ( isset( $data['email_cc'] ) ) { |
|
342 | - update_user_meta( $user_id, '_wpinv_email_cc', sanitize_text_field( $data['email_cc'] ) ); |
|
341 | + if (isset($data['email_cc'])) { |
|
342 | + update_user_meta($user_id, '_wpinv_email_cc', sanitize_text_field($data['email_cc'])); |
|
343 | 343 | } |
344 | 344 | |
345 | - wpinv_set_error( 'address_updated', __( 'Your billing address has been updated', 'invoicing' ), 'success' ); |
|
345 | + wpinv_set_error('address_updated', __('Your billing address has been updated', 'invoicing'), 'success'); |
|
346 | 346 | } |
347 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
347 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
348 | 348 | |
349 | 349 | |
350 | 350 | /* |
@@ -362,27 +362,27 @@ discard block |
||
362 | 362 | * @param array $tabs |
363 | 363 | * @return array |
364 | 364 | */ |
365 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
365 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
366 | 366 | |
367 | 367 | // Abort if the integration is inactive. |
368 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
368 | + if (!getpaid_is_userswp_integration_active()) { |
|
369 | 369 | return $tabs; |
370 | 370 | } |
371 | 371 | |
372 | - $new_tabs = array(); |
|
372 | + $new_tabs = array(); |
|
373 | 373 | |
374 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
374 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
375 | 375 | |
376 | - $new_tabs[ $slug ] = array( |
|
376 | + $new_tabs[$slug] = array( |
|
377 | 377 | 'title' => $tab['label'], |
378 | 378 | 'icon' => $tab['icon'], |
379 | 379 | ); |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - return array_merge( $tabs, $new_tabs ); |
|
383 | + return array_merge($tabs, $new_tabs); |
|
384 | 384 | } |
385 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
385 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Display our UsersWP account tabs. |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | * @param array $tabs |
392 | 392 | * @return array |
393 | 393 | */ |
394 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
394 | +function getpaid_display_userswp_account_tabs($tab) { |
|
395 | 395 | global $getpaid_tab_url; |
396 | 396 | |
397 | 397 | $our_tabs = getpaid_get_user_content_tabs(); |
398 | 398 | |
399 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
400 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
401 | - echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() ); |
|
399 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
400 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
401 | + echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html()); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | } |
405 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
405 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
406 | 406 | |
407 | 407 | function getpaid_allowed_html() { |
408 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
408 | + $allowed_html = wp_kses_allowed_html('post'); |
|
409 | 409 | |
410 | 410 | // form fields |
411 | 411 | $allowed_html['form'] = array( |
@@ -476,17 +476,17 @@ discard block |
||
476 | 476 | * @param string $tab Current tab. |
477 | 477 | * @return string Title. |
478 | 478 | */ |
479 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
479 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
480 | 480 | |
481 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
481 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
482 | 482 | |
483 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
484 | - return $our_tabs[ $tab ]['label']; |
|
483 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
484 | + return $our_tabs[$tab]['label']; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | return $title; |
488 | 488 | } |
489 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
489 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
490 | 490 | |
491 | 491 | /** |
492 | 492 | * Registers the UsersWP integration settings. |
@@ -495,26 +495,26 @@ discard block |
||
495 | 495 | * @param array $settings An array of integration settings. |
496 | 496 | * @return array |
497 | 497 | */ |
498 | -function getpaid_register_userswp_settings( $settings ) { |
|
498 | +function getpaid_register_userswp_settings($settings) { |
|
499 | 499 | |
500 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
500 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
501 | 501 | |
502 | 502 | $settings[] = array( |
503 | 503 | |
504 | 504 | 'id' => 'userswp', |
505 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
505 | + 'label' => __('UsersWP', 'invoicing'), |
|
506 | 506 | 'settings' => array( |
507 | 507 | |
508 | 508 | 'userswp_settings' => array( |
509 | 509 | 'id' => 'userswp_settings', |
510 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
510 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
511 | 511 | 'type' => 'header', |
512 | 512 | ), |
513 | 513 | |
514 | 514 | 'enable_userswp' => array( |
515 | 515 | 'id' => 'enable_userswp', |
516 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
517 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
516 | + 'name' => __('Enable Integration', 'invoicing'), |
|
517 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
518 | 518 | 'type' => 'checkbox', |
519 | 519 | 'std' => 1, |
520 | 520 | ), |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | |
528 | 528 | return $settings; |
529 | 529 | } |
530 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
530 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
531 | 531 | |
532 | 532 | /** |
533 | 533 | * Ovewrites the invoices history page to UsersWP. |
@@ -535,18 +535,18 @@ discard block |
||
535 | 535 | * @since 2.3.1 |
536 | 536 | * @return bool |
537 | 537 | */ |
538 | -function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) { |
|
538 | +function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) { |
|
539 | 539 | |
540 | 540 | $our_tabs = getpaid_get_user_content_tabs(); |
541 | 541 | $tab = "gp-{$post_type}s"; |
542 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
543 | - return add_query_arg( 'type', $tab, uwp_get_account_page_url() ); |
|
542 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
543 | + return add_query_arg('type', $tab, uwp_get_account_page_url()); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | return $url; |
547 | 547 | |
548 | 548 | } |
549 | -add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 ); |
|
549 | +add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2); |
|
550 | 550 | |
551 | 551 | /** |
552 | 552 | * Checks if the integration is enabled. |
@@ -555,8 +555,8 @@ discard block |
||
555 | 555 | * @return bool |
556 | 556 | */ |
557 | 557 | function getpaid_is_userswp_integration_active() { |
558 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
559 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
558 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
559 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | /* |
@@ -574,26 +574,26 @@ discard block |
||
574 | 574 | * @param array $settings An array of integration settings. |
575 | 575 | * @return array |
576 | 576 | */ |
577 | -function getpaid_register_buddypress_settings( $settings ) { |
|
577 | +function getpaid_register_buddypress_settings($settings) { |
|
578 | 578 | |
579 | - if ( class_exists( 'BuddyPress' ) ) { |
|
579 | + if (class_exists('BuddyPress')) { |
|
580 | 580 | |
581 | 581 | $settings[] = array( |
582 | 582 | |
583 | 583 | 'id' => 'buddypress', |
584 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
584 | + 'label' => __('BuddyPress', 'invoicing'), |
|
585 | 585 | 'settings' => array( |
586 | 586 | |
587 | 587 | 'buddypress_settings' => array( |
588 | 588 | 'id' => 'buddypress_settings', |
589 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
589 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
590 | 590 | 'type' => 'header', |
591 | 591 | ), |
592 | 592 | |
593 | 593 | 'enable_buddypress' => array( |
594 | 594 | 'id' => 'enable_buddypress', |
595 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
596 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
595 | + 'name' => __('Enable Integration', 'invoicing'), |
|
596 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
597 | 597 | 'type' => 'checkbox', |
598 | 598 | 'std' => 1, |
599 | 599 | ), |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | return $settings; |
608 | 608 | } |
609 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
609 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
610 | 610 | |
611 | 611 | /** |
612 | 612 | * Checks if the integration is enabled. |
@@ -615,8 +615,8 @@ discard block |
||
615 | 615 | * @return bool |
616 | 616 | */ |
617 | 617 | function getpaid_is_buddypress_integration_active() { |
618 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
619 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
618 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
619 | + return class_exists('BuddyPress') && !empty($enabled); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -627,13 +627,13 @@ discard block |
||
627 | 627 | */ |
628 | 628 | function getpaid_setup_buddypress_integration() { |
629 | 629 | |
630 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
630 | + if (getpaid_is_buddypress_integration_active()) { |
|
631 | 631 | require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'; |
632 | 632 | buddypress()->getpaid = new BP_GetPaid_Component(); |
633 | 633 | } |
634 | 634 | |
635 | 635 | } |
636 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
636 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
|
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Checks if a given user has purchased a given item. |
@@ -641,10 +641,10 @@ discard block |
||
641 | 641 | * @since 2.6.17 |
642 | 642 | * @param int $user_id The user id. |
643 | 643 | */ |
644 | -function getpaid_has_user_purchased_item( $user_id, $item_id ) { |
|
644 | +function getpaid_has_user_purchased_item($user_id, $item_id) { |
|
645 | 645 | global $wpdb; |
646 | 646 | |
647 | - if ( empty( $user_id ) ) { |
|
647 | + if (empty($user_id)) { |
|
648 | 648 | return false; |
649 | 649 | } |
650 | 650 | |
@@ -659,5 +659,5 @@ discard block |
||
659 | 659 | ) |
660 | 660 | ); |
661 | 661 | |
662 | - return ! empty( $count ); |
|
662 | + return !empty($count); |
|
663 | 663 | } |
@@ -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 | * The main admin class. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | 41 | |
42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
44 | 44 | $this->reports = new GetPaid_Reports(); |
45 | 45 | |
46 | - if ( is_admin() ) { |
|
46 | + if (is_admin()) { |
|
47 | 47 | $this->init_admin_hooks(); |
48 | 48 | } |
49 | 49 | |
@@ -54,34 +54,34 @@ discard block |
||
54 | 54 | * |
55 | 55 | */ |
56 | 56 | private function init_admin_hooks() { |
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 ); |
|
58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
60 | - add_action( 'admin_init', array( $this, 'activation_redirect' ) ); |
|
61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) ); |
|
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
71 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
75 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
76 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
77 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
78 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9); |
|
58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
63 | + add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); |
|
64 | + add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form')); |
|
65 | + add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice')); |
|
66 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
67 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
68 | + add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); |
|
69 | + add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
70 | + add_action('getpaid_authenticated_admin_action_refresh_permalinks', array($this, 'admin_refresh_permalinks')); |
|
71 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
72 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
73 | + add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); |
|
74 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
75 | + add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); |
|
76 | + add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); |
|
77 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
78 | + do_action('getpaid_init_admin_hooks', $this); |
|
79 | 79 | |
80 | 80 | // Setup/welcome |
81 | - if ( ! empty( $_GET['page'] ) ) { |
|
82 | - switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
81 | + if (!empty($_GET['page'])) { |
|
82 | + switch (sanitize_text_field($_GET['page'])) { |
|
83 | 83 | case 'gp-setup': |
84 | - include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
84 | + include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php'; |
|
85 | 85 | break; |
86 | 86 | } |
87 | 87 | } |
@@ -95,37 +95,37 @@ discard block |
||
95 | 95 | public function enqeue_scripts() { |
96 | 96 | global $current_screen, $pagenow; |
97 | 97 | |
98 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
98 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
99 | 99 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
100 | 100 | |
101 | - if ( ! empty( $current_screen->post_type ) ) { |
|
101 | + if (!empty($current_screen->post_type)) { |
|
102 | 102 | $page = $current_screen->post_type; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // General styles. |
106 | - if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) { |
|
106 | + if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) { |
|
107 | 107 | |
108 | 108 | // Styles. |
109 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
110 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
111 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
109 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
110 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
111 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
112 | 112 | |
113 | 113 | // Scripts. |
114 | - wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
114 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
115 | 115 | |
116 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
117 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
118 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
116 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
117 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
118 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | 122 | // Payment form scripts. |
123 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
123 | + if ('wpi_payment_form' == $page && $editing) { |
|
124 | 124 | $this->load_payment_form_scripts(); |
125 | 125 | } |
126 | 126 | |
127 | - if ( $page == 'wpinv-subscriptions' ) { |
|
128 | - wp_enqueue_script( 'postbox' ); |
|
127 | + if ($page == 'wpinv-subscriptions') { |
|
128 | + wp_enqueue_script('postbox'); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | } |
@@ -138,31 +138,31 @@ discard block |
||
138 | 138 | global $post; |
139 | 139 | |
140 | 140 | $date_range = array( |
141 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
141 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days', |
|
142 | 142 | ); |
143 | 143 | |
144 | - if ( $date_range['period'] == 'custom' ) { |
|
144 | + if ($date_range['period'] == 'custom') { |
|
145 | 145 | |
146 | - if ( isset( $_GET['from'] ) ) { |
|
147 | - $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
146 | + if (isset($_GET['from'])) { |
|
147 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( isset( $_GET['to'] ) ) { |
|
151 | - $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
150 | + if (isset($_GET['to'])) { |
|
151 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | 155 | $i18n = array( |
156 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
157 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
158 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
159 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
160 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
156 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
157 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
158 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
159 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
160 | + 'rest_root' => esc_url_raw(rest_url()), |
|
161 | 161 | 'date_range' => $date_range, |
162 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
163 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
164 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
165 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
162 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
163 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
164 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
165 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
166 | 166 | 'tax' => wpinv_tax_amount(), |
167 | 167 | 'discount' => 0, |
168 | 168 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -171,39 +171,39 @@ discard block |
||
171 | 171 | 'thousand_sep' => wpinv_thousands_separator(), |
172 | 172 | 'decimal_sep' => wpinv_decimal_separator(), |
173 | 173 | 'decimals' => wpinv_decimals(), |
174 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
175 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
176 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
177 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
178 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
179 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
180 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
181 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
182 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
183 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
184 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
185 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
186 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
187 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
188 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
189 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
190 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
191 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
192 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
193 | - 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
174 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
175 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
176 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
177 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
178 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
179 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
180 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
181 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
182 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
183 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
184 | + 'action_edit' => __('Edit', 'invoicing'), |
|
185 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
186 | + 'item_description' => __('Item Description', 'invoicing'), |
|
187 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
188 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
189 | + 'searching' => __('Searching', 'invoicing'), |
|
190 | + 'loading' => __('Loading...', 'invoicing'), |
|
191 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
192 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
193 | + 'graphs' => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())), |
|
194 | 194 | ); |
195 | 195 | |
196 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
196 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
197 | 197 | |
198 | - $invoice = new WPInv_Invoice( $post ); |
|
198 | + $invoice = new WPInv_Invoice($post); |
|
199 | 199 | $i18n['save_invoice'] = sprintf( |
200 | - __( 'Save %s', 'invoicing' ), |
|
201 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
200 | + __('Save %s', 'invoicing'), |
|
201 | + ucfirst($invoice->get_invoice_quote_type()) |
|
202 | 202 | ); |
203 | 203 | |
204 | 204 | $i18n['invoice_description'] = sprintf( |
205 | - __( '%s Description', 'invoicing' ), |
|
206 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
205 | + __('%s Description', 'invoicing'), |
|
206 | + ucfirst($invoice->get_invoice_quote_type()) |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | } |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | * @param string $footer_text |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function admin_footer_text( $footer_text ) { |
|
220 | + public function admin_footer_text($footer_text) { |
|
221 | 221 | global $current_screen; |
222 | 222 | |
223 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
223 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
224 | 224 | |
225 | - if ( ! empty( $current_screen->post_type ) ) { |
|
225 | + if (!empty($current_screen->post_type)) { |
|
226 | 226 | $page = $current_screen->post_type; |
227 | 227 | } |
228 | 228 | |
229 | 229 | // General styles. |
230 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
230 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
231 | 231 | |
232 | 232 | // Change the footer text |
233 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
233 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
234 | 234 | |
235 | - $rating_url = esc_url( |
|
235 | + $rating_url = esc_url( |
|
236 | 236 | wp_nonce_url( |
237 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
237 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
238 | 238 | 'getpaid-nonce', |
239 | 239 | 'getpaid-nonce' |
240 | 240 | ) |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $footer_text = sprintf( |
244 | 244 | /* translators: %s: five stars */ |
245 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
245 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
246 | 246 | "<a href='$rating_url'>★★★★★</a>" |
247 | 247 | ); |
248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | $footer_text = sprintf( |
252 | 252 | /* translators: %s: GetPaid */ |
253 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
253 | + __('Thank you for using %s!', 'invoicing'), |
|
254 | 254 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
255 | 255 | ); |
256 | 256 | |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @since 2.0.0 |
267 | 267 | */ |
268 | 268 | public function redirect_to_wordpress_rating_page() { |
269 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
270 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
269 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
270 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
271 | 271 | exit; |
272 | 272 | } |
273 | 273 | |
@@ -278,30 +278,30 @@ discard block |
||
278 | 278 | protected function load_payment_form_scripts() { |
279 | 279 | global $post; |
280 | 280 | |
281 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
|
282 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
283 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
281 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); |
|
282 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
283 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
284 | 284 | |
285 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
286 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version ); |
|
285 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
286 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version); |
|
287 | 287 | |
288 | 288 | wp_localize_script( |
289 | 289 | 'wpinv-admin-payment-form-script', |
290 | 290 | 'wpinvPaymentFormAdmin', |
291 | 291 | array( |
292 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
293 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
292 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
293 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
294 | 294 | 'currency' => wpinv_currency_symbol(), |
295 | 295 | 'position' => wpinv_currency_position(), |
296 | 296 | 'decimals' => (int) wpinv_decimals(), |
297 | 297 | 'thousands_sep' => wpinv_thousands_separator(), |
298 | 298 | 'decimals_sep' => wpinv_decimal_separator(), |
299 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
299 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
300 | 300 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
301 | 301 | ) |
302 | 302 | ); |
303 | 303 | |
304 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
304 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | |
@@ -312,24 +312,24 @@ discard block |
||
312 | 312 | * @return string |
313 | 313 | * |
314 | 314 | */ |
315 | - public function admin_body_class( $classes ) { |
|
315 | + public function admin_body_class($classes) { |
|
316 | 316 | global $pagenow, $post, $current_screen; |
317 | 317 | |
318 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
318 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
319 | 319 | |
320 | - if ( ! empty( $current_screen->post_type ) ) { |
|
320 | + if (!empty($current_screen->post_type)) { |
|
321 | 321 | $page = $current_screen->post_type; |
322 | 322 | } |
323 | 323 | |
324 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
325 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
324 | + if (false !== stripos($page, 'wpi')) { |
|
325 | + $classes .= ' wpi-' . sanitize_key($page); |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
328 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
329 | 329 | $classes .= ' wpinv-cpt wpinv'; |
330 | 330 | } |
331 | 331 | |
332 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
332 | + if (getpaid_is_invoice_post_type($page)) { |
|
333 | 333 | $classes .= ' getpaid-is-invoice-cpt'; |
334 | 334 | } |
335 | 335 | |
@@ -348,21 +348,21 @@ discard block |
||
348 | 348 | 'version' => WPINV_VERSION, |
349 | 349 | 'support_url' => 'https://wpgetpaid.com/support/', |
350 | 350 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
351 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
351 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
352 | 352 | ) |
353 | 353 | ); |
354 | 354 | |
355 | 355 | new AyeCode_Connect_Helper( |
356 | 356 | array( |
357 | - 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
358 | - 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
359 | - 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
360 | - 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
361 | - 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
362 | - 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
363 | - 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
357 | + 'connect_title' => __('WP Invoicing - an AyeCode product!', 'invoicing'), |
|
358 | + 'connect_external' => __('Please confirm you wish to connect your site?', 'invoicing'), |
|
359 | + 'connect' => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'), |
|
360 | + 'connect_button' => __('Connect Site', 'invoicing'), |
|
361 | + 'connecting_button' => __('Connecting...', 'invoicing'), |
|
362 | + 'error_localhost' => __('This service will only work with a live domain, not a localhost.', 'invoicing'), |
|
363 | + 'error' => __('Something went wrong, please refresh and try again.', 'invoicing'), |
|
364 | 364 | ), |
365 | - array( 'wpi-addons' ) |
|
365 | + array('wpi-addons') |
|
366 | 366 | ); |
367 | 367 | |
368 | 368 | } |
@@ -374,20 +374,20 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function activation_redirect() { |
376 | 376 | |
377 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
377 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
378 | 378 | |
379 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
379 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Bail if activating from network, or bulk |
384 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
384 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
388 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
388 | + update_option('wpinv_redirected_to_settings', 1); |
|
389 | 389 | |
390 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
390 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
391 | 391 | exit; |
392 | 392 | |
393 | 393 | } |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function maybe_do_admin_action() { |
399 | 399 | |
400 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
401 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
402 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
400 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
401 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
402 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | } |
@@ -409,24 +409,24 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @param array $args |
411 | 411 | */ |
412 | - public function duplicate_invoice( $args ) { |
|
412 | + public function duplicate_invoice($args) { |
|
413 | 413 | |
414 | - if ( empty( $args['invoice_id'] ) ) { |
|
414 | + if (empty($args['invoice_id'])) { |
|
415 | 415 | return; |
416 | 416 | } |
417 | 417 | |
418 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
418 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
419 | 419 | |
420 | - if ( ! $invoice->exists() ) { |
|
420 | + if (!$invoice->exists()) { |
|
421 | 421 | return; |
422 | 422 | } |
423 | 423 | |
424 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
424 | + $new_invoice = getpaid_duplicate_invoice($invoice); |
|
425 | 425 | $new_invoice->save(); |
426 | 426 | |
427 | - if ( $new_invoice->exists() ) { |
|
427 | + if ($new_invoice->exists()) { |
|
428 | 428 | |
429 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) ); |
|
429 | + getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box')); |
|
430 | 430 | |
431 | 431 | wp_safe_redirect( |
432 | 432 | add_query_arg( |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | 'action' => 'edit', |
435 | 435 | 'post' => $new_invoice->get_id(), |
436 | 436 | ), |
437 | - admin_url( 'post.php' ) |
|
437 | + admin_url('post.php') |
|
438 | 438 | ) |
439 | 439 | ); |
440 | 440 | exit; |
441 | 441 | |
442 | 442 | } |
443 | 443 | |
444 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) ); |
|
444 | + getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box')); |
|
445 | 445 | |
446 | 446 | } |
447 | 447 | |
@@ -450,34 +450,34 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @param array $args |
452 | 452 | */ |
453 | - public function duplicate_payment_form( $args ) { |
|
453 | + public function duplicate_payment_form($args) { |
|
454 | 454 | |
455 | - if ( empty( $args['form_id'] ) ) { |
|
455 | + if (empty($args['form_id'])) { |
|
456 | 456 | return; |
457 | 457 | } |
458 | 458 | |
459 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
459 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
460 | 460 | |
461 | - if ( ! $form->exists() ) { |
|
461 | + if (!$form->exists()) { |
|
462 | 462 | return; |
463 | 463 | } |
464 | 464 | |
465 | 465 | $new_form = new GetPaid_Payment_Form(); |
466 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
467 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
468 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
469 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
466 | + $new_form->set_author($form->get_author('edit')); |
|
467 | + $new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); |
|
468 | + $new_form->set_elements($form->get_elements('edit')); |
|
469 | + $new_form->set_items($form->get_items('edit')); |
|
470 | 470 | $new_form->save(); |
471 | 471 | |
472 | - if ( $new_form->exists() ) { |
|
473 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
474 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
472 | + if ($new_form->exists()) { |
|
473 | + $this->show_success(__('Form duplicated successfully', 'invoicing')); |
|
474 | + $url = get_edit_post_link($new_form->get_id(), 'edit'); |
|
475 | 475 | } else { |
476 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
477 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
476 | + $this->show_error(__('Unable to duplicate form', 'invoicing')); |
|
477 | + $url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); |
|
478 | 478 | } |
479 | 479 | |
480 | - wp_redirect( $url ); |
|
480 | + wp_redirect($url); |
|
481 | 481 | exit; |
482 | 482 | } |
483 | 483 | |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @param array $args |
488 | 488 | */ |
489 | - public function send_customer_invoice( $args ) { |
|
490 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
491 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
489 | + public function send_customer_invoice($args) { |
|
490 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
491 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
492 | 492 | exit; |
493 | 493 | } |
494 | 494 | |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @param array $args |
499 | 499 | */ |
500 | - public function send_customer_payment_reminder( $args ) { |
|
501 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
500 | + public function send_customer_payment_reminder($args) { |
|
501 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
502 | 502 | |
503 | - if ( $sent ) { |
|
504 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
503 | + if ($sent) { |
|
504 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
505 | 505 | } else { |
506 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
506 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
507 | 507 | } |
508 | 508 | |
509 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
509 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
510 | 510 | exit; |
511 | 511 | } |
512 | 512 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | */ |
517 | 517 | public function admin_reset_tax_rates() { |
518 | 518 | |
519 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
520 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
519 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
520 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
521 | 521 | exit; |
522 | 522 | |
523 | 523 | } |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | public function admin_create_missing_pages() { |
530 | 530 | $installer = new GetPaid_Installer(); |
531 | 531 | $installer->create_pages(); |
532 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
533 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
532 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
533 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
534 | 534 | exit; |
535 | 535 | } |
536 | 536 | |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | */ |
540 | 540 | public function admin_refresh_permalinks() { |
541 | 541 | flush_rewrite_rules(); |
542 | - $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
543 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
542 | + $this->show_success(__('Permalinks refreshed.', 'invoicing')); |
|
543 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
544 | 544 | exit; |
545 | 545 | } |
546 | 546 | |
@@ -552,35 +552,35 @@ discard block |
||
552 | 552 | global $wpdb; |
553 | 553 | $installer = new GetPaid_Installer(); |
554 | 554 | |
555 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
555 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') { |
|
556 | 556 | $installer->create_subscriptions_table(); |
557 | 557 | |
558 | - if ( $wpdb->last_error !== '' ) { |
|
559 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
558 | + if ($wpdb->last_error !== '') { |
|
559 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | |
563 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
563 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') { |
|
564 | 564 | $installer->create_invoices_table(); |
565 | 565 | |
566 | - if ( '' !== $wpdb->last_error ) { |
|
567 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
566 | + if ('' !== $wpdb->last_error) { |
|
567 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
571 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') { |
|
572 | 572 | $installer->create_invoice_items_table(); |
573 | 573 | |
574 | - if ( '' !== $wpdb->last_error ) { |
|
575 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
574 | + if ('' !== $wpdb->last_error) { |
|
575 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
576 | 576 | } |
577 | 577 | } |
578 | 578 | |
579 | - if ( ! $this->has_notices() ) { |
|
580 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
579 | + if (!$this->has_notices()) { |
|
580 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
581 | 581 | } |
582 | 582 | |
583 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
583 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
584 | 584 | exit; |
585 | 585 | } |
586 | 586 | |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | $installer->migrate_old_invoices(); |
596 | 596 | |
597 | 597 | // Show an admin message. |
598 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
598 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
599 | 599 | |
600 | 600 | // Redirect the admin. |
601 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
601 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
602 | 602 | exit; |
603 | 603 | |
604 | 604 | } |
@@ -610,78 +610,78 @@ discard block |
||
610 | 610 | public function admin_download_customers() { |
611 | 611 | global $wpdb; |
612 | 612 | |
613 | - $output = fopen( 'php://output', 'w' ); |
|
613 | + $output = fopen('php://output', 'w'); |
|
614 | 614 | |
615 | - if ( false === $output ) { |
|
616 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
615 | + if (false === $output) { |
|
616 | + wp_die(esc_html__('Unsupported server', 'invoicing'), 500); |
|
617 | 617 | } |
618 | 618 | |
619 | - header( 'Content-Type:text/csv' ); |
|
620 | - header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
619 | + header('Content-Type:text/csv'); |
|
620 | + header('Content-Disposition:attachment;filename=customers.csv'); |
|
621 | 621 | |
622 | 622 | $post_types = ''; |
623 | 623 | |
624 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
625 | - $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type ); |
|
624 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
625 | + $post_types .= $wpdb->prepare('post_type=%s OR ', $post_type); |
|
626 | 626 | } |
627 | 627 | |
628 | - $post_types = rtrim( $post_types, ' OR' ); |
|
628 | + $post_types = rtrim($post_types, ' OR'); |
|
629 | 629 | |
630 | - $customers = $wpdb->get_col( "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" ); |
|
630 | + $customers = $wpdb->get_col("SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"); |
|
631 | 631 | |
632 | 632 | $columns = array( |
633 | - 'name' => __( 'Name', 'invoicing' ), |
|
634 | - 'email' => __( 'Email', 'invoicing' ), |
|
635 | - 'country' => __( 'Country', 'invoicing' ), |
|
636 | - 'state' => __( 'State', 'invoicing' ), |
|
637 | - 'city' => __( 'City', 'invoicing' ), |
|
638 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
639 | - 'address' => __( 'Address', 'invoicing' ), |
|
640 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
641 | - 'company' => __( 'Company', 'invoicing' ), |
|
642 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
643 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
644 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
645 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
633 | + 'name' => __('Name', 'invoicing'), |
|
634 | + 'email' => __('Email', 'invoicing'), |
|
635 | + 'country' => __('Country', 'invoicing'), |
|
636 | + 'state' => __('State', 'invoicing'), |
|
637 | + 'city' => __('City', 'invoicing'), |
|
638 | + 'zip' => __('ZIP', 'invoicing'), |
|
639 | + 'address' => __('Address', 'invoicing'), |
|
640 | + 'phone' => __('Phone', 'invoicing'), |
|
641 | + 'company' => __('Company', 'invoicing'), |
|
642 | + 'company_id' => __('Company ID', 'invoicing'), |
|
643 | + 'invoices' => __('Invoices', 'invoicing'), |
|
644 | + 'total_raw' => __('Total Spend', 'invoicing'), |
|
645 | + 'signup' => __('Date created', 'invoicing'), |
|
646 | 646 | ); |
647 | 647 | |
648 | 648 | // Output the csv column headers. |
649 | - fputcsv( $output, array_values( $columns ) ); |
|
649 | + fputcsv($output, array_values($columns)); |
|
650 | 650 | |
651 | 651 | // Loop through |
652 | 652 | $table = new WPInv_Customers_Table(); |
653 | - foreach ( $customers as $customer_id ) { |
|
653 | + foreach ($customers as $customer_id) { |
|
654 | 654 | |
655 | - $user = get_user_by( 'id', $customer_id ); |
|
655 | + $user = get_user_by('id', $customer_id); |
|
656 | 656 | $row = array(); |
657 | - if ( empty( $user ) ) { |
|
657 | + if (empty($user)) { |
|
658 | 658 | continue; |
659 | 659 | } |
660 | 660 | |
661 | - foreach ( array_keys( $columns ) as $column ) { |
|
661 | + foreach (array_keys($columns) as $column) { |
|
662 | 662 | |
663 | 663 | $method = 'column_' . $column; |
664 | 664 | |
665 | - if ( 'name' == $column ) { |
|
666 | - $value = esc_html( $user->display_name ); |
|
667 | - } elseif ( 'email' == $column ) { |
|
668 | - $value = sanitize_email( $user->user_email ); |
|
669 | - } elseif ( is_callable( array( $table, $method ) ) ) { |
|
670 | - $value = wp_strip_all_tags( $table->$method( $user ) ); |
|
665 | + if ('name' == $column) { |
|
666 | + $value = esc_html($user->display_name); |
|
667 | + } elseif ('email' == $column) { |
|
668 | + $value = sanitize_email($user->user_email); |
|
669 | + } elseif (is_callable(array($table, $method))) { |
|
670 | + $value = wp_strip_all_tags($table->$method($user)); |
|
671 | 671 | } |
672 | 672 | |
673 | - if ( empty( $value ) ) { |
|
674 | - $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
673 | + if (empty($value)) { |
|
674 | + $value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true)); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | $row[] = $value; |
678 | 678 | |
679 | 679 | } |
680 | 680 | |
681 | - fputcsv( $output, $row ); |
|
681 | + fputcsv($output, $row); |
|
682 | 682 | } |
683 | 683 | |
684 | - fclose( $output ); |
|
684 | + fclose($output); |
|
685 | 685 | exit; |
686 | 686 | |
687 | 687 | } |
@@ -691,27 +691,27 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @param array $data |
693 | 693 | */ |
694 | - public function admin_install_plugin( $data ) { |
|
694 | + public function admin_install_plugin($data) { |
|
695 | 695 | |
696 | - if ( ! empty( $data['plugins'] ) ) { |
|
696 | + if (!empty($data['plugins'])) { |
|
697 | 697 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
698 | 698 | wp_cache_flush(); |
699 | 699 | |
700 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
701 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
702 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
703 | - $installed = $upgrader->install( $plugin_zip ); |
|
700 | + foreach ($data['plugins'] as $slug => $file) { |
|
701 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
702 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
703 | + $installed = $upgrader->install($plugin_zip); |
|
704 | 704 | |
705 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
706 | - activate_plugin( $file, '', false, true ); |
|
705 | + if (!is_wp_error($installed) && $installed) { |
|
706 | + activate_plugin($file, '', false, true); |
|
707 | 707 | } else { |
708 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
708 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
714 | - wp_safe_redirect( $redirect ); |
|
713 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
714 | + wp_safe_redirect($redirect); |
|
715 | 715 | exit; |
716 | 716 | |
717 | 717 | } |
@@ -721,41 +721,41 @@ discard block |
||
721 | 721 | * |
722 | 722 | * @param array $data |
723 | 723 | */ |
724 | - public function admin_connect_gateway( $data ) { |
|
724 | + public function admin_connect_gateway($data) { |
|
725 | 725 | |
726 | - if ( ! empty( $data['plugin'] ) ) { |
|
726 | + if (!empty($data['plugin'])) { |
|
727 | 727 | |
728 | - $gateway = sanitize_key( $data['plugin'] ); |
|
729 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
728 | + $gateway = sanitize_key($data['plugin']); |
|
729 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
730 | 730 | |
731 | - if ( ! empty( $connect_url ) ) { |
|
732 | - wp_redirect( $connect_url ); |
|
731 | + if (!empty($connect_url)) { |
|
732 | + wp_redirect($connect_url); |
|
733 | 733 | exit; |
734 | 734 | } |
735 | 735 | |
736 | - if ( 'stripe' == $data['plugin'] ) { |
|
736 | + if ('stripe' == $data['plugin']) { |
|
737 | 737 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
738 | 738 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
739 | 739 | wp_cache_flush(); |
740 | 740 | |
741 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
742 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
743 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
744 | - $upgrader->install( $plugin_zip ); |
|
741 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
742 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
743 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
744 | + $upgrader->install($plugin_zip); |
|
745 | 745 | } |
746 | 746 | |
747 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
747 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
748 | 748 | } |
749 | 749 | |
750 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
751 | - if ( ! empty( $connect_url ) ) { |
|
752 | - wp_redirect( $connect_url ); |
|
750 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
751 | + if (!empty($connect_url)) { |
|
752 | + wp_redirect($connect_url); |
|
753 | 753 | exit; |
754 | 754 | } |
755 | 755 | } |
756 | 756 | |
757 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
758 | - wp_safe_redirect( $redirect ); |
|
757 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
758 | + wp_safe_redirect($redirect); |
|
759 | 759 | exit; |
760 | 760 | |
761 | 761 | } |
@@ -769,35 +769,35 @@ discard block |
||
769 | 769 | |
770 | 770 | // Fetch all invoices that have discount codes. |
771 | 771 | $table = $wpdb->prefix . 'getpaid_invoices'; |
772 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
772 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
773 | 773 | |
774 | - foreach ( $invoices as $invoice ) { |
|
774 | + foreach ($invoices as $invoice) { |
|
775 | 775 | |
776 | - $invoice = new WPInv_Invoice( $invoice ); |
|
776 | + $invoice = new WPInv_Invoice($invoice); |
|
777 | 777 | |
778 | - if ( ! $invoice->exists() ) { |
|
778 | + if (!$invoice->exists()) { |
|
779 | 779 | continue; |
780 | 780 | } |
781 | 781 | |
782 | 782 | // Abort if the discount does not exist or does not apply here. |
783 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
784 | - if ( ! $discount->exists() ) { |
|
783 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
784 | + if (!$discount->exists()) { |
|
785 | 785 | continue; |
786 | 786 | } |
787 | 787 | |
788 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
788 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
789 | 789 | $invoice->recalculate_total(); |
790 | 790 | |
791 | - if ( $invoice->get_total_discount() > 0 ) { |
|
791 | + if ($invoice->get_total_discount() > 0) { |
|
792 | 792 | $invoice->save(); |
793 | 793 | } |
794 | 794 | } |
795 | 795 | |
796 | 796 | // Show an admin message. |
797 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
797 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
798 | 798 | |
799 | 799 | // Redirect the admin. |
800 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
800 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
801 | 801 | exit; |
802 | 802 | |
803 | 803 | } |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | * @return array |
810 | 810 | */ |
811 | 811 | public function get_notices() { |
812 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
813 | - return is_array( $notices ) ? $notices : array(); |
|
812 | + $notices = get_option('wpinv_admin_notices'); |
|
813 | + return is_array($notices) ? $notices : array(); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | * @return array |
821 | 821 | */ |
822 | 822 | public function has_notices() { |
823 | - return count( $this->get_notices() ) > 0; |
|
823 | + return count($this->get_notices()) > 0; |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | * @since 1.0.19 |
831 | 831 | */ |
832 | 832 | public function clear_notices() { |
833 | - delete_option( 'wpinv_admin_notices' ); |
|
833 | + delete_option('wpinv_admin_notices'); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -839,16 +839,16 @@ discard block |
||
839 | 839 | * @access public |
840 | 840 | * @since 1.0.19 |
841 | 841 | */ |
842 | - public function save_notice( $type, $message ) { |
|
842 | + public function save_notice($type, $message) { |
|
843 | 843 | $notices = $this->get_notices(); |
844 | 844 | |
845 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
846 | - $notices[ $type ] = array(); |
|
845 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
846 | + $notices[$type] = array(); |
|
847 | 847 | } |
848 | 848 | |
849 | - $notices[ $type ][] = $message; |
|
849 | + $notices[$type][] = $message; |
|
850 | 850 | |
851 | - update_option( 'wpinv_admin_notices', $notices ); |
|
851 | + update_option('wpinv_admin_notices', $notices); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | * @access public |
859 | 859 | * @since 1.0.19 |
860 | 860 | */ |
861 | - public function show_success( $msg ) { |
|
862 | - $this->save_notice( 'success', $msg ); |
|
861 | + public function show_success($msg) { |
|
862 | + $this->save_notice('success', $msg); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | * @param string $msg The message to qeue. |
870 | 870 | * @since 1.0.19 |
871 | 871 | */ |
872 | - public function show_error( $msg ) { |
|
873 | - $this->save_notice( 'error', $msg ); |
|
872 | + public function show_error($msg) { |
|
873 | + $this->save_notice('error', $msg); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @param string $msg The message to qeue. |
881 | 881 | * @since 1.0.19 |
882 | 882 | */ |
883 | - public function show_warning( $msg ) { |
|
884 | - $this->save_notice( 'warning', $msg ); |
|
883 | + public function show_warning($msg) { |
|
884 | + $this->save_notice('warning', $msg); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | /** |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * @param string $msg The message to qeue. |
892 | 892 | * @since 1.0.19 |
893 | 893 | */ |
894 | - public function show_info( $msg ) { |
|
895 | - $this->save_notice( 'info', $msg ); |
|
894 | + public function show_info($msg) { |
|
895 | + $this->save_notice('info', $msg); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -906,29 +906,29 @@ discard block |
||
906 | 906 | $notices = $this->get_notices(); |
907 | 907 | $this->clear_notices(); |
908 | 908 | |
909 | - foreach ( $notices as $type => $messages ) { |
|
909 | + foreach ($notices as $type => $messages) { |
|
910 | 910 | |
911 | - if ( ! is_array( $messages ) ) { |
|
911 | + if (!is_array($messages)) { |
|
912 | 912 | continue; |
913 | 913 | } |
914 | 914 | |
915 | - $type = esc_attr( $type ); |
|
916 | - foreach ( $messages as $message ) { |
|
917 | - echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
915 | + $type = esc_attr($type); |
|
916 | + foreach ($messages as $message) { |
|
917 | + echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>"); |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | |
921 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
921 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
922 | 922 | |
923 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
924 | - $url = wp_nonce_url( |
|
925 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
923 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
924 | + $url = wp_nonce_url( |
|
925 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
926 | 926 | 'getpaid-nonce', |
927 | 927 | 'getpaid-nonce' |
928 | 928 | ); |
929 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
930 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
931 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
929 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
930 | + $message2 = __('Generate Pages', 'invoicing'); |
|
931 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
932 | 932 | break; |
933 | 933 | } |
934 | 934 | } |
@@ -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 | * This class handles invoice notificaiton emails. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->invoice_actions = apply_filters( |
29 | 29 | 'getpaid_notification_email_invoice_triggers', |
30 | 30 | array( |
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
31 | + 'getpaid_new_invoice' => array('new_invoice', 'user_invoice'), |
|
32 | 32 | 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
33 | 33 | 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
34 | 34 | 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init_hooks() { |
52 | 52 | |
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
53 | + add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2); |
|
54 | + add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2); |
|
55 | 55 | |
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
56 | + foreach ($this->invoice_actions as $hook => $email_type) { |
|
57 | + $this->init_email_type_hook($hook, $email_type); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param string $hook |
65 | 65 | * @param string|array $email_type |
66 | 66 | */ |
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
67 | + public function init_email_type_hook($hook, $email_type) { |
|
68 | 68 | |
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
69 | + $email_type = wpinv_parse_list($email_type); |
|
70 | 70 | |
71 | - foreach ( $email_type as $type ) { |
|
71 | + foreach ($email_type as $type) { |
|
72 | 72 | |
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
73 | + $email = new GetPaid_Notification_Email($type); |
|
74 | 74 | |
75 | 75 | // Abort if it is not active. |
76 | - if ( ! $email->is_active() ) { |
|
76 | + if (!$email->is_active()) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
80 | + if (method_exists($this, $type)) { |
|
81 | + add_action($hook, array($this, $type), 100, 2); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type, $hook); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param array $merge_tags |
94 | 94 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
95 | 95 | */ |
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
96 | + public function invoice_merge_tags($merge_tags, $object) { |
|
97 | 97 | |
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
98 | + if (is_a($object, 'WPInv_Invoice')) { |
|
99 | 99 | return array_merge( |
100 | 100 | $merge_tags, |
101 | - $this->get_invoice_merge_tags( $object ) |
|
101 | + $this->get_invoice_merge_tags($object) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
105 | + if (is_a($object, 'WPInv_Subscription')) { |
|
106 | 106 | return array_merge( |
107 | 107 | $merge_tags, |
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
108 | + $this->get_invoice_merge_tags($object->get_parent_payment()) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -119,50 +119,50 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
122 | + public function get_invoice_merge_tags($invoice) { |
|
123 | 123 | |
124 | 124 | // Abort if it does not exist. |
125 | - if ( ! $invoice->get_id() ) { |
|
125 | + if (!$invoice->get_id()) { |
|
126 | 126 | return array(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $merge_tags = array( |
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}' => esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
130 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
131 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
132 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
133 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
134 | + '{email}' => sanitize_email($invoice->get_email()), |
|
135 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
136 | + '{invoice_currency}' => sanitize_text_field($invoice->get_currency()), |
|
137 | + '{invoice_total}' => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())), |
|
138 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
139 | + '{invoice_pay_link}' => esc_url($invoice->get_checkout_payment_url()), |
|
140 | + '{invoice_receipt_link}' => esc_url($invoice->get_receipt_url()), |
|
141 | + '{invoice_date}' => getpaid_format_date_value($invoice->get_date_created()), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')), |
|
143 | + '{invoice_quote}' => sanitize_text_field(strtolower($invoice->get_label())), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_label())), |
|
145 | + '{invoice_description}' => wp_kses_post($invoice->get_description()), |
|
146 | + '{subscription_name}' => wp_kses_post($invoice->get_subscription_name()), |
|
147 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
150 | + $payment_form_data = $invoice->get_meta('payment_form_data', true); |
|
151 | 151 | |
152 | - if ( is_array( $payment_form_data ) ) { |
|
152 | + if (is_array($payment_form_data)) { |
|
153 | 153 | |
154 | - foreach ( $payment_form_data as $label => $value ) { |
|
154 | + foreach ($payment_form_data as $label => $value) { |
|
155 | 155 | |
156 | - $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | - $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
156 | + $label = preg_replace('/[^a-z0-9]+/', '_', strtolower($label)); |
|
157 | + $value = is_array($value) ? implode(', ', $value) : $value; |
|
158 | 158 | |
159 | - if ( is_scalar( $value ) ) { |
|
160 | - $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
159 | + if (is_scalar($value)) { |
|
160 | + $merge_tags["{{$label}}"] = wp_kses_post($value); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
165 | + return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * @param string|array $recipients |
175 | 175 | * @param array $extra_args Extra template args. |
176 | 176 | */ |
177 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
177 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
178 | 178 | |
179 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
179 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
180 | 180 | |
181 | - $skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' ); |
|
182 | - if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) { |
|
181 | + $skip = $invoice->is_free() && wpinv_get_option('skip_email_free_invoice'); |
|
182 | + if (apply_filters('getpaid_skip_invoice_email', $skip, $type, $invoice)) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
@@ -187,43 +187,43 @@ discard block |
||
187 | 187 | $merge_tags = $email->get_merge_tags(); |
188 | 188 | |
189 | 189 | $result = $mailer->send( |
190 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
191 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
192 | - $email->get_content( $merge_tags, $extra_args ), |
|
190 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
191 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
192 | + $email->get_content($merge_tags, $extra_args), |
|
193 | 193 | $email->get_attachments() |
194 | 194 | ); |
195 | 195 | |
196 | 196 | // Maybe send a copy to the admin. |
197 | - if ( $email->include_admin_bcc() ) { |
|
197 | + if ($email->include_admin_bcc()) { |
|
198 | 198 | $mailer->send( |
199 | 199 | wpinv_get_admin_email(), |
200 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
201 | - $email->get_content( $merge_tags ), |
|
200 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
201 | + $email->get_content($merge_tags), |
|
202 | 202 | $email->get_attachments() |
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - if ( $result ) { |
|
206 | + if ($result) { |
|
207 | 207 | $invoice->add_system_note( |
208 | 208 | sprintf( |
209 | 209 | // translators: %1 is the email type, %2 is the invoice recipient. |
210 | - __( 'Successfully sent %1$s notification email to %2$s.', 'invoicing' ), |
|
211 | - sanitize_key( $type ), |
|
212 | - $email->is_admin_email() ? __( 'admin', 'invoicing' ) : __( 'the customer', 'invoicing' ) |
|
210 | + __('Successfully sent %1$s notification email to %2$s.', 'invoicing'), |
|
211 | + sanitize_key($type), |
|
212 | + $email->is_admin_email() ? __('admin', 'invoicing') : __('the customer', 'invoicing') |
|
213 | 213 | ) |
214 | 214 | ); |
215 | 215 | } else { |
216 | 216 | $invoice->add_system_note( |
217 | 217 | sprintf( |
218 | 218 | // translators: %1 is the email type, %2 is the invoice recipient. |
219 | - __( 'Failed sending %1$s notification email to %2$s.', 'invoicing' ), |
|
220 | - sanitize_key( $type ), |
|
221 | - $email->is_admin_email() ? __( 'admin', 'invoicing' ) : __( 'the customer', 'invoicing' ) |
|
219 | + __('Failed sending %1$s notification email to %2$s.', 'invoicing'), |
|
220 | + sanitize_key($type), |
|
221 | + $email->is_admin_email() ? __('admin', 'invoicing') : __('the customer', 'invoicing') |
|
222 | 222 | ) |
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
226 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
227 | 227 | |
228 | 228 | return $result; |
229 | 229 | } |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | * @param array $recipients |
235 | 235 | * @param GetPaid_Notification_Email $email |
236 | 236 | */ |
237 | - public function filter_email_recipients( $recipients, $email ) { |
|
237 | + public function filter_email_recipients($recipients, $email) { |
|
238 | 238 | |
239 | - if ( ! $email->is_admin_email() ) { |
|
239 | + if (!$email->is_admin_email()) { |
|
240 | 240 | $cc = $email->object->get_email_cc(); |
241 | - $cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true ); |
|
241 | + $cc_2 = get_user_meta($email->object->get_user_id(), '_wpinv_email_cc', true); |
|
242 | 242 | |
243 | - if ( ! empty( $cc ) ) { |
|
244 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
245 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
243 | + if (!empty($cc)) { |
|
244 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
245 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( ! empty( $cc_2 ) ) { |
|
249 | - $cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) ); |
|
250 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) ); |
|
248 | + if (!empty($cc_2)) { |
|
249 | + $cc_2 = array_map('sanitize_email', wpinv_parse_list($cc_2)); |
|
250 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc_2))); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -260,17 +260,17 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @param WPInv_Invoice $invoice |
262 | 262 | */ |
263 | - public function new_invoice( $invoice ) { |
|
263 | + public function new_invoice($invoice) { |
|
264 | 264 | |
265 | 265 | // Only send this email for invoices created via the admin page. |
266 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
266 | + if (!$invoice->is_type('invoice') || $invoice->is_paid() || $this->is_payment_form_invoice($invoice->get_id())) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
270 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
271 | 271 | $recipient = wpinv_get_admin_email(); |
272 | 272 | |
273 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
273 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
274 | 274 | |
275 | 275 | } |
276 | 276 | |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @param WPInv_Invoice $invoice |
281 | 281 | */ |
282 | - public function cancelled_invoice( $invoice ) { |
|
282 | + public function cancelled_invoice($invoice) { |
|
283 | 283 | |
284 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
284 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
285 | 285 | $recipient = $invoice->get_email(); |
286 | 286 | |
287 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
287 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @param WPInv_Invoice $invoice |
294 | 294 | */ |
295 | - public function failed_invoice( $invoice ) { |
|
295 | + public function failed_invoice($invoice) { |
|
296 | 296 | |
297 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
297 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
298 | 298 | $recipient = wpinv_get_admin_email(); |
299 | 299 | |
300 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
300 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
301 | 301 | |
302 | 302 | } |
303 | 303 | |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @param WPInv_Invoice $invoice |
308 | 308 | */ |
309 | - public function onhold_invoice( $invoice ) { |
|
309 | + public function onhold_invoice($invoice) { |
|
310 | 310 | |
311 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
311 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
312 | 312 | $recipient = $invoice->get_email(); |
313 | 313 | |
314 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
314 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
315 | 315 | |
316 | 316 | } |
317 | 317 | |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param WPInv_Invoice $invoice |
322 | 322 | */ |
323 | - public function processing_invoice( $invoice ) { |
|
323 | + public function processing_invoice($invoice) { |
|
324 | 324 | |
325 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
325 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
326 | 326 | $recipient = $invoice->get_email(); |
327 | 327 | |
328 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
328 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
329 | 329 | |
330 | 330 | } |
331 | 331 | |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @param WPInv_Invoice $invoice |
336 | 336 | */ |
337 | - public function completed_invoice( $invoice ) { |
|
337 | + public function completed_invoice($invoice) { |
|
338 | 338 | |
339 | 339 | // (Maybe) abort if it is a renewal invoice. |
340 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
340 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
344 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
345 | 345 | $recipient = $invoice->get_email(); |
346 | 346 | |
347 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
347 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
348 | 348 | |
349 | 349 | } |
350 | 350 | |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @param WPInv_Invoice $invoice |
355 | 355 | */ |
356 | - public function refunded_invoice( $invoice ) { |
|
356 | + public function refunded_invoice($invoice) { |
|
357 | 357 | |
358 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
358 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
359 | 359 | $recipient = $invoice->get_email(); |
360 | 360 | |
361 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
361 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
@@ -368,21 +368,21 @@ discard block |
||
368 | 368 | * @param WPInv_Invoice $invoice |
369 | 369 | * @param bool $force |
370 | 370 | */ |
371 | - public function user_invoice( $invoice, $force = false ) { |
|
371 | + public function user_invoice($invoice, $force = false) { |
|
372 | 372 | |
373 | - if ( ! $force && ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
373 | + if (!$force && !empty($GLOBALS['wpinv_skip_invoice_notification'])) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Only send this email for invoices created via the admin page. |
378 | - if ( ! $invoice->is_type( 'invoice' ) || ( empty( $force ) && $invoice->is_paid() ) || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) { |
|
378 | + if (!$invoice->is_type('invoice') || (empty($force) && $invoice->is_paid()) || (empty($force) && $this->is_payment_form_invoice($invoice->get_id()))) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
382 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
383 | 383 | $recipient = $invoice->get_email(); |
384 | 384 | |
385 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
385 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
386 | 386 | |
387 | 387 | } |
388 | 388 | |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | * @param int $invoice |
393 | 393 | * @return bool |
394 | 394 | */ |
395 | - public function is_payment_form_invoice( $invoice ) { |
|
396 | - $created_via = get_post_meta( $invoice, 'wpinv_created_via', true ); |
|
395 | + public function is_payment_form_invoice($invoice) { |
|
396 | + $created_via = get_post_meta($invoice, 'wpinv_created_via', true); |
|
397 | 397 | $is_payment_form_invoice = 'payment_form' === $created_via || 'geodirectory' === $created_via; |
398 | - $is_payment_form_invoice = apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice ); |
|
399 | - return empty( $_GET['getpaid-admin-action'] ) && $is_payment_form_invoice; |
|
398 | + $is_payment_form_invoice = apply_filters('getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice); |
|
399 | + return empty($_GET['getpaid-admin-action']) && $is_payment_form_invoice; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -405,12 +405,12 @@ discard block |
||
405 | 405 | * @param WPInv_Invoice $invoice |
406 | 406 | * @param string $note |
407 | 407 | */ |
408 | - public function user_note( $invoice, $note ) { |
|
408 | + public function user_note($invoice, $note) { |
|
409 | 409 | |
410 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
410 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
411 | 411 | $recipient = $invoice->get_email(); |
412 | 412 | |
413 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
413 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @param WPInv_Invoice $invoice |
421 | 421 | */ |
422 | - public function force_send_overdue_notice( $invoice ) { |
|
423 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
424 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
422 | + public function force_send_overdue_notice($invoice) { |
|
423 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
424 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -432,38 +432,38 @@ discard block |
||
432 | 432 | public function overdue() { |
433 | 433 | global $wpdb; |
434 | 434 | |
435 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
435 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
436 | 436 | |
437 | 437 | // Fetch reminder days. |
438 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
438 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
439 | 439 | |
440 | 440 | // Abort if non is set. |
441 | - if ( empty( $reminder_days ) ) { |
|
441 | + if (empty($reminder_days)) { |
|
442 | 442 | return; |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Retrieve date query. |
446 | - $date_query = $this->get_date_query( $reminder_days ); |
|
446 | + $date_query = $this->get_date_query($reminder_days); |
|
447 | 447 | |
448 | 448 | // Invoices table. |
449 | 449 | $table = $wpdb->prefix . 'getpaid_invoices'; |
450 | 450 | |
451 | 451 | // Fetch invoices. |
452 | - $invoices = $wpdb->get_col( |
|
452 | + $invoices = $wpdb->get_col( |
|
453 | 453 | "SELECT posts.ID FROM $wpdb->posts as posts |
454 | 454 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
455 | 455 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query" |
456 | 456 | ); |
457 | 457 | |
458 | - foreach ( $invoices as $invoice ) { |
|
458 | + foreach ($invoices as $invoice) { |
|
459 | 459 | |
460 | 460 | // Only send this email for invoices created via the admin page. |
461 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
462 | - $invoice = new WPInv_Invoice( $invoice ); |
|
461 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
462 | + $invoice = new WPInv_Invoice($invoice); |
|
463 | 463 | $email->object = $invoice; |
464 | 464 | |
465 | - if ( $invoice->needs_payment() ) { |
|
466 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
465 | + if ($invoice->needs_payment()) { |
|
466 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | } |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | * @param array $reminder_days |
477 | 477 | * @return string |
478 | 478 | */ |
479 | - public function get_date_query( $reminder_days ) { |
|
479 | + public function get_date_query($reminder_days) { |
|
480 | 480 | |
481 | 481 | $date_query = array( |
482 | 482 | 'relation' => 'OR', |
483 | 483 | ); |
484 | 484 | |
485 | - foreach ( $reminder_days as $days ) { |
|
486 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
485 | + foreach ($reminder_days as $days) { |
|
486 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
487 | 487 | |
488 | 488 | $date_query[] = array( |
489 | 489 | 'year' => $date['year'], |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
496 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
497 | 497 | |
498 | 498 | return $date_query->get_sql(); |
499 | 499 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param int the item ID to retrieve. |
15 | 15 | * @return WPInv_Item|false |
16 | 16 | */ |
17 | -function wpinv_get_item_by_id( $id ) { |
|
18 | - $item = wpinv_get_item( $id ); |
|
19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
17 | +function wpinv_get_item_by_id($id) { |
|
18 | + $item = wpinv_get_item($id); |
|
19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return WPInv_Item|false |
26 | 26 | */ |
27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
28 | 28 | |
29 | - if ( 'id' == strtolower( $field ) ) { |
|
30 | - return wpinv_get_item_by_id( $field ); |
|
29 | + if ('id' == strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($field); |
|
31 | 31 | } |
32 | 32 | |
33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
34 | + return empty($id) ? false : wpinv_get_item($id); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | * @param int|WPInv_Item the item to retrieve. |
42 | 42 | * @return WPInv_Item|false |
43 | 43 | */ |
44 | -function wpinv_get_item( $item = 0 ) { |
|
44 | +function wpinv_get_item($item = 0) { |
|
45 | 45 | |
46 | - if ( empty( $item ) ) { |
|
46 | + if (empty($item)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | - $item = new WPInv_Item( $item ); |
|
50 | + $item = new WPInv_Item($item); |
|
51 | 51 | return $item->exists() ? $item : false; |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | -function wpinv_get_all_items( $args = array() ) { |
|
55 | +function wpinv_get_all_items($args = array()) { |
|
56 | 56 | |
57 | 57 | $args = wp_parse_args( |
58 | 58 | $args, |
59 | 59 | array( |
60 | - 'status' => array( 'publish' ), |
|
61 | - 'limit' => get_option( 'posts_per_page' ), |
|
60 | + 'status' => array('publish'), |
|
61 | + 'limit' => get_option('posts_per_page'), |
|
62 | 62 | 'page' => 1, |
63 | 63 | 'exclude' => array(), |
64 | 64 | 'orderby' => 'date', |
@@ -78,44 +78,44 @@ discard block |
||
78 | 78 | 'fields' => 'ids', |
79 | 79 | 'orderby' => $args['orderby'], |
80 | 80 | 'order' => $args['order'], |
81 | - 'paged' => absint( $args['page'] ), |
|
81 | + 'paged' => absint($args['page']), |
|
82 | 82 | ); |
83 | 83 | |
84 | - if ( ! empty( $args['exclude'] ) ) { |
|
85 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
84 | + if (!empty($args['exclude'])) { |
|
85 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
86 | 86 | } |
87 | 87 | |
88 | - if ( ! $args['paginate'] ) { |
|
88 | + if (!$args['paginate']) { |
|
89 | 89 | $wp_query_args['no_found_rows'] = true; |
90 | 90 | } |
91 | 91 | |
92 | - if ( ! empty( $args['search'] ) ) { |
|
92 | + if (!empty($args['search'])) { |
|
93 | 93 | $wp_query_args['s'] = $args['search']; |
94 | 94 | } |
95 | 95 | |
96 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
97 | - $types = wpinv_parse_list( $args['type'] ); |
|
96 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
97 | + $types = wpinv_parse_list($args['type']); |
|
98 | 98 | $wp_query_args['meta_query'][] = array( |
99 | 99 | 'key' => '_wpinv_type', |
100 | - 'value' => implode( ',', $types ), |
|
100 | + 'value' => implode(',', $types), |
|
101 | 101 | 'compare' => 'IN', |
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args ); |
|
105 | + $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
|
106 | 106 | |
107 | 107 | // Get results. |
108 | - $items = new WP_Query( $wp_query_args ); |
|
108 | + $items = new WP_Query($wp_query_args); |
|
109 | 109 | |
110 | - if ( 'objects' === $args['return'] ) { |
|
111 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
112 | - } elseif ( 'self' === $args['return'] ) { |
|
110 | + if ('objects' === $args['return']) { |
|
111 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
112 | + } elseif ('self' === $args['return']) { |
|
113 | 113 | return $items; |
114 | 114 | } else { |
115 | 115 | $return = $items->posts; |
116 | 116 | } |
117 | 117 | |
118 | - if ( $args['paginate'] ) { |
|
118 | + if ($args['paginate']) { |
|
119 | 119 | return (object) array( |
120 | 120 | 'items' => $return, |
121 | 121 | 'total' => $items->found_posts, |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
131 | - if ( empty( $item_id ) ) { |
|
130 | +function wpinv_is_free_item($item_id = 0) { |
|
131 | + if (empty($item_id)) { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
135 | - $item = new WPInv_Item( $item_id ); |
|
135 | + $item = new WPInv_Item($item_id); |
|
136 | 136 | |
137 | 137 | return $item->is_free(); |
138 | 138 | } |
@@ -142,21 +142,21 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
144 | 144 | */ |
145 | -function wpinv_item_is_editable( $item = 0 ) { |
|
145 | +function wpinv_item_is_editable($item = 0) { |
|
146 | 146 | |
147 | 147 | // Fetch the item. |
148 | - $item = new WPInv_Item( $item ); |
|
148 | + $item = new WPInv_Item($item); |
|
149 | 149 | |
150 | 150 | // Check if it is editable. |
151 | 151 | return $item->is_editable(); |
152 | 152 | } |
153 | 153 | |
154 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
155 | - if ( empty( $item_id ) ) { |
|
154 | +function wpinv_get_item_price($item_id = 0) { |
|
155 | + if (empty($item_id)) { |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
159 | - $item = new WPInv_Item( $item_id ); |
|
159 | + $item = new WPInv_Item($item_id); |
|
160 | 160 | |
161 | 161 | return $item->get_price(); |
162 | 162 | } |
@@ -166,88 +166,88 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param WPInv_Item|int $item |
168 | 168 | */ |
169 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
170 | - $item = new WPInv_Item( $item ); |
|
169 | +function wpinv_is_recurring_item($item = 0) { |
|
170 | + $item = new WPInv_Item($item); |
|
171 | 171 | return $item->is_recurring(); |
172 | 172 | } |
173 | 173 | |
174 | -function wpinv_item_price( $item_id = 0 ) { |
|
175 | - if ( empty( $item_id ) ) { |
|
174 | +function wpinv_item_price($item_id = 0) { |
|
175 | + if (empty($item_id)) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - $price = wpinv_get_item_price( $item_id ); |
|
180 | - $price = wpinv_price( $price ); |
|
179 | + $price = wpinv_get_item_price($item_id); |
|
180 | + $price = wpinv_price($price); |
|
181 | 181 | |
182 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
182 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
183 | 183 | } |
184 | 184 | |
185 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
186 | - if ( is_null( $amount_override ) ) { |
|
187 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
185 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
186 | + if (is_null($amount_override)) { |
|
187 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
188 | 188 | } else { |
189 | 189 | $original_price = $amount_override; |
190 | 190 | } |
191 | 191 | |
192 | 192 | $price = $original_price; |
193 | 193 | |
194 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
194 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
195 | 195 | } |
196 | 196 | |
197 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
198 | - if ( empty( $item_id ) ) { |
|
197 | +function wpinv_item_custom_singular_name($item_id) { |
|
198 | + if (empty($item_id)) { |
|
199 | 199 | return false; |
200 | 200 | } |
201 | 201 | |
202 | - $item = new WPInv_Item( $item_id ); |
|
202 | + $item = new WPInv_Item($item_id); |
|
203 | 203 | |
204 | 204 | return $item->get_custom_singular_name(); |
205 | 205 | } |
206 | 206 | |
207 | 207 | function wpinv_get_item_types() { |
208 | 208 | $item_types = array( |
209 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
210 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
209 | + 'custom' => __('Standard', 'invoicing'), |
|
210 | + 'fee' => __('Fee', 'invoicing'), |
|
211 | 211 | ); |
212 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
212 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | function wpinv_item_types() { |
216 | 216 | $item_types = wpinv_get_item_types(); |
217 | 217 | |
218 | - return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
218 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
219 | 219 | } |
220 | 220 | |
221 | -function wpinv_get_item_type( $item_id ) { |
|
222 | - if ( empty( $item_id ) ) { |
|
221 | +function wpinv_get_item_type($item_id) { |
|
222 | + if (empty($item_id)) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | - $item = new WPInv_Item( $item_id ); |
|
226 | + $item = new WPInv_Item($item_id); |
|
227 | 227 | |
228 | 228 | return $item->get_type(); |
229 | 229 | } |
230 | 230 | |
231 | -function wpinv_item_type( $item_id ) { |
|
231 | +function wpinv_item_type($item_id) { |
|
232 | 232 | $item_types = wpinv_get_item_types(); |
233 | 233 | |
234 | - $item_type = wpinv_get_item_type( $item_id ); |
|
234 | + $item_type = wpinv_get_item_type($item_id); |
|
235 | 235 | |
236 | - if ( empty( $item_type ) ) { |
|
236 | + if (empty($item_type)) { |
|
237 | 237 | $item_type = '-'; |
238 | 238 | } |
239 | 239 | |
240 | - $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' ); |
|
240 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
241 | 241 | |
242 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
242 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
243 | 243 | } |
244 | 244 | |
245 | -function wpinv_get_random_item( $post_ids = true ) { |
|
246 | - wpinv_get_random_items( 1, $post_ids ); |
|
245 | +function wpinv_get_random_item($post_ids = true) { |
|
246 | + wpinv_get_random_items(1, $post_ids); |
|
247 | 247 | } |
248 | 248 | |
249 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
250 | - if ( $post_ids ) { |
|
249 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
250 | + if ($post_ids) { |
|
251 | 251 | $args = array( |
252 | 252 | 'post_type' => 'wpi_item', |
253 | 253 | 'orderby' => 'rand', |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | ); |
263 | 263 | } |
264 | 264 | |
265 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
265 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
266 | 266 | |
267 | - return get_posts( $args ); |
|
267 | + return get_posts($args); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | * @param WPInv_Item|int $item |
274 | 274 | * @param bool $html |
275 | 275 | */ |
276 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
276 | +function wpinv_get_item_suffix($item, $html = true) { |
|
277 | 277 | |
278 | - $item = new WPInv_Item( $item ); |
|
279 | - $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : ''; |
|
280 | - $suffix = $html ? $suffix : wp_strip_all_tags( $suffix ); |
|
278 | + $item = new WPInv_Item($item); |
|
279 | + $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : ''; |
|
280 | + $suffix = $html ? $suffix : wp_strip_all_tags($suffix); |
|
281 | 281 | |
282 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
282 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | * @param WPInv_Item|int $item |
289 | 289 | * @param bool $force_delete |
290 | 290 | */ |
291 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
292 | - $item = new WPInv_Item( $item ); |
|
293 | - $item->delete( $force_delete ); |
|
291 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
292 | + $item = new WPInv_Item($item); |
|
293 | + $item->delete($force_delete); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -329,44 +329,44 @@ discard block |
||
329 | 329 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
330 | 330 | * @return bool|WP_Error|WPInv_Item |
331 | 331 | */ |
332 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
332 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
333 | 333 | |
334 | 334 | // Prepare the item. |
335 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
336 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
337 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
335 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
336 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
337 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
338 | 338 | |
339 | - if ( ! empty( $item ) ) { |
|
339 | + if (!empty($item)) { |
|
340 | 340 | $args['ID'] = $item->get_id(); |
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Do we have an item? |
345 | - if ( ! empty( $args['ID'] ) ) { |
|
346 | - $item = new WPInv_Item( $args['ID'] ); |
|
345 | + if (!empty($args['ID'])) { |
|
346 | + $item = new WPInv_Item($args['ID']); |
|
347 | 347 | } else { |
348 | 348 | $item = new WPInv_Item(); |
349 | 349 | } |
350 | 350 | |
351 | 351 | // Do we have an error? |
352 | - if ( ! empty( $item->last_error ) ) { |
|
353 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
352 | + if (!empty($item->last_error)) { |
|
353 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Update item props. |
357 | - $item->set_props( $args ); |
|
357 | + $item->set_props($args); |
|
358 | 358 | |
359 | 359 | // Save the item. |
360 | 360 | $item->save(); |
361 | 361 | |
362 | 362 | // Do we have an error? |
363 | - if ( ! empty( $item->last_error ) ) { |
|
364 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
363 | + if (!empty($item->last_error)) { |
|
364 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | // Was the item saved? |
368 | - if ( ! $item->get_id() ) { |
|
369 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
368 | + if (!$item->get_id()) { |
|
369 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | return $item; |
@@ -378,14 +378,14 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @see wpinv_create_item() |
380 | 380 | */ |
381 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
382 | - return wpinv_create_item( $args, $wp_error ); |
|
381 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
382 | + return wpinv_create_item($args, $wp_error); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
386 | 386 | * Sanitizes a recurring period |
387 | 387 | */ |
388 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
388 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
389 | 389 | |
390 | 390 | $periods = array( |
391 | 391 | 'D' => 'day', |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | 'Y' => 'year', |
395 | 395 | ); |
396 | 396 | |
397 | - if ( ! isset( $periods[ $period ] ) ) { |
|
397 | + if (!isset($periods[$period])) { |
|
398 | 398 | $period = 'D'; |
399 | 399 | } |
400 | 400 | |
401 | - return $full ? $periods[ $period ] : $period; |
|
401 | + return $full ? $periods[$period] : $period; |
|
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | -function wpinv_item_max_buyable_quantity( $item_id ) { |
|
406 | - return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id ); |
|
405 | +function wpinv_item_max_buyable_quantity($item_id) { |
|
406 | + return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -411,47 +411,47 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @param WPInv_Item|GetPaid_Form_Item $item |
413 | 413 | */ |
414 | -function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) { |
|
414 | +function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) { |
|
415 | 415 | |
416 | 416 | // Abort if it is not recurring. |
417 | - if ( ! $item->is_recurring() ) { |
|
417 | + if (!$item->is_recurring()) { |
|
418 | 418 | return ''; |
419 | 419 | } |
420 | 420 | |
421 | - $initial_price = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price; |
|
422 | - $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price; |
|
423 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
421 | + $initial_price = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price; |
|
422 | + $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price; |
|
423 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
424 | 424 | $initial_class = 'getpaid-item-initial-price'; |
425 | 425 | $recurring_class = 'getpaid-item-recurring-price'; |
426 | 426 | $bill_times = $item->get_recurring_limit(); |
427 | 427 | $bill_times_less = $bill_times - 1; |
428 | 428 | |
429 | - if ( ! empty( $bill_times ) ) { |
|
429 | + if (!empty($bill_times)) { |
|
430 | 430 | $bill_times = $item->get_recurring_interval() * $bill_times; |
431 | - $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
|
432 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
431 | + $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval()); |
|
432 | + $bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times); |
|
433 | 433 | } |
434 | 434 | |
435 | - if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
|
436 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
437 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
435 | + if ($item instanceof GetPaid_Form_Item && false === $_initial_price) { |
|
436 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
437 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
438 | 438 | } |
439 | 439 | |
440 | - if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) { |
|
441 | - return __( 'Free forever', 'invoicing' ); |
|
440 | + if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) { |
|
441 | + return __('Free forever', 'invoicing'); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | // For free trial items. |
445 | - if ( $item->has_free_trial() ) { |
|
446 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
445 | + if ($item->has_free_trial()) { |
|
446 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
447 | 447 | |
448 | - if ( wpinv_price( 0, $currency ) == $initial_price ) { |
|
448 | + if (wpinv_price(0, $currency) == $initial_price) { |
|
449 | 449 | |
450 | - if ( empty( $bill_times ) ) { |
|
450 | + if (empty($bill_times)) { |
|
451 | 451 | |
452 | 452 | return sprintf( |
453 | 453 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
454 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
454 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
455 | 455 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
456 | 456 | "<span class='$recurring_class'>$recurring_price</span>", |
457 | 457 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | return sprintf( |
463 | 463 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times |
464 | - _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
464 | + _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
465 | 465 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
466 | 466 | "<span class='$recurring_class'>$recurring_price</span>", |
467 | 467 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -470,11 +470,11 @@ discard block |
||
470 | 470 | |
471 | 471 | } |
472 | 472 | |
473 | - if ( empty( $bill_times ) ) { |
|
473 | + if (empty($bill_times)) { |
|
474 | 474 | |
475 | 475 | return sprintf( |
476 | 476 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
477 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
477 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
478 | 478 | "<span class='$initial_class'>$initial_price</span>", |
479 | 479 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
480 | 480 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | |
486 | 486 | return sprintf( |
487 | 487 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times |
488 | - _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ), |
|
488 | + _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'), |
|
489 | 489 | "<span class='$initial_class'>$initial_price</span>", |
490 | 490 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
491 | 491 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | |
496 | 496 | } |
497 | 497 | |
498 | - if ( $initial_price == $recurring_price ) { |
|
498 | + if ($initial_price == $recurring_price) { |
|
499 | 499 | |
500 | - if ( empty( $bill_times ) ) { |
|
500 | + if (empty($bill_times)) { |
|
501 | 501 | |
502 | 502 | return sprintf( |
503 | 503 | // translators: $1: is the recurring price, $2: is the susbcription period |
504 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
504 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
505 | 505 | "<span class='$recurring_class'>$recurring_price</span>", |
506 | 506 | "<span class='getpaid-item-recurring-period'>$period</span>" |
507 | 507 | ); |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | |
511 | 511 | return sprintf( |
512 | 512 | // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times |
513 | - _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
513 | + _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
514 | 514 | "<span class='$recurring_class'>$recurring_price</span>", |
515 | 515 | "<span class='getpaid-item-recurring-period'>$period</span>", |
516 | 516 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -518,13 +518,13 @@ discard block |
||
518 | 518 | |
519 | 519 | } |
520 | 520 | |
521 | - if ( $initial_price == wpinv_price( 0, $currency ) ) { |
|
521 | + if ($initial_price == wpinv_price(0, $currency)) { |
|
522 | 522 | |
523 | - if ( empty( $bill_times ) ) { |
|
523 | + if (empty($bill_times)) { |
|
524 | 524 | |
525 | 525 | return sprintf( |
526 | 526 | // translators: $1: is the recurring period, $2: is the recurring price |
527 | - _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ), |
|
527 | + _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'), |
|
528 | 528 | "<span class='getpaid-item-recurring-period'>$period</span>", |
529 | 529 | "<span class='$recurring_class'>$recurring_price</span>" |
530 | 530 | ); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | |
534 | 534 | return sprintf( |
535 | 535 | // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times |
536 | - _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ), |
|
536 | + _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'), |
|
537 | 537 | "<span class='getpaid-item-recurring-period'>$period</span>", |
538 | 538 | "<span class='$recurring_class'>$recurring_price</span>", |
539 | 539 | "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>" |
@@ -541,11 +541,11 @@ discard block |
||
541 | 541 | |
542 | 542 | } |
543 | 543 | |
544 | - if ( empty( $bill_times ) ) { |
|
544 | + if (empty($bill_times)) { |
|
545 | 545 | |
546 | 546 | return sprintf( |
547 | 547 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
548 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
548 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
549 | 549 | "<span class='$initial_class'>$initial_price</span>", |
550 | 550 | "<span class='$recurring_class'>$recurring_price</span>", |
551 | 551 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | |
556 | 556 | return sprintf( |
557 | 557 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times |
558 | - _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ), |
|
558 | + _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'), |
|
559 | 559 | "<span class='$initial_class'>$initial_price</span>", |
560 | 560 | "<span class='$recurring_class'>$recurring_price</span>", |
561 | 561 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -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 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | function wpinv_register_settings() { |
147 | 147 | |
148 | 148 | // Loop through all tabs. |
149 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
149 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
150 | 150 | |
151 | 151 | // In each tab, loop through sections. |
152 | - foreach ( $sections as $section => $settings ) { |
|
152 | + foreach ($sections as $section => $settings) { |
|
153 | 153 | |
154 | 154 | // Check for backwards compatibility |
155 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
156 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
155 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
156 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
157 | 157 | $section = 'main'; |
158 | 158 | $settings = $sections; |
159 | 159 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | 'wpinv_settings_' . $tab . '_' . $section |
167 | 167 | ); |
168 | 168 | |
169 | - foreach ( $settings as $option ) { |
|
170 | - if ( ! empty( $option['id'] ) ) { |
|
171 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
169 | + foreach ($settings as $option) { |
|
170 | + if (!empty($option['id'])) { |
|
171 | + wpinv_register_settings_option($tab, $section, $option); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Creates our settings in the options table. |
178 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
178 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
179 | 179 | } |
180 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
180 | +add_action('admin_init', 'wpinv_register_settings'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Register a single settings option. |
@@ -187,49 +187,49 @@ discard block |
||
187 | 187 | * @param string $option |
188 | 188 | * |
189 | 189 | */ |
190 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
190 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
191 | 191 | |
192 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
192 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
193 | 193 | $cb = "wpinv_{$option['type']}_callback"; |
194 | 194 | $section = "wpinv_settings_{$tab}_$section"; |
195 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
195 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
196 | 196 | |
197 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
198 | - $tip = wpinv_clean( $option['desc'] ); |
|
197 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
198 | + $tip = wpinv_clean($option['desc']); |
|
199 | 199 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
200 | - unset( $option['desc'] ); |
|
200 | + unset($option['desc']); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Loop through all tabs. |
204 | 204 | add_settings_field( |
205 | 205 | 'wpinv_settings[' . $option['id'] . ']', |
206 | 206 | $name, |
207 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
207 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
208 | 208 | $section, |
209 | 209 | $section, |
210 | 210 | array( |
211 | 211 | 'section' => $section, |
212 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
213 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
212 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
213 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
214 | 214 | 'name' => $name, |
215 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
216 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
217 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
218 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
219 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
220 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
221 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
222 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
223 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
224 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
225 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
226 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
227 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
228 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
229 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
230 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
215 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
216 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
217 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
218 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
219 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
220 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
221 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
222 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
223 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
224 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
225 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
226 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
227 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
228 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
229 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
230 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
244 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return array |
251 | 251 | */ |
252 | 252 | function getpaid_get_integration_settings() { |
253 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
253 | + return apply_filters('getpaid_integration_settings', array()); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,153 +258,153 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array |
260 | 260 | */ |
261 | -function wpinv_settings_sanitize( $input = array() ) { |
|
261 | +function wpinv_settings_sanitize($input = array()) { |
|
262 | 262 | |
263 | 263 | $wpinv_options = wpinv_get_options(); |
264 | 264 | $raw_referrer = wp_get_raw_referer(); |
265 | 265 | |
266 | - if ( empty( $raw_referrer ) ) { |
|
267 | - return array_merge( $wpinv_options, $input ); |
|
266 | + if (empty($raw_referrer)) { |
|
267 | + return array_merge($wpinv_options, $input); |
|
268 | 268 | } |
269 | 269 | |
270 | - wp_parse_str( $raw_referrer, $referrer ); |
|
270 | + wp_parse_str($raw_referrer, $referrer); |
|
271 | 271 | |
272 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
273 | - return array_merge( $wpinv_options, $input ); |
|
272 | + if (in_array('gp-setup', $referrer)) { |
|
273 | + return array_merge($wpinv_options, $input); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | $settings = wpinv_get_registered_settings(); |
277 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
278 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
277 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
278 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
279 | 279 | |
280 | 280 | $input = $input ? $input : array(); |
281 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
282 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
281 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
282 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
283 | 283 | |
284 | 284 | // Loop through each setting being saved and pass it through a sanitization filter |
285 | - foreach ( $input as $key => $value ) { |
|
285 | + foreach ($input as $key => $value) { |
|
286 | 286 | |
287 | 287 | // Get the setting type (checkbox, select, etc) |
288 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
288 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
289 | 289 | |
290 | - if ( $type ) { |
|
290 | + if ($type) { |
|
291 | 291 | // Field type specific filter |
292 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
292 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // General filter |
296 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
297 | 297 | |
298 | 298 | // Key specific filter. |
299 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
299 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // Loop through the whitelist and unset any that are empty for the tab being saved |
303 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
304 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
303 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
304 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
305 | 305 | |
306 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
306 | + $found_settings = array_merge($main_settings, $section_settings); |
|
307 | 307 | |
308 | - if ( ! empty( $found_settings ) ) { |
|
309 | - foreach ( $found_settings as $key => $value ) { |
|
308 | + if (!empty($found_settings)) { |
|
309 | + foreach ($found_settings as $key => $value) { |
|
310 | 310 | |
311 | 311 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
312 | - if ( is_numeric( $key ) ) { |
|
312 | + if (is_numeric($key)) { |
|
313 | 313 | $key = $value['id']; |
314 | 314 | } |
315 | 315 | |
316 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
317 | - unset( $wpinv_options[ $key ] ); |
|
316 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
317 | + unset($wpinv_options[$key]); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Merge our new settings with the existing |
323 | - $output = array_merge( $wpinv_options, $input ); |
|
323 | + $output = array_merge($wpinv_options, $input); |
|
324 | 324 | |
325 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
325 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
326 | 326 | |
327 | 327 | return $output; |
328 | 328 | } |
329 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
330 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
329 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
330 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
331 | 331 | |
332 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
332 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
334 | 334 | return $input; |
335 | 335 | } |
336 | 336 | |
337 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
337 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
338 | 338 | $tax_rates = array(); |
339 | 339 | |
340 | - foreach ( $new_rates as $rate ) { |
|
340 | + foreach ($new_rates as $rate) { |
|
341 | 341 | |
342 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
343 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
344 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
345 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
346 | - $rate['global'] = empty( $rate['state'] ); |
|
342 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
343 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
344 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
345 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
346 | + $rate['global'] = empty($rate['state']); |
|
347 | 347 | $tax_rates[] = $rate; |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
351 | + update_option('wpinv_tax_rates', $tax_rates); |
|
352 | 352 | |
353 | 353 | return $input; |
354 | 354 | } |
355 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
355 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
356 | 356 | |
357 | -function wpinv_settings_sanitize_tax_rules( $input ) { |
|
358 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
357 | +function wpinv_settings_sanitize_tax_rules($input) { |
|
358 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
359 | 359 | return $input; |
360 | 360 | } |
361 | 361 | |
362 | - if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) { |
|
362 | + if (empty($_POST['wpinv_tax_rules_nonce']) || !wp_verify_nonce($_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules')) { |
|
363 | 363 | return $input; |
364 | 364 | } |
365 | 365 | |
366 | - $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array(); |
|
366 | + $new_rules = !empty($_POST['tax_rules']) ? wp_kses_post_deep(array_values($_POST['tax_rules'])) : array(); |
|
367 | 367 | $tax_rules = array(); |
368 | 368 | |
369 | - foreach ( $new_rules as $rule ) { |
|
369 | + foreach ($new_rules as $rule) { |
|
370 | 370 | |
371 | - $rule['key'] = sanitize_title_with_dashes( $rule['key'] ); |
|
372 | - $rule['label'] = sanitize_text_field( $rule['label'] ); |
|
373 | - $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] ); |
|
371 | + $rule['key'] = sanitize_title_with_dashes($rule['key']); |
|
372 | + $rule['label'] = sanitize_text_field($rule['label']); |
|
373 | + $rule['tax_base'] = sanitize_text_field($rule['tax_base']); |
|
374 | 374 | $tax_rules[] = $rule; |
375 | 375 | |
376 | 376 | } |
377 | 377 | |
378 | - update_option( 'wpinv_tax_rules', $tax_rules ); |
|
378 | + update_option('wpinv_tax_rules', $tax_rules); |
|
379 | 379 | |
380 | 380 | return $input; |
381 | 381 | } |
382 | -add_filter( 'wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules' ); |
|
382 | +add_filter('wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules'); |
|
383 | 383 | |
384 | 384 | function wpinv_get_settings_tabs() { |
385 | 385 | $tabs = array(); |
386 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
387 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
388 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
389 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
386 | + $tabs['general'] = __('General', 'invoicing'); |
|
387 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
388 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
389 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
390 | 390 | |
391 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
392 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
391 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
392 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
393 | 393 | } |
394 | 394 | |
395 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
396 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
397 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
395 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
396 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
397 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
398 | 398 | |
399 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
399 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
400 | 400 | } |
401 | 401 | |
402 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
402 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
403 | 403 | $tabs = false; |
404 | 404 | $sections = wpinv_get_registered_settings_sections(); |
405 | 405 | |
406 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
407 | - $tabs = $sections[ $tab ]; |
|
406 | + if ($tab && !empty($sections[$tab])) { |
|
407 | + $tabs = $sections[$tab]; |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | return $tabs; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | function wpinv_get_registered_settings_sections() { |
414 | 414 | static $sections = false; |
415 | 415 | |
416 | - if ( false !== $sections ) { |
|
416 | + if (false !== $sections) { |
|
417 | 417 | return $sections; |
418 | 418 | } |
419 | 419 | |
@@ -421,231 +421,231 @@ discard block |
||
421 | 421 | 'general' => apply_filters( |
422 | 422 | 'wpinv_settings_sections_general', |
423 | 423 | array( |
424 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
425 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
426 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
427 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
424 | + 'main' => __('General Settings', 'invoicing'), |
|
425 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
426 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
427 | + 'labels' => __('Label Texts', 'invoicing'), |
|
428 | 428 | ) |
429 | 429 | ), |
430 | 430 | 'gateways' => apply_filters( |
431 | 431 | 'wpinv_settings_sections_gateways', |
432 | 432 | array( |
433 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
433 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
434 | 434 | ) |
435 | 435 | ), |
436 | 436 | 'taxes' => apply_filters( |
437 | 437 | 'wpinv_settings_sections_taxes', |
438 | 438 | array( |
439 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
440 | - 'rules' => __( 'Tax Rules', 'invoicing' ), |
|
441 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
442 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
439 | + 'main' => __('Tax Settings', 'invoicing'), |
|
440 | + 'rules' => __('Tax Rules', 'invoicing'), |
|
441 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
442 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
443 | 443 | ) |
444 | 444 | ), |
445 | 445 | 'emails' => apply_filters( |
446 | 446 | 'wpinv_settings_sections_emails', |
447 | 447 | array( |
448 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
448 | + 'main' => __('Email Settings', 'invoicing'), |
|
449 | 449 | ) |
450 | 450 | ), |
451 | 451 | |
452 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
452 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
453 | 453 | |
454 | 454 | 'privacy' => apply_filters( |
455 | 455 | 'wpinv_settings_sections_privacy', |
456 | 456 | array( |
457 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
457 | + 'main' => __('Privacy policy', 'invoicing'), |
|
458 | 458 | ) |
459 | 459 | ), |
460 | 460 | 'misc' => apply_filters( |
461 | 461 | 'wpinv_settings_sections_misc', |
462 | 462 | array( |
463 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
464 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
463 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
464 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
465 | 465 | ) |
466 | 466 | ), |
467 | 467 | 'tools' => apply_filters( |
468 | 468 | 'wpinv_settings_sections_tools', |
469 | 469 | array( |
470 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
470 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
471 | 471 | ) |
472 | 472 | ), |
473 | 473 | ); |
474 | 474 | |
475 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
475 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
476 | 476 | |
477 | 477 | return $sections; |
478 | 478 | } |
479 | 479 | |
480 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
480 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
481 | 481 | $pages_options = array(); |
482 | 482 | |
483 | - if ( $default_label !== null && $default_label !== false ) { |
|
484 | - $pages_options = array( '' => $default_label ); // Blank option |
|
483 | + if ($default_label !== null && $default_label !== false) { |
|
484 | + $pages_options = array('' => $default_label); // Blank option |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | $pages = get_pages(); |
488 | - if ( $pages ) { |
|
489 | - foreach ( $pages as $page ) { |
|
488 | + if ($pages) { |
|
489 | + foreach ($pages as $page) { |
|
490 | 490 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
491 | - $pages_options[ $page->ID ] = $title; |
|
491 | + $pages_options[$page->ID] = $title; |
|
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | 495 | return $pages_options; |
496 | 496 | } |
497 | 497 | |
498 | -function wpinv_header_callback( $args ) { |
|
499 | - if ( ! empty( $args['desc'] ) ) { |
|
500 | - echo wp_kses_post( $args['desc'] ); |
|
498 | +function wpinv_header_callback($args) { |
|
499 | + if (!empty($args['desc'])) { |
|
500 | + echo wp_kses_post($args['desc']); |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
504 | -function wpinv_hidden_callback( $args ) { |
|
504 | +function wpinv_hidden_callback($args) { |
|
505 | 505 | |
506 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
507 | - $value = wpinv_get_option( $args['id'], $std ); |
|
506 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
507 | + $value = wpinv_get_option($args['id'], $std); |
|
508 | 508 | |
509 | - if ( isset( $args['set_value'] ) ) { |
|
509 | + if (isset($args['set_value'])) { |
|
510 | 510 | $value = $args['set_value']; |
511 | 511 | } |
512 | 512 | |
513 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
513 | + if (isset($args['faux']) && true === $args['faux']) { |
|
514 | 514 | $args['readonly'] = true; |
515 | - $name = ''; |
|
515 | + $name = ''; |
|
516 | 516 | } else { |
517 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
517 | + $name = 'wpinv_settings[' . esc_attr($args['id']) . ']'; |
|
518 | 518 | } |
519 | 519 | |
520 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
520 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
521 | 521 | |
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
525 | 525 | * Displays a checkbox settings callback. |
526 | 526 | */ |
527 | -function wpinv_checkbox_callback( $args ) { |
|
527 | +function wpinv_checkbox_callback($args) { |
|
528 | 528 | |
529 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
530 | - $std = wpinv_get_option( $args['id'], $std ); |
|
531 | - $id = esc_attr( $args['id'] ); |
|
529 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
530 | + $std = wpinv_get_option($args['id'], $std); |
|
531 | + $id = esc_attr($args['id']); |
|
532 | 532 | |
533 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
533 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
534 | 534 | ?> |
535 | 535 | <fieldset> |
536 | 536 | <label> |
537 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" /> |
|
538 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
537 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox" /> |
|
538 | + <?php echo wp_kses_post($args['desc']); ?> |
|
539 | 539 | </label> |
540 | 540 | </fieldset> |
541 | 541 | <?php |
542 | 542 | } |
543 | 543 | |
544 | -function wpinv_multicheck_callback( $args ) { |
|
544 | +function wpinv_multicheck_callback($args) { |
|
545 | 545 | |
546 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
547 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
546 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
547 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
548 | 548 | |
549 | - if ( ! empty( $args['options'] ) ) { |
|
549 | + if (!empty($args['options'])) { |
|
550 | 550 | |
551 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
552 | - $value = wpinv_get_option( $args['id'], $std ); |
|
551 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
552 | + $value = wpinv_get_option($args['id'], $std); |
|
553 | 553 | |
554 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
555 | - foreach ( $args['options'] as $key => $option ) : |
|
556 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
557 | - if ( in_array( $sanitize_key, $value ) ) { |
|
554 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">'; |
|
555 | + foreach ($args['options'] as $key => $option) : |
|
556 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
557 | + if (in_array($sanitize_key, $value)) { |
|
558 | 558 | $enabled = $sanitize_key; |
559 | 559 | } else { |
560 | 560 | $enabled = null; |
561 | 561 | } |
562 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
563 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
562 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
563 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>'; |
|
564 | 564 | endforeach; |
565 | 565 | echo '</div>'; |
566 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
566 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
570 | -function wpinv_payment_icons_callback( $args ) { |
|
570 | +function wpinv_payment_icons_callback($args) { |
|
571 | 571 | |
572 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
573 | - $value = wpinv_get_option( $args['id'], false ); |
|
572 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
573 | + $value = wpinv_get_option($args['id'], false); |
|
574 | 574 | |
575 | - if ( ! empty( $args['options'] ) ) { |
|
576 | - foreach ( $args['options'] as $key => $option ) { |
|
577 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
575 | + if (!empty($args['options'])) { |
|
576 | + foreach ($args['options'] as $key => $option) { |
|
577 | + $sanitize_key = wpinv_sanitize_key($key); |
|
578 | 578 | |
579 | - if ( empty( $value ) ) { |
|
579 | + if (empty($value)) { |
|
580 | 580 | $enabled = $option; |
581 | 581 | } else { |
582 | 582 | $enabled = null; |
583 | 583 | } |
584 | 584 | |
585 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
585 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
586 | 586 | |
587 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
587 | + echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
588 | 588 | |
589 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
590 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
589 | + if (wpinv_string_is_image_url($key)) { |
|
590 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
591 | 591 | } else { |
592 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
592 | + $card = strtolower(str_replace(' ', '', $option)); |
|
593 | 593 | |
594 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
595 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
594 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
595 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
596 | 596 | } else { |
597 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
597 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
598 | 598 | $content_dir = WP_CONTENT_DIR; |
599 | 599 | |
600 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
600 | + if (function_exists('wp_normalize_path')) { |
|
601 | 601 | // Replaces backslashes with forward slashes for Windows systems |
602 | - $image = wp_normalize_path( $image ); |
|
603 | - $content_dir = wp_normalize_path( $content_dir ); |
|
602 | + $image = wp_normalize_path($image); |
|
603 | + $content_dir = wp_normalize_path($content_dir); |
|
604 | 604 | } |
605 | 605 | |
606 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
606 | + $image = str_replace($content_dir, content_url(), $image); |
|
607 | 607 | } |
608 | 608 | |
609 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
609 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
610 | 610 | } |
611 | - echo wp_kses_post( $option ) . '</label>'; |
|
611 | + echo wp_kses_post($option) . '</label>'; |
|
612 | 612 | } |
613 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
613 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
618 | 618 | * Displays a radio settings field. |
619 | 619 | */ |
620 | -function wpinv_radio_callback( $args ) { |
|
620 | +function wpinv_radio_callback($args) { |
|
621 | 621 | |
622 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
623 | - $std = wpinv_get_option( $args['id'], $std ); |
|
622 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
623 | + $std = wpinv_get_option($args['id'], $std); |
|
624 | 624 | ?> |
625 | 625 | <fieldset> |
626 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
627 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
626 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
627 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
628 | 628 | <li> |
629 | 629 | <label> |
630 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
631 | - <?php echo wp_kses_post( $option ); ?> |
|
630 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
631 | + <?php echo wp_kses_post($option); ?> |
|
632 | 632 | </label> |
633 | 633 | </li> |
634 | 634 | <?php endforeach; ?> |
635 | 635 | </ul> |
636 | 636 | </fieldset> |
637 | 637 | <?php |
638 | - getpaid_settings_description_callback( $args ); |
|
638 | + getpaid_settings_description_callback($args); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
642 | 642 | * Displays a description if available. |
643 | 643 | */ |
644 | -function getpaid_settings_description_callback( $args ) { |
|
644 | +function getpaid_settings_description_callback($args) { |
|
645 | 645 | |
646 | - if ( ! empty( $args['desc'] ) ) { |
|
646 | + if (!empty($args['desc'])) { |
|
647 | 647 | $description = $args['desc']; |
648 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
648 | + echo wp_kses_post("<p class='description'>$description</p>"); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | } |
@@ -660,35 +660,35 @@ discard block |
||
660 | 660 | </tr> |
661 | 661 | <tr class="bsui"> |
662 | 662 | <td colspan="2" class="p-0"> |
663 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
663 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
664 | 664 | |
665 | 665 | <?php |
666 | 666 | } |
667 | 667 | |
668 | -function wpinv_gateway_select_callback( $args ) { |
|
668 | +function wpinv_gateway_select_callback($args) { |
|
669 | 669 | |
670 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
671 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
672 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
673 | - $value = wpinv_get_option( $args['id'], $std ); |
|
670 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
671 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
672 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
673 | + $value = wpinv_get_option($args['id'], $std); |
|
674 | 674 | |
675 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
675 | + echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >'; |
|
676 | 676 | |
677 | - foreach ( $args['options'] as $key => $option ) : |
|
677 | + foreach ($args['options'] as $key => $option) : |
|
678 | 678 | |
679 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
679 | + echo '<option value="' . esc_attr($key) . '" '; |
|
680 | 680 | |
681 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
682 | - selected( $key, $args['selected'] ); |
|
681 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
682 | + selected($key, $args['selected']); |
|
683 | 683 | } else { |
684 | - selected( $key, $value ); |
|
684 | + selected($key, $value); |
|
685 | 685 | } |
686 | 686 | |
687 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
687 | + echo '>' . esc_html($option['admin_label']) . '</option>'; |
|
688 | 688 | endforeach; |
689 | 689 | |
690 | 690 | echo '</select>'; |
691 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
691 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -697,16 +697,16 @@ discard block |
||
697 | 697 | * @param array $args |
698 | 698 | * @return string |
699 | 699 | */ |
700 | -function wpinv_settings_attrs_helper( $args ) { |
|
700 | +function wpinv_settings_attrs_helper($args) { |
|
701 | 701 | |
702 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
703 | - $id = esc_attr( $args['id'] ); |
|
704 | - $value = is_scalar( $value ) ? $value : ''; |
|
702 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
703 | + $id = esc_attr($args['id']); |
|
704 | + $value = is_scalar($value) ? $value : ''; |
|
705 | 705 | |
706 | 706 | $attrs = array( |
707 | - 'name' => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]", |
|
708 | - 'readonly' => ! empty( $args['faux'] ), |
|
709 | - 'value' => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ), |
|
707 | + 'name' => !empty($args['faux']) ? false : "wpinv_settings[$id]", |
|
708 | + 'readonly' => !empty($args['faux']), |
|
709 | + 'value' => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value), |
|
710 | 710 | 'id' => 'wpinv-settings-' . $args['id'], |
711 | 711 | 'style' => $args['style'], |
712 | 712 | 'class' => $args['class'], |
@@ -714,20 +714,20 @@ discard block |
||
714 | 714 | 'data-placeholder' => $args['placeholder'], |
715 | 715 | ); |
716 | 716 | |
717 | - if ( ! empty( $args['onchange'] ) ) { |
|
717 | + if (!empty($args['onchange'])) { |
|
718 | 718 | $attrs['onchange'] = $args['onchange']; |
719 | 719 | } |
720 | 720 | |
721 | - foreach ( $attrs as $key => $value ) { |
|
721 | + foreach ($attrs as $key => $value) { |
|
722 | 722 | |
723 | - if ( false === $value ) { |
|
723 | + if (false === $value) { |
|
724 | 724 | continue; |
725 | 725 | } |
726 | 726 | |
727 | - if ( true === $value ) { |
|
728 | - echo ' ' . esc_attr( $key ); |
|
727 | + if (true === $value) { |
|
728 | + echo ' ' . esc_attr($key); |
|
729 | 729 | } else { |
730 | - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
730 | + echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | } |
@@ -737,12 +737,12 @@ discard block |
||
737 | 737 | /** |
738 | 738 | * Displays a text input settings callback. |
739 | 739 | */ |
740 | -function wpinv_text_callback( $args ) { |
|
740 | +function wpinv_text_callback($args) { |
|
741 | 741 | |
742 | 742 | ?> |
743 | 743 | <label style="width: 100%;"> |
744 | - <input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
745 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
744 | + <input type="text" <?php wpinv_settings_attrs_helper($args); ?>> |
|
745 | + <?php getpaid_settings_description_callback($args); ?> |
|
746 | 746 | </label> |
747 | 747 | <?php |
748 | 748 | |
@@ -751,174 +751,174 @@ discard block |
||
751 | 751 | /** |
752 | 752 | * Displays a number input settings callback. |
753 | 753 | */ |
754 | -function wpinv_number_callback( $args ) { |
|
754 | +function wpinv_number_callback($args) { |
|
755 | 755 | |
756 | 756 | ?> |
757 | 757 | <label style="width: 100%;"> |
758 | - <input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
759 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
758 | + <input type="number" step="<?php echo esc_attr($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>> |
|
759 | + <?php getpaid_settings_description_callback($args); ?> |
|
760 | 760 | </label> |
761 | 761 | <?php |
762 | 762 | |
763 | 763 | } |
764 | 764 | |
765 | -function wpinv_textarea_callback( $args ) { |
|
765 | +function wpinv_textarea_callback($args) { |
|
766 | 766 | |
767 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
768 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
769 | - $value = wpinv_get_option( $args['id'], $std ); |
|
767 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
768 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
769 | + $value = wpinv_get_option($args['id'], $std); |
|
770 | 770 | |
771 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
772 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
771 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
772 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
773 | 773 | |
774 | - echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
775 | - echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
774 | + echo '<textarea class="' . esc_attr($class) . ' txtarea-' . esc_attr($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . esc_attr($args['cols']) . '" rows="' . esc_attr($args['rows']) . '" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
775 | + echo '<br /><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
776 | 776 | |
777 | 777 | } |
778 | 778 | |
779 | -function wpinv_password_callback( $args ) { |
|
779 | +function wpinv_password_callback($args) { |
|
780 | 780 | |
781 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
782 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
783 | - $value = wpinv_get_option( $args['id'], $std ); |
|
781 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
782 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
783 | + $value = wpinv_get_option($args['id'], $std); |
|
784 | 784 | |
785 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
786 | - echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
787 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
785 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
786 | + echo '<input type="password" class="' . esc_attr($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
787 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
788 | 788 | |
789 | 789 | } |
790 | 790 | |
791 | -function wpinv_missing_callback( $args ) { |
|
791 | +function wpinv_missing_callback($args) { |
|
792 | 792 | printf( |
793 | - esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
794 | - '<strong>' . esc_html( $args['id'] ) . '</strong>' |
|
793 | + esc_html__('The callback function used for the %s setting is missing.', 'invoicing'), |
|
794 | + '<strong>' . esc_html($args['id']) . '</strong>' |
|
795 | 795 | ); |
796 | 796 | } |
797 | 797 | |
798 | 798 | /** |
799 | 799 | * Displays a number input settings callback. |
800 | 800 | */ |
801 | -function wpinv_select_callback( $args ) { |
|
801 | +function wpinv_select_callback($args) { |
|
802 | 802 | |
803 | - $desc = wp_kses_post( $args['desc'] ); |
|
804 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
805 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
806 | - $value = wpinv_get_option( $args['id'], $value ); |
|
807 | - $rand = uniqid( 'random_id' ); |
|
803 | + $desc = wp_kses_post($args['desc']); |
|
804 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
805 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
806 | + $value = wpinv_get_option($args['id'], $value); |
|
807 | + $rand = uniqid('random_id'); |
|
808 | 808 | |
809 | 809 | ?> |
810 | 810 | <label style="width: 100%;"> |
811 | - <select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true"> |
|
812 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
813 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option> |
|
811 | + <select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true"> |
|
812 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
813 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option> |
|
814 | 814 | <?php endforeach; ?> |
815 | 815 | </select> |
816 | 816 | |
817 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
818 | - <a href="<?php echo esc_url( get_edit_post_link( $value ) ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a> |
|
817 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
818 | + <a href="<?php echo esc_url(get_edit_post_link($value)); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a> |
|
819 | 819 | <?php endif; ?> |
820 | 820 | |
821 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
822 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr( $rand ); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a> |
|
823 | - <div id='<?php echo esc_attr( $rand ); ?>' style='display:none;'> |
|
821 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
822 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr($rand); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a> |
|
823 | + <div id='<?php echo esc_attr($rand); ?>' style='display:none;'> |
|
824 | 824 | <div> |
825 | - <h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3> |
|
826 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post( gepaid_trim_lines( $args['default_content'] ) ); ?></textarea> |
|
827 | - <h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3> |
|
828 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : wp_kses_post( gepaid_trim_lines( $_post->post_content ) ); ?></textarea> |
|
825 | + <h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3> |
|
826 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post(gepaid_trim_lines($args['default_content'])); ?></textarea> |
|
827 | + <h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3> |
|
828 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : wp_kses_post(gepaid_trim_lines($_post->post_content)); ?></textarea> |
|
829 | 829 | </div> |
830 | 830 | </div> |
831 | 831 | <?php endif; ?> |
832 | 832 | |
833 | - <?php echo wp_kses_post( $desc ); ?> |
|
833 | + <?php echo wp_kses_post($desc); ?> |
|
834 | 834 | </label> |
835 | 835 | <?php |
836 | 836 | |
837 | 837 | } |
838 | 838 | |
839 | -function wpinv_color_select_callback( $args ) { |
|
839 | +function wpinv_color_select_callback($args) { |
|
840 | 840 | |
841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
842 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
843 | - $value = wpinv_get_option( $args['id'], $std ); |
|
841 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
842 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
843 | + $value = wpinv_get_option($args['id'], $std); |
|
844 | 844 | |
845 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
845 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
846 | 846 | |
847 | - foreach ( $args['options'] as $option => $color ) { |
|
848 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
847 | + foreach ($args['options'] as $option => $color) { |
|
848 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | echo '</select>'; |
852 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
852 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
853 | 853 | |
854 | 854 | } |
855 | 855 | |
856 | -function wpinv_rich_editor_callback( $args ) { |
|
856 | +function wpinv_rich_editor_callback($args) { |
|
857 | 857 | global $wp_version; |
858 | 858 | |
859 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
859 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
860 | 860 | |
861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
861 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
862 | + $value = wpinv_get_option($args['id'], $std); |
|
863 | 863 | |
864 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
864 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
865 | 865 | $value = $std; |
866 | 866 | } |
867 | 867 | |
868 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
868 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
869 | 869 | |
870 | 870 | echo '<div class="getpaid-settings-editor-input">'; |
871 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
871 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
872 | 872 | wp_editor( |
873 | - stripslashes( $value ), |
|
874 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
873 | + stripslashes($value), |
|
874 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
875 | 875 | array( |
876 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
877 | - 'textarea_rows' => absint( $rows ), |
|
876 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
877 | + 'textarea_rows' => absint($rows), |
|
878 | 878 | 'media_buttons' => false, |
879 | 879 | ) |
880 | 880 | ); |
881 | 881 | } else { |
882 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
882 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
883 | 883 | } |
884 | 884 | |
885 | - echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
885 | + echo '</div><br/><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
886 | 886 | |
887 | 887 | } |
888 | 888 | |
889 | -function wpinv_upload_callback( $args ) { |
|
889 | +function wpinv_upload_callback($args) { |
|
890 | 890 | |
891 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
891 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
892 | 892 | |
893 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
894 | - $value = wpinv_get_option( $args['id'], $std ); |
|
893 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
894 | + $value = wpinv_get_option($args['id'], $std); |
|
895 | 895 | |
896 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
897 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
898 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
899 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
896 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
897 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
898 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__('Upload File', 'invoicing') . '"/></span>'; |
|
899 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
900 | 900 | |
901 | 901 | } |
902 | 902 | |
903 | -function wpinv_color_callback( $args ) { |
|
903 | +function wpinv_color_callback($args) { |
|
904 | 904 | |
905 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
906 | - $value = wpinv_get_option( $args['id'], $std ); |
|
907 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
905 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
906 | + $value = wpinv_get_option($args['id'], $std); |
|
907 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
908 | 908 | |
909 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
910 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
909 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
910 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | |
914 | -function wpinv_country_states_callback( $args ) { |
|
914 | +function wpinv_country_states_callback($args) { |
|
915 | 915 | |
916 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
917 | - $value = wpinv_get_option( $args['id'], $std ); |
|
916 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
917 | + $value = wpinv_get_option($args['id'], $std); |
|
918 | 918 | |
919 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
919 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
920 | 920 | |
921 | - if ( isset( $args['placeholder'] ) ) { |
|
921 | + if (isset($args['placeholder'])) { |
|
922 | 922 | $placeholder = $args['placeholder']; |
923 | 923 | } else { |
924 | 924 | $placeholder = ''; |
@@ -926,15 +926,15 @@ discard block |
||
926 | 926 | |
927 | 927 | $states = wpinv_get_country_states(); |
928 | 928 | |
929 | - $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2'; |
|
930 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
929 | + $class = empty($states) ? 'wpinv-no-states' : 'wpi_select2'; |
|
930 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="' . esc_attr($class) . '" data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
931 | 931 | |
932 | - foreach ( $states as $option => $name ) { |
|
933 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
932 | + foreach ($states as $option => $name) { |
|
933 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | echo '</select>'; |
937 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
937 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
938 | 938 | |
939 | 939 | } |
940 | 940 | |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | </tr> |
949 | 949 | <tr class="bsui"> |
950 | 950 | <td colspan="2" class="p-0"> |
951 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
951 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
952 | 952 | |
953 | 953 | <?php |
954 | 954 | |
@@ -957,11 +957,11 @@ discard block |
||
957 | 957 | /** |
958 | 958 | * Displays a tax rate' edit row. |
959 | 959 | */ |
960 | -function wpinv_tax_rate_callback( $tax_rate, $key ) { |
|
960 | +function wpinv_tax_rate_callback($tax_rate, $key) { |
|
961 | 961 | |
962 | - $key = sanitize_key( $key ); |
|
963 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
964 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
962 | + $key = sanitize_key($key); |
|
963 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
964 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
965 | 965 | |
966 | 966 | } |
967 | 967 | |
@@ -975,177 +975,177 @@ discard block |
||
975 | 975 | </tr> |
976 | 976 | <tr class="bsui"> |
977 | 977 | <td colspan="2" class="p-0"> |
978 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rules-edit.php'; ?> |
|
978 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rules-edit.php'; ?> |
|
979 | 979 | |
980 | 980 | <?php |
981 | 981 | |
982 | 982 | } |
983 | 983 | |
984 | -function wpinv_tools_callback( $args ) { |
|
984 | +function wpinv_tools_callback($args) { |
|
985 | 985 | ?> |
986 | 986 | </td><tr> |
987 | 987 | <td colspan="2" class="wpinv_tools_tdbox"> |
988 | 988 | <?php |
989 | - if ( $args['desc'] ) { |
|
989 | + if ($args['desc']) { |
|
990 | 990 | ?> |
991 | -<p><?php echo wp_kses_post( $args['desc'] ); ?></p><?php } ?> |
|
992 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
991 | +<p><?php echo wp_kses_post($args['desc']); ?></p><?php } ?> |
|
992 | + <?php do_action('wpinv_tools_before'); ?> |
|
993 | 993 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
994 | 994 | <thead> |
995 | 995 | <tr> |
996 | - <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th> |
|
997 | - <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th> |
|
998 | - <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th> |
|
996 | + <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th> |
|
997 | + <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th> |
|
998 | + <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th> |
|
999 | 999 | </tr> |
1000 | 1000 | </thead> |
1001 | 1001 | |
1002 | 1002 | <tbody> |
1003 | 1003 | <tr> |
1004 | - <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td> |
|
1004 | + <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td> |
|
1005 | 1005 | <td> |
1006 | - <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
1006 | + <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
1007 | 1007 | </td> |
1008 | 1008 | <td> |
1009 | 1009 | <a href=" |
1010 | 1010 | <?php |
1011 | 1011 | echo esc_url( |
1012 | 1012 | wp_nonce_url( |
1013 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
1013 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
1014 | 1014 | 'getpaid-nonce', |
1015 | 1015 | 'getpaid-nonce' |
1016 | 1016 | ) |
1017 | 1017 | ); |
1018 | 1018 | ?> |
1019 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1019 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1020 | 1020 | </td> |
1021 | 1021 | </tr> |
1022 | 1022 | <tr> |
1023 | - <td><?php esc_html_e( 'Refresh Permalinks', 'invoicing' ); ?></td> |
|
1023 | + <td><?php esc_html_e('Refresh Permalinks', 'invoicing'); ?></td> |
|
1024 | 1024 | <td> |
1025 | - <small><?php esc_html_e( 'Might fix the page not found error when viewing an invoice.', 'invoicing' ); ?></small> |
|
1025 | + <small><?php esc_html_e('Might fix the page not found error when viewing an invoice.', 'invoicing'); ?></small> |
|
1026 | 1026 | </td> |
1027 | 1027 | <td> |
1028 | 1028 | <a href=" |
1029 | 1029 | <?php |
1030 | 1030 | echo esc_url( |
1031 | 1031 | wp_nonce_url( |
1032 | - add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ), |
|
1032 | + add_query_arg('getpaid-admin-action', 'refresh_permalinks'), |
|
1033 | 1033 | 'getpaid-nonce', |
1034 | 1034 | 'getpaid-nonce' |
1035 | 1035 | ) |
1036 | 1036 | ); |
1037 | 1037 | ?> |
1038 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1038 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1039 | 1039 | </td> |
1040 | 1040 | </tr> |
1041 | 1041 | <tr> |
1042 | - <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td> |
|
1042 | + <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td> |
|
1043 | 1043 | <td> |
1044 | - <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
1044 | + <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
1045 | 1045 | </td> |
1046 | 1046 | <td> |
1047 | 1047 | <a href=" |
1048 | 1048 | <?php |
1049 | 1049 | echo esc_url( |
1050 | 1050 | wp_nonce_url( |
1051 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1051 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
1052 | 1052 | 'getpaid-nonce', |
1053 | 1053 | 'getpaid-nonce' |
1054 | 1054 | ) |
1055 | 1055 | ); |
1056 | 1056 | ?> |
1057 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1057 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1058 | 1058 | </td> |
1059 | 1059 | </tr> |
1060 | 1060 | <tr> |
1061 | - <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
1061 | + <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td> |
|
1062 | 1062 | <td> |
1063 | - <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1063 | + <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1064 | 1064 | </td> |
1065 | 1065 | <td> |
1066 | 1066 | <a href=" |
1067 | 1067 | <?php |
1068 | 1068 | echo esc_url( |
1069 | 1069 | wp_nonce_url( |
1070 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1070 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1071 | 1071 | 'getpaid-nonce', |
1072 | 1072 | 'getpaid-nonce' |
1073 | 1073 | ) |
1074 | 1074 | ); |
1075 | 1075 | ?> |
1076 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1076 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1077 | 1077 | </td> |
1078 | 1078 | </tr> |
1079 | 1079 | |
1080 | 1080 | <tr> |
1081 | - <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1081 | + <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1082 | 1082 | <td> |
1083 | - <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1083 | + <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1084 | 1084 | </td> |
1085 | 1085 | <td> |
1086 | 1086 | <a href=" |
1087 | 1087 | <?php |
1088 | 1088 | echo esc_url( |
1089 | 1089 | wp_nonce_url( |
1090 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1090 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1091 | 1091 | 'getpaid-nonce', |
1092 | 1092 | 'getpaid-nonce' |
1093 | 1093 | ) |
1094 | 1094 | ); |
1095 | 1095 | ?> |
1096 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1096 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1097 | 1097 | </td> |
1098 | 1098 | </tr> |
1099 | 1099 | |
1100 | 1100 | <tr> |
1101 | - <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1101 | + <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td> |
|
1102 | 1102 | <td> |
1103 | - <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1103 | + <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1104 | 1104 | </td> |
1105 | 1105 | <td> |
1106 | 1106 | <a href=" |
1107 | 1107 | <?php |
1108 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1108 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1109 | 1109 | ?> |
1110 | - " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
|
1110 | + " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a> |
|
1111 | 1111 | </td> |
1112 | 1112 | </tr> |
1113 | 1113 | |
1114 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1114 | + <?php do_action('wpinv_tools_row'); ?> |
|
1115 | 1115 | </tbody> |
1116 | 1116 | </table> |
1117 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1117 | + <?php do_action('wpinv_tools_after'); ?> |
|
1118 | 1118 | <?php |
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | |
1122 | -function wpinv_descriptive_text_callback( $args ) { |
|
1123 | - echo wp_kses_post( $args['desc'] ); |
|
1122 | +function wpinv_descriptive_text_callback($args) { |
|
1123 | + echo wp_kses_post($args['desc']); |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | -function wpinv_raw_html_callback( $args ) { |
|
1127 | - echo wp_kses( $args['desc'], getpaid_allowed_html() ); |
|
1126 | +function wpinv_raw_html_callback($args) { |
|
1127 | + echo wp_kses($args['desc'], getpaid_allowed_html()); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | -function wpinv_hook_callback( $args ) { |
|
1131 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1130 | +function wpinv_hook_callback($args) { |
|
1131 | + do_action('wpinv_' . $args['id'], $args); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | function wpinv_set_settings_cap() { |
1135 | 1135 | return wpinv_get_capability(); |
1136 | 1136 | } |
1137 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1137 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1138 | 1138 | |
1139 | 1139 | |
1140 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1141 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1142 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1140 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1141 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1142 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1143 | 1143 | |
1144 | - if ( $old != $new ) { |
|
1145 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1144 | + if ($old != $new) { |
|
1145 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1146 | 1146 | } |
1147 | 1147 | } |
1148 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1148 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1149 | 1149 | |
1150 | 1150 | /** |
1151 | 1151 | * Returns the merge tags help text. |
@@ -1154,16 +1154,16 @@ discard block |
||
1154 | 1154 | * |
1155 | 1155 | * @return string |
1156 | 1156 | */ |
1157 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1157 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1158 | 1158 | |
1159 | 1159 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1160 | 1160 | $link = sprintf( |
1161 | 1161 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1162 | 1162 | $url, |
1163 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1163 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1164 | 1164 | ); |
1165 | 1165 | |
1166 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1166 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1167 | 1167 | |
1168 | 1168 | return "$description $link"; |
1169 | 1169 |
@@ -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' => '', |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * Parse incoming $args into an array and merge it with $defaults |
67 | 67 | */ |
68 | - $args = wp_parse_args( $args, $defaults ); |
|
68 | + $args = wp_parse_args($args, $defaults); |
|
69 | 69 | $output = ''; |
70 | - if ( ! empty( $args['type'] ) ) { |
|
70 | + if (!empty($args['type'])) { |
|
71 | 71 | // hidden label option needs to be empty |
72 | 72 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
73 | 73 | |
74 | - $type = sanitize_html_class( $args['type'] ); |
|
74 | + $type = sanitize_html_class($args['type']); |
|
75 | 75 | |
76 | 76 | $help_text = ''; |
77 | 77 | $label = ''; |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | ); |
86 | 86 | |
87 | 87 | // floating labels need label after |
88 | - if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) { |
|
88 | + if ($args['label_type'] == 'floating' && $type != 'checkbox') { |
|
89 | 89 | $label_after = true; |
90 | 90 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
91 | 91 | } |
92 | 92 | |
93 | 93 | // size |
94 | 94 | $size = ''; |
95 | - if ( $args['size'] == 'lg' || $args['size'] == 'large' ) { |
|
95 | + if ($args['size'] == 'lg' || $args['size'] == 'large') { |
|
96 | 96 | $size = 'lg'; |
97 | 97 | $args['class'] .= ' form-control-lg'; |
98 | - }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) { |
|
98 | + }elseif ($args['size'] == 'sm' || $args['size'] == 'small') { |
|
99 | 99 | $size = 'sm'; |
100 | 100 | $args['class'] .= ' form-control-sm'; |
101 | 101 | } |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');'; |
105 | 105 | |
106 | 106 | // Some special sauce for files |
107 | - if ( $type == 'file' ) { |
|
107 | + if ($type == 'file') { |
|
108 | 108 | $label_after = true; // if type file we need the label after |
109 | 109 | $args['class'] .= ' custom-file-input '; |
110 | - } elseif ( $type == 'checkbox' ) { |
|
110 | + } elseif ($type == 'checkbox') { |
|
111 | 111 | $label_after = true; // if type file we need the label after |
112 | 112 | $args['class'] .= ' custom-control-input '; |
113 | - } elseif ( $type == 'datepicker' || $type == 'timepicker' ) { |
|
113 | + } elseif ($type == 'datepicker' || $type == 'timepicker') { |
|
114 | 114 | $type = 'text'; |
115 | 115 | $args['class'] .= ' bg-initial '; // @todo not sure why we have this? |
116 | - $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');"; |
|
116 | + $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr($args['name']) . "\']').trigger('change');"; |
|
117 | 117 | |
118 | 118 | $args['extra_attributes']['data-aui-init'] = 'flatpickr'; |
119 | 119 | |
120 | 120 | // set a way to clear field if empty |
121 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) { |
|
121 | + if ($args['input_group_right'] === '' && $args['clear_icon'] !== false) { |
|
122 | 122 | $args['input_group_right_inside'] = true; |
123 | 123 | $args['clear_icon'] = true; |
124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | // enqueue the script |
127 | 127 | $aui_settings = AyeCode_UI_Settings::instance(); |
128 | 128 | $aui_settings->enqueue_flatpickr(); |
129 | - } elseif ( $type == 'iconpicker' ) { |
|
129 | + } elseif ($type == 'iconpicker') { |
|
130 | 130 | $type = 'text'; |
131 | 131 | //$args['class'] .= ' aui-flatpickr bg-initial '; |
132 | 132 | // $args['class'] .= ' bg-initial '; |
@@ -141,103 +141,103 @@ discard block |
||
141 | 141 | $aui_settings->enqueue_iconpicker(); |
142 | 142 | } |
143 | 143 | |
144 | - if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) { |
|
145 | - $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />'; |
|
144 | + if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) { |
|
145 | + $output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />'; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // allow clear icon |
149 | - if ( $args['input_group_right'] === '' && $args['clear_icon'] ) { |
|
150 | - $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' ); |
|
149 | + if ($args['input_group_right'] === '' && $args['clear_icon']) { |
|
150 | + $font_size = $size == 'sm' ? '1.3' : ($size == 'lg' ? '1.65' : '1.5'); |
|
151 | 151 | $args['input_group_right_inside'] = true; |
152 | - $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: '.$font_size.'rem" aria-hidden="true" class="close">×</span></span>'; |
|
152 | + $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="close">×</span></span>'; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | // open/type |
156 | 156 | $output .= '<input type="' . $type . '" '; |
157 | 157 | |
158 | 158 | // name |
159 | - if ( ! empty( $args['name'] ) ) { |
|
160 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
159 | + if (!empty($args['name'])) { |
|
160 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // id |
164 | - if ( ! empty( $args['id'] ) ) { |
|
165 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
164 | + if (!empty($args['id'])) { |
|
165 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // placeholder |
169 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
170 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
169 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
170 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // title |
174 | - if ( ! empty( $args['title'] ) ) { |
|
175 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
174 | + if (!empty($args['title'])) { |
|
175 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | // value |
179 | - if ( ! empty( $args['value'] ) ) { |
|
180 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
179 | + if (!empty($args['value'])) { |
|
180 | + $output .= AUI_Component_Helper::value($args['value']); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // checked, for radio and checkboxes |
184 | - if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) { |
|
184 | + if (($type == 'checkbox' || $type == 'radio') && $args['checked']) { |
|
185 | 185 | $output .= ' checked '; |
186 | 186 | } |
187 | 187 | |
188 | 188 | // validation text |
189 | - if ( ! empty( $args['validation_text'] ) ) { |
|
190 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
189 | + if (!empty($args['validation_text'])) { |
|
190 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
191 | 191 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
192 | 192 | } |
193 | 193 | |
194 | 194 | // validation_pattern |
195 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
196 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
195 | + if (!empty($args['validation_pattern'])) { |
|
196 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // step (for numbers) |
200 | - if ( ! empty( $args['step'] ) ) { |
|
200 | + if (!empty($args['step'])) { |
|
201 | 201 | $output .= ' step="' . $args['step'] . '" '; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // required |
205 | - if ( ! empty( $args['required'] ) ) { |
|
205 | + if (!empty($args['required'])) { |
|
206 | 206 | $output .= ' required '; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // class |
210 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
210 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
211 | 211 | $output .= ' class="form-control ' . $class . '" '; |
212 | 212 | |
213 | 213 | // data-attributes |
214 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
214 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
215 | 215 | |
216 | 216 | // extra attributes |
217 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
218 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
217 | + if (!empty($args['extra_attributes'])) { |
|
218 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // close |
222 | 222 | $output .= ' >'; |
223 | 223 | |
224 | 224 | // help text |
225 | - if ( ! empty( $args['help_text'] ) ) { |
|
226 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
225 | + if (!empty($args['help_text'])) { |
|
226 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | // label |
230 | - if ( ! empty( $args['label'] ) ) { |
|
230 | + if (!empty($args['label'])) { |
|
231 | 231 | $label_base_class = ''; |
232 | - if ( $type == 'file' ) { |
|
232 | + if ($type == 'file') { |
|
233 | 233 | $label_base_class = ' custom-file-label'; |
234 | - } elseif ( $type == 'checkbox' ) { |
|
235 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
236 | - $label_args['title'] = wp_kses_post( $args['help_text'] ); |
|
234 | + } elseif ($type == 'checkbox') { |
|
235 | + if (!empty($args['label_force_left'])) { |
|
236 | + $label_args['title'] = wp_kses_post($args['help_text']); |
|
237 | 237 | $help_text = ''; |
238 | 238 | //$label_args['class'] .= ' d-inline '; |
239 | 239 | $args['wrap_class'] .= ' align-items-center '; |
240 | - }else{ |
|
240 | + } else { |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -245,45 +245,45 @@ discard block |
||
245 | 245 | } |
246 | 246 | $label_args['class'] .= $label_base_class; |
247 | 247 | $temp_label_args = $label_args; |
248 | - if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";} |
|
249 | - $label = self::label( $temp_label_args, $type ); |
|
248 | + if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; } |
|
249 | + $label = self::label($temp_label_args, $type); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | |
254 | 254 | |
255 | 255 | // set help text in the correct position |
256 | - if ( $label_after ) { |
|
256 | + if ($label_after) { |
|
257 | 257 | $output .= $label . $help_text; |
258 | 258 | } |
259 | 259 | |
260 | 260 | // some input types need a separate wrap |
261 | - if ( $type == 'file' ) { |
|
262 | - $output = self::wrap( array( |
|
261 | + if ($type == 'file') { |
|
262 | + $output = self::wrap(array( |
|
263 | 263 | 'content' => $output, |
264 | 264 | 'class' => 'form-group custom-file' |
265 | - ) ); |
|
266 | - } elseif ( $type == 'checkbox' ) { |
|
265 | + )); |
|
266 | + } elseif ($type == 'checkbox') { |
|
267 | 267 | |
268 | 268 | $label_args['title'] = $args['label']; |
269 | - $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ); |
|
270 | - $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
271 | - $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : ''; |
|
272 | - $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox'; |
|
273 | - if ( ! empty( $args['label_force_left'] ) ) { |
|
269 | + $label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label'); |
|
270 | + $label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>'; |
|
271 | + $switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : ''; |
|
272 | + $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox'; |
|
273 | + if (!empty($args['label_force_left'])) { |
|
274 | 274 | $wrap_class .= ' d-flex align-content-center'; |
275 | - $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) ); |
|
275 | + $label = str_replace("custom-control-label", "", self::label($label_args, 'cb')); |
|
276 | 276 | } |
277 | - $output = self::wrap( array( |
|
277 | + $output = self::wrap(array( |
|
278 | 278 | 'content' => $output, |
279 | 279 | 'class' => 'custom-control ' . $wrap_class |
280 | - ) ); |
|
280 | + )); |
|
281 | 281 | |
282 | - if ( $args['label_type'] == 'horizontal' ) { |
|
283 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
282 | + if ($args['label_type'] == 'horizontal') { |
|
283 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
284 | 284 | $output = $label . '<div class="' . $input_col . '">' . $output . '</div>'; |
285 | 285 | } |
286 | - } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) { |
|
286 | + } elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) { |
|
287 | 287 | |
288 | 288 | |
289 | 289 | // allow password field to toggle view |
@@ -297,65 +297,65 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | // input group wraps |
300 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
301 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
300 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
301 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
302 | 302 | $group_size = $size == 'lg' ? ' input-group-lg' : ''; |
303 | 303 | $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size; |
304 | 304 | |
305 | - if ( $args['input_group_left'] ) { |
|
306 | - $output = self::wrap( array( |
|
305 | + if ($args['input_group_left']) { |
|
306 | + $output = self::wrap(array( |
|
307 | 307 | 'content' => $output, |
308 | 308 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
309 | 309 | 'input_group_left' => $args['input_group_left'], |
310 | 310 | 'input_group_left_inside' => $args['input_group_left_inside'] |
311 | - ) ); |
|
311 | + )); |
|
312 | 312 | } |
313 | - if ( $args['input_group_right'] ) { |
|
314 | - $output = self::wrap( array( |
|
313 | + if ($args['input_group_right']) { |
|
314 | + $output = self::wrap(array( |
|
315 | 315 | 'content' => $output, |
316 | 316 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size, |
317 | 317 | 'input_group_right' => $args['input_group_right'], |
318 | 318 | 'input_group_right_inside' => $args['input_group_right_inside'] |
319 | - ) ); |
|
319 | + )); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | } |
323 | 323 | |
324 | - if ( ! $label_after ) { |
|
324 | + if (!$label_after) { |
|
325 | 325 | $output .= $help_text; |
326 | 326 | } |
327 | 327 | |
328 | 328 | |
329 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
330 | - $output = self::wrap( array( |
|
329 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
330 | + $output = self::wrap(array( |
|
331 | 331 | 'content' => $output, |
332 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
333 | - ) ); |
|
332 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
333 | + )); |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( ! $label_after ) { |
|
336 | + if (!$label_after) { |
|
337 | 337 | $output = $label . $output; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // wrap |
341 | - if ( ! $args['no_wrap'] ) { |
|
341 | + if (!$args['no_wrap']) { |
|
342 | 342 | $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group'; |
343 | 343 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
344 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
345 | - $output = self::wrap( array( |
|
344 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
345 | + $output = self::wrap(array( |
|
346 | 346 | 'content' => $output, |
347 | 347 | 'class' => $wrap_class, |
348 | 348 | 'element_require' => $args['element_require'], |
349 | 349 | 'argument_id' => $args['id'], |
350 | 350 | 'wrap_attributes' => $args['wrap_attributes'], |
351 | - ) ); |
|
351 | + )); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | return $output; |
356 | 356 | } |
357 | 357 | |
358 | - public static function label( $args = array(), $type = '' ) { |
|
358 | + public static function label($args = array(), $type = '') { |
|
359 | 359 | //<label for="exampleInputEmail1">Email address</label> |
360 | 360 | $defaults = array( |
361 | 361 | 'title' => 'div', |
@@ -368,33 +368,33 @@ discard block |
||
368 | 368 | /** |
369 | 369 | * Parse incoming $args into an array and merge it with $defaults |
370 | 370 | */ |
371 | - $args = wp_parse_args( $args, $defaults ); |
|
371 | + $args = wp_parse_args($args, $defaults); |
|
372 | 372 | $output = ''; |
373 | 373 | |
374 | - if ( $args['title'] ) { |
|
374 | + if ($args['title']) { |
|
375 | 375 | |
376 | 376 | // maybe hide labels //@todo set a global option for visibility class |
377 | - if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) { |
|
377 | + if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) { |
|
378 | 378 | $class = $args['class']; |
379 | 379 | } else { |
380 | 380 | $class = 'sr-only ' . $args['class']; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // maybe horizontal |
384 | - if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) { |
|
385 | - $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label'; |
|
384 | + if ($args['label_type'] == 'horizontal' && $type != 'checkbox') { |
|
385 | + $class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label'; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | // open |
389 | 389 | $output .= '<label '; |
390 | 390 | |
391 | 391 | // for |
392 | - if ( ! empty( $args['for'] ) ) { |
|
393 | - $output .= ' for="' . esc_attr( $args['for'] ) . '" '; |
|
392 | + if (!empty($args['for'])) { |
|
393 | + $output .= ' for="' . esc_attr($args['for']) . '" '; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | // class |
397 | - $class = $class ? AUI_Component_Helper::esc_classes( $class ) : ''; |
|
397 | + $class = $class ? AUI_Component_Helper::esc_classes($class) : ''; |
|
398 | 398 | $output .= ' class="' . $class . '" '; |
399 | 399 | |
400 | 400 | // close |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | |
403 | 403 | |
404 | 404 | // title, don't escape fully as can contain html |
405 | - if ( ! empty( $args['title'] ) ) { |
|
406 | - $output .= wp_kses_post( $args['title'] ); |
|
405 | + if (!empty($args['title'])) { |
|
406 | + $output .= wp_kses_post($args['title']); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | // close wrap |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @return string |
425 | 425 | */ |
426 | - public static function wrap( $args = array() ) { |
|
426 | + public static function wrap($args = array()) { |
|
427 | 427 | $defaults = array( |
428 | 428 | 'type' => 'div', |
429 | 429 | 'class' => 'form-group', |
@@ -440,31 +440,31 @@ discard block |
||
440 | 440 | /** |
441 | 441 | * Parse incoming $args into an array and merge it with $defaults |
442 | 442 | */ |
443 | - $args = wp_parse_args( $args, $defaults ); |
|
443 | + $args = wp_parse_args($args, $defaults); |
|
444 | 444 | $output = ''; |
445 | - if ( $args['type'] ) { |
|
445 | + if ($args['type']) { |
|
446 | 446 | |
447 | 447 | // open |
448 | - $output .= '<' . sanitize_html_class( $args['type'] ); |
|
448 | + $output .= '<' . sanitize_html_class($args['type']); |
|
449 | 449 | |
450 | 450 | // element require |
451 | - if ( ! empty( $args['element_require'] ) ) { |
|
452 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
451 | + if (!empty($args['element_require'])) { |
|
452 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
453 | 453 | $args['class'] .= " aui-conditional-field"; |
454 | 454 | } |
455 | 455 | |
456 | 456 | // argument_id |
457 | - if ( ! empty( $args['argument_id'] ) ) { |
|
458 | - $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"'; |
|
457 | + if (!empty($args['argument_id'])) { |
|
458 | + $output .= ' data-argument="' . esc_attr($args['argument_id']) . '"'; |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | // class |
462 | - $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : ''; |
|
462 | + $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : ''; |
|
463 | 463 | $output .= ' class="' . $class . '" '; |
464 | 464 | |
465 | 465 | // Attributes |
466 | - if ( ! empty( $args['wrap_attributes'] ) ) { |
|
467 | - $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] ); |
|
466 | + if (!empty($args['wrap_attributes'])) { |
|
467 | + $output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | // close wrap |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | |
473 | 473 | |
474 | 474 | // Input group left |
475 | - if ( ! empty( $args['input_group_left'] ) ) { |
|
476 | - $position_class = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : ''; |
|
477 | - $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
475 | + if (!empty($args['input_group_left'])) { |
|
476 | + $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : ''; |
|
477 | + $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>'; |
|
478 | 478 | $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>'; |
479 | 479 | } |
480 | 480 | |
@@ -482,15 +482,15 @@ discard block |
||
482 | 482 | $output .= $args['content']; |
483 | 483 | |
484 | 484 | // Input group right |
485 | - if ( ! empty( $args['input_group_right'] ) ) { |
|
486 | - $position_class = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : ''; |
|
487 | - $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
485 | + if (!empty($args['input_group_right'])) { |
|
486 | + $position_class = !empty($args['input_group_right_inside']) ? 'position-absolute h-100' : ''; |
|
487 | + $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>'; |
|
488 | 488 | $output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>'; |
489 | 489 | } |
490 | 490 | |
491 | 491 | |
492 | 492 | // close wrap |
493 | - $output .= '</' . sanitize_html_class( $args['type'] ) . '>'; |
|
493 | + $output .= '</' . sanitize_html_class($args['type']) . '>'; |
|
494 | 494 | |
495 | 495 | |
496 | 496 | } else { |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * |
508 | 508 | * @return string The rendered component. |
509 | 509 | */ |
510 | - public static function textarea( $args = array() ) { |
|
510 | + public static function textarea($args = array()) { |
|
511 | 511 | $defaults = array( |
512 | 512 | 'name' => '', |
513 | 513 | 'class' => '', |
@@ -544,28 +544,28 @@ discard block |
||
544 | 544 | /** |
545 | 545 | * Parse incoming $args into an array and merge it with $defaults |
546 | 546 | */ |
547 | - $args = wp_parse_args( $args, $defaults ); |
|
547 | + $args = wp_parse_args($args, $defaults); |
|
548 | 548 | $output = ''; |
549 | 549 | |
550 | 550 | // hidden label option needs to be empty |
551 | 551 | $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type']; |
552 | 552 | |
553 | 553 | // floating labels don't work with wysiwyg so set it as top |
554 | - if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) { |
|
554 | + if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) { |
|
555 | 555 | $args['label_type'] = 'top'; |
556 | 556 | } |
557 | 557 | |
558 | 558 | $label_after = $args['label_after']; |
559 | 559 | |
560 | 560 | // floating labels need label after |
561 | - if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) { |
|
561 | + if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) { |
|
562 | 562 | $label_after = true; |
563 | 563 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
564 | 564 | } |
565 | 565 | |
566 | 566 | // label |
567 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
568 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
567 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
568 | + } elseif (!empty($args['label']) && !$label_after) { |
|
569 | 569 | $label_args = array( |
570 | 570 | 'title' => $args['label'], |
571 | 571 | 'for' => $args['id'], |
@@ -573,34 +573,34 @@ discard block |
||
573 | 573 | 'label_type' => $args['label_type'], |
574 | 574 | 'label_col' => $args['label_col'] |
575 | 575 | ); |
576 | - $output .= self::label( $label_args ); |
|
576 | + $output .= self::label($label_args); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | // maybe horizontal label |
580 | - if ( $args['label_type'] == 'horizontal' ) { |
|
581 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
580 | + if ($args['label_type'] == 'horizontal') { |
|
581 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
582 | 582 | $output .= '<div class="' . $input_col . '">'; |
583 | 583 | } |
584 | 584 | |
585 | - if ( ! empty( $args['wysiwyg'] ) ) { |
|
585 | + if (!empty($args['wysiwyg'])) { |
|
586 | 586 | ob_start(); |
587 | 587 | $content = $args['value']; |
588 | - $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor'; |
|
588 | + $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor'; |
|
589 | 589 | $settings = array( |
590 | - 'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4, |
|
590 | + 'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4, |
|
591 | 591 | 'quicktags' => false, |
592 | 592 | 'media_buttons' => false, |
593 | 593 | 'editor_class' => 'form-control', |
594 | - 'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ), |
|
594 | + 'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']), |
|
595 | 595 | 'teeny' => true, |
596 | 596 | ); |
597 | 597 | |
598 | 598 | // maybe set settings if array |
599 | - if ( is_array( $args['wysiwyg'] ) ) { |
|
600 | - $settings = wp_parse_args( $args['wysiwyg'], $settings ); |
|
599 | + if (is_array($args['wysiwyg'])) { |
|
600 | + $settings = wp_parse_args($args['wysiwyg'], $settings); |
|
601 | 601 | } |
602 | 602 | |
603 | - wp_editor( $content, $editor_id, $settings ); |
|
603 | + wp_editor($content, $editor_id, $settings); |
|
604 | 604 | $output .= ob_get_clean(); |
605 | 605 | } else { |
606 | 606 | |
@@ -608,65 +608,65 @@ discard block |
||
608 | 608 | $output .= '<textarea '; |
609 | 609 | |
610 | 610 | // name |
611 | - if ( ! empty( $args['name'] ) ) { |
|
612 | - $output .= ' name="' . esc_attr( $args['name'] ) . '" '; |
|
611 | + if (!empty($args['name'])) { |
|
612 | + $output .= ' name="' . esc_attr($args['name']) . '" '; |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | // id |
616 | - if ( ! empty( $args['id'] ) ) { |
|
617 | - $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" '; |
|
616 | + if (!empty($args['id'])) { |
|
617 | + $output .= ' id="' . sanitize_html_class($args['id']) . '" '; |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | // placeholder |
621 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) { |
|
622 | - $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" '; |
|
621 | + if (isset($args['placeholder']) && '' != $args['placeholder']) { |
|
622 | + $output .= ' placeholder="' . esc_attr($args['placeholder']) . '" '; |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | // title |
626 | - if ( ! empty( $args['title'] ) ) { |
|
627 | - $output .= ' title="' . esc_attr( $args['title'] ) . '" '; |
|
626 | + if (!empty($args['title'])) { |
|
627 | + $output .= ' title="' . esc_attr($args['title']) . '" '; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // validation text |
631 | - if ( ! empty( $args['validation_text'] ) ) { |
|
632 | - $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" '; |
|
631 | + if (!empty($args['validation_text'])) { |
|
632 | + $output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" '; |
|
633 | 633 | $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" '; |
634 | 634 | } |
635 | 635 | |
636 | 636 | // validation_pattern |
637 | - if ( ! empty( $args['validation_pattern'] ) ) { |
|
638 | - $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" '; |
|
637 | + if (!empty($args['validation_pattern'])) { |
|
638 | + $output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" '; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | // required |
642 | - if ( ! empty( $args['required'] ) ) { |
|
642 | + if (!empty($args['required'])) { |
|
643 | 643 | $output .= ' required '; |
644 | 644 | } |
645 | 645 | |
646 | 646 | // rows |
647 | - if ( ! empty( $args['rows'] ) ) { |
|
648 | - $output .= ' rows="' . absint( $args['rows'] ) . '" '; |
|
647 | + if (!empty($args['rows'])) { |
|
648 | + $output .= ' rows="' . absint($args['rows']) . '" '; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
652 | 652 | // class |
653 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
653 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
654 | 654 | $output .= ' class="form-control ' . $class . '" '; |
655 | 655 | |
656 | 656 | // extra attributes |
657 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
658 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
657 | + if (!empty($args['extra_attributes'])) { |
|
658 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | // close tag |
662 | 662 | $output .= ' >'; |
663 | 663 | |
664 | 664 | // value |
665 | - if ( ! empty( $args['value'] ) ) { |
|
666 | - if ( ! empty( $args['allow_tags'] ) ) { |
|
667 | - $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML. |
|
665 | + if (!empty($args['value'])) { |
|
666 | + if (!empty($args['allow_tags'])) { |
|
667 | + $output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML. |
|
668 | 668 | } else { |
669 | - $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] ); |
|
669 | + $output .= AUI_Component_Helper::sanitize_textarea_field($args['value']); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | |
@@ -675,23 +675,23 @@ discard block |
||
675 | 675 | |
676 | 676 | |
677 | 677 | // input group wraps |
678 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
679 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
680 | - if ( $args['input_group_left'] ) { |
|
681 | - $output = self::wrap( array( |
|
678 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
679 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
680 | + if ($args['input_group_left']) { |
|
681 | + $output = self::wrap(array( |
|
682 | 682 | 'content' => $output, |
683 | 683 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
684 | 684 | 'input_group_left' => $args['input_group_left'], |
685 | 685 | 'input_group_left_inside' => $args['input_group_left_inside'] |
686 | - ) ); |
|
686 | + )); |
|
687 | 687 | } |
688 | - if ( $args['input_group_right'] ) { |
|
689 | - $output = self::wrap( array( |
|
688 | + if ($args['input_group_right']) { |
|
689 | + $output = self::wrap(array( |
|
690 | 690 | 'content' => $output, |
691 | 691 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
692 | 692 | 'input_group_right' => $args['input_group_right'], |
693 | 693 | 'input_group_right_inside' => $args['input_group_right_inside'] |
694 | - ) ); |
|
694 | + )); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | } |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | } |
701 | 701 | |
702 | - if ( ! empty( $args['label'] ) && $label_after ) { |
|
702 | + if (!empty($args['label']) && $label_after) { |
|
703 | 703 | $label_args = array( |
704 | 704 | 'title' => $args['label'], |
705 | 705 | 'for' => $args['id'], |
@@ -707,32 +707,32 @@ discard block |
||
707 | 707 | 'label_type' => $args['label_type'], |
708 | 708 | 'label_col' => $args['label_col'] |
709 | 709 | ); |
710 | - $output .= self::label( $label_args ); |
|
710 | + $output .= self::label($label_args); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | // help text |
714 | - if ( ! empty( $args['help_text'] ) ) { |
|
715 | - $output .= AUI_Component_Helper::help_text( $args['help_text'] ); |
|
714 | + if (!empty($args['help_text'])) { |
|
715 | + $output .= AUI_Component_Helper::help_text($args['help_text']); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | // maybe horizontal label |
719 | - if ( $args['label_type'] == 'horizontal' ) { |
|
719 | + if ($args['label_type'] == 'horizontal') { |
|
720 | 720 | $output .= '</div>'; |
721 | 721 | } |
722 | 722 | |
723 | 723 | |
724 | 724 | // wrap |
725 | - if ( ! $args['no_wrap'] ) { |
|
725 | + if (!$args['no_wrap']) { |
|
726 | 726 | $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group'; |
727 | 727 | $wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class; |
728 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
729 | - $output = self::wrap( array( |
|
728 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
729 | + $output = self::wrap(array( |
|
730 | 730 | 'content' => $output, |
731 | 731 | 'class' => $wrap_class, |
732 | 732 | 'element_require' => $args['element_require'], |
733 | 733 | 'argument_id' => $args['id'], |
734 | 734 | 'wrap_attributes' => $args['wrap_attributes'], |
735 | - ) ); |
|
735 | + )); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | * |
747 | 747 | * @return string The rendered component. |
748 | 748 | */ |
749 | - public static function select( $args = array() ) { |
|
749 | + public static function select($args = array()) { |
|
750 | 750 | $defaults = array( |
751 | 751 | 'class' => '', |
752 | 752 | 'wrap_class' => '', |
@@ -783,11 +783,11 @@ discard block |
||
783 | 783 | /** |
784 | 784 | * Parse incoming $args into an array and merge it with $defaults |
785 | 785 | */ |
786 | - $args = wp_parse_args( $args, $defaults ); |
|
786 | + $args = wp_parse_args($args, $defaults); |
|
787 | 787 | $output = ''; |
788 | 788 | |
789 | 789 | // for now lets hide floating labels |
790 | - if ( $args['label_type'] == 'floating' ) { |
|
790 | + if ($args['label_type'] == 'floating') { |
|
791 | 791 | $args['label_type'] = 'hidden'; |
792 | 792 | } |
793 | 793 | |
@@ -798,89 +798,89 @@ discard block |
||
798 | 798 | $label_after = $args['label_after']; |
799 | 799 | |
800 | 800 | // floating labels need label after |
801 | - if ( $args['label_type'] == 'floating' ) { |
|
801 | + if ($args['label_type'] == 'floating') { |
|
802 | 802 | $label_after = true; |
803 | 803 | $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works. |
804 | 804 | } |
805 | 805 | |
806 | 806 | // Maybe setup select2 |
807 | 807 | $is_select2 = false; |
808 | - if ( ! empty( $args['select2'] ) ) { |
|
808 | + if (!empty($args['select2'])) { |
|
809 | 809 | $args['class'] .= ' aui-select2'; |
810 | 810 | $is_select2 = true; |
811 | - } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) { |
|
811 | + } elseif (strpos($args['class'], 'aui-select2') !== false) { |
|
812 | 812 | $is_select2 = true; |
813 | 813 | } |
814 | 814 | |
815 | 815 | // select2 tags |
816 | - if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason |
|
816 | + if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason |
|
817 | 817 | $args['data-tags'] = 'true'; |
818 | 818 | $args['data-token-separators'] = "[',']"; |
819 | 819 | $args['multiple'] = true; |
820 | 820 | } |
821 | 821 | |
822 | 822 | // select2 placeholder |
823 | - if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) { |
|
824 | - $args['data-placeholder'] = esc_attr( $args['placeholder'] ); |
|
825 | - $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true; |
|
823 | + if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) { |
|
824 | + $args['data-placeholder'] = esc_attr($args['placeholder']); |
|
825 | + $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true; |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | // Set hidden input to save empty value for multiselect. |
829 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) { |
|
830 | - $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>'; |
|
829 | + if (!empty($args['multiple']) && !empty($args['name'])) { |
|
830 | + $output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value="" data-ignore-rule/>'; |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | // open/type |
834 | 834 | $output .= '<select '; |
835 | 835 | |
836 | 836 | // style |
837 | - if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
837 | + if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) { |
|
838 | 838 | $output .= " style='width:100%;' "; |
839 | 839 | } |
840 | 840 | |
841 | 841 | // element require |
842 | - if ( ! empty( $args['element_require'] ) ) { |
|
843 | - $output .= AUI_Component_Helper::element_require( $args['element_require'] ); |
|
842 | + if (!empty($args['element_require'])) { |
|
843 | + $output .= AUI_Component_Helper::element_require($args['element_require']); |
|
844 | 844 | $args['class'] .= " aui-conditional-field"; |
845 | 845 | } |
846 | 846 | |
847 | 847 | // class |
848 | - $class = ! empty( $args['class'] ) ? $args['class'] : ''; |
|
849 | - $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class ); |
|
848 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
849 | + $output .= AUI_Component_Helper::class_attr('custom-select ' . $class); |
|
850 | 850 | |
851 | 851 | // name |
852 | - if ( ! empty( $args['name'] ) ) { |
|
853 | - $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] ); |
|
852 | + if (!empty($args['name'])) { |
|
853 | + $output .= AUI_Component_Helper::name($args['name'], $args['multiple']); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | // id |
857 | - if ( ! empty( $args['id'] ) ) { |
|
858 | - $output .= AUI_Component_Helper::id( $args['id'] ); |
|
857 | + if (!empty($args['id'])) { |
|
858 | + $output .= AUI_Component_Helper::id($args['id']); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | // title |
862 | - if ( ! empty( $args['title'] ) ) { |
|
863 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
862 | + if (!empty($args['title'])) { |
|
863 | + $output .= AUI_Component_Helper::title($args['title']); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | // data-attributes |
867 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
867 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
868 | 868 | |
869 | 869 | // aria-attributes |
870 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
870 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
871 | 871 | |
872 | 872 | // extra attributes |
873 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
874 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
873 | + if (!empty($args['extra_attributes'])) { |
|
874 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | // required |
878 | - if ( ! empty( $args['required'] ) ) { |
|
878 | + if (!empty($args['required'])) { |
|
879 | 879 | $output .= ' required '; |
880 | 880 | } |
881 | 881 | |
882 | 882 | // multiple |
883 | - if ( ! empty( $args['multiple'] ) ) { |
|
883 | + if (!empty($args['multiple'])) { |
|
884 | 884 | $output .= ' multiple '; |
885 | 885 | } |
886 | 886 | |
@@ -888,50 +888,50 @@ discard block |
||
888 | 888 | $output .= ' >'; |
889 | 889 | |
890 | 890 | // placeholder |
891 | - if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) { |
|
892 | - $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>'; |
|
893 | - } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) { |
|
891 | + if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) { |
|
892 | + $output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>'; |
|
893 | + } elseif ($is_select2 && !empty($args['placeholder'])) { |
|
894 | 894 | $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder |
895 | 895 | } |
896 | 896 | |
897 | 897 | // Options |
898 | - if ( ! empty( $args['options'] ) ) { |
|
898 | + if (!empty($args['options'])) { |
|
899 | 899 | |
900 | - if ( ! is_array( $args['options'] ) ) { |
|
900 | + if (!is_array($args['options'])) { |
|
901 | 901 | $output .= $args['options']; // not the preferred way but an option |
902 | 902 | } else { |
903 | - foreach ( $args['options'] as $val => $name ) { |
|
903 | + foreach ($args['options'] as $val => $name) { |
|
904 | 904 | $selected = ''; |
905 | - if ( is_array( $name ) ) { |
|
906 | - if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) { |
|
907 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
905 | + if (is_array($name)) { |
|
906 | + if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) { |
|
907 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
908 | 908 | |
909 | - $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>'; |
|
909 | + $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
910 | 910 | } else { |
911 | - $option_label = isset( $name['label'] ) ? $name['label'] : ''; |
|
912 | - $option_value = isset( $name['value'] ) ? $name['value'] : ''; |
|
913 | - $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : ''; |
|
914 | - if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) { |
|
915 | - $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : ""; |
|
916 | - } elseif ( ! empty( $args['value'] ) ) { |
|
917 | - $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false ); |
|
918 | - } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) { |
|
919 | - $selected = selected( $option_value, $args['value'], false ); |
|
911 | + $option_label = isset($name['label']) ? $name['label'] : ''; |
|
912 | + $option_value = isset($name['value']) ? $name['value'] : ''; |
|
913 | + $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : ''; |
|
914 | + if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) { |
|
915 | + $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : ""; |
|
916 | + } elseif (!empty($args['value'])) { |
|
917 | + $selected = selected($option_value, stripslashes_deep($args['value']), false); |
|
918 | + } elseif (empty($args['value']) && $args['value'] === $option_value) { |
|
919 | + $selected = selected($option_value, $args['value'], false); |
|
920 | 920 | } |
921 | 921 | |
922 | - $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>'; |
|
922 | + $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>'; |
|
923 | 923 | } |
924 | 924 | } else { |
925 | - if ( ! empty( $args['value'] ) ) { |
|
926 | - if ( is_array( $args['value'] ) ) { |
|
927 | - $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : ''; |
|
928 | - } elseif ( ! empty( $args['value'] ) ) { |
|
929 | - $selected = selected( $args['value'], $val, false ); |
|
925 | + if (!empty($args['value'])) { |
|
926 | + if (is_array($args['value'])) { |
|
927 | + $selected = in_array($val, $args['value']) ? 'selected="selected"' : ''; |
|
928 | + } elseif (!empty($args['value'])) { |
|
929 | + $selected = selected($args['value'], $val, false); |
|
930 | 930 | } |
931 | - } elseif ( $args['value'] === $val ) { |
|
932 | - $selected = selected( $args['value'], $val, false ); |
|
931 | + } elseif ($args['value'] === $val) { |
|
932 | + $selected = selected($args['value'], $val, false); |
|
933 | 933 | } |
934 | - $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>'; |
|
934 | + $output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>'; |
|
935 | 935 | } |
936 | 936 | } |
937 | 937 | } |
@@ -944,8 +944,8 @@ discard block |
||
944 | 944 | $label = ''; |
945 | 945 | $help_text = ''; |
946 | 946 | // label |
947 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
948 | - } elseif ( ! empty( $args['label'] ) && ! $label_after ) { |
|
947 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
948 | + } elseif (!empty($args['label']) && !$label_after) { |
|
949 | 949 | $label_args = array( |
950 | 950 | 'title' => $args['label'], |
951 | 951 | 'for' => $args['id'], |
@@ -953,49 +953,49 @@ discard block |
||
953 | 953 | 'label_type' => $args['label_type'], |
954 | 954 | 'label_col' => $args['label_col'] |
955 | 955 | ); |
956 | - $label = self::label( $label_args ); |
|
956 | + $label = self::label($label_args); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | // help text |
960 | - if ( ! empty( $args['help_text'] ) ) { |
|
961 | - $help_text = AUI_Component_Helper::help_text( $args['help_text'] ); |
|
960 | + if (!empty($args['help_text'])) { |
|
961 | + $help_text = AUI_Component_Helper::help_text($args['help_text']); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | // input group wraps |
965 | - if ( $args['input_group_left'] || $args['input_group_right'] ) { |
|
966 | - $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : ''; |
|
967 | - if ( $args['input_group_left'] ) { |
|
968 | - $output = self::wrap( array( |
|
965 | + if ($args['input_group_left'] || $args['input_group_right']) { |
|
966 | + $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : ''; |
|
967 | + if ($args['input_group_left']) { |
|
968 | + $output = self::wrap(array( |
|
969 | 969 | 'content' => $output, |
970 | 970 | 'class' => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
971 | 971 | 'input_group_left' => $args['input_group_left'], |
972 | 972 | 'input_group_left_inside' => $args['input_group_left_inside'] |
973 | - ) ); |
|
973 | + )); |
|
974 | 974 | } |
975 | - if ( $args['input_group_right'] ) { |
|
976 | - $output = self::wrap( array( |
|
975 | + if ($args['input_group_right']) { |
|
976 | + $output = self::wrap(array( |
|
977 | 977 | 'content' => $output, |
978 | 978 | 'class' => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group', |
979 | 979 | 'input_group_right' => $args['input_group_right'], |
980 | 980 | 'input_group_right_inside' => $args['input_group_right_inside'] |
981 | - ) ); |
|
981 | + )); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | } |
985 | 985 | |
986 | - if ( ! $label_after ) { |
|
986 | + if (!$label_after) { |
|
987 | 987 | $output .= $help_text; |
988 | 988 | } |
989 | 989 | |
990 | 990 | |
991 | - if ( $args['label_type'] == 'horizontal' ) { |
|
992 | - $output = self::wrap( array( |
|
991 | + if ($args['label_type'] == 'horizontal') { |
|
992 | + $output = self::wrap(array( |
|
993 | 993 | 'content' => $output, |
994 | - 'class' => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ) |
|
995 | - ) ); |
|
994 | + 'class' => AUI_Component_Helper::get_column_class($args['label_col'], 'input') |
|
995 | + )); |
|
996 | 996 | } |
997 | 997 | |
998 | - if ( ! $label_after ) { |
|
998 | + if (!$label_after) { |
|
999 | 999 | $output = $label . $output; |
1000 | 1000 | } |
1001 | 1001 | |
@@ -1006,16 +1006,16 @@ discard block |
||
1006 | 1006 | |
1007 | 1007 | |
1008 | 1008 | // wrap |
1009 | - if ( ! $args['no_wrap'] ) { |
|
1009 | + if (!$args['no_wrap']) { |
|
1010 | 1010 | $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
1011 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1012 | - $output = self::wrap( array( |
|
1011 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1012 | + $output = self::wrap(array( |
|
1013 | 1013 | 'content' => $output, |
1014 | 1014 | 'class' => $wrap_class, |
1015 | 1015 | 'element_require' => $args['element_require'], |
1016 | 1016 | 'argument_id' => $args['id'], |
1017 | 1017 | 'wrap_attributes' => $args['wrap_attributes'], |
1018 | - ) ); |
|
1018 | + )); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | * |
1030 | 1030 | * @return string The rendered component. |
1031 | 1031 | */ |
1032 | - public static function radio( $args = array() ) { |
|
1032 | + public static function radio($args = array()) { |
|
1033 | 1033 | $defaults = array( |
1034 | 1034 | 'class' => '', |
1035 | 1035 | 'wrap_class' => '', |
@@ -1059,10 +1059,10 @@ discard block |
||
1059 | 1059 | /** |
1060 | 1060 | * Parse incoming $args into an array and merge it with $defaults |
1061 | 1061 | */ |
1062 | - $args = wp_parse_args( $args, $defaults ); |
|
1062 | + $args = wp_parse_args($args, $defaults); |
|
1063 | 1063 | |
1064 | 1064 | // for now lets use horizontal for floating |
1065 | - if ( $args['label_type'] == 'floating' ) { |
|
1065 | + if ($args['label_type'] == 'floating') { |
|
1066 | 1066 | $args['label_type'] = 'horizontal'; |
1067 | 1067 | } |
1068 | 1068 | |
@@ -1077,47 +1077,47 @@ discard block |
||
1077 | 1077 | |
1078 | 1078 | |
1079 | 1079 | // label before |
1080 | - if ( ! empty( $args['label'] ) ) { |
|
1081 | - $output .= self::label( $label_args, 'radio' ); |
|
1080 | + if (!empty($args['label'])) { |
|
1081 | + $output .= self::label($label_args, 'radio'); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | // maybe horizontal label |
1085 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1086 | - $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' ); |
|
1085 | + if ($args['label_type'] == 'horizontal') { |
|
1086 | + $input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input'); |
|
1087 | 1087 | $output .= '<div class="' . $input_col . '">'; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - if ( ! empty( $args['options'] ) ) { |
|
1090 | + if (!empty($args['options'])) { |
|
1091 | 1091 | $count = 0; |
1092 | - foreach ( $args['options'] as $value => $label ) { |
|
1092 | + foreach ($args['options'] as $value => $label) { |
|
1093 | 1093 | $option_args = $args; |
1094 | 1094 | $option_args['value'] = $value; |
1095 | 1095 | $option_args['label'] = $label; |
1096 | 1096 | $option_args['checked'] = $value == $args['value'] ? true : false; |
1097 | - $output .= self::radio_option( $option_args, $count ); |
|
1098 | - $count ++; |
|
1097 | + $output .= self::radio_option($option_args, $count); |
|
1098 | + $count++; |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | // help text |
1103 | - $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : ''; |
|
1103 | + $help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : ''; |
|
1104 | 1104 | $output .= $help_text; |
1105 | 1105 | |
1106 | 1106 | // maybe horizontal label |
1107 | - if ( $args['label_type'] == 'horizontal' ) { |
|
1107 | + if ($args['label_type'] == 'horizontal') { |
|
1108 | 1108 | $output .= '</div>'; |
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // wrap |
1112 | 1112 | $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group'; |
1113 | - $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1114 | - $output = self::wrap( array( |
|
1113 | + $wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class; |
|
1114 | + $output = self::wrap(array( |
|
1115 | 1115 | 'content' => $output, |
1116 | 1116 | 'class' => $wrap_class, |
1117 | 1117 | 'element_require' => $args['element_require'], |
1118 | 1118 | 'argument_id' => $args['id'], |
1119 | 1119 | 'wrap_attributes' => $args['wrap_attributes'], |
1120 | - ) ); |
|
1120 | + )); |
|
1121 | 1121 | |
1122 | 1122 | |
1123 | 1123 | return $output; |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | * |
1131 | 1131 | * @return string The rendered component. |
1132 | 1132 | */ |
1133 | - public static function radio_option( $args = array(), $count = '' ) { |
|
1133 | + public static function radio_option($args = array(), $count = '') { |
|
1134 | 1134 | $defaults = array( |
1135 | 1135 | 'class' => '', |
1136 | 1136 | 'id' => '', |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | /** |
1149 | 1149 | * Parse incoming $args into an array and merge it with $defaults |
1150 | 1150 | */ |
1151 | - $args = wp_parse_args( $args, $defaults ); |
|
1151 | + $args = wp_parse_args($args, $defaults); |
|
1152 | 1152 | |
1153 | 1153 | $output = ''; |
1154 | 1154 | |
@@ -1159,43 +1159,43 @@ discard block |
||
1159 | 1159 | $output .= ' class="form-check-input" '; |
1160 | 1160 | |
1161 | 1161 | // name |
1162 | - if ( ! empty( $args['name'] ) ) { |
|
1163 | - $output .= AUI_Component_Helper::name( $args['name'] ); |
|
1162 | + if (!empty($args['name'])) { |
|
1163 | + $output .= AUI_Component_Helper::name($args['name']); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | // id |
1167 | - if ( ! empty( $args['id'] ) ) { |
|
1168 | - $output .= AUI_Component_Helper::id( $args['id'] . $count ); |
|
1167 | + if (!empty($args['id'])) { |
|
1168 | + $output .= AUI_Component_Helper::id($args['id'] . $count); |
|
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | // title |
1172 | - if ( ! empty( $args['title'] ) ) { |
|
1173 | - $output .= AUI_Component_Helper::title( $args['title'] ); |
|
1172 | + if (!empty($args['title'])) { |
|
1173 | + $output .= AUI_Component_Helper::title($args['title']); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | // value |
1177 | - if ( isset( $args['value'] ) ) { |
|
1178 | - $output .= AUI_Component_Helper::value( $args['value'] ); |
|
1177 | + if (isset($args['value'])) { |
|
1178 | + $output .= AUI_Component_Helper::value($args['value']); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | // checked, for radio and checkboxes |
1182 | - if ( $args['checked'] ) { |
|
1182 | + if ($args['checked']) { |
|
1183 | 1183 | $output .= ' checked '; |
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | // data-attributes |
1187 | - $output .= AUI_Component_Helper::data_attributes( $args ); |
|
1187 | + $output .= AUI_Component_Helper::data_attributes($args); |
|
1188 | 1188 | |
1189 | 1189 | // aria-attributes |
1190 | - $output .= AUI_Component_Helper::aria_attributes( $args ); |
|
1190 | + $output .= AUI_Component_Helper::aria_attributes($args); |
|
1191 | 1191 | |
1192 | 1192 | // extra attributes |
1193 | - if ( ! empty( $args['extra_attributes'] ) ) { |
|
1194 | - $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] ); |
|
1193 | + if (!empty($args['extra_attributes'])) { |
|
1194 | + $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | // required |
1198 | - if ( ! empty( $args['required'] ) ) { |
|
1198 | + if (!empty($args['required'])) { |
|
1199 | 1199 | $output .= ' required '; |
1200 | 1200 | } |
1201 | 1201 | |
@@ -1203,38 +1203,38 @@ discard block |
||
1203 | 1203 | $output .= ' >'; |
1204 | 1204 | |
1205 | 1205 | // label |
1206 | - if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) { |
|
1207 | - } elseif ( ! empty( $args['label'] ) ) { |
|
1208 | - $output .= self::label( array( |
|
1206 | + if (!empty($args['label']) && is_array($args['label'])) { |
|
1207 | + } elseif (!empty($args['label'])) { |
|
1208 | + $output .= self::label(array( |
|
1209 | 1209 | 'title' => $args['label'], |
1210 | 1210 | 'for' => $args['id'] . $count, |
1211 | 1211 | 'class' => 'form-check-label' |
1212 | - ), 'radio' ); |
|
1212 | + ), 'radio'); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | // wrap |
1216 | - if ( ! $args['no_wrap'] ) { |
|
1216 | + if (!$args['no_wrap']) { |
|
1217 | 1217 | $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check'; |
1218 | 1218 | |
1219 | 1219 | // Unique wrap class |
1220 | 1220 | $uniq_class = 'fwrap'; |
1221 | - if ( ! empty( $args['name'] ) ) { |
|
1221 | + if (!empty($args['name'])) { |
|
1222 | 1222 | $uniq_class .= '-' . $args['name']; |
1223 | - } else if ( ! empty( $args['id'] ) ) { |
|
1223 | + } else if (!empty($args['id'])) { |
|
1224 | 1224 | $uniq_class .= '-' . $args['id']; |
1225 | 1225 | } |
1226 | 1226 | |
1227 | - if ( isset( $args['value'] ) || $args['value'] !== "" ) { |
|
1227 | + if (isset($args['value']) || $args['value'] !== "") { |
|
1228 | 1228 | $uniq_class .= '-' . $args['value']; |
1229 | 1229 | } else { |
1230 | 1230 | $uniq_class .= '-' . $count; |
1231 | 1231 | } |
1232 | - $wrap_class .= ' ' . sanitize_html_class( $uniq_class ); |
|
1232 | + $wrap_class .= ' ' . sanitize_html_class($uniq_class); |
|
1233 | 1233 | |
1234 | - $output = self::wrap( array( |
|
1234 | + $output = self::wrap(array( |
|
1235 | 1235 | 'content' => $output, |
1236 | 1236 | 'class' => $wrap_class |
1237 | - ) ); |
|
1237 | + )); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | return $output; |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,58 +170,58 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) { |
|
182 | + if (isset($name)) { |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | } |
185 | 185 | $templates[] = $slug . '.php'; |
186 | 186 | |
187 | 187 | // Allow template parts to be filtered |
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
189 | 189 | |
190 | 190 | // Return the part that is found |
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | + return wpinv_locate_tmpl($templates, $load, false); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
194 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
195 | 195 | // No file found yet |
196 | 196 | $located = false; |
197 | 197 | |
198 | 198 | // Try to find a template file |
199 | - foreach ( (array)$template_names as $template_name ) { |
|
199 | + foreach ((array) $template_names as $template_name) { |
|
200 | 200 | |
201 | 201 | // Continue if template is empty |
202 | - if ( empty( $template_name ) ) { |
|
202 | + if (empty($template_name)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Trim off any slashes from the template name |
207 | - $template_name = ltrim( $template_name, '/' ); |
|
207 | + $template_name = ltrim($template_name, '/'); |
|
208 | 208 | |
209 | 209 | // try locating this template file by looping through the template paths |
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
210 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
212 | + if (file_exists($template_path . $template_name)) { |
|
213 | 213 | $located = $template_path . $template_name; |
214 | 214 | break; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
218 | + if (!empty($located)) { |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ((true == $load) && !empty($located)) { |
|
224 | + load_template($located, $require_once); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $located; |
@@ -231,73 +231,73 @@ discard block |
||
231 | 231 | $template_dir = wpinv_get_theme_template_dir_name(); |
232 | 232 | |
233 | 233 | $file_paths = array( |
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
234 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
235 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
236 | 236 | 100 => wpinv_get_templates_dir(), |
237 | 237 | ); |
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
240 | 240 | |
241 | 241 | // sort the file paths based on priority |
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
242 | + ksort($file_paths, SORT_NUMERIC); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map('trailingslashit', $file_paths); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | 249 | $pages = array(); |
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
250 | + $pages[] = wpinv_get_option('success_page'); |
|
251 | + $pages[] = wpinv_get_option('failure_page'); |
|
252 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
253 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
255 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
260 | 260 | } |
261 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
261 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
262 | 262 | |
263 | -function wpinv_add_body_classes( $class ) { |
|
264 | - $classes = (array)$class; |
|
263 | +function wpinv_add_body_classes($class) { |
|
264 | + $classes = (array) $class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
266 | + if (wpinv_is_checkout()) { |
|
267 | 267 | $classes[] = 'wpinv-checkout'; |
268 | 268 | $classes[] = 'wpinv-page'; |
269 | 269 | } |
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
271 | + if (wpinv_is_success_page()) { |
|
272 | 272 | $classes[] = 'wpinv-success'; |
273 | 273 | $classes[] = 'wpinv-page'; |
274 | 274 | } |
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
276 | + if (wpinv_is_failed_transaction_page()) { |
|
277 | 277 | $classes[] = 'wpinv-failed-transaction'; |
278 | 278 | $classes[] = 'wpinv-page'; |
279 | 279 | } |
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
281 | + if (wpinv_is_invoice_history_page()) { |
|
282 | 282 | $classes[] = 'wpinv-history'; |
283 | 283 | $classes[] = 'wpinv-page'; |
284 | 284 | } |
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
286 | + if (wpinv_is_subscriptions_history_page()) { |
|
287 | 287 | $classes[] = 'wpinv-subscription'; |
288 | 288 | $classes[] = 'wpinv-page'; |
289 | 289 | } |
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
291 | + if (wpinv_is_test_mode()) { |
|
292 | 292 | $classes[] = 'wpinv-test-mode'; |
293 | 293 | $classes[] = 'wpinv-page'; |
294 | 294 | } |
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique($classes); |
|
297 | 297 | } |
298 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
298 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
299 | 299 | |
300 | -function wpinv_html_select( $args = array() ) { |
|
300 | +function wpinv_html_select($args = array()) { |
|
301 | 301 | $defaults = array( |
302 | 302 | 'options' => array(), |
303 | 303 | 'name' => null, |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | 'selected' => 0, |
307 | 307 | 'placeholder' => null, |
308 | 308 | 'multiple' => false, |
309 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
310 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
309 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
310 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
311 | 311 | 'data' => array(), |
312 | 312 | 'onchange' => null, |
313 | 313 | 'required' => false, |
@@ -315,79 +315,79 @@ discard block |
||
315 | 315 | 'readonly' => false, |
316 | 316 | ); |
317 | 317 | |
318 | - $args = wp_parse_args( $args, $defaults ); |
|
318 | + $args = wp_parse_args($args, $defaults); |
|
319 | 319 | |
320 | 320 | $attrs = array( |
321 | 321 | 'name' => $args['name'], |
322 | 322 | 'id' => $args['id'], |
323 | - 'class' => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ), |
|
324 | - 'multiple' => ! empty( $args['multiple'] ), |
|
325 | - 'readonly' => ! empty( $args['readonly'] ), |
|
326 | - 'disabled' => ! empty( $args['disabled'] ), |
|
327 | - 'required' => ! empty( $args['required'] ), |
|
328 | - 'onchange' => ! empty( $args['onchange'] ), |
|
323 | + 'class' => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))), |
|
324 | + 'multiple' => !empty($args['multiple']), |
|
325 | + 'readonly' => !empty($args['readonly']), |
|
326 | + 'disabled' => !empty($args['disabled']), |
|
327 | + 'required' => !empty($args['required']), |
|
328 | + 'onchange' => !empty($args['onchange']), |
|
329 | 329 | ); |
330 | 330 | |
331 | - if ( $args['placeholder'] ) { |
|
331 | + if ($args['placeholder']) { |
|
332 | 332 | $attrs['data-placeholder'] = $args['placeholder']; |
333 | 333 | } |
334 | 334 | |
335 | - if ( $args['onchange'] ) { |
|
335 | + if ($args['onchange']) { |
|
336 | 336 | $attrs['onchange'] = $args['onchange']; |
337 | 337 | } |
338 | 338 | |
339 | - foreach ( $args['data'] as $key => $value ) { |
|
339 | + foreach ($args['data'] as $key => $value) { |
|
340 | 340 | $attrs["data-$key"] = $value; |
341 | 341 | } |
342 | 342 | |
343 | 343 | echo '<select '; |
344 | 344 | |
345 | - foreach ( $attrs as $attr => $value ) { |
|
345 | + foreach ($attrs as $attr => $value) { |
|
346 | 346 | |
347 | - if ( false === $value ) { |
|
347 | + if (false === $value) { |
|
348 | 348 | continue; |
349 | 349 | } |
350 | 350 | |
351 | - if ( true === $value ) { |
|
352 | - echo ' ' . esc_attr( $attr ); |
|
351 | + if (true === $value) { |
|
352 | + echo ' ' . esc_attr($attr); |
|
353 | 353 | } else { |
354 | - echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; |
|
354 | + echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"'; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | } |
358 | 358 | |
359 | 359 | echo '>'; |
360 | 360 | |
361 | - if ( $args['show_option_all'] ) { |
|
362 | - if ( $args['multiple'] ) { |
|
363 | - $selected = in_array( 0, $args['selected'] ); |
|
361 | + if ($args['show_option_all']) { |
|
362 | + if ($args['multiple']) { |
|
363 | + $selected = in_array(0, $args['selected']); |
|
364 | 364 | } else { |
365 | - $selected = empty( $args['selected'] ); |
|
365 | + $selected = empty($args['selected']); |
|
366 | 366 | } |
367 | - echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
367 | + echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $args['options'] ) ) { |
|
370 | + if (!empty($args['options'])) { |
|
371 | 371 | |
372 | - if ( $args['show_option_none'] ) { |
|
373 | - if ( $args['multiple'] ) { |
|
374 | - $selected = in_array( '', $args['selected'], true ); |
|
372 | + if ($args['show_option_none']) { |
|
373 | + if ($args['multiple']) { |
|
374 | + $selected = in_array('', $args['selected'], true); |
|
375 | 375 | } else { |
376 | 376 | $selected = $args['selected'] === ''; |
377 | 377 | } |
378 | 378 | |
379 | - echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
379 | + echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
380 | 380 | } |
381 | 381 | |
382 | - foreach ( $args['options'] as $key => $option ) { |
|
382 | + foreach ($args['options'] as $key => $option) { |
|
383 | 383 | |
384 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
385 | - $selected = in_array( $key, $args['selected'], true ); |
|
384 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
385 | + $selected = in_array($key, $args['selected'], true); |
|
386 | 386 | } else { |
387 | 387 | $selected = $args['selected'] === $key; |
388 | 388 | } |
389 | 389 | |
390 | - echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>'; |
|
390 | + echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>'; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | |
396 | 396 | } |
397 | 397 | |
398 | -function wpinv_item_dropdown( $args = array() ) { |
|
398 | +function wpinv_item_dropdown($args = array()) { |
|
399 | 399 | $defaults = array( |
400 | 400 | 'name' => 'wpi_item', |
401 | 401 | 'id' => 'wpi_item', |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | 'multiple' => false, |
404 | 404 | 'selected' => 0, |
405 | 405 | 'number' => -1, |
406 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
407 | - 'data' => array( 'search-type' => 'item' ), |
|
406 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
407 | + 'data' => array('search-type' => 'item'), |
|
408 | 408 | 'show_option_all' => false, |
409 | 409 | 'show_option_none' => false, |
410 | 410 | 'show_recurring' => false, |
411 | 411 | ); |
412 | 412 | |
413 | - $args = wp_parse_args( $args, $defaults ); |
|
413 | + $args = wp_parse_args($args, $defaults); |
|
414 | 414 | |
415 | 415 | $item_args = array( |
416 | 416 | 'post_type' => 'wpi_item', |
@@ -419,40 +419,40 @@ discard block |
||
419 | 419 | 'posts_per_page' => $args['number'], |
420 | 420 | ); |
421 | 421 | |
422 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
422 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
423 | 423 | |
424 | - $items = get_posts( $item_args ); |
|
424 | + $items = get_posts($item_args); |
|
425 | 425 | $options = array(); |
426 | - if ( $items ) { |
|
427 | - foreach ( $items as $item ) { |
|
428 | - $title = esc_html( $item->post_title ); |
|
426 | + if ($items) { |
|
427 | + foreach ($items as $item) { |
|
428 | + $title = esc_html($item->post_title); |
|
429 | 429 | |
430 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
431 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
430 | + if (!empty($args['show_recurring'])) { |
|
431 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
432 | 432 | } |
433 | 433 | |
434 | - $options[ absint( $item->ID ) ] = $title; |
|
434 | + $options[absint($item->ID)] = $title; |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | // This ensures that any selected items are included in the drop down |
439 | - if ( is_array( $args['selected'] ) ) { |
|
440 | - foreach ( $args['selected'] as $item ) { |
|
441 | - if ( ! in_array( $item, $options ) ) { |
|
442 | - $title = get_the_title( $item ); |
|
443 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
444 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
439 | + if (is_array($args['selected'])) { |
|
440 | + foreach ($args['selected'] as $item) { |
|
441 | + if (!in_array($item, $options)) { |
|
442 | + $title = get_the_title($item); |
|
443 | + if (!empty($args['show_recurring'])) { |
|
444 | + $title .= wpinv_get_item_suffix($item, false); |
|
445 | 445 | } |
446 | - $options[ $item ] = $title; |
|
446 | + $options[$item] = $title; |
|
447 | 447 | } |
448 | 448 | } |
449 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
450 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
451 | - $title = get_the_title( $args['selected'] ); |
|
452 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
453 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
449 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
450 | + if (!in_array($args['selected'], $options)) { |
|
451 | + $title = get_the_title($args['selected']); |
|
452 | + if (!empty($args['show_recurring'])) { |
|
453 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
454 | 454 | } |
455 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
455 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -488,16 +488,16 @@ discard block |
||
488 | 488 | ); |
489 | 489 | |
490 | 490 | $options = array(); |
491 | - if ( $items ) { |
|
492 | - foreach ( $items as $item ) { |
|
493 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
491 | + if ($items) { |
|
492 | + foreach ($items as $item) { |
|
493 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | return $options; |
498 | 498 | } |
499 | 499 | |
500 | -function wpinv_html_checkbox( $args = array() ) { |
|
500 | +function wpinv_html_checkbox($args = array()) { |
|
501 | 501 | $defaults = array( |
502 | 502 | 'name' => null, |
503 | 503 | 'current' => null, |
@@ -508,17 +508,17 @@ discard block |
||
508 | 508 | ), |
509 | 509 | ); |
510 | 510 | |
511 | - $args = wp_parse_args( $args, $defaults ); |
|
511 | + $args = wp_parse_args($args, $defaults); |
|
512 | 512 | |
513 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
513 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
514 | 514 | $attr = ''; |
515 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
515 | + if (!empty($args['options']['disabled'])) { |
|
516 | 516 | $attr .= ' disabled="disabled"'; |
517 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
517 | + } elseif (!empty($args['options']['readonly'])) { |
|
518 | 518 | $attr .= ' readonly'; |
519 | 519 | } |
520 | 520 | |
521 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
521 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
522 | 522 | |
523 | 523 | return $output; |
524 | 524 | } |
@@ -526,34 +526,34 @@ discard block |
||
526 | 526 | /** |
527 | 527 | * Displays a hidden field. |
528 | 528 | */ |
529 | -function getpaid_hidden_field( $name, $value ) { |
|
530 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
529 | +function getpaid_hidden_field($name, $value) { |
|
530 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Displays a submit field. |
535 | 535 | */ |
536 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
537 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
536 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
537 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
538 | 538 | } |
539 | 539 | |
540 | -function wpinv_html_text( $args = array() ) { |
|
540 | +function wpinv_html_text($args = array()) { |
|
541 | 541 | // Backwards compatibility |
542 | - if ( func_num_args() > 1 ) { |
|
542 | + if (func_num_args() > 1) { |
|
543 | 543 | $args = func_get_args(); |
544 | 544 | |
545 | 545 | $name = $args[0]; |
546 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
547 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
548 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
546 | + $value = isset($args[1]) ? $args[1] : ''; |
|
547 | + $label = isset($args[2]) ? $args[2] : ''; |
|
548 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | $defaults = array( |
552 | 552 | 'id' => '', |
553 | - 'name' => isset( $name ) ? $name : 'text', |
|
554 | - 'value' => isset( $value ) ? $value : null, |
|
555 | - 'label' => isset( $label ) ? $label : null, |
|
556 | - 'desc' => isset( $desc ) ? $desc : null, |
|
553 | + 'name' => isset($name) ? $name : 'text', |
|
554 | + 'value' => isset($value) ? $value : null, |
|
555 | + 'label' => isset($label) ? $label : null, |
|
556 | + 'desc' => isset($desc) ? $desc : null, |
|
557 | 557 | 'placeholder' => '', |
558 | 558 | 'class' => 'regular-text', |
559 | 559 | 'disabled' => false, |
@@ -563,41 +563,41 @@ discard block |
||
563 | 563 | 'data' => false, |
564 | 564 | ); |
565 | 565 | |
566 | - $args = wp_parse_args( $args, $defaults ); |
|
566 | + $args = wp_parse_args($args, $defaults); |
|
567 | 567 | |
568 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
568 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
569 | 569 | $options = ''; |
570 | - if ( $args['required'] ) { |
|
570 | + if ($args['required']) { |
|
571 | 571 | $options .= ' required="required"'; |
572 | 572 | } |
573 | - if ( $args['readonly'] ) { |
|
573 | + if ($args['readonly']) { |
|
574 | 574 | $options .= ' readonly'; |
575 | 575 | } |
576 | - if ( $args['readonly'] ) { |
|
576 | + if ($args['readonly']) { |
|
577 | 577 | $options .= ' readonly'; |
578 | 578 | } |
579 | 579 | |
580 | 580 | $data = ''; |
581 | - if ( ! empty( $args['data'] ) ) { |
|
582 | - foreach ( $args['data'] as $key => $value ) { |
|
583 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
581 | + if (!empty($args['data'])) { |
|
582 | + foreach ($args['data'] as $key => $value) { |
|
583 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
588 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
589 | - if ( ! empty( $args['desc'] ) ) { |
|
590 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
587 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
588 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
589 | + if (!empty($args['desc'])) { |
|
590 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
591 | 591 | } |
592 | 592 | |
593 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
593 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
594 | 594 | |
595 | 595 | $output .= '</span>'; |
596 | 596 | |
597 | 597 | return $output; |
598 | 598 | } |
599 | 599 | |
600 | -function wpinv_html_textarea( $args = array() ) { |
|
600 | +function wpinv_html_textarea($args = array()) { |
|
601 | 601 | $defaults = array( |
602 | 602 | 'name' => 'textarea', |
603 | 603 | 'value' => null, |
@@ -608,31 +608,31 @@ discard block |
||
608 | 608 | 'placeholder' => '', |
609 | 609 | ); |
610 | 610 | |
611 | - $args = wp_parse_args( $args, $defaults ); |
|
611 | + $args = wp_parse_args($args, $defaults); |
|
612 | 612 | |
613 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
613 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
614 | 614 | $disabled = ''; |
615 | - if ( $args['disabled'] ) { |
|
615 | + if ($args['disabled']) { |
|
616 | 616 | $disabled = ' disabled="disabled"'; |
617 | 617 | } |
618 | 618 | |
619 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
620 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
621 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
619 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
620 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
621 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
622 | 622 | |
623 | - if ( ! empty( $args['desc'] ) ) { |
|
624 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
623 | + if (!empty($args['desc'])) { |
|
624 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
625 | 625 | } |
626 | 626 | $output .= '</span>'; |
627 | 627 | |
628 | 628 | return $output; |
629 | 629 | } |
630 | 630 | |
631 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
631 | +function wpinv_html_ajax_user_search($args = array()) { |
|
632 | 632 | $defaults = array( |
633 | 633 | 'name' => 'user_id', |
634 | 634 | 'value' => null, |
635 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
635 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
636 | 636 | 'label' => null, |
637 | 637 | 'desc' => null, |
638 | 638 | 'class' => '', |
@@ -641,13 +641,13 @@ discard block |
||
641 | 641 | 'data' => false, |
642 | 642 | ); |
643 | 643 | |
644 | - $args = wp_parse_args( $args, $defaults ); |
|
644 | + $args = wp_parse_args($args, $defaults); |
|
645 | 645 | |
646 | 646 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
647 | 647 | |
648 | 648 | $output = '<span class="wpinv_user_search_wrap">'; |
649 | - $output .= wpinv_html_text( $args ); |
|
650 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
649 | + $output .= wpinv_html_text($args); |
|
650 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
651 | 651 | $output .= '</span>'; |
652 | 652 | |
653 | 653 | return $output; |
@@ -658,44 +658,44 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @param string $template the template that is currently being used. |
660 | 660 | */ |
661 | -function wpinv_template( $template ) { |
|
661 | +function wpinv_template($template) { |
|
662 | 662 | global $post; |
663 | 663 | |
664 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
664 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
665 | 665 | |
666 | 666 | // If the user can view this invoice, display it. |
667 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
667 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
668 | 668 | |
669 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
669 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
670 | 670 | |
671 | 671 | // Else display an error message. |
672 | 672 | } else { |
673 | 673 | |
674 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
674 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
675 | 675 | |
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
679 | 679 | return $template; |
680 | 680 | } |
681 | -add_filter( 'template_include', 'wpinv_template', 1000, 1 ); |
|
681 | +add_filter('template_include', 'wpinv_template', 1000, 1); |
|
682 | 682 | |
683 | 683 | function wpinv_get_business_address() { |
684 | 684 | $business_address = wpinv_store_address(); |
685 | - $business_address = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : ''; |
|
685 | + $business_address = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : ''; |
|
686 | 686 | |
687 | 687 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
688 | 688 | |
689 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
689 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
693 | 693 | * Displays the company address. |
694 | 694 | */ |
695 | 695 | function wpinv_display_from_address() { |
696 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
696 | + wpinv_get_template('invoice/company-address.php'); |
|
697 | 697 | } |
698 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
698 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
699 | 699 | |
700 | 700 | /** |
701 | 701 | * Generates a watermark text for an invoice. |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | * @param WPInv_Invoice $invoice |
704 | 704 | * @return string |
705 | 705 | */ |
706 | -function wpinv_watermark( $invoice ) { |
|
707 | - $watermark = wpinv_get_watermark( $invoice ); |
|
708 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
706 | +function wpinv_watermark($invoice) { |
|
707 | + $watermark = wpinv_get_watermark($invoice); |
|
708 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -714,37 +714,37 @@ discard block |
||
714 | 714 | * @param WPInv_Invoice $invoice |
715 | 715 | * @return string |
716 | 716 | */ |
717 | -function wpinv_get_watermark( $invoice ) { |
|
717 | +function wpinv_get_watermark($invoice) { |
|
718 | 718 | return $invoice->get_status_nicename(); |
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
722 | 722 | * @deprecated |
723 | 723 | */ |
724 | -function wpinv_display_invoice_details( $invoice ) { |
|
725 | - return getpaid_invoice_meta( $invoice ); |
|
724 | +function wpinv_display_invoice_details($invoice) { |
|
725 | + return getpaid_invoice_meta($invoice); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
729 | 729 | * Displays invoice meta. |
730 | 730 | */ |
731 | -function getpaid_invoice_meta( $invoice ) { |
|
731 | +function getpaid_invoice_meta($invoice) { |
|
732 | 732 | |
733 | - $invoice = new WPInv_Invoice( $invoice ); |
|
733 | + $invoice = new WPInv_Invoice($invoice); |
|
734 | 734 | |
735 | 735 | // Ensure that we have an invoice. |
736 | - if ( 0 == $invoice->get_id() ) { |
|
736 | + if (0 == $invoice->get_id()) { |
|
737 | 737 | return; |
738 | 738 | } |
739 | 739 | |
740 | 740 | // Get the invoice meta. |
741 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
741 | + $meta = getpaid_get_invoice_meta($invoice); |
|
742 | 742 | |
743 | 743 | // Display the meta. |
744 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
744 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
745 | 745 | |
746 | 746 | } |
747 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
747 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
748 | 748 | |
749 | 749 | /** |
750 | 750 | * Retrieves the address markup to use on Invoices. |
@@ -756,29 +756,29 @@ discard block |
||
756 | 756 | * @param string $separator How to separate address lines. |
757 | 757 | * @return string |
758 | 758 | */ |
759 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
759 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
760 | 760 | |
761 | 761 | // Retrieve the address markup... |
762 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
763 | - $format = wpinv_get_full_address_format( $country ); |
|
762 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
763 | + $format = wpinv_get_full_address_format($country); |
|
764 | 764 | |
765 | 765 | // ... and the replacements. |
766 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
766 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
767 | 767 | |
768 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
768 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
769 | 769 | |
770 | 770 | // Remove unavailable tags. |
771 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
771 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
772 | 772 | |
773 | 773 | // Clean up white space. |
774 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
775 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
774 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
775 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
776 | 776 | |
777 | 777 | // Break newlines apart and remove empty lines/trim commas and white space. |
778 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
778 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
779 | 779 | |
780 | 780 | // Add html breaks. |
781 | - $formatted_address = implode( $separator, $formatted_address ); |
|
781 | + $formatted_address = implode($separator, $formatted_address); |
|
782 | 782 | |
783 | 783 | // We're done! |
784 | 784 | return $formatted_address; |
@@ -790,118 +790,118 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @param WPInv_Invoice $invoice |
792 | 792 | */ |
793 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
794 | - if ( ! empty( $invoice ) ) { |
|
795 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
793 | +function wpinv_display_to_address($invoice = 0) { |
|
794 | + if (!empty($invoice)) { |
|
795 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
796 | 796 | } |
797 | 797 | } |
798 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
798 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
799 | 799 | |
800 | 800 | |
801 | 801 | /** |
802 | 802 | * Displays invoice line items. |
803 | 803 | */ |
804 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
804 | +function wpinv_display_line_items($invoice_id = 0) { |
|
805 | 805 | |
806 | 806 | // Prepare the invoice. |
807 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
807 | + $invoice = new WPInv_Invoice($invoice_id); |
|
808 | 808 | |
809 | 809 | // Abort if there is no invoice. |
810 | - if ( 0 == $invoice->get_id() ) { |
|
810 | + if (0 == $invoice->get_id()) { |
|
811 | 811 | return; |
812 | 812 | } |
813 | 813 | |
814 | 814 | // Line item columns. |
815 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
816 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
815 | + $columns = getpaid_invoice_item_columns($invoice); |
|
816 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
817 | 817 | |
818 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
818 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
819 | 819 | } |
820 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
820 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
821 | 821 | |
822 | 822 | /** |
823 | 823 | * Displays invoice subscriptions. |
824 | 824 | * |
825 | 825 | * @param WPInv_Invoice $invoice |
826 | 826 | */ |
827 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
827 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
828 | 828 | |
829 | 829 | // Subscriptions. |
830 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
830 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
831 | 831 | |
832 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
832 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
833 | 833 | return; |
834 | 834 | } |
835 | 835 | |
836 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
836 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
837 | 837 | |
838 | 838 | // Display related subscriptions. |
839 | - if ( is_array( $subscriptions ) ) { |
|
840 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
841 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
839 | + if (is_array($subscriptions)) { |
|
840 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
841 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
842 | 842 | } |
843 | 843 | |
844 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
845 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
846 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
844 | + if ($main_subscription->get_total_payments() > 1) { |
|
845 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
846 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | } |
850 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
851 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
850 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
851 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
852 | 852 | |
853 | 853 | /** |
854 | 854 | * Displays invoice notices on invoices. |
855 | 855 | */ |
856 | 856 | function wpinv_display_invoice_notice() { |
857 | 857 | |
858 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
859 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
858 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
859 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
860 | 860 | |
861 | - if ( empty( $label ) && empty( $notice ) ) { |
|
861 | + if (empty($label) && empty($notice)) { |
|
862 | 862 | return; |
863 | 863 | } |
864 | 864 | |
865 | 865 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
866 | 866 | |
867 | - if ( ! empty( $label ) ) { |
|
868 | - echo "<h5>" . esc_html( $label ) . "</h5>"; |
|
867 | + if (!empty($label)) { |
|
868 | + echo "<h5>" . esc_html($label) . "</h5>"; |
|
869 | 869 | } |
870 | 870 | |
871 | - if ( ! empty( $notice ) ) { |
|
872 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>'; |
|
871 | + if (!empty($notice)) { |
|
872 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>'; |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | echo '</div>'; |
876 | 876 | } |
877 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
877 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
878 | 878 | |
879 | 879 | /** |
880 | 880 | * @param WPInv_Invoice $invoice |
881 | 881 | */ |
882 | -function wpinv_display_invoice_notes( $invoice ) { |
|
882 | +function wpinv_display_invoice_notes($invoice) { |
|
883 | 883 | |
884 | 884 | // Retrieve the notes. |
885 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
885 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
886 | 886 | |
887 | 887 | // Abort if we have non. |
888 | - if ( empty( $notes ) ) { |
|
888 | + if (empty($notes)) { |
|
889 | 889 | return; |
890 | 890 | } |
891 | 891 | |
892 | 892 | // Echo the note. |
893 | 893 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
894 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>'; |
|
894 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>'; |
|
895 | 895 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
896 | 896 | |
897 | - foreach ( $notes as $note ) { |
|
898 | - wpinv_get_invoice_note_line_item( $note ); |
|
897 | + foreach ($notes as $note) { |
|
898 | + wpinv_get_invoice_note_line_item($note); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | echo '</ul>'; |
902 | 902 | echo '</div>'; |
903 | 903 | } |
904 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
904 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
905 | 905 | |
906 | 906 | /** |
907 | 907 | * Loads scripts on our invoice templates. |
@@ -909,32 +909,32 @@ discard block |
||
909 | 909 | function wpinv_display_style() { |
910 | 910 | |
911 | 911 | // Make sure that all scripts have been loaded. |
912 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
913 | - do_action( 'wp_enqueue_scripts' ); |
|
912 | + if (!did_action('wp_enqueue_scripts')) { |
|
913 | + do_action('wp_enqueue_scripts'); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | // Register the invoices style. |
917 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
917 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
918 | 918 | |
919 | 919 | // Load required styles |
920 | - wp_print_styles( 'wpinv-single-style' ); |
|
921 | - wp_print_styles( 'ayecode-ui' ); |
|
920 | + wp_print_styles('wpinv-single-style'); |
|
921 | + wp_print_styles('ayecode-ui'); |
|
922 | 922 | |
923 | 923 | // Maybe load custom css. |
924 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
924 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
925 | 925 | |
926 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
927 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
928 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
926 | + if (isset($custom_css) && !empty($custom_css)) { |
|
927 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
928 | + $custom_css = str_replace('>', '>', $custom_css); |
|
929 | 929 | echo '<style type="text/css">'; |
930 | - echo wp_kses_post( $custom_css ); |
|
930 | + echo wp_kses_post($custom_css); |
|
931 | 931 | echo '</style>'; |
932 | 932 | } |
933 | 933 | |
934 | 934 | wp_site_icon(); |
935 | 935 | } |
936 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
937 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
936 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
937 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
938 | 938 | |
939 | 939 | |
940 | 940 | /** |
@@ -946,41 +946,41 @@ discard block |
||
946 | 946 | // Retrieve the current invoice. |
947 | 947 | $invoice_id = getpaid_get_current_invoice_id(); |
948 | 948 | |
949 | - if ( empty( $invoice_id ) ) { |
|
949 | + if (empty($invoice_id)) { |
|
950 | 950 | |
951 | 951 | return aui()->alert( |
952 | 952 | array( |
953 | 953 | 'type' => 'warning', |
954 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
954 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
955 | 955 | ) |
956 | 956 | ); |
957 | 957 | |
958 | 958 | } |
959 | 959 | |
960 | 960 | // Can the user view this invoice? |
961 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
961 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
962 | 962 | |
963 | 963 | return aui()->alert( |
964 | 964 | array( |
965 | 965 | 'type' => 'warning', |
966 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
966 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
967 | 967 | ) |
968 | 968 | ); |
969 | 969 | |
970 | 970 | } |
971 | 971 | |
972 | 972 | // Ensure that it is not yet paid for. |
973 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
973 | + $invoice = new WPInv_Invoice($invoice_id); |
|
974 | 974 | |
975 | 975 | // Maybe mark it as viewed. |
976 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
976 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
977 | 977 | |
978 | - if ( $invoice->is_paid() ) { |
|
978 | + if ($invoice->is_paid()) { |
|
979 | 979 | |
980 | 980 | return aui()->alert( |
981 | 981 | array( |
982 | 982 | 'type' => 'success', |
983 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
983 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
984 | 984 | ) |
985 | 985 | ); |
986 | 986 | |
@@ -990,15 +990,15 @@ discard block |
||
990 | 990 | $wpi_checkout_id = $invoice_id; |
991 | 991 | |
992 | 992 | // Retrieve appropriate payment form. |
993 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
994 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
993 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
994 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
995 | 995 | |
996 | - if ( ! $payment_form->exists() ) { |
|
996 | + if (!$payment_form->exists()) { |
|
997 | 997 | |
998 | 998 | return aui()->alert( |
999 | 999 | array( |
1000 | 1000 | 'type' => 'warning', |
1001 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1001 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1002 | 1002 | ) |
1003 | 1003 | ); |
1004 | 1004 | |
@@ -1007,29 +1007,29 @@ discard block |
||
1007 | 1007 | // Set the invoice. |
1008 | 1008 | $payment_form->invoice = $invoice; |
1009 | 1009 | |
1010 | - if ( ! $payment_form->is_default() ) { |
|
1010 | + if (!$payment_form->is_default()) { |
|
1011 | 1011 | |
1012 | 1012 | $items = array(); |
1013 | 1013 | $item_ids = array(); |
1014 | 1014 | |
1015 | - foreach ( $invoice->get_items() as $item ) { |
|
1016 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1015 | + foreach ($invoice->get_items() as $item) { |
|
1016 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1017 | 1017 | $item_ids[] = $item->get_id(); |
1018 | 1018 | $items[] = $item; |
1019 | 1019 | } |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - foreach ( $payment_form->get_items() as $item ) { |
|
1023 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1022 | + foreach ($payment_form->get_items() as $item) { |
|
1023 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1024 | 1024 | $item_ids[] = $item->get_id(); |
1025 | 1025 | $items[] = $item; |
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - $payment_form->set_items( $items ); |
|
1029 | + $payment_form->set_items($items); |
|
1030 | 1030 | |
1031 | 1031 | } else { |
1032 | - $payment_form->set_items( $invoice->get_items() ); |
|
1032 | + $payment_form->set_items($invoice->get_items()); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | // Generate the html. |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | function wpinv_empty_cart_message() { |
1041 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1041 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
@@ -1056,76 +1056,76 @@ discard block |
||
1056 | 1056 | true |
1057 | 1057 | ); |
1058 | 1058 | } |
1059 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1059 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1060 | 1060 | |
1061 | 1061 | /** |
1062 | 1062 | * Filters the receipt page. |
1063 | 1063 | */ |
1064 | -function wpinv_filter_success_page_content( $content ) { |
|
1064 | +function wpinv_filter_success_page_content($content) { |
|
1065 | 1065 | |
1066 | 1066 | // Maybe abort early. |
1067 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1067 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1068 | 1068 | return $content; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | // Ensure this is our page. |
1072 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1072 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1073 | 1073 | |
1074 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1075 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1074 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1075 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1076 | 1076 | |
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | return $content; |
1080 | 1080 | } |
1081 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1081 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1082 | 1082 | |
1083 | -function wpinv_invoice_link( $invoice_id ) { |
|
1084 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1083 | +function wpinv_invoice_link($invoice_id) { |
|
1084 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1085 | 1085 | |
1086 | - if ( empty( $invoice ) ) { |
|
1086 | + if (empty($invoice)) { |
|
1087 | 1087 | return null; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1090 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1091 | 1091 | |
1092 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1092 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1096 | - if ( empty( $note ) ) { |
|
1095 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1096 | + if (empty($note)) { |
|
1097 | 1097 | return null; |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - if ( is_int( $note ) ) { |
|
1101 | - $note = get_comment( $note ); |
|
1100 | + if (is_int($note)) { |
|
1101 | + $note = get_comment($note); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1104 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1105 | 1105 | return null; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | - $note_classes = array( 'note' ); |
|
1109 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1108 | + $note_classes = array('note'); |
|
1109 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1110 | 1110 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1111 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1112 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1111 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1112 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1113 | 1113 | |
1114 | 1114 | ob_start(); |
1115 | 1115 | ?> |
1116 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1116 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1117 | 1117 | <div class="note_content"> |
1118 | 1118 | |
1119 | - <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?> |
|
1119 | + <?php echo wp_kses_post(wptexturize($note->comment_content)); ?> |
|
1120 | 1120 | |
1121 | - <?php if ( ! is_admin() ) : ?> |
|
1121 | + <?php if (!is_admin()) : ?> |
|
1122 | 1122 | <em class="small form-text text-muted mt-0"> |
1123 | 1123 | <?php |
1124 | 1124 | printf( |
1125 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1126 | - esc_html( $note->comment_author ), |
|
1127 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1128 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1125 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1126 | + esc_html($note->comment_author), |
|
1127 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1128 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1129 | 1129 | ); |
1130 | 1130 | ?> |
1131 | 1131 | </em> |
@@ -1133,21 +1133,21 @@ discard block |
||
1133 | 1133 | |
1134 | 1134 | </div> |
1135 | 1135 | |
1136 | - <?php if ( is_admin() ) : ?> |
|
1136 | + <?php if (is_admin()) : ?> |
|
1137 | 1137 | |
1138 | 1138 | <p class="meta px-4 py-2"> |
1139 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1139 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1140 | 1140 | <?php |
1141 | 1141 | printf( |
1142 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1143 | - esc_html( $note->comment_author ), |
|
1144 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1145 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1142 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1143 | + esc_html($note->comment_author), |
|
1144 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1145 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1146 | 1146 | ); |
1147 | 1147 | ?> |
1148 | 1148 | </abbr> |
1149 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1150 | - <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
1149 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1150 | + <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
1151 | 1151 | <?php } ?> |
1152 | 1152 | </p> |
1153 | 1153 | |
@@ -1156,10 +1156,10 @@ discard block |
||
1156 | 1156 | </li> |
1157 | 1157 | <?php |
1158 | 1158 | $note_content = ob_get_clean(); |
1159 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1159 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1160 | 1160 | |
1161 | - if ( $echo ) { |
|
1162 | - echo wp_kses_post( $note_content ); |
|
1161 | + if ($echo) { |
|
1162 | + echo wp_kses_post($note_content); |
|
1163 | 1163 | } else { |
1164 | 1164 | return $note_content; |
1165 | 1165 | } |
@@ -1172,43 +1172,43 @@ discard block |
||
1172 | 1172 | * @return string |
1173 | 1173 | */ |
1174 | 1174 | function wpinv_get_policy_text() { |
1175 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1175 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1176 | 1176 | |
1177 | - $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) ); |
|
1177 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1178 | 1178 | |
1179 | - if ( ! $privacy_page_id ) { |
|
1180 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1179 | + if (!$privacy_page_id) { |
|
1180 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1183 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1184 | 1184 | |
1185 | 1185 | $find_replace = array( |
1186 | 1186 | '[wpinv_privacy_policy]' => $privacy_link, |
1187 | 1187 | ); |
1188 | 1188 | |
1189 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1189 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1190 | 1190 | |
1191 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
1191 | + return wp_kses_post(wpautop($privacy_text)); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | function wpinv_oxygen_fix_conflict() { |
1195 | 1195 | global $ct_ignore_post_types; |
1196 | 1196 | |
1197 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1197 | + if (!is_array($ct_ignore_post_types)) { |
|
1198 | 1198 | $ct_ignore_post_types = array(); |
1199 | 1199 | } |
1200 | 1200 | |
1201 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1201 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1202 | 1202 | |
1203 | - foreach ( $post_types as $post_type ) { |
|
1203 | + foreach ($post_types as $post_type) { |
|
1204 | 1204 | $ct_ignore_post_types[] = $post_type; |
1205 | 1205 | |
1206 | 1206 | // Ignore post type |
1207 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1207 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1211 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1210 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1211 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1216,10 +1216,10 @@ discard block |
||
1216 | 1216 | * |
1217 | 1217 | * @param GetPaid_Payment_Form $form |
1218 | 1218 | */ |
1219 | -function getpaid_display_payment_form( $form ) { |
|
1219 | +function getpaid_display_payment_form($form) { |
|
1220 | 1220 | |
1221 | - if ( is_numeric( $form ) ) { |
|
1222 | - $form = new GetPaid_Payment_Form( $form ); |
|
1221 | + if (is_numeric($form)) { |
|
1222 | + $form = new GetPaid_Payment_Form($form); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | $form->display(); |
@@ -1229,61 +1229,61 @@ discard block |
||
1229 | 1229 | /** |
1230 | 1230 | * Helper function to display a item payment form on the frontend. |
1231 | 1231 | */ |
1232 | -function getpaid_display_item_payment_form( $items ) { |
|
1232 | +function getpaid_display_item_payment_form($items) { |
|
1233 | 1233 | |
1234 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1235 | - $form->set_items( $items ); |
|
1234 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1235 | + $form->set_items($items); |
|
1236 | 1236 | |
1237 | - if ( 0 == count( $form->get_items() ) ) { |
|
1237 | + if (0 == count($form->get_items())) { |
|
1238 | 1238 | aui()->alert( |
1239 | 1239 | array( |
1240 | 1240 | 'type' => 'warning', |
1241 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1241 | + 'content' => __('No published items found', 'invoicing'), |
|
1242 | 1242 | ), |
1243 | 1243 | true |
1244 | 1244 | ); |
1245 | 1245 | return; |
1246 | 1246 | } |
1247 | 1247 | |
1248 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1249 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
1248 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1249 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
1250 | 1250 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
1251 | 1251 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
1252 | 1252 | |
1253 | - $form->display( $extra_items ); |
|
1253 | + $form->display($extra_items); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | /** |
1257 | 1257 | * Helper function to display an invoice payment form on the frontend. |
1258 | 1258 | */ |
1259 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1259 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1260 | 1260 | |
1261 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1261 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1262 | 1262 | |
1263 | - if ( empty( $invoice ) ) { |
|
1263 | + if (empty($invoice)) { |
|
1264 | 1264 | aui()->alert( |
1265 | 1265 | array( |
1266 | 1266 | 'type' => 'warning', |
1267 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1267 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1268 | 1268 | ), |
1269 | 1269 | true |
1270 | 1270 | ); |
1271 | 1271 | return; |
1272 | 1272 | } |
1273 | 1273 | |
1274 | - if ( $invoice->is_paid() ) { |
|
1274 | + if ($invoice->is_paid()) { |
|
1275 | 1275 | aui()->alert( |
1276 | 1276 | array( |
1277 | 1277 | 'type' => 'warning', |
1278 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1278 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1279 | 1279 | ), |
1280 | 1280 | true |
1281 | 1281 | ); |
1282 | 1282 | return; |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1286 | - $form->set_items( $invoice->get_items() ); |
|
1285 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1286 | + $form->set_items($invoice->get_items()); |
|
1287 | 1287 | |
1288 | 1288 | $form->display(); |
1289 | 1289 | } |
@@ -1291,25 +1291,25 @@ discard block |
||
1291 | 1291 | /** |
1292 | 1292 | * Helper function to convert item string to array. |
1293 | 1293 | */ |
1294 | -function getpaid_convert_items_to_array( $items ) { |
|
1295 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1294 | +function getpaid_convert_items_to_array($items) { |
|
1295 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1296 | 1296 | $prepared = array(); |
1297 | 1297 | |
1298 | - foreach ( $items as $item ) { |
|
1299 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1298 | + foreach ($items as $item) { |
|
1299 | + $data = array_map('trim', explode('|', $item)); |
|
1300 | 1300 | |
1301 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1301 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1302 | 1302 | continue; |
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | $quantity = 1; |
1306 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1306 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1307 | 1307 | $quantity = (float) $data[1]; |
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | // WPML support. |
1311 | - $item_id = apply_filters( 'wpml_object_id', $data[0], 'wpi_item', true ); |
|
1312 | - $prepared[ $item_id ] = $quantity; |
|
1311 | + $item_id = apply_filters('wpml_object_id', $data[0], 'wpi_item', true); |
|
1312 | + $prepared[$item_id] = $quantity; |
|
1313 | 1313 | |
1314 | 1314 | } |
1315 | 1315 | |
@@ -1319,13 +1319,13 @@ discard block |
||
1319 | 1319 | /** |
1320 | 1320 | * Helper function to convert item array to string. |
1321 | 1321 | */ |
1322 | -function getpaid_convert_items_to_string( $items ) { |
|
1322 | +function getpaid_convert_items_to_string($items) { |
|
1323 | 1323 | $prepared = array(); |
1324 | 1324 | |
1325 | - foreach ( $items as $item => $quantity ) { |
|
1325 | + foreach ($items as $item => $quantity) { |
|
1326 | 1326 | $prepared[] = "$item|$quantity"; |
1327 | 1327 | } |
1328 | - return implode( ',', $prepared ); |
|
1328 | + return implode(',', $prepared); |
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | /** |
@@ -1333,21 +1333,21 @@ discard block |
||
1333 | 1333 | * |
1334 | 1334 | * Provide a label and one of $form, $items or $invoice. |
1335 | 1335 | */ |
1336 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1337 | - $label = sanitize_text_field( $label ); |
|
1336 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1337 | + $label = sanitize_text_field($label); |
|
1338 | 1338 | |
1339 | - if ( ! empty( $form ) ) { |
|
1340 | - $form = esc_attr( $form ); |
|
1339 | + if (!empty($form)) { |
|
1340 | + $form = esc_attr($form); |
|
1341 | 1341 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - if ( ! empty( $items ) ) { |
|
1345 | - $items = esc_attr( $items ); |
|
1344 | + if (!empty($items)) { |
|
1345 | + $items = esc_attr($items); |
|
1346 | 1346 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | - if ( ! empty( $invoice ) ) { |
|
1350 | - $invoice = esc_attr( $invoice ); |
|
1349 | + if (!empty($invoice)) { |
|
1350 | + $invoice = esc_attr($invoice); |
|
1351 | 1351 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1352 | 1352 | } |
1353 | 1353 | |
@@ -1358,17 +1358,17 @@ discard block |
||
1358 | 1358 | * |
1359 | 1359 | * @param WPInv_Invoice $invoice |
1360 | 1360 | */ |
1361 | -function getpaid_the_invoice_description( $invoice ) { |
|
1361 | +function getpaid_the_invoice_description($invoice) { |
|
1362 | 1362 | $description = $invoice->get_description(); |
1363 | 1363 | |
1364 | - if ( empty( $description ) ) { |
|
1364 | + if (empty($description)) { |
|
1365 | 1365 | return; |
1366 | 1366 | } |
1367 | 1367 | |
1368 | - echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>"; |
|
1368 | + echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post(wpautop($description)) . "</em></small>"; |
|
1369 | 1369 | } |
1370 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1371 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1370 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1371 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1372 | 1372 | |
1373 | 1373 | /** |
1374 | 1374 | * Render element on a form. |
@@ -1376,79 +1376,79 @@ discard block |
||
1376 | 1376 | * @param array $element |
1377 | 1377 | * @param GetPaid_Payment_Form $form |
1378 | 1378 | */ |
1379 | -function getpaid_payment_form_element( $element, $form ) { |
|
1379 | +function getpaid_payment_form_element($element, $form) { |
|
1380 | 1380 | |
1381 | 1381 | // Set up the args. |
1382 | - $element_type = trim( $element['type'] ); |
|
1382 | + $element_type = trim($element['type']); |
|
1383 | 1383 | $element['form'] = $form; |
1384 | - extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1384 | + extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1385 | 1385 | |
1386 | 1386 | // Try to locate the appropriate template. |
1387 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1387 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1388 | 1388 | |
1389 | 1389 | // Abort if this is not our element. |
1390 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1390 | + if (empty($located) || !file_exists($located)) { |
|
1391 | 1391 | return; |
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | // Generate the class and id of the element. |
1395 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1396 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1395 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1396 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1397 | 1397 | |
1398 | - $element_id = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id; |
|
1399 | - $query_value = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1398 | + $element_id = !empty($element['label']) ? sanitize_title($element['label']) : $id; |
|
1399 | + $query_value = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1400 | 1400 | |
1401 | 1401 | $element_id = 'getpaid-' . $element_id; |
1402 | - if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) { |
|
1403 | - $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ]; |
|
1402 | + if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) { |
|
1403 | + $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()]; |
|
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | // Echo the opening wrapper. |
1407 | - echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>"; |
|
1407 | + echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>"; |
|
1408 | 1408 | |
1409 | 1409 | // Fires before displaying a given element type's content. |
1410 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1410 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1411 | 1411 | |
1412 | 1412 | // Include the template for the element. |
1413 | 1413 | include $located; |
1414 | 1414 | |
1415 | 1415 | // Fires after displaying a given element type's content. |
1416 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1416 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1417 | 1417 | |
1418 | 1418 | // Echo the closing wrapper. |
1419 | 1419 | echo '</div>'; |
1420 | 1420 | } |
1421 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1421 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1422 | 1422 | |
1423 | 1423 | /** |
1424 | 1424 | * Render an element's edit page. |
1425 | 1425 | * |
1426 | 1426 | * @param WP_Post $post |
1427 | 1427 | */ |
1428 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1428 | +function getpaid_payment_form_edit_element_template($post) { |
|
1429 | 1429 | |
1430 | 1430 | // Retrieve all elements. |
1431 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1431 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1432 | 1432 | |
1433 | - foreach ( $all_elements as $element ) { |
|
1433 | + foreach ($all_elements as $element) { |
|
1434 | 1434 | |
1435 | 1435 | // Try to locate the appropriate template. |
1436 | - $element = esc_attr( sanitize_key( $element ) ); |
|
1437 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1436 | + $element = esc_attr(sanitize_key($element)); |
|
1437 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1438 | 1438 | |
1439 | 1439 | // Continue if this is not our element. |
1440 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1440 | + if (empty($located) || !file_exists($located)) { |
|
1441 | 1441 | continue; |
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | // Include the template for the element. |
1445 | - echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">"; |
|
1445 | + echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">"; |
|
1446 | 1446 | include $located; |
1447 | 1447 | echo '</div>'; |
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | } |
1451 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1451 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1452 | 1452 | |
1453 | 1453 | /** |
1454 | 1454 | * Render an element's preview. |
@@ -1457,27 +1457,27 @@ discard block |
||
1457 | 1457 | function getpaid_payment_form_render_element_preview_template() { |
1458 | 1458 | |
1459 | 1459 | // Retrieve all elements. |
1460 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1460 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1461 | 1461 | |
1462 | - foreach ( $all_elements as $element ) { |
|
1462 | + foreach ($all_elements as $element) { |
|
1463 | 1463 | |
1464 | 1464 | // Try to locate the appropriate template. |
1465 | - $element = sanitize_key( $element ); |
|
1466 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1465 | + $element = sanitize_key($element); |
|
1466 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1467 | 1467 | |
1468 | 1468 | // Continue if this is not our element. |
1469 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1469 | + if (empty($located) || !file_exists($located)) { |
|
1470 | 1470 | continue; |
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | // Include the template for the element. |
1474 | - echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">"; |
|
1474 | + echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">"; |
|
1475 | 1475 | include $located; |
1476 | 1476 | echo '</div>'; |
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | } |
1480 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1480 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1481 | 1481 | |
1482 | 1482 | /** |
1483 | 1483 | * Shows a list of gateways that support recurring payments. |
@@ -1485,17 +1485,17 @@ discard block |
||
1485 | 1485 | function wpinv_get_recurring_gateways_text() { |
1486 | 1486 | $gateways = array(); |
1487 | 1487 | |
1488 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1489 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1490 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1488 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1489 | + if (wpinv_gateway_support_subscription($key)) { |
|
1490 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1491 | 1491 | } |
1492 | 1492 | } |
1493 | 1493 | |
1494 | - if ( empty( $gateways ) ) { |
|
1495 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
1494 | + if (empty($gateways)) { |
|
1495 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
1498 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
1499 | 1499 | |
1500 | 1500 | } |
1501 | 1501 | |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | * @return GetPaid_Template |
1506 | 1506 | */ |
1507 | 1507 | function getpaid_template() { |
1508 | - return getpaid()->get( 'template' ); |
|
1508 | + return getpaid()->get('template'); |
|
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | /** |
@@ -1514,8 +1514,8 @@ discard block |
||
1514 | 1514 | * @param array args |
1515 | 1515 | * @return string |
1516 | 1516 | */ |
1517 | -function getpaid_paginate_links( $args ) { |
|
1518 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1517 | +function getpaid_paginate_links($args) { |
|
1518 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | /** |
@@ -1525,22 +1525,22 @@ discard block |
||
1525 | 1525 | * @param string state |
1526 | 1526 | * @return string |
1527 | 1527 | */ |
1528 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) { |
|
1528 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) { |
|
1529 | 1529 | |
1530 | - $states = wpinv_get_country_states( $country ); |
|
1531 | - $uniqid = uniqid( '_' ); |
|
1530 | + $states = wpinv_get_country_states($country); |
|
1531 | + $uniqid = uniqid('_'); |
|
1532 | 1532 | |
1533 | - if ( ! empty( $states ) ) { |
|
1533 | + if (!empty($states)) { |
|
1534 | 1534 | |
1535 | 1535 | return aui()->select( |
1536 | 1536 | array( |
1537 | 1537 | 'options' => $states, |
1538 | - 'name' => esc_attr( $field_name ), |
|
1539 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1540 | - 'value' => sanitize_text_field( $state ), |
|
1538 | + 'name' => esc_attr($field_name), |
|
1539 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1540 | + 'value' => sanitize_text_field($state), |
|
1541 | 1541 | 'placeholder' => $placeholder, |
1542 | 1542 | 'required' => $required, |
1543 | - 'label' => wp_kses_post( $label ), |
|
1543 | + 'label' => wp_kses_post($label), |
|
1544 | 1544 | 'label_type' => 'vertical', |
1545 | 1545 | 'help_text' => $help_text, |
1546 | 1546 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1557,14 +1557,14 @@ discard block |
||
1557 | 1557 | |
1558 | 1558 | return aui()->input( |
1559 | 1559 | array( |
1560 | - 'name' => esc_attr( $field_name ), |
|
1561 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1560 | + 'name' => esc_attr($field_name), |
|
1561 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1562 | 1562 | 'placeholder' => $placeholder, |
1563 | 1563 | 'required' => $required, |
1564 | - 'label' => wp_kses_post( $label ), |
|
1564 | + 'label' => wp_kses_post($label), |
|
1565 | 1565 | 'label_type' => 'vertical', |
1566 | 1566 | 'help_text' => $help_text, |
1567 | - 'value' => sanitize_text_field( $state ), |
|
1567 | + 'value' => sanitize_text_field($state), |
|
1568 | 1568 | 'class' => 'getpaid-address-field wpinv_state', |
1569 | 1569 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1570 | 1570 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1583,16 +1583,16 @@ discard block |
||
1583 | 1583 | * @param array $element |
1584 | 1584 | * @return string |
1585 | 1585 | */ |
1586 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1586 | +function getpaid_get_form_element_grid_class($element) { |
|
1587 | 1587 | |
1588 | 1588 | $class = 'col-12'; |
1589 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1589 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1590 | 1590 | |
1591 | - if ( $width == 'half' ) { |
|
1591 | + if ($width == 'half') { |
|
1592 | 1592 | $class .= ' col-md-6'; |
1593 | 1593 | } |
1594 | 1594 | |
1595 | - if ( $width == 'third' ) { |
|
1595 | + if ($width == 'third') { |
|
1596 | 1596 | $class .= ' col-md-4'; |
1597 | 1597 | } |
1598 | 1598 | |
@@ -1607,15 +1607,15 @@ discard block |
||
1607 | 1607 | * |
1608 | 1608 | * @return string |
1609 | 1609 | */ |
1610 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
1610 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
1611 | 1611 | |
1612 | 1612 | return add_query_arg( |
1613 | 1613 | array( |
1614 | 1614 | 'getpaid_embed' => 1, |
1615 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
1616 | - 'item' => $items ? urlencode( $items ) : false, |
|
1615 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
1616 | + 'item' => $items ? urlencode($items) : false, |
|
1617 | 1617 | ), |
1618 | - home_url( 'index.php' ) |
|
1618 | + home_url('index.php') |
|
1619 | 1619 | ); |
1620 | 1620 | |
1621 | 1621 | } |
@@ -1625,13 +1625,13 @@ discard block |
||
1625 | 1625 | * |
1626 | 1626 | * @return string |
1627 | 1627 | */ |
1628 | -function getpaid_filter_embed_template( $template ) { |
|
1628 | +function getpaid_filter_embed_template($template) { |
|
1629 | 1629 | |
1630 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
1631 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
1630 | + if (isset($_GET['getpaid_embed'])) { |
|
1631 | + wpinv_get_template('payment-forms/embed.php'); |
|
1632 | 1632 | exit; |
1633 | 1633 | } |
1634 | 1634 | |
1635 | 1635 | return $template; |
1636 | 1636 | } |
1637 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
1637 | +add_filter('template_include', 'getpaid_filter_embed_template'); |