@@ -521,7 +521,7 @@ |
||
521 | 521 | * Example: <?php $give = Give(); ?> |
522 | 522 | * |
523 | 523 | * @since 1.0 |
524 | - * @return object|Give |
|
524 | + * @return Give |
|
525 | 525 | */ |
526 | 526 | function Give() { |
527 | 527 | return Give::instance(); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | |
41 | 41 | // Exit if accessed directly. |
42 | -if ( ! defined( 'ABSPATH' ) ) { |
|
42 | +if ( ! defined('ABSPATH')) { |
|
43 | 43 | exit; |
44 | 44 | } |
45 | 45 | |
46 | -if ( ! class_exists( 'Give' ) ) : |
|
46 | +if ( ! class_exists('Give')) : |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Main Give Class |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return Give |
238 | 238 | */ |
239 | 239 | public static function instance() { |
240 | - if ( is_null( self::$_instance ) ) { |
|
240 | + if (is_null(self::$_instance)) { |
|
241 | 241 | self::$_instance = new self(); |
242 | 242 | } |
243 | 243 | |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function __construct() { |
251 | 251 | // PHP version |
252 | - if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) { |
|
253 | - define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' ); |
|
252 | + if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) { |
|
253 | + define('GIVE_REQUIRED_PHP_VERSION', '5.3'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | // Bailout: Need minimum php version to load plugin. |
257 | - if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { |
|
258 | - add_action( 'admin_notices', array( $this, 'minmum_phpversion_notice' ) ); |
|
257 | + if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) { |
|
258 | + add_action('admin_notices', array($this, 'minmum_phpversion_notice')); |
|
259 | 259 | |
260 | 260 | return; |
261 | 261 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $this->includes(); |
266 | 266 | $this->init_hooks(); |
267 | 267 | |
268 | - do_action( 'give_loaded' ); |
|
268 | + do_action('give_loaded'); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @since 1.8.9 |
275 | 275 | */ |
276 | 276 | private function init_hooks() { |
277 | - register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
278 | - add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); |
|
277 | + register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
278 | + add_action('plugins_loaded', array($this, 'init'), 0); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @since 1.8.9 |
292 | 292 | */ |
293 | - do_action( 'before_give_init' ); |
|
293 | + do_action('before_give_init'); |
|
294 | 294 | |
295 | 295 | // Set up localization. |
296 | 296 | $this->load_textdomain(); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @since 1.8.7 |
322 | 322 | */ |
323 | - do_action( 'give_init', $this ); |
|
323 | + do_action('give_init', $this); |
|
324 | 324 | |
325 | 325 | } |
326 | 326 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public function __clone() { |
339 | 339 | // Cloning instances of the class is forbidden. |
340 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
340 | + give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function __wakeup() { |
352 | 352 | // Unserializing instances of the class is forbidden. |
353 | - give_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
353 | + give_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0'); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -364,33 +364,33 @@ discard block |
||
364 | 364 | private function setup_constants() { |
365 | 365 | |
366 | 366 | // Plugin version |
367 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
368 | - define( 'GIVE_VERSION', '2.0.0' ); |
|
367 | + if ( ! defined('GIVE_VERSION')) { |
|
368 | + define('GIVE_VERSION', '2.0.0'); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | // Plugin Root File |
372 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
373 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
372 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
373 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | // Plugin Folder Path |
377 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
378 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) ); |
|
377 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
378 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE)); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | // Plugin Folder URL |
382 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
383 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) ); |
|
382 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
383 | + define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE)); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | // Plugin Basename aka: "give/give.php" |
387 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
388 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) ); |
|
387 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
388 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE)); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | // Make sure CAL_GREGORIAN is defined |
392 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
393 | - define( 'CAL_GREGORIAN', 1 ); |
|
392 | + if ( ! defined('CAL_GREGORIAN')) { |
|
393 | + define('CAL_GREGORIAN', 1); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
@@ -408,152 +408,152 @@ discard block |
||
408 | 408 | /** |
409 | 409 | * Load libraries. |
410 | 410 | */ |
411 | - if ( ! class_exists( 'WP_Async_Request' ) ) { |
|
412 | - include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-async-request.php' ); |
|
411 | + if ( ! class_exists('WP_Async_Request')) { |
|
412 | + include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-async-request.php'); |
|
413 | 413 | } |
414 | 414 | |
415 | - if ( ! class_exists( 'WP_Background_Process' ) ) { |
|
416 | - include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-background-process.php' ); |
|
415 | + if ( ! class_exists('WP_Background_Process')) { |
|
416 | + include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-background-process.php'); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
420 | 420 | * Load plugin files |
421 | 421 | */ |
422 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
423 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
422 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
423 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
424 | 424 | $give_options = give_get_settings(); |
425 | 425 | |
426 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
427 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php'; |
|
428 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
429 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php'; |
|
430 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
431 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
432 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
433 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
434 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
435 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
436 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php'; |
|
437 | - require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php'; |
|
438 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php'; |
|
439 | - |
|
440 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
441 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
442 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
443 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
444 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-meta.php'; |
|
445 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php'; |
|
446 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php'; |
|
447 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php'; |
|
448 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
449 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
450 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
451 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
452 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
453 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
454 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-payment-meta.php'; |
|
455 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-form-meta.php'; |
|
456 | - |
|
457 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
458 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
459 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
460 | - require_once GIVE_PLUGIN_DIR . 'includes/import-functions.php'; |
|
461 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
462 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
463 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
464 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
465 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
466 | - require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php'; |
|
467 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
468 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
469 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
470 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
471 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
472 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
473 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php'; |
|
474 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
475 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
476 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
477 | - |
|
478 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php'; |
|
479 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
480 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
481 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
482 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
483 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
484 | - |
|
485 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
486 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
487 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
488 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
489 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
490 | - |
|
491 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
492 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
493 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php'; |
|
494 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
495 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
496 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
497 | - |
|
498 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php'; |
|
499 | - require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php'; |
|
500 | - |
|
501 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php'; |
|
502 | - |
|
503 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
504 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
426 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
427 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-async-process.php'; |
|
428 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
429 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php'; |
|
430 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
431 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
432 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
433 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
434 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
435 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
436 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-tooltips.php'; |
|
437 | + require_once GIVE_PLUGIN_DIR.'includes/class-notices.php'; |
|
438 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-translation.php'; |
|
439 | + |
|
440 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
441 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
442 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
443 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
444 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-meta.php'; |
|
445 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php'; |
|
446 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php'; |
|
447 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php'; |
|
448 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
449 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
450 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
451 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
452 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
453 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
454 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-payment-meta.php'; |
|
455 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-form-meta.php'; |
|
456 | + |
|
457 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
458 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
459 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
460 | + require_once GIVE_PLUGIN_DIR.'includes/import-functions.php'; |
|
461 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
462 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
463 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
464 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
465 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
466 | + require_once GIVE_PLUGIN_DIR.'includes/currency-functions.php'; |
|
467 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
468 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
469 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
470 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
471 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
472 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
473 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php'; |
|
474 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
475 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
476 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
477 | + |
|
478 | + require_once GIVE_PLUGIN_DIR.'includes/payments/backward-compatibility.php'; |
|
479 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
480 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
481 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
482 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
483 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
484 | + |
|
485 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
486 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
487 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
488 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
489 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
490 | + |
|
491 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
492 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
493 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notifications.php'; |
|
494 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
495 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
496 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
497 | + |
|
498 | + require_once GIVE_PLUGIN_DIR.'includes/donors/class-give-donors-query.php'; |
|
499 | + require_once GIVE_PLUGIN_DIR.'includes/donors/backward-compatibility.php'; |
|
500 | + |
|
501 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php'; |
|
502 | + |
|
503 | + if (defined('WP_CLI') && WP_CLI) { |
|
504 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
505 | 505 | } |
506 | 506 | |
507 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
508 | - |
|
509 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
510 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
511 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
512 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
513 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
514 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
515 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php'; |
|
516 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
517 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
518 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
519 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-blank-slate.php'; |
|
520 | - |
|
521 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
522 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
523 | - |
|
524 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php'; |
|
525 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php'; |
|
526 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php'; |
|
527 | - |
|
528 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
529 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
530 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
531 | - |
|
532 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php'; |
|
533 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php'; |
|
534 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php'; |
|
535 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php'; |
|
536 | - |
|
537 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php'; |
|
538 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php'; |
|
539 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php'; |
|
540 | - |
|
541 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; |
|
542 | - |
|
543 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php'; |
|
544 | - |
|
545 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
546 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
547 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
548 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
549 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
550 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
551 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
552 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
553 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
507 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
508 | + |
|
509 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
510 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
511 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
512 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
513 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
514 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
515 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php'; |
|
516 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
517 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
518 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
519 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-blank-slate.php'; |
|
520 | + |
|
521 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
522 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
523 | + |
|
524 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php'; |
|
525 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php'; |
|
526 | + require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php'; |
|
527 | + |
|
528 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
529 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
530 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
531 | + |
|
532 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php'; |
|
533 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php'; |
|
534 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php'; |
|
535 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php'; |
|
536 | + |
|
537 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php'; |
|
538 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php'; |
|
539 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php'; |
|
540 | + |
|
541 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'; |
|
542 | + |
|
543 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php'; |
|
544 | + |
|
545 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
546 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
547 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
548 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
549 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
550 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
551 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
552 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
553 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
554 | 554 | }// End if(). |
555 | 555 | |
556 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
556 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
557 | 557 | |
558 | 558 | } |
559 | 559 | |
@@ -568,16 +568,16 @@ discard block |
||
568 | 568 | public function load_textdomain() { |
569 | 569 | |
570 | 570 | // Set filter for Give's languages directory |
571 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
572 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
571 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
572 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
573 | 573 | |
574 | 574 | // Traditional WordPress plugin locale filter. |
575 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
576 | - $locale = apply_filters( 'plugin_locale', $locale, 'give' ); |
|
575 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
576 | + $locale = apply_filters('plugin_locale', $locale, 'give'); |
|
577 | 577 | |
578 | - unload_textdomain( 'give' ); |
|
579 | - load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' ); |
|
580 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
578 | + unload_textdomain('give'); |
|
579 | + load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo'); |
|
580 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
581 | 581 | |
582 | 582 | } |
583 | 583 | |
@@ -590,17 +590,17 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function minmum_phpversion_notice() { |
592 | 592 | // Bailout. |
593 | - if ( ! is_admin() ) { |
|
593 | + if ( ! is_admin()) { |
|
594 | 594 | return; |
595 | 595 | } |
596 | 596 | |
597 | - $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; |
|
598 | - $notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>'; |
|
599 | - $notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>'; |
|
600 | - $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; |
|
601 | - $notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>'; |
|
602 | - $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; |
|
603 | - $notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>'; |
|
597 | + $notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>'; |
|
598 | + $notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>'; |
|
599 | + $notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>'; |
|
600 | + $notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>'; |
|
601 | + $notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>'; |
|
602 | + $notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>'; |
|
603 | + $notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>'; |
|
604 | 604 | |
605 | 605 | echo sprintf( |
606 | 606 | '<div class="notice notice-error">%1$s</div>', |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * Return the calculated completion percentage. |
217 | 217 | * |
218 | 218 | * @since 1.8.12 |
219 | - * @return int |
|
219 | + * @return double |
|
220 | 220 | */ |
221 | 221 | public function get_percentage_complete() { |
222 | 222 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -353,6 +353,9 @@ discard block |
||
353 | 353 | return true; |
354 | 354 | } |
355 | 355 | |
356 | + /** |
|
357 | + * @param integer $page |
|
358 | + */ |
|
356 | 359 | public function get_delete_ids( $donation_ids, $page ) { |
357 | 360 | $index = $page --; |
358 | 361 | $count = count( $donation_ids ); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -109,32 +109,32 @@ discard block |
||
109 | 109 | $donor_ids = array(); |
110 | 110 | |
111 | 111 | // Check if the ajax request if running for the first time. |
112 | - if ( 1 === (int) $this->step ) { |
|
112 | + if (1 === (int) $this->step) { |
|
113 | 113 | // Delete all the donation ids. |
114 | - $this->delete_option( $this->donation_key ); |
|
114 | + $this->delete_option($this->donation_key); |
|
115 | 115 | // Delete all the donor ids. |
116 | - $this->delete_option( $this->donor_key ); |
|
116 | + $this->delete_option($this->donor_key); |
|
117 | 117 | |
118 | 118 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
119 | - $this->update_option( $this->step_key, 'count' ); |
|
119 | + $this->update_option($this->step_key, 'count'); |
|
120 | 120 | |
121 | 121 | // Delete tha page count of the step. |
122 | - $this->update_option( $this->step_on_key, '0' ); |
|
122 | + $this->update_option($this->step_on_key, '0'); |
|
123 | 123 | } else { |
124 | 124 | // Get the old donors list. |
125 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
125 | + $donor_ids = $this->get_option($this->donor_key); |
|
126 | 126 | |
127 | 127 | // Get the old donation list. |
128 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
128 | + $donation_ids = $this->get_option($this->donation_key); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
132 | 132 | $step = (int) $this->get_step(); |
133 | - if ( 1 === $step ) { |
|
133 | + if (1 === $step) { |
|
134 | 134 | /** |
135 | 135 | * Will add or update the donation and donor data by running wp query. |
136 | 136 | */ |
137 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
137 | + $this->count($step, $donation_ids, $donor_ids); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
146 | 146 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
147 | 147 | */ |
148 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
148 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
149 | 149 | |
150 | 150 | // Get the Page count by default it's zero. |
151 | 151 | $paged = (int) $this->get_step_page(); |
152 | 152 | // Incresed the page count by one. |
153 | - ++ $paged; |
|
153 | + ++$paged; |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Filter add to alter the argument before the wp quest run |
157 | 157 | */ |
158 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
158 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
159 | 159 | 'post_type' => 'give_payment', |
160 | 160 | 'post_status' => 'any', |
161 | 161 | 'posts_per_page' => $this->per_step, |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | // ONLY TEST MODE TRANSACTIONS!!! |
164 | 164 | 'meta_key' => '_give_payment_mode', |
165 | 165 | 'meta_value' => 'test', |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | |
168 | 168 | // Reset the post data. |
169 | 169 | wp_reset_postdata(); |
170 | 170 | // Getting the new donation. |
171 | - $donation_posts = new WP_Query( $args ); |
|
171 | + $donation_posts = new WP_Query($args); |
|
172 | 172 | |
173 | 173 | // The Loop. |
174 | - if ( $donation_posts->have_posts() ) { |
|
175 | - while ( $donation_posts->have_posts() ) { |
|
174 | + if ($donation_posts->have_posts()) { |
|
175 | + while ($donation_posts->have_posts()) { |
|
176 | 176 | $donation_posts->the_post(); |
177 | 177 | global $post; |
178 | 178 | // Add the donation id in side the array. |
@@ -191,23 +191,23 @@ discard block |
||
191 | 191 | $max_num_pages = (int) $donation_posts->max_num_pages; |
192 | 192 | |
193 | 193 | // Check current page is less then max number of page or not |
194 | - if ( $paged < $max_num_pages ) { |
|
194 | + if ($paged < $max_num_pages) { |
|
195 | 195 | // Update the curretn page virable for the next step |
196 | - $this->update_option( $this->step_on_key, $paged ); |
|
196 | + $this->update_option($this->step_on_key, $paged); |
|
197 | 197 | |
198 | 198 | // Calculating percentage. |
199 | 199 | $page_remain = $max_num_pages - $paged; |
200 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
200 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
201 | 201 | $this->step_completed = $paged; |
202 | 202 | } else { |
203 | - $donation_ids_count = count( $donor_ids ); |
|
204 | - $this->update_option( $this->step_key, 'donation' ); |
|
205 | - $this->update_option( $this->step_on_key, '0' ); |
|
203 | + $donation_ids_count = count($donor_ids); |
|
204 | + $this->update_option($this->step_key, 'donation'); |
|
205 | + $this->update_option($this->step_on_key, '0'); |
|
206 | 206 | } |
207 | 207 | |
208 | - $donor_ids = array_unique( $donor_ids ); |
|
209 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
210 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
208 | + $donor_ids = array_unique($donor_ids); |
|
209 | + $this->update_option($this->donor_key, $donor_ids); |
|
210 | + $this->update_option($this->donation_key, $donation_ids); |
|
211 | 211 | |
212 | 212 | wp_reset_postdata(); |
213 | 213 | } |
@@ -219,34 +219,34 @@ discard block |
||
219 | 219 | * @return int |
220 | 220 | */ |
221 | 221 | public function get_percentage_complete() { |
222 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
222 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | public function process_step() { |
226 | 226 | |
227 | - if ( ! $this->can_export() ) { |
|
228 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
227 | + if ( ! $this->can_export()) { |
|
228 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $had_data = $this->get_data(); |
232 | 232 | |
233 | - if ( $had_data ) { |
|
233 | + if ($had_data) { |
|
234 | 234 | $this->done = false; |
235 | 235 | |
236 | 236 | return true; |
237 | 237 | } else { |
238 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
239 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
238 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
239 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
240 | 240 | |
241 | - $this->delete_option( $this->donation_key ); |
|
241 | + $this->delete_option($this->donation_key); |
|
242 | 242 | |
243 | 243 | // Reset the sequential order numbers |
244 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
245 | - delete_option( 'give_last_payment_number' ); |
|
244 | + if (give_get_option('enable_sequential')) { |
|
245 | + delete_option('give_last_payment_number'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | $this->done = true; |
249 | - $this->message = __( 'Test donor and transactions successfully deleted.', 'give' ); |
|
249 | + $this->message = __('Test donor and transactions successfully deleted.', 'give'); |
|
250 | 250 | |
251 | 251 | return false; |
252 | 252 | } |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | public function get_data() { |
265 | 265 | |
266 | 266 | // Get the donation id's. |
267 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
267 | + $donation_ids = $this->get_option($this->donation_key); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Return false id not test donation is found. |
271 | 271 | */ |
272 | - if ( empty( $donation_ids ) ) { |
|
272 | + if (empty($donation_ids)) { |
|
273 | 273 | $this->is_empty = true; |
274 | 274 | $this->total_step = 1; |
275 | 275 | |
@@ -280,70 +280,70 @@ discard block |
||
280 | 280 | $step = (int) $this->get_step(); |
281 | 281 | |
282 | 282 | // get teh donor ids. |
283 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
283 | + $donor_ids = $this->get_option($this->donor_key); |
|
284 | 284 | |
285 | 285 | // In step to we delete all the donation in loop. |
286 | - if ( 2 === $step ) { |
|
286 | + if (2 === $step) { |
|
287 | 287 | $pass_to_donor = false; |
288 | 288 | $page = (int) $this->get_step_page(); |
289 | - $page ++; |
|
290 | - $count = count( $donation_ids ); |
|
289 | + $page++; |
|
290 | + $count = count($donation_ids); |
|
291 | 291 | |
292 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
292 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
293 | 293 | $this->step_completed = $page; |
294 | 294 | |
295 | 295 | |
296 | - if ( $count > $this->per_step ) { |
|
296 | + if ($count > $this->per_step) { |
|
297 | 297 | |
298 | - $this->update_option( $this->step_on_key, $page ); |
|
299 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
300 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
298 | + $this->update_option($this->step_on_key, $page); |
|
299 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
300 | + $current_page = (int) ceil($count / $this->per_step); |
|
301 | 301 | |
302 | - if ( $page === $current_page ) { |
|
302 | + if ($page === $current_page) { |
|
303 | 303 | $pass_to_donor = true; |
304 | 304 | } |
305 | 305 | } else { |
306 | 306 | $pass_to_donor = true; |
307 | 307 | } |
308 | 308 | |
309 | - if ( true === $pass_to_donor ) { |
|
310 | - $this->update_option( $this->step_key, 'donor' ); |
|
311 | - $this->update_option( $this->step_on_key, '0' ); |
|
309 | + if (true === $pass_to_donor) { |
|
310 | + $this->update_option($this->step_key, 'donor'); |
|
311 | + $this->update_option($this->step_on_key, '0'); |
|
312 | 312 | } |
313 | 313 | |
314 | - foreach ( $donation_ids as $item ) { |
|
314 | + foreach ($donation_ids as $item) { |
|
315 | 315 | // Delete the main payment. |
316 | - give_delete_donation( absint( $item ) ); |
|
316 | + give_delete_donation(absint($item)); |
|
317 | 317 | } |
318 | - do_action( 'give_delete_log_cache' ); |
|
318 | + do_action('give_delete_log_cache'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
322 | 322 | // Here we delete all the donor |
323 | - if ( 3 === $step ) { |
|
323 | + if (3 === $step) { |
|
324 | 324 | $page = (int) $this->get_step_page(); |
325 | - $count = count( $donor_ids ); |
|
325 | + $count = count($donor_ids); |
|
326 | 326 | |
327 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
328 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
327 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
328 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
329 | 329 | |
330 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
330 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
331 | 331 | 'post_type' => 'give_payment', |
332 | 332 | 'post_status' => 'any', |
333 | 333 | 'posts_per_page' => 1, |
334 | 334 | 'meta_key' => '_give_payment_mode', |
335 | 335 | 'meta_value' => 'live', |
336 | - 'author' => $donor_ids[ $page ], |
|
337 | - ) ); |
|
336 | + 'author' => $donor_ids[$page], |
|
337 | + )); |
|
338 | 338 | |
339 | - $donation_posts = get_posts( $args ); |
|
340 | - if ( empty( $donation_posts ) ) { |
|
341 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
339 | + $donation_posts = get_posts($args); |
|
340 | + if (empty($donation_posts)) { |
|
341 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
342 | 342 | } |
343 | 343 | |
344 | - $page ++; |
|
345 | - $this->update_option( $this->step_on_key, $page ); |
|
346 | - if ( $count === $page ) { |
|
344 | + $page++; |
|
345 | + $this->update_option($this->step_on_key, $page); |
|
346 | + if ($count === $page) { |
|
347 | 347 | $this->is_empty = false; |
348 | 348 | |
349 | 349 | return false; |
@@ -355,24 +355,24 @@ discard block |
||
355 | 355 | return true; |
356 | 356 | } |
357 | 357 | |
358 | - public function get_delete_ids( $donation_ids, $page ) { |
|
359 | - $index = $page --; |
|
360 | - $count = count( $donation_ids ); |
|
358 | + public function get_delete_ids($donation_ids, $page) { |
|
359 | + $index = $page--; |
|
360 | + $count = count($donation_ids); |
|
361 | 361 | $temp = 0; |
362 | 362 | $current_page = 0; |
363 | 363 | $post_delete = $this->per_step; |
364 | 364 | $page_donation_id = array(); |
365 | 365 | |
366 | - foreach ( $donation_ids as $item ) { |
|
367 | - $temp ++; |
|
368 | - $page_donation_id[ $current_page ][] = $item; |
|
369 | - if ( $temp === $post_delete ) { |
|
370 | - $current_page ++; |
|
366 | + foreach ($donation_ids as $item) { |
|
367 | + $temp++; |
|
368 | + $page_donation_id[$current_page][] = $item; |
|
369 | + if ($temp === $post_delete) { |
|
370 | + $current_page++; |
|
371 | 371 | $temp = 0; |
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | - return $page_donation_id[ $page ]; |
|
375 | + return $page_donation_id[$page]; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return mixed Returns the data from the database |
386 | 386 | */ |
387 | - public function get_option( $key, $defalut_value = false ) { |
|
388 | - return get_option( $key, $defalut_value ); |
|
387 | + public function get_option($key, $defalut_value = false) { |
|
388 | + return get_option($key, $defalut_value); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @return void |
400 | 400 | */ |
401 | - public function update_option( $key, $value ) { |
|
402 | - update_option( $key, $value, false ); |
|
401 | + public function update_option($key, $value) { |
|
402 | + update_option($key, $value, false); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return void |
413 | 413 | */ |
414 | - public function delete_option( $key ) { |
|
415 | - delete_option( $key ); |
|
414 | + public function delete_option($key) { |
|
415 | + delete_option($key); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | * @return int|string |
424 | 424 | */ |
425 | 425 | private function get_step() { |
426 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
427 | - if ( 'count' === $step_key ) { |
|
426 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
427 | + if ('count' === $step_key) { |
|
428 | 428 | return 1; |
429 | - } elseif ( 'donation' === $step_key ) { |
|
429 | + } elseif ('donation' === $step_key) { |
|
430 | 430 | return 2; |
431 | - } elseif ( 'donor' === $step_key ) { |
|
431 | + } elseif ('donor' === $step_key) { |
|
432 | 432 | return 3; |
433 | 433 | } else { |
434 | 434 | return $step_key; |
@@ -439,6 +439,6 @@ discard block |
||
439 | 439 | * Get the current $page value in the ajax. |
440 | 440 | */ |
441 | 441 | private function get_step_page() { |
442 | - return $this->get_option( $this->step_on_key, false ); |
|
442 | + return $this->get_option($this->step_on_key, false); |
|
443 | 443 | } |
444 | 444 | } |
@@ -340,7 +340,7 @@ |
||
340 | 340 | * @since 1.0 |
341 | 341 | * |
342 | 342 | * @param int|float|string $amount Formatted or sanitized price |
343 | - * @param int|bool $dp number of decimals |
|
343 | + * @param boolean $dp number of decimals |
|
344 | 344 | * @param bool $sanitize Whether or not sanitize number |
345 | 345 | * |
346 | 346 | * @return string $amount Newly formatted amount or Price Not Available |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,37 +23,37 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return mixed |
25 | 25 | */ |
26 | -function give_get_currency_formatting_settings( $id_or_currency_code = null ) { |
|
26 | +function give_get_currency_formatting_settings($id_or_currency_code = null) { |
|
27 | 27 | $give_options = give_get_settings(); |
28 | 28 | $setting = array(); |
29 | 29 | |
30 | - if ( ! empty( $id_or_currency_code ) ) { |
|
31 | - $currencies = give_get_currencies( 'all' ); |
|
30 | + if ( ! empty($id_or_currency_code)) { |
|
31 | + $currencies = give_get_currencies('all'); |
|
32 | 32 | |
33 | 33 | // Set default formatting setting only if currency not set as global currency. |
34 | 34 | if ( |
35 | - is_string( $id_or_currency_code ) && |
|
36 | - ! empty( $give_options['currency'] ) && |
|
35 | + is_string($id_or_currency_code) && |
|
36 | + ! empty($give_options['currency']) && |
|
37 | 37 | $id_or_currency_code !== $give_options['currency'] && |
38 | - array_key_exists( $id_or_currency_code, $currencies ) |
|
38 | + array_key_exists($id_or_currency_code, $currencies) |
|
39 | 39 | ) { |
40 | - $setting = $currencies[ $id_or_currency_code ]['setting']; |
|
41 | - } elseif ( is_numeric( $id_or_currency_code ) && 'give_payment' === get_post_type( $id_or_currency_code ) ) { |
|
42 | - $donation_meta = give_get_meta( $id_or_currency_code, '_give_payment_meta', true ); |
|
40 | + $setting = $currencies[$id_or_currency_code]['setting']; |
|
41 | + } elseif (is_numeric($id_or_currency_code) && 'give_payment' === get_post_type($id_or_currency_code)) { |
|
42 | + $donation_meta = give_get_meta($id_or_currency_code, '_give_payment_meta', true); |
|
43 | 43 | |
44 | 44 | if ( |
45 | - ! empty( $donation_meta['currency'] ) && |
|
45 | + ! empty($donation_meta['currency']) && |
|
46 | 46 | $give_options['currency'] !== $donation_meta['currency'] |
47 | 47 | ) { |
48 | - $setting = $currencies[ $donation_meta['currency'] ]['setting']; |
|
48 | + $setting = $currencies[$donation_meta['currency']]['setting']; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - if ( empty( $setting ) ) { |
|
53 | + if (empty($setting)) { |
|
54 | 54 | // Set thousand separator. |
55 | - $thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ','; |
|
56 | - $thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator; |
|
55 | + $thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ','; |
|
56 | + $thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator; |
|
57 | 57 | |
58 | 58 | // Set decimal separator. |
59 | 59 | $default_decimal_separators = array( |
@@ -61,17 +61,16 @@ discard block |
||
61 | 61 | ',' => '.', |
62 | 62 | ); |
63 | 63 | |
64 | - $default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ? |
|
65 | - $default_decimal_separators[ $thousand_separator ] : |
|
66 | - '.'; |
|
64 | + $default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ? |
|
65 | + $default_decimal_separators[$thousand_separator] : '.'; |
|
67 | 66 | |
68 | - $decimal_separator = ! empty( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : $default_decimal_separator; |
|
67 | + $decimal_separator = ! empty($give_options['decimal_separator']) ? $give_options['decimal_separator'] : $default_decimal_separator; |
|
69 | 68 | |
70 | 69 | $setting = array( |
71 | - 'currency_position' => give_get_option( 'currency_position', 'before' ), |
|
70 | + 'currency_position' => give_get_option('currency_position', 'before'), |
|
72 | 71 | 'thousands_separator' => $thousand_separator, |
73 | 72 | 'decimal_separator' => $decimal_separator, |
74 | - 'number_decimals' => give_get_option( 'number_decimals', 0 ), |
|
73 | + 'number_decimals' => give_get_option('number_decimals', 0), |
|
75 | 74 | ); |
76 | 75 | } |
77 | 76 | |
@@ -80,7 +79,7 @@ discard block |
||
80 | 79 | * |
81 | 80 | * @since 1.8.15 |
82 | 81 | */ |
83 | - return apply_filters( 'give_get_currency_formatting_settings', $setting, $id_or_currency_code ); |
|
82 | + return apply_filters('give_get_currency_formatting_settings', $setting, $id_or_currency_code); |
|
84 | 83 | } |
85 | 84 | |
86 | 85 | /** |
@@ -92,16 +91,16 @@ discard block |
||
92 | 91 | * |
93 | 92 | * @return mixed |
94 | 93 | */ |
95 | -function give_get_price_decimals( $id_or_currency_code = null ) { |
|
94 | +function give_get_price_decimals($id_or_currency_code = null) { |
|
96 | 95 | // Set currency on basis of donation id. |
97 | - if ( empty( $id_or_currency_code ) ) { |
|
96 | + if (empty($id_or_currency_code)) { |
|
98 | 97 | $id_or_currency_code = give_get_currency(); |
99 | 98 | } |
100 | 99 | |
101 | 100 | $number_of_decimals = 0; |
102 | 101 | |
103 | - if ( ! give_is_zero_based_currency( $id_or_currency_code ) ) { |
|
104 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
102 | + if ( ! give_is_zero_based_currency($id_or_currency_code)) { |
|
103 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
105 | 104 | $number_of_decimals = $setting['number_decimals']; |
106 | 105 | } |
107 | 106 | |
@@ -110,7 +109,7 @@ discard block |
||
110 | 109 | * |
111 | 110 | * @since 1.6 |
112 | 111 | */ |
113 | - return apply_filters( 'give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code ); |
|
112 | + return apply_filters('give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code); |
|
114 | 113 | } |
115 | 114 | |
116 | 115 | /** |
@@ -122,15 +121,15 @@ discard block |
||
122 | 121 | * |
123 | 122 | * @return mixed |
124 | 123 | */ |
125 | -function give_get_price_thousand_separator( $id_or_currency_code = null ) { |
|
126 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
124 | +function give_get_price_thousand_separator($id_or_currency_code = null) { |
|
125 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
127 | 126 | |
128 | 127 | /** |
129 | 128 | * Filter the thousand separator |
130 | 129 | * |
131 | 130 | * @since 1.6 |
132 | 131 | */ |
133 | - return apply_filters( 'give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code ); |
|
132 | + return apply_filters('give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code); |
|
134 | 133 | } |
135 | 134 | |
136 | 135 | /** |
@@ -142,15 +141,15 @@ discard block |
||
142 | 141 | * |
143 | 142 | * @return mixed |
144 | 143 | */ |
145 | -function give_get_price_decimal_separator( $id_or_currency_code = null ) { |
|
146 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
144 | +function give_get_price_decimal_separator($id_or_currency_code = null) { |
|
145 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
147 | 146 | |
148 | 147 | /** |
149 | 148 | * Filter the thousand separator |
150 | 149 | * |
151 | 150 | * @since 1.6 |
152 | 151 | */ |
153 | - return apply_filters( 'give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code ); |
|
152 | + return apply_filters('give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code); |
|
154 | 153 | } |
155 | 154 | |
156 | 155 | |
@@ -163,8 +162,8 @@ discard block |
||
163 | 162 | * |
164 | 163 | * @return string $amount Newly sanitized amount |
165 | 164 | */ |
166 | -function give_sanitize_amount_for_db( $number ) { |
|
167 | - return give_maybe_sanitize_amount( $number, array( 'number_decimals' => 6 ) ); |
|
165 | +function give_sanitize_amount_for_db($number) { |
|
166 | + return give_maybe_sanitize_amount($number, array('number_decimals' => 6)); |
|
168 | 167 | } |
169 | 168 | |
170 | 169 | /** |
@@ -177,19 +176,19 @@ discard block |
||
177 | 176 | * |
178 | 177 | * @return string $amount Newly sanitized amount |
179 | 178 | */ |
180 | -function give_maybe_sanitize_amount( $number, $args = array() ) { |
|
179 | +function give_maybe_sanitize_amount($number, $args = array()) { |
|
181 | 180 | // Bailout. |
182 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
181 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
183 | 182 | return $number; |
184 | 183 | } |
185 | 184 | |
186 | 185 | $func_args = func_get_args(); |
187 | 186 | |
188 | 187 | // Backward compatibility. |
189 | - if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) { |
|
188 | + if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) { |
|
190 | 189 | $args = array( |
191 | 190 | 'number_decimals' => $func_args[1], |
192 | - 'trim_zeros' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
191 | + 'trim_zeros' => isset($func_args[2]) ? $func_args[2] : false, |
|
193 | 192 | ); |
194 | 193 | } |
195 | 194 | |
@@ -202,23 +201,22 @@ discard block |
||
202 | 201 | ) |
203 | 202 | ); |
204 | 203 | |
205 | - $thousand_separator = give_get_price_thousand_separator( $args['currency'] ); |
|
206 | - $decimal_separator = give_get_price_decimal_separator( $args['currency'] ); |
|
207 | - $number_decimals = is_bool( $args['number_decimals'] ) ? |
|
208 | - give_get_price_decimals() : |
|
209 | - $args['number_decimals']; |
|
204 | + $thousand_separator = give_get_price_thousand_separator($args['currency']); |
|
205 | + $decimal_separator = give_get_price_decimal_separator($args['currency']); |
|
206 | + $number_decimals = is_bool($args['number_decimals']) ? |
|
207 | + give_get_price_decimals() : $args['number_decimals']; |
|
210 | 208 | |
211 | 209 | // Explode number by . decimal separator. |
212 | - $number_parts = explode( '.', $number ); |
|
210 | + $number_parts = explode('.', $number); |
|
213 | 211 | |
214 | 212 | // Remove currency symbols from number if any. |
215 | - $number = trim( str_replace( give_currency_symbols( true ), '', $number ) ); |
|
213 | + $number = trim(str_replace(give_currency_symbols(true), '', $number)); |
|
216 | 214 | |
217 | 215 | if ( |
218 | 216 | // Non formatted number. |
219 | 217 | ( |
220 | - ( false === strpos( $number, $thousand_separator ) ) && |
|
221 | - ( false === strpos( $number, $decimal_separator ) ) |
|
218 | + (false === strpos($number, $thousand_separator)) && |
|
219 | + (false === strpos($number, $decimal_separator)) |
|
222 | 220 | ) || |
223 | 221 | |
224 | 222 | // Decimal formatted number. |
@@ -228,35 +226,35 @@ discard block |
||
228 | 226 | ( |
229 | 227 | $number_decimals && |
230 | 228 | '.' === $thousand_separator && |
231 | - false !== strpos( $number, $thousand_separator ) && |
|
232 | - false === strpos( $number, $decimal_separator ) && |
|
233 | - 2 === count( $number_parts ) && |
|
234 | - ( $number_decimals >= strlen( $number_parts[1] ) ) |
|
229 | + false !== strpos($number, $thousand_separator) && |
|
230 | + false === strpos($number, $decimal_separator) && |
|
231 | + 2 === count($number_parts) && |
|
232 | + ($number_decimals >= strlen($number_parts[1])) |
|
235 | 233 | ) |
236 | 234 | ) { |
237 | - return number_format( $number, $number_decimals, '.', '' ); |
|
235 | + return number_format($number, $number_decimals, '.', ''); |
|
238 | 236 | } |
239 | 237 | |
240 | 238 | // Handle thousand separator as '.' |
241 | 239 | // Handle sanitize database values. |
242 | - $is_db_sanitize_val = ( 2 === count( $number_parts ) && |
|
243 | - is_numeric( $number_parts[0] ) && |
|
244 | - is_numeric( $number_parts[1] ) && |
|
245 | - ( 6 === strlen( $number_parts[1] ) ) ); |
|
240 | + $is_db_sanitize_val = (2 === count($number_parts) && |
|
241 | + is_numeric($number_parts[0]) && |
|
242 | + is_numeric($number_parts[1]) && |
|
243 | + (6 === strlen($number_parts[1]))); |
|
246 | 244 | |
247 | - if ( $is_db_sanitize_val ) { |
|
245 | + if ($is_db_sanitize_val) { |
|
248 | 246 | // Sanitize database value. |
249 | - return number_format( $number, $number_decimals, '.', '' ); |
|
247 | + return number_format($number, $number_decimals, '.', ''); |
|
250 | 248 | |
251 | 249 | } elseif ( |
252 | 250 | '.' === $thousand_separator && |
253 | - false !== strpos( $number, $thousand_separator ) |
|
251 | + false !== strpos($number, $thousand_separator) |
|
254 | 252 | ) { |
255 | 253 | // Fix point thousand separator value. |
256 | - $number = str_replace( '.', '', $number ); |
|
254 | + $number = str_replace('.', '', $number); |
|
257 | 255 | } |
258 | 256 | |
259 | - return give_sanitize_amount( $number, $args ); |
|
257 | + return give_sanitize_amount($number, $args); |
|
260 | 258 | } |
261 | 259 | |
262 | 260 | /** |
@@ -273,10 +271,10 @@ discard block |
||
273 | 271 | * |
274 | 272 | * @return string $amount Newly sanitized amount |
275 | 273 | */ |
276 | -function give_sanitize_amount( $number, $args = array() ) { |
|
274 | +function give_sanitize_amount($number, $args = array()) { |
|
277 | 275 | |
278 | 276 | // Bailout. |
279 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
277 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
280 | 278 | return $number; |
281 | 279 | } |
282 | 280 | |
@@ -284,10 +282,10 @@ discard block |
||
284 | 282 | $func_args = func_get_args(); |
285 | 283 | |
286 | 284 | // Backward compatibility. |
287 | - if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) { |
|
285 | + if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) { |
|
288 | 286 | $args = array( |
289 | 287 | 'number_decimals' => $func_args[1], |
290 | - 'trim_zeros' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
288 | + 'trim_zeros' => isset($func_args[2]) ? $func_args[2] : false, |
|
291 | 289 | ); |
292 | 290 | } |
293 | 291 | |
@@ -303,58 +301,58 @@ discard block |
||
303 | 301 | // Remove slash from amount. |
304 | 302 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
305 | 303 | // To prevent notices and warning remove slash from amount/number. |
306 | - $number = wp_unslash( $number ); |
|
304 | + $number = wp_unslash($number); |
|
307 | 305 | |
308 | - $thousand_separator = give_get_price_thousand_separator( $args['currency'] ); |
|
306 | + $thousand_separator = give_get_price_thousand_separator($args['currency']); |
|
309 | 307 | |
310 | 308 | $locale = localeconv(); |
311 | 309 | $decimals = array( |
312 | - give_get_price_decimal_separator( $args['currency'] ), |
|
310 | + give_get_price_decimal_separator($args['currency']), |
|
313 | 311 | $locale['decimal_point'], |
314 | 312 | $locale['mon_decimal_point'], |
315 | 313 | ); |
316 | 314 | |
317 | 315 | // Remove locale from string |
318 | - if ( ! is_float( $number ) ) { |
|
319 | - $number = str_replace( $decimals, '.', $number ); |
|
316 | + if ( ! is_float($number)) { |
|
317 | + $number = str_replace($decimals, '.', $number); |
|
320 | 318 | } |
321 | 319 | |
322 | 320 | // Remove thousand amount formatting if amount has. |
323 | 321 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
324 | 322 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
325 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
326 | - $number = str_replace( $thousand_separator, '', $number ); |
|
327 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
328 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
323 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
324 | + $number = str_replace($thousand_separator, '', $number); |
|
325 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
326 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
329 | 327 | } |
330 | 328 | |
331 | 329 | // Remove non numeric entity before decimal separator. |
332 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
333 | - $default_dp = give_get_price_decimals( $args['currency'] ); |
|
330 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
331 | + $default_dp = give_get_price_decimals($args['currency']); |
|
334 | 332 | |
335 | 333 | // Reset negative amount to zero. |
336 | - if ( 0 > $number ) { |
|
337 | - $number = number_format( 0, $default_dp, '.' ); |
|
334 | + if (0 > $number) { |
|
335 | + $number = number_format(0, $default_dp, '.'); |
|
338 | 336 | } |
339 | 337 | |
340 | 338 | // If number does not have decimal then add number of decimals to it. |
341 | 339 | if ( |
342 | - false === strpos( $number, '.' ) |
|
343 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
340 | + false === strpos($number, '.') |
|
341 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
344 | 342 | ) { |
345 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
343 | + $number = number_format($number, $default_dp, '.', ''); |
|
346 | 344 | } |
347 | 345 | |
348 | 346 | // Format number by custom number of decimals. |
349 | - if ( false !== $args['number_decimals'] ) { |
|
350 | - $dp = intval( is_bool( $args['number_decimals'] ) ? $default_dp : $args['number_decimals'] ); |
|
351 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
352 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
347 | + if (false !== $args['number_decimals']) { |
|
348 | + $dp = intval(is_bool($args['number_decimals']) ? $default_dp : $args['number_decimals']); |
|
349 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
350 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
353 | 351 | } |
354 | 352 | |
355 | 353 | // Trim zeros. |
356 | - if ( $args['trim_zeros'] && strstr( $number, '.' ) ) { |
|
357 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
354 | + if ($args['trim_zeros'] && strstr($number, '.')) { |
|
355 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
358 | 356 | } |
359 | 357 | |
360 | 358 | /** |
@@ -362,7 +360,7 @@ discard block |
||
362 | 360 | * |
363 | 361 | * @since 1.0 |
364 | 362 | */ |
365 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
363 | + return apply_filters('give_sanitize_amount', $number); |
|
366 | 364 | } |
367 | 365 | |
368 | 366 | /** |
@@ -375,9 +373,9 @@ discard block |
||
375 | 373 | * |
376 | 374 | * @return string $amount Newly formatted amount or Price Not Available |
377 | 375 | */ |
378 | -function give_format_amount( $amount, $args = array() ) { |
|
376 | +function give_format_amount($amount, $args = array()) { |
|
379 | 377 | // Backward compatibility. |
380 | - if ( is_bool( $args ) ) { |
|
378 | + if (is_bool($args)) { |
|
381 | 379 | $args = array( |
382 | 380 | 'decimal' => $args, |
383 | 381 | ); |
@@ -390,61 +388,60 @@ discard block |
||
390 | 388 | 'currency' => '', |
391 | 389 | ); |
392 | 390 | |
393 | - $args = wp_parse_args( $args, $default_args ); |
|
391 | + $args = wp_parse_args($args, $default_args); |
|
394 | 392 | |
395 | 393 | // Set Currency based on donation id, if required. |
396 | - if ( $args['donation_id'] && empty( $args['currency'] ) ) { |
|
397 | - $donation_meta = give_get_meta( $args['donation_id'], '_give_payment_meta', true ); |
|
394 | + if ($args['donation_id'] && empty($args['currency'])) { |
|
395 | + $donation_meta = give_get_meta($args['donation_id'], '_give_payment_meta', true); |
|
398 | 396 | $args['currency'] = $donation_meta['currency']; |
399 | 397 | } |
400 | 398 | |
401 | 399 | $formatted = 0; |
402 | - $currency = ! empty( $args['currency'] ) ? $args['currency'] : give_get_currency( $args['donation_id'] ); |
|
403 | - $thousands_sep = give_get_price_thousand_separator( $currency ); |
|
404 | - $decimal_sep = give_get_price_decimal_separator( $currency ); |
|
405 | - $decimals = ! empty( $args['decimal'] ) ? give_get_price_decimals( $currency ) : 0; |
|
400 | + $currency = ! empty($args['currency']) ? $args['currency'] : give_get_currency($args['donation_id']); |
|
401 | + $thousands_sep = give_get_price_thousand_separator($currency); |
|
402 | + $decimal_sep = give_get_price_decimal_separator($currency); |
|
403 | + $decimals = ! empty($args['decimal']) ? give_get_price_decimals($currency) : 0; |
|
406 | 404 | |
407 | - if ( ! empty( $amount ) ) { |
|
405 | + if ( ! empty($amount)) { |
|
408 | 406 | // Sanitize amount before formatting. |
409 | - $amount = ! empty( $args['sanitize'] ) ? |
|
410 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $decimals, 'currency' => $currency ) ) : |
|
411 | - number_format( $amount, $decimals, '.', '' ); |
|
407 | + $amount = ! empty($args['sanitize']) ? |
|
408 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $decimals, 'currency' => $currency)) : number_format($amount, $decimals, '.', ''); |
|
412 | 409 | |
413 | - switch ( $currency ) { |
|
410 | + switch ($currency) { |
|
414 | 411 | case 'INR': |
415 | 412 | $decimal_amount = ''; |
416 | 413 | |
417 | 414 | // Extract decimals from amount |
418 | - if ( ( $pos = strpos( $amount, '.' ) ) !== false ) { |
|
419 | - if ( ! empty( $decimals ) ) { |
|
420 | - $decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 ); |
|
421 | - $amount = substr( $amount, 0, $pos ); |
|
422 | - |
|
423 | - if ( ! $decimal_amount ) { |
|
424 | - $decimal_amount = substr( "{$decimal_sep}0000000000", 0, ( $decimals + 1 ) ); |
|
425 | - } elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) { |
|
426 | - $decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) ); |
|
415 | + if (($pos = strpos($amount, '.')) !== false) { |
|
416 | + if ( ! empty($decimals)) { |
|
417 | + $decimal_amount = substr(round(substr($amount, $pos), $decimals), 1); |
|
418 | + $amount = substr($amount, 0, $pos); |
|
419 | + |
|
420 | + if ( ! $decimal_amount) { |
|
421 | + $decimal_amount = substr("{$decimal_sep}0000000000", 0, ($decimals + 1)); |
|
422 | + } elseif (($decimals + 1) > strlen($decimal_amount)) { |
|
423 | + $decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1)); |
|
427 | 424 | } |
428 | 425 | } else { |
429 | - $amount = number_format( $amount, $decimals, $decimal_sep, '' ); |
|
426 | + $amount = number_format($amount, $decimals, $decimal_sep, ''); |
|
430 | 427 | } |
431 | 428 | } |
432 | 429 | |
433 | 430 | // Extract last 3 from amount |
434 | - $result = substr( $amount, - 3 ); |
|
435 | - $amount = substr( $amount, 0, - 3 ); |
|
431 | + $result = substr($amount, - 3); |
|
432 | + $amount = substr($amount, 0, - 3); |
|
436 | 433 | |
437 | 434 | // Apply digits 2 by 2 |
438 | - while ( strlen( $amount ) > 0 ) { |
|
439 | - $result = substr( $amount, - 2 ) . $thousands_sep . $result; |
|
440 | - $amount = substr( $amount, 0, - 2 ); |
|
435 | + while (strlen($amount) > 0) { |
|
436 | + $result = substr($amount, - 2).$thousands_sep.$result; |
|
437 | + $amount = substr($amount, 0, - 2); |
|
441 | 438 | } |
442 | 439 | |
443 | - $formatted = $result . $decimal_amount; |
|
440 | + $formatted = $result.$decimal_amount; |
|
444 | 441 | break; |
445 | 442 | |
446 | 443 | default: |
447 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
444 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
448 | 445 | } |
449 | 446 | } |
450 | 447 | |
@@ -453,7 +450,7 @@ discard block |
||
453 | 450 | * |
454 | 451 | * @since 1.0 |
455 | 452 | */ |
456 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args ); |
|
453 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args); |
|
457 | 454 | } |
458 | 455 | |
459 | 456 | |
@@ -471,17 +468,17 @@ discard block |
||
471 | 468 | * |
472 | 469 | * @return string formatted amount number with large number names. |
473 | 470 | */ |
474 | -function give_human_format_large_amount( $amount, $args = array() ) { |
|
471 | +function give_human_format_large_amount($amount, $args = array()) { |
|
475 | 472 | // Sanitize amount. |
476 | - $sanitize_amount = give_maybe_sanitize_amount( $amount ); |
|
473 | + $sanitize_amount = give_maybe_sanitize_amount($amount); |
|
477 | 474 | |
478 | 475 | // Bailout. |
479 | - if ( ! floatval( $sanitize_amount ) ) { |
|
476 | + if ( ! floatval($sanitize_amount)) { |
|
480 | 477 | return '0'; |
481 | 478 | }; |
482 | 479 | |
483 | 480 | // Set default currency; |
484 | - if ( empty( $args['currency'] ) ) { |
|
481 | + if (empty($args['currency'])) { |
|
485 | 482 | $args['currency'] = give_get_currency(); |
486 | 483 | } |
487 | 484 | |
@@ -489,37 +486,37 @@ discard block |
||
489 | 486 | $thousands_sep = give_get_price_thousand_separator(); |
490 | 487 | |
491 | 488 | // Explode amount to calculate name of large numbers. |
492 | - $amount_array = explode( $thousands_sep, $amount ); |
|
489 | + $amount_array = explode($thousands_sep, $amount); |
|
493 | 490 | |
494 | 491 | // Calculate amount parts count. |
495 | - $amount_count_parts = count( $amount_array ); |
|
492 | + $amount_count_parts = count($amount_array); |
|
496 | 493 | |
497 | 494 | // Human format amount (default). |
498 | 495 | $human_format_amount = $amount; |
499 | 496 | |
500 | - switch ( $args['currency'] ) { |
|
497 | + switch ($args['currency']) { |
|
501 | 498 | case 'INR': |
502 | 499 | // Calculate large number formatted amount. |
503 | - if ( 4 < $amount_count_parts ) { |
|
504 | - $human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
505 | - } elseif ( 3 < $amount_count_parts ) { |
|
506 | - $human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) ); |
|
507 | - } elseif ( 2 < $amount_count_parts ) { |
|
508 | - $human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) ); |
|
500 | + if (4 < $amount_count_parts) { |
|
501 | + $human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
502 | + } elseif (3 < $amount_count_parts) { |
|
503 | + $human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2)); |
|
504 | + } elseif (2 < $amount_count_parts) { |
|
505 | + $human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2)); |
|
509 | 506 | } |
510 | 507 | break; |
511 | 508 | default: |
512 | 509 | // Calculate large number formatted amount. |
513 | - if ( 4 < $amount_count_parts ) { |
|
514 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
515 | - } elseif ( 3 < $amount_count_parts ) { |
|
516 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
517 | - } elseif ( 2 < $amount_count_parts ) { |
|
518 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
510 | + if (4 < $amount_count_parts) { |
|
511 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
512 | + } elseif (3 < $amount_count_parts) { |
|
513 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
514 | + } elseif (2 < $amount_count_parts) { |
|
515 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
519 | 516 | } |
520 | 517 | } |
521 | 518 | |
522 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
519 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
523 | 520 | } |
524 | 521 | |
525 | 522 | /** |
@@ -533,17 +530,16 @@ discard block |
||
533 | 530 | * |
534 | 531 | * @return string $amount Newly formatted amount or Price Not Available |
535 | 532 | */ |
536 | -function give_format_decimal( $amount, $dp = false, $sanitize = true ) { |
|
533 | +function give_format_decimal($amount, $dp = false, $sanitize = true) { |
|
537 | 534 | $decimal_separator = give_get_price_decimal_separator(); |
538 | 535 | $formatted_amount = $sanitize ? |
539 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $dp ) ) : |
|
540 | - number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
536 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $dp)) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
541 | 537 | |
542 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
543 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
538 | + if (false !== strpos($formatted_amount, '.')) { |
|
539 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
544 | 540 | } |
545 | 541 | |
546 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
542 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
547 | 543 | } |
548 | 544 | |
549 | 545 | /** |
@@ -555,7 +551,7 @@ discard block |
||
555 | 551 | * |
556 | 552 | * @return string Date format string |
557 | 553 | */ |
558 | -function give_date_format( $date_context = '' ) { |
|
554 | +function give_date_format($date_context = '') { |
|
559 | 555 | /** |
560 | 556 | * Filter the date context |
561 | 557 | * |
@@ -576,19 +572,19 @@ discard block |
||
576 | 572 | * |
577 | 573 | * } |
578 | 574 | */ |
579 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
575 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
580 | 576 | |
581 | 577 | // Set date format to default date format. |
582 | - $date_format = get_option( 'date_format' ); |
|
578 | + $date_format = get_option('date_format'); |
|
583 | 579 | |
584 | 580 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
585 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
586 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
587 | - ? $date_format_contexts[ $date_context ] |
|
581 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
582 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
583 | + ? $date_format_contexts[$date_context] |
|
588 | 584 | : $date_format; |
589 | 585 | } |
590 | 586 | |
591 | - return apply_filters( 'give_date_format', $date_format ); |
|
587 | + return apply_filters('give_date_format', $date_format); |
|
592 | 588 | } |
593 | 589 | |
594 | 590 | /** |
@@ -602,8 +598,8 @@ discard block |
||
602 | 598 | * |
603 | 599 | * @return string |
604 | 600 | */ |
605 | -function give_get_cache_key( $action, $query_args ) { |
|
606 | - return Give_Cache::get_key( $action, $query_args ); |
|
601 | +function give_get_cache_key($action, $query_args) { |
|
602 | + return Give_Cache::get_key($action, $query_args); |
|
607 | 603 | } |
608 | 604 | |
609 | 605 | /** |
@@ -616,11 +612,11 @@ discard block |
||
616 | 612 | * |
617 | 613 | * @return string|array |
618 | 614 | */ |
619 | -function give_clean( $var ) { |
|
620 | - if ( is_array( $var ) ) { |
|
621 | - return array_map( 'give_clean', $var ); |
|
615 | +function give_clean($var) { |
|
616 | + if (is_array($var)) { |
|
617 | + return array_map('give_clean', $var); |
|
622 | 618 | } else { |
623 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
619 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
624 | 620 | } |
625 | 621 | } |
626 | 622 | |
@@ -633,10 +629,10 @@ discard block |
||
633 | 629 | * |
634 | 630 | * @return int |
635 | 631 | */ |
636 | -function give_let_to_num( $size ) { |
|
637 | - $l = substr( $size, - 1 ); |
|
638 | - $ret = substr( $size, 0, - 1 ); |
|
639 | - switch ( strtoupper( $l ) ) { |
|
632 | +function give_let_to_num($size) { |
|
633 | + $l = substr($size, - 1); |
|
634 | + $ret = substr($size, 0, - 1); |
|
635 | + switch (strtoupper($l)) { |
|
640 | 636 | case 'P': |
641 | 637 | $ret *= 1024; |
642 | 638 | case 'T': |
@@ -663,22 +659,22 @@ discard block |
||
663 | 659 | * |
664 | 660 | * @return bool |
665 | 661 | */ |
666 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
662 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
667 | 663 | |
668 | 664 | // Verify nonce. |
669 | - $verify_nonce = wp_verify_nonce( $nonce, $action ); |
|
665 | + $verify_nonce = wp_verify_nonce($nonce, $action); |
|
670 | 666 | |
671 | 667 | // On ajax request send nonce verification status. |
672 | - if ( wp_doing_ajax() ) { |
|
668 | + if (wp_doing_ajax()) { |
|
673 | 669 | return $verify_nonce; |
674 | 670 | } |
675 | 671 | |
676 | - if ( ! $verify_nonce ) { |
|
672 | + if ( ! $verify_nonce) { |
|
677 | 673 | $wp_die_args = wp_parse_args( |
678 | 674 | $wp_die_args, |
679 | 675 | array( |
680 | - 'message' => __( 'Nonce verification has failed.', 'give' ), |
|
681 | - 'title' => __( 'Error', 'give' ), |
|
676 | + 'message' => __('Nonce verification has failed.', 'give'), |
|
677 | + 'title' => __('Error', 'give'), |
|
682 | 678 | 'args' => array( |
683 | 679 | 'response' => 403, |
684 | 680 | ) |
@@ -704,19 +700,19 @@ discard block |
||
704 | 700 | * |
705 | 701 | * @return bool |
706 | 702 | */ |
707 | -function give_verify_donation_form_nonce( $nonce = '' ) { |
|
703 | +function give_verify_donation_form_nonce($nonce = '') { |
|
708 | 704 | // Get nonce key from donation. |
709 | - $nonce = empty( $nonce ) ? give_clean( $_POST['_wpnonce'] ) : $nonce; |
|
710 | - $form_id = isset( $_POST['give-form-id'] ) ? absint( $_POST['give-form-id'] ) : 0; |
|
705 | + $nonce = empty($nonce) ? give_clean($_POST['_wpnonce']) : $nonce; |
|
706 | + $form_id = isset($_POST['give-form-id']) ? absint($_POST['give-form-id']) : 0; |
|
711 | 707 | |
712 | 708 | // Form nonce action. |
713 | 709 | $nonce_action = "donation_form_nonce_{$form_id}"; |
714 | 710 | |
715 | 711 | // Nonce validation. |
716 | - $verify_nonce = give_validate_nonce( $nonce, $nonce_action ); |
|
712 | + $verify_nonce = give_validate_nonce($nonce, $nonce_action); |
|
717 | 713 | |
718 | - if ( ! $verify_nonce ) { |
|
719 | - give_set_error( 'donation_form_nonce', __( 'Nonce verification has failed.', 'give' ) ); |
|
714 | + if ( ! $verify_nonce) { |
|
715 | + give_set_error('donation_form_nonce', __('Nonce verification has failed.', 'give')); |
|
720 | 716 | } |
721 | 717 | |
722 | 718 | return $verify_nonce; |
@@ -736,43 +732,43 @@ discard block |
||
736 | 732 | * |
737 | 733 | * @return mixed |
738 | 734 | */ |
739 | -function give_check_variable( $variable, $conditional = '', $default = false, $array_key_name = '' ) { |
|
735 | +function give_check_variable($variable, $conditional = '', $default = false, $array_key_name = '') { |
|
740 | 736 | // Get value from array if array key non empty. |
741 | - if( empty( $array_key_name ) ) { |
|
742 | - switch ( $conditional ) { |
|
737 | + if (empty($array_key_name)) { |
|
738 | + switch ($conditional) { |
|
743 | 739 | case 'isset_empty': |
744 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
740 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
745 | 741 | break; |
746 | 742 | |
747 | 743 | case 'empty': |
748 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
744 | + $variable = ! empty($variable) ? $variable : $default; |
|
749 | 745 | break; |
750 | 746 | |
751 | 747 | case 'null': |
752 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
748 | + $variable = ! is_null($variable) ? $variable : $default; |
|
753 | 749 | break; |
754 | 750 | |
755 | 751 | default: |
756 | - $variable = isset( $variable ) ? $variable : $default; |
|
752 | + $variable = isset($variable) ? $variable : $default; |
|
757 | 753 | } |
758 | 754 | } else { |
759 | - $isset = array_key_exists( $array_key_name, $variable ); |
|
755 | + $isset = array_key_exists($array_key_name, $variable); |
|
760 | 756 | |
761 | - switch ( $conditional ) { |
|
757 | + switch ($conditional) { |
|
762 | 758 | case 'isset_empty': |
763 | - $variable = ( $isset && ! empty( $variable[ $array_key_name ] ) ) ? $variable[ $array_key_name ] : $default; |
|
759 | + $variable = ($isset && ! empty($variable[$array_key_name])) ? $variable[$array_key_name] : $default; |
|
764 | 760 | break; |
765 | 761 | |
766 | 762 | case 'empty': |
767 | - $variable = ! empty( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
763 | + $variable = ! empty($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
768 | 764 | break; |
769 | 765 | |
770 | 766 | case 'null': |
771 | - $variable = $isset && ! is_null( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
767 | + $variable = $isset && ! is_null($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
772 | 768 | break; |
773 | 769 | |
774 | 770 | default: |
775 | - $variable = $isset && isset( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
771 | + $variable = $isset && isset($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
776 | 772 | } |
777 | 773 | } |
778 | 774 |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* @var Give_Updates $give_updates */ |
3 | -$plugins = $give_updates->get_updates( 'plugin' ); |
|
4 | -if ( empty( $plugins ) ) { |
|
3 | +$plugins = $give_updates->get_updates('plugin'); |
|
4 | +if (empty($plugins)) { |
|
5 | 5 | return; |
6 | 6 | } |
7 | 7 | |
8 | 8 | ob_start(); |
9 | -foreach ( $plugins as $plugin_data ) { |
|
10 | - if ( 'active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type'] ) { |
|
9 | +foreach ($plugins as $plugin_data) { |
|
10 | + if ('active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type']) { |
|
11 | 11 | continue; |
12 | 12 | } |
13 | 13 | |
@@ -15,36 +15,36 @@ discard block |
||
15 | 15 | $author_name = $plugin_data['Author']; |
16 | 16 | |
17 | 17 | // Link the plugin name to the plugin URL if available. |
18 | - if ( ! empty( $plugin_data['PluginURI'] ) ) { |
|
18 | + if ( ! empty($plugin_data['PluginURI'])) { |
|
19 | 19 | $plugin_name = sprintf( |
20 | 20 | '<a href="%s" title="%s">%s</a> (%s)', |
21 | - esc_url( $plugin_data['PluginURI'] ), |
|
22 | - esc_attr__( 'Visit plugin homepage', 'give' ), |
|
21 | + esc_url($plugin_data['PluginURI']), |
|
22 | + esc_attr__('Visit plugin homepage', 'give'), |
|
23 | 23 | $plugin_name, |
24 | - esc_html( $plugin_data['Version'] ) |
|
24 | + esc_html($plugin_data['Version']) |
|
25 | 25 | ); |
26 | 26 | } |
27 | 27 | |
28 | 28 | // Link the author name to the author URL if available. |
29 | - if ( ! empty( $plugin_data['AuthorURI'] ) ) { |
|
29 | + if ( ! empty($plugin_data['AuthorURI'])) { |
|
30 | 30 | $author_name = sprintf( |
31 | 31 | '<a href="%s" title="%s">%s</a>', |
32 | - esc_url( $plugin_data['AuthorURI'] ), |
|
33 | - esc_attr__( 'Visit author homepage', 'give' ), |
|
32 | + esc_url($plugin_data['AuthorURI']), |
|
33 | + esc_attr__('Visit author homepage', 'give'), |
|
34 | 34 | $author_name |
35 | 35 | ); |
36 | 36 | } |
37 | 37 | ?> |
38 | - <tr <?php echo( true !== $plugin_data['License'] ? 'data-tooltip="' . __( 'Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give' ) . '"' : '' ); ?>> |
|
39 | - <td><?php echo wp_kses( $plugin_name, wp_kses_allowed_html( 'post' ) ); ?></td> |
|
38 | + <tr <?php echo(true !== $plugin_data['License'] ? 'data-tooltip="'.__('Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give').'"' : ''); ?>> |
|
39 | + <td><?php echo wp_kses($plugin_name, wp_kses_allowed_html('post')); ?></td> |
|
40 | 40 | <td> |
41 | 41 | <?php |
42 | - echo ( true === $plugin_data['License'] ) ? '<span class="dashicons dashicons-yes"></span>' . __( 'Licensed', 'give' ) : '<span class="dashicons dashicons-no-alt"></span>' . __( 'Unlicensed', 'give' ); |
|
42 | + echo (true === $plugin_data['License']) ? '<span class="dashicons dashicons-yes"></span>'.__('Licensed', 'give') : '<span class="dashicons dashicons-no-alt"></span>'.__('Unlicensed', 'give'); |
|
43 | 43 | |
44 | 44 | echo sprintf( |
45 | 45 | ' – %s – %s', |
46 | - sprintf( _x( 'by %s', 'by author', 'give' ), wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ), |
|
47 | - sprintf( __( '(Latest Version: %s)' ), $plugin_data['update']->new_version ) |
|
46 | + sprintf(_x('by %s', 'by author', 'give'), wp_kses($author_name, wp_kses_allowed_html('post'))), |
|
47 | + sprintf(__('(Latest Version: %s)'), $plugin_data['update']->new_version) |
|
48 | 48 | ); |
49 | 49 | ?> |
50 | 50 | </td> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | * @return array $form_columns Updated array of forms columns |
28 | 28 | * Post Type List Table |
29 | 29 | */ |
30 | -function give_form_columns( $give_form_columns ) { |
|
30 | +function give_form_columns($give_form_columns) { |
|
31 | 31 | |
32 | 32 | // Standard columns |
33 | 33 | $give_form_columns = array( |
34 | 34 | 'cb' => '<input type="checkbox"/>', |
35 | - 'title' => __( 'Name', 'give' ), |
|
36 | - 'form_category' => __( 'Categories', 'give' ), |
|
37 | - 'form_tag' => __( 'Tags', 'give' ), |
|
38 | - 'price' => __( 'Amount', 'give' ), |
|
39 | - 'goal' => __( 'Goal', 'give' ), |
|
40 | - 'donations' => __( 'Donations', 'give' ), |
|
41 | - 'earnings' => __( 'Income', 'give' ), |
|
42 | - 'shortcode' => __( 'Shortcode', 'give' ), |
|
43 | - 'date' => __( 'Date', 'give' ), |
|
35 | + 'title' => __('Name', 'give'), |
|
36 | + 'form_category' => __('Categories', 'give'), |
|
37 | + 'form_tag' => __('Tags', 'give'), |
|
38 | + 'price' => __('Amount', 'give'), |
|
39 | + 'goal' => __('Goal', 'give'), |
|
40 | + 'donations' => __('Donations', 'give'), |
|
41 | + 'earnings' => __('Income', 'give'), |
|
42 | + 'shortcode' => __('Shortcode', 'give'), |
|
43 | + 'date' => __('Date', 'give'), |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | // Does the user want categories / tags? |
47 | - if ( ! give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
48 | - unset( $give_form_columns['form_category'] ); |
|
47 | + if ( ! give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
48 | + unset($give_form_columns['form_category']); |
|
49 | 49 | } |
50 | - if ( ! give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
51 | - unset( $give_form_columns['form_tag'] ); |
|
50 | + if ( ! give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
51 | + unset($give_form_columns['form_tag']); |
|
52 | 52 | } |
53 | 53 | |
54 | - return apply_filters( 'give_forms_columns', $give_form_columns ); |
|
54 | + return apply_filters('give_forms_columns', $give_form_columns); |
|
55 | 55 | } |
56 | 56 | |
57 | -add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' ); |
|
57 | +add_filter('manage_edit-give_forms_columns', 'give_form_columns'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Render Give Form Columns |
@@ -66,59 +66,59 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return void |
68 | 68 | */ |
69 | -function give_render_form_columns( $column_name, $post_id ) { |
|
70 | - if ( get_post_type( $post_id ) == 'give_forms' ) { |
|
69 | +function give_render_form_columns($column_name, $post_id) { |
|
70 | + if (get_post_type($post_id) == 'give_forms') { |
|
71 | 71 | |
72 | - switch ( $column_name ) { |
|
72 | + switch ($column_name) { |
|
73 | 73 | case 'form_category': |
74 | - echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' ); |
|
74 | + echo get_the_term_list($post_id, 'give_forms_category', '', ', ', ''); |
|
75 | 75 | break; |
76 | 76 | case 'form_tag': |
77 | - echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' ); |
|
77 | + echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', ''); |
|
78 | 78 | break; |
79 | 79 | case 'price': |
80 | - if ( give_has_variable_prices( $post_id ) ) { |
|
81 | - echo give_price_range( $post_id ); |
|
80 | + if (give_has_variable_prices($post_id)) { |
|
81 | + echo give_price_range($post_id); |
|
82 | 82 | } else { |
83 | - echo give_price( $post_id, false ); |
|
84 | - echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />'; |
|
83 | + echo give_price($post_id, false); |
|
84 | + echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />'; |
|
85 | 85 | } |
86 | 86 | break; |
87 | 87 | case 'goal': |
88 | - if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) { |
|
89 | - echo give_goal( $post_id, false ); |
|
88 | + if (give_is_setting_enabled(give_get_meta($post_id, '_give_goal_option', true))) { |
|
89 | + echo give_goal($post_id, false); |
|
90 | 90 | } else { |
91 | - esc_html_e( 'No Goal Set', 'give' ); |
|
91 | + esc_html_e('No Goal Set', 'give'); |
|
92 | 92 | } |
93 | 93 | |
94 | - echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />'; |
|
94 | + echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />'; |
|
95 | 95 | break; |
96 | 96 | case 'donations': |
97 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
98 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . $post_id ) ) . '">'; |
|
99 | - echo give_get_form_sales_stats( $post_id ); |
|
97 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
98 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.$post_id)).'">'; |
|
99 | + echo give_get_form_sales_stats($post_id); |
|
100 | 100 | echo '</a>'; |
101 | 101 | } else { |
102 | 102 | echo '-'; |
103 | 103 | } |
104 | 104 | break; |
105 | 105 | case 'earnings': |
106 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
107 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $post_id ) ) . '">'; |
|
108 | - echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), array( 'sanitize' => false ) ) ); |
|
106 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
107 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$post_id)).'">'; |
|
108 | + echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id), array('sanitize' => false))); |
|
109 | 109 | echo '</a>'; |
110 | 110 | } else { |
111 | 111 | echo '-'; |
112 | 112 | } |
113 | 113 | break; |
114 | 114 | case 'shortcode': |
115 | - echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="' . absint( $post_id ) . '"]">'; |
|
115 | + echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="'.absint($post_id).'"]">'; |
|
116 | 116 | break; |
117 | 117 | }// End switch(). |
118 | 118 | }// End if(). |
119 | 119 | } |
120 | 120 | |
121 | -add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 ); |
|
121 | +add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Registers the sortable columns in the list table |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array $columns Array of sortable columns |
131 | 131 | */ |
132 | -function give_sortable_form_columns( $columns ) { |
|
132 | +function give_sortable_form_columns($columns) { |
|
133 | 133 | $columns['price'] = 'amount'; |
134 | 134 | $columns['sales'] = 'sales'; |
135 | 135 | $columns['earnings'] = 'earnings'; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | return $columns; |
140 | 140 | } |
141 | 141 | |
142 | -add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' ); |
|
142 | +add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Sorts Columns in the Forms List Table |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return array $vars Array of all the sort variables. |
152 | 152 | */ |
153 | -function give_sort_forms( $vars ) { |
|
153 | +function give_sort_forms($vars) { |
|
154 | 154 | // Check if we're viewing the "give_forms" post type. |
155 | - if ( ! isset( $vars['post_type'] ) || ! isset( $vars['orderby'] ) || 'give_forms' !== $vars['post_type'] ) { |
|
155 | + if ( ! isset($vars['post_type']) || ! isset($vars['orderby']) || 'give_forms' !== $vars['post_type']) { |
|
156 | 156 | return $vars; |
157 | 157 | } |
158 | 158 | |
159 | - switch ( $vars['orderby'] ) { |
|
159 | + switch ($vars['orderby']) { |
|
160 | 160 | // Check if 'orderby' is set to "sales". |
161 | 161 | case 'sales': |
162 | 162 | $vars = array_merge( |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | // Check if "orderby" is set to "price/amount". |
183 | 183 | case 'amount': |
184 | - $multi_level_meta_key = ( 'asc' === $vars['order'] ) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount'; |
|
184 | + $multi_level_meta_key = ('asc' === $vars['order']) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount'; |
|
185 | 185 | |
186 | 186 | $vars['orderby'] = 'meta_value_num'; |
187 | 187 | $vars['meta_query'] = array( |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return array Array of all sort variables. |
235 | 235 | */ |
236 | -function give_filter_forms( $vars ) { |
|
237 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
236 | +function give_filter_forms($vars) { |
|
237 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
238 | 238 | |
239 | 239 | // If an author ID was passed, use it |
240 | - if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) { |
|
240 | + if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) { |
|
241 | 241 | |
242 | 242 | $author_id = $_REQUEST['author']; |
243 | - if ( (int) $author_id !== get_current_user_id() ) { |
|
244 | - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
243 | + if ((int) $author_id !== get_current_user_id()) { |
|
244 | + wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array( |
|
245 | 245 | 'response' => 403, |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | $vars = array_merge( |
249 | 249 | $vars, |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | * @return void |
268 | 268 | */ |
269 | 269 | function give_forms_load() { |
270 | - add_filter( 'request', 'give_sort_forms' ); |
|
271 | - add_filter( 'request', 'give_filter_forms' ); |
|
270 | + add_filter('request', 'give_sort_forms'); |
|
271 | + add_filter('request', 'give_filter_forms'); |
|
272 | 272 | } |
273 | 273 | |
274 | -add_action( 'load-edit.php', 'give_forms_load', 9999 ); |
|
274 | +add_action('load-edit.php', 'give_forms_load', 9999); |
|
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Remove Forms Month Filter |
@@ -285,17 +285,17 @@ discard block |
||
285 | 285 | * @global $typenow The post type we are viewing. |
286 | 286 | * @return array Empty array disables the dropdown. |
287 | 287 | */ |
288 | -function give_remove_month_filter( $dates ) { |
|
288 | +function give_remove_month_filter($dates) { |
|
289 | 289 | global $typenow; |
290 | 290 | |
291 | - if ( $typenow == 'give_forms' ) { |
|
291 | + if ($typenow == 'give_forms') { |
|
292 | 292 | $dates = array(); |
293 | 293 | } |
294 | 294 | |
295 | 295 | return $dates; |
296 | 296 | } |
297 | 297 | |
298 | -add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 ); |
|
298 | +add_filter('months_dropdown_results', 'give_remove_month_filter', 99); |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Updates price when saving post |
@@ -306,23 +306,23 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @return int|null |
308 | 308 | */ |
309 | -function give_price_save_quick_edit( $post_id ) { |
|
310 | - if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
|
309 | +function give_price_save_quick_edit($post_id) { |
|
310 | + if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
313 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
314 | 314 | return $post_id; |
315 | 315 | } |
316 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
316 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
317 | 317 | return $post_id; |
318 | 318 | } |
319 | 319 | |
320 | - if ( isset( $_REQUEST['_give_regprice'] ) ) { |
|
321 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ) ); |
|
320 | + if (isset($_REQUEST['_give_regprice'])) { |
|
321 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db(strip_tags(stripslashes($_REQUEST['_give_regprice'])))); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | -add_action( 'save_post', 'give_price_save_quick_edit' ); |
|
325 | +add_action('save_post', 'give_price_save_quick_edit'); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Process bulk edit actions via AJAX |
@@ -332,18 +332,18 @@ discard block |
||
332 | 332 | */ |
333 | 333 | function give_save_bulk_edit() { |
334 | 334 | |
335 | - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
|
335 | + $post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
336 | 336 | |
337 | - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { |
|
338 | - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0; |
|
339 | - foreach ( $post_ids as $post_id ) { |
|
337 | + if ( ! empty($post_ids) && is_array($post_ids)) { |
|
338 | + $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0; |
|
339 | + foreach ($post_ids as $post_id) { |
|
340 | 340 | |
341 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
341 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
342 | 342 | continue; |
343 | 343 | } |
344 | 344 | |
345 | - if ( ! empty( $price ) ) { |
|
346 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( $price ) ); |
|
345 | + if ( ! empty($price)) { |
|
346 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db($price)); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |
@@ -351,4 +351,4 @@ discard block |
||
351 | 351 | die(); |
352 | 352 | } |
353 | 353 | |
354 | -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' ); |
|
354 | +add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit'); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | |
26 | - $this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
27 | - $this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
26 | + $this->shortcode['title'] = esc_html__('Donation Form Goal', 'give'); |
|
27 | + $this->shortcode['label'] = esc_html__('Donation Form Goal', 'give'); |
|
28 | 28 | |
29 | - parent::__construct( 'give_goal' ); |
|
29 | + parent::__construct('give_goal'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | |
39 | 39 | $create_form_link = sprintf( |
40 | 40 | /* translators: %s: create new form URL */ |
41 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
42 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
41 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
42 | + admin_url('post-new.php?post_type=give_forms') |
|
43 | 43 | ); |
44 | 44 | |
45 | 45 | return array( |
@@ -51,35 +51,35 @@ discard block |
||
51 | 51 | 'meta_value' => 'enabled', |
52 | 52 | ), |
53 | 53 | 'name' => 'id', |
54 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
55 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
54 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
55 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
56 | 56 | 'required' => array( |
57 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
58 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
57 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
58 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
59 | 59 | ), |
60 | 60 | ), |
61 | 61 | array( |
62 | 62 | 'type' => 'container', |
63 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
63 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
64 | 64 | ), |
65 | 65 | array( |
66 | 66 | 'type' => 'listbox', |
67 | 67 | 'name' => 'show_text', |
68 | - 'label' => esc_attr__( 'Show Text:', 'give' ), |
|
69 | - 'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
|
68 | + 'label' => esc_attr__('Show Text:', 'give'), |
|
69 | + 'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'), |
|
70 | 70 | 'options' => array( |
71 | - 'true' => esc_html__( 'Show', 'give' ), |
|
72 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
71 | + 'true' => esc_html__('Show', 'give'), |
|
72 | + 'false' => esc_html__('Hide', 'give'), |
|
73 | 73 | ), |
74 | 74 | ), |
75 | 75 | array( |
76 | 76 | 'type' => 'listbox', |
77 | 77 | 'name' => 'show_bar', |
78 | - 'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
|
79 | - 'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
78 | + 'label' => esc_attr__('Show Progress Bar:', 'give'), |
|
79 | + 'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'), |
|
80 | 80 | 'options' => array( |
81 | - 'true' => esc_html__( 'Show', 'give' ), |
|
82 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
81 | + 'true' => esc_html__('Show', 'give'), |
|
82 | + 'false' => esc_html__('Hide', 'give'), |
|
83 | 83 | ), |
84 | 84 | ), |
85 | 85 | ); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * This template is used to display the registration form with [give_register] |
4 | 4 | */ |
5 | -Give()->notices->render_frontend_notices( 0 ); ?> |
|
5 | +Give()->notices->render_frontend_notices(0); ?> |
|
6 | 6 | |
7 | 7 | <form id="give-register-form" class="give-form" action="" method="post"> |
8 | 8 | <?php |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @since 1.0 |
15 | 15 | */ |
16 | - do_action( 'give_register_form_fields_top' ); |
|
16 | + do_action('give_register_form_fields_top'); |
|
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <fieldset> |
20 | - <legend><?php esc_html_e( 'Register a New Account', 'give' ); ?></legend> |
|
20 | + <legend><?php esc_html_e('Register a New Account', 'give'); ?></legend> |
|
21 | 21 | |
22 | 22 | <?php |
23 | 23 | /** |
@@ -27,26 +27,26 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @since 1.0 |
29 | 29 | */ |
30 | - do_action( 'give_register_form_fields_before' ); |
|
30 | + do_action('give_register_form_fields_before'); |
|
31 | 31 | ?> |
32 | 32 | |
33 | 33 | <div class="form-row form-row-first form-row-responsive"> |
34 | - <label for="give-user-login"><?php esc_html_e( 'Username', 'give' ); ?></label> |
|
34 | + <label for="give-user-login"><?php esc_html_e('Username', 'give'); ?></label> |
|
35 | 35 | <input id="give-user-login" class="required give-input" type="text" name="give_user_login" required aria-required="true" /> |
36 | 36 | </div> |
37 | 37 | |
38 | 38 | <div class="form-row form-row-last form-row-responsive"> |
39 | - <label for="give-user-email"><?php esc_html_e( 'Email', 'give' ); ?></label> |
|
39 | + <label for="give-user-email"><?php esc_html_e('Email', 'give'); ?></label> |
|
40 | 40 | <input id="give-user-email" class="required give-input" type="email" name="give_user_email" required aria-required="true" /> |
41 | 41 | </div> |
42 | 42 | |
43 | 43 | <div class="form-row form-row-first form-row-responsive"> |
44 | - <label for="give-user-pass"><?php esc_html_e( 'Password', 'give' ); ?></label> |
|
44 | + <label for="give-user-pass"><?php esc_html_e('Password', 'give'); ?></label> |
|
45 | 45 | <input id="give-user-pass" class="password required give-input" type="password" name="give_user_pass" required aria-required="true" /> |
46 | 46 | </div> |
47 | 47 | |
48 | 48 | <div class="form-row form-row-last form-row-responsive"> |
49 | - <label for="give-user-pass2"><?php esc_html_e( 'Confirm PW', 'give' ); ?></label> |
|
49 | + <label for="give-user-pass2"><?php esc_html_e('Confirm PW', 'give'); ?></label> |
|
50 | 50 | <input id="give-user-pass2" class="password required give-input" type="password" name="give_user_pass2" required aria-required="true" /> |
51 | 51 | </div> |
52 | 52 | |
@@ -58,17 +58,17 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @since 1.0 |
60 | 60 | */ |
61 | - do_action( 'give_register_form_fields_before_submit' ); |
|
61 | + do_action('give_register_form_fields_before_submit'); |
|
62 | 62 | ?> |
63 | 63 | |
64 | 64 | <div class="give-hidden"> |
65 | 65 | <input type="hidden" name="give_honeypot" value="" /> |
66 | 66 | <input type="hidden" name="give_action" value="user_register" /> |
67 | - <input type="hidden" name="give_redirect" value="<?php echo esc_url( $give_register_redirect ); ?>" /> |
|
67 | + <input type="hidden" name="give_redirect" value="<?php echo esc_url($give_register_redirect); ?>" /> |
|
68 | 68 | </div> |
69 | 69 | |
70 | 70 | <div class="form-row"> |
71 | - <input class="button" name="give_register_submit" type="submit" value="<?php esc_attr_e( 'Register', 'give' ); ?>" /> |
|
71 | + <input class="button" name="give_register_submit" type="submit" value="<?php esc_attr_e('Register', 'give'); ?>" /> |
|
72 | 72 | </div> |
73 | 73 | |
74 | 74 | <?php |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @since 1.0 |
81 | 81 | */ |
82 | - do_action( 'give_register_form_fields_after' ); |
|
82 | + do_action('give_register_form_fields_after'); |
|
83 | 83 | ?> |
84 | 84 | |
85 | 85 | </fieldset> |
@@ -92,6 +92,6 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @since 1.0 |
94 | 94 | */ |
95 | - do_action( 'give_register_form_fields_bottom' ); |
|
95 | + do_action('give_register_form_fields_bottom'); |
|
96 | 96 | ?> |
97 | 97 | </form> |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly. |
14 | 14 | } |
15 | 15 | |
16 | -$template = strtolower( get_option( 'template' ) ); |
|
16 | +$template = strtolower(get_option('template')); |
|
17 | 17 | |
18 | -switch ( $template ) { |
|
18 | +switch ($template) { |
|
19 | 19 | case 'twentyeleven' : |
20 | 20 | echo '<div id="primary" class="give-wrap"><div id="content" role="main" class="twentyeleven">'; |
21 | 21 | break; |
@@ -65,6 +65,6 @@ discard block |
||
65 | 65 | echo '<div class="wrapper hentry" style="box-sizing: border-box;">'; |
66 | 66 | break; |
67 | 67 | default : |
68 | - echo apply_filters( 'give_default_wrapper_start', '<div id="container" class="give-wrap container"><div id="content" role="main">' ); |
|
68 | + echo apply_filters('give_default_wrapper_start', '<div id="container" class="give-wrap container"><div id="content" role="main">'); |
|
69 | 69 | break; |
70 | 70 | } |
71 | 71 | \ No newline at end of file |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly. |
14 | 14 | } |
15 | 15 | |
16 | -$template = get_option( 'template' ); |
|
16 | +$template = get_option('template'); |
|
17 | 17 | |
18 | -switch ( $template ) { |
|
18 | +switch ($template) { |
|
19 | 19 | case 'twentyeleven' : |
20 | 20 | echo '</div></div>'; |
21 | 21 | break; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | break; |
28 | 28 | case 'twentyfourteen' : |
29 | 29 | echo '</div></div></div>'; |
30 | - get_sidebar( 'content' ); |
|
30 | + get_sidebar('content'); |
|
31 | 31 | break; |
32 | 32 | case 'twentyfifteen' : |
33 | 33 | echo '</div></div>'; |
@@ -57,6 +57,6 @@ discard block |
||
57 | 57 | echo '</div>'; |
58 | 58 | break; |
59 | 59 | default : |
60 | - echo apply_filters( 'give_default_wrapper_end', '</div></div>' ); |
|
60 | + echo apply_filters('give_default_wrapper_end', '</div></div>'); |
|
61 | 61 | break; |
62 | 62 | } |
63 | 63 | \ No newline at end of file |