@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -25,56 +25,56 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_do_automatic_upgrades() { |
| 27 | 27 | $did_upgrade = false; |
| 28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
| 28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
| 29 | 29 | |
| 30 | - if ( ! $give_version ) { |
|
| 30 | + if ( ! $give_version) { |
|
| 31 | 31 | // 1.0 is the first version to use this option so we must add it. |
| 32 | 32 | $give_version = '1.0'; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - switch ( true ) { |
|
| 35 | + switch (true) { |
|
| 36 | 36 | |
| 37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
| 37 | + case version_compare($give_version, '1.6', '<') : |
|
| 38 | 38 | give_v16_upgrades(); |
| 39 | 39 | $did_upgrade = true; |
| 40 | 40 | |
| 41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
| 41 | + case version_compare($give_version, '1.7', '<') : |
|
| 42 | 42 | give_v17_upgrades(); |
| 43 | 43 | $did_upgrade = true; |
| 44 | 44 | |
| 45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
| 45 | + case version_compare($give_version, '1.8', '<') : |
|
| 46 | 46 | give_v18_upgrades(); |
| 47 | 47 | $did_upgrade = true; |
| 48 | 48 | |
| 49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
| 49 | + case version_compare($give_version, '1.8.7', '<') : |
|
| 50 | 50 | give_v187_upgrades(); |
| 51 | 51 | $did_upgrade = true; |
| 52 | 52 | |
| 53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
| 53 | + case version_compare($give_version, '1.8.8', '<') : |
|
| 54 | 54 | give_v188_upgrades(); |
| 55 | 55 | $did_upgrade = true; |
| 56 | 56 | |
| 57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
| 57 | + case version_compare($give_version, '1.8.9', '<') : |
|
| 58 | 58 | give_v189_upgrades(); |
| 59 | 59 | $did_upgrade = true; |
| 60 | 60 | |
| 61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
| 61 | + case version_compare($give_version, '1.8.12', '<') : |
|
| 62 | 62 | give_v1812_upgrades(); |
| 63 | 63 | $did_upgrade = true; |
| 64 | 64 | |
| 65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
| 65 | + case version_compare($give_version, '1.8.13', '<') : |
|
| 66 | 66 | give_v1813_upgrades(); |
| 67 | 67 | $did_upgrade = true; |
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( $did_upgrade ) { |
|
| 72 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 71 | + if ($did_upgrade) { |
|
| 72 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
| 77 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
| 76 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
| 77 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Display Upgrade Notices |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | -function give_show_upgrade_notices( $give_updates ) { |
|
| 89 | +function give_show_upgrade_notices($give_updates) { |
|
| 90 | 90 | // v1.3.2 Upgrades |
| 91 | 91 | $give_updates->register( |
| 92 | 92 | array( |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | ); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
| 155 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Triggers all upgrade functions |
@@ -164,29 +164,29 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | function give_trigger_upgrades() { |
| 166 | 166 | |
| 167 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 168 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 167 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 168 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
| 169 | 169 | 'response' => 403, |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $give_version = get_option( 'give_version' ); |
|
| 173 | + $give_version = get_option('give_version'); |
|
| 174 | 174 | |
| 175 | - if ( ! $give_version ) { |
|
| 175 | + if ( ! $give_version) { |
|
| 176 | 176 | // 1.0 is the first version to use this option so we must add it. |
| 177 | 177 | $give_version = '1.0'; |
| 178 | - add_option( 'give_version', $give_version ); |
|
| 178 | + add_option('give_version', $give_version); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 182 | - delete_option( 'give_doing_upgrade' ); |
|
| 181 | + update_option('give_version', GIVE_VERSION); |
|
| 182 | + delete_option('give_doing_upgrade'); |
|
| 183 | 183 | |
| 184 | - if ( DOING_AJAX ) { |
|
| 185 | - die( 'complete' ); |
|
| 184 | + if (DOING_AJAX) { |
|
| 185 | + die('complete'); |
|
| 186 | 186 | } // End if(). |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
| 189 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -202,24 +202,24 @@ discard block |
||
| 202 | 202 | /* @var Give_Updates $give_updates */ |
| 203 | 203 | $give_updates = Give_Updates::get_instance(); |
| 204 | 204 | |
| 205 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 206 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 205 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 206 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
| 207 | 207 | 'response' => 403, |
| 208 | - ) ); |
|
| 208 | + )); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - ignore_user_abort( true ); |
|
| 211 | + ignore_user_abort(true); |
|
| 212 | 212 | |
| 213 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 214 | - @set_time_limit( 0 ); |
|
| 213 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 214 | + @set_time_limit(0); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // UPDATE DB METAKEYS. |
| 218 | 218 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
| 219 | - $query = $wpdb->query( $sql ); |
|
| 219 | + $query = $wpdb->query($sql); |
|
| 220 | 220 | |
| 221 | 221 | $give_updates->percentage = 100; |
| 222 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
| 222 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
@@ -243,24 +243,24 @@ discard block |
||
| 243 | 243 | $where .= "AND ( p.post_status = 'abandoned' )"; |
| 244 | 244 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
| 245 | 245 | |
| 246 | - $sql = $select . $join . $where; |
|
| 247 | - $found_payments = $wpdb->get_col( $sql ); |
|
| 246 | + $sql = $select.$join.$where; |
|
| 247 | + $found_payments = $wpdb->get_col($sql); |
|
| 248 | 248 | |
| 249 | - foreach ( $found_payments as $payment ) { |
|
| 249 | + foreach ($found_payments as $payment) { |
|
| 250 | 250 | |
| 251 | 251 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
| 252 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
| 252 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
| 253 | 253 | |
| 254 | 254 | // 1450124863 = 12/10/2015 20:42:25. |
| 255 | - if ( $modified_time >= 1450124863 ) { |
|
| 255 | + if ($modified_time >= 1450124863) { |
|
| 256 | 256 | |
| 257 | - give_update_payment_status( $payment, 'pending' ); |
|
| 257 | + give_update_payment_status($payment, 'pending'); |
|
| 258 | 258 | |
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $give_updates->percentage = 100; |
| 263 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
| 263 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -273,17 +273,17 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | function give_v152_cleanup_users() { |
| 275 | 275 | |
| 276 | - $give_version = get_option( 'give_version' ); |
|
| 276 | + $give_version = get_option('give_version'); |
|
| 277 | 277 | |
| 278 | - if ( ! $give_version ) { |
|
| 278 | + if ( ! $give_version) { |
|
| 279 | 279 | // 1.0 is the first version to use this option so we must add it. |
| 280 | 280 | $give_version = '1.0'; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
| 283 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
| 284 | 284 | |
| 285 | 285 | // v1.5.2 Upgrades |
| 286 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
| 286 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
| 287 | 287 | |
| 288 | 288 | // Delete all caps with "ss". |
| 289 | 289 | // Also delete all unused "campaign" roles. |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | ); |
| 331 | 331 | |
| 332 | 332 | global $wp_roles; |
| 333 | - foreach ( $delete_caps as $cap ) { |
|
| 334 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 335 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 333 | + foreach ($delete_caps as $cap) { |
|
| 334 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 335 | + $wp_roles->remove_cap($role, $cap); |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
@@ -342,15 +342,15 @@ discard block |
||
| 342 | 342 | $roles->add_caps(); |
| 343 | 343 | |
| 344 | 344 | // The Update Ran. |
| 345 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 346 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
| 347 | - delete_option( 'give_doing_upgrade' ); |
|
| 345 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 346 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
| 347 | + delete_option('give_doing_upgrade'); |
|
| 348 | 348 | |
| 349 | 349 | }// End if(). |
| 350 | 350 | |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
| 353 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | 356 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -393,53 +393,53 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | // Get addons license key. |
| 395 | 395 | $addons = array(); |
| 396 | - foreach ( $give_options as $key => $value ) { |
|
| 397 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
| 398 | - $addons[ $key ] = $value; |
|
| 396 | + foreach ($give_options as $key => $value) { |
|
| 397 | + if (false !== strpos($key, '_license_key')) { |
|
| 398 | + $addons[$key] = $value; |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | // Bailout: We do not have any addon license data to upgrade. |
| 403 | - if ( empty( $addons ) ) { |
|
| 403 | + if (empty($addons)) { |
|
| 404 | 404 | return false; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - foreach ( $addons as $key => $addon_license ) { |
|
| 407 | + foreach ($addons as $key => $addon_license) { |
|
| 408 | 408 | |
| 409 | 409 | // Get addon shortname. |
| 410 | - $shortname = str_replace( '_license_key', '', $key ); |
|
| 410 | + $shortname = str_replace('_license_key', '', $key); |
|
| 411 | 411 | |
| 412 | 412 | // Addon license option name. |
| 413 | - $addon_license_option_name = $shortname . '_license_active'; |
|
| 413 | + $addon_license_option_name = $shortname.'_license_active'; |
|
| 414 | 414 | |
| 415 | 415 | // bailout if license is empty. |
| 416 | - if ( empty( $addon_license ) ) { |
|
| 417 | - delete_option( $addon_license_option_name ); |
|
| 416 | + if (empty($addon_license)) { |
|
| 417 | + delete_option($addon_license_option_name); |
|
| 418 | 418 | continue; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Get addon name. |
| 422 | 422 | $addon_name = array(); |
| 423 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
| 424 | - foreach ( $addon_name_parts as $name_part ) { |
|
| 423 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
| 424 | + foreach ($addon_name_parts as $name_part) { |
|
| 425 | 425 | |
| 426 | 426 | // Fix addon name |
| 427 | - switch ( $name_part ) { |
|
| 427 | + switch ($name_part) { |
|
| 428 | 428 | case 'authorizenet' : |
| 429 | 429 | $name_part = 'authorize.net'; |
| 430 | 430 | break; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $addon_name[] = ucfirst( $name_part ); |
|
| 433 | + $addon_name[] = ucfirst($name_part); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $addon_name = implode( ' ', $addon_name ); |
|
| 436 | + $addon_name = implode(' ', $addon_name); |
|
| 437 | 437 | |
| 438 | 438 | // Data to send to the API |
| 439 | 439 | $api_params = array( |
| 440 | 440 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
| 441 | 441 | 'license' => $addon_license, |
| 442 | - 'item_name' => urlencode( $addon_name ), |
|
| 442 | + 'item_name' => urlencode($addon_name), |
|
| 443 | 443 | 'url' => home_url(), |
| 444 | 444 | ); |
| 445 | 445 | |
@@ -454,17 +454,17 @@ discard block |
||
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | 456 | // Make sure there are no errors. |
| 457 | - if ( is_wp_error( $response ) ) { |
|
| 458 | - delete_option( $addon_license_option_name ); |
|
| 457 | + if (is_wp_error($response)) { |
|
| 458 | + delete_option($addon_license_option_name); |
|
| 459 | 459 | continue; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | // Tell WordPress to look for updates. |
| 463 | - set_site_transient( 'update_plugins', null ); |
|
| 463 | + set_site_transient('update_plugins', null); |
|
| 464 | 464 | |
| 465 | 465 | // Decode license data. |
| 466 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 467 | - update_option( $addon_license_option_name, $license_data ); |
|
| 466 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 467 | + update_option($addon_license_option_name, $license_data); |
|
| 468 | 468 | }// End foreach(). |
| 469 | 469 | } |
| 470 | 470 | |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | ); |
| 495 | 495 | |
| 496 | 496 | global $wp_roles; |
| 497 | - foreach ( $delete_caps as $cap ) { |
|
| 498 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 499 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 497 | + foreach ($delete_caps as $cap) { |
|
| 498 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 499 | + $wp_roles->remove_cap($role, $cap); |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | function give_v18_upgrades_core_setting() { |
| 531 | 531 | // Core settings which changes from checkbox to radio. |
| 532 | 532 | $core_setting_names = array_merge( |
| 533 | - array_keys( give_v18_renamed_core_settings() ), |
|
| 533 | + array_keys(give_v18_renamed_core_settings()), |
|
| 534 | 534 | array( |
| 535 | 535 | 'uninstall_on_delete', |
| 536 | 536 | 'scripts_footer', |
@@ -542,48 +542,48 @@ discard block |
||
| 542 | 542 | ); |
| 543 | 543 | |
| 544 | 544 | // Bailout: If not any setting define. |
| 545 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
| 545 | + if ($give_settings = get_option('give_settings')) { |
|
| 546 | 546 | |
| 547 | 547 | $setting_changed = false; |
| 548 | 548 | |
| 549 | 549 | // Loop: check each setting field. |
| 550 | - foreach ( $core_setting_names as $setting_name ) { |
|
| 550 | + foreach ($core_setting_names as $setting_name) { |
|
| 551 | 551 | // New setting name. |
| 552 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
| 552 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
| 553 | 553 | |
| 554 | 554 | // Continue: If setting already set. |
| 555 | 555 | if ( |
| 556 | - array_key_exists( $new_setting_name, $give_settings ) |
|
| 557 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
| 556 | + array_key_exists($new_setting_name, $give_settings) |
|
| 557 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
| 558 | 558 | ) { |
| 559 | 559 | continue; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | // Set checkbox value to radio value. |
| 563 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
| 563 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
| 564 | 564 | |
| 565 | 565 | // @see https://github.com/WordImpress/Give/issues/1063 |
| 566 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
| 566 | + if (false !== strpos($setting_name, 'disable_')) { |
|
| 567 | 567 | |
| 568 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
| 569 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
| 568 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
| 569 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
| 570 | 570 | |
| 571 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
| 571 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | // Tell bot to update core setting to db. |
| 575 | - if ( ! $setting_changed ) { |
|
| 575 | + if ( ! $setting_changed) { |
|
| 576 | 576 | $setting_changed = true; |
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | // Update setting only if they changed. |
| 581 | - if ( $setting_changed ) { |
|
| 582 | - update_option( 'give_settings', $give_settings ); |
|
| 581 | + if ($setting_changed) { |
|
| 582 | + update_option('give_settings', $give_settings); |
|
| 583 | 583 | } |
| 584 | 584 | }// End if(). |
| 585 | 585 | |
| 586 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
| 586 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $give_updates = Give_Updates::get_instance(); |
| 598 | 598 | |
| 599 | 599 | // form query |
| 600 | - $forms = new WP_Query( array( |
|
| 600 | + $forms = new WP_Query(array( |
|
| 601 | 601 | 'paged' => $give_updates->step, |
| 602 | 602 | 'status' => 'any', |
| 603 | 603 | 'order' => 'ASC', |
@@ -606,41 +606,41 @@ discard block |
||
| 606 | 606 | ) |
| 607 | 607 | ); |
| 608 | 608 | |
| 609 | - if ( $forms->have_posts() ) { |
|
| 610 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 609 | + if ($forms->have_posts()) { |
|
| 610 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
| 611 | 611 | |
| 612 | - while ( $forms->have_posts() ) { |
|
| 612 | + while ($forms->have_posts()) { |
|
| 613 | 613 | $forms->the_post(); |
| 614 | 614 | |
| 615 | 615 | // Form content. |
| 616 | 616 | // Note in version 1.8 display content setting split into display content and content placement setting. |
| 617 | 617 | // You can delete _give_content_option in future |
| 618 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
| 619 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
| 620 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
| 621 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
| 618 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
| 619 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
| 620 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
| 621 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
| 622 | 622 | |
| 623 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
| 624 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
| 623 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
| 624 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // "Disable" Guest Donation. Checkbox |
| 628 | 628 | // See: https://github.com/WordImpress/Give/issues/1470 |
| 629 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
| 630 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
| 631 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
| 629 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
| 630 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
| 631 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
| 632 | 632 | |
| 633 | 633 | // Offline Donations |
| 634 | 634 | // See: https://github.com/WordImpress/Give/issues/1579 |
| 635 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
| 636 | - if ( 'no' === $offline_donation ) { |
|
| 635 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
| 636 | + if ('no' === $offline_donation) { |
|
| 637 | 637 | $offline_donation_newval = 'global'; |
| 638 | - } elseif ( 'yes' === $offline_donation ) { |
|
| 638 | + } elseif ('yes' === $offline_donation) { |
|
| 639 | 639 | $offline_donation_newval = 'enabled'; |
| 640 | 640 | } else { |
| 641 | 641 | $offline_donation_newval = 'disabled'; |
| 642 | 642 | } |
| 643 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
| 643 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
| 644 | 644 | |
| 645 | 645 | // Convert yes/no setting field to enabled/disabled. |
| 646 | 646 | $form_radio_settings = array( |
@@ -660,15 +660,15 @@ discard block |
||
| 660 | 660 | '_give_offline_donation_enable_billing_fields_single', |
| 661 | 661 | ); |
| 662 | 662 | |
| 663 | - foreach ( $form_radio_settings as $meta_key ) { |
|
| 663 | + foreach ($form_radio_settings as $meta_key) { |
|
| 664 | 664 | // Get value. |
| 665 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
| 665 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
| 666 | 666 | |
| 667 | 667 | // Convert meta value only if it is in yes/no/none. |
| 668 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
| 668 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
| 669 | 669 | |
| 670 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
| 671 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
| 670 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
| 671 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | }// End while(). |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | } else { |
| 679 | 679 | // No more forms found, finish up. |
| 680 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
| 680 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | '_transient_give_stats_', |
| 727 | 727 | 'give_cache', |
| 728 | 728 | '_transient_give_add_ons_feed', |
| 729 | - '_transient__give_ajax_works' . |
|
| 729 | + '_transient__give_ajax_works'. |
|
| 730 | 730 | '_transient_give_total_api_keys', |
| 731 | 731 | '_transient_give_i18n_give_promo_hide', |
| 732 | 732 | '_transient_give_contributors', |
@@ -753,24 +753,24 @@ discard block |
||
| 753 | 753 | ARRAY_A |
| 754 | 754 | ); |
| 755 | 755 | |
| 756 | - if ( ! empty( $user_apikey_options ) ) { |
|
| 757 | - foreach ( $user_apikey_options as $user ) { |
|
| 758 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
| 759 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
| 760 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
| 756 | + if ( ! empty($user_apikey_options)) { |
|
| 757 | + foreach ($user_apikey_options as $user) { |
|
| 758 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
| 759 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
| 760 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - if ( ! empty( $cached_options ) ) { |
|
| 765 | - foreach ( $cached_options as $option ) { |
|
| 766 | - switch ( true ) { |
|
| 767 | - case ( false !== strpos( $option, 'transient' ) ): |
|
| 768 | - $option = str_replace( '_transient_', '', $option ); |
|
| 769 | - delete_transient( $option ); |
|
| 764 | + if ( ! empty($cached_options)) { |
|
| 765 | + foreach ($cached_options as $option) { |
|
| 766 | + switch (true) { |
|
| 767 | + case (false !== strpos($option, 'transient')): |
|
| 768 | + $option = str_replace('_transient_', '', $option); |
|
| 769 | + delete_transient($option); |
|
| 770 | 770 | break; |
| 771 | 771 | |
| 772 | 772 | default: |
| 773 | - delete_option( $option ); |
|
| 773 | + delete_option($option); |
|
| 774 | 774 | } |
| 775 | 775 | } |
| 776 | 776 | } |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | global $wp_roles; |
| 789 | 789 | |
| 790 | 790 | // Get the role object. |
| 791 | - $give_worker = get_role( 'give_worker' ); |
|
| 791 | + $give_worker = get_role('give_worker'); |
|
| 792 | 792 | |
| 793 | 793 | // A list of capabilities to add for give workers. |
| 794 | 794 | $caps_to_add = array( |
@@ -796,9 +796,9 @@ discard block |
||
| 796 | 796 | 'edit_pages', |
| 797 | 797 | ); |
| 798 | 798 | |
| 799 | - foreach ( $caps_to_add as $cap ) { |
|
| 799 | + foreach ($caps_to_add as $cap) { |
|
| 800 | 800 | // Add the capability. |
| 801 | - $give_worker->add_cap( $cap ); |
|
| 801 | + $give_worker->add_cap($cap); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | } |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | $give_updates = Give_Updates::get_instance(); |
| 816 | 816 | |
| 817 | 817 | // form query |
| 818 | - $donation_forms = new WP_Query( array( |
|
| 818 | + $donation_forms = new WP_Query(array( |
|
| 819 | 819 | 'paged' => $give_updates->step, |
| 820 | 820 | 'status' => 'any', |
| 821 | 821 | 'order' => 'ASC', |
@@ -824,10 +824,10 @@ discard block |
||
| 824 | 824 | ) |
| 825 | 825 | ); |
| 826 | 826 | |
| 827 | - if ( $donation_forms->have_posts() ) { |
|
| 828 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 827 | + if ($donation_forms->have_posts()) { |
|
| 828 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 829 | 829 | |
| 830 | - while ( $donation_forms->have_posts() ) { |
|
| 830 | + while ($donation_forms->have_posts()) { |
|
| 831 | 831 | $donation_forms->the_post(); |
| 832 | 832 | $form_id = get_the_ID(); |
| 833 | 833 | |
@@ -835,41 +835,41 @@ discard block |
||
| 835 | 835 | update_post_meta( |
| 836 | 836 | $form_id, |
| 837 | 837 | '_give_set_price', |
| 838 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
| 838 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
| 839 | 839 | ); |
| 840 | 840 | |
| 841 | 841 | // Remove formatting from _give_custom_amount_minimum |
| 842 | 842 | update_post_meta( |
| 843 | 843 | $form_id, |
| 844 | 844 | '_give_custom_amount_minimum', |
| 845 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
| 845 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
| 846 | 846 | ); |
| 847 | 847 | |
| 848 | 848 | // Bailout. |
| 849 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
| 849 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
| 850 | 850 | continue; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
| 853 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
| 854 | 854 | |
| 855 | - if ( ! empty( $donation_levels ) ) { |
|
| 855 | + if ( ! empty($donation_levels)) { |
|
| 856 | 856 | |
| 857 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
| 858 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
| 859 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
| 857 | + foreach ($donation_levels as $index => $donation_level) { |
|
| 858 | + if (isset($donation_level['_give_amount'])) { |
|
| 859 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
| 860 | 860 | } |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
| 863 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
| 864 | 864 | |
| 865 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
| 865 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
| 866 | 866 | |
| 867 | - $min_amount = min( $donation_levels_amounts ); |
|
| 868 | - $max_amount = max( $donation_levels_amounts ); |
|
| 867 | + $min_amount = min($donation_levels_amounts); |
|
| 868 | + $max_amount = max($donation_levels_amounts); |
|
| 869 | 869 | |
| 870 | 870 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
| 871 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
| 872 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
| 871 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
| 872 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | } |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | wp_reset_postdata(); |
| 879 | 879 | } else { |
| 880 | 880 | // The Update Ran. |
| 881 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
| 881 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | } |
@@ -934,22 +934,22 @@ discard block |
||
| 934 | 934 | $give_settings = give_get_settings(); |
| 935 | 935 | $give_setting_updated = false; |
| 936 | 936 | |
| 937 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
| 937 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
| 938 | 938 | $give_settings['number_decimals'] = 0; |
| 939 | 939 | $give_settings['decimal_separator'] = ''; |
| 940 | 940 | $give_setting_updated = true; |
| 941 | 941 | |
| 942 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
| 942 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
| 943 | 943 | $give_settings['number_decimals'] = 0; |
| 944 | 944 | $give_setting_updated = true; |
| 945 | 945 | |
| 946 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
| 946 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
| 947 | 947 | $give_settings['number_decimals'] = 5; |
| 948 | 948 | $give_setting_updated = true; |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - if ( $give_setting_updated ) { |
|
| 952 | - update_option( 'give_settings', $give_settings ); |
|
| 951 | + if ($give_setting_updated) { |
|
| 952 | + update_option('give_settings', $give_settings); |
|
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | |
@@ -968,70 +968,70 @@ discard block |
||
| 968 | 968 | $give_updates = Give_Updates::get_instance(); |
| 969 | 969 | |
| 970 | 970 | // form query |
| 971 | - $donation_forms = new WP_Query( array( |
|
| 971 | + $donation_forms = new WP_Query(array( |
|
| 972 | 972 | 'paged' => $give_updates->step, |
| 973 | 973 | 'status' => 'any', |
| 974 | 974 | 'order' => 'ASC', |
| 975 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
| 975 | + 'post_type' => array('give_forms', 'give_payment'), |
|
| 976 | 976 | 'posts_per_page' => 20, |
| 977 | 977 | ) |
| 978 | 978 | ); |
| 979 | 979 | |
| 980 | - if ( $donation_forms->have_posts() ) { |
|
| 981 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 980 | + if ($donation_forms->have_posts()) { |
|
| 981 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 982 | 982 | |
| 983 | - while ( $donation_forms->have_posts() ) { |
|
| 983 | + while ($donation_forms->have_posts()) { |
|
| 984 | 984 | $donation_forms->the_post(); |
| 985 | 985 | global $post; |
| 986 | 986 | |
| 987 | - $meta = get_post_meta( $post->ID ); |
|
| 987 | + $meta = get_post_meta($post->ID); |
|
| 988 | 988 | |
| 989 | - switch ( $post->post_type ) { |
|
| 989 | + switch ($post->post_type) { |
|
| 990 | 990 | case 'give_forms': |
| 991 | 991 | // _give_set_price |
| 992 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
| 993 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
| 992 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
| 993 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | // _give_custom_amount_minimum |
| 997 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
| 998 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
| 997 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
| 998 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | // _give_levels_minimum_amount |
| 1002 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
| 1003 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
| 1002 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
| 1003 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | // _give_levels_maximum_amount |
| 1007 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
| 1008 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
| 1007 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
| 1008 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | // _give_set_goal |
| 1012 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
| 1013 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
| 1012 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
| 1013 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | // _give_form_earnings |
| 1017 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
| 1018 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
| 1017 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
| 1018 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | // _give_custom_amount_minimum |
| 1022 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
| 1023 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
| 1022 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
| 1023 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
| 1024 | 1024 | |
| 1025 | - foreach ( $donation_levels as $index => $level ) { |
|
| 1026 | - if ( empty( $level['_give_amount'] ) ) { |
|
| 1025 | + foreach ($donation_levels as $index => $level) { |
|
| 1026 | + if (empty($level['_give_amount'])) { |
|
| 1027 | 1027 | continue; |
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
| 1030 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | $meta['_give_donation_levels'] = $donation_levels; |
| 1034 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
| 1034 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | |
@@ -1039,8 +1039,8 @@ discard block |
||
| 1039 | 1039 | |
| 1040 | 1040 | case 'give_payment': |
| 1041 | 1041 | // _give_payment_total |
| 1042 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
| 1043 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
| 1042 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
| 1043 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | break; |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | wp_reset_postdata(); |
| 1052 | 1052 | } else { |
| 1053 | 1053 | // The Update Ran. |
| 1054 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
| 1054 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | } |
| 1057 | 1057 | |
@@ -1071,22 +1071,22 @@ discard block |
||
| 1071 | 1071 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
| 1072 | 1072 | |
| 1073 | 1073 | // form query |
| 1074 | - $donors = Give()->donors->get_donors( array( |
|
| 1074 | + $donors = Give()->donors->get_donors(array( |
|
| 1075 | 1075 | 'number' => 20, |
| 1076 | 1076 | 'offset' => $offset, |
| 1077 | 1077 | ) |
| 1078 | 1078 | ); |
| 1079 | 1079 | |
| 1080 | - if ( ! empty( $donors ) ) { |
|
| 1081 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
| 1080 | + if ( ! empty($donors)) { |
|
| 1081 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
| 1082 | 1082 | |
| 1083 | 1083 | /* @var Object $donor */ |
| 1084 | - foreach ( $donors as $donor ) { |
|
| 1085 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
| 1084 | + foreach ($donors as $donor) { |
|
| 1085 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | } else { |
| 1088 | 1088 | // The Update Ran. |
| 1089 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
| 1089 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -1101,25 +1101,25 @@ discard block |
||
| 1101 | 1101 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
| 1102 | 1102 | |
| 1103 | 1103 | // Fetch all the existing donors. |
| 1104 | - $donors = Give()->donors->get_donors( array( |
|
| 1104 | + $donors = Give()->donors->get_donors(array( |
|
| 1105 | 1105 | 'number' => 20, |
| 1106 | 1106 | 'offset' => $offset, |
| 1107 | 1107 | ) |
| 1108 | 1108 | ); |
| 1109 | 1109 | |
| 1110 | - if ( ! empty( $donors ) ) { |
|
| 1111 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
| 1110 | + if ( ! empty($donors)) { |
|
| 1111 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
| 1112 | 1112 | |
| 1113 | 1113 | /* @var Object $donor */ |
| 1114 | - foreach ( $donors as $donor ) { |
|
| 1114 | + foreach ($donors as $donor) { |
|
| 1115 | 1115 | $user_id = $donor->user_id; |
| 1116 | 1116 | |
| 1117 | 1117 | // Proceed, if donor is attached with user. |
| 1118 | - if ( $user_id ) { |
|
| 1119 | - $user = get_userdata( $user_id ); |
|
| 1118 | + if ($user_id) { |
|
| 1119 | + $user = get_userdata($user_id); |
|
| 1120 | 1120 | |
| 1121 | 1121 | // Update user role, if user has subscriber role. |
| 1122 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
| 1122 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
| 1123 | 1123 | wp_update_user( |
| 1124 | 1124 | array( |
| 1125 | 1125 | 'ID' => $user_id, |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | } |
| 1132 | 1132 | } else { |
| 1133 | 1133 | // The Update Ran. |
| 1134 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
| 1134 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
| 1135 | 1135 | } |
| 1136 | 1136 | } |
| 1137 | 1137 | |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | */ |
| 1144 | 1144 | function give_v1813_upgrades() { |
| 1145 | 1145 | // Update admin setting. |
| 1146 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
| 1146 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
| 1147 | 1147 | |
| 1148 | 1148 | // Update Give roles. |
| 1149 | 1149 | $roles = new Give_Roles(); |
@@ -95,13 +95,13 @@ |
||
| 95 | 95 | 'disabled' => __( 'Head', 'give' ), |
| 96 | 96 | ) |
| 97 | 97 | ), |
| 98 | - array( |
|
| 99 | - 'name' => __( 'Advanced Settings Docs Link', 'give' ), |
|
| 100 | - 'id' => 'advanced_settings_docs_link', |
|
| 101 | - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
| 102 | - 'title' => __( 'Advanced Settings', 'give' ), |
|
| 103 | - 'type' => 'give_docs_link', |
|
| 104 | - ), |
|
| 98 | + array( |
|
| 99 | + 'name' => __( 'Advanced Settings Docs Link', 'give' ), |
|
| 100 | + 'id' => 'advanced_settings_docs_link', |
|
| 101 | + 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
| 102 | + 'title' => __( 'Advanced Settings', 'give' ), |
|
| 103 | + 'type' => 'give_docs_link', |
|
| 104 | + ), |
|
| 105 | 105 | array( |
| 106 | 106 | 'id' => 'give_title_data_control_2', |
| 107 | 107 | 'type' => 'sectionend' |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_Advanced' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Advanced')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Advanced. |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function __construct() { |
| 29 | 29 | $this->id = 'advanced'; |
| 30 | - $this->label = __( 'Advanced', 'give' ); |
|
| 30 | + $this->label = __('Advanced', 'give'); |
|
| 31 | 31 | |
| 32 | 32 | $this->default_tab = 'advanced-options'; |
| 33 | 33 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $current_section = give_get_current_setting_section(); |
| 47 | 47 | |
| 48 | - switch ( $current_section ) { |
|
| 48 | + switch ($current_section) { |
|
| 49 | 49 | case 'advanced-options': |
| 50 | 50 | $settings = array( |
| 51 | 51 | array( |
@@ -53,19 +53,19 @@ discard block |
||
| 53 | 53 | 'type' => 'title' |
| 54 | 54 | ), |
| 55 | 55 | array( |
| 56 | - 'name' => __( 'Remove Data on Uninstall', 'give' ), |
|
| 57 | - 'desc' => __( 'When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give' ), |
|
| 56 | + 'name' => __('Remove Data on Uninstall', 'give'), |
|
| 57 | + 'desc' => __('When the plugin is deleted, completely remove all Give data. This includes all Give settings, forms, form meta, donor, donor data, donations. Everything.', 'give'), |
|
| 58 | 58 | 'id' => 'uninstall_on_delete', |
| 59 | 59 | 'type' => 'radio_inline', |
| 60 | 60 | 'default' => 'disabled', |
| 61 | 61 | 'options' => array( |
| 62 | - 'enabled' => __( 'Yes, Remove all data', 'give' ), |
|
| 63 | - 'disabled' => __( 'No, keep my Give settings and donation data', 'give' ), |
|
| 62 | + 'enabled' => __('Yes, Remove all data', 'give'), |
|
| 63 | + 'disabled' => __('No, keep my Give settings and donation data', 'give'), |
|
| 64 | 64 | ) |
| 65 | 65 | ), |
| 66 | 66 | array( |
| 67 | - 'name' => __( 'Default User Role', 'give' ), |
|
| 68 | - 'desc' => __( 'Assign default user roles for donors when donors opt to register as a WP User.', 'give' ), |
|
| 67 | + 'name' => __('Default User Role', 'give'), |
|
| 68 | + 'desc' => __('Assign default user roles for donors when donors opt to register as a WP User.', 'give'), |
|
| 69 | 69 | 'id' => 'donor_default_user_role', |
| 70 | 70 | 'type' => 'select', |
| 71 | 71 | 'default' => 'give_donor', |
@@ -73,33 +73,33 @@ discard block |
||
| 73 | 73 | ), |
| 74 | 74 | array( |
| 75 | 75 | /* translators: %s: the_content */ |
| 76 | - 'name' => sprintf( __( '%s filter', 'give' ), '<code>the_content</code>' ), |
|
| 76 | + 'name' => sprintf(__('%s filter', 'give'), '<code>the_content</code>'), |
|
| 77 | 77 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
| 78 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
|
| 78 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'), |
|
| 79 | 79 | 'id' => 'the_content_filter', |
| 80 | 80 | 'default' => 'enabled', |
| 81 | 81 | 'type' => 'radio_inline', |
| 82 | 82 | 'options' => array( |
| 83 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 84 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 83 | + 'enabled' => __('Enabled', 'give'), |
|
| 84 | + 'disabled' => __('Disabled', 'give'), |
|
| 85 | 85 | ) |
| 86 | 86 | ), |
| 87 | 87 | array( |
| 88 | - 'name' => __( 'Script Loading Location', 'give' ), |
|
| 89 | - 'desc' => __( 'This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give' ), |
|
| 88 | + 'name' => __('Script Loading Location', 'give'), |
|
| 89 | + 'desc' => __('This allows you to load your Give scripts either in the <code><head></code> or footer of your website.', 'give'), |
|
| 90 | 90 | 'id' => 'scripts_footer', |
| 91 | 91 | 'type' => 'radio_inline', |
| 92 | 92 | 'default' => 'disabled', |
| 93 | 93 | 'options' => array( |
| 94 | - 'enabled' => __( 'Footer', 'give' ), |
|
| 95 | - 'disabled' => __( 'Head', 'give' ), |
|
| 94 | + 'enabled' => __('Footer', 'give'), |
|
| 95 | + 'disabled' => __('Head', 'give'), |
|
| 96 | 96 | ) |
| 97 | 97 | ), |
| 98 | 98 | array( |
| 99 | - 'name' => __( 'Advanced Settings Docs Link', 'give' ), |
|
| 99 | + 'name' => __('Advanced Settings Docs Link', 'give'), |
|
| 100 | 100 | 'id' => 'advanced_settings_docs_link', |
| 101 | - 'url' => esc_url( 'http://docs.givewp.com/settings-advanced' ), |
|
| 102 | - 'title' => __( 'Advanced Settings', 'give' ), |
|
| 101 | + 'url' => esc_url('http://docs.givewp.com/settings-advanced'), |
|
| 102 | + 'title' => __('Advanced Settings', 'give'), |
|
| 103 | 103 | 'type' => 'give_docs_link', |
| 104 | 104 | ), |
| 105 | 105 | array( |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * Filter the advanced settings. |
| 116 | 116 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
| 117 | 117 | */ |
| 118 | - $settings = apply_filters( 'give_settings_advanced', $settings ); |
|
| 118 | + $settings = apply_filters('give_settings_advanced', $settings); |
|
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Filter the settings. |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param array $settings |
| 126 | 126 | */ |
| 127 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 127 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 128 | 128 | |
| 129 | 129 | // Output. |
| 130 | 130 | return $settings; |
@@ -138,10 +138,10 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function get_sections() { |
| 140 | 140 | $sections = array( |
| 141 | - 'advanced-options' => __( 'Advanced Options', 'give' ) |
|
| 141 | + 'advanced-options' => __('Advanced Options', 'give') |
|
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
| 144 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function __construct() { |
| 48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
| 49 | - $this->metabox_label = __( 'Donation Form Options', 'give' ); |
|
| 49 | + $this->metabox_label = __('Donation Form Options', 'give'); |
|
| 50 | 50 | |
| 51 | 51 | // Setup. |
| 52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
| 52 | + add_action('admin_init', array($this, 'setup')); |
|
| 53 | 53 | |
| 54 | 54 | // Add metabox. |
| 55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 ); |
|
| 55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 10); |
|
| 56 | 56 | |
| 57 | 57 | // Save form meta. |
| 58 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
| 58 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
| 59 | 59 | |
| 60 | 60 | // cmb2 old setting loaders. |
| 61 | 61 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
| 62 | 62 | // Add offline donations options. |
| 63 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
| 63 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
| 64 | 64 | |
| 65 | 65 | // Maintain active tab query parameter after save. |
| 66 | - add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 ); |
|
| 66 | + add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -85,24 +85,24 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function get_settings() { |
| 87 | 87 | $post_id = give_get_admin_post_id(); |
| 88 | - $price = give_get_form_price( $post_id ); |
|
| 89 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
| 90 | - $goal = give_format_amount( give_get_form_goal( $post_id ), array( 'sanitize' => false ) ); |
|
| 91 | - $price_placeholder = give_format_decimal( '1.00', false, false ); |
|
| 88 | + $price = give_get_form_price($post_id); |
|
| 89 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
| 90 | + $goal = give_format_amount(give_get_form_goal($post_id), array('sanitize' => false)); |
|
| 91 | + $price_placeholder = give_format_decimal('1.00', false, false); |
|
| 92 | 92 | |
| 93 | 93 | // No empty prices - min. 1.00 for new forms |
| 94 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
| 94 | + if (empty($price) && is_null($post_id)) { |
|
| 95 | 95 | $price = '1.00'; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Min. $1.00 for new forms |
| 99 | - if ( empty( $custom_amount_minimum ) ) { |
|
| 99 | + if (empty($custom_amount_minimum)) { |
|
| 100 | 100 | $custom_amount_minimum = '1.00'; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Format amounts. |
| 104 | - $price = give_format_amount( $price, array( 'sanitize' => false ) ); |
|
| 105 | - $custom_amount_minimum = give_format_amount( $custom_amount_minimum, array( 'sanitize' => false ) ); |
|
| 104 | + $price = give_format_amount($price, array('sanitize' => false)); |
|
| 105 | + $custom_amount_minimum = give_format_amount($custom_amount_minimum, array('sanitize' => false)); |
|
| 106 | 106 | |
| 107 | 107 | // Start with an underscore to hide fields from custom fields list |
| 108 | 108 | $prefix = '_give_'; |
@@ -111,27 +111,27 @@ discard block |
||
| 111 | 111 | /** |
| 112 | 112 | * Repeatable Field Groups |
| 113 | 113 | */ |
| 114 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
| 114 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
| 115 | 115 | 'id' => 'form_field_options', |
| 116 | - 'title' => __( 'Donation Options', 'give' ), |
|
| 116 | + 'title' => __('Donation Options', 'give'), |
|
| 117 | 117 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
| 118 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
| 118 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
| 119 | 119 | // Donation Option |
| 120 | 120 | array( |
| 121 | - 'name' => __( 'Donation Option', 'give' ), |
|
| 122 | - 'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
| 123 | - 'id' => $prefix . 'price_option', |
|
| 121 | + 'name' => __('Donation Option', 'give'), |
|
| 122 | + 'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
| 123 | + 'id' => $prefix.'price_option', |
|
| 124 | 124 | 'type' => 'radio_inline', |
| 125 | 125 | 'default' => 'set', |
| 126 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
| 127 | - 'set' => __( 'Set Donation', 'give' ), |
|
| 128 | - 'multi' => __( 'Multi-level Donation', 'give' ), |
|
| 129 | - ) ), |
|
| 126 | + 'options' => apply_filters('give_forms_price_options', array( |
|
| 127 | + 'set' => __('Set Donation', 'give'), |
|
| 128 | + 'multi' => __('Multi-level Donation', 'give'), |
|
| 129 | + )), |
|
| 130 | 130 | ), |
| 131 | 131 | array( |
| 132 | - 'name' => __( 'Set Donation', 'give' ), |
|
| 133 | - 'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
| 134 | - 'id' => $prefix . 'set_price', |
|
| 132 | + 'name' => __('Set Donation', 'give'), |
|
| 133 | + 'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
| 134 | + 'id' => $prefix.'set_price', |
|
| 135 | 135 | 'type' => 'text_small', |
| 136 | 136 | 'data_type' => 'price', |
| 137 | 137 | 'attributes' => array( |
@@ -142,34 +142,34 @@ discard block |
||
| 142 | 142 | ), |
| 143 | 143 | // Display Style |
| 144 | 144 | array( |
| 145 | - 'name' => __( 'Display Style', 'give' ), |
|
| 146 | - 'description' => __( 'Set how the donations levels will display on the form.', 'give' ), |
|
| 147 | - 'id' => $prefix . 'display_style', |
|
| 145 | + 'name' => __('Display Style', 'give'), |
|
| 146 | + 'description' => __('Set how the donations levels will display on the form.', 'give'), |
|
| 147 | + 'id' => $prefix.'display_style', |
|
| 148 | 148 | 'type' => 'radio_inline', |
| 149 | 149 | 'default' => 'buttons', |
| 150 | 150 | 'options' => array( |
| 151 | - 'buttons' => __( 'Buttons', 'give' ), |
|
| 152 | - 'radios' => __( 'Radios', 'give' ), |
|
| 153 | - 'dropdown' => __( 'Dropdown', 'give' ), |
|
| 151 | + 'buttons' => __('Buttons', 'give'), |
|
| 152 | + 'radios' => __('Radios', 'give'), |
|
| 153 | + 'dropdown' => __('Dropdown', 'give'), |
|
| 154 | 154 | ), |
| 155 | 155 | 'wrapper_class' => 'give-hidden', |
| 156 | 156 | ), |
| 157 | 157 | // Custom Amount |
| 158 | 158 | array( |
| 159 | - 'name' => __( 'Custom Amount', 'give' ), |
|
| 160 | - 'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
| 161 | - 'id' => $prefix . 'custom_amount', |
|
| 159 | + 'name' => __('Custom Amount', 'give'), |
|
| 160 | + 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), |
|
| 161 | + 'id' => $prefix.'custom_amount', |
|
| 162 | 162 | 'type' => 'radio_inline', |
| 163 | 163 | 'default' => 'disabled', |
| 164 | 164 | 'options' => array( |
| 165 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 166 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 165 | + 'enabled' => __('Enabled', 'give'), |
|
| 166 | + 'disabled' => __('Disabled', 'give'), |
|
| 167 | 167 | ), |
| 168 | 168 | ), |
| 169 | 169 | array( |
| 170 | - 'name' => __( 'Minimum Amount', 'give' ), |
|
| 171 | - 'description' => __( 'Enter the minimum custom donation amount.', 'give' ), |
|
| 172 | - 'id' => $prefix . 'custom_amount_minimum', |
|
| 170 | + 'name' => __('Minimum Amount', 'give'), |
|
| 171 | + 'description' => __('Enter the minimum custom donation amount.', 'give'), |
|
| 172 | + 'id' => $prefix.'custom_amount_minimum', |
|
| 173 | 173 | 'type' => 'text_small', |
| 174 | 174 | 'data_type' => 'price', |
| 175 | 175 | 'attributes' => array( |
@@ -180,37 +180,37 @@ discard block |
||
| 180 | 180 | 'wrapper_class' => 'give-hidden', |
| 181 | 181 | ), |
| 182 | 182 | array( |
| 183 | - 'name' => __( 'Custom Amount Text', 'give' ), |
|
| 184 | - 'description' => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
| 185 | - 'id' => $prefix . 'custom_amount_text', |
|
| 183 | + 'name' => __('Custom Amount Text', 'give'), |
|
| 184 | + 'description' => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
| 185 | + 'id' => $prefix.'custom_amount_text', |
|
| 186 | 186 | 'type' => 'text_medium', |
| 187 | 187 | 'attributes' => array( |
| 188 | 188 | 'rows' => 3, |
| 189 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
| 189 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
| 190 | 190 | ), |
| 191 | 191 | 'wrapper_class' => 'give-hidden', |
| 192 | 192 | ), |
| 193 | 193 | // Donation Levels: Repeatable CMB2 Group |
| 194 | 194 | array( |
| 195 | - 'id' => $prefix . 'donation_levels', |
|
| 195 | + 'id' => $prefix.'donation_levels', |
|
| 196 | 196 | 'type' => 'group', |
| 197 | 197 | 'options' => array( |
| 198 | - 'add_button' => __( 'Add Level', 'give' ), |
|
| 199 | - 'header_title' => __( 'Donation Level', 'give' ), |
|
| 198 | + 'add_button' => __('Add Level', 'give'), |
|
| 199 | + 'header_title' => __('Donation Level', 'give'), |
|
| 200 | 200 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
| 201 | 201 | ), |
| 202 | 202 | 'wrapper_class' => 'give-hidden', |
| 203 | 203 | // Fields array works the same, except id's only need to be unique for this group. |
| 204 | 204 | // Prefix is not needed. |
| 205 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
| 205 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
| 206 | 206 | array( |
| 207 | - 'name' => __( 'ID', 'give' ), |
|
| 208 | - 'id' => $prefix . 'id', |
|
| 207 | + 'name' => __('ID', 'give'), |
|
| 208 | + 'id' => $prefix.'id', |
|
| 209 | 209 | 'type' => 'levels_id', |
| 210 | 210 | ), |
| 211 | 211 | array( |
| 212 | - 'name' => __( 'Amount', 'give' ), |
|
| 213 | - 'id' => $prefix . 'amount', |
|
| 212 | + 'name' => __('Amount', 'give'), |
|
| 213 | + 'id' => $prefix.'amount', |
|
| 214 | 214 | 'type' => 'text_small', |
| 215 | 215 | 'data_type' => 'price', |
| 216 | 216 | 'attributes' => array( |
@@ -219,112 +219,112 @@ discard block |
||
| 219 | 219 | ), |
| 220 | 220 | ), |
| 221 | 221 | array( |
| 222 | - 'name' => __( 'Text', 'give' ), |
|
| 223 | - 'id' => $prefix . 'text', |
|
| 222 | + 'name' => __('Text', 'give'), |
|
| 223 | + 'id' => $prefix.'text', |
|
| 224 | 224 | 'type' => 'text', |
| 225 | 225 | 'attributes' => array( |
| 226 | - 'placeholder' => __( 'Donation Level', 'give' ), |
|
| 226 | + 'placeholder' => __('Donation Level', 'give'), |
|
| 227 | 227 | 'class' => 'give-multilevel-text-field', |
| 228 | 228 | ), |
| 229 | 229 | ), |
| 230 | 230 | array( |
| 231 | - 'name' => __( 'Default', 'give' ), |
|
| 232 | - 'id' => $prefix . 'default', |
|
| 231 | + 'name' => __('Default', 'give'), |
|
| 232 | + 'id' => $prefix.'default', |
|
| 233 | 233 | 'type' => 'give_default_radio_inline', |
| 234 | 234 | ), |
| 235 | - ) ), |
|
| 235 | + )), |
|
| 236 | 236 | ), |
| 237 | 237 | array( |
| 238 | 238 | 'name' => 'donation_options_docs', |
| 239 | 239 | 'type' => 'docs_link', |
| 240 | 240 | 'url' => 'http://docs.givewp.com/form-donation-options', |
| 241 | - 'title' => __( 'Donation Options', 'give' ), |
|
| 241 | + 'title' => __('Donation Options', 'give'), |
|
| 242 | 242 | ), |
| 243 | 243 | ), |
| 244 | 244 | $post_id |
| 245 | 245 | ), |
| 246 | - ) ), |
|
| 246 | + )), |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * Display Options |
| 250 | 250 | */ |
| 251 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
| 251 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
| 252 | 252 | 'id' => 'form_display_options', |
| 253 | - 'title' => __( 'Form Display', 'give' ), |
|
| 253 | + 'title' => __('Form Display', 'give'), |
|
| 254 | 254 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
| 255 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
| 255 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
| 256 | 256 | array( |
| 257 | - 'name' => __( 'Display Options', 'give' ), |
|
| 258 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
| 259 | - 'id' => $prefix . 'payment_display', |
|
| 257 | + 'name' => __('Display Options', 'give'), |
|
| 258 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
| 259 | + 'id' => $prefix.'payment_display', |
|
| 260 | 260 | 'type' => 'radio_inline', |
| 261 | 261 | 'options' => array( |
| 262 | - 'onpage' => __( 'All Fields', 'give' ), |
|
| 263 | - 'modal' => __( 'Modal', 'give' ), |
|
| 264 | - 'reveal' => __( 'Reveal', 'give' ), |
|
| 265 | - 'button' => __( 'Button', 'give' ), |
|
| 262 | + 'onpage' => __('All Fields', 'give'), |
|
| 263 | + 'modal' => __('Modal', 'give'), |
|
| 264 | + 'reveal' => __('Reveal', 'give'), |
|
| 265 | + 'button' => __('Button', 'give'), |
|
| 266 | 266 | ), |
| 267 | 267 | 'default' => 'onpage', |
| 268 | 268 | ), |
| 269 | 269 | array( |
| 270 | - 'id' => $prefix . 'reveal_label', |
|
| 271 | - 'name' => __( 'Continue Button', 'give' ), |
|
| 272 | - 'desc' => __( 'The button label for displaying the additional payment fields.', 'give' ), |
|
| 270 | + 'id' => $prefix.'reveal_label', |
|
| 271 | + 'name' => __('Continue Button', 'give'), |
|
| 272 | + 'desc' => __('The button label for displaying the additional payment fields.', 'give'), |
|
| 273 | 273 | 'type' => 'text_small', |
| 274 | 274 | 'attributes' => array( |
| 275 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
| 275 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
| 276 | 276 | ), |
| 277 | 277 | 'wrapper_class' => 'give-hidden', |
| 278 | 278 | ), |
| 279 | 279 | array( |
| 280 | - 'id' => $prefix . 'checkout_label', |
|
| 281 | - 'name' => __( 'Submit Button', 'give' ), |
|
| 282 | - 'desc' => __( 'The button label for completing a donation.', 'give' ), |
|
| 280 | + 'id' => $prefix.'checkout_label', |
|
| 281 | + 'name' => __('Submit Button', 'give'), |
|
| 282 | + 'desc' => __('The button label for completing a donation.', 'give'), |
|
| 283 | 283 | 'type' => 'text_small', |
| 284 | 284 | 'attributes' => array( |
| 285 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
| 285 | + 'placeholder' => __('Donate Now', 'give'), |
|
| 286 | 286 | ), |
| 287 | 287 | ), |
| 288 | 288 | array( |
| 289 | - 'name' => __( 'Default Gateway', 'give' ), |
|
| 290 | - 'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
| 291 | - 'id' => $prefix . 'default_gateway', |
|
| 289 | + 'name' => __('Default Gateway', 'give'), |
|
| 290 | + 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
| 291 | + 'id' => $prefix.'default_gateway', |
|
| 292 | 292 | 'type' => 'default_gateway', |
| 293 | 293 | ), |
| 294 | 294 | array( |
| 295 | - 'name' => __( 'Guest Donations', 'give' ), |
|
| 296 | - 'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
| 297 | - 'id' => $prefix . 'logged_in_only', |
|
| 295 | + 'name' => __('Guest Donations', 'give'), |
|
| 296 | + 'desc' => __('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
| 297 | + 'id' => $prefix.'logged_in_only', |
|
| 298 | 298 | 'type' => 'radio_inline', |
| 299 | 299 | 'default' => 'enabled', |
| 300 | 300 | 'options' => array( |
| 301 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 302 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 301 | + 'enabled' => __('Enabled', 'give'), |
|
| 302 | + 'disabled' => __('Disabled', 'give'), |
|
| 303 | 303 | ), |
| 304 | 304 | ), |
| 305 | 305 | array( |
| 306 | - 'name' => __( 'Registration', 'give' ), |
|
| 307 | - 'desc' => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
| 308 | - 'id' => $prefix . 'show_register_form', |
|
| 306 | + 'name' => __('Registration', 'give'), |
|
| 307 | + 'desc' => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
| 308 | + 'id' => $prefix.'show_register_form', |
|
| 309 | 309 | 'type' => 'radio', |
| 310 | 310 | 'options' => array( |
| 311 | - 'none' => __( 'None', 'give' ), |
|
| 312 | - 'registration' => __( 'Registration', 'give' ), |
|
| 313 | - 'login' => __( 'Login', 'give' ), |
|
| 314 | - 'both' => __( 'Registration + Login', 'give' ), |
|
| 311 | + 'none' => __('None', 'give'), |
|
| 312 | + 'registration' => __('Registration', 'give'), |
|
| 313 | + 'login' => __('Login', 'give'), |
|
| 314 | + 'both' => __('Registration + Login', 'give'), |
|
| 315 | 315 | ), |
| 316 | 316 | 'default' => 'none', |
| 317 | 317 | ), |
| 318 | 318 | array( |
| 319 | - 'name' => __( 'Floating Labels', 'give' ), |
|
| 319 | + 'name' => __('Floating Labels', 'give'), |
|
| 320 | 320 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
| 321 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
| 322 | - 'id' => $prefix . 'form_floating_labels', |
|
| 321 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
| 322 | + 'id' => $prefix.'form_floating_labels', |
|
| 323 | 323 | 'type' => 'radio_inline', |
| 324 | 324 | 'options' => array( |
| 325 | - 'global' => __( 'Global Option', 'give' ), |
|
| 326 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 327 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 325 | + 'global' => __('Global Option', 'give'), |
|
| 326 | + 'enabled' => __('Enabled', 'give'), |
|
| 327 | + 'disabled' => __('Disabled', 'give'), |
|
| 328 | 328 | ), |
| 329 | 329 | 'default' => 'global', |
| 330 | 330 | ), |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | 'name' => 'form_display_docs', |
| 333 | 333 | 'type' => 'docs_link', |
| 334 | 334 | 'url' => 'http://docs.givewp.com/form-display-options', |
| 335 | - 'title' => __( 'Form Display', 'give' ), |
|
| 335 | + 'title' => __('Form Display', 'give'), |
|
| 336 | 336 | ), |
| 337 | 337 | ), |
| 338 | 338 | $post_id |
@@ -343,31 +343,31 @@ discard block |
||
| 343 | 343 | /** |
| 344 | 344 | * Donation Goals |
| 345 | 345 | */ |
| 346 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
| 346 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
| 347 | 347 | 'id' => 'donation_goal_options', |
| 348 | - 'title' => __( 'Donation Goal', 'give' ), |
|
| 348 | + 'title' => __('Donation Goal', 'give'), |
|
| 349 | 349 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
| 350 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
| 350 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
| 351 | 351 | // Goals |
| 352 | 352 | array( |
| 353 | - 'name' => __( 'Donation Goal', 'give' ), |
|
| 354 | - 'description' => __( 'Do you want to set a donation goal for this form?', 'give' ), |
|
| 355 | - 'id' => $prefix . 'goal_option', |
|
| 353 | + 'name' => __('Donation Goal', 'give'), |
|
| 354 | + 'description' => __('Do you want to set a donation goal for this form?', 'give'), |
|
| 355 | + 'id' => $prefix.'goal_option', |
|
| 356 | 356 | 'type' => 'radio_inline', |
| 357 | 357 | 'default' => 'disabled', |
| 358 | 358 | 'options' => array( |
| 359 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 360 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 359 | + 'enabled' => __('Enabled', 'give'), |
|
| 360 | + 'disabled' => __('Disabled', 'give'), |
|
| 361 | 361 | ), |
| 362 | 362 | ), |
| 363 | 363 | array( |
| 364 | - 'name' => __( 'Goal Amount', 'give' ), |
|
| 365 | - 'description' => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
| 366 | - 'id' => $prefix . 'set_goal', |
|
| 364 | + 'name' => __('Goal Amount', 'give'), |
|
| 365 | + 'description' => __('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
| 366 | + 'id' => $prefix.'set_goal', |
|
| 367 | 367 | 'type' => 'text_small', |
| 368 | 368 | 'data_type' => 'price', |
| 369 | 369 | 'attributes' => array( |
| 370 | - 'placeholder' => give_format_decimal( '0.00', false, false ), |
|
| 370 | + 'placeholder' => give_format_decimal('0.00', false, false), |
|
| 371 | 371 | 'value' => $goal, |
| 372 | 372 | 'class' => 'give-money-field', |
| 373 | 373 | ), |
@@ -375,97 +375,97 @@ discard block |
||
| 375 | 375 | ), |
| 376 | 376 | |
| 377 | 377 | array( |
| 378 | - 'name' => __( 'Goal Format', 'give' ), |
|
| 379 | - 'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
| 380 | - 'id' => $prefix . 'goal_format', |
|
| 378 | + 'name' => __('Goal Format', 'give'), |
|
| 379 | + 'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
| 380 | + 'id' => $prefix.'goal_format', |
|
| 381 | 381 | 'type' => 'radio_inline', |
| 382 | 382 | 'default' => 'amount', |
| 383 | 383 | 'options' => array( |
| 384 | - 'amount' => __( 'Amount', 'give' ), |
|
| 385 | - 'percentage' => __( 'Percentage', 'give' ), |
|
| 384 | + 'amount' => __('Amount', 'give'), |
|
| 385 | + 'percentage' => __('Percentage', 'give'), |
|
| 386 | 386 | ), |
| 387 | 387 | 'wrapper_class' => 'give-hidden', |
| 388 | 388 | ), |
| 389 | 389 | array( |
| 390 | - 'name' => __( 'Progress Bar Color', 'give' ), |
|
| 391 | - 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ), |
|
| 392 | - 'id' => $prefix . 'goal_color', |
|
| 390 | + 'name' => __('Progress Bar Color', 'give'), |
|
| 391 | + 'desc' => __('Customize the color of the goal progress bar.', 'give'), |
|
| 392 | + 'id' => $prefix.'goal_color', |
|
| 393 | 393 | 'type' => 'colorpicker', |
| 394 | 394 | 'default' => '#2bc253', |
| 395 | 395 | 'wrapper_class' => 'give-hidden', |
| 396 | 396 | ), |
| 397 | 397 | |
| 398 | 398 | array( |
| 399 | - 'name' => __( 'Close Form', 'give' ), |
|
| 400 | - 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
| 401 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
| 399 | + 'name' => __('Close Form', 'give'), |
|
| 400 | + 'desc' => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
| 401 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
| 402 | 402 | 'type' => 'radio_inline', |
| 403 | 403 | 'default' => 'disabled', |
| 404 | 404 | 'options' => array( |
| 405 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 406 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 405 | + 'enabled' => __('Enabled', 'give'), |
|
| 406 | + 'disabled' => __('Disabled', 'give'), |
|
| 407 | 407 | ), |
| 408 | 408 | 'wrapper_class' => 'give-hidden', |
| 409 | 409 | ), |
| 410 | 410 | array( |
| 411 | - 'name' => __( 'Goal Achieved Message', 'give' ), |
|
| 412 | - 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ), |
|
| 413 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
| 411 | + 'name' => __('Goal Achieved Message', 'give'), |
|
| 412 | + 'desc' => __('Do you want to display a custom message when the goal is closed?', 'give'), |
|
| 413 | + 'id' => $prefix.'form_goal_achieved_message', |
|
| 414 | 414 | 'type' => 'wysiwyg', |
| 415 | - 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
| 415 | + 'default' => __('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
| 416 | 416 | 'wrapper_class' => 'give-hidden', |
| 417 | 417 | ), |
| 418 | 418 | array( |
| 419 | 419 | 'name' => 'donation_goal_docs', |
| 420 | 420 | 'type' => 'docs_link', |
| 421 | 421 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
| 422 | - 'title' => __( 'Donation Goal', 'give' ), |
|
| 422 | + 'title' => __('Donation Goal', 'give'), |
|
| 423 | 423 | ), |
| 424 | 424 | ), |
| 425 | 425 | $post_id |
| 426 | 426 | ), |
| 427 | - ) ), |
|
| 427 | + )), |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * Content Field |
| 431 | 431 | */ |
| 432 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
| 432 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
| 433 | 433 | 'id' => 'form_content_options', |
| 434 | - 'title' => __( 'Form Content', 'give' ), |
|
| 434 | + 'title' => __('Form Content', 'give'), |
|
| 435 | 435 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
| 436 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
| 436 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
| 437 | 437 | |
| 438 | 438 | // Donation content. |
| 439 | 439 | array( |
| 440 | - 'name' => __( 'Display Content', 'give' ), |
|
| 441 | - 'description' => __( 'Do you want to add custom content to this form?', 'give' ), |
|
| 442 | - 'id' => $prefix . 'display_content', |
|
| 440 | + 'name' => __('Display Content', 'give'), |
|
| 441 | + 'description' => __('Do you want to add custom content to this form?', 'give'), |
|
| 442 | + 'id' => $prefix.'display_content', |
|
| 443 | 443 | 'type' => 'radio_inline', |
| 444 | 444 | 'options' => array( |
| 445 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 446 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 445 | + 'enabled' => __('Enabled', 'give'), |
|
| 446 | + 'disabled' => __('Disabled', 'give'), |
|
| 447 | 447 | ), |
| 448 | 448 | 'default' => 'disabled', |
| 449 | 449 | ), |
| 450 | 450 | |
| 451 | 451 | // Content placement. |
| 452 | 452 | array( |
| 453 | - 'name' => __( 'Content Placement', 'give' ), |
|
| 454 | - 'description' => __( 'This option controls where the content appears within the donation form.', 'give' ), |
|
| 455 | - 'id' => $prefix . 'content_placement', |
|
| 453 | + 'name' => __('Content Placement', 'give'), |
|
| 454 | + 'description' => __('This option controls where the content appears within the donation form.', 'give'), |
|
| 455 | + 'id' => $prefix.'content_placement', |
|
| 456 | 456 | 'type' => 'radio_inline', |
| 457 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 458 | - 'give_pre_form' => __( 'Above fields', 'give' ), |
|
| 459 | - 'give_post_form' => __( 'Below fields', 'give' ), |
|
| 457 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
| 458 | + 'give_pre_form' => __('Above fields', 'give'), |
|
| 459 | + 'give_post_form' => __('Below fields', 'give'), |
|
| 460 | 460 | ) |
| 461 | 461 | ), |
| 462 | 462 | 'default' => 'give_pre_form', |
| 463 | 463 | 'wrapper_class' => 'give-hidden', |
| 464 | 464 | ), |
| 465 | 465 | array( |
| 466 | - 'name' => __( 'Content', 'give' ), |
|
| 467 | - 'description' => __( 'This content will display on the single give form page.', 'give' ), |
|
| 468 | - 'id' => $prefix . 'form_content', |
|
| 466 | + 'name' => __('Content', 'give'), |
|
| 467 | + 'description' => __('This content will display on the single give form page.', 'give'), |
|
| 468 | + 'id' => $prefix.'form_content', |
|
| 469 | 469 | 'type' => 'wysiwyg', |
| 470 | 470 | 'wrapper_class' => 'give-hidden', |
| 471 | 471 | ), |
@@ -473,51 +473,51 @@ discard block |
||
| 473 | 473 | 'name' => 'form_content_docs', |
| 474 | 474 | 'type' => 'docs_link', |
| 475 | 475 | 'url' => 'http://docs.givewp.com/form-content', |
| 476 | - 'title' => __( 'Form Content', 'give' ), |
|
| 476 | + 'title' => __('Form Content', 'give'), |
|
| 477 | 477 | ), |
| 478 | 478 | ), |
| 479 | 479 | $post_id |
| 480 | 480 | ), |
| 481 | - ) ), |
|
| 481 | + )), |
|
| 482 | 482 | |
| 483 | 483 | /** |
| 484 | 484 | * Terms & Conditions |
| 485 | 485 | */ |
| 486 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
| 486 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
| 487 | 487 | 'id' => 'form_terms_options', |
| 488 | - 'title' => __( 'Terms & Conditions', 'give' ), |
|
| 488 | + 'title' => __('Terms & Conditions', 'give'), |
|
| 489 | 489 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
| 490 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
| 490 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
| 491 | 491 | // Donation Option |
| 492 | 492 | array( |
| 493 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
| 494 | - 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
| 495 | - 'id' => $prefix . 'terms_option', |
|
| 493 | + 'name' => __('Terms and Conditions', 'give'), |
|
| 494 | + 'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
| 495 | + 'id' => $prefix.'terms_option', |
|
| 496 | 496 | 'type' => 'radio_inline', |
| 497 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 498 | - 'global' => __( 'Global Option', 'give' ), |
|
| 499 | - 'enabled' => __( 'Customize', 'give' ), |
|
| 500 | - 'disabled' => __( 'Disable', 'give' ), |
|
| 497 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
| 498 | + 'global' => __('Global Option', 'give'), |
|
| 499 | + 'enabled' => __('Customize', 'give'), |
|
| 500 | + 'disabled' => __('Disable', 'give'), |
|
| 501 | 501 | ) |
| 502 | 502 | ), |
| 503 | 503 | 'default' => 'global', |
| 504 | 504 | ), |
| 505 | 505 | array( |
| 506 | - 'id' => $prefix . 'agree_label', |
|
| 507 | - 'name' => __( 'Agreement Label', 'give' ), |
|
| 508 | - 'desc' => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
| 506 | + 'id' => $prefix.'agree_label', |
|
| 507 | + 'name' => __('Agreement Label', 'give'), |
|
| 508 | + 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
| 509 | 509 | 'type' => 'text', |
| 510 | 510 | 'size' => 'regular', |
| 511 | 511 | 'attributes' => array( |
| 512 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
| 512 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
| 513 | 513 | ), |
| 514 | 514 | 'wrapper_class' => 'give-hidden', |
| 515 | 515 | ), |
| 516 | 516 | array( |
| 517 | - 'id' => $prefix . 'agree_text', |
|
| 518 | - 'name' => __( 'Agreement Text', 'give' ), |
|
| 519 | - 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
| 520 | - 'default' => give_get_option( 'agreement_text' ), |
|
| 517 | + 'id' => $prefix.'agree_text', |
|
| 518 | + 'name' => __('Agreement Text', 'give'), |
|
| 519 | + 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
| 520 | + 'default' => give_get_option('agreement_text'), |
|
| 521 | 521 | 'type' => 'wysiwyg', |
| 522 | 522 | 'wrapper_class' => 'give-hidden', |
| 523 | 523 | ), |
@@ -525,18 +525,18 @@ discard block |
||
| 525 | 525 | 'name' => 'terms_docs', |
| 526 | 526 | 'type' => 'docs_link', |
| 527 | 527 | 'url' => 'http://docs.givewp.com/form-terms', |
| 528 | - 'title' => __( 'Terms and Conditions', 'give' ), |
|
| 528 | + 'title' => __('Terms and Conditions', 'give'), |
|
| 529 | 529 | ), |
| 530 | 530 | ), |
| 531 | 531 | $post_id |
| 532 | 532 | ), |
| 533 | - ) ), |
|
| 533 | + )), |
|
| 534 | 534 | ); |
| 535 | 535 | |
| 536 | 536 | /** |
| 537 | 537 | * Filter the metabox tabbed panel settings. |
| 538 | 538 | */ |
| 539 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
| 539 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
| 540 | 540 | |
| 541 | 541 | // Output. |
| 542 | 542 | return $settings; |
@@ -552,8 +552,8 @@ discard block |
||
| 552 | 552 | add_meta_box( |
| 553 | 553 | $this->get_metabox_ID(), |
| 554 | 554 | $this->get_metabox_label(), |
| 555 | - array( $this, 'output' ), |
|
| 556 | - array( 'give_forms' ), |
|
| 555 | + array($this, 'output'), |
|
| 556 | + array('give_forms'), |
|
| 557 | 557 | 'normal', |
| 558 | 558 | 'high' |
| 559 | 559 | ); |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | function enqueue_script() { |
| 570 | 570 | global $post; |
| 571 | 571 | |
| 572 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
| 572 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
| 573 | 573 | |
| 574 | 574 | } |
| 575 | 575 | } |
@@ -604,32 +604,32 @@ discard block |
||
| 604 | 604 | public function get_tabs() { |
| 605 | 605 | $tabs = array(); |
| 606 | 606 | |
| 607 | - if ( ! empty( $this->settings ) ) { |
|
| 608 | - foreach ( $this->settings as $setting ) { |
|
| 609 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
| 607 | + if ( ! empty($this->settings)) { |
|
| 608 | + foreach ($this->settings as $setting) { |
|
| 609 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
| 610 | 610 | continue; |
| 611 | 611 | } |
| 612 | 612 | $tab = array( |
| 613 | 613 | 'id' => $setting['id'], |
| 614 | 614 | 'label' => $setting['title'], |
| 615 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
| 615 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
| 616 | 616 | ); |
| 617 | 617 | |
| 618 | - if ( $this->has_sub_tab( $setting ) ) { |
|
| 619 | - if ( empty( $setting['sub-fields'] ) ) { |
|
| 618 | + if ($this->has_sub_tab($setting)) { |
|
| 619 | + if (empty($setting['sub-fields'])) { |
|
| 620 | 620 | $tab = array(); |
| 621 | 621 | } else { |
| 622 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
| 622 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
| 623 | 623 | $tab['sub-fields'][] = array( |
| 624 | 624 | 'id' => $sub_fields['id'], |
| 625 | 625 | 'label' => $sub_fields['title'], |
| 626 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
| 626 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
| 627 | 627 | ); |
| 628 | 628 | } |
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - if ( ! empty( $tab ) ) { |
|
| 632 | + if ( ! empty($tab)) { |
|
| 633 | 633 | $tabs[] = $tab; |
| 634 | 634 | } |
| 635 | 635 | } |
@@ -646,33 +646,33 @@ discard block |
||
| 646 | 646 | */ |
| 647 | 647 | public function output() { |
| 648 | 648 | // Bailout. |
| 649 | - if ( $form_data_tabs = $this->get_tabs() ) : |
|
| 650 | - $active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options'; |
|
| 651 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
| 649 | + if ($form_data_tabs = $this->get_tabs()) : |
|
| 650 | + $active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options'; |
|
| 651 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
| 652 | 652 | ?> |
| 653 | 653 | <input id="give_form_active_tab" type="hidden" name="give_form_active_tab"> |
| 654 | 654 | <div class="give-metabox-panel-wrap"> |
| 655 | 655 | <ul class="give-form-data-tabs give-metabox-tabs"> |
| 656 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
| 656 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
| 657 | 657 | <?php |
| 658 | 658 | // Determine if current tab is active. |
| 659 | 659 | $is_active = $active_tab === $form_data_tab['id'] ? true : false; |
| 660 | 660 | ?> |
| 661 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
| 661 | + <li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
| 662 | 662 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
| 663 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
| 663 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
| 664 | 664 | <?php echo $form_data_tab['icon-html']; ?> |
| 665 | 665 | <?php else : ?> |
| 666 | 666 | <span class="give-icon give-icon-default"></span> |
| 667 | 667 | <?php endif; ?> |
| 668 | 668 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
| 669 | 669 | </a> |
| 670 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
| 670 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
| 671 | 671 | <ul class="give-metabox-sub-tabs give-hidden"> |
| 672 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
| 672 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
| 673 | 673 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
| 674 | 674 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
| 675 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
| 675 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
| 676 | 676 | <?php echo $sub_tab['icon-html']; ?> |
| 677 | 677 | <?php else : ?> |
| 678 | 678 | <span class="give-icon give-icon-default"></span> |
@@ -687,30 +687,30 @@ discard block |
||
| 687 | 687 | <?php endforeach; ?> |
| 688 | 688 | </ul> |
| 689 | 689 | |
| 690 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
| 691 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
| 692 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
| 690 | + <?php foreach ($this->settings as $setting) : ?> |
|
| 691 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
| 692 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
| 693 | 693 | <?php |
| 694 | 694 | // Determine if current panel is active. |
| 695 | 695 | $is_active = $active_tab === $setting['id'] ? true : false; |
| 696 | 696 | ?> |
| 697 | - <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>"> |
|
| 698 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
| 699 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
| 700 | - <?php give_render_field( $field ); ?> |
|
| 697 | + <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>"> |
|
| 698 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
| 699 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
| 700 | + <?php give_render_field($field); ?> |
|
| 701 | 701 | <?php endforeach; ?> |
| 702 | 702 | <?php endif; ?> |
| 703 | 703 | </div> |
| 704 | 704 | |
| 705 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
| 705 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
| 706 | 706 | <?php else : ?> |
| 707 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
| 708 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
| 709 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
| 707 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
| 708 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
| 709 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
| 710 | 710 | <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
| 711 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
| 712 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
| 713 | - <?php give_render_field( $sub_field ); ?> |
|
| 711 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
| 712 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
| 713 | + <?php give_render_field($sub_field); ?> |
|
| 714 | 714 | <?php endforeach; ?> |
| 715 | 715 | <?php endif; ?> |
| 716 | 716 | </div> |
@@ -734,9 +734,9 @@ discard block |
||
| 734 | 734 | * |
| 735 | 735 | * @return bool |
| 736 | 736 | */ |
| 737 | - private function has_sub_tab( $field_setting ) { |
|
| 737 | + private function has_sub_tab($field_setting) { |
|
| 738 | 738 | $has_sub_tab = false; |
| 739 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
| 739 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
| 740 | 740 | $has_sub_tab = true; |
| 741 | 741 | } |
| 742 | 742 | |
@@ -750,13 +750,13 @@ discard block |
||
| 750 | 750 | * @return array |
| 751 | 751 | */ |
| 752 | 752 | function cmb2_metabox_settings() { |
| 753 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
| 753 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
| 754 | 754 | $give_forms_settings = $all_cmb2_settings; |
| 755 | 755 | |
| 756 | 756 | // Filter settings: Use only give forms related settings. |
| 757 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
| 758 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
| 759 | - unset( $give_forms_settings[ $index ] ); |
|
| 757 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
| 758 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
| 759 | + unset($give_forms_settings[$index]); |
|
| 760 | 760 | } |
| 761 | 761 | } |
| 762 | 762 | |
@@ -774,96 +774,96 @@ discard block |
||
| 774 | 774 | * |
| 775 | 775 | * @return void |
| 776 | 776 | */ |
| 777 | - public function save( $post_id, $post ) { |
|
| 777 | + public function save($post_id, $post) { |
|
| 778 | 778 | |
| 779 | 779 | // $post_id and $post are required. |
| 780 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
| 780 | + if (empty($post_id) || empty($post)) { |
|
| 781 | 781 | return; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | // Don't save meta boxes for revisions or autosaves. |
| 785 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 785 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
| 786 | 786 | return; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | // Check the nonce. |
| 790 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
| 790 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
| 791 | 791 | return; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
| 795 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
| 795 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
| 796 | 796 | return; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | // Check user has permission to edit. |
| 800 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 800 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 801 | 801 | return; |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | // Fire action before saving form meta. |
| 805 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
| 805 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
| 806 | 806 | |
| 807 | 807 | /** |
| 808 | 808 | * Filter the meta key to save. |
| 809 | 809 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
| 810 | 810 | */ |
| 811 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
| 811 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
| 812 | 812 | |
| 813 | 813 | // Save form meta data. |
| 814 | - if ( ! empty( $form_meta_keys ) ) { |
|
| 815 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
| 814 | + if ( ! empty($form_meta_keys)) { |
|
| 815 | + foreach ($form_meta_keys as $form_meta_key) { |
|
| 816 | 816 | |
| 817 | 817 | // Set default value for checkbox fields. |
| 818 | 818 | if ( |
| 819 | - ! isset( $_POST[ $form_meta_key ] ) |
|
| 820 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
| 819 | + ! isset($_POST[$form_meta_key]) |
|
| 820 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
| 821 | 821 | ) { |
| 822 | - $_POST[ $form_meta_key ] = ''; |
|
| 822 | + $_POST[$form_meta_key] = ''; |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
| 826 | - $setting_field = $this->get_setting_field( $form_meta_key ); |
|
| 827 | - if ( ! empty( $setting_field['type'] ) ) { |
|
| 828 | - switch ( $setting_field['type'] ) { |
|
| 825 | + if (isset($_POST[$form_meta_key])) { |
|
| 826 | + $setting_field = $this->get_setting_field($form_meta_key); |
|
| 827 | + if ( ! empty($setting_field['type'])) { |
|
| 828 | + switch ($setting_field['type']) { |
|
| 829 | 829 | case 'textarea': |
| 830 | 830 | case 'wysiwyg': |
| 831 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
| 831 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
| 832 | 832 | break; |
| 833 | 833 | |
| 834 | 834 | case 'group': |
| 835 | 835 | $form_meta_value = array(); |
| 836 | 836 | |
| 837 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
| 837 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
| 838 | 838 | |
| 839 | 839 | // Do not save template input field values. |
| 840 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
| 840 | + if ('{{row-count-placeholder}}' === $index) { |
|
| 841 | 841 | continue; |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | $group_meta_value = array(); |
| 845 | - foreach ( $group as $field_id => $field_value ) { |
|
| 846 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
| 845 | + foreach ($group as $field_id => $field_value) { |
|
| 846 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
| 847 | 847 | case 'wysiwyg': |
| 848 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
| 848 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
| 849 | 849 | break; |
| 850 | 850 | |
| 851 | 851 | default: |
| 852 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
| 852 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
| 853 | 853 | } |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - if ( ! empty( $group_meta_value ) ) { |
|
| 857 | - $form_meta_value[ $index ] = $group_meta_value; |
|
| 856 | + if ( ! empty($group_meta_value)) { |
|
| 857 | + $form_meta_value[$index] = $group_meta_value; |
|
| 858 | 858 | } |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | // Arrange repeater field keys in order. |
| 862 | - $form_meta_value = array_values( $form_meta_value ); |
|
| 862 | + $form_meta_value = array_values($form_meta_value); |
|
| 863 | 863 | break; |
| 864 | 864 | |
| 865 | 865 | default: |
| 866 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
| 866 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
| 867 | 867 | }// End switch(). |
| 868 | 868 | |
| 869 | 869 | /** |
@@ -873,24 +873,24 @@ discard block |
||
| 873 | 873 | */ |
| 874 | 874 | $form_meta_value = apply_filters( |
| 875 | 875 | 'give_pre_save_form_meta_value', |
| 876 | - $this->sanitize_form_meta( $form_meta_value, $setting_field ), |
|
| 876 | + $this->sanitize_form_meta($form_meta_value, $setting_field), |
|
| 877 | 877 | $form_meta_key, |
| 878 | 878 | $this, |
| 879 | 879 | $post_id |
| 880 | 880 | ); |
| 881 | 881 | |
| 882 | 882 | // Save data. |
| 883 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
| 883 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
| 884 | 884 | |
| 885 | 885 | // Fire after saving form meta key. |
| 886 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
| 886 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
| 887 | 887 | }// End if(). |
| 888 | 888 | }// End if(). |
| 889 | 889 | }// End foreach(). |
| 890 | 890 | }// End if(). |
| 891 | 891 | |
| 892 | 892 | // Fire action after saving form meta. |
| 893 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
| 893 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -903,10 +903,10 @@ discard block |
||
| 903 | 903 | * |
| 904 | 904 | * @return string |
| 905 | 905 | */ |
| 906 | - private function get_field_id( $field ) { |
|
| 906 | + private function get_field_id($field) { |
|
| 907 | 907 | $field_id = ''; |
| 908 | 908 | |
| 909 | - if ( array_key_exists( 'id', $field ) ) { |
|
| 909 | + if (array_key_exists('id', $field)) { |
|
| 910 | 910 | $field_id = $field['id']; |
| 911 | 911 | |
| 912 | 912 | } |
@@ -923,12 +923,12 @@ discard block |
||
| 923 | 923 | * |
| 924 | 924 | * @return array |
| 925 | 925 | */ |
| 926 | - private function get_fields_id( $setting ) { |
|
| 926 | + private function get_fields_id($setting) { |
|
| 927 | 927 | $meta_keys = array(); |
| 928 | 928 | |
| 929 | - if ( ! empty( $setting ) ) { |
|
| 930 | - foreach ( $setting['fields'] as $field ) { |
|
| 931 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
| 929 | + if ( ! empty($setting)) { |
|
| 930 | + foreach ($setting['fields'] as $field) { |
|
| 931 | + if ($field_id = $this->get_field_id($field)) { |
|
| 932 | 932 | $meta_keys[] = $field_id; |
| 933 | 933 | } |
| 934 | 934 | } |
@@ -946,14 +946,14 @@ discard block |
||
| 946 | 946 | * |
| 947 | 947 | * @return array |
| 948 | 948 | */ |
| 949 | - private function get_sub_fields_id( $setting ) { |
|
| 949 | + private function get_sub_fields_id($setting) { |
|
| 950 | 950 | $meta_keys = array(); |
| 951 | 951 | |
| 952 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
| 953 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
| 954 | - if ( ! empty( $fields['fields'] ) ) { |
|
| 955 | - foreach ( $fields['fields'] as $field ) { |
|
| 956 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
| 952 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
| 953 | + foreach ($setting['sub-fields'] as $fields) { |
|
| 954 | + if ( ! empty($fields['fields'])) { |
|
| 955 | + foreach ($fields['fields'] as $field) { |
|
| 956 | + if ($field_id = $this->get_field_id($field)) { |
|
| 957 | 957 | $meta_keys[] = $field_id; |
| 958 | 958 | } |
| 959 | 959 | } |
@@ -974,14 +974,14 @@ discard block |
||
| 974 | 974 | private function get_meta_keys_from_settings() { |
| 975 | 975 | $meta_keys = array(); |
| 976 | 976 | |
| 977 | - foreach ( $this->settings as $setting ) { |
|
| 978 | - if ( $this->has_sub_tab( $setting ) ) { |
|
| 979 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
| 977 | + foreach ($this->settings as $setting) { |
|
| 978 | + if ($this->has_sub_tab($setting)) { |
|
| 979 | + $meta_key = $this->get_sub_fields_id($setting); |
|
| 980 | 980 | } else { |
| 981 | - $meta_key = $this->get_fields_id( $setting ); |
|
| 981 | + $meta_key = $this->get_fields_id($setting); |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
| 984 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | return $meta_keys; |
@@ -998,10 +998,10 @@ discard block |
||
| 998 | 998 | * |
| 999 | 999 | * @return string |
| 1000 | 1000 | */ |
| 1001 | - function get_field_type( $field_id, $group_id = '' ) { |
|
| 1002 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
| 1001 | + function get_field_type($field_id, $group_id = '') { |
|
| 1002 | + $field = $this->get_setting_field($field_id, $group_id); |
|
| 1003 | 1003 | |
| 1004 | - $type = array_key_exists( 'type', $field ) |
|
| 1004 | + $type = array_key_exists('type', $field) |
|
| 1005 | 1005 | ? $field['type'] |
| 1006 | 1006 | : ''; |
| 1007 | 1007 | |
@@ -1019,12 +1019,12 @@ discard block |
||
| 1019 | 1019 | * |
| 1020 | 1020 | * @return array |
| 1021 | 1021 | */ |
| 1022 | - private function get_field( $setting, $field_id ) { |
|
| 1022 | + private function get_field($setting, $field_id) { |
|
| 1023 | 1023 | $setting_field = array(); |
| 1024 | 1024 | |
| 1025 | - if ( ! empty( $setting['fields'] ) ) { |
|
| 1026 | - foreach ( $setting['fields'] as $field ) { |
|
| 1027 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
| 1025 | + if ( ! empty($setting['fields'])) { |
|
| 1026 | + foreach ($setting['fields'] as $field) { |
|
| 1027 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
| 1028 | 1028 | $setting_field = $field; |
| 1029 | 1029 | break; |
| 1030 | 1030 | } |
@@ -1044,12 +1044,12 @@ discard block |
||
| 1044 | 1044 | * |
| 1045 | 1045 | * @return array |
| 1046 | 1046 | */ |
| 1047 | - private function get_sub_field( $setting, $field_id ) { |
|
| 1047 | + private function get_sub_field($setting, $field_id) { |
|
| 1048 | 1048 | $setting_field = array(); |
| 1049 | 1049 | |
| 1050 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
| 1051 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
| 1052 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
| 1050 | + if ( ! empty($setting['sub-fields'])) { |
|
| 1051 | + foreach ($setting['sub-fields'] as $fields) { |
|
| 1052 | + if ($field = $this->get_field($fields, $field_id)) { |
|
| 1053 | 1053 | $setting_field = $field; |
| 1054 | 1054 | break; |
| 1055 | 1055 | } |
@@ -1069,17 +1069,17 @@ discard block |
||
| 1069 | 1069 | * |
| 1070 | 1070 | * @return array |
| 1071 | 1071 | */ |
| 1072 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
| 1072 | + function get_setting_field($field_id, $group_id = '') { |
|
| 1073 | 1073 | $setting_field = array(); |
| 1074 | 1074 | |
| 1075 | 1075 | $_field_id = $field_id; |
| 1076 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
| 1076 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
| 1077 | 1077 | |
| 1078 | - if ( ! empty( $this->settings ) ) { |
|
| 1079 | - foreach ( $this->settings as $setting ) { |
|
| 1078 | + if ( ! empty($this->settings)) { |
|
| 1079 | + foreach ($this->settings as $setting) { |
|
| 1080 | 1080 | if ( |
| 1081 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
| 1082 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
| 1081 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
| 1082 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
| 1083 | 1083 | ) { |
| 1084 | 1084 | break; |
| 1085 | 1085 | } |
@@ -1087,9 +1087,9 @@ discard block |
||
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | // Get field from group. |
| 1090 | - if ( ! empty( $group_id ) ) { |
|
| 1091 | - foreach ( $setting_field['fields'] as $field ) { |
|
| 1092 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
| 1090 | + if ( ! empty($group_id)) { |
|
| 1091 | + foreach ($setting_field['fields'] as $field) { |
|
| 1092 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
| 1093 | 1093 | $setting_field = $field; |
| 1094 | 1094 | } |
| 1095 | 1095 | } |
@@ -1108,14 +1108,14 @@ discard block |
||
| 1108 | 1108 | * |
| 1109 | 1109 | * @return mixed |
| 1110 | 1110 | */ |
| 1111 | - function add_offline_donations_setting_tab( $settings ) { |
|
| 1112 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
| 1113 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
| 1111 | + function add_offline_donations_setting_tab($settings) { |
|
| 1112 | + if (give_is_gateway_active('offline')) { |
|
| 1113 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
| 1114 | 1114 | 'id' => 'offline_donations_options', |
| 1115 | - 'title' => __( 'Offline Donations', 'give' ), |
|
| 1115 | + 'title' => __('Offline Donations', 'give'), |
|
| 1116 | 1116 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
| 1117 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
| 1118 | - ) ); |
|
| 1117 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
| 1118 | + )); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | return $settings; |
@@ -1133,22 +1133,22 @@ discard block |
||
| 1133 | 1133 | * |
| 1134 | 1134 | * @return mixed |
| 1135 | 1135 | */ |
| 1136 | - function sanitize_form_meta( $meta_value, $setting_field ) { |
|
| 1137 | - switch ( $setting_field['type'] ) { |
|
| 1136 | + function sanitize_form_meta($meta_value, $setting_field) { |
|
| 1137 | + switch ($setting_field['type']) { |
|
| 1138 | 1138 | case 'group': |
| 1139 | - if ( ! empty( $setting_field['fields'] ) ) { |
|
| 1140 | - foreach ( $setting_field['fields'] as $field ) { |
|
| 1141 | - if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) { |
|
| 1139 | + if ( ! empty($setting_field['fields'])) { |
|
| 1140 | + foreach ($setting_field['fields'] as $field) { |
|
| 1141 | + if (empty($field['data_type']) || 'price' !== $field['data_type']) { |
|
| 1142 | 1142 | continue; |
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | - foreach ( $meta_value as $index => $meta_data ) { |
|
| 1146 | - if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) { |
|
| 1145 | + foreach ($meta_value as $index => $meta_data) { |
|
| 1146 | + if ( ! isset($meta_value[$index][$field['id']])) { |
|
| 1147 | 1147 | continue; |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - $meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) |
|
| 1151 | - ? give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) |
|
| 1150 | + $meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']]) |
|
| 1151 | + ? give_sanitize_amount_for_db($meta_value[$index][$field['id']]) |
|
| 1152 | 1152 | : 0; |
| 1153 | 1153 | } |
| 1154 | 1154 | } |
@@ -1156,8 +1156,8 @@ discard block |
||
| 1156 | 1156 | break; |
| 1157 | 1157 | |
| 1158 | 1158 | default: |
| 1159 | - if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) { |
|
| 1160 | - $meta_value = $meta_value ? give_sanitize_amount_for_db( $meta_value ) : 0; |
|
| 1159 | + if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) { |
|
| 1160 | + $meta_value = $meta_value ? give_sanitize_amount_for_db($meta_value) : 0; |
|
| 1161 | 1161 | } |
| 1162 | 1162 | } |
| 1163 | 1163 | |
@@ -1175,12 +1175,12 @@ discard block |
||
| 1175 | 1175 | * |
| 1176 | 1176 | * @return string The URL after redirect. |
| 1177 | 1177 | */ |
| 1178 | - public function maintain_active_tab( $location, $post_id ) { |
|
| 1178 | + public function maintain_active_tab($location, $post_id) { |
|
| 1179 | 1179 | if ( |
| 1180 | - 'give_forms' === get_post_type( $post_id ) && |
|
| 1181 | - ! empty( $_POST['give_form_active_tab'] ) |
|
| 1180 | + 'give_forms' === get_post_type($post_id) && |
|
| 1181 | + ! empty($_POST['give_form_active_tab']) |
|
| 1182 | 1182 | ) { |
| 1183 | - $location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location ); |
|
| 1183 | + $location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | return $location; |
@@ -662,9 +662,12 @@ discard block |
||
| 662 | 662 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
| 663 | 663 | <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
| 664 | 664 | <?php echo $form_data_tab['icon-html']; ?> |
| 665 | - <?php else : ?> |
|
| 665 | + <?php else { |
|
| 666 | + : ?> |
|
| 666 | 667 | <span class="give-icon give-icon-default"></span> |
| 667 | - <?php endif; ?> |
|
| 668 | + <?php endif; |
|
| 669 | +} |
|
| 670 | +?> |
|
| 668 | 671 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
| 669 | 672 | </a> |
| 670 | 673 | <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
@@ -674,9 +677,12 @@ discard block |
||
| 674 | 677 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
| 675 | 678 | <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
| 676 | 679 | <?php echo $sub_tab['icon-html']; ?> |
| 677 | - <?php else : ?> |
|
| 680 | + <?php else { |
|
| 681 | + : ?> |
|
| 678 | 682 | <span class="give-icon give-icon-default"></span> |
| 679 | - <?php endif; ?> |
|
| 683 | + <?php endif; |
|
| 684 | +} |
|
| 685 | +?> |
|
| 680 | 686 | <span class="give-label"><?php echo $sub_tab['label']; ?></span> |
| 681 | 687 | </a> |
| 682 | 688 | </li> |
@@ -703,11 +709,14 @@ discard block |
||
| 703 | 709 | </div> |
| 704 | 710 | |
| 705 | 711 | <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
| 706 | - <?php else : ?> |
|
| 712 | + <?php else { |
|
| 713 | + : ?> |
|
| 707 | 714 | <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
| 708 | 715 | <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
| 709 | 716 | <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
| 710 | - <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
|
| 717 | + <div id="<?php echo $sub_fields['id']; |
|
| 718 | +} |
|
| 719 | +?>" class="panel give_options_panel give-hidden"> |
|
| 711 | 720 | <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
| 712 | 721 | <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
| 713 | 722 | <?php give_render_field( $sub_field ); ?> |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.8.13 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -75,63 +75,63 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function init() { |
| 77 | 77 | // Bail early if screen cannot be detected. |
| 78 | - if ( empty( $this->screen ) ) { |
|
| 78 | + if (empty($this->screen)) { |
|
| 79 | 79 | return null; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $content = array(); |
| 83 | 83 | |
| 84 | 84 | // Define content and hook into the appropriate action. |
| 85 | - switch ( $this->screen ) { |
|
| 85 | + switch ($this->screen) { |
|
| 86 | 86 | // Forms screen. |
| 87 | 87 | case 'edit-give_forms': |
| 88 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 88 | + $this->form = $this->post_exists('give_forms'); |
|
| 89 | 89 | |
| 90 | - if ( $this->form ) { |
|
| 90 | + if ($this->form) { |
|
| 91 | 91 | // Form exists. Bail out. |
| 92 | 92 | return false; |
| 93 | 93 | } else { |
| 94 | 94 | // No forms exist. |
| 95 | - $content = $this->get_content( 'no_forms' ); |
|
| 95 | + $content = $this->get_content('no_forms'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) ); |
|
| 98 | + add_action('manage_posts_extra_tablenav', array($this, 'render')); |
|
| 99 | 99 | break; |
| 100 | 100 | // Donations screen. |
| 101 | 101 | case 'give_forms_page_give-payment-history': |
| 102 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 103 | - $this->donation = $this->post_exists( 'give_payment' ); |
|
| 102 | + $this->form = $this->post_exists('give_forms'); |
|
| 103 | + $this->donation = $this->post_exists('give_payment'); |
|
| 104 | 104 | |
| 105 | - if ( $this->donation ) { |
|
| 105 | + if ($this->donation) { |
|
| 106 | 106 | // Donation exists. Bail out. |
| 107 | 107 | return false; |
| 108 | - } elseif ( ! $this->form ) { |
|
| 108 | + } elseif ( ! $this->form) { |
|
| 109 | 109 | // No forms and no donations exist. |
| 110 | - $content = $this->get_content( 'no_donations_or_forms' ); |
|
| 110 | + $content = $this->get_content('no_donations_or_forms'); |
|
| 111 | 111 | } else { |
| 112 | 112 | // No donations exist but a form does exist. |
| 113 | - $content = $this->get_content( 'no_donations' ); |
|
| 113 | + $content = $this->get_content('no_donations'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - add_action( 'give_payments_page_bottom', array( $this, 'render' ) ); |
|
| 116 | + add_action('give_payments_page_bottom', array($this, 'render')); |
|
| 117 | 117 | break; |
| 118 | 118 | // Donors screen. |
| 119 | 119 | case 'give_forms_page_give-donors': |
| 120 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 120 | + $this->form = $this->post_exists('give_forms'); |
|
| 121 | 121 | $this->donor = $this->donor_exists(); |
| 122 | 122 | |
| 123 | - if ( $this->donor ) { |
|
| 123 | + if ($this->donor) { |
|
| 124 | 124 | // Donor exists. Bail out. |
| 125 | 125 | return false; |
| 126 | - } elseif ( ! $this->form ) { |
|
| 126 | + } elseif ( ! $this->form) { |
|
| 127 | 127 | // No forms and no donors exist. |
| 128 | - $content = $this->get_content( 'no_donors_or_forms' ); |
|
| 128 | + $content = $this->get_content('no_donors_or_forms'); |
|
| 129 | 129 | } else { |
| 130 | 130 | // No donors exist but a form does exist. |
| 131 | - $content = $this->get_content( 'no_donors' ); |
|
| 131 | + $content = $this->get_content('no_donors'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - add_action( 'give_donors_table_bottom', array( $this, 'render' ) ); |
|
| 134 | + add_action('give_donors_table_bottom', array($this, 'render')); |
|
| 135 | 135 | break; |
| 136 | 136 | default: |
| 137 | 137 | return null; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $this->content = $content; |
| 141 | 141 | |
| 142 | 142 | // Hide non-essential UI elements. |
| 143 | - add_action( 'admin_head', array( $this, 'hide_ui' ) ); |
|
| 143 | + add_action('admin_head', array($this, 'hide_ui')); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @param string $which The location of the list table hook: 'top' or 'bottom'. |
| 152 | 152 | */ |
| 153 | - public function render( $which = 'bottom') { |
|
| 153 | + public function render($which = 'bottom') { |
|
| 154 | 154 | // Bail out to prevent content from rendering twice. |
| 155 | - if ( 'top' === $which ) { |
|
| 155 | + if ('top' === $which) { |
|
| 156 | 156 | return null; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * @param string $screen The current screen ID. |
| 179 | 179 | */ |
| 180 | - $content = apply_filters( 'give_blank_slate_content', $this->content, $screen ); |
|
| 180 | + $content = apply_filters('give_blank_slate_content', $this->content, $screen); |
|
| 181 | 181 | |
| 182 | - $template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php'; |
|
| 182 | + $template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php'; |
|
| 183 | 183 | |
| 184 | 184 | include $template_path; |
| 185 | 185 | } |
@@ -201,17 +201,17 @@ discard block |
||
| 201 | 201 | * @param string $post_type Post type used in the query. |
| 202 | 202 | * @return bool True if post exists, otherwise false. |
| 203 | 203 | */ |
| 204 | - private function post_exists( $post_type ) { |
|
| 204 | + private function post_exists($post_type) { |
|
| 205 | 205 | // Attempt to get a single post of the post type. |
| 206 | - $query = new WP_Query( array( |
|
| 206 | + $query = new WP_Query(array( |
|
| 207 | 207 | 'post_type' => $post_type, |
| 208 | 208 | 'posts_per_page' => 1, |
| 209 | 209 | 'no_found_rows' => false, |
| 210 | 210 | 'update_post_meta_cache' => false, |
| 211 | 211 | 'update_post_term_cache' => false, |
| 212 | 212 | 'fields' => 'ids', |
| 213 | - 'post_status' => array( 'any', 'trash' ), |
|
| 214 | - ) ); |
|
| 213 | + 'post_status' => array('any', 'trash'), |
|
| 214 | + )); |
|
| 215 | 215 | |
| 216 | 216 | return $query->have_posts(); |
| 217 | 217 | } |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | * @return bool True if donor exists, otherwise false. |
| 225 | 225 | */ |
| 226 | 226 | private function donor_exists() { |
| 227 | - $donors = Give()->donors->get_donors( array( 'number' => 1 ) ); |
|
| 227 | + $donors = Give()->donors->get_donors(array('number' => 1)); |
|
| 228 | 228 | |
| 229 | - return ! empty( $donors ); |
|
| 229 | + return ! empty($donors); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | * @param string $context The key used to determine which content is returned. |
| 238 | 238 | * @return array Blank slate content. |
| 239 | 239 | */ |
| 240 | - private function get_content( $context ) { |
|
| 240 | + private function get_content($context) { |
|
| 241 | 241 | // Define default content. |
| 242 | 242 | $defaults = array( |
| 243 | - 'image_url' => GIVE_PLUGIN_URL . 'assets/images/svg/give-icon-full-circle.svg', |
|
| 244 | - 'image_alt' => __( 'Give Icon', 'give' ), |
|
| 245 | - 'heading' => __( 'No donation forms found.', 'give' ), |
|
| 246 | - 'message' => __( 'The first step towards accepting online donations is to create a form.', 'give' ), |
|
| 247 | - 'cta_text' => __( 'Create Donation Form', 'give' ), |
|
| 248 | - 'cta_link' => admin_url( 'post-new.php?post_type=give_forms' ), |
|
| 243 | + 'image_url' => GIVE_PLUGIN_URL.'assets/images/svg/give-icon-full-circle.svg', |
|
| 244 | + 'image_alt' => __('Give Icon', 'give'), |
|
| 245 | + 'heading' => __('No donation forms found.', 'give'), |
|
| 246 | + 'message' => __('The first step towards accepting online donations is to create a form.', 'give'), |
|
| 247 | + 'cta_text' => __('Create Donation Form', 'give'), |
|
| 248 | + 'cta_link' => admin_url('post-new.php?post_type=give_forms'), |
|
| 249 | 249 | 'help' => sprintf( |
| 250 | - __( 'Need help? Get started with %sGive 101%s.', 'wbpr' ), |
|
| 250 | + __('Need help? Get started with %sGive 101%s.', 'wbpr'), |
|
| 251 | 251 | '<a href="http://docs.givewp.com/give101/" target="_blank">', |
| 252 | 252 | '</a>' |
| 253 | 253 | ), |
@@ -256,40 +256,40 @@ discard block |
||
| 256 | 256 | // Define contextual content. |
| 257 | 257 | $content = array( |
| 258 | 258 | 'no_donations_or_forms' => array( |
| 259 | - 'heading' => __( 'No donations found.', 'give' ), |
|
| 260 | - 'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ), |
|
| 259 | + 'heading' => __('No donations found.', 'give'), |
|
| 260 | + 'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'), |
|
| 261 | 261 | ), |
| 262 | 262 | 'no_donations' => array( |
| 263 | - 'heading' => __( 'No donations found.', 'give' ), |
|
| 264 | - 'message' => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ), |
|
| 265 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
| 266 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
| 263 | + 'heading' => __('No donations found.', 'give'), |
|
| 264 | + 'message' => __('When your first donation arrives, a record of the donation will appear here.', 'give'), |
|
| 265 | + 'cta_text' => __('View All Forms', 'give'), |
|
| 266 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
| 267 | 267 | 'help' => sprintf( |
| 268 | - __( 'Need help? Learn more about %sDonations%s.', 'wbpr' ), |
|
| 268 | + __('Need help? Learn more about %sDonations%s.', 'wbpr'), |
|
| 269 | 269 | '<a href="http://docs.givewp.com/core-donations/">', |
| 270 | 270 | '</a>' |
| 271 | 271 | ), |
| 272 | 272 | ), |
| 273 | 273 | 'no_donors_or_forms' => array( |
| 274 | - 'heading' => __( 'No donors found.', 'give' ), |
|
| 275 | - 'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ), |
|
| 274 | + 'heading' => __('No donors found.', 'give'), |
|
| 275 | + 'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'), |
|
| 276 | 276 | ), |
| 277 | 277 | 'no_donors' => array( |
| 278 | - 'heading' => __( 'No donors found.', 'give' ), |
|
| 279 | - 'message' => __( 'When your first donation arrives, the donor will appear here.', 'give' ), |
|
| 280 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
| 281 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
| 278 | + 'heading' => __('No donors found.', 'give'), |
|
| 279 | + 'message' => __('When your first donation arrives, the donor will appear here.', 'give'), |
|
| 280 | + 'cta_text' => __('View All Forms', 'give'), |
|
| 281 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
| 282 | 282 | 'help' => sprintf( |
| 283 | - __( 'Need help? Learn more about %sDonors%s.', 'wbpr' ), |
|
| 283 | + __('Need help? Learn more about %sDonors%s.', 'wbpr'), |
|
| 284 | 284 | '<a href="http://docs.givewp.com/core-donors/">', |
| 285 | 285 | '</a>' |
| 286 | 286 | ), |
| 287 | 287 | ), |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - if ( isset( $content[ $context ] ) ) { |
|
| 290 | + if (isset($content[$context])) { |
|
| 291 | 291 | // Merge contextual content with defaults. |
| 292 | - return wp_parse_args( $content[ $context ], $defaults ); |
|
| 292 | + return wp_parse_args($content[$context], $defaults); |
|
| 293 | 293 | } else { |
| 294 | 294 | // Return defaults if context is undefined. |
| 295 | 295 | return $defaults; |
@@ -2,13 +2,13 @@ discard block |
||
| 2 | 2 | /** |
| 3 | 3 | * Admin View: Settings |
| 4 | 4 | */ |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | +if ( ! defined('ABSPATH')) { |
|
| 6 | 6 | exit; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | // Bailout: Do not output anything if setting tab is not defined. |
| 11 | -if( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
| 11 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
| 12 | 12 | /** |
| 13 | 13 | * Filter the form action. |
| 14 | 14 | * |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @since 1.8 |
| 20 | 20 | */ |
| 21 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
| 21 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Filter the main form tab. |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @since 1.8 |
| 32 | 32 | */ |
| 33 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
| 34 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
| 33 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
| 34 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
| 35 | 35 | ?> |
| 36 | - <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>"> |
|
| 36 | + <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>"> |
|
| 37 | 37 | <?php echo $form_open_tag; ?> |
| 38 | 38 | <h2></h2> |
| 39 | 39 | <?php |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | ?> |
| 43 | 43 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
| 44 | 44 | <?php |
| 45 | - foreach ( $tabs as $name => $label ) { |
|
| 46 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
| 45 | + foreach ($tabs as $name => $label) { |
|
| 46 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab == $name ? 'nav-tab-active' : '').'">'.$label.'</a>'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @since 1.8 |
| 57 | 57 | */ |
| 58 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
| 58 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
| 59 | 59 | ?> |
| 60 | 60 | </div> |
| 61 | 61 | <div class="give-sub-nav-tab-wrapper"> |
| 62 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a> |
|
| 62 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a> |
|
| 63 | 63 | <nav class="give-sub-nav-tab give-hidden"></nav> |
| 64 | 64 | </div> |
| 65 | - <h1 class="screen-reader-text"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
| 65 | + <h1 class="screen-reader-text"><?php echo esc_html($tabs[$current_tab]); ?></h1> |
|
| 66 | 66 | <?php |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @since 1.8 |
| 76 | 76 | */ |
| 77 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
| 77 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Trigger Action. |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @since 1.8 |
| 87 | 87 | */ |
| 88 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
| 88 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
| 89 | 89 | |
| 90 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
| 90 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
| 91 | 91 | <div class="give-submit-wrap"> |
| 92 | - <?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?> |
|
| 93 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'give' ); ?>" /> |
|
| 92 | + <?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?> |
|
| 93 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e('Save changes', 'give'); ?>" /> |
|
| 94 | 94 | </div> |
| 95 | 95 | <?php endif; ?> |
| 96 | 96 | <?php echo $form_close_tag; ?> |
| 97 | 97 | </div> |
| 98 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
| 98 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
| 99 | 99 | <?php endif; ?> |
| 100 | 100 | \ No newline at end of file |
@@ -95,5 +95,8 @@ |
||
| 95 | 95 | <?php endif; ?> |
| 96 | 96 | <?php echo $form_close_tag; ?> |
| 97 | 97 | </div> |
| 98 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
| 98 | +<?php else { |
|
| 99 | + : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
| 100 | +} |
|
| 101 | +?> |
|
| 99 | 102 | <?php endif; ?> |
| 100 | 103 | \ No newline at end of file |
@@ -17,23 +17,23 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div class="give-blank-slate"> |
| 20 | - <?php if ( ! empty( $content['image_url'] ) ) : ?> |
|
| 21 | - <img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>"> |
|
| 20 | + <?php if ( ! empty($content['image_url'])) : ?> |
|
| 21 | + <img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>"> |
|
| 22 | 22 | <?php endif; ?> |
| 23 | 23 | |
| 24 | - <?php if ( ! empty( $content['heading'] ) ) : ?> |
|
| 25 | - <h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2> |
|
| 24 | + <?php if ( ! empty($content['heading'])) : ?> |
|
| 25 | + <h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2> |
|
| 26 | 26 | <?php endif; ?> |
| 27 | 27 | |
| 28 | - <?php if ( ! empty( $content['message'] ) ) : ?> |
|
| 29 | - <p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p> |
|
| 28 | + <?php if ( ! empty($content['message'])) : ?> |
|
| 29 | + <p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p> |
|
| 30 | 30 | <?php endif; ?> |
| 31 | 31 | |
| 32 | - <?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?> |
|
| 33 | - <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a> |
|
| 32 | + <?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?> |
|
| 33 | + <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a> |
|
| 34 | 34 | <?php endif; ?> |
| 35 | 35 | |
| 36 | - <?php if ( ! empty( $content['help'] ) ) : ?> |
|
| 36 | + <?php if ( ! empty($content['help'])) : ?> |
|
| 37 | 37 | <p class="give-blank-slate__help"> |
| 38 | 38 | <?php |
| 39 | 39 | $allowed_html = array( |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'code' => array(), |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - echo wp_kses( $content['help'], $allowed_html ); |
|
| 50 | + echo wp_kses($content['help'], $allowed_html); |
|
| 51 | 51 | ?> |
| 52 | 52 | </p> |
| 53 | 53 | <?php endif; ?> |
@@ -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 | |
@@ -80,104 +80,102 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function get_data() { |
| 82 | 82 | |
| 83 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
| 84 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 85 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
| 86 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 83 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
| 84 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 85 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
| 86 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 87 | 87 | |
| 88 | - if ( false === $totals ) { |
|
| 88 | + if (false === $totals) { |
|
| 89 | 89 | $totals = array(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if ( false === $payment_items ) { |
|
| 92 | + if (false === $payment_items) { |
|
| 93 | 93 | $payment_items = array(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if ( false === $processed_payments ) { |
|
| 96 | + if (false === $processed_payments) { |
|
| 97 | 97 | $processed_payments = array(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 100 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 101 | 101 | |
| 102 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
| 102 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
| 103 | 103 | |
| 104 | - if ( false === $payments ) { |
|
| 105 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 104 | + if (false === $payments) { |
|
| 105 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 106 | 106 | 'post_parent__in' => $all_forms, |
| 107 | 107 | 'number' => $this->per_step, |
| 108 | 108 | 'status' => 'publish', |
| 109 | 109 | 'paged' => $this->step, |
| 110 | 110 | 'output' => 'payments', |
| 111 | - ) ); |
|
| 111 | + )); |
|
| 112 | 112 | |
| 113 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 113 | + $payments_query = new Give_Payments_Query($args); |
|
| 114 | 114 | $payments = $payments_query->get_payments(); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $payments ) { |
|
| 117 | + if ($payments) { |
|
| 118 | 118 | |
| 119 | 119 | //Loop through payments |
| 120 | - foreach ( $payments as $payment ) { |
|
| 120 | + foreach ($payments as $payment) { |
|
| 121 | 121 | |
| 122 | 122 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
| 123 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
| 123 | + if (in_array($payment->ID, $processed_payments)) { |
|
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // Verify accepted status |
| 128 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 128 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 129 | 129 | $processed_payments[] = $payment->ID; |
| 130 | 130 | continue; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $payment_item = $payment_items[ $payment->ID ]; |
|
| 133 | + $payment_item = $payment_items[$payment->ID]; |
|
| 134 | 134 | |
| 135 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
| 135 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
| 136 | 136 | |
| 137 | 137 | //Must have a form ID |
| 138 | - if ( empty( $form_id ) ) { |
|
| 138 | + if (empty($form_id)) { |
|
| 139 | 139 | continue; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | //Form ID must be within $all_forms array to be validated |
| 143 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
| 143 | + if ( ! in_array($form_id, $all_forms)) { |
|
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Set Sales count |
| 148 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
| 149 | - ++ $totals[ $form_id ]['sales'] : |
|
| 150 | - 1; |
|
| 148 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
| 149 | + ++$totals[$form_id]['sales'] : 1; |
|
| 151 | 150 | |
| 152 | 151 | // Set Total Earnings |
| 153 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
| 154 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
| 155 | - $payment_item['price']; |
|
| 152 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
| 153 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
| 156 | 154 | |
| 157 | 155 | $processed_payments[] = $payment->ID; |
| 158 | 156 | } |
| 159 | 157 | |
| 160 | 158 | // Get the list of form ids which does not contain any payment record. |
| 161 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
| 162 | - foreach ( $remaining_form_ids as $form_id ) { |
|
| 159 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
| 160 | + foreach ($remaining_form_ids as $form_id) { |
|
| 163 | 161 | //If array key doesn't exist, create it |
| 164 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
| 165 | - $totals[ $form_id ] = array( |
|
| 162 | + if ( ! array_key_exists($form_id, $totals)) { |
|
| 163 | + $totals[$form_id] = array( |
|
| 166 | 164 | 'sales' => (int) 0, |
| 167 | 165 | 'earnings' => (float) 0, |
| 168 | 166 | ); |
| 169 | 167 | } |
| 170 | 168 | } |
| 171 | 169 | |
| 172 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
| 173 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
| 170 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
| 171 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
| 174 | 172 | |
| 175 | 173 | return true; |
| 176 | 174 | } |
| 177 | 175 | |
| 178 | - foreach ( $totals as $key => $stats ) { |
|
| 179 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
| 180 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
| 176 | + foreach ($totals as $key => $stats) { |
|
| 177 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
| 178 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
| 181 | 179 | } |
| 182 | 180 | |
| 183 | 181 | return false; |
@@ -192,20 +190,20 @@ discard block |
||
| 192 | 190 | */ |
| 193 | 191 | public function get_percentage_complete() { |
| 194 | 192 | |
| 195 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 193 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 196 | 194 | |
| 197 | - if ( false === $total ) { |
|
| 195 | + if (false === $total) { |
|
| 198 | 196 | $this->pre_fetch(); |
| 199 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 197 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 200 | 198 | } |
| 201 | 199 | |
| 202 | 200 | $percentage = 100; |
| 203 | 201 | |
| 204 | - if ( $total > 0 ) { |
|
| 205 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 202 | + if ($total > 0) { |
|
| 203 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 206 | 204 | } |
| 207 | 205 | |
| 208 | - if ( $percentage > 100 ) { |
|
| 206 | + if ($percentage > 100) { |
|
| 209 | 207 | $percentage = 100; |
| 210 | 208 | } |
| 211 | 209 | |
@@ -219,8 +217,8 @@ discard block |
||
| 219 | 217 | * |
| 220 | 218 | * @param array $request The Form Data passed into the batch processing |
| 221 | 219 | */ |
| 222 | - public function set_properties( $request ) { |
|
| 223 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 220 | + public function set_properties($request) { |
|
| 221 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 224 | 222 | } |
| 225 | 223 | |
| 226 | 224 | /** |
@@ -231,35 +229,35 @@ discard block |
||
| 231 | 229 | */ |
| 232 | 230 | public function process_step() { |
| 233 | 231 | |
| 234 | - if ( ! $this->can_export() ) { |
|
| 235 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 232 | + if ( ! $this->can_export()) { |
|
| 233 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 236 | 234 | } |
| 237 | 235 | |
| 238 | 236 | $had_data = $this->get_data(); |
| 239 | 237 | |
| 240 | - if ( $had_data ) { |
|
| 238 | + if ($had_data) { |
|
| 241 | 239 | $this->done = false; |
| 242 | 240 | |
| 243 | 241 | return true; |
| 244 | 242 | } else { |
| 245 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 246 | - $this->delete_data( 'give_recount_all_total' ); |
|
| 247 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 248 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 249 | - $this->delete_data( 'give_temp_form_ids' ); |
|
| 250 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 243 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 244 | + $this->delete_data('give_recount_all_total'); |
|
| 245 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 246 | + $this->delete_data('give_temp_payment_items'); |
|
| 247 | + $this->delete_data('give_temp_form_ids'); |
|
| 248 | + $this->delete_data('give_temp_processed_payments'); |
|
| 251 | 249 | $this->done = true; |
| 252 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
| 250 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
| 253 | 251 | |
| 254 | 252 | return false; |
| 255 | 253 | } |
| 256 | 254 | } |
| 257 | 255 | |
| 258 | 256 | public function headers() { |
| 259 | - ignore_user_abort( true ); |
|
| 257 | + ignore_user_abort(true); |
|
| 260 | 258 | |
| 261 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 262 | - set_time_limit( 0 ); |
|
| 259 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 260 | + set_time_limit(0); |
|
| 263 | 261 | } |
| 264 | 262 | } |
| 265 | 263 | |
@@ -286,69 +284,69 @@ discard block |
||
| 286 | 284 | */ |
| 287 | 285 | public function pre_fetch() { |
| 288 | 286 | |
| 289 | - if ( $this->step == 1 ) { |
|
| 290 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
| 291 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 292 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 293 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 294 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
| 287 | + if ($this->step == 1) { |
|
| 288 | + $this->delete_data('give_temp_recount_all_total'); |
|
| 289 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 290 | + $this->delete_data('give_temp_payment_items'); |
|
| 291 | + $this->delete_data('give_temp_processed_payments'); |
|
| 292 | + $this->delete_data('give_temp_all_payments_data'); |
|
| 295 | 293 | } |
| 296 | 294 | |
| 297 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 298 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
| 295 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 296 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
| 299 | 297 | |
| 300 | - if ( false === $total ) { |
|
| 298 | + if (false === $total) { |
|
| 301 | 299 | $total = 0; |
| 302 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 300 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 303 | 301 | |
| 304 | - if ( false === $payment_items ) { |
|
| 302 | + if (false === $payment_items) { |
|
| 305 | 303 | $payment_items = array(); |
| 306 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 304 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 307 | 305 | } |
| 308 | 306 | |
| 309 | 307 | $args = array( |
| 310 | 308 | 'post_status' => 'publish', |
| 311 | 309 | 'post_type' => 'give_forms', |
| 312 | - 'posts_per_page' => - 1, |
|
| 310 | + 'posts_per_page' => -1, |
|
| 313 | 311 | 'fields' => 'ids', |
| 314 | 312 | ); |
| 315 | 313 | |
| 316 | - $all_forms = get_posts( $args ); |
|
| 317 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
| 314 | + $all_forms = get_posts($args); |
|
| 315 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
| 318 | 316 | |
| 319 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 317 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 320 | 318 | 'post_parent__in' => $all_forms, |
| 321 | 319 | 'number' => $this->per_step, |
| 322 | 320 | 'status' => 'publish', |
| 323 | 321 | 'page' => $this->step, |
| 324 | 322 | 'output' => 'payments', |
| 325 | - ) ); |
|
| 323 | + )); |
|
| 326 | 324 | |
| 327 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 325 | + $payments_query = new Give_Payments_Query($args); |
|
| 328 | 326 | $payments = $payments_query->get_payments(); |
| 329 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
| 327 | + $total = wp_count_posts('give_payment')->publish; |
|
| 330 | 328 | |
| 331 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
| 329 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
| 332 | 330 | |
| 333 | - if ( $payments ) { |
|
| 331 | + if ($payments) { |
|
| 334 | 332 | |
| 335 | - foreach ( $payments as $payment ) { |
|
| 333 | + foreach ($payments as $payment) { |
|
| 336 | 334 | |
| 337 | - $payment = new Give_Payment( $payment->ID ); |
|
| 335 | + $payment = new Give_Payment($payment->ID); |
|
| 338 | 336 | $form_id = $payment->form_id; |
| 339 | 337 | |
| 340 | 338 | //If for some reason somehow the form_ID isn't set check payment meta |
| 341 | - if ( empty( $payment->form_id ) ) { |
|
| 339 | + if (empty($payment->form_id)) { |
|
| 342 | 340 | $payment_meta = $payment->get_meta(); |
| 343 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 341 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 344 | 342 | } |
| 345 | 343 | |
| 346 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 344 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 347 | 345 | continue; |
| 348 | 346 | } |
| 349 | 347 | |
| 350 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
| 351 | - $payment_items[ $payment->ID ] = array( |
|
| 348 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
| 349 | + $payment_items[$payment->ID] = array( |
|
| 352 | 350 | 'id' => $form_id, |
| 353 | 351 | 'payment_id' => $payment->ID, |
| 354 | 352 | 'price' => $payment->total, |
@@ -359,8 +357,8 @@ discard block |
||
| 359 | 357 | |
| 360 | 358 | } |
| 361 | 359 | |
| 362 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 363 | - $this->store_data( 'give_recount_all_total', $total ); |
|
| 360 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 361 | + $this->store_data('give_recount_all_total', $total); |
|
| 364 | 362 | } |
| 365 | 363 | |
| 366 | 364 | } |
@@ -374,17 +372,17 @@ discard block |
||
| 374 | 372 | * |
| 375 | 373 | * @return mixed Returns the data from the database |
| 376 | 374 | */ |
| 377 | - private function get_stored_data( $key ) { |
|
| 375 | + private function get_stored_data($key) { |
|
| 378 | 376 | global $wpdb; |
| 379 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 377 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 380 | 378 | |
| 381 | - if ( empty( $value ) ) { |
|
| 379 | + if (empty($value)) { |
|
| 382 | 380 | return false; |
| 383 | 381 | } |
| 384 | 382 | |
| 385 | - $maybe_json = json_decode( $value ); |
|
| 386 | - if ( ! is_null( $maybe_json ) ) { |
|
| 387 | - $value = json_decode( $value, true ); |
|
| 383 | + $maybe_json = json_decode($value); |
|
| 384 | + if ( ! is_null($maybe_json)) { |
|
| 385 | + $value = json_decode($value, true); |
|
| 388 | 386 | } |
| 389 | 387 | |
| 390 | 388 | return $value; |
@@ -400,10 +398,10 @@ discard block |
||
| 400 | 398 | * |
| 401 | 399 | * @return void |
| 402 | 400 | */ |
| 403 | - private function store_data( $key, $value ) { |
|
| 401 | + private function store_data($key, $value) { |
|
| 404 | 402 | global $wpdb; |
| 405 | 403 | |
| 406 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 404 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 407 | 405 | |
| 408 | 406 | $data = array( |
| 409 | 407 | 'option_name' => $key, |
@@ -417,7 +415,7 @@ discard block |
||
| 417 | 415 | '%s', |
| 418 | 416 | ); |
| 419 | 417 | |
| 420 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 418 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 421 | 419 | } |
| 422 | 420 | |
| 423 | 421 | /** |
@@ -429,9 +427,9 @@ discard block |
||
| 429 | 427 | * |
| 430 | 428 | * @return void |
| 431 | 429 | */ |
| 432 | - private function delete_data( $key ) { |
|
| 430 | + private function delete_data($key) { |
|
| 433 | 431 | global $wpdb; |
| 434 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 432 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 435 | 433 | } |
| 436 | 434 | |
| 437 | 435 | } |
@@ -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 | |
@@ -53,40 +53,40 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function get_data() { |
| 55 | 55 | |
| 56 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 57 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
| 56 | + $donor = new Give_Donor($this->customer_id); |
|
| 57 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
| 58 | 58 | |
| 59 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 60 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 59 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 60 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 61 | 61 | |
| 62 | - if ( count( $step_items ) > 0 ) { |
|
| 63 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 62 | + if (count($step_items) > 0) { |
|
| 63 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 64 | 64 | $step_total = 0; |
| 65 | 65 | |
| 66 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 66 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
| 67 | 67 | |
| 68 | - foreach ( $step_items as $payment ) { |
|
| 69 | - $payment = get_post( $payment->ID ); |
|
| 68 | + foreach ($step_items as $payment) { |
|
| 69 | + $payment = get_post($payment->ID); |
|
| 70 | 70 | |
| 71 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 71 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 72 | 72 | |
| 73 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 73 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
| 74 | 74 | $missing_payments[] = $payment->ID; |
| 75 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
| 75 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
| 76 | 76 | |
| 77 | 77 | continue; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 81 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 81 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 82 | 82 | |
| 83 | - if ( true === $should_process_payment ) { |
|
| 83 | + if (true === $should_process_payment) { |
|
| 84 | 84 | |
| 85 | 85 | $found_payment_ids[] = $payment->ID; |
| 86 | 86 | |
| 87 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
| 88 | - $payment_amount = give_get_payment_amount( $payment->ID ); |
|
| 89 | - $step_total += $payment_amount; |
|
| 87 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
| 88 | + $payment_amount = give_get_payment_amount($payment->ID); |
|
| 89 | + $step_total += $payment_amount; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | } |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $updated_total = $pending_total + $step_total; |
| 97 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
| 98 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
| 97 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
| 98 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
| 99 | 99 | |
| 100 | 100 | return true; |
| 101 | 101 | } |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function get_percentage_complete() { |
| 114 | 114 | |
| 115 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 116 | - $total = count( $payments ); |
|
| 115 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 116 | + $total = count($payments); |
|
| 117 | 117 | |
| 118 | 118 | $percentage = 100; |
| 119 | 119 | |
| 120 | - if ( $total > 0 ) { |
|
| 121 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 120 | + if ($total > 0) { |
|
| 121 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( $percentage > 100 ) { |
|
| 124 | + if ($percentage > 100) { |
|
| 125 | 125 | $percentage = 100; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param array $request The Form Data passed into the batch processing |
| 137 | 137 | */ |
| 138 | - public function set_properties( $request ) { |
|
| 139 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 138 | + public function set_properties($request) { |
|
| 139 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,63 +147,63 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function process_step() { |
| 149 | 149 | |
| 150 | - if ( ! $this->can_export() ) { |
|
| 151 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 150 | + if ( ! $this->can_export()) { |
|
| 151 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $had_data = $this->get_data(); |
| 155 | 155 | |
| 156 | - if ( $had_data ) { |
|
| 156 | + if ($had_data) { |
|
| 157 | 157 | $this->done = false; |
| 158 | 158 | |
| 159 | 159 | return true; |
| 160 | 160 | } else { |
| 161 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 162 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
| 163 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 161 | + $donor = new Give_Donor($this->customer_id); |
|
| 162 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
| 163 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
| 164 | 164 | |
| 165 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
| 165 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
| 166 | 166 | |
| 167 | 167 | // Find non-existing payments (deleted) and total up the donation count |
| 168 | 168 | $purchase_count = 0; |
| 169 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 170 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 171 | - unset( $payment_ids[ $key ] ); |
|
| 169 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 170 | + if (in_array($payment_id, $removed_payments)) { |
|
| 171 | + unset($payment_ids[$key]); |
|
| 172 | 172 | continue; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $payment = get_post( $payment_id ); |
|
| 176 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
| 177 | - $purchase_count ++; |
|
| 175 | + $payment = get_post($payment_id); |
|
| 176 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
| 177 | + $purchase_count++; |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 181 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
| 182 | 182 | |
| 183 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 184 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 185 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
| 186 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 183 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 184 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
| 185 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
| 186 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 187 | 187 | |
| 188 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 189 | - $donor->update( array( |
|
| 188 | + $payment_ids = implode(',', $payment_ids); |
|
| 189 | + $donor->update(array( |
|
| 190 | 190 | 'payment_ids' => $payment_ids, |
| 191 | 191 | 'purchase_count' => $purchase_count, |
| 192 | 192 | 'purchase_value' => $pending_total, |
| 193 | - ) ); |
|
| 193 | + )); |
|
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
| 196 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
| 196 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
| 197 | 197 | |
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function headers() { |
| 203 | - ignore_user_abort( true ); |
|
| 203 | + ignore_user_abort(true); |
|
| 204 | 204 | |
| 205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 206 | - set_time_limit( 0 ); |
|
| 205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 206 | + set_time_limit(0); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
| 230 | 230 | * @return void |
| 231 | 231 | */ |
| 232 | 232 | public function pre_fetch() { |
| 233 | - if ( $this->step === 1 ) { |
|
| 234 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 233 | + if ($this->step === 1) { |
|
| 234 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 235 | 235 | |
| 236 | 236 | // Before we start, let's zero out the customer's data |
| 237 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 238 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
| 237 | + $donor = new Give_Donor($this->customer_id); |
|
| 238 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
| 239 | 239 | |
| 240 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
| 240 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
| 241 | 241 | |
| 242 | 242 | $attached_args = array( |
| 243 | 243 | 'post__in' => $attached_payment_ids, |
| 244 | - 'number' => - 1, |
|
| 244 | + 'number' => -1, |
|
| 245 | 245 | 'status' => $allowed_payment_status, |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - $attached_payments = give_get_payments( $attached_args ); |
|
| 248 | + $attached_payments = give_get_payments($attached_args); |
|
| 249 | 249 | |
| 250 | 250 | $unattached_args = array( |
| 251 | 251 | 'post__not_in' => $attached_payment_ids, |
| 252 | - 'number' => - 1, |
|
| 252 | + 'number' => -1, |
|
| 253 | 253 | 'status' => $allowed_payment_status, |
| 254 | 254 | 'meta_query' => array( |
| 255 | 255 | array( |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | ), |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 262 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 263 | 263 | |
| 264 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 264 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 265 | 265 | |
| 266 | - $this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments ); |
|
| 266 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -276,17 +276,17 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return mixed Returns the data from the database |
| 278 | 278 | */ |
| 279 | - private function get_stored_data( $key ) { |
|
| 279 | + private function get_stored_data($key) { |
|
| 280 | 280 | global $wpdb; |
| 281 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 281 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 282 | 282 | |
| 283 | - if ( empty( $value ) ) { |
|
| 283 | + if (empty($value)) { |
|
| 284 | 284 | return false; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $maybe_json = json_decode( $value ); |
|
| 288 | - if ( ! is_null( $maybe_json ) ) { |
|
| 289 | - $value = json_decode( $value, true ); |
|
| 287 | + $maybe_json = json_decode($value); |
|
| 288 | + if ( ! is_null($maybe_json)) { |
|
| 289 | + $value = json_decode($value, true); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | return $value; |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return void |
| 304 | 304 | */ |
| 305 | - private function store_data( $key, $value ) { |
|
| 305 | + private function store_data($key, $value) { |
|
| 306 | 306 | global $wpdb; |
| 307 | 307 | |
| 308 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 308 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 309 | 309 | |
| 310 | 310 | $data = array( |
| 311 | 311 | 'option_name' => $key, |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | '%s', |
| 320 | 320 | ); |
| 321 | 321 | |
| 322 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 322 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | - private function delete_data( $key ) { |
|
| 334 | + private function delete_data($key) { |
|
| 335 | 335 | global $wpdb; |
| 336 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 336 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | } |
@@ -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 | |
@@ -59,58 +59,58 @@ discard block |
||
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | 61 | public function get_data() { |
| 62 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 62 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 63 | 63 | |
| 64 | - if ( $this->step == 1 ) { |
|
| 65 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 64 | + if ($this->step == 1) { |
|
| 65 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
| 68 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
| 69 | 69 | |
| 70 | - if ( false === $totals ) { |
|
| 70 | + if (false === $totals) { |
|
| 71 | 71 | $totals = array( |
| 72 | 72 | 'earnings' => (float) 0, |
| 73 | 73 | 'sales' => 0, |
| 74 | 74 | ); |
| 75 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 75 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 78 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 79 | 79 | 'give_forms' => $this->form_id, |
| 80 | 80 | 'number' => $this->per_step, |
| 81 | 81 | 'status' => $accepted_statuses, |
| 82 | 82 | 'paged' => $this->step, |
| 83 | 83 | 'fields' => 'ids', |
| 84 | - ) ); |
|
| 84 | + )); |
|
| 85 | 85 | |
| 86 | - $payments = new Give_Payments_Query( $args ); |
|
| 86 | + $payments = new Give_Payments_Query($args); |
|
| 87 | 87 | $payments = $payments->get_payments(); |
| 88 | 88 | |
| 89 | - if ( $payments ) { |
|
| 90 | - foreach ( $payments as $payment ) { |
|
| 89 | + if ($payments) { |
|
| 90 | + foreach ($payments as $payment) { |
|
| 91 | 91 | //Ensure acceptible status only |
| 92 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 92 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 93 | 93 | continue; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | //Ensure only payments for this form are counted |
| 97 | - if ( $payment->form_id != $this->form_id ) { |
|
| 97 | + if ($payment->form_id != $this->form_id) { |
|
| 98 | 98 | continue; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $totals['sales'] ++; |
|
| 101 | + $totals['sales']++; |
|
| 102 | 102 | $totals['earnings'] += $payment->total; |
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 106 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 107 | 107 | |
| 108 | 108 | return true; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
| 113 | - give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
| 112 | + give_update_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
| 113 | + give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
| 114 | 114 | |
| 115 | 115 | return false; |
| 116 | 116 | } |
@@ -122,35 +122,35 @@ discard block |
||
| 122 | 122 | * @return int |
| 123 | 123 | */ |
| 124 | 124 | public function get_percentage_complete() { |
| 125 | - if ( $this->step == 1 ) { |
|
| 126 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 125 | + if ($this->step == 1) { |
|
| 126 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 130 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
| 129 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 130 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
| 131 | 131 | |
| 132 | - if ( false === $total ) { |
|
| 132 | + if (false === $total) { |
|
| 133 | 133 | $total = 0; |
| 134 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 134 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 135 | 135 | 'give_forms' => $this->form_id, |
| 136 | - 'number' => - 1, |
|
| 136 | + 'number' => -1, |
|
| 137 | 137 | 'status' => $accepted_statuses, |
| 138 | 138 | 'fields' => 'ids', |
| 139 | - ) ); |
|
| 139 | + )); |
|
| 140 | 140 | |
| 141 | - $payments = new Give_Payments_Query( $args ); |
|
| 142 | - $total = count( $payments->get_payments() ); |
|
| 143 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
| 141 | + $payments = new Give_Payments_Query($args); |
|
| 142 | + $total = count($payments->get_payments()); |
|
| 143 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
| 144 | 144 | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $percentage = 100; |
| 148 | 148 | |
| 149 | - if ( $total > 0 ) { |
|
| 150 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 149 | + if ($total > 0) { |
|
| 150 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( $percentage > 100 ) { |
|
| 153 | + if ($percentage > 100) { |
|
| 154 | 154 | $percentage = 100; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @param array $request The Form Data passed into the batch processing |
| 166 | 166 | */ |
| 167 | - public function set_properties( $request ) { |
|
| 168 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 167 | + public function set_properties($request) { |
|
| 168 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -176,31 +176,31 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function process_step() { |
| 178 | 178 | |
| 179 | - if ( ! $this->can_export() ) { |
|
| 180 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 179 | + if ( ! $this->can_export()) { |
|
| 180 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $had_data = $this->get_data(); |
| 184 | 184 | |
| 185 | - if ( $had_data ) { |
|
| 185 | + if ($had_data) { |
|
| 186 | 186 | $this->done = false; |
| 187 | 187 | |
| 188 | 188 | return true; |
| 189 | 189 | } else { |
| 190 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 191 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 190 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 191 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 192 | 192 | $this->done = true; |
| 193 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
| 193 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
| 194 | 194 | |
| 195 | 195 | return false; |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | public function headers() { |
| 200 | - ignore_user_abort( true ); |
|
| 200 | + ignore_user_abort(true); |
|
| 201 | 201 | |
| 202 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 203 | - set_time_limit( 0 ); |
|
| 202 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 203 | + set_time_limit(0); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
@@ -228,17 +228,17 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return mixed Returns the data from the database |
| 230 | 230 | */ |
| 231 | - private function get_stored_data( $key ) { |
|
| 231 | + private function get_stored_data($key) { |
|
| 232 | 232 | global $wpdb; |
| 233 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 233 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 234 | 234 | |
| 235 | - if ( empty( $value ) ) { |
|
| 235 | + if (empty($value)) { |
|
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $maybe_json = json_decode( $value ); |
|
| 240 | - if ( ! is_null( $maybe_json ) ) { |
|
| 241 | - $value = json_decode( $value, true ); |
|
| 239 | + $maybe_json = json_decode($value); |
|
| 240 | + if ( ! is_null($maybe_json)) { |
|
| 241 | + $value = json_decode($value, true); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | return $value; |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @return void |
| 256 | 256 | */ |
| 257 | - private function store_data( $key, $value ) { |
|
| 257 | + private function store_data($key, $value) { |
|
| 258 | 258 | global $wpdb; |
| 259 | 259 | |
| 260 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 260 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 261 | 261 | |
| 262 | 262 | $data = array( |
| 263 | 263 | 'option_name' => $key, |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | '%s', |
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 274 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return void |
| 285 | 285 | */ |
| 286 | - private function delete_data( $key ) { |
|
| 286 | + private function delete_data($key) { |
|
| 287 | 287 | global $wpdb; |
| 288 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 288 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
| 292 | 292 | \ No newline at end of file |