@@ -55,8 +55,11 @@ discard block |
||
| 55 | 55 | <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
| 56 | 56 | <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
| 57 | 57 | <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
| 58 | - <?php else : ?> |
|
| 59 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
| 58 | + <?php else { |
|
| 59 | + : ?> |
|
| 60 | + <?php _e( 'The updates have been paused.', 'give' ); |
|
| 61 | +} |
|
| 62 | +?> |
|
| 60 | 63 | |
| 61 | 64 | <?php endif; ?> |
| 62 | 65 | </span> |
@@ -108,7 +111,10 @@ discard block |
||
| 108 | 111 | </div><!-- .postbox --> |
| 109 | 112 | </div> <!-- .post-container --> |
| 110 | 113 | </div> |
| 111 | - <?php else: include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php';?> |
|
| 114 | + <?php else { |
|
| 115 | + : include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; |
|
| 116 | +} |
|
| 117 | +?> |
|
| 112 | 118 | <?php endif; ?> |
| 113 | 119 | |
| 114 | 120 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -18,67 +18,66 @@ discard block |
||
| 18 | 18 | ?> |
| 19 | 19 | <div class="wrap" id="poststuff"> |
| 20 | 20 | <div id="give-updates"> |
| 21 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1> |
|
| 21 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1> |
|
| 22 | 22 | <hr class="wp-header-end"> |
| 23 | 23 | |
| 24 | 24 | <?php $db_updates = $give_updates->get_pending_db_update_count(); ?> |
| 25 | - <?php if ( ! empty( $db_updates ) ) : ?> |
|
| 25 | + <?php if ( ! empty($db_updates)) : ?> |
|
| 26 | 26 | <?php |
| 27 | 27 | $is_doing_updates = $give_updates->is_doing_updates(); |
| 28 | - $db_update_url = add_query_arg( array( 'type' => 'database', ) ); |
|
| 29 | - $resume_updates = get_option( 'give_doing_upgrade' ); |
|
| 30 | - $width = ! empty( $resume_updates ) ? $resume_updates['percentage'] : 0; |
|
| 28 | + $db_update_url = add_query_arg(array('type' => 'database',)); |
|
| 29 | + $resume_updates = get_option('give_doing_upgrade'); |
|
| 30 | + $width = ! empty($resume_updates) ? $resume_updates['percentage'] : 0; |
|
| 31 | 31 | ?> |
| 32 | 32 | <div class="give-update-panel-content"> |
| 33 | - <p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p> |
|
| 33 | + <p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p> |
|
| 34 | 34 | </div> |
| 35 | 35 | |
| 36 | - <div id="give-db-updates" data-resume-update="<?php echo absint( $give_updates->is_doing_updates() ); ?>"> |
|
| 36 | + <div id="give-db-updates" data-resume-update="<?php echo absint($give_updates->is_doing_updates()); ?>"> |
|
| 37 | 37 | <div class="postbox-container"> |
| 38 | 38 | <div class="postbox"> |
| 39 | - <h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2> |
|
| 39 | + <h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2> |
|
| 40 | 40 | <div class="inside"> |
| 41 | 41 | <div class="panel-content"> |
| 42 | 42 | <p class="give-update-button"> |
| 43 | - <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
| 43 | + <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
| 44 | 44 | <?php |
| 45 | - if ( ! give_test_ajax_works() ) { |
|
| 45 | + if ( ! give_test_ajax_works()) { |
|
| 46 | 46 | echo sprintf( |
| 47 | 47 | '%1$s <a href="%2$s" target="_blank">%3$s</a>', |
| 48 | - __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), |
|
| 49 | - esc_url( 'http://docs.givewp.com/troubleshooting-db-updates' ), |
|
| 50 | - __( 'Read More', 'give' ) . ' »' |
|
| 48 | + __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), |
|
| 49 | + esc_url('http://docs.givewp.com/troubleshooting-db-updates'), |
|
| 50 | + __('Read More', 'give').' »' |
|
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | } else { |
| 54 | 54 | echo sprintf( |
| 55 | - __( '%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give' ), |
|
| 55 | + __('%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give'), |
|
| 56 | 56 | $is_doing_updates ? |
| 57 | - __( 'Give is currently updating the database in the background.', 'give' ) : |
|
| 58 | - __( 'Give needs to update the database.', 'give' ), |
|
| 57 | + __('Give is currently updating the database in the background.', 'give') : __('Give needs to update the database.', 'give'), |
|
| 59 | 58 | $db_update_url, |
| 60 | - ( $is_doing_updates ? 'give-hidden' : '' ), |
|
| 61 | - __( 'Update now', 'give' ) |
|
| 59 | + ($is_doing_updates ? 'give-hidden' : ''), |
|
| 60 | + __('Update now', 'give') |
|
| 62 | 61 | ); |
| 63 | 62 | } |
| 64 | 63 | ?> |
| 65 | 64 | </span> |
| 66 | - <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
| 67 | - <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
|
| 68 | - <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
| 65 | + <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
| 66 | + <?php if (get_option('give_upgrade_error')) : ?> |
|
| 67 | + <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
| 69 | 68 | <?php else : ?> |
| 70 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
| 69 | + <?php _e('The updates have been paused.', 'give'); ?> |
|
| 71 | 70 | |
| 72 | 71 | <?php endif; ?> |
| 73 | 72 | </span> |
| 74 | 73 | |
| 75 | - <?php if ( Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
| 76 | - <?php $is_disabled = isset( $_GET['give-restart-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
| 77 | - <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>><?php _e( 'Restart Upgrades', 'give' ); ?></button> |
|
| 78 | - <?php elseif( $give_updates->is_doing_updates() ): ?> |
|
| 79 | - <?php $is_disabled = isset( $_GET['give-pause-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
| 80 | - <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>> |
|
| 81 | - <?php _e( 'Pause Upgrades', 'give' ); ?> |
|
| 74 | + <?php if (Give_Updates::$background_updater->is_paused_process()) : ?> |
|
| 75 | + <?php $is_disabled = isset($_GET['give-restart-db-upgrades']) ? ' disabled' : ''; ?> |
|
| 76 | + <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>><?php _e('Restart Upgrades', 'give'); ?></button> |
|
| 77 | + <?php elseif ($give_updates->is_doing_updates()): ?> |
|
| 78 | + <?php $is_disabled = isset($_GET['give-pause-db-upgrades']) ? ' disabled' : ''; ?> |
|
| 79 | + <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>> |
|
| 80 | + <?php _e('Pause Upgrades', 'give'); ?> |
|
| 82 | 81 | </button> |
| 83 | 82 | <?php endif; ?> |
| 84 | 83 | </p> |
@@ -88,7 +87,7 @@ discard block |
||
| 88 | 87 | <strong> |
| 89 | 88 | <?php |
| 90 | 89 | echo sprintf( |
| 91 | - __( 'Update %s of %s', 'give' ), |
|
| 90 | + __('Update %s of %s', 'give'), |
|
| 92 | 91 | $give_updates->get_running_db_update(), |
| 93 | 92 | $give_updates->get_total_new_db_update_count() |
| 94 | 93 | ); |
@@ -96,10 +95,10 @@ discard block |
||
| 96 | 95 | </strong> |
| 97 | 96 | </p> |
| 98 | 97 | <div class="progress-content"> |
| 99 | - <?php if ( $is_doing_updates ) : ?> |
|
| 98 | + <?php if ($is_doing_updates) : ?> |
|
| 100 | 99 | <div class="notice-wrap give-clearfix"> |
| 101 | 100 | |
| 102 | - <?php if ( ! Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
| 101 | + <?php if ( ! Give_Updates::$background_updater->is_paused_process()) : ?> |
|
| 103 | 102 | <span class="spinner is-active"></span> |
| 104 | 103 | <?php endif; ?> |
| 105 | 104 | |
@@ -111,7 +110,7 @@ discard block |
||
| 111 | 110 | </div> |
| 112 | 111 | </div> |
| 113 | 112 | |
| 114 | - <?php if ( ! $is_doing_updates ) : ?> |
|
| 113 | + <?php if ( ! $is_doing_updates) : ?> |
|
| 115 | 114 | <div class="give-run-database-update"></div> |
| 116 | 115 | <?php endif; ?> |
| 117 | 116 | </div> |
@@ -119,18 +118,18 @@ discard block |
||
| 119 | 118 | </div><!-- .postbox --> |
| 120 | 119 | </div> <!-- .post-container --> |
| 121 | 120 | </div> |
| 122 | - <?php else: include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php';?> |
|
| 121 | + <?php else: include GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; ?> |
|
| 123 | 122 | <?php endif; ?> |
| 124 | 123 | |
| 125 | 124 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
| 126 | - <?php if ( ! empty( $plugin_updates ) ) : ?> |
|
| 127 | - <?php $plugin_update_url = add_query_arg( array( |
|
| 125 | + <?php if ( ! empty($plugin_updates)) : ?> |
|
| 126 | + <?php $plugin_update_url = add_query_arg(array( |
|
| 128 | 127 | 'plugin_status' => 'give', |
| 129 | - ), admin_url( '/plugins.php' ) ); ?> |
|
| 128 | + ), admin_url('/plugins.php')); ?> |
|
| 130 | 129 | <div id="give-plugin-updates"> |
| 131 | 130 | <div class="postbox-container"> |
| 132 | 131 | <div class="postbox"> |
| 133 | - <h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2> |
|
| 132 | + <h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2> |
|
| 134 | 133 | <div class="inside"> |
| 135 | 134 | <div class="panel-content"> |
| 136 | 135 | <p> |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /* @var Give_Updates $give_updates */ |
| 3 | -$plugins = $give_updates->get_updates( 'plugin' ); |
|
| 4 | -if ( empty( $plugins ) ) { |
|
| 3 | +$plugins = $give_updates->get_updates('plugin'); |
|
| 4 | +if (empty($plugins)) { |
|
| 5 | 5 | return; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | ob_start(); |
| 9 | -foreach ( $plugins as $plugin_data ) { |
|
| 10 | - if ( 'active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type'] ) { |
|
| 9 | +foreach ($plugins as $plugin_data) { |
|
| 10 | + if ('active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type']) { |
|
| 11 | 11 | continue; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -15,45 +15,45 @@ discard block |
||
| 15 | 15 | $author_name = $plugin_data['Author']; |
| 16 | 16 | |
| 17 | 17 | // Link the plugin name to the plugin URL if available. |
| 18 | - if ( ! empty( $plugin_data['PluginURI'] ) ) { |
|
| 18 | + if ( ! empty($plugin_data['PluginURI'])) { |
|
| 19 | 19 | $plugin_name = sprintf( |
| 20 | 20 | '<a href="%s" title="%s">%s</a> (%s)', |
| 21 | - esc_url( $plugin_data['PluginURI'] ), |
|
| 22 | - esc_attr__( 'Visit plugin homepage', 'give' ), |
|
| 21 | + esc_url($plugin_data['PluginURI']), |
|
| 22 | + esc_attr__('Visit plugin homepage', 'give'), |
|
| 23 | 23 | $plugin_name, |
| 24 | - esc_html( $plugin_data['Version'] ) |
|
| 24 | + esc_html($plugin_data['Version']) |
|
| 25 | 25 | ); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // Link the author name to the author URL if available. |
| 29 | - if ( ! empty( $plugin_data['AuthorURI'] ) ) { |
|
| 29 | + if ( ! empty($plugin_data['AuthorURI'])) { |
|
| 30 | 30 | $author_name = sprintf( |
| 31 | 31 | '<a href="%s" title="%s">%s</a>', |
| 32 | - esc_url( $plugin_data['AuthorURI'] ), |
|
| 33 | - esc_attr__( 'Visit author homepage', 'give' ), |
|
| 32 | + esc_url($plugin_data['AuthorURI']), |
|
| 33 | + esc_attr__('Visit author homepage', 'give'), |
|
| 34 | 34 | $author_name |
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | 37 | ?> |
| 38 | 38 | <tr> |
| 39 | - <td><?php echo wp_kses( $plugin_name, wp_kses_allowed_html( 'post' ) ); ?></td> |
|
| 39 | + <td><?php echo wp_kses($plugin_name, wp_kses_allowed_html('post')); ?></td> |
|
| 40 | 40 | <td> |
| 41 | 41 | <?php |
| 42 | 42 | echo true === $plugin_data['License'] |
| 43 | 43 | ? sprintf( |
| 44 | 44 | '<span class="dashicons dashicons-yes"></span>%s', |
| 45 | - __( 'Licensed', 'give' ) |
|
| 45 | + __('Licensed', 'give') |
|
| 46 | 46 | ) |
| 47 | 47 | : sprintf( |
| 48 | 48 | '<span data-tooltip="%s"><span class="dashicons dashicons-no-alt"></span>%s</span>', |
| 49 | - __( 'Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give' ), |
|
| 50 | - __( 'Unlicensed', 'give' ) |
|
| 49 | + __('Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give'), |
|
| 50 | + __('Unlicensed', 'give') |
|
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | echo sprintf( |
| 54 | 54 | ' – %s – %s', |
| 55 | - sprintf( _x( 'by %s', 'by author', 'give' ), wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ), |
|
| 56 | - sprintf( __( '(Latest Version: %s)' ), $plugin_data['update']->new_version ) |
|
| 55 | + sprintf(_x('by %s', 'by author', 'give'), wp_kses($author_name, wp_kses_allowed_html('post'))), |
|
| 56 | + sprintf(__('(Latest Version: %s)'), $plugin_data['update']->new_version) |
|
| 57 | 57 | ); |
| 58 | 58 | ?> |
| 59 | 59 | </td> |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // Exit if accessed directly. |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -25,70 +25,70 @@ 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 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
| 69 | + case version_compare($give_version, '1.8.17', '<') : |
|
| 70 | 70 | give_v1817_upgrades(); |
| 71 | 71 | $did_upgrade = true; |
| 72 | 72 | |
| 73 | - case version_compare( $give_version, '1.8.18', '<' ) : |
|
| 73 | + case version_compare($give_version, '1.8.18', '<') : |
|
| 74 | 74 | give_v1818_upgrades(); |
| 75 | 75 | $did_upgrade = true; |
| 76 | 76 | |
| 77 | - case version_compare( $give_version, '2.0', '<' ) : |
|
| 77 | + case version_compare($give_version, '2.0', '<') : |
|
| 78 | 78 | give_v20_upgrades(); |
| 79 | 79 | $did_upgrade = true; |
| 80 | 80 | |
| 81 | - case version_compare( $give_version, '2.0.1', '<' ) : |
|
| 81 | + case version_compare($give_version, '2.0.1', '<') : |
|
| 82 | 82 | // Do nothing on fresh install. |
| 83 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
| 83 | + if ( ! doing_action('give_upgrades')) { |
|
| 84 | 84 | give_v201_create_tables(); |
| 85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
| 85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
| 86 | 86 | Give_Updates::$background_updater->dispatch(); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $did_upgrade = true; |
| 90 | 90 | |
| 91 | - case version_compare( $give_version, '2.0.2', '<' ) : |
|
| 91 | + case version_compare($give_version, '2.0.2', '<') : |
|
| 92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
| 93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
| 94 | 94 | $v201_updates = array( |
@@ -98,35 +98,35 @@ discard block |
||
| 98 | 98 | 'v201_logs_upgrades', |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - foreach ( $v201_updates as $v201_update ) { |
|
| 102 | - if ( in_array( $v201_update, $completed_upgrades ) ) { |
|
| 103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades ) ] ); |
|
| 101 | + foreach ($v201_updates as $v201_update) { |
|
| 102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
| 103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
| 107 | + update_option('give_completed_upgrades', $completed_upgrades); |
|
| 108 | 108 | |
| 109 | 109 | // Do nothing on fresh install. |
| 110 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
| 110 | + if ( ! doing_action('give_upgrades')) { |
|
| 111 | 111 | give_v201_create_tables(); |
| 112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
| 112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
| 113 | 113 | Give_Updates::$background_updater->dispatch(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $did_upgrade = true; |
| 117 | 117 | |
| 118 | - case version_compare( $give_version, '2.0.3', '<' ) : |
|
| 118 | + case version_compare($give_version, '2.0.3', '<') : |
|
| 119 | 119 | give_v203_upgrades(); |
| 120 | 120 | $did_upgrade = true; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( $did_upgrade ) { |
|
| 124 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 123 | + if ($did_upgrade) { |
|
| 124 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
| 129 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
| 128 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
| 129 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * Display Upgrade Notices. |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | -function give_show_upgrade_notices( $give_updates ) { |
|
| 143 | +function give_show_upgrade_notices($give_updates) { |
|
| 144 | 144 | // v1.3.2 Upgrades |
| 145 | 145 | $give_updates->register( |
| 146 | 146 | array( |
@@ -206,32 +206,32 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | 208 | // v1.8.17 Upgrades for donations. |
| 209 | - $give_updates->register( array( |
|
| 209 | + $give_updates->register(array( |
|
| 210 | 210 | 'id' => 'v1817_update_donation_iranian_currency_code', |
| 211 | 211 | 'version' => '1.8.17', |
| 212 | 212 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
| 213 | - ) ); |
|
| 213 | + )); |
|
| 214 | 214 | |
| 215 | 215 | // v1.8.17 Upgrades for cleanup of user roles. |
| 216 | - $give_updates->register( array( |
|
| 216 | + $give_updates->register(array( |
|
| 217 | 217 | 'id' => 'v1817_cleanup_user_roles', |
| 218 | 218 | 'version' => '1.8.17', |
| 219 | 219 | 'callback' => 'give_v1817_cleanup_user_roles', |
| 220 | - ) ); |
|
| 220 | + )); |
|
| 221 | 221 | |
| 222 | 222 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
| 223 | - $give_updates->register( array( |
|
| 223 | + $give_updates->register(array( |
|
| 224 | 224 | 'id' => 'v1818_assign_custom_amount_set_donation', |
| 225 | 225 | 'version' => '1.8.18', |
| 226 | 226 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
| 227 | - ) ); |
|
| 227 | + )); |
|
| 228 | 228 | |
| 229 | 229 | // v1.8.18 Cleanup the Give Worker Role Caps. |
| 230 | - $give_updates->register( array( |
|
| 230 | + $give_updates->register(array( |
|
| 231 | 231 | 'id' => 'v1818_give_worker_role_cleanup', |
| 232 | 232 | 'version' => '1.8.18', |
| 233 | 233 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
| 234 | - ) ); |
|
| 234 | + )); |
|
| 235 | 235 | |
| 236 | 236 | // v2.0.0 Upgrades |
| 237 | 237 | $give_updates->register( |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | 'id' => 'v20_move_metadata_into_new_table', |
| 286 | 286 | 'version' => '2.0.0', |
| 287 | 287 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
| 288 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
| 288 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
| 289 | 289 | ) |
| 290 | 290 | ); |
| 291 | 291 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | 'id' => 'v201_move_metadata_into_new_table', |
| 332 | 332 | 'version' => '2.0.1', |
| 333 | 333 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
| 334 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
| 334 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
| 335 | 335 | ) |
| 336 | 336 | ); |
| 337 | 337 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | 'id' => 'v213_delete_donation_meta', |
| 360 | 360 | 'version' => '2.1.3', |
| 361 | 361 | 'callback' => 'give_v213_delete_donation_meta_callback', |
| 362 | - 'depends' => array( 'v201_move_metadata_into_new_table' ) |
|
| 362 | + 'depends' => array('v201_move_metadata_into_new_table') |
|
| 363 | 363 | ) |
| 364 | 364 | ); |
| 365 | 365 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
| 377 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | 380 | * Triggers all upgrade functions |
@@ -386,29 +386,29 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | function give_trigger_upgrades() { |
| 388 | 388 | |
| 389 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 390 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 389 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 390 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
| 391 | 391 | 'response' => 403, |
| 392 | - ) ); |
|
| 392 | + )); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - $give_version = get_option( 'give_version' ); |
|
| 395 | + $give_version = get_option('give_version'); |
|
| 396 | 396 | |
| 397 | - if ( ! $give_version ) { |
|
| 397 | + if ( ! $give_version) { |
|
| 398 | 398 | // 1.0 is the first version to use this option so we must add it. |
| 399 | 399 | $give_version = '1.0'; |
| 400 | - add_option( 'give_version', $give_version ); |
|
| 400 | + add_option('give_version', $give_version); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 404 | - delete_option( 'give_doing_upgrade' ); |
|
| 403 | + update_option('give_version', GIVE_VERSION); |
|
| 404 | + delete_option('give_doing_upgrade'); |
|
| 405 | 405 | |
| 406 | - if ( DOING_AJAX ) { |
|
| 407 | - die( 'complete' ); |
|
| 406 | + if (DOING_AJAX) { |
|
| 407 | + die('complete'); |
|
| 408 | 408 | } // End if(). |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
| 411 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
| 412 | 412 | |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | // UPDATE DB METAKEYS. |
| 428 | 428 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
| 429 | - $query = $wpdb->query( $sql ); |
|
| 429 | + $query = $wpdb->query($sql); |
|
| 430 | 430 | |
| 431 | 431 | $give_updates->percentage = 100; |
| 432 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
| 432 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | |
@@ -453,24 +453,24 @@ discard block |
||
| 453 | 453 | $where .= "AND ( p.post_status = 'abandoned' )"; |
| 454 | 454 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
| 455 | 455 | |
| 456 | - $sql = $select . $join . $where; |
|
| 457 | - $found_payments = $wpdb->get_col( $sql ); |
|
| 456 | + $sql = $select.$join.$where; |
|
| 457 | + $found_payments = $wpdb->get_col($sql); |
|
| 458 | 458 | |
| 459 | - foreach ( $found_payments as $payment ) { |
|
| 459 | + foreach ($found_payments as $payment) { |
|
| 460 | 460 | |
| 461 | 461 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
| 462 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
| 462 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
| 463 | 463 | |
| 464 | 464 | // 1450124863 = 12/10/2015 20:42:25. |
| 465 | - if ( $modified_time >= 1450124863 ) { |
|
| 465 | + if ($modified_time >= 1450124863) { |
|
| 466 | 466 | |
| 467 | - give_update_payment_status( $payment, 'pending' ); |
|
| 467 | + give_update_payment_status($payment, 'pending'); |
|
| 468 | 468 | |
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | $give_updates->percentage = 100; |
| 473 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
| 473 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | |
@@ -483,17 +483,17 @@ discard block |
||
| 483 | 483 | */ |
| 484 | 484 | function give_v152_cleanup_users() { |
| 485 | 485 | |
| 486 | - $give_version = get_option( 'give_version' ); |
|
| 486 | + $give_version = get_option('give_version'); |
|
| 487 | 487 | |
| 488 | - if ( ! $give_version ) { |
|
| 488 | + if ( ! $give_version) { |
|
| 489 | 489 | // 1.0 is the first version to use this option so we must add it. |
| 490 | 490 | $give_version = '1.0'; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
| 493 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
| 494 | 494 | |
| 495 | 495 | // v1.5.2 Upgrades |
| 496 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
| 496 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
| 497 | 497 | |
| 498 | 498 | // Delete all caps with "ss". |
| 499 | 499 | // Also delete all unused "campaign" roles. |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | ); |
| 541 | 541 | |
| 542 | 542 | global $wp_roles; |
| 543 | - foreach ( $delete_caps as $cap ) { |
|
| 544 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 545 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 543 | + foreach ($delete_caps as $cap) { |
|
| 544 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 545 | + $wp_roles->remove_cap($role, $cap); |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
@@ -552,15 +552,15 @@ discard block |
||
| 552 | 552 | $roles->add_caps(); |
| 553 | 553 | |
| 554 | 554 | // The Update Ran. |
| 555 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 556 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
| 557 | - delete_option( 'give_doing_upgrade' ); |
|
| 555 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 556 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
| 557 | + delete_option('give_doing_upgrade'); |
|
| 558 | 558 | |
| 559 | 559 | }// End if(). |
| 560 | 560 | |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
| 563 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
| 564 | 564 | |
| 565 | 565 | /** |
| 566 | 566 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -603,53 +603,53 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | // Get addons license key. |
| 605 | 605 | $addons = array(); |
| 606 | - foreach ( $give_options as $key => $value ) { |
|
| 607 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
| 608 | - $addons[ $key ] = $value; |
|
| 606 | + foreach ($give_options as $key => $value) { |
|
| 607 | + if (false !== strpos($key, '_license_key')) { |
|
| 608 | + $addons[$key] = $value; |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | // Bailout: We do not have any addon license data to upgrade. |
| 613 | - if ( empty( $addons ) ) { |
|
| 613 | + if (empty($addons)) { |
|
| 614 | 614 | return false; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - foreach ( $addons as $key => $addon_license ) { |
|
| 617 | + foreach ($addons as $key => $addon_license) { |
|
| 618 | 618 | |
| 619 | 619 | // Get addon shortname. |
| 620 | - $shortname = str_replace( '_license_key', '', $key ); |
|
| 620 | + $shortname = str_replace('_license_key', '', $key); |
|
| 621 | 621 | |
| 622 | 622 | // Addon license option name. |
| 623 | - $addon_license_option_name = $shortname . '_license_active'; |
|
| 623 | + $addon_license_option_name = $shortname.'_license_active'; |
|
| 624 | 624 | |
| 625 | 625 | // bailout if license is empty. |
| 626 | - if ( empty( $addon_license ) ) { |
|
| 627 | - delete_option( $addon_license_option_name ); |
|
| 626 | + if (empty($addon_license)) { |
|
| 627 | + delete_option($addon_license_option_name); |
|
| 628 | 628 | continue; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | // Get addon name. |
| 632 | 632 | $addon_name = array(); |
| 633 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
| 634 | - foreach ( $addon_name_parts as $name_part ) { |
|
| 633 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
| 634 | + foreach ($addon_name_parts as $name_part) { |
|
| 635 | 635 | |
| 636 | 636 | // Fix addon name |
| 637 | - switch ( $name_part ) { |
|
| 637 | + switch ($name_part) { |
|
| 638 | 638 | case 'authorizenet' : |
| 639 | 639 | $name_part = 'authorize.net'; |
| 640 | 640 | break; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - $addon_name[] = ucfirst( $name_part ); |
|
| 643 | + $addon_name[] = ucfirst($name_part); |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $addon_name = implode( ' ', $addon_name ); |
|
| 646 | + $addon_name = implode(' ', $addon_name); |
|
| 647 | 647 | |
| 648 | 648 | // Data to send to the API. |
| 649 | 649 | $api_params = array( |
| 650 | 650 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
| 651 | 651 | 'license' => $addon_license, |
| 652 | - 'item_name' => urlencode( $addon_name ), |
|
| 652 | + 'item_name' => urlencode($addon_name), |
|
| 653 | 653 | 'url' => home_url(), |
| 654 | 654 | ); |
| 655 | 655 | |
@@ -664,17 +664,17 @@ discard block |
||
| 664 | 664 | ); |
| 665 | 665 | |
| 666 | 666 | // Make sure there are no errors. |
| 667 | - if ( is_wp_error( $response ) ) { |
|
| 668 | - delete_option( $addon_license_option_name ); |
|
| 667 | + if (is_wp_error($response)) { |
|
| 668 | + delete_option($addon_license_option_name); |
|
| 669 | 669 | continue; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | // Tell WordPress to look for updates. |
| 673 | - set_site_transient( 'update_plugins', null ); |
|
| 673 | + set_site_transient('update_plugins', null); |
|
| 674 | 674 | |
| 675 | 675 | // Decode license data. |
| 676 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 677 | - update_option( $addon_license_option_name, $license_data ); |
|
| 676 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 677 | + update_option($addon_license_option_name, $license_data); |
|
| 678 | 678 | }// End foreach(). |
| 679 | 679 | } |
| 680 | 680 | |
@@ -704,9 +704,9 @@ discard block |
||
| 704 | 704 | ); |
| 705 | 705 | |
| 706 | 706 | global $wp_roles; |
| 707 | - foreach ( $delete_caps as $cap ) { |
|
| 708 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 709 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 707 | + foreach ($delete_caps as $cap) { |
|
| 708 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 709 | + $wp_roles->remove_cap($role, $cap); |
|
| 710 | 710 | } |
| 711 | 711 | } |
| 712 | 712 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | function give_v18_upgrades_core_setting() { |
| 741 | 741 | // Core settings which changes from checkbox to radio. |
| 742 | 742 | $core_setting_names = array_merge( |
| 743 | - array_keys( give_v18_renamed_core_settings() ), |
|
| 743 | + array_keys(give_v18_renamed_core_settings()), |
|
| 744 | 744 | array( |
| 745 | 745 | 'uninstall_on_delete', |
| 746 | 746 | 'scripts_footer', |
@@ -752,48 +752,48 @@ discard block |
||
| 752 | 752 | ); |
| 753 | 753 | |
| 754 | 754 | // Bailout: If not any setting define. |
| 755 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
| 755 | + if ($give_settings = get_option('give_settings')) { |
|
| 756 | 756 | |
| 757 | 757 | $setting_changed = false; |
| 758 | 758 | |
| 759 | 759 | // Loop: check each setting field. |
| 760 | - foreach ( $core_setting_names as $setting_name ) { |
|
| 760 | + foreach ($core_setting_names as $setting_name) { |
|
| 761 | 761 | // New setting name. |
| 762 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
| 762 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
| 763 | 763 | |
| 764 | 764 | // Continue: If setting already set. |
| 765 | 765 | if ( |
| 766 | - array_key_exists( $new_setting_name, $give_settings ) |
|
| 767 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
| 766 | + array_key_exists($new_setting_name, $give_settings) |
|
| 767 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
| 768 | 768 | ) { |
| 769 | 769 | continue; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | // Set checkbox value to radio value. |
| 773 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
| 773 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
| 774 | 774 | |
| 775 | 775 | // @see https://github.com/WordImpress/Give/issues/1063. |
| 776 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
| 776 | + if (false !== strpos($setting_name, 'disable_')) { |
|
| 777 | 777 | |
| 778 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
| 779 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
| 778 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
| 779 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
| 780 | 780 | |
| 781 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
| 781 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | // Tell bot to update core setting to db. |
| 785 | - if ( ! $setting_changed ) { |
|
| 785 | + if ( ! $setting_changed) { |
|
| 786 | 786 | $setting_changed = true; |
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | // Update setting only if they changed. |
| 791 | - if ( $setting_changed ) { |
|
| 792 | - update_option( 'give_settings', $give_settings ); |
|
| 791 | + if ($setting_changed) { |
|
| 792 | + update_option('give_settings', $give_settings); |
|
| 793 | 793 | } |
| 794 | 794 | }// End if(). |
| 795 | 795 | |
| 796 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
| 796 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | /** |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | $give_updates = Give_Updates::get_instance(); |
| 808 | 808 | |
| 809 | 809 | // form query |
| 810 | - $forms = new WP_Query( array( |
|
| 810 | + $forms = new WP_Query(array( |
|
| 811 | 811 | 'paged' => $give_updates->step, |
| 812 | 812 | 'status' => 'any', |
| 813 | 813 | 'order' => 'ASC', |
@@ -816,41 +816,41 @@ discard block |
||
| 816 | 816 | ) |
| 817 | 817 | ); |
| 818 | 818 | |
| 819 | - if ( $forms->have_posts() ) { |
|
| 820 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 819 | + if ($forms->have_posts()) { |
|
| 820 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
| 821 | 821 | |
| 822 | - while ( $forms->have_posts() ) { |
|
| 822 | + while ($forms->have_posts()) { |
|
| 823 | 823 | $forms->the_post(); |
| 824 | 824 | |
| 825 | 825 | // Form content. |
| 826 | 826 | // Note in version 1.8 display content setting split into display content and content placement setting. |
| 827 | 827 | // You can delete _give_content_option in future. |
| 828 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
| 829 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
| 830 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
| 831 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
| 828 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
| 829 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
| 830 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
| 831 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
| 832 | 832 | |
| 833 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
| 834 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
| 833 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
| 834 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | // "Disable" Guest Donation. Checkbox. |
| 838 | 838 | // See: https://github.com/WordImpress/Give/issues/1470. |
| 839 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
| 840 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
| 841 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
| 839 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
| 840 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
| 841 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
| 842 | 842 | |
| 843 | 843 | // Offline Donations. |
| 844 | 844 | // See: https://github.com/WordImpress/Give/issues/1579. |
| 845 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
| 846 | - if ( 'no' === $offline_donation ) { |
|
| 845 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
| 846 | + if ('no' === $offline_donation) { |
|
| 847 | 847 | $offline_donation_newval = 'global'; |
| 848 | - } elseif ( 'yes' === $offline_donation ) { |
|
| 848 | + } elseif ('yes' === $offline_donation) { |
|
| 849 | 849 | $offline_donation_newval = 'enabled'; |
| 850 | 850 | } else { |
| 851 | 851 | $offline_donation_newval = 'disabled'; |
| 852 | 852 | } |
| 853 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
| 853 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
| 854 | 854 | |
| 855 | 855 | // Convert yes/no setting field to enabled/disabled. |
| 856 | 856 | $form_radio_settings = array( |
@@ -870,15 +870,15 @@ discard block |
||
| 870 | 870 | '_give_offline_donation_enable_billing_fields_single', |
| 871 | 871 | ); |
| 872 | 872 | |
| 873 | - foreach ( $form_radio_settings as $meta_key ) { |
|
| 873 | + foreach ($form_radio_settings as $meta_key) { |
|
| 874 | 874 | // Get value. |
| 875 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
| 875 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
| 876 | 876 | |
| 877 | 877 | // Convert meta value only if it is in yes/no/none. |
| 878 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
| 878 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
| 879 | 879 | |
| 880 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
| 881 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
| 880 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
| 881 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | }// End while(). |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | |
| 888 | 888 | } else { |
| 889 | 889 | // No more forms found, finish up. |
| 890 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
| 890 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | '%_transient_give_stats_%', |
| 955 | 955 | 'give_cache%', |
| 956 | 956 | '%_transient_give_add_ons_feed%', |
| 957 | - '%_transient__give_ajax_works' . |
|
| 957 | + '%_transient__give_ajax_works'. |
|
| 958 | 958 | '%_transient_give_total_api_keys%', |
| 959 | 959 | '%_transient_give_i18n_give_promo_hide%', |
| 960 | 960 | '%_transient_give_contributors%', |
@@ -981,24 +981,24 @@ discard block |
||
| 981 | 981 | ARRAY_A |
| 982 | 982 | ); |
| 983 | 983 | |
| 984 | - if ( ! empty( $user_apikey_options ) ) { |
|
| 985 | - foreach ( $user_apikey_options as $user ) { |
|
| 986 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
| 987 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
| 988 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
| 984 | + if ( ! empty($user_apikey_options)) { |
|
| 985 | + foreach ($user_apikey_options as $user) { |
|
| 986 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
| 987 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
| 988 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
| 989 | 989 | } |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | - if ( ! empty( $cached_options ) ) { |
|
| 993 | - foreach ( $cached_options as $option ) { |
|
| 994 | - switch ( true ) { |
|
| 995 | - case ( false !== strpos( $option, 'transient' ) ): |
|
| 996 | - $option = str_replace( '_transient_', '', $option ); |
|
| 997 | - delete_transient( $option ); |
|
| 992 | + if ( ! empty($cached_options)) { |
|
| 993 | + foreach ($cached_options as $option) { |
|
| 994 | + switch (true) { |
|
| 995 | + case (false !== strpos($option, 'transient')): |
|
| 996 | + $option = str_replace('_transient_', '', $option); |
|
| 997 | + delete_transient($option); |
|
| 998 | 998 | break; |
| 999 | 999 | |
| 1000 | 1000 | default: |
| 1001 | - delete_option( $option ); |
|
| 1001 | + delete_option($option); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | } |
| 1004 | 1004 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | global $wp_roles; |
| 1017 | 1017 | |
| 1018 | 1018 | // Get the role object. |
| 1019 | - $give_worker = get_role( 'give_worker' ); |
|
| 1019 | + $give_worker = get_role('give_worker'); |
|
| 1020 | 1020 | |
| 1021 | 1021 | // A list of capabilities to add for give workers. |
| 1022 | 1022 | $caps_to_add = array( |
@@ -1024,9 +1024,9 @@ discard block |
||
| 1024 | 1024 | 'edit_pages', |
| 1025 | 1025 | ); |
| 1026 | 1026 | |
| 1027 | - foreach ( $caps_to_add as $cap ) { |
|
| 1027 | + foreach ($caps_to_add as $cap) { |
|
| 1028 | 1028 | // Add the capability. |
| 1029 | - $give_worker->add_cap( $cap ); |
|
| 1029 | + $give_worker->add_cap($cap); |
|
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
| 1043 | 1043 | $give_updates = Give_Updates::get_instance(); |
| 1044 | 1044 | |
| 1045 | 1045 | // form query. |
| 1046 | - $donation_forms = new WP_Query( array( |
|
| 1046 | + $donation_forms = new WP_Query(array( |
|
| 1047 | 1047 | 'paged' => $give_updates->step, |
| 1048 | 1048 | 'status' => 'any', |
| 1049 | 1049 | 'order' => 'ASC', |
@@ -1052,10 +1052,10 @@ discard block |
||
| 1052 | 1052 | ) |
| 1053 | 1053 | ); |
| 1054 | 1054 | |
| 1055 | - if ( $donation_forms->have_posts() ) { |
|
| 1056 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 1055 | + if ($donation_forms->have_posts()) { |
|
| 1056 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 1057 | 1057 | |
| 1058 | - while ( $donation_forms->have_posts() ) { |
|
| 1058 | + while ($donation_forms->have_posts()) { |
|
| 1059 | 1059 | $donation_forms->the_post(); |
| 1060 | 1060 | $form_id = get_the_ID(); |
| 1061 | 1061 | |
@@ -1063,41 +1063,41 @@ discard block |
||
| 1063 | 1063 | update_post_meta( |
| 1064 | 1064 | $form_id, |
| 1065 | 1065 | '_give_set_price', |
| 1066 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
| 1066 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
| 1067 | 1067 | ); |
| 1068 | 1068 | |
| 1069 | 1069 | // Remove formatting from _give_custom_amount_minimum. |
| 1070 | 1070 | update_post_meta( |
| 1071 | 1071 | $form_id, |
| 1072 | 1072 | '_give_custom_amount_minimum', |
| 1073 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
| 1073 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
| 1074 | 1074 | ); |
| 1075 | 1075 | |
| 1076 | 1076 | // Bailout. |
| 1077 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
| 1077 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
| 1078 | 1078 | continue; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
| 1081 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
| 1082 | 1082 | |
| 1083 | - if ( ! empty( $donation_levels ) ) { |
|
| 1083 | + if ( ! empty($donation_levels)) { |
|
| 1084 | 1084 | |
| 1085 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
| 1086 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
| 1087 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
| 1085 | + foreach ($donation_levels as $index => $donation_level) { |
|
| 1086 | + if (isset($donation_level['_give_amount'])) { |
|
| 1087 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
| 1091 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
| 1092 | 1092 | |
| 1093 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
| 1093 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
| 1094 | 1094 | |
| 1095 | - $min_amount = min( $donation_levels_amounts ); |
|
| 1096 | - $max_amount = max( $donation_levels_amounts ); |
|
| 1095 | + $min_amount = min($donation_levels_amounts); |
|
| 1096 | + $max_amount = max($donation_levels_amounts); |
|
| 1097 | 1097 | |
| 1098 | 1098 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
| 1099 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
| 1100 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
| 1099 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
| 1100 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | wp_reset_postdata(); |
| 1107 | 1107 | } else { |
| 1108 | 1108 | // The Update Ran. |
| 1109 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
| 1109 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | */ |
| 1157 | 1157 | function give_v20_upgrades() { |
| 1158 | 1158 | // Update cache setting. |
| 1159 | - give_update_option( 'cache', 'enabled' ); |
|
| 1159 | + give_update_option('cache', 'enabled'); |
|
| 1160 | 1160 | |
| 1161 | 1161 | // Upgrade email settings. |
| 1162 | 1162 | give_v20_upgrades_email_setting(); |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | $all_setting = give_get_settings(); |
| 1176 | 1176 | |
| 1177 | 1177 | // Bailout on fresh install. |
| 1178 | - if ( empty( $all_setting ) ) { |
|
| 1178 | + if (empty($all_setting)) { |
|
| 1179 | 1179 | return; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
@@ -1194,19 +1194,19 @@ discard block |
||
| 1194 | 1194 | 'admin_notices' => 'new-donation_notification', |
| 1195 | 1195 | ); |
| 1196 | 1196 | |
| 1197 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
| 1197 | + foreach ($settings as $old_setting => $new_setting) { |
|
| 1198 | 1198 | // Do not update already modified |
| 1199 | - if ( ! is_array( $new_setting ) ) { |
|
| 1200 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
| 1199 | + if ( ! is_array($new_setting)) { |
|
| 1200 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
| 1201 | 1201 | continue; |
| 1202 | 1202 | } |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | - switch ( $old_setting ) { |
|
| 1205 | + switch ($old_setting) { |
|
| 1206 | 1206 | case 'admin_notices': |
| 1207 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
| 1207 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
| 1208 | 1208 | |
| 1209 | - give_update_option( $new_setting, $notification_status ); |
|
| 1209 | + give_update_option($new_setting, $notification_status); |
|
| 1210 | 1210 | |
| 1211 | 1211 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
| 1212 | 1212 | // give_delete_option( $old_setting ); |
@@ -1217,19 +1217,19 @@ discard block |
||
| 1217 | 1217 | case 'admin_notice_emails': |
| 1218 | 1218 | $recipients = give_get_admin_notice_emails(); |
| 1219 | 1219 | |
| 1220 | - foreach ( $new_setting as $setting ) { |
|
| 1220 | + foreach ($new_setting as $setting) { |
|
| 1221 | 1221 | // bailout if setting already exist. |
| 1222 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
| 1222 | + if (array_key_exists($setting, $all_setting)) { |
|
| 1223 | 1223 | continue; |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | - give_update_option( $setting, $recipients ); |
|
| 1226 | + give_update_option($setting, $recipients); |
|
| 1227 | 1227 | } |
| 1228 | 1228 | break; |
| 1229 | 1229 | |
| 1230 | 1230 | default: |
| 1231 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
| 1232 | - give_delete_option( $old_setting ); |
|
| 1231 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
| 1232 | + give_delete_option($old_setting); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | } |
| 1235 | 1235 | } |
@@ -1246,22 +1246,22 @@ discard block |
||
| 1246 | 1246 | $give_settings = give_get_settings(); |
| 1247 | 1247 | $give_setting_updated = false; |
| 1248 | 1248 | |
| 1249 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
| 1249 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
| 1250 | 1250 | $give_settings['number_decimals'] = 0; |
| 1251 | 1251 | $give_settings['decimal_separator'] = ''; |
| 1252 | 1252 | $give_setting_updated = true; |
| 1253 | 1253 | |
| 1254 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
| 1254 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
| 1255 | 1255 | $give_settings['number_decimals'] = 0; |
| 1256 | 1256 | $give_setting_updated = true; |
| 1257 | 1257 | |
| 1258 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
| 1258 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
| 1259 | 1259 | $give_settings['number_decimals'] = 5; |
| 1260 | 1260 | $give_setting_updated = true; |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | - if ( $give_setting_updated ) { |
|
| 1264 | - update_option( 'give_settings', $give_settings ); |
|
| 1263 | + if ($give_setting_updated) { |
|
| 1264 | + update_option('give_settings', $give_settings); |
|
| 1265 | 1265 | } |
| 1266 | 1266 | } |
| 1267 | 1267 | |
@@ -1280,69 +1280,69 @@ discard block |
||
| 1280 | 1280 | $give_updates = Give_Updates::get_instance(); |
| 1281 | 1281 | |
| 1282 | 1282 | // form query. |
| 1283 | - $donation_forms = new WP_Query( array( |
|
| 1283 | + $donation_forms = new WP_Query(array( |
|
| 1284 | 1284 | 'paged' => $give_updates->step, |
| 1285 | 1285 | 'status' => 'any', |
| 1286 | 1286 | 'order' => 'ASC', |
| 1287 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
| 1287 | + 'post_type' => array('give_forms', 'give_payment'), |
|
| 1288 | 1288 | 'posts_per_page' => 20, |
| 1289 | 1289 | ) |
| 1290 | 1290 | ); |
| 1291 | - if ( $donation_forms->have_posts() ) { |
|
| 1292 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 1291 | + if ($donation_forms->have_posts()) { |
|
| 1292 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 1293 | 1293 | |
| 1294 | - while ( $donation_forms->have_posts() ) { |
|
| 1294 | + while ($donation_forms->have_posts()) { |
|
| 1295 | 1295 | $donation_forms->the_post(); |
| 1296 | 1296 | global $post; |
| 1297 | 1297 | |
| 1298 | - $meta = get_post_meta( $post->ID ); |
|
| 1298 | + $meta = get_post_meta($post->ID); |
|
| 1299 | 1299 | |
| 1300 | - switch ( $post->post_type ) { |
|
| 1300 | + switch ($post->post_type) { |
|
| 1301 | 1301 | case 'give_forms': |
| 1302 | 1302 | // _give_set_price. |
| 1303 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
| 1304 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
| 1303 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
| 1304 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
| 1305 | 1305 | } |
| 1306 | 1306 | |
| 1307 | 1307 | // _give_custom_amount_minimum. |
| 1308 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
| 1309 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
| 1308 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
| 1309 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | // _give_levels_minimum_amount. |
| 1313 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
| 1314 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
| 1313 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
| 1314 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | // _give_levels_maximum_amount. |
| 1318 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
| 1319 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
| 1318 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
| 1319 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | // _give_set_goal. |
| 1323 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
| 1324 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
| 1323 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
| 1324 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | // _give_form_earnings. |
| 1328 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
| 1329 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
| 1328 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
| 1329 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | // _give_custom_amount_minimum. |
| 1333 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
| 1334 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
| 1333 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
| 1334 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
| 1335 | 1335 | |
| 1336 | - foreach ( $donation_levels as $index => $level ) { |
|
| 1337 | - if ( empty( $level['_give_amount'] ) ) { |
|
| 1336 | + foreach ($donation_levels as $index => $level) { |
|
| 1337 | + if (empty($level['_give_amount'])) { |
|
| 1338 | 1338 | continue; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
| 1341 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | 1344 | $meta['_give_donation_levels'] = $donation_levels; |
| 1345 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
| 1345 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | |
@@ -1350,8 +1350,8 @@ discard block |
||
| 1350 | 1350 | |
| 1351 | 1351 | case 'give_payment': |
| 1352 | 1352 | // _give_payment_total. |
| 1353 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
| 1354 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
| 1353 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
| 1354 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | break; |
@@ -1362,7 +1362,7 @@ discard block |
||
| 1362 | 1362 | wp_reset_postdata(); |
| 1363 | 1363 | } else { |
| 1364 | 1364 | // The Update Ran. |
| 1365 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
| 1365 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
| 1366 | 1366 | } |
| 1367 | 1367 | } |
| 1368 | 1368 | |
@@ -1381,22 +1381,22 @@ discard block |
||
| 1381 | 1381 | $give_updates = Give_Updates::get_instance(); |
| 1382 | 1382 | |
| 1383 | 1383 | // form query. |
| 1384 | - $donors = Give()->donors->get_donors( array( |
|
| 1384 | + $donors = Give()->donors->get_donors(array( |
|
| 1385 | 1385 | 'number' => 20, |
| 1386 | - 'offset' => $give_updates->get_offset( 20 ), |
|
| 1386 | + 'offset' => $give_updates->get_offset(20), |
|
| 1387 | 1387 | ) |
| 1388 | 1388 | ); |
| 1389 | 1389 | |
| 1390 | - if ( ! empty( $donors ) ) { |
|
| 1391 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
| 1390 | + if ( ! empty($donors)) { |
|
| 1391 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
| 1392 | 1392 | |
| 1393 | 1393 | /* @var Object $donor */ |
| 1394 | - foreach ( $donors as $donor ) { |
|
| 1395 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
| 1394 | + foreach ($donors as $donor) { |
|
| 1395 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | } else { |
| 1398 | 1398 | // The Update Ran. |
| 1399 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
| 1399 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
| 1400 | 1400 | } |
| 1401 | 1401 | } |
| 1402 | 1402 | |
@@ -1410,25 +1410,25 @@ discard block |
||
| 1410 | 1410 | $give_updates = Give_Updates::get_instance(); |
| 1411 | 1411 | |
| 1412 | 1412 | // Fetch all the existing donors. |
| 1413 | - $donors = Give()->donors->get_donors( array( |
|
| 1413 | + $donors = Give()->donors->get_donors(array( |
|
| 1414 | 1414 | 'number' => 20, |
| 1415 | - 'offset' => $give_updates->get_offset( 20 ), |
|
| 1415 | + 'offset' => $give_updates->get_offset(20), |
|
| 1416 | 1416 | ) |
| 1417 | 1417 | ); |
| 1418 | 1418 | |
| 1419 | - if ( ! empty( $donors ) ) { |
|
| 1420 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
| 1419 | + if ( ! empty($donors)) { |
|
| 1420 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
| 1421 | 1421 | |
| 1422 | 1422 | /* @var Object $donor */ |
| 1423 | - foreach ( $donors as $donor ) { |
|
| 1423 | + foreach ($donors as $donor) { |
|
| 1424 | 1424 | $user_id = $donor->user_id; |
| 1425 | 1425 | |
| 1426 | 1426 | // Proceed, if donor is attached with user. |
| 1427 | - if ( $user_id ) { |
|
| 1428 | - $user = get_userdata( $user_id ); |
|
| 1427 | + if ($user_id) { |
|
| 1428 | + $user = get_userdata($user_id); |
|
| 1429 | 1429 | |
| 1430 | 1430 | // Update user role, if user has subscriber role. |
| 1431 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
| 1431 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
| 1432 | 1432 | wp_update_user( |
| 1433 | 1433 | array( |
| 1434 | 1434 | 'ID' => $user_id, |
@@ -1440,7 +1440,7 @@ discard block |
||
| 1440 | 1440 | } |
| 1441 | 1441 | } else { |
| 1442 | 1442 | // The Update Ran. |
| 1443 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
| 1443 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
| 1444 | 1444 | } |
| 1445 | 1445 | } |
| 1446 | 1446 | |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | */ |
| 1453 | 1453 | function give_v1813_upgrades() { |
| 1454 | 1454 | // Update admin setting. |
| 1455 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
| 1455 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
| 1456 | 1456 | |
| 1457 | 1457 | // Update Give roles. |
| 1458 | 1458 | $roles = new Give_Roles(); |
@@ -1470,33 +1470,33 @@ discard block |
||
| 1470 | 1470 | $give_updates = Give_Updates::get_instance(); |
| 1471 | 1471 | |
| 1472 | 1472 | // form query. |
| 1473 | - $payments = new WP_Query( array( |
|
| 1473 | + $payments = new WP_Query(array( |
|
| 1474 | 1474 | 'paged' => $give_updates->step, |
| 1475 | 1475 | 'status' => 'any', |
| 1476 | 1476 | 'order' => 'ASC', |
| 1477 | - 'post_type' => array( 'give_payment' ), |
|
| 1477 | + 'post_type' => array('give_payment'), |
|
| 1478 | 1478 | 'posts_per_page' => 100, |
| 1479 | 1479 | ) |
| 1480 | 1480 | ); |
| 1481 | 1481 | |
| 1482 | - if ( $payments->have_posts() ) { |
|
| 1483 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
| 1482 | + if ($payments->have_posts()) { |
|
| 1483 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
| 1484 | 1484 | |
| 1485 | - while ( $payments->have_posts() ) { |
|
| 1485 | + while ($payments->have_posts()) { |
|
| 1486 | 1486 | $payments->the_post(); |
| 1487 | 1487 | |
| 1488 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
| 1488 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
| 1489 | 1489 | |
| 1490 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
| 1490 | + if ('RIAL' === $payment_meta['currency']) { |
|
| 1491 | 1491 | $payment_meta['currency'] = 'IRR'; |
| 1492 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
| 1492 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | } else { |
| 1498 | 1498 | // The Update Ran. |
| 1499 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
| 1499 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
| 1500 | 1500 | } |
| 1501 | 1501 | } |
| 1502 | 1502 | |
@@ -1509,9 +1509,9 @@ discard block |
||
| 1509 | 1509 | function give_v1817_upgrades() { |
| 1510 | 1510 | $give_settings = give_get_settings(); |
| 1511 | 1511 | |
| 1512 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
| 1512 | + if ('RIAL' === $give_settings['currency']) { |
|
| 1513 | 1513 | $give_settings['currency'] = 'IRR'; |
| 1514 | - update_option( 'give_settings', $give_settings ); |
|
| 1514 | + update_option('give_settings', $give_settings); |
|
| 1515 | 1515 | } |
| 1516 | 1516 | } |
| 1517 | 1517 | |
@@ -1524,7 +1524,7 @@ discard block |
||
| 1524 | 1524 | |
| 1525 | 1525 | global $wp_roles; |
| 1526 | 1526 | |
| 1527 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
| 1527 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
| 1528 | 1528 | return; |
| 1529 | 1529 | } |
| 1530 | 1530 | |
@@ -1548,15 +1548,15 @@ discard block |
||
| 1548 | 1548 | ), |
| 1549 | 1549 | ); |
| 1550 | 1550 | |
| 1551 | - foreach ( $add_caps as $role => $caps ) { |
|
| 1552 | - foreach ( $caps as $cap ) { |
|
| 1553 | - $wp_roles->add_cap( $role, $cap ); |
|
| 1551 | + foreach ($add_caps as $role => $caps) { |
|
| 1552 | + foreach ($caps as $cap) { |
|
| 1553 | + $wp_roles->add_cap($role, $cap); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | - foreach ( $remove_caps as $role => $caps ) { |
|
| 1558 | - foreach ( $caps as $cap ) { |
|
| 1559 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 1557 | + foreach ($remove_caps as $role => $caps) { |
|
| 1558 | + foreach ($caps as $cap) { |
|
| 1559 | + $wp_roles->remove_cap($role, $cap); |
|
| 1560 | 1560 | } |
| 1561 | 1561 | } |
| 1562 | 1562 | |
@@ -1580,7 +1580,7 @@ discard block |
||
| 1580 | 1580 | $roles->add_roles(); |
| 1581 | 1581 | $roles->add_caps(); |
| 1582 | 1582 | |
| 1583 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
| 1583 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | /** |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | function give_v1818_upgrades() { |
| 1592 | 1592 | |
| 1593 | 1593 | // Remove email_access_installed from give_settings. |
| 1594 | - give_delete_option( 'email_access_installed' ); |
|
| 1594 | + give_delete_option('email_access_installed'); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
@@ -1604,23 +1604,23 @@ discard block |
||
| 1604 | 1604 | /* @var Give_Updates $give_updates */ |
| 1605 | 1605 | $give_updates = Give_Updates::get_instance(); |
| 1606 | 1606 | |
| 1607 | - $donations = new WP_Query( array( |
|
| 1607 | + $donations = new WP_Query(array( |
|
| 1608 | 1608 | 'paged' => $give_updates->step, |
| 1609 | 1609 | 'status' => 'any', |
| 1610 | 1610 | 'order' => 'ASC', |
| 1611 | - 'post_type' => array( 'give_payment' ), |
|
| 1611 | + 'post_type' => array('give_payment'), |
|
| 1612 | 1612 | 'posts_per_page' => 100, |
| 1613 | 1613 | ) |
| 1614 | 1614 | ); |
| 1615 | 1615 | |
| 1616 | - if ( $donations->have_posts() ) { |
|
| 1617 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
| 1616 | + if ($donations->have_posts()) { |
|
| 1617 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
| 1618 | 1618 | |
| 1619 | - while ( $donations->have_posts() ) { |
|
| 1619 | + while ($donations->have_posts()) { |
|
| 1620 | 1620 | $donations->the_post(); |
| 1621 | 1621 | |
| 1622 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
| 1623 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
| 1622 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
| 1623 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
| 1624 | 1624 | |
| 1625 | 1625 | // Update Donation meta with price_id set as custom, only if it is: |
| 1626 | 1626 | // 1. Donation Type = Set Donation. |
@@ -1629,19 +1629,19 @@ discard block |
||
| 1629 | 1629 | if ( |
| 1630 | 1630 | $form->ID && |
| 1631 | 1631 | $form->is_set_type_donation_form() && |
| 1632 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
| 1633 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
| 1632 | + ('custom' !== $donation_meta['price_id']) && |
|
| 1633 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
| 1634 | 1634 | ) { |
| 1635 | 1635 | $donation_meta['price_id'] = 'custom'; |
| 1636 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
| 1637 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
| 1636 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
| 1637 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
| 1638 | 1638 | } |
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | 1641 | wp_reset_postdata(); |
| 1642 | 1642 | } else { |
| 1643 | 1643 | // Update Ran Successfully. |
| 1644 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
| 1644 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
| 1645 | 1645 | } |
| 1646 | 1646 | } |
| 1647 | 1647 | |
@@ -1659,7 +1659,7 @@ discard block |
||
| 1659 | 1659 | |
| 1660 | 1660 | global $wp_roles; |
| 1661 | 1661 | |
| 1662 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
| 1662 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
| 1663 | 1663 | return; |
| 1664 | 1664 | } |
| 1665 | 1665 | |
@@ -1677,9 +1677,9 @@ discard block |
||
| 1677 | 1677 | ), |
| 1678 | 1678 | ); |
| 1679 | 1679 | |
| 1680 | - foreach ( $remove_caps as $role => $caps ) { |
|
| 1681 | - foreach ( $caps as $cap ) { |
|
| 1682 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 1680 | + foreach ($remove_caps as $role => $caps) { |
|
| 1681 | + foreach ($caps as $cap) { |
|
| 1682 | + $wp_roles->remove_cap($role, $cap); |
|
| 1683 | 1683 | } |
| 1684 | 1684 | } |
| 1685 | 1685 | |
@@ -1690,7 +1690,7 @@ discard block |
||
| 1690 | 1690 | $roles->add_roles(); |
| 1691 | 1691 | $roles->add_caps(); |
| 1692 | 1692 | |
| 1693 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
| 1693 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | /** |
@@ -1704,7 +1704,7 @@ discard block |
||
| 1704 | 1704 | $give_updates = Give_Updates::get_instance(); |
| 1705 | 1705 | |
| 1706 | 1706 | // form query |
| 1707 | - $forms = new WP_Query( array( |
|
| 1707 | + $forms = new WP_Query(array( |
|
| 1708 | 1708 | 'paged' => $give_updates->step, |
| 1709 | 1709 | 'status' => 'any', |
| 1710 | 1710 | 'order' => 'ASC', |
@@ -1713,22 +1713,22 @@ discard block |
||
| 1713 | 1713 | ) |
| 1714 | 1714 | ); |
| 1715 | 1715 | |
| 1716 | - if ( $forms->have_posts() ) { |
|
| 1717 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
| 1716 | + if ($forms->have_posts()) { |
|
| 1717 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
| 1718 | 1718 | |
| 1719 | - while ( $forms->have_posts() ) { |
|
| 1719 | + while ($forms->have_posts()) { |
|
| 1720 | 1720 | $forms->the_post(); |
| 1721 | 1721 | global $post; |
| 1722 | 1722 | |
| 1723 | 1723 | // Update offline instruction email notification status. |
| 1724 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
| 1725 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
| 1724 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
| 1725 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
| 1726 | 1726 | 'enabled', |
| 1727 | 1727 | 'global', |
| 1728 | - ) ) |
|
| 1728 | + )) |
|
| 1729 | 1729 | ? $offline_instruction_notification_status |
| 1730 | 1730 | : 'global'; |
| 1731 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
| 1731 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
| 1732 | 1732 | |
| 1733 | 1733 | // Update offline instruction email message. |
| 1734 | 1734 | update_post_meta( |
@@ -1760,7 +1760,7 @@ discard block |
||
| 1760 | 1760 | wp_reset_postdata(); |
| 1761 | 1761 | } else { |
| 1762 | 1762 | // No more forms found, finish up. |
| 1763 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
| 1763 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
| 1764 | 1764 | } |
| 1765 | 1765 | } |
| 1766 | 1766 | |
@@ -1777,7 +1777,7 @@ discard block |
||
| 1777 | 1777 | $give_updates = Give_Updates::get_instance(); |
| 1778 | 1778 | |
| 1779 | 1779 | // form query |
| 1780 | - $forms = new WP_Query( array( |
|
| 1780 | + $forms = new WP_Query(array( |
|
| 1781 | 1781 | 'paged' => $give_updates->step, |
| 1782 | 1782 | 'status' => 'any', |
| 1783 | 1783 | 'order' => 'ASC', |
@@ -1786,19 +1786,19 @@ discard block |
||
| 1786 | 1786 | ) |
| 1787 | 1787 | ); |
| 1788 | 1788 | |
| 1789 | - if ( $forms->have_posts() ) { |
|
| 1790 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
| 1789 | + if ($forms->have_posts()) { |
|
| 1790 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
| 1791 | 1791 | |
| 1792 | - while ( $forms->have_posts() ) { |
|
| 1792 | + while ($forms->have_posts()) { |
|
| 1793 | 1793 | $forms->the_post(); |
| 1794 | 1794 | global $post; |
| 1795 | 1795 | |
| 1796 | 1796 | // Split _give_payment_meta meta. |
| 1797 | 1797 | // @todo Remove _give_payment_meta after releases 2.0 |
| 1798 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
| 1798 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
| 1799 | 1799 | |
| 1800 | - if ( ! empty( $payment_meta ) ) { |
|
| 1801 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
| 1800 | + if ( ! empty($payment_meta)) { |
|
| 1801 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | $deprecated_meta_keys = array( |
@@ -1807,9 +1807,9 @@ discard block |
||
| 1807 | 1807 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
| 1808 | 1808 | ); |
| 1809 | 1809 | |
| 1810 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
| 1810 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
| 1811 | 1811 | // Do not add new meta key if already exist. |
| 1812 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
| 1812 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
| 1813 | 1813 | continue; |
| 1814 | 1814 | } |
| 1815 | 1815 | |
@@ -1818,25 +1818,25 @@ discard block |
||
| 1818 | 1818 | array( |
| 1819 | 1819 | 'post_id' => $post->ID, |
| 1820 | 1820 | 'meta_key' => $new_meta_key, |
| 1821 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
| 1821 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
| 1822 | 1822 | ) |
| 1823 | 1823 | ); |
| 1824 | 1824 | } |
| 1825 | 1825 | |
| 1826 | 1826 | // Bailout |
| 1827 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
| 1827 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
| 1828 | 1828 | /* @var Give_Donor $donor */ |
| 1829 | - $donor = new Give_Donor( $donor_id ); |
|
| 1829 | + $donor = new Give_Donor($donor_id); |
|
| 1830 | 1830 | |
| 1831 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
| 1832 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
| 1833 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
| 1834 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
| 1835 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
| 1836 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
| 1831 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
| 1832 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
| 1833 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
| 1834 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
| 1835 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
| 1836 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
| 1837 | 1837 | |
| 1838 | 1838 | // Save address. |
| 1839 | - $donor->add_address( 'billing[]', $address ); |
|
| 1839 | + $donor->add_address('billing[]', $address); |
|
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | }// End while(). |
@@ -1847,7 +1847,7 @@ discard block |
||
| 1847 | 1847 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
| 1848 | 1848 | |
| 1849 | 1849 | // No more forms found, finish up. |
| 1850 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
| 1850 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
| 1851 | 1851 | } |
| 1852 | 1852 | } |
| 1853 | 1853 | |
@@ -1863,7 +1863,7 @@ discard block |
||
| 1863 | 1863 | $give_updates = Give_Updates::get_instance(); |
| 1864 | 1864 | |
| 1865 | 1865 | // form query |
| 1866 | - $forms = new WP_Query( array( |
|
| 1866 | + $forms = new WP_Query(array( |
|
| 1867 | 1867 | 'paged' => $give_updates->step, |
| 1868 | 1868 | 'order' => 'DESC', |
| 1869 | 1869 | 'post_type' => 'give_log', |
@@ -1872,20 +1872,20 @@ discard block |
||
| 1872 | 1872 | ) |
| 1873 | 1873 | ); |
| 1874 | 1874 | |
| 1875 | - if ( $forms->have_posts() ) { |
|
| 1876 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
| 1875 | + if ($forms->have_posts()) { |
|
| 1876 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
| 1877 | 1877 | |
| 1878 | - while ( $forms->have_posts() ) { |
|
| 1878 | + while ($forms->have_posts()) { |
|
| 1879 | 1879 | $forms->the_post(); |
| 1880 | 1880 | global $post; |
| 1881 | 1881 | |
| 1882 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
| 1882 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
| 1883 | 1883 | continue; |
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
| 1887 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
| 1888 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
| 1886 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
| 1887 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
| 1888 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
| 1889 | 1889 | |
| 1890 | 1890 | $log_data = array( |
| 1891 | 1891 | 'ID' => $post->ID, |
@@ -1898,29 +1898,29 @@ discard block |
||
| 1898 | 1898 | ); |
| 1899 | 1899 | $log_meta = array(); |
| 1900 | 1900 | |
| 1901 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
| 1902 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
| 1903 | - switch ( $meta_key ) { |
|
| 1901 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
| 1902 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
| 1903 | + switch ($meta_key) { |
|
| 1904 | 1904 | case '_give_log_payment_id': |
| 1905 | - $log_data['log_parent'] = current( $meta_value ); |
|
| 1905 | + $log_data['log_parent'] = current($meta_value); |
|
| 1906 | 1906 | $log_meta['_give_log_form_id'] = $post->post_parent; |
| 1907 | 1907 | break; |
| 1908 | 1908 | |
| 1909 | 1909 | default: |
| 1910 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
| 1910 | + $log_meta[$meta_key] = current($meta_value); |
|
| 1911 | 1911 | } |
| 1912 | 1912 | } |
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | - if ( 'api_request' === $term_name ) { |
|
| 1915 | + if ('api_request' === $term_name) { |
|
| 1916 | 1916 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
| 1919 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
| 1920 | 1920 | |
| 1921 | - if ( ! empty( $log_meta ) ) { |
|
| 1922 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
| 1923 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
| 1921 | + if ( ! empty($log_meta)) { |
|
| 1922 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
| 1923 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
| 1924 | 1924 | } |
| 1925 | 1925 | } |
| 1926 | 1926 | |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | Give()->logs->delete_cache(); |
| 1963 | 1963 | |
| 1964 | 1964 | // No more forms found, finish up. |
| 1965 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
| 1965 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
| 1966 | 1966 | } |
| 1967 | 1967 | } |
| 1968 | 1968 | |
@@ -1978,19 +1978,19 @@ discard block |
||
| 1978 | 1978 | $give_updates = Give_Updates::get_instance(); |
| 1979 | 1979 | |
| 1980 | 1980 | // form query |
| 1981 | - $payments = new WP_Query( array( |
|
| 1981 | + $payments = new WP_Query(array( |
|
| 1982 | 1982 | 'paged' => $give_updates->step, |
| 1983 | 1983 | 'status' => 'any', |
| 1984 | 1984 | 'order' => 'ASC', |
| 1985 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
| 1985 | + 'post_type' => array('give_forms', 'give_payment'), |
|
| 1986 | 1986 | 'posts_per_page' => 100, |
| 1987 | 1987 | ) |
| 1988 | 1988 | ); |
| 1989 | 1989 | |
| 1990 | - if ( $payments->have_posts() ) { |
|
| 1991 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
| 1990 | + if ($payments->have_posts()) { |
|
| 1991 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
| 1992 | 1992 | |
| 1993 | - while ( $payments->have_posts() ) { |
|
| 1993 | + while ($payments->have_posts()) { |
|
| 1994 | 1994 | $payments->the_post(); |
| 1995 | 1995 | global $post; |
| 1996 | 1996 | |
@@ -2002,19 +2002,19 @@ discard block |
||
| 2002 | 2002 | ARRAY_A |
| 2003 | 2003 | ); |
| 2004 | 2004 | |
| 2005 | - if ( ! empty( $meta_data ) ) { |
|
| 2006 | - foreach ( $meta_data as $index => $data ) { |
|
| 2005 | + if ( ! empty($meta_data)) { |
|
| 2006 | + foreach ($meta_data as $index => $data) { |
|
| 2007 | 2007 | // Check for duplicate meta values. |
| 2008 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
| 2008 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
| 2009 | 2009 | continue; |
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | - switch ( $post->post_type ) { |
|
| 2012 | + switch ($post->post_type) { |
|
| 2013 | 2013 | case 'give_forms': |
| 2014 | 2014 | $data['form_id'] = $data['post_id']; |
| 2015 | - unset( $data['post_id'] ); |
|
| 2015 | + unset($data['post_id']); |
|
| 2016 | 2016 | |
| 2017 | - Give()->form_meta->insert( $data ); |
|
| 2017 | + Give()->form_meta->insert($data); |
|
| 2018 | 2018 | // @todo: delete form meta from post meta table after releases 2.0. |
| 2019 | 2019 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
| 2020 | 2020 | |
@@ -2022,9 +2022,9 @@ discard block |
||
| 2022 | 2022 | |
| 2023 | 2023 | case 'give_payment': |
| 2024 | 2024 | $data['payment_id'] = $data['post_id']; |
| 2025 | - unset( $data['post_id'] ); |
|
| 2025 | + unset($data['post_id']); |
|
| 2026 | 2026 | |
| 2027 | - Give()->payment_meta->insert( $data ); |
|
| 2027 | + Give()->payment_meta->insert($data); |
|
| 2028 | 2028 | |
| 2029 | 2029 | // @todo: delete donation meta from post meta table after releases 2.0. |
| 2030 | 2030 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2039,7 +2039,7 @@ discard block |
||
| 2039 | 2039 | wp_reset_postdata(); |
| 2040 | 2040 | } else { |
| 2041 | 2041 | // No more forms found, finish up. |
| 2042 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
| 2042 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
| 2043 | 2043 | } |
| 2044 | 2044 | |
| 2045 | 2045 | } |
@@ -2055,44 +2055,44 @@ discard block |
||
| 2055 | 2055 | /* @var Give_Updates $give_updates */ |
| 2056 | 2056 | $give_updates = Give_Updates::get_instance(); |
| 2057 | 2057 | |
| 2058 | - $donors = Give()->donors->get_donors( array( |
|
| 2058 | + $donors = Give()->donors->get_donors(array( |
|
| 2059 | 2059 | 'paged' => $give_updates->step, |
| 2060 | 2060 | 'number' => 100, |
| 2061 | - ) ); |
|
| 2061 | + )); |
|
| 2062 | 2062 | |
| 2063 | - if ( $donors ) { |
|
| 2064 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
| 2063 | + if ($donors) { |
|
| 2064 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
| 2065 | 2065 | // Loop through Donors |
| 2066 | - foreach ( $donors as $donor ) { |
|
| 2066 | + foreach ($donors as $donor) { |
|
| 2067 | 2067 | |
| 2068 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
| 2069 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
| 2070 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
| 2068 | + $donor_name = explode(' ', $donor->name, 2); |
|
| 2069 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
| 2070 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
| 2071 | 2071 | |
| 2072 | 2072 | // If first name meta of donor is not created, then create it. |
| 2073 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
| 2074 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
| 2073 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
| 2074 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
| 2075 | 2075 | } |
| 2076 | 2076 | |
| 2077 | 2077 | // If last name meta of donor is not created, then create it. |
| 2078 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
| 2079 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
| 2078 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
| 2079 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | 2082 | // If Donor is connected with WP User then update user meta. |
| 2083 | - if ( $donor->user_id ) { |
|
| 2084 | - if ( isset( $donor_name[0] ) ) { |
|
| 2085 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
| 2083 | + if ($donor->user_id) { |
|
| 2084 | + if (isset($donor_name[0])) { |
|
| 2085 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
| 2086 | 2086 | } |
| 2087 | - if ( isset( $donor_name[1] ) ) { |
|
| 2088 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
| 2087 | + if (isset($donor_name[1])) { |
|
| 2088 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
| 2089 | 2089 | } |
| 2090 | 2090 | } |
| 2091 | 2091 | } |
| 2092 | 2092 | |
| 2093 | 2093 | } else { |
| 2094 | 2094 | // The Update Ran. |
| 2095 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
| 2095 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | 2098 | } |
@@ -2121,15 +2121,15 @@ discard block |
||
| 2121 | 2121 | |
| 2122 | 2122 | $users = $user_query->get_results(); |
| 2123 | 2123 | |
| 2124 | - if ( $users ) { |
|
| 2125 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
| 2124 | + if ($users) { |
|
| 2125 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
| 2126 | 2126 | |
| 2127 | 2127 | // Loop through Donors |
| 2128 | - foreach ( $users as $user ) { |
|
| 2128 | + foreach ($users as $user) { |
|
| 2129 | 2129 | /* @var Give_Donor $donor */ |
| 2130 | - $donor = new Give_Donor( $user->ID, true ); |
|
| 2130 | + $donor = new Give_Donor($user->ID, true); |
|
| 2131 | 2131 | |
| 2132 | - if ( ! $donor->id ) { |
|
| 2132 | + if ( ! $donor->id) { |
|
| 2133 | 2133 | continue; |
| 2134 | 2134 | } |
| 2135 | 2135 | |
@@ -2145,10 +2145,10 @@ discard block |
||
| 2145 | 2145 | ) |
| 2146 | 2146 | ); |
| 2147 | 2147 | |
| 2148 | - if ( ! empty( $address ) ) { |
|
| 2149 | - $address = maybe_unserialize( $address ); |
|
| 2150 | - $donor->add_address( 'personal', $address ); |
|
| 2151 | - $donor->add_address( 'billing[]', $address ); |
|
| 2148 | + if ( ! empty($address)) { |
|
| 2149 | + $address = maybe_unserialize($address); |
|
| 2150 | + $donor->add_address('personal', $address); |
|
| 2151 | + $donor->add_address('billing[]', $address); |
|
| 2152 | 2152 | |
| 2153 | 2153 | |
| 2154 | 2154 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2158,7 +2158,7 @@ discard block |
||
| 2158 | 2158 | |
| 2159 | 2159 | } else { |
| 2160 | 2160 | // The Update Ran. |
| 2161 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
| 2161 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | } |
@@ -2182,15 +2182,15 @@ discard block |
||
| 2182 | 2182 | ); |
| 2183 | 2183 | |
| 2184 | 2184 | // Alter customer table |
| 2185 | - foreach ( $tables as $old_table => $new_table ) { |
|
| 2185 | + foreach ($tables as $old_table => $new_table) { |
|
| 2186 | 2186 | if ( |
| 2187 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
| 2188 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
| 2187 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
| 2188 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
| 2189 | 2189 | ) { |
| 2190 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
| 2190 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
| 2191 | 2191 | |
| 2192 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
| 2193 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
| 2192 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
| 2193 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
| 2194 | 2194 | } |
| 2195 | 2195 | } |
| 2196 | 2196 | } |
@@ -2198,7 +2198,7 @@ discard block |
||
| 2198 | 2198 | $give_updates->percentage = 100; |
| 2199 | 2199 | |
| 2200 | 2200 | // No more forms found, finish up. |
| 2201 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
| 2201 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
| 2202 | 2202 | |
| 2203 | 2203 | // Re initiate donor classes. |
| 2204 | 2204 | Give()->donors = new Give_DB_Donors(); |
@@ -2216,19 +2216,19 @@ discard block |
||
| 2216 | 2216 | function give_v201_create_tables() { |
| 2217 | 2217 | global $wpdb; |
| 2218 | 2218 | |
| 2219 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
| 2219 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
| 2220 | 2220 | Give()->payment_meta->create_table(); |
| 2221 | 2221 | } |
| 2222 | 2222 | |
| 2223 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
| 2223 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
| 2224 | 2224 | Give()->form_meta->create_table(); |
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
| 2227 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
| 2228 | 2228 | Give()->logs->log_db->create_table(); |
| 2229 | 2229 | } |
| 2230 | 2230 | |
| 2231 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
| 2231 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
| 2232 | 2232 | Give()->logs->logmeta_db->create_table(); |
| 2233 | 2233 | } |
| 2234 | 2234 | } |
@@ -2253,31 +2253,31 @@ discard block |
||
| 2253 | 2253 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
| 2254 | 2254 | ) |
| 2255 | 2255 | AND $wpdb->posts.post_type = 'give_payment' |
| 2256 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
| 2256 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
| 2257 | 2257 | ORDER BY $wpdb->posts.post_date ASC |
| 2258 | 2258 | LIMIT 100 |
| 2259 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
| 2259 | + OFFSET ".$give_updates->get_offset(100) |
|
| 2260 | 2260 | ); |
| 2261 | 2261 | |
| 2262 | - if ( ! empty( $payments ) ) { |
|
| 2263 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
| 2262 | + if ( ! empty($payments)) { |
|
| 2263 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
| 2264 | 2264 | |
| 2265 | - foreach ( $payments as $payment_id ) { |
|
| 2266 | - $post = get_post( $payment_id ); |
|
| 2267 | - setup_postdata( $post ); |
|
| 2265 | + foreach ($payments as $payment_id) { |
|
| 2266 | + $post = get_post($payment_id); |
|
| 2267 | + setup_postdata($post); |
|
| 2268 | 2268 | |
| 2269 | 2269 | // Do not add new meta keys if already refactored. |
| 2270 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
| 2270 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
| 2271 | 2271 | continue; |
| 2272 | 2272 | } |
| 2273 | 2273 | |
| 2274 | 2274 | |
| 2275 | 2275 | // Split _give_payment_meta meta. |
| 2276 | 2276 | // @todo Remove _give_payment_meta after releases 2.0 |
| 2277 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
| 2277 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
| 2278 | 2278 | |
| 2279 | - if ( ! empty( $payment_meta ) ) { |
|
| 2280 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
| 2279 | + if ( ! empty($payment_meta)) { |
|
| 2280 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | $deprecated_meta_keys = array( |
@@ -2286,9 +2286,9 @@ discard block |
||
| 2286 | 2286 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
| 2287 | 2287 | ); |
| 2288 | 2288 | |
| 2289 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
| 2289 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
| 2290 | 2290 | // Do not add new meta key if already exist. |
| 2291 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
| 2291 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
| 2292 | 2292 | continue; |
| 2293 | 2293 | } |
| 2294 | 2294 | |
@@ -2297,25 +2297,25 @@ discard block |
||
| 2297 | 2297 | array( |
| 2298 | 2298 | 'post_id' => $post->ID, |
| 2299 | 2299 | 'meta_key' => $new_meta_key, |
| 2300 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
| 2300 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
| 2301 | 2301 | ) |
| 2302 | 2302 | ); |
| 2303 | 2303 | } |
| 2304 | 2304 | |
| 2305 | 2305 | // Bailout |
| 2306 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
| 2306 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
| 2307 | 2307 | /* @var Give_Donor $donor */ |
| 2308 | - $donor = new Give_Donor( $donor_id ); |
|
| 2308 | + $donor = new Give_Donor($donor_id); |
|
| 2309 | 2309 | |
| 2310 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
| 2311 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
| 2312 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
| 2313 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
| 2314 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
| 2315 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
| 2310 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
| 2311 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
| 2312 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
| 2313 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
| 2314 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
| 2315 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
| 2316 | 2316 | |
| 2317 | 2317 | // Save address. |
| 2318 | - $donor->add_address( 'billing[]', $address ); |
|
| 2318 | + $donor->add_address('billing[]', $address); |
|
| 2319 | 2319 | } |
| 2320 | 2320 | |
| 2321 | 2321 | }// End while(). |
@@ -2326,7 +2326,7 @@ discard block |
||
| 2326 | 2326 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
| 2327 | 2327 | |
| 2328 | 2328 | // No more forms found, finish up. |
| 2329 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
| 2329 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
| 2330 | 2330 | } |
| 2331 | 2331 | } |
| 2332 | 2332 | |
@@ -2346,21 +2346,21 @@ discard block |
||
| 2346 | 2346 | SELECT ID FROM $wpdb->posts |
| 2347 | 2347 | WHERE 1=1 |
| 2348 | 2348 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
| 2349 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
| 2349 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
| 2350 | 2350 | ORDER BY $wpdb->posts.post_date ASC |
| 2351 | 2351 | LIMIT 100 |
| 2352 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
| 2352 | + OFFSET ".$give_updates->get_offset(100) |
|
| 2353 | 2353 | ); |
| 2354 | 2354 | |
| 2355 | - if ( ! empty( $payments ) ) { |
|
| 2356 | - $give_updates->set_percentage( give_get_total_post_type_count( array( |
|
| 2355 | + if ( ! empty($payments)) { |
|
| 2356 | + $give_updates->set_percentage(give_get_total_post_type_count(array( |
|
| 2357 | 2357 | 'give_forms', |
| 2358 | 2358 | 'give_payment', |
| 2359 | - ) ), $give_updates->step * 100 ); |
|
| 2359 | + )), $give_updates->step * 100); |
|
| 2360 | 2360 | |
| 2361 | - foreach ( $payments as $payment_id ) { |
|
| 2362 | - $post = get_post( $payment_id ); |
|
| 2363 | - setup_postdata( $post ); |
|
| 2361 | + foreach ($payments as $payment_id) { |
|
| 2362 | + $post = get_post($payment_id); |
|
| 2363 | + setup_postdata($post); |
|
| 2364 | 2364 | |
| 2365 | 2365 | $meta_data = $wpdb->get_results( |
| 2366 | 2366 | $wpdb->prepare( |
@@ -2370,19 +2370,19 @@ discard block |
||
| 2370 | 2370 | ARRAY_A |
| 2371 | 2371 | ); |
| 2372 | 2372 | |
| 2373 | - if ( ! empty( $meta_data ) ) { |
|
| 2374 | - foreach ( $meta_data as $index => $data ) { |
|
| 2373 | + if ( ! empty($meta_data)) { |
|
| 2374 | + foreach ($meta_data as $index => $data) { |
|
| 2375 | 2375 | // Check for duplicate meta values. |
| 2376 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
| 2376 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
| 2377 | 2377 | continue; |
| 2378 | 2378 | } |
| 2379 | 2379 | |
| 2380 | - switch ( $post->post_type ) { |
|
| 2380 | + switch ($post->post_type) { |
|
| 2381 | 2381 | case 'give_forms': |
| 2382 | 2382 | $data['form_id'] = $data['post_id']; |
| 2383 | - unset( $data['post_id'] ); |
|
| 2383 | + unset($data['post_id']); |
|
| 2384 | 2384 | |
| 2385 | - Give()->form_meta->insert( $data ); |
|
| 2385 | + Give()->form_meta->insert($data); |
|
| 2386 | 2386 | // @todo: delete form meta from post meta table after releases 2.0. |
| 2387 | 2387 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
| 2388 | 2388 | |
@@ -2390,9 +2390,9 @@ discard block |
||
| 2390 | 2390 | |
| 2391 | 2391 | case 'give_payment': |
| 2392 | 2392 | $data['payment_id'] = $data['post_id']; |
| 2393 | - unset( $data['post_id'] ); |
|
| 2393 | + unset($data['post_id']); |
|
| 2394 | 2394 | |
| 2395 | - Give()->payment_meta->insert( $data ); |
|
| 2395 | + Give()->payment_meta->insert($data); |
|
| 2396 | 2396 | |
| 2397 | 2397 | // @todo: delete donation meta from post meta table after releases 2.0. |
| 2398 | 2398 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2407,7 +2407,7 @@ discard block |
||
| 2407 | 2407 | wp_reset_postdata(); |
| 2408 | 2408 | } else { |
| 2409 | 2409 | // No more forms found, finish up. |
| 2410 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
| 2410 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | 2413 | } |
@@ -2428,26 +2428,26 @@ discard block |
||
| 2428 | 2428 | SELECT ID FROM $wpdb->posts |
| 2429 | 2429 | WHERE 1=1 |
| 2430 | 2430 | AND $wpdb->posts.post_type = 'give_log' |
| 2431 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
| 2431 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
| 2432 | 2432 | ORDER BY $wpdb->posts.post_date ASC |
| 2433 | 2433 | LIMIT 100 |
| 2434 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
| 2434 | + OFFSET ".$give_updates->get_offset(100) |
|
| 2435 | 2435 | ); |
| 2436 | 2436 | |
| 2437 | - if ( ! empty( $logs ) ) { |
|
| 2438 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
| 2437 | + if ( ! empty($logs)) { |
|
| 2438 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
| 2439 | 2439 | |
| 2440 | - foreach ( $logs as $log_id ) { |
|
| 2441 | - $post = get_post( $log_id ); |
|
| 2442 | - setup_postdata( $post ); |
|
| 2440 | + foreach ($logs as $log_id) { |
|
| 2441 | + $post = get_post($log_id); |
|
| 2442 | + setup_postdata($post); |
|
| 2443 | 2443 | |
| 2444 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
| 2444 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
| 2445 | 2445 | continue; |
| 2446 | 2446 | } |
| 2447 | 2447 | |
| 2448 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
| 2449 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
| 2450 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
| 2448 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
| 2449 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
| 2450 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
| 2451 | 2451 | |
| 2452 | 2452 | $log_data = array( |
| 2453 | 2453 | 'ID' => $post->ID, |
@@ -2460,29 +2460,29 @@ discard block |
||
| 2460 | 2460 | ); |
| 2461 | 2461 | $log_meta = array(); |
| 2462 | 2462 | |
| 2463 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
| 2464 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
| 2465 | - switch ( $meta_key ) { |
|
| 2463 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
| 2464 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
| 2465 | + switch ($meta_key) { |
|
| 2466 | 2466 | case '_give_log_payment_id': |
| 2467 | - $log_data['log_parent'] = current( $meta_value ); |
|
| 2467 | + $log_data['log_parent'] = current($meta_value); |
|
| 2468 | 2468 | $log_meta['_give_log_form_id'] = $post->post_parent; |
| 2469 | 2469 | break; |
| 2470 | 2470 | |
| 2471 | 2471 | default: |
| 2472 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
| 2472 | + $log_meta[$meta_key] = current($meta_value); |
|
| 2473 | 2473 | } |
| 2474 | 2474 | } |
| 2475 | 2475 | } |
| 2476 | 2476 | |
| 2477 | - if ( 'api_request' === $term_name ) { |
|
| 2477 | + if ('api_request' === $term_name) { |
|
| 2478 | 2478 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
| 2479 | 2479 | } |
| 2480 | 2480 | |
| 2481 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
| 2481 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
| 2482 | 2482 | |
| 2483 | - if ( ! empty( $log_meta ) ) { |
|
| 2484 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
| 2485 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
| 2483 | + if ( ! empty($log_meta)) { |
|
| 2484 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
| 2485 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
| 2486 | 2486 | } |
| 2487 | 2487 | } |
| 2488 | 2488 | |
@@ -2495,7 +2495,7 @@ discard block |
||
| 2495 | 2495 | Give()->logs->delete_cache(); |
| 2496 | 2496 | |
| 2497 | 2497 | // No more forms found, finish up. |
| 2498 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
| 2498 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
| 2499 | 2499 | } |
| 2500 | 2500 | } |
| 2501 | 2501 | |
@@ -2510,51 +2510,51 @@ discard block |
||
| 2510 | 2510 | global $wpdb; |
| 2511 | 2511 | give_v201_create_tables(); |
| 2512 | 2512 | |
| 2513 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
| 2514 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
| 2515 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
| 2513 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
| 2514 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
| 2515 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
| 2516 | 2516 | $donor_data = array(); |
| 2517 | 2517 | |
| 2518 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
| 2519 | - foreach ( $missing_donors as $donor_id ) { |
|
| 2518 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
| 2519 | + foreach ($missing_donors as $donor_id) { |
|
| 2520 | 2520 | $donor_data[] = array( |
| 2521 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
| 2522 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
| 2521 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
| 2522 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
| 2523 | 2523 | |
| 2524 | 2524 | ); |
| 2525 | 2525 | } |
| 2526 | 2526 | } |
| 2527 | 2527 | |
| 2528 | - if ( ! empty( $donor_data ) ) { |
|
| 2528 | + if ( ! empty($donor_data)) { |
|
| 2529 | 2529 | $donor_table_name = Give()->donors->table_name; |
| 2530 | 2530 | $donor_meta_table_name = Give()->donor_meta->table_name; |
| 2531 | 2531 | |
| 2532 | 2532 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
| 2533 | 2533 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
| 2534 | 2534 | |
| 2535 | - foreach ( $donor_data as $donor ) { |
|
| 2535 | + foreach ($donor_data as $donor) { |
|
| 2536 | 2536 | $donor['info'][0] = (array) $donor['info'][0]; |
| 2537 | 2537 | |
| 2538 | 2538 | // Prevent duplicate meta id issue. |
| 2539 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
| 2539 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
| 2540 | 2540 | continue; |
| 2541 | 2541 | } |
| 2542 | 2542 | |
| 2543 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
| 2543 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
| 2544 | 2544 | |
| 2545 | - if ( ! empty( $donor['meta'] ) ) { |
|
| 2546 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
| 2545 | + if ( ! empty($donor['meta'])) { |
|
| 2546 | + foreach ($donor['meta'] as $donor_meta) { |
|
| 2547 | 2547 | $donor_meta = (array) $donor_meta; |
| 2548 | 2548 | |
| 2549 | 2549 | // Prevent duplicate meta id issue. |
| 2550 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
| 2551 | - unset( $donor_meta['meta_id'] ); |
|
| 2550 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
| 2551 | + unset($donor_meta['meta_id']); |
|
| 2552 | 2552 | } |
| 2553 | 2553 | |
| 2554 | 2554 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
| 2555 | - unset( $donor_meta['customer_id'] ); |
|
| 2555 | + unset($donor_meta['customer_id']); |
|
| 2556 | 2556 | |
| 2557 | - Give()->donor_meta->insert( $donor_meta ); |
|
| 2557 | + Give()->donor_meta->insert($donor_meta); |
|
| 2558 | 2558 | } |
| 2559 | 2559 | } |
| 2560 | 2560 | |
@@ -2573,35 +2573,35 @@ discard block |
||
| 2573 | 2573 | ) |
| 2574 | 2574 | ); |
| 2575 | 2575 | |
| 2576 | - $donor = new Give_Donor( $donor_id ); |
|
| 2576 | + $donor = new Give_Donor($donor_id); |
|
| 2577 | 2577 | |
| 2578 | - if ( ! empty( $address ) ) { |
|
| 2579 | - $address = maybe_unserialize( $address ); |
|
| 2580 | - $donor->add_address( 'personal', $address ); |
|
| 2581 | - $donor->add_address( 'billing[]', $address ); |
|
| 2578 | + if ( ! empty($address)) { |
|
| 2579 | + $address = maybe_unserialize($address); |
|
| 2580 | + $donor->add_address('personal', $address); |
|
| 2581 | + $donor->add_address('billing[]', $address); |
|
| 2582 | 2582 | } |
| 2583 | 2583 | |
| 2584 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
| 2585 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
| 2586 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
| 2584 | + $donor_name = explode(' ', $donor->name, 2); |
|
| 2585 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
| 2586 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
| 2587 | 2587 | |
| 2588 | 2588 | // If first name meta of donor is not created, then create it. |
| 2589 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
| 2590 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
| 2589 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
| 2590 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | 2593 | // If last name meta of donor is not created, then create it. |
| 2594 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
| 2595 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
| 2594 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
| 2595 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
| 2596 | 2596 | } |
| 2597 | 2597 | |
| 2598 | 2598 | // If Donor is connected with WP User then update user meta. |
| 2599 | - if ( $donor->user_id ) { |
|
| 2600 | - if ( isset( $donor_name[0] ) ) { |
|
| 2601 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
| 2599 | + if ($donor->user_id) { |
|
| 2600 | + if (isset($donor_name[0])) { |
|
| 2601 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
| 2602 | 2602 | } |
| 2603 | - if ( isset( $donor_name[1] ) ) { |
|
| 2604 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
| 2603 | + if (isset($donor_name[1])) { |
|
| 2604 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
| 2605 | 2605 | } |
| 2606 | 2606 | } |
| 2607 | 2607 | } |
@@ -2612,7 +2612,7 @@ discard block |
||
| 2612 | 2612 | } |
| 2613 | 2613 | |
| 2614 | 2614 | Give_Updates::get_instance()->percentage = 100; |
| 2615 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
| 2615 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
| 2616 | 2616 | } |
| 2617 | 2617 | |
| 2618 | 2618 | |
@@ -2625,14 +2625,14 @@ discard block |
||
| 2625 | 2625 | global $wpdb; |
| 2626 | 2626 | |
| 2627 | 2627 | // Do not auto load option. |
| 2628 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
| 2628 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
| 2629 | 2629 | |
| 2630 | 2630 | // Remove from cache. |
| 2631 | 2631 | $all_options = wp_load_alloptions(); |
| 2632 | 2632 | |
| 2633 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
| 2634 | - unset( $all_options['give_completed_upgrades'] ); |
|
| 2635 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
| 2633 | + if (isset($all_options['give_completed_upgrades'])) { |
|
| 2634 | + unset($all_options['give_completed_upgrades']); |
|
| 2635 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
| 2636 | 2636 | } |
| 2637 | 2637 | |
| 2638 | 2638 | } |
@@ -2647,7 +2647,7 @@ discard block |
||
| 2647 | 2647 | $give_updates = Give_Updates::get_instance(); |
| 2648 | 2648 | |
| 2649 | 2649 | // form query. |
| 2650 | - $donation_forms = new WP_Query( array( |
|
| 2650 | + $donation_forms = new WP_Query(array( |
|
| 2651 | 2651 | 'paged' => $give_updates->step, |
| 2652 | 2652 | 'status' => 'any', |
| 2653 | 2653 | 'order' => 'ASC', |
@@ -2656,16 +2656,16 @@ discard block |
||
| 2656 | 2656 | ) |
| 2657 | 2657 | ); |
| 2658 | 2658 | |
| 2659 | - if ( $donation_forms->have_posts() ) { |
|
| 2660 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 2659 | + if ($donation_forms->have_posts()) { |
|
| 2660 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 2661 | 2661 | |
| 2662 | - while ( $donation_forms->have_posts() ) { |
|
| 2662 | + while ($donation_forms->have_posts()) { |
|
| 2663 | 2663 | $donation_forms->the_post(); |
| 2664 | 2664 | $form_id = get_the_ID(); |
| 2665 | 2665 | |
| 2666 | - $form_closed_status = give_get_meta( $form_id, '_give_form_status', true ); |
|
| 2667 | - if ( empty( $form_closed_status ) ) { |
|
| 2668 | - give_set_form_closed_status( $form_id ); |
|
| 2666 | + $form_closed_status = give_get_meta($form_id, '_give_form_status', true); |
|
| 2667 | + if (empty($form_closed_status)) { |
|
| 2668 | + give_set_form_closed_status($form_id); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | } |
| 2671 | 2671 | |
@@ -2675,7 +2675,7 @@ discard block |
||
| 2675 | 2675 | } else { |
| 2676 | 2676 | |
| 2677 | 2677 | // The Update Ran. |
| 2678 | - give_set_upgrade_complete( 'v210_verify_form_status_upgrades' ); |
|
| 2678 | + give_set_upgrade_complete('v210_verify_form_status_upgrades'); |
|
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | 2681 | } |
@@ -2695,22 +2695,22 @@ discard block |
||
| 2695 | 2695 | SELECT DISTINCT payment_id |
| 2696 | 2696 | FROM {$donation_meta_table} |
| 2697 | 2697 | LIMIT 20 |
| 2698 | - OFFSET {$give_updates->get_offset( 20 )} |
|
| 2698 | + OFFSET {$give_updates->get_offset(20)} |
|
| 2699 | 2699 | " |
| 2700 | 2700 | ); |
| 2701 | 2701 | |
| 2702 | - if ( ! empty( $donations ) ) { |
|
| 2703 | - foreach ( $donations as $donation ) { |
|
| 2704 | - $donation_obj = get_post( $donation ); |
|
| 2702 | + if ( ! empty($donations)) { |
|
| 2703 | + foreach ($donations as $donation) { |
|
| 2704 | + $donation_obj = get_post($donation); |
|
| 2705 | 2705 | |
| 2706 | - if ( ! $donation_obj instanceof WP_Post ) { |
|
| 2707 | - Give()->payment_meta->delete_all_meta( $donation ); |
|
| 2706 | + if ( ! $donation_obj instanceof WP_Post) { |
|
| 2707 | + Give()->payment_meta->delete_all_meta($donation); |
|
| 2708 | 2708 | } |
| 2709 | 2709 | } |
| 2710 | 2710 | } else { |
| 2711 | 2711 | |
| 2712 | 2712 | // The Update Ran. |
| 2713 | - give_set_upgrade_complete( 'v213_delete_donation_meta' ); |
|
| 2713 | + give_set_upgrade_complete('v213_delete_donation_meta'); |
|
| 2714 | 2714 | } |
| 2715 | 2715 | |
| 2716 | 2716 | } |
@@ -2722,8 +2722,8 @@ discard block |
||
| 2722 | 2722 | */ |
| 2723 | 2723 | function give_v215_update_donor_user_roles_callback() { |
| 2724 | 2724 | |
| 2725 | - $role = get_role( 'give_manager' ); |
|
| 2726 | - $role->add_cap( 'view_give_payments' ); |
|
| 2725 | + $role = get_role('give_manager'); |
|
| 2726 | + $role->add_cap('view_give_payments'); |
|
| 2727 | 2727 | |
| 2728 | - give_set_upgrade_complete( 'v215_update_donor_user_roles' ); |
|
| 2728 | + give_set_upgrade_complete('v215_update_donor_user_roles'); |
|
| 2729 | 2729 | } |
@@ -80,34 +80,34 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @param array $args |
| 82 | 82 | */ |
| 83 | - public function register( $args ) { |
|
| 83 | + public function register($args) { |
|
| 84 | 84 | $args_default = array( |
| 85 | 85 | 'id' => '', |
| 86 | 86 | 'version' => '', |
| 87 | 87 | 'callback' => '', |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - $args = wp_parse_args( $args, $args_default ); |
|
| 90 | + $args = wp_parse_args($args, $args_default); |
|
| 91 | 91 | |
| 92 | 92 | // You can only register database upgrade. |
| 93 | 93 | $args['type'] = 'database'; |
| 94 | 94 | |
| 95 | 95 | // Bailout. |
| 96 | 96 | if ( |
| 97 | - empty( $args['id'] ) || |
|
| 98 | - empty( $args['version'] ) || |
|
| 99 | - empty( $args['callback'] ) || |
|
| 100 | - ! is_callable( $args['callback'] ) |
|
| 97 | + empty($args['id']) || |
|
| 98 | + empty($args['version']) || |
|
| 99 | + empty($args['callback']) || |
|
| 100 | + ! is_callable($args['callback']) |
|
| 101 | 101 | ) { |
| 102 | 102 | return; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Change depend param to array. |
| 106 | - if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) { |
|
| 107 | - $args['depend'] = array( $args['depend'] ); |
|
| 106 | + if (isset($args['depend']) && is_string($args['depend'])) { |
|
| 107 | + $args['depend'] = array($args['depend']); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $this->updates[ $args['type'] ][] = $args; |
|
| 110 | + $this->updates[$args['type']][] = $args; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @return static |
| 119 | 119 | */ |
| 120 | 120 | static function get_instance() { |
| 121 | - if ( is_null( self::$instance ) ) { |
|
| 121 | + if (is_null(self::$instance)) { |
|
| 122 | 122 | self::$instance = new self(); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -136,27 +136,27 @@ discard block |
||
| 136 | 136 | /** |
| 137 | 137 | * Load file |
| 138 | 138 | */ |
| 139 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php'; |
|
| 140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 139 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php'; |
|
| 140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 141 | 141 | |
| 142 | 142 | self::$background_updater = new Give_Background_Updater(); |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Setup hooks. |
| 146 | 146 | */ |
| 147 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
| 148 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
| 149 | - add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) ); |
|
| 150 | - add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) ); |
|
| 151 | - add_action( 'admin_init', array( $this, '__redirect_admin' ) ); |
|
| 152 | - add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 ); |
|
| 153 | - add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 ); |
|
| 154 | - add_action( 'admin_notices', array( $this, '__show_notice' ) ); |
|
| 155 | - add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) ); |
|
| 156 | - |
|
| 157 | - if ( is_admin() ) { |
|
| 158 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
| 159 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
| 147 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
| 148 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
| 149 | + add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info')); |
|
| 150 | + add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating')); |
|
| 151 | + add_action('admin_init', array($this, '__redirect_admin')); |
|
| 152 | + add_action('admin_init', array($this, '__pause_db_update'), - 1); |
|
| 153 | + add_action('admin_init', array($this, '__restart_db_update'), - 1); |
|
| 154 | + add_action('admin_notices', array($this, '__show_notice')); |
|
| 155 | + add_action('give_restart_db_upgrade', array($this, '__health_background_update')); |
|
| 156 | + |
|
| 157 | + if (is_admin()) { |
|
| 158 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
| 159 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | $addons = give_get_plugins(); |
| 171 | 171 | $plugin_updates = get_plugin_updates(); |
| 172 | 172 | |
| 173 | - foreach ( $addons as $key => $info ) { |
|
| 174 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
| 173 | + foreach ($addons as $key => $info) { |
|
| 174 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
| 175 | 175 | continue; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
| 178 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @access public |
| 188 | 188 | */ |
| 189 | 189 | public function __register_upgrade() { |
| 190 | - if ( ! is_admin() ) { |
|
| 190 | + if ( ! is_admin()) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @since 1.8.12 |
| 198 | 198 | */ |
| 199 | - do_action( 'give_register_updates', $this ); |
|
| 199 | + do_action('give_register_updates', $this); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -209,23 +209,22 @@ discard block |
||
| 209 | 209 | global $menu; |
| 210 | 210 | |
| 211 | 211 | // Bailout. |
| 212 | - if ( empty( $menu ) || ! $this->get_total_update_count() ) { |
|
| 212 | + if (empty($menu) || ! $this->get_total_update_count()) { |
|
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
| 216 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
| 217 | 217 | |
| 218 | - foreach ( $menu as $index => $menu_item ) { |
|
| 219 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
| 218 | + foreach ($menu as $index => $menu_item) { |
|
| 219 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
| 220 | 220 | continue; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $menu[ $index ][0] = sprintf( |
|
| 223 | + $menu[$index][0] = sprintf( |
|
| 224 | 224 | '%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>', |
| 225 | - __( 'Donations', 'give' ), |
|
| 225 | + __('Donations', 'give'), |
|
| 226 | 226 | $is_update ? |
| 227 | - $this->get_db_update_processing_percentage() : |
|
| 228 | - $this->get_total_update_count(), |
|
| 227 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
| 229 | 228 | $is_update ? '%' : '' |
| 230 | 229 | ); |
| 231 | 230 | |
@@ -244,41 +243,40 @@ discard block |
||
| 244 | 243 | $this->__register_plugin_addon_updates(); |
| 245 | 244 | |
| 246 | 245 | // Bailout. |
| 247 | - if ( ! $this->get_total_update_count() ) { |
|
| 246 | + if ( ! $this->get_total_update_count()) { |
|
| 248 | 247 | // Show complete update message if still on update setting page. |
| 249 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
| 248 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
| 250 | 249 | // Upgrades |
| 251 | 250 | add_submenu_page( |
| 252 | 251 | 'edit.php?post_type=give_forms', |
| 253 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
| 254 | - __( 'Updates', 'give' ), |
|
| 252 | + esc_html__('Give Updates Complete', 'give'), |
|
| 253 | + __('Updates', 'give'), |
|
| 255 | 254 | 'manage_give_settings', |
| 256 | 255 | 'give-updates', |
| 257 | - array( $this, 'render_complete_page' ) |
|
| 256 | + array($this, 'render_complete_page') |
|
| 258 | 257 | ); |
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 260 | return; |
| 262 | 261 | } |
| 263 | 262 | |
| 264 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
| 263 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
| 265 | 264 | |
| 266 | 265 | // Upgrades |
| 267 | 266 | add_submenu_page( |
| 268 | 267 | 'edit.php?post_type=give_forms', |
| 269 | - esc_html__( 'Give Updates', 'give' ), |
|
| 268 | + esc_html__('Give Updates', 'give'), |
|
| 270 | 269 | sprintf( |
| 271 | 270 | '%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>', |
| 272 | - __( 'Updates', 'give' ), |
|
| 273 | - isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '', |
|
| 271 | + __('Updates', 'give'), |
|
| 272 | + isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '', |
|
| 274 | 273 | $is_update ? |
| 275 | - $this->get_db_update_processing_percentage() : |
|
| 276 | - $this->get_total_update_count(), |
|
| 274 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
| 277 | 275 | $is_update ? '%' : '' |
| 278 | 276 | ), |
| 279 | 277 | 'manage_give_settings', |
| 280 | 278 | 'give-updates', |
| 281 | - array( $this, 'render_page' ) |
|
| 279 | + array($this, 'render_page') |
|
| 282 | 280 | ); |
| 283 | 281 | } |
| 284 | 282 | |
@@ -293,13 +291,13 @@ discard block |
||
| 293 | 291 | // Show db upgrade completed notice. |
| 294 | 292 | if ( |
| 295 | 293 | ! wp_doing_ajax() && |
| 296 | - current_user_can( 'manage_give_settings' ) && |
|
| 297 | - get_option( 'give_show_db_upgrade_complete_notice' ) && |
|
| 298 | - ! isset( $_GET['give-db-update-completed'] ) |
|
| 294 | + current_user_can('manage_give_settings') && |
|
| 295 | + get_option('give_show_db_upgrade_complete_notice') && |
|
| 296 | + ! isset($_GET['give-db-update-completed']) |
|
| 299 | 297 | ) { |
| 300 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
| 298 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
| 301 | 299 | |
| 302 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-updates&give-db-update-completed=give_db_upgrade_completed' ) ); |
|
| 300 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-updates&give-db-update-completed=give_db_upgrade_completed')); |
|
| 303 | 301 | exit(); |
| 304 | 302 | } |
| 305 | 303 | } |
@@ -315,15 +313,15 @@ discard block |
||
| 315 | 313 | * |
| 316 | 314 | * @return bool |
| 317 | 315 | */ |
| 318 | - public function __pause_db_update( $force = false ) { |
|
| 316 | + public function __pause_db_update($force = false) { |
|
| 319 | 317 | // Bailout. |
| 320 | 318 | if ( |
| 321 | 319 | ! $force && |
| 322 | 320 | ( |
| 323 | 321 | wp_doing_ajax() || |
| 324 | - ! isset( $_GET['page'] ) || |
|
| 322 | + ! isset($_GET['page']) || |
|
| 325 | 323 | 'give-updates' !== $_GET['page'] || |
| 326 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
| 324 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
| 327 | 325 | self::$background_updater->is_paused_process() |
| 328 | 326 | ) |
| 329 | 327 | |
@@ -331,13 +329,13 @@ discard block |
||
| 331 | 329 | return false; |
| 332 | 330 | } |
| 333 | 331 | |
| 334 | - delete_option( 'give_upgrade_error' ); |
|
| 332 | + delete_option('give_upgrade_error'); |
|
| 335 | 333 | |
| 336 | - $this->__health_background_update( $this ); |
|
| 334 | + $this->__health_background_update($this); |
|
| 337 | 335 | $batch = self::$background_updater->get_all_batch(); |
| 338 | 336 | |
| 339 | 337 | // Bailout: if batch is empty |
| 340 | - if ( empty( $batch->data ) ) { |
|
| 338 | + if (empty($batch->data)) { |
|
| 341 | 339 | return false; |
| 342 | 340 | } |
| 343 | 341 | |
@@ -346,25 +344,25 @@ discard block |
||
| 346 | 344 | |
| 347 | 345 | // Do not stop background process immediately if task running. |
| 348 | 346 | // @see Give_Background_Updater::lock_process |
| 349 | - if ( ! $force && self::$background_updater->is_process_running() ) { |
|
| 350 | - update_option( 'give_pause_upgrade', 1 ); |
|
| 347 | + if ( ! $force && self::$background_updater->is_process_running()) { |
|
| 348 | + update_option('give_pause_upgrade', 1); |
|
| 351 | 349 | |
| 352 | 350 | return true; |
| 353 | 351 | } |
| 354 | 352 | |
| 355 | - update_option( 'give_paused_batches', $batch, 'no' ); |
|
| 356 | - delete_option( $batch->key ); |
|
| 357 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
| 358 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
| 353 | + update_option('give_paused_batches', $batch, 'no'); |
|
| 354 | + delete_option($batch->key); |
|
| 355 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
| 356 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
| 359 | 357 | |
| 360 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
| 358 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
| 361 | 359 | |
| 362 | 360 | /** |
| 363 | 361 | * Fire action when pause db updates |
| 364 | 362 | * |
| 365 | 363 | * @since 2.0.1 |
| 366 | 364 | */ |
| 367 | - do_action( 'give_pause_db_upgrade', $this ); |
|
| 365 | + do_action('give_pause_db_upgrade', $this); |
|
| 368 | 366 | |
| 369 | 367 | return true; |
| 370 | 368 | } |
@@ -381,31 +379,31 @@ discard block |
||
| 381 | 379 | // Bailout. |
| 382 | 380 | if ( |
| 383 | 381 | wp_doing_ajax() || |
| 384 | - ! isset( $_GET['page'] ) || |
|
| 382 | + ! isset($_GET['page']) || |
|
| 385 | 383 | 'give-updates' !== $_GET['page'] || |
| 386 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
| 384 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
| 387 | 385 | ! self::$background_updater->is_paused_process() |
| 388 | 386 | ) { |
| 389 | 387 | return false; |
| 390 | 388 | } |
| 391 | 389 | |
| 392 | 390 | Give_Background_Updater::flush_cache(); |
| 393 | - $batch = get_option( 'give_paused_batches' ); |
|
| 391 | + $batch = get_option('give_paused_batches'); |
|
| 394 | 392 | |
| 395 | - if ( ! empty( $batch ) ) { |
|
| 396 | - wp_cache_delete( $batch->key, 'options' ); |
|
| 397 | - update_option( $batch->key, $batch->data ); |
|
| 393 | + if ( ! empty($batch)) { |
|
| 394 | + wp_cache_delete($batch->key, 'options'); |
|
| 395 | + update_option($batch->key, $batch->data); |
|
| 398 | 396 | |
| 399 | - delete_option( 'give_paused_batches' ); |
|
| 397 | + delete_option('give_paused_batches'); |
|
| 400 | 398 | |
| 401 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
| 399 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
| 402 | 400 | |
| 403 | 401 | |
| 404 | 402 | /** Fire action when restart db updates |
| 405 | 403 | * |
| 406 | 404 | * @since 2.0.1 |
| 407 | 405 | */ |
| 408 | - do_action( 'give_restart_db_upgrade', $this ); |
|
| 406 | + do_action('give_restart_db_upgrade', $this); |
|
| 409 | 407 | |
| 410 | 408 | self::$background_updater->dispatch(); |
| 411 | 409 | } |
@@ -421,53 +419,53 @@ discard block |
||
| 421 | 419 | * |
| 422 | 420 | * @param Give_Updates $give_updates |
| 423 | 421 | */ |
| 424 | - public function __health_background_update( $give_updates ) { |
|
| 425 | - if ( ! $this->is_doing_updates() ) { |
|
| 422 | + public function __health_background_update($give_updates) { |
|
| 423 | + if ( ! $this->is_doing_updates()) { |
|
| 426 | 424 | return; |
| 427 | 425 | } |
| 428 | 426 | |
| 429 | 427 | Give_Background_Updater::flush_cache(); |
| 430 | 428 | |
| 431 | 429 | $batch = Give_Updates::$background_updater->get_all_batch(); |
| 432 | - $batch_data_count = count( $batch->data ); |
|
| 433 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
| 434 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
| 435 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
| 430 | + $batch_data_count = count($batch->data); |
|
| 431 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
| 432 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
| 433 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
| 436 | 434 | $log_data = ''; |
| 437 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
| 435 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
| 438 | 436 | |
| 439 | - if ( ! empty( $doing_upgrade_args ) ) { |
|
| 440 | - $log_data .= 'Doing update:' . "\n"; |
|
| 441 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
| 437 | + if ( ! empty($doing_upgrade_args)) { |
|
| 438 | + $log_data .= 'Doing update:'."\n"; |
|
| 439 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
| 442 | 440 | } |
| 443 | 441 | |
| 444 | 442 | /** |
| 445 | 443 | * Add remove upgrade from batch |
| 446 | 444 | */ |
| 447 | - if ( ! empty( $batch->data ) ) { |
|
| 445 | + if ( ! empty($batch->data)) { |
|
| 448 | 446 | |
| 449 | - foreach ( $batch->data as $index => $update ) { |
|
| 450 | - $log_data = print_r( $update, true ) . "\n"; |
|
| 447 | + foreach ($batch->data as $index => $update) { |
|
| 448 | + $log_data = print_r($update, true)."\n"; |
|
| 451 | 449 | |
| 452 | - if ( ! is_callable( $update['callback'] ) ) { |
|
| 453 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
| 454 | - unset( $batch->data[ $index ] ); |
|
| 455 | - } elseif ( give_has_upgrade_completed( $update['id'] ) ) { |
|
| 456 | - $log_data .= 'Removing already completed update: ' . "{$update['id']}\n"; |
|
| 457 | - unset( $batch->data[ $index ] ); |
|
| 450 | + if ( ! is_callable($update['callback'])) { |
|
| 451 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
| 452 | + unset($batch->data[$index]); |
|
| 453 | + } elseif (give_has_upgrade_completed($update['id'])) { |
|
| 454 | + $log_data .= 'Removing already completed update: '."{$update['id']}\n"; |
|
| 455 | + unset($batch->data[$index]); |
|
| 458 | 456 | } |
| 459 | 457 | |
| 460 | - if ( ! empty( $update['depend'] ) ) { |
|
| 458 | + if ( ! empty($update['depend'])) { |
|
| 461 | 459 | |
| 462 | - foreach ( $update['depend'] as $depend ) { |
|
| 463 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
| 464 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
| 460 | + foreach ($update['depend'] as $depend) { |
|
| 461 | + if (give_has_upgrade_completed($depend)) { |
|
| 462 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
| 465 | 463 | continue; |
| 466 | 464 | } |
| 467 | 465 | |
| 468 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
| 469 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
| 470 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
| 466 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
| 467 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
| 468 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
| 471 | 469 | } |
| 472 | 470 | } |
| 473 | 471 | } |
@@ -477,52 +475,52 @@ discard block |
||
| 477 | 475 | /** |
| 478 | 476 | * Add new upgrade to batch |
| 479 | 477 | */ |
| 480 | - if ( $new_updates = $this->get_updates( 'database', 'new' ) ) { |
|
| 481 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
| 478 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
| 479 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
| 482 | 480 | |
| 483 | - foreach ( $new_updates as $index => $new_update ) { |
|
| 484 | - if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
| 485 | - unset( $new_updates[ $index ] ); |
|
| 481 | + foreach ($new_updates as $index => $new_update) { |
|
| 482 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
| 483 | + unset($new_updates[$index]); |
|
| 486 | 484 | } |
| 487 | 485 | } |
| 488 | 486 | |
| 489 | - if ( ! empty( $new_updates ) ) { |
|
| 490 | - $log_data .= 'Adding new update: ' . "\n"; |
|
| 491 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
| 487 | + if ( ! empty($new_updates)) { |
|
| 488 | + $log_data .= 'Adding new update: '."\n"; |
|
| 489 | + $log_data .= print_r($new_updates, true)."\n"; |
|
| 492 | 490 | |
| 493 | - $batch->data = array_merge( (array) $batch->data, $new_updates ); |
|
| 494 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) ); |
|
| 491 | + $batch->data = array_merge((array) $batch->data, $new_updates); |
|
| 492 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates))); |
|
| 495 | 493 | } |
| 496 | 494 | } |
| 497 | 495 | |
| 498 | 496 | /** |
| 499 | 497 | * Fix batch |
| 500 | 498 | */ |
| 501 | - if ( empty( $batch->data ) ) { |
|
| 499 | + if (empty($batch->data)) { |
|
| 502 | 500 | // Complete batch if do not have any data to process. |
| 503 | - self::$background_updater->delete( $batch->key ); |
|
| 501 | + self::$background_updater->delete($batch->key); |
|
| 504 | 502 | |
| 505 | - if ( self::$background_updater->has_queue() ) { |
|
| 506 | - $this->__health_background_update( $this ); |
|
| 503 | + if (self::$background_updater->has_queue()) { |
|
| 504 | + $this->__health_background_update($this); |
|
| 507 | 505 | } else { |
| 508 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
| 509 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
| 506 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
| 507 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
| 510 | 508 | |
| 511 | 509 | self::$background_updater->complete(); |
| 512 | 510 | } |
| 513 | 511 | |
| 514 | - } elseif ( $batch_data_count !== count( $batch->data ) ) { |
|
| 512 | + } elseif ($batch_data_count !== count($batch->data)) { |
|
| 515 | 513 | |
| 516 | - $log_data .= 'Updating batch' . "\n"; |
|
| 517 | - $log_data .= print_r( $batch, true ); |
|
| 514 | + $log_data .= 'Updating batch'."\n"; |
|
| 515 | + $log_data .= print_r($batch, true); |
|
| 518 | 516 | |
| 519 | - if ( ! empty( $batch->key ) ) { |
|
| 520 | - wp_cache_delete( $batch->key, 'options' ); |
|
| 521 | - update_option( $batch->key, $batch->data ); |
|
| 517 | + if ( ! empty($batch->key)) { |
|
| 518 | + wp_cache_delete($batch->key, 'options'); |
|
| 519 | + update_option($batch->key, $batch->data); |
|
| 522 | 520 | } else { |
| 523 | 521 | |
| 524 | - foreach ( $batch->data as $data ) { |
|
| 525 | - Give_Updates::$background_updater->push_to_queue( $data ); |
|
| 522 | + foreach ($batch->data as $data) { |
|
| 523 | + Give_Updates::$background_updater->push_to_queue($data); |
|
| 526 | 524 | } |
| 527 | 525 | |
| 528 | 526 | Give_Updates::$background_updater->save(); |
@@ -533,31 +531,31 @@ discard block |
||
| 533 | 531 | /** |
| 534 | 532 | * Fix give_doing_upgrade option |
| 535 | 533 | */ |
| 536 | - if( $fresh_new_db_count = $this->get_total_new_db_update_count( true ) ) { |
|
| 537 | - update_option( 'give_db_update_count', $fresh_new_db_count ); |
|
| 534 | + if ($fresh_new_db_count = $this->get_total_new_db_update_count(true)) { |
|
| 535 | + update_option('give_db_update_count', $fresh_new_db_count); |
|
| 538 | 536 | } |
| 539 | 537 | |
| 540 | 538 | $doing_upgrade_args['update'] = 1; |
| 541 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count ); |
|
| 542 | - $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true ); |
|
| 539 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count); |
|
| 540 | + $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true); |
|
| 543 | 541 | |
| 544 | 542 | // Remove already completed update from info. |
| 545 | 543 | if ( |
| 546 | - empty( $doing_upgrade_args['update_info'] ) |
|
| 547 | - || give_has_upgrade_completed( $doing_upgrade_args['update_info']['id'] ) |
|
| 544 | + empty($doing_upgrade_args['update_info']) |
|
| 545 | + || give_has_upgrade_completed($doing_upgrade_args['update_info']['id']) |
|
| 548 | 546 | ) { |
| 549 | - $doing_upgrade_args['update_info'] = current( array_values( $batch->data ) ); |
|
| 547 | + $doing_upgrade_args['update_info'] = current(array_values($batch->data)); |
|
| 550 | 548 | $doing_upgrade_args['step'] = 1; |
| 551 | 549 | } |
| 552 | 550 | |
| 553 | 551 | // Check if dependency completed or not. |
| 554 | - if ( isset( $doing_upgrade_args['update_info']['depend'] ) ) { |
|
| 555 | - foreach ( $doing_upgrade_args['update_info']['depend'] as $depend ) { |
|
| 556 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
| 552 | + if (isset($doing_upgrade_args['update_info']['depend'])) { |
|
| 553 | + foreach ($doing_upgrade_args['update_info']['depend'] as $depend) { |
|
| 554 | + if (give_has_upgrade_completed($depend)) { |
|
| 557 | 555 | continue; |
| 558 | 556 | } |
| 559 | 557 | |
| 560 | - $doing_upgrade_args['update_info'] = $all_updates[ array_search( $depend, $all_update_ids ) ]; |
|
| 558 | + $doing_upgrade_args['update_info'] = $all_updates[array_search($depend, $all_update_ids)]; |
|
| 561 | 559 | $doing_upgrade_args['step'] = 1; |
| 562 | 560 | $doing_upgrade_args['percentage'] = 0; |
| 563 | 561 | $doing_upgrade_args['total_percentage'] = 0; |
@@ -566,14 +564,14 @@ discard block |
||
| 566 | 564 | } |
| 567 | 565 | } |
| 568 | 566 | |
| 569 | - if( ! empty( $doing_upgrade_args['update_info'] ) ) { |
|
| 570 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
| 567 | + if ( ! empty($doing_upgrade_args['update_info'])) { |
|
| 568 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
| 571 | 569 | |
| 572 | - $log_data .= 'Updated doing update:' . "\n"; |
|
| 573 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
| 570 | + $log_data .= 'Updated doing update:'."\n"; |
|
| 571 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
| 574 | 572 | } |
| 575 | 573 | |
| 576 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
| 574 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
| 577 | 575 | } |
| 578 | 576 | |
| 579 | 577 | |
@@ -587,66 +585,66 @@ discard block |
||
| 587 | 585 | $current_screen = get_current_screen(); |
| 588 | 586 | |
| 589 | 587 | // Bailout. |
| 590 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 588 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 591 | 589 | return; |
| 592 | 590 | } |
| 593 | 591 | |
| 594 | 592 | // Run DB updates. |
| 595 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
| 593 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
| 596 | 594 | $this->run_db_update(); |
| 597 | 595 | } |
| 598 | 596 | |
| 599 | 597 | |
| 600 | 598 | // Bailout. |
| 601 | - if ( in_array( $current_screen->base, array( 'give_forms_page_give-updates', 'update-core' ) ) ) { |
|
| 599 | + if (in_array($current_screen->base, array('give_forms_page_give-updates', 'update-core'))) { |
|
| 602 | 600 | return; |
| 603 | 601 | } |
| 604 | 602 | |
| 605 | 603 | // Show notice if upgrade paused. |
| 606 | - if ( self::$background_updater->is_paused_process() ) { |
|
| 604 | + if (self::$background_updater->is_paused_process()) { |
|
| 607 | 605 | ob_start(); |
| 608 | 606 | |
| 609 | - $upgrade_error = get_option( 'give_upgrade_error' ); |
|
| 610 | - if ( ! $upgrade_error ) : ?> |
|
| 611 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 612 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?> |
|
| 607 | + $upgrade_error = get_option('give_upgrade_error'); |
|
| 608 | + if ( ! $upgrade_error) : ?> |
|
| 609 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 610 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?> |
|
| 613 | 611 | <br> |
| 614 | 612 | <br> |
| 615 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
|
| 616 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
| 613 | + <a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn"> |
|
| 614 | + <?php _e('Restart the updater', 'give'); ?> |
|
| 617 | 615 | </a> |
| 618 | 616 | <?php else: ?> |
| 619 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 620 | - – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
| 621 | - <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e( 'Read More', 'give' ); ?> »</a> |
|
| 617 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 618 | + – <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
| 619 | + <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e('Read More', 'give'); ?> »</a> |
|
| 622 | 620 | <?php |
| 623 | 621 | endif; |
| 624 | 622 | $desc_html = ob_get_clean(); |
| 625 | 623 | |
| 626 | - Give()->notices->register_notice( array( |
|
| 624 | + Give()->notices->register_notice(array( |
|
| 627 | 625 | 'id' => 'give_upgrade_db', |
| 628 | 626 | 'type' => 'error', |
| 629 | 627 | 'dismissible' => false, |
| 630 | 628 | 'description' => $desc_html, |
| 631 | - ) ); |
|
| 629 | + )); |
|
| 632 | 630 | } |
| 633 | 631 | |
| 634 | 632 | // Bailout if doing upgrades. |
| 635 | - if ( $this->is_doing_updates() ) { |
|
| 633 | + if ($this->is_doing_updates()) { |
|
| 636 | 634 | return; |
| 637 | 635 | } |
| 638 | 636 | |
| 639 | 637 | // Show notice if ajax is not working. |
| 640 | - if ( ! give_test_ajax_works() ) { |
|
| 638 | + if ( ! give_test_ajax_works()) { |
|
| 641 | 639 | Give()->notices->register_notice( |
| 642 | 640 | array( |
| 643 | 641 | 'id' => 'give_db_upgrade_ajax_inaccessible', |
| 644 | 642 | 'type' => 'error', |
| 645 | 643 | 'description' => sprintf( |
| 646 | 644 | '%1$s <a href="%2$s" target="_blank">%3$s</a>', |
| 647 | - __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), |
|
| 648 | - esc_url( 'http://docs.givewp.com/troubleshooting-db-updates' ), |
|
| 649 | - __( 'Read More', 'give' ) . ' »' |
|
| 645 | + __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), |
|
| 646 | + esc_url('http://docs.givewp.com/troubleshooting-db-updates'), |
|
| 647 | + __('Read More', 'give').' »' |
|
| 650 | 648 | ), |
| 651 | 649 | 'show' => true, |
| 652 | 650 | ) |
@@ -656,40 +654,40 @@ discard block |
||
| 656 | 654 | } |
| 657 | 655 | |
| 658 | 656 | // Show db upgrade completed notice. |
| 659 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
| 660 | - Give()->notices->register_notice( array( |
|
| 657 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
| 658 | + Give()->notices->register_notice(array( |
|
| 661 | 659 | 'id' => 'give_db_upgrade_completed', |
| 662 | 660 | 'type' => 'updated', |
| 663 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
| 661 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
| 664 | 662 | 'show' => true, |
| 665 | - ) ); |
|
| 663 | + )); |
|
| 666 | 664 | |
| 667 | 665 | // Start update. |
| 668 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
| 666 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
| 669 | 667 | $this->run_db_update(); |
| 670 | 668 | |
| 671 | 669 | // Show run the update notice. |
| 672 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
| 670 | + } elseif ($this->get_total_new_db_update_count()) { |
|
| 673 | 671 | ob_start(); |
| 674 | 672 | ?> |
| 675 | 673 | <p> |
| 676 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 677 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?> |
|
| 674 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 675 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?> |
|
| 678 | 676 | </p> |
| 679 | 677 | <p class="submit"> |
| 680 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now"> |
|
| 681 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
| 678 | + <a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now"> |
|
| 679 | + <?php _e('Run the updater', 'give'); ?> |
|
| 682 | 680 | </a> |
| 683 | 681 | </p> |
| 684 | 682 | <?php |
| 685 | 683 | $desc_html = ob_get_clean(); |
| 686 | 684 | |
| 687 | - Give()->notices->register_notice( array( |
|
| 685 | + Give()->notices->register_notice(array( |
|
| 688 | 686 | 'id' => 'give_upgrade_db', |
| 689 | 687 | 'type' => 'updated', |
| 690 | 688 | 'dismissible' => false, |
| 691 | 689 | 'description' => $desc_html, |
| 692 | - ) ); |
|
| 690 | + )); |
|
| 693 | 691 | } |
| 694 | 692 | } |
| 695 | 693 | |
@@ -700,7 +698,7 @@ discard block |
||
| 700 | 698 | * @access public |
| 701 | 699 | */ |
| 702 | 700 | public function render_complete_page() { |
| 703 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
| 701 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
| 704 | 702 | } |
| 705 | 703 | |
| 706 | 704 | /** |
@@ -710,7 +708,7 @@ discard block |
||
| 710 | 708 | * @access public |
| 711 | 709 | */ |
| 712 | 710 | public function render_page() { |
| 713 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
| 711 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
| 714 | 712 | } |
| 715 | 713 | |
| 716 | 714 | /** |
@@ -721,26 +719,26 @@ discard block |
||
| 721 | 719 | */ |
| 722 | 720 | private function run_db_update() { |
| 723 | 721 | // Bailout. |
| 724 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
| 722 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
| 725 | 723 | return; |
| 726 | 724 | } |
| 727 | 725 | |
| 728 | - $updates = $this->get_updates( 'database', 'new' ); |
|
| 726 | + $updates = $this->get_updates('database', 'new'); |
|
| 729 | 727 | |
| 730 | - foreach ( $updates as $update ) { |
|
| 731 | - self::$background_updater->push_to_queue( $update ); |
|
| 728 | + foreach ($updates as $update) { |
|
| 729 | + self::$background_updater->push_to_queue($update); |
|
| 732 | 730 | } |
| 733 | 731 | |
| 734 | - add_option( 'give_db_update_count', count( $updates ), '', 'no' ); |
|
| 732 | + add_option('give_db_update_count', count($updates), '', 'no'); |
|
| 735 | 733 | |
| 736 | - add_option( 'give_doing_upgrade', array( |
|
| 734 | + add_option('give_doing_upgrade', array( |
|
| 737 | 735 | 'update_info' => $updates[0], |
| 738 | 736 | 'step' => 1, |
| 739 | 737 | 'update' => 1, |
| 740 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
| 738 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
| 741 | 739 | 'percentage' => 0, |
| 742 | 740 | 'total_percentage' => 0, |
| 743 | - ), '', 'no' ); |
|
| 741 | + ), '', 'no'); |
|
| 744 | 742 | |
| 745 | 743 | self::$background_updater->save()->dispatch(); |
| 746 | 744 | } |
@@ -754,14 +752,13 @@ discard block |
||
| 754 | 752 | */ |
| 755 | 753 | public function __flush_resume_updates() { |
| 756 | 754 | //delete_option( 'give_doing_upgrade' ); |
| 757 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 755 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 758 | 756 | |
| 759 | 757 | // Reset counter. |
| 760 | 758 | $this->step = $this->percentage = 0; |
| 761 | 759 | |
| 762 | - $this->update = ( $this->get_total_db_update_count() > $this->update ) ? |
|
| 763 | - ( $this->update + 1 ) : |
|
| 764 | - $this->update; |
|
| 760 | + $this->update = ($this->get_total_db_update_count() > $this->update) ? |
|
| 761 | + ($this->update + 1) : $this->update; |
|
| 765 | 762 | } |
| 766 | 763 | |
| 767 | 764 | |
@@ -776,7 +773,7 @@ discard block |
||
| 776 | 773 | public function __give_start_updating() { |
| 777 | 774 | // Check permission. |
| 778 | 775 | if ( |
| 779 | - ! current_user_can( 'manage_give_settings' ) || |
|
| 776 | + ! current_user_can('manage_give_settings') || |
|
| 780 | 777 | $this->is_doing_updates() |
| 781 | 778 | ) { |
| 782 | 779 | wp_send_json_error(); |
@@ -784,7 +781,7 @@ discard block |
||
| 784 | 781 | |
| 785 | 782 | // @todo: validate nonce |
| 786 | 783 | // @todo: set http method to post |
| 787 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
| 784 | + if (empty($_POST['run_db_update'])) { |
|
| 788 | 785 | wp_send_json_error(); |
| 789 | 786 | } |
| 790 | 787 | |
@@ -803,34 +800,34 @@ discard block |
||
| 803 | 800 | * @return string |
| 804 | 801 | */ |
| 805 | 802 | public function __give_db_updates_info() { |
| 806 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
| 803 | + $update_info = get_option('give_doing_upgrade'); |
|
| 807 | 804 | $response_type = ''; |
| 808 | 805 | |
| 809 | - if ( self::$background_updater->is_paused_process() ) { |
|
| 806 | + if (self::$background_updater->is_paused_process()) { |
|
| 810 | 807 | $update_info = array( |
| 811 | - 'message' => __( 'The updates have been paused.', 'give' ), |
|
| 808 | + 'message' => __('The updates have been paused.', 'give'), |
|
| 812 | 809 | 'heading' => '', |
| 813 | 810 | 'percentage' => 0, |
| 814 | 811 | ); |
| 815 | 812 | |
| 816 | - if ( get_option( 'give_upgrade_error' ) ) { |
|
| 817 | - $update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); |
|
| 813 | + if (get_option('give_upgrade_error')) { |
|
| 814 | + $update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); |
|
| 818 | 815 | } |
| 819 | 816 | |
| 820 | 817 | $response_type = 'error'; |
| 821 | 818 | |
| 822 | - } elseif ( empty( $update_info ) || ! $this->get_total_new_db_update_count( true ) ) { |
|
| 819 | + } elseif (empty($update_info) || ! $this->get_total_new_db_update_count(true)) { |
|
| 823 | 820 | $update_info = array( |
| 824 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
| 825 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
| 821 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
| 822 | + 'heading' => __('Updates Completed.', 'give'), |
|
| 826 | 823 | 'percentage' => 0, |
| 827 | 824 | ); |
| 828 | 825 | $response_type = 'success'; |
| 829 | 826 | |
| 830 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
| 827 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
| 831 | 828 | } |
| 832 | 829 | |
| 833 | - $this->send_ajax_response( $update_info, $response_type ); |
|
| 830 | + $this->send_ajax_response($update_info, $response_type); |
|
| 834 | 831 | } |
| 835 | 832 | |
| 836 | 833 | /** |
@@ -842,7 +839,7 @@ discard block |
||
| 842 | 839 | * @param $data |
| 843 | 840 | * @param string $type |
| 844 | 841 | */ |
| 845 | - public function send_ajax_response( $data, $type = '' ) { |
|
| 842 | + public function send_ajax_response($data, $type = '') { |
|
| 846 | 843 | $default = array( |
| 847 | 844 | 'message' => '', |
| 848 | 845 | 'heading' => '', |
@@ -852,24 +849,24 @@ discard block |
||
| 852 | 849 | ); |
| 853 | 850 | |
| 854 | 851 | // Set data. |
| 855 | - $data = wp_parse_args( $data, $default ); |
|
| 852 | + $data = wp_parse_args($data, $default); |
|
| 856 | 853 | |
| 857 | 854 | // Enable cache. |
| 858 | 855 | Give_Cache::enable(); |
| 859 | 856 | |
| 860 | - switch ( $type ) { |
|
| 857 | + switch ($type) { |
|
| 861 | 858 | case 'success': |
| 862 | - wp_send_json_success( $data ); |
|
| 859 | + wp_send_json_success($data); |
|
| 863 | 860 | break; |
| 864 | 861 | |
| 865 | 862 | case 'error': |
| 866 | - wp_send_json_error( $data ); |
|
| 863 | + wp_send_json_error($data); |
|
| 867 | 864 | break; |
| 868 | 865 | |
| 869 | 866 | default: |
| 870 | - wp_send_json( array( |
|
| 867 | + wp_send_json(array( |
|
| 871 | 868 | 'data' => $data, |
| 872 | - ) ); |
|
| 869 | + )); |
|
| 873 | 870 | break; |
| 874 | 871 | } |
| 875 | 872 | } |
@@ -883,12 +880,12 @@ discard block |
||
| 883 | 880 | * @param $total |
| 884 | 881 | * @param $current_total |
| 885 | 882 | */ |
| 886 | - public function set_percentage( $total, $current_total ) { |
|
| 883 | + public function set_percentage($total, $current_total) { |
|
| 887 | 884 | // Set percentage. |
| 888 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
| 885 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
| 889 | 886 | |
| 890 | 887 | // Verify percentage. |
| 891 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
| 888 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
| 892 | 889 | } |
| 893 | 890 | |
| 894 | 891 | /** |
@@ -901,22 +898,22 @@ discard block |
||
| 901 | 898 | * |
| 902 | 899 | * @return bool|null |
| 903 | 900 | */ |
| 904 | - public function is_parent_updates_completed( $update ) { |
|
| 901 | + public function is_parent_updates_completed($update) { |
|
| 905 | 902 | // Bailout. |
| 906 | - if ( empty( $update['depend'] ) ) { |
|
| 903 | + if (empty($update['depend'])) { |
|
| 907 | 904 | return true; |
| 908 | 905 | } |
| 909 | 906 | |
| 910 | 907 | // Check if dependency is valid or not. |
| 911 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
| 908 | + if ( ! $this->has_valid_dependency($update)) { |
|
| 912 | 909 | return null; |
| 913 | 910 | } |
| 914 | 911 | |
| 915 | 912 | $is_dependency_completed = true; |
| 916 | 913 | |
| 917 | - foreach ( $update['depend'] as $depend ) { |
|
| 914 | + foreach ($update['depend'] as $depend) { |
|
| 918 | 915 | |
| 919 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
| 916 | + if ( ! give_has_upgrade_completed($depend)) { |
|
| 920 | 917 | $is_dependency_completed = false; |
| 921 | 918 | break; |
| 922 | 919 | } |
@@ -933,7 +930,7 @@ discard block |
||
| 933 | 930 | * @return bool |
| 934 | 931 | */ |
| 935 | 932 | public function is_doing_updates() { |
| 936 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
| 933 | + return (bool) get_option('give_doing_upgrade'); |
|
| 937 | 934 | } |
| 938 | 935 | |
| 939 | 936 | |
@@ -947,7 +944,7 @@ discard block |
||
| 947 | 944 | * |
| 948 | 945 | * @return bool |
| 949 | 946 | */ |
| 950 | - public function has_valid_dependency( $update ) { |
|
| 947 | + public function has_valid_dependency($update) { |
|
| 951 | 948 | $is_valid_dependency = true; |
| 952 | 949 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
| 953 | 950 | // |
@@ -973,33 +970,33 @@ discard block |
||
| 973 | 970 | * |
| 974 | 971 | * @return array |
| 975 | 972 | */ |
| 976 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
| 973 | + public function get_updates($update_type = '', $status = 'all') { |
|
| 977 | 974 | // return all updates. |
| 978 | - if ( empty( $update_type ) ) { |
|
| 975 | + if (empty($update_type)) { |
|
| 979 | 976 | return $this->updates; |
| 980 | 977 | } |
| 981 | 978 | |
| 982 | 979 | // Get specific update. |
| 983 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
| 980 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
| 984 | 981 | |
| 985 | 982 | // Bailout. |
| 986 | - if ( empty( $updates ) ) { |
|
| 983 | + if (empty($updates)) { |
|
| 987 | 984 | return $updates; |
| 988 | 985 | } |
| 989 | 986 | |
| 990 | - switch ( $status ) { |
|
| 987 | + switch ($status) { |
|
| 991 | 988 | case 'new': |
| 992 | 989 | // Remove already completed updates. |
| 993 | - wp_cache_delete( 'give_completed_upgrades', 'options' ); |
|
| 990 | + wp_cache_delete('give_completed_upgrades', 'options'); |
|
| 994 | 991 | $completed_updates = give_get_completed_upgrades(); |
| 995 | 992 | |
| 996 | - if ( ! empty( $completed_updates ) ) { |
|
| 997 | - foreach ( $updates as $index => $update ) { |
|
| 998 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
| 999 | - unset( $updates[ $index ] ); |
|
| 993 | + if ( ! empty($completed_updates)) { |
|
| 994 | + foreach ($updates as $index => $update) { |
|
| 995 | + if (in_array($update['id'], $completed_updates)) { |
|
| 996 | + unset($updates[$index]); |
|
| 1000 | 997 | } |
| 1001 | 998 | } |
| 1002 | - $updates = array_values( $updates ); |
|
| 999 | + $updates = array_values($updates); |
|
| 1003 | 1000 | } |
| 1004 | 1001 | |
| 1005 | 1002 | break; |
@@ -1016,7 +1013,7 @@ discard block |
||
| 1016 | 1013 | * @return int |
| 1017 | 1014 | */ |
| 1018 | 1015 | public function get_total_plugin_update_count() { |
| 1019 | - return count( $this->get_updates( 'plugin' ) ); |
|
| 1016 | + return count($this->get_updates('plugin')); |
|
| 1020 | 1017 | } |
| 1021 | 1018 | |
| 1022 | 1019 | /** |
@@ -1031,7 +1028,7 @@ discard block |
||
| 1031 | 1028 | $db_update_count = $this->get_pending_db_update_count(); |
| 1032 | 1029 | $plugin_update_count = $this->get_total_plugin_update_count(); |
| 1033 | 1030 | |
| 1034 | - return ( $db_update_count + $plugin_update_count ); |
|
| 1031 | + return ($db_update_count + $plugin_update_count); |
|
| 1035 | 1032 | } |
| 1036 | 1033 | |
| 1037 | 1034 | /** |
@@ -1043,7 +1040,7 @@ discard block |
||
| 1043 | 1040 | * @return int |
| 1044 | 1041 | */ |
| 1045 | 1042 | public function get_pending_db_update_count() { |
| 1046 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
| 1043 | + return count($this->get_updates('database', 'new')); |
|
| 1047 | 1044 | } |
| 1048 | 1045 | |
| 1049 | 1046 | /** |
@@ -1055,7 +1052,7 @@ discard block |
||
| 1055 | 1052 | * @return int |
| 1056 | 1053 | */ |
| 1057 | 1054 | public function get_total_db_update_count() { |
| 1058 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
| 1055 | + return count($this->get_updates('database', 'all')); |
|
| 1059 | 1056 | } |
| 1060 | 1057 | |
| 1061 | 1058 | /** |
@@ -1068,10 +1065,9 @@ discard block |
||
| 1068 | 1065 | * |
| 1069 | 1066 | * @return int |
| 1070 | 1067 | */ |
| 1071 | - public function get_total_new_db_update_count( $refresh = false ) { |
|
| 1068 | + public function get_total_new_db_update_count($refresh = false) { |
|
| 1072 | 1069 | $update_count = $this->is_doing_updates() && ! $refresh ? |
| 1073 | - get_option( 'give_db_update_count' ) : |
|
| 1074 | - $this->get_pending_db_update_count(); |
|
| 1070 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
| 1075 | 1071 | |
| 1076 | 1072 | return $update_count; |
| 1077 | 1073 | } |
@@ -1086,11 +1082,11 @@ discard block |
||
| 1086 | 1082 | * |
| 1087 | 1083 | * @return int |
| 1088 | 1084 | */ |
| 1089 | - public function get_running_db_update( $refresh = false ) { |
|
| 1085 | + public function get_running_db_update($refresh = false) { |
|
| 1090 | 1086 | $current_update = 1; |
| 1091 | 1087 | |
| 1092 | - if ( $this->is_doing_updates() && ! $refresh ) { |
|
| 1093 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
| 1088 | + if ($this->is_doing_updates() && ! $refresh) { |
|
| 1089 | + $current_update = get_option('give_doing_upgrade'); |
|
| 1094 | 1090 | $current_update = $current_update['update']; |
| 1095 | 1091 | } |
| 1096 | 1092 | |
@@ -1107,25 +1103,23 @@ discard block |
||
| 1107 | 1103 | * |
| 1108 | 1104 | * @return float|int |
| 1109 | 1105 | */ |
| 1110 | - public function get_db_update_processing_percentage( $refresh = false ) { |
|
| 1106 | + public function get_db_update_processing_percentage($refresh = false) { |
|
| 1111 | 1107 | // Bailout. |
| 1112 | - if ( ! $this->get_total_new_db_update_count( $refresh ) ) { |
|
| 1108 | + if ( ! $this->get_total_new_db_update_count($refresh)) { |
|
| 1113 | 1109 | return 0; |
| 1114 | 1110 | } |
| 1115 | 1111 | |
| 1116 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
| 1117 | - $update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100; |
|
| 1118 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
| 1119 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
| 1112 | + $resume_update = get_option('give_doing_upgrade'); |
|
| 1113 | + $update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100; |
|
| 1114 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
| 1115 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
| 1120 | 1116 | |
| 1121 | 1117 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
| 1122 | 1118 | |
| 1123 | 1119 | return $this->is_doing_updates() ? |
| 1124 | - ( absint( $final_percentage ) ? |
|
| 1125 | - absint( $final_percentage ) : |
|
| 1126 | - round( $final_percentage, 2 ) |
|
| 1127 | - ) : |
|
| 1128 | - 0; |
|
| 1120 | + (absint($final_percentage) ? |
|
| 1121 | + absint($final_percentage) : round($final_percentage, 2) |
|
| 1122 | + ) : 0; |
|
| 1129 | 1123 | } |
| 1130 | 1124 | |
| 1131 | 1125 | |
@@ -1137,8 +1131,8 @@ discard block |
||
| 1137 | 1131 | * @return array |
| 1138 | 1132 | */ |
| 1139 | 1133 | public function get_update_ids() { |
| 1140 | - $all_updates = $this->get_updates( 'database', 'all' ); |
|
| 1141 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
| 1134 | + $all_updates = $this->get_updates('database', 'all'); |
|
| 1135 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
| 1142 | 1136 | |
| 1143 | 1137 | return $all_update_ids; |
| 1144 | 1138 | } |
@@ -1153,10 +1147,9 @@ discard block |
||
| 1153 | 1147 | * |
| 1154 | 1148 | * @return float|int |
| 1155 | 1149 | */ |
| 1156 | - public function get_offset( $process_item_count ) { |
|
| 1157 | - return ( 1 === $this->step ) ? |
|
| 1158 | - 0 : |
|
| 1159 | - ( $this->step - 1 ) * $process_item_count; |
|
| 1150 | + public function get_offset($process_item_count) { |
|
| 1151 | + return (1 === $this->step) ? |
|
| 1152 | + 0 : ($this->step - 1) * $process_item_count; |
|
| 1160 | 1153 | } |
| 1161 | 1154 | } |
| 1162 | 1155 | |
@@ -615,8 +615,11 @@ |
||
| 615 | 615 | <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
| 616 | 616 | <?php _e( 'Restart the updater', 'give' ); ?> |
| 617 | 617 | </a> |
| 618 | - <?php else: ?> |
|
| 619 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 618 | + <?php else { |
|
| 619 | + : ?> |
|
| 620 | + <strong><?php _e( 'Database Update', 'give' ); |
|
| 621 | +} |
|
| 622 | +?></strong> |
|
| 620 | 623 | – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
| 621 | 624 | <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e( 'Read More', 'give' ); ?> »</a> |
| 622 | 625 | <?php |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,19 +23,19 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array An array of updated action links. |
| 25 | 25 | */ |
| 26 | -function give_plugin_action_links( $actions ) { |
|
| 26 | +function give_plugin_action_links($actions) { |
|
| 27 | 27 | $new_actions = array( |
| 28 | 28 | 'settings' => sprintf( |
| 29 | 29 | '<a href="%1$s">%2$s</a>', |
| 30 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings' ), |
|
| 31 | - __( 'Settings', 'give' ) |
|
| 30 | + admin_url('edit.php?post_type=give_forms&page=give-settings'), |
|
| 31 | + __('Settings', 'give') |
|
| 32 | 32 | ), |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - return array_merge( $new_actions, $actions ); |
|
| 35 | + return array_merge($new_actions, $actions); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' ); |
|
| 38 | +add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links'); |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return array |
| 50 | 50 | */ |
| 51 | -function give_plugin_row_meta( $plugin_meta, $plugin_file ) { |
|
| 52 | - if ( GIVE_PLUGIN_BASENAME !== $plugin_file ) { |
|
| 51 | +function give_plugin_row_meta($plugin_meta, $plugin_file) { |
|
| 52 | + if (GIVE_PLUGIN_BASENAME !== $plugin_file) { |
|
| 53 | 53 | return $plugin_meta; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ), 'https://givewp.com/documentation/' |
| 66 | 66 | ) |
| 67 | 67 | ), |
| 68 | - __( 'Documentation', 'give' ) |
|
| 68 | + __('Documentation', 'give') |
|
| 69 | 69 | ), |
| 70 | 70 | sprintf( |
| 71 | 71 | '<a href="%1$s" target="_blank">%2$s</a>', |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | ), 'https://givewp.com/addons/' |
| 79 | 79 | ) |
| 80 | 80 | ), |
| 81 | - __( 'Add-ons', 'give' ) |
|
| 81 | + __('Add-ons', 'give') |
|
| 82 | 82 | ), |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - return array_merge( $plugin_meta, $new_meta_links ); |
|
| 85 | + return array_merge($plugin_meta, $new_meta_links); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
| 88 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
|
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -103,19 +103,18 @@ discard block |
||
| 103 | 103 | $title = ''; |
| 104 | 104 | global $submenu, $plugin_page; |
| 105 | 105 | |
| 106 | - foreach ( array_keys( $submenu ) as $parent ) { |
|
| 107 | - if ( 'edit.php?post_type=give_forms' !== $parent ) { |
|
| 106 | + foreach (array_keys($submenu) as $parent) { |
|
| 107 | + if ('edit.php?post_type=give_forms' !== $parent) { |
|
| 108 | 108 | continue; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - foreach ( $submenu[ $parent ] as $submenu_array ) { |
|
| 112 | - if ( $plugin_page !== $submenu_array[2] ) { |
|
| 111 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 112 | + if ($plugin_page !== $submenu_array[2]) { |
|
| 113 | 113 | continue; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $title = isset( $submenu_array[0] ) ? |
|
| 117 | - $submenu_array[0] : |
|
| 118 | - $submenu_array[3]; |
|
| 116 | + $title = isset($submenu_array[0]) ? |
|
| 117 | + $submenu_array[0] : $submenu_array[3]; |
|
| 119 | 118 | } |
| 120 | 119 | } |
| 121 | 120 | |
@@ -129,11 +128,11 @@ discard block |
||
| 129 | 128 | */ |
| 130 | 129 | function give_recently_activated_addons() { |
| 131 | 130 | // Check if action is set. |
| 132 | - if ( isset( $_REQUEST['action'] ) ) { |
|
| 133 | - $plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' ); |
|
| 131 | + if (isset($_REQUEST['action'])) { |
|
| 132 | + $plugin_action = ('-1' !== $_REQUEST['action']) ? $_REQUEST['action'] : (isset($_REQUEST['action2']) ? $_REQUEST['action2'] : ''); |
|
| 134 | 133 | $plugins = array(); |
| 135 | 134 | |
| 136 | - switch ( $plugin_action ) { |
|
| 135 | + switch ($plugin_action) { |
|
| 137 | 136 | case 'activate': // Single add-on activation. |
| 138 | 137 | $plugins[] = $_REQUEST['plugin']; |
| 139 | 138 | break; |
@@ -143,27 +142,27 @@ discard block |
||
| 143 | 142 | } |
| 144 | 143 | |
| 145 | 144 | |
| 146 | - if ( ! empty( $plugins ) ) { |
|
| 145 | + if ( ! empty($plugins)) { |
|
| 147 | 146 | |
| 148 | 147 | $give_addons = give_get_recently_activated_addons(); |
| 149 | 148 | |
| 150 | - foreach ( $plugins as $plugin ) { |
|
| 149 | + foreach ($plugins as $plugin) { |
|
| 151 | 150 | // Get plugins which has 'Give-' as prefix. |
| 152 | - if ( stripos( $plugin, 'Give-' ) !== false ) { |
|
| 151 | + if (stripos($plugin, 'Give-') !== false) { |
|
| 153 | 152 | $give_addons[] = $plugin; |
| 154 | 153 | } |
| 155 | 154 | } |
| 156 | 155 | |
| 157 | - if ( ! empty( $give_addons ) ) { |
|
| 156 | + if ( ! empty($give_addons)) { |
|
| 158 | 157 | // Update the Give's activated add-ons. |
| 159 | - update_option( 'give_recently_activated_addons', $give_addons ); |
|
| 158 | + update_option('give_recently_activated_addons', $give_addons); |
|
| 160 | 159 | } |
| 161 | 160 | } |
| 162 | 161 | } |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | 164 | // Add add-on plugins to wp option table. |
| 166 | -add_action( 'activated_plugin', 'give_recently_activated_addons', 10 ); |
|
| 165 | +add_action('activated_plugin', 'give_recently_activated_addons', 10); |
|
| 167 | 166 | |
| 168 | 167 | /** |
| 169 | 168 | * Create new menu in plugin section that include all the add-on |
@@ -174,19 +173,19 @@ discard block |
||
| 174 | 173 | * |
| 175 | 174 | * @return mixed |
| 176 | 175 | */ |
| 177 | -function give_filter_addons_do_filter_addons( $plugin_menu ) { |
|
| 176 | +function give_filter_addons_do_filter_addons($plugin_menu) { |
|
| 178 | 177 | global $plugins; |
| 179 | 178 | |
| 180 | - foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) { |
|
| 179 | + foreach ($plugins['all'] as $plugin_slug => $plugin_data) { |
|
| 181 | 180 | |
| 182 | - if ( false !== strpos( $plugin_data['Name'], 'Give' ) && false !== strpos( $plugin_data['AuthorName'], 'WordImpress' ) ) { |
|
| 183 | - $plugins['give'][ $plugin_slug ] = $plugins['all'][ $plugin_slug ]; |
|
| 184 | - $plugins['give'][ $plugin_slug ]['plugin'] = $plugin_slug; |
|
| 181 | + if (false !== strpos($plugin_data['Name'], 'Give') && false !== strpos($plugin_data['AuthorName'], 'WordImpress')) { |
|
| 182 | + $plugins['give'][$plugin_slug] = $plugins['all'][$plugin_slug]; |
|
| 183 | + $plugins['give'][$plugin_slug]['plugin'] = $plugin_slug; |
|
| 185 | 184 | // replicate the next step. |
| 186 | - if ( current_user_can( 'update_plugins' ) ) { |
|
| 187 | - $current = get_site_transient( 'update_plugins' ); |
|
| 188 | - if ( isset( $current->response[ $plugin_slug ] ) ) { |
|
| 189 | - $plugins['give'][ $plugin_slug ]['update'] = true; |
|
| 185 | + if (current_user_can('update_plugins')) { |
|
| 186 | + $current = get_site_transient('update_plugins'); |
|
| 187 | + if (isset($current->response[$plugin_slug])) { |
|
| 188 | + $plugins['give'][$plugin_slug]['update'] = true; |
|
| 190 | 189 | } |
| 191 | 190 | } |
| 192 | 191 | } |
@@ -196,8 +195,8 @@ discard block |
||
| 196 | 195 | |
| 197 | 196 | } |
| 198 | 197 | |
| 199 | -add_filter( 'show_advanced_plugins', 'give_filter_addons_do_filter_addons' ); |
|
| 200 | -add_filter( 'show_network_active_plugins', 'give_filter_addons_do_filter_addons' ); |
|
| 198 | +add_filter('show_advanced_plugins', 'give_filter_addons_do_filter_addons'); |
|
| 199 | +add_filter('show_network_active_plugins', 'give_filter_addons_do_filter_addons'); |
|
| 201 | 200 | |
| 202 | 201 | /** |
| 203 | 202 | * Make the Give Menu as an default menu and update the Menu Name |
@@ -208,30 +207,30 @@ discard block |
||
| 208 | 207 | * |
| 209 | 208 | * @return mixed |
| 210 | 209 | */ |
| 211 | -function give_filter_addons_filter_addons( $views ) { |
|
| 210 | +function give_filter_addons_filter_addons($views) { |
|
| 212 | 211 | |
| 213 | 212 | global $status, $plugins; |
| 214 | 213 | |
| 215 | - if ( ! empty( $plugins['give'] ) ) { |
|
| 214 | + if ( ! empty($plugins['give'])) { |
|
| 216 | 215 | $class = ''; |
| 217 | 216 | |
| 218 | - if ( 'give' === $status ) { |
|
| 217 | + if ('give' === $status) { |
|
| 219 | 218 | $class = 'current'; |
| 220 | 219 | } |
| 221 | 220 | |
| 222 | 221 | $views['give'] = sprintf( |
| 223 | 222 | '<a class="%s" href="plugins.php?plugin_status=give"> %s <span class="count">(%s) </span></a>', |
| 224 | 223 | $class, |
| 225 | - __( 'Give', 'give' ), |
|
| 226 | - count( $plugins['give'] ) |
|
| 224 | + __('Give', 'give'), |
|
| 225 | + count($plugins['give']) |
|
| 227 | 226 | ); |
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | return $views; |
| 231 | 230 | } |
| 232 | 231 | |
| 233 | -add_filter( 'views_plugins', 'give_filter_addons_filter_addons' ); |
|
| 234 | -add_filter( 'views_plugins-network', 'give_filter_addons_filter_addons' ); |
|
| 232 | +add_filter('views_plugins', 'give_filter_addons_filter_addons'); |
|
| 233 | +add_filter('views_plugins-network', 'give_filter_addons_filter_addons'); |
|
| 235 | 234 | |
| 236 | 235 | /** |
| 237 | 236 | * Set the Give as the Main menu when admin click on the Give Menu in Plugin section. |
@@ -242,17 +241,17 @@ discard block |
||
| 242 | 241 | * |
| 243 | 242 | * @return mixed |
| 244 | 243 | */ |
| 245 | -function give_prepare_filter_addons( $plugins ) { |
|
| 244 | +function give_prepare_filter_addons($plugins) { |
|
| 246 | 245 | global $status; |
| 247 | 246 | |
| 248 | - if ( isset( $_REQUEST['plugin_status'] ) && 'give' === $_REQUEST['plugin_status'] ) { |
|
| 247 | + if (isset($_REQUEST['plugin_status']) && 'give' === $_REQUEST['plugin_status']) { |
|
| 249 | 248 | $status = 'give'; |
| 250 | 249 | } |
| 251 | 250 | |
| 252 | 251 | return $plugins; |
| 253 | 252 | } |
| 254 | 253 | |
| 255 | -add_filter( 'all_plugins', 'give_prepare_filter_addons' ); |
|
| 254 | +add_filter('all_plugins', 'give_prepare_filter_addons'); |
|
| 256 | 255 | |
| 257 | 256 | |
| 258 | 257 | /** |
@@ -263,26 +262,26 @@ discard block |
||
| 263 | 262 | * |
| 264 | 263 | * @since 2.1 |
| 265 | 264 | */ |
| 266 | -function give_in_plugin_update_message( $data, $response ) { |
|
| 265 | +function give_in_plugin_update_message($data, $response) { |
|
| 267 | 266 | $new_version = $data['new_version']; |
| 268 | - $current_version_parts = explode( '.', GIVE_VERSION ); |
|
| 269 | - $new_version_parts = explode( '.', $new_version ); |
|
| 267 | + $current_version_parts = explode('.', GIVE_VERSION); |
|
| 268 | + $new_version_parts = explode('.', $new_version); |
|
| 270 | 269 | |
| 271 | 270 | // If it is a minor upgrade then return. |
| 272 | - if ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.' . $new_version_parts[1], '=' ) ) { |
|
| 271 | + if (version_compare($current_version_parts[0].'.'.$current_version_parts[1], $new_version_parts[0].'.'.$new_version_parts[1], '=')) { |
|
| 273 | 272 | |
| 274 | 273 | return; |
| 275 | 274 | } |
| 276 | 275 | |
| 277 | 276 | // Get the upgrade notice from the trunk. |
| 278 | - $upgrade_notice = give_get_plugin_upgrade_notice( $new_version ); |
|
| 277 | + $upgrade_notice = give_get_plugin_upgrade_notice($new_version); |
|
| 279 | 278 | |
| 280 | 279 | // Display upgrade notice. |
| 281 | - echo apply_filters( 'give_in_plugin_update_message', $upgrade_notice ? '</p>' . wp_kses_post( $upgrade_notice ) . '<p class="dummy">' : '' ); |
|
| 280 | + echo apply_filters('give_in_plugin_update_message', $upgrade_notice ? '</p>'.wp_kses_post($upgrade_notice).'<p class="dummy">' : ''); |
|
| 282 | 281 | } |
| 283 | 282 | |
| 284 | 283 | // Display upgrade notice. |
| 285 | -add_action( 'in_plugin_update_message-' . GIVE_PLUGIN_BASENAME, 'give_in_plugin_update_message', 10, 2 ); |
|
| 284 | +add_action('in_plugin_update_message-'.GIVE_PLUGIN_BASENAME, 'give_in_plugin_update_message', 10, 2); |
|
| 286 | 285 | |
| 287 | 286 | |
| 288 | 287 | /** |
@@ -296,18 +295,18 @@ discard block |
||
| 296 | 295 | * |
| 297 | 296 | * @return string |
| 298 | 297 | */ |
| 299 | -function give_get_plugin_upgrade_notice( $new_version ) { |
|
| 298 | +function give_get_plugin_upgrade_notice($new_version) { |
|
| 300 | 299 | |
| 301 | 300 | // Cache the upgrade notice. |
| 302 | 301 | $transient_name = "give_upgrade_notice_{$new_version}"; |
| 303 | - $upgrade_notice = get_transient( $transient_name ); |
|
| 302 | + $upgrade_notice = get_transient($transient_name); |
|
| 304 | 303 | |
| 305 | - if ( false === $upgrade_notice ) { |
|
| 306 | - $response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/give/trunk/readme.txt' ); |
|
| 304 | + if (false === $upgrade_notice) { |
|
| 305 | + $response = wp_safe_remote_get('https://plugins.svn.wordpress.org/give/trunk/readme.txt'); |
|
| 307 | 306 | |
| 308 | - if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) { |
|
| 309 | - $upgrade_notice = give_parse_plugin_update_notice( $response['body'], $new_version ); |
|
| 310 | - set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS ); |
|
| 307 | + if ( ! is_wp_error($response) && ! empty($response['body'])) { |
|
| 308 | + $upgrade_notice = give_parse_plugin_update_notice($response['body'], $new_version); |
|
| 309 | + set_transient($transient_name, $upgrade_notice, DAY_IN_SECONDS); |
|
| 311 | 310 | } |
| 312 | 311 | } |
| 313 | 312 | |
@@ -327,46 +326,46 @@ discard block |
||
| 327 | 326 | * |
| 328 | 327 | * @return string |
| 329 | 328 | */ |
| 330 | -function give_parse_plugin_update_notice( $content, $new_version ) { |
|
| 331 | - $version_parts = explode( '.', $new_version ); |
|
| 329 | +function give_parse_plugin_update_notice($content, $new_version) { |
|
| 330 | + $version_parts = explode('.', $new_version); |
|
| 332 | 331 | $check_for_notices = array( |
| 333 | - $version_parts[0] . '.0', |
|
| 334 | - $version_parts[0] . '.0.0', |
|
| 335 | - $version_parts[0] . '.' . $version_parts[1] . '.' . '0', |
|
| 332 | + $version_parts[0].'.0', |
|
| 333 | + $version_parts[0].'.0.0', |
|
| 334 | + $version_parts[0].'.'.$version_parts[1].'.'.'0', |
|
| 336 | 335 | ); |
| 337 | 336 | |
| 338 | 337 | // Regex to extract Upgrade notice from the readme.txt file. |
| 339 | - $notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis'; |
|
| 338 | + $notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote($new_version).'\s*=|$)~Uis'; |
|
| 340 | 339 | |
| 341 | 340 | $upgrade_notice = ''; |
| 342 | 341 | |
| 343 | - foreach ( $check_for_notices as $check_version ) { |
|
| 344 | - if ( version_compare( GIVE_VERSION, $check_version, '>' ) ) { |
|
| 342 | + foreach ($check_for_notices as $check_version) { |
|
| 343 | + if (version_compare(GIVE_VERSION, $check_version, '>')) { |
|
| 345 | 344 | continue; |
| 346 | 345 | } |
| 347 | 346 | |
| 348 | 347 | $matches = null; |
| 349 | 348 | |
| 350 | - if ( preg_match( $notice_regexp, $content, $matches ) ) { |
|
| 351 | - $notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) ); |
|
| 349 | + if (preg_match($notice_regexp, $content, $matches)) { |
|
| 350 | + $notices = (array) preg_split('~[\r\n]+~', trim($matches[2])); |
|
| 352 | 351 | |
| 353 | - if ( version_compare( trim( $matches[1] ), $check_version, '=' ) ) { |
|
| 352 | + if (version_compare(trim($matches[1]), $check_version, '=')) { |
|
| 354 | 353 | $upgrade_notice .= '<p class="give-plugin-upgrade-notice">'; |
| 355 | 354 | |
| 356 | - foreach ( $notices as $index => $line ) { |
|
| 357 | - $upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ); |
|
| 355 | + foreach ($notices as $index => $line) { |
|
| 356 | + $upgrade_notice .= preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line); |
|
| 358 | 357 | } |
| 359 | 358 | |
| 360 | 359 | $upgrade_notice .= '</p>'; |
| 361 | 360 | } |
| 362 | 361 | |
| 363 | - if ( ! empty( $upgrade_notice ) ) { |
|
| 362 | + if ( ! empty($upgrade_notice)) { |
|
| 364 | 363 | break; |
| 365 | 364 | } |
| 366 | 365 | } |
| 367 | 366 | } |
| 368 | 367 | |
| 369 | - return wp_kses_post( $upgrade_notice ); |
|
| 368 | + return wp_kses_post($upgrade_notice); |
|
| 370 | 369 | } |
| 371 | 370 | |
| 372 | 371 | |
@@ -403,7 +402,7 @@ discard block |
||
| 403 | 402 | <?php |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | -add_action( 'admin_head', 'give_plugin_notice_css' ); |
|
| 405 | +add_action('admin_head', 'give_plugin_notice_css'); |
|
| 407 | 406 | |
| 408 | 407 | /** |
| 409 | 408 | * Get list of add-on last activated. |
@@ -413,5 +412,5 @@ discard block |
||
| 413 | 412 | * @return mixed|array list of recently activated add-on |
| 414 | 413 | */ |
| 415 | 414 | function give_get_recently_activated_addons() { |
| 416 | - return get_option( 'give_recently_activated_addons', array() ); |
|
| 415 | + return get_option('give_recently_activated_addons', array()); |
|
| 417 | 416 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | |
| 27 | - $this->shortcode['title'] = esc_html__( 'Donation Receipt', 'give' ); |
|
| 28 | - $this->shortcode['label'] = esc_html__( 'Donation Receipt', 'give' ); |
|
| 27 | + $this->shortcode['title'] = esc_html__('Donation Receipt', 'give'); |
|
| 28 | + $this->shortcode['label'] = esc_html__('Donation Receipt', 'give'); |
|
| 29 | 29 | |
| 30 | - parent::__construct( 'give_receipt' ); |
|
| 30 | + parent::__construct('give_receipt'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -40,71 +40,71 @@ discard block |
||
| 40 | 40 | return array( |
| 41 | 41 | array( |
| 42 | 42 | 'type' => 'container', |
| 43 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
| 43 | + 'html' => sprintf('<p class="strong">%s</p>', esc_html__('Optional settings', 'give')), |
|
| 44 | 44 | ), |
| 45 | 45 | array( |
| 46 | 46 | 'type' => 'listbox', |
| 47 | 47 | 'name' => 'price', |
| 48 | - 'label' => esc_html__( 'Show Donation Amount:', 'give' ), |
|
| 48 | + 'label' => esc_html__('Show Donation Amount:', 'give'), |
|
| 49 | 49 | 'options' => array( |
| 50 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 50 | + 'false' => esc_html__('Hide', 'give'), |
|
| 51 | 51 | ), |
| 52 | - 'placeholder' => esc_html__( 'Show', 'give' ) |
|
| 52 | + 'placeholder' => esc_html__('Show', 'give') |
|
| 53 | 53 | ), |
| 54 | 54 | array( |
| 55 | 55 | 'type' => 'listbox', |
| 56 | 56 | 'name' => 'donor', |
| 57 | - 'label' => esc_html__( 'Show Donor Name:', 'give' ), |
|
| 57 | + 'label' => esc_html__('Show Donor Name:', 'give'), |
|
| 58 | 58 | 'options' => array( |
| 59 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 60 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 59 | + 'true' => esc_html__('Show', 'give'), |
|
| 60 | + 'false' => esc_html__('Hide', 'give'), |
|
| 61 | 61 | ), |
| 62 | - 'placeholder' => esc_html__( 'Show', 'give' ) |
|
| 62 | + 'placeholder' => esc_html__('Show', 'give') |
|
| 63 | 63 | ), |
| 64 | 64 | array( |
| 65 | 65 | 'type' => 'listbox', |
| 66 | 66 | 'name' => 'date', |
| 67 | - 'label' => esc_html__( 'Show Date:', 'give' ), |
|
| 67 | + 'label' => esc_html__('Show Date:', 'give'), |
|
| 68 | 68 | 'options' => array( |
| 69 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 69 | + 'false' => esc_html__('Hide', 'give'), |
|
| 70 | 70 | ), |
| 71 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
| 71 | + 'placeholder' => esc_html__('Show', 'give'), |
|
| 72 | 72 | ), |
| 73 | 73 | array( |
| 74 | 74 | 'type' => 'listbox', |
| 75 | 75 | 'name' => 'payment_key', |
| 76 | - 'label' => esc_html__( 'Show Payment Key:', 'give' ), |
|
| 76 | + 'label' => esc_html__('Show Payment Key:', 'give'), |
|
| 77 | 77 | 'options' => array( |
| 78 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 78 | + 'true' => esc_html__('Show', 'give'), |
|
| 79 | 79 | ), |
| 80 | - 'placeholder' => esc_html__( 'Hide', 'give' ), |
|
| 80 | + 'placeholder' => esc_html__('Hide', 'give'), |
|
| 81 | 81 | ), |
| 82 | 82 | array( |
| 83 | 83 | 'type' => 'listbox', |
| 84 | 84 | 'name' => 'payment_method', |
| 85 | - 'label' => esc_html__( 'Show Payment Method:', 'give' ), |
|
| 85 | + 'label' => esc_html__('Show Payment Method:', 'give'), |
|
| 86 | 86 | 'options' => array( |
| 87 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 87 | + 'false' => esc_html__('Hide', 'give'), |
|
| 88 | 88 | ), |
| 89 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
| 89 | + 'placeholder' => esc_html__('Show', 'give'), |
|
| 90 | 90 | ), |
| 91 | 91 | array( |
| 92 | 92 | 'type' => 'listbox', |
| 93 | 93 | 'name' => 'payment_id', |
| 94 | - 'label' => esc_html__( 'Show Payment ID:', 'give' ), |
|
| 94 | + 'label' => esc_html__('Show Payment ID:', 'give'), |
|
| 95 | 95 | 'options' => array( |
| 96 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
| 96 | + 'false' => esc_html__('Hide', 'give'), |
|
| 97 | 97 | ), |
| 98 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
| 98 | + 'placeholder' => esc_html__('Show', 'give'), |
|
| 99 | 99 | ), |
| 100 | 100 | array( |
| 101 | 101 | 'type' => 'listbox', |
| 102 | 102 | 'name' => 'company_name', |
| 103 | - 'label' => esc_html__( 'Company Name:', 'give' ), |
|
| 103 | + 'label' => esc_html__('Company Name:', 'give'), |
|
| 104 | 104 | 'options' => array( |
| 105 | - 'true' => esc_html__( 'Show', 'give' ), |
|
| 105 | + 'true' => esc_html__('Show', 'give'), |
|
| 106 | 106 | ), |
| 107 | - 'placeholder' => esc_html__( 'Hide', 'give' ) |
|
| 107 | + 'placeholder' => esc_html__('Hide', 'give') |
|
| 108 | 108 | ), |
| 109 | 109 | ); |
| 110 | 110 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if access directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @return static |
| 47 | 47 | */ |
| 48 | 48 | static function get_instance() { |
| 49 | - if ( null === static::$instance ) { |
|
| 49 | + if (null === static::$instance) { |
|
| 50 | 50 | self::$instance = new static(); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - public static function has_preview( Give_Email_Notification $email ) { |
|
| 67 | + public static function has_preview(Give_Email_Notification $email) { |
|
| 68 | 68 | return $email->config['has_preview']; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return bool |
| 80 | 80 | */ |
| 81 | - public static function has_recipient_field( Give_Email_Notification $email ) { |
|
| 81 | + public static function has_recipient_field(Give_Email_Notification $email) { |
|
| 82 | 82 | return $email->config['has_recipient_field']; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return bool |
| 94 | 94 | */ |
| 95 | - public static function is_notification_status_editable( Give_Email_Notification $email ) { |
|
| 95 | + public static function is_notification_status_editable(Give_Email_Notification $email) { |
|
| 96 | 96 | $user_can_edit = $email->config['notification_status_editable']; |
| 97 | 97 | |
| 98 | 98 | return (bool) $user_can_edit; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - public static function is_content_type_editable( Give_Email_Notification $email ) { |
|
| 111 | + public static function is_content_type_editable(Give_Email_Notification $email) { |
|
| 112 | 112 | return $email->config['content_type_editable']; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return bool |
| 124 | 124 | */ |
| 125 | - public static function is_email_preview_has_header( Give_Email_Notification $email ) { |
|
| 125 | + public static function is_email_preview_has_header(Give_Email_Notification $email) { |
|
| 126 | 126 | return $email->config['has_preview_header']; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return bool |
| 138 | 138 | */ |
| 139 | - public static function is_email_preview( Give_Email_Notification $email ) { |
|
| 139 | + public static function is_email_preview(Give_Email_Notification $email) { |
|
| 140 | 140 | return $email->config['has_preview']; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return bool |
| 152 | 152 | */ |
| 153 | - public static function is_show_on_emails_setting_page( Give_Email_Notification $email ){ |
|
| 153 | + public static function is_show_on_emails_setting_page(Give_Email_Notification $email) { |
|
| 154 | 154 | return $email->config['show_on_emails_setting_page']; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return bool |
| 167 | 167 | */ |
| 168 | - public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ){ |
|
| 169 | - return give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ); |
|
| 168 | + public static function can_use_form_email_options(Give_Email_Notification $email, $form_id = null) { |
|
| 169 | + return give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true)); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return string |
| 182 | 182 | */ |
| 183 | - public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) { |
|
| 184 | - $notification_status = $email->get_notification_status( $form_id ); |
|
| 183 | + public static function is_email_notification_active(Give_Email_Notification $email, $form_id = null) { |
|
| 184 | + $notification_status = $email->get_notification_status($form_id); |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | - $notification_status = empty( $form_id ) |
|
| 188 | - ? give_is_setting_enabled( $notification_status ) |
|
| 189 | - : give_is_setting_enabled( give_get_option( "{$email->config['id']}_notification", $email->config['notification_status'] ) ) && give_is_setting_enabled( $notification_status, array( 'enabled', 'global' ) ); |
|
| 187 | + $notification_status = empty($form_id) |
|
| 188 | + ? give_is_setting_enabled($notification_status) |
|
| 189 | + : give_is_setting_enabled(give_get_option("{$email->config['id']}_notification", $email->config['notification_status'])) && give_is_setting_enabled($notification_status, array('enabled', 'global')); |
|
| 190 | 190 | // To check if email notification is active or not on a per-form basis, email notification must be globally active—otherwise it will be considered disabled. |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @param bool $notification_status True if notification is enable and false when disable |
| 202 | 202 | */ |
| 203 | - return apply_filters( "give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id ); |
|
| 203 | + return apply_filters("give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | $is_preview = false; |
| 215 | 215 | |
| 216 | 216 | if ( |
| 217 | - current_user_can( 'manage_give_settings' ) |
|
| 218 | - && ! empty( $_GET['give_action'] ) |
|
| 217 | + current_user_can('manage_give_settings') |
|
| 218 | + && ! empty($_GET['give_action']) |
|
| 219 | 219 | && 'preview_email' === $_GET['give_action'] |
| 220 | 220 | ) { |
| 221 | 221 | $is_preview = true; |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | $is_preview = false; |
| 236 | 236 | |
| 237 | 237 | if ( |
| 238 | - current_user_can( 'manage_give_settings' ) |
|
| 239 | - && ! empty( $_GET['give_action'] ) |
|
| 238 | + current_user_can('manage_give_settings') |
|
| 239 | + && ! empty($_GET['give_action']) |
|
| 240 | 240 | && 'send_preview_email' === $_GET['give_action'] |
| 241 | 241 | ) { |
| 242 | 242 | $is_preview = true; |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @return string |
| 258 | 258 | */ |
| 259 | - public static function get_formatted_email_type( $content_type ) { |
|
| 259 | + public static function get_formatted_email_type($content_type) { |
|
| 260 | 260 | $email_contents = array( |
| 261 | - 'text/html' => __( 'HTML', 'give' ), |
|
| 262 | - 'text/plain' => __( 'Plain', 'give' ), |
|
| 261 | + 'text/html' => __('HTML', 'give'), |
|
| 262 | + 'text/plain' => __('Plain', 'give'), |
|
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | - return $email_contents[ $content_type ]; |
|
| 265 | + return $email_contents[$content_type]; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
@@ -279,41 +279,41 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return mixed |
| 281 | 281 | */ |
| 282 | - public static function get_value( Give_Email_Notification $email, $option_name, $form_id = null, $default = false ) { |
|
| 282 | + public static function get_value(Give_Email_Notification $email, $option_name, $form_id = null, $default = false) { |
|
| 283 | 283 | // If form id set then option name can be contain _give_ prefix which is only used for meta key, |
| 284 | 284 | // So make sure you are using correct option name. |
| 285 | - $global_option_name = ( 0 === strpos( $option_name, '_give_' ) |
|
| 286 | - ? str_replace( '_give_', '', $option_name ) |
|
| 287 | - : $option_name ); |
|
| 288 | - $option_value = give_get_option( $global_option_name, $default ); |
|
| 285 | + $global_option_name = (0 === strpos($option_name, '_give_') |
|
| 286 | + ? str_replace('_give_', '', $option_name) |
|
| 287 | + : $option_name); |
|
| 288 | + $option_value = give_get_option($global_option_name, $default); |
|
| 289 | 289 | |
| 290 | 290 | if ( |
| 291 | - ! empty( $form_id ) |
|
| 291 | + ! empty($form_id) |
|
| 292 | 292 | && give_is_setting_enabled( |
| 293 | 293 | give_get_meta( |
| 294 | 294 | $form_id, |
| 295 | - Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'notification', |
|
| 295 | + Give_Email_Setting_Field::get_prefix($email, $form_id).'notification', |
|
| 296 | 296 | true, |
| 297 | 297 | 'global' |
| 298 | 298 | ) |
| 299 | 299 | ) |
| 300 | 300 | ) { |
| 301 | - $option_value = get_post_meta( $form_id, $option_name, true ); |
|
| 301 | + $option_value = get_post_meta($form_id, $option_name, true); |
|
| 302 | 302 | |
| 303 | 303 | // Get only email field value from recipients setting. |
| 304 | - if( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) { |
|
| 305 | - $option_value = wp_list_pluck( $option_value, 'email' ); |
|
| 304 | + if (Give_Email_Setting_Field::get_prefix($email, $form_id).'recipient' === $option_name) { |
|
| 305 | + $option_value = wp_list_pluck($option_value, 'email'); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $option_value = empty( $option_value ) ? $default : $option_value; |
|
| 309 | + $option_value = empty($option_value) ? $default : $option_value; |
|
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | 312 | * Filter the setting value |
| 313 | 313 | * |
| 314 | 314 | * @since 2.0 |
| 315 | 315 | */ |
| 316 | - return apply_filters( 'give_email_setting_value', $option_value, $option_name, $email, $form_id, $default ); |
|
| 316 | + return apply_filters('give_email_setting_value', $option_value, $option_name, $email, $form_id, $default); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | |
@@ -328,12 +328,12 @@ discard block |
||
| 328 | 328 | * |
| 329 | 329 | * @return string |
| 330 | 330 | */ |
| 331 | - public static function get_email_logo( $form_id ) { |
|
| 331 | + public static function get_email_logo($form_id) { |
|
| 332 | 332 | |
| 333 | 333 | // Email logo tag. |
| 334 | - $header_img = $form_id && give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ) |
|
| 335 | - ? give_get_meta( $form_id, '_give_email_logo', true ) |
|
| 336 | - : give_get_option( 'email_logo', '' ); |
|
| 334 | + $header_img = $form_id && give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true)) |
|
| 335 | + ? give_get_meta($form_id, '_give_email_logo', true) |
|
| 336 | + : give_get_option('email_logo', ''); |
|
| 337 | 337 | |
| 338 | 338 | return $header_img; |
| 339 | 339 | } |
@@ -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_License' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_License')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_License. |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function __construct() { |
| 29 | 29 | $this->id = 'licenses'; |
| 30 | - $this->label = esc_html__( 'Licenses', 'give' ); |
|
| 30 | + $this->label = esc_html__('Licenses', 'give'); |
|
| 31 | 31 | |
| 32 | 32 | parent::__construct(); |
| 33 | 33 | |
| 34 | 34 | // Filter to remove the license tab. |
| 35 | - add_filter( 'give-settings_tabs_array', array( $this, 'remove_license_tab' ), 9999999, 1 ); |
|
| 35 | + add_filter('give-settings_tabs_array', array($this, 'remove_license_tab'), 9999999, 1); |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * Filter the licenses settings. |
| 50 | 50 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
| 51 | 51 | */ |
| 52 | - $settings = apply_filters( 'give_settings_licenses', $settings ); |
|
| 52 | + $settings = apply_filters('give_settings_licenses', $settings); |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Filter the settings. |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param array $settings |
| 60 | 60 | */ |
| 61 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 61 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 62 | 62 | |
| 63 | 63 | // Output. |
| 64 | 64 | return $settings; |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return array |
| 76 | 76 | */ |
| 77 | - public function remove_license_tab( $tabs ) { |
|
| 77 | + public function remove_license_tab($tabs) { |
|
| 78 | 78 | /** |
| 79 | 79 | * Remove the license tab if no Give licensed addon |
| 80 | 80 | * is activated. |
| 81 | 81 | */ |
| 82 | - if ( ! $this->is_show_setting_page() ) { |
|
| 83 | - unset( $tabs['licenses'] ); |
|
| 82 | + if ( ! $this->is_show_setting_page()) { |
|
| 83 | + unset($tabs['licenses']); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $tabs; |
@@ -97,17 +97,17 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | private function is_show_setting_page() { |
| 99 | 99 | $licensed_addons = Give_License::get_licensed_addons(); |
| 100 | - $activated_plugins = get_option( 'active_plugins', array() ); |
|
| 100 | + $activated_plugins = get_option('active_plugins', array()); |
|
| 101 | 101 | |
| 102 | 102 | // Get list of network enabled plugin. |
| 103 | - if ( is_multisite() ) { |
|
| 104 | - $sitewide_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
| 105 | - $activated_plugins = ! empty( $activated_plugins ) |
|
| 106 | - ? array_merge( $sitewide_activated_plugins, $activated_plugins ) |
|
| 103 | + if (is_multisite()) { |
|
| 104 | + $sitewide_activated_plugins = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
| 105 | + $activated_plugins = ! empty($activated_plugins) |
|
| 106 | + ? array_merge($sitewide_activated_plugins, $activated_plugins) |
|
| 107 | 107 | : $sitewide_activated_plugins; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - return (bool) count( array_intersect( $activated_plugins, $licensed_addons ) ); |
|
| 110 | + return (bool) count(array_intersect($activated_plugins, $licensed_addons)); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -6,26 +6,26 @@ discard block |
||
| 6 | 6 | global $give_receipt_args, $payment; |
| 7 | 7 | |
| 8 | 8 | // Validation: Ensure $payment var is set. |
| 9 | -if ( empty( $payment ) ) { |
|
| 10 | - $payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0; |
|
| 9 | +if (empty($payment)) { |
|
| 10 | + $payment = ! empty($give_receipt_args['id']) ? get_post($give_receipt_args['id']) : 0; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | // Double-Validation: Check for $payment global. |
| 14 | -if ( empty( $payment ) ) { |
|
| 15 | - Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) ); |
|
| 14 | +if (empty($payment)) { |
|
| 15 | + Give()->notices->print_frontend_notice(__('The specified receipt ID appears to be invalid.', 'give')); |
|
| 16 | 16 | |
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $donation_id = $payment->ID; |
| 21 | -$donation_number = Give()->seq_donation_number->get_serial_code( $payment->ID ); |
|
| 22 | -$form_id = give_get_payment_meta( $donation_id, '_give_payment_form_id', true ); |
|
| 23 | -$donation = give_get_donation_form_title( $donation_id ); |
|
| 24 | -$user = give_get_payment_meta_user_info( $donation_id ); |
|
| 25 | -$email = give_get_payment_user_email( $donation_id ); |
|
| 21 | +$donation_number = Give()->seq_donation_number->get_serial_code($payment->ID); |
|
| 22 | +$form_id = give_get_payment_meta($donation_id, '_give_payment_form_id', true); |
|
| 23 | +$donation = give_get_donation_form_title($donation_id); |
|
| 24 | +$user = give_get_payment_meta_user_info($donation_id); |
|
| 25 | +$email = give_get_payment_user_email($donation_id); |
|
| 26 | 26 | $status = $payment->post_status; |
| 27 | -$status_label = give_get_payment_status( $payment, true ); |
|
| 28 | -$company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true ); |
|
| 27 | +$status_label = give_get_payment_status($payment, true); |
|
| 28 | +$company_name = give_get_payment_meta($donation_id, '_give_donation_company', true); |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Generate Donation Receipt Arguments. |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | * @since 1.8.8 |
| 37 | 37 | */ |
| 38 | 38 | $give_receipt_args['donation_receipt']['donor'] = array( |
| 39 | - 'name' => __( 'Donor', 'give' ), |
|
| 40 | - 'value' => $user['first_name'] . ' ' . $user['last_name'], |
|
| 39 | + 'name' => __('Donor', 'give'), |
|
| 40 | + 'value' => $user['first_name'].' '.$user['last_name'], |
|
| 41 | 41 | 'display' => $give_receipt_args['donor'], |
| 42 | 42 | ); |
| 43 | 43 | |
@@ -51,51 +51,51 @@ discard block |
||
| 51 | 51 | * @return bool show/hide company name in donation receipt page. |
| 52 | 52 | */ |
| 53 | 53 | $give_receipt_args['donation_receipt']['company_name'] = array( |
| 54 | - 'name' => __( 'Company Name', 'give' ), |
|
| 55 | - 'value' => esc_attr( $company_name ), |
|
| 54 | + 'name' => __('Company Name', 'give'), |
|
| 55 | + 'value' => esc_attr($company_name), |
|
| 56 | 56 | // Do not show company field if empty |
| 57 | - 'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'], |
|
| 57 | + 'display' => empty($company_name) ? false : $give_receipt_args['company_name'], |
|
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | $give_receipt_args['donation_receipt']['date'] = array( |
| 61 | - 'name' => __( 'Date', 'give' ), |
|
| 62 | - 'value' => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ), |
|
| 61 | + 'name' => __('Date', 'give'), |
|
| 62 | + 'value' => date_i18n(give_date_format(), strtotime(give_get_payment_completed_date($donation_id))), |
|
| 63 | 63 | 'display' => $give_receipt_args['date'], |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | $give_receipt_args['donation_receipt']['total_donation'] = array( |
| 67 | - 'name' => __( 'Total Donation', 'give' ), |
|
| 68 | - 'value' => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ), |
|
| 67 | + 'name' => __('Total Donation', 'give'), |
|
| 68 | + 'value' => give_donation_amount($donation_id, array('currency' => true, 'amount' => true, 'type' => 'receipt')), |
|
| 69 | 69 | 'display' => $give_receipt_args['price'], |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | $give_receipt_args['donation_receipt']['donation'] = array( |
| 73 | - 'name' => __( 'Donation', 'give' ), |
|
| 73 | + 'name' => __('Donation', 'give'), |
|
| 74 | 74 | 'value' => $donation, |
| 75 | 75 | 'display' => true, |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | 78 | $give_receipt_args['donation_receipt']['donation_status'] = array( |
| 79 | - 'name' => __( 'Donation Status', 'give' ), |
|
| 80 | - 'value' => esc_attr( $status_label ), |
|
| 79 | + 'name' => __('Donation Status', 'give'), |
|
| 80 | + 'value' => esc_attr($status_label), |
|
| 81 | 81 | 'display' => $give_receipt_args['payment_status'], |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | $give_receipt_args['donation_receipt']['donation_id'] = array( |
| 85 | - 'name' => __( 'Donation ID', 'give' ), |
|
| 85 | + 'name' => __('Donation ID', 'give'), |
|
| 86 | 86 | 'value' => $donation_number, |
| 87 | 87 | 'display' => $give_receipt_args['payment_id'], |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | $give_receipt_args['donation_receipt']['payment_key'] = array( |
| 91 | - 'name' => __( 'Payment Key', 'give' ), |
|
| 92 | - 'value' => get_post_meta( $donation_id, '_give_payment_purchase_key', true ), |
|
| 91 | + 'name' => __('Payment Key', 'give'), |
|
| 92 | + 'value' => get_post_meta($donation_id, '_give_payment_purchase_key', true), |
|
| 93 | 93 | 'display' => $give_receipt_args['payment_key'], |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | 96 | $give_receipt_args['donation_receipt']['payment_method'] = array( |
| 97 | - 'name' => __( 'Payment Method', 'give' ), |
|
| 98 | - 'value' => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ), |
|
| 97 | + 'name' => __('Payment Method', 'give'), |
|
| 98 | + 'value' => give_get_gateway_checkout_label(give_get_payment_gateway($donation_id)), |
|
| 99 | 99 | 'display' => $give_receipt_args['payment_method'], |
| 100 | 100 | ); |
| 101 | 101 | |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @since 1.8.8 |
| 112 | 112 | */ |
| 113 | -$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id ); |
|
| 113 | +$give_receipt_args['donation_receipt'] = apply_filters('give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id); |
|
| 114 | 114 | |
| 115 | 115 | // When the donation were made through offline donation, We won't show receipt and payment status though. |
| 116 | -if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) { |
|
| 116 | +if ('offline' === give_get_payment_gateway($payment->ID) && 'pending' === $status) { |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * Before the offline donation receipt content starts. |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | * @param Give_Payment $payment Donation payment object. |
| 124 | 124 | * @param array $give_receipt_args Receipt Arguments. |
| 125 | 125 | */ |
| 126 | - do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args ); |
|
| 126 | + do_action('give_receipt_before_offline_payment', $payment, $give_receipt_args); |
|
| 127 | 127 | ?> |
| 128 | - <h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2> |
|
| 129 | - <div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>"> |
|
| 128 | + <h2><?php echo apply_filters('give_receipt_offline_payment_heading', __('Your Donation is Almost Complete!', 'give')); ?></h2> |
|
| 129 | + <div id="give_donation_receipt" class="<?php echo esc_attr(apply_filters('give_receipt_offline_payment_classes', 'give_receipt_offline_payment')); ?>"> |
|
| 130 | 130 | <?php |
| 131 | 131 | // Instruction for offline donation. |
| 132 | - $offline_instruction = give_get_offline_payment_instruction( $form_id, true ); |
|
| 132 | + $offline_instruction = give_get_offline_payment_instruction($form_id, true); |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * Instruction for the offline donation. |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param Give_Payment $payment Payment object. |
| 141 | 141 | * @param integer $form_id Donation form id. |
| 142 | 142 | */ |
| 143 | - echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id ); |
|
| 143 | + echo apply_filters('give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id); |
|
| 144 | 144 | ?> |
| 145 | 145 | </div> |
| 146 | 146 | <?php |
@@ -152,52 +152,52 @@ discard block |
||
| 152 | 152 | * @param Give_Payment $payment Donation payment object. |
| 153 | 153 | * @param array $give_receipt_args Receipt Arguments. |
| 154 | 154 | */ |
| 155 | - do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args ); |
|
| 155 | + do_action('give_receipt_after_offline_payment', $payment, $give_receipt_args); |
|
| 156 | 156 | |
| 157 | 157 | return; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Show payment status notice based on shortcode attribute. |
| 161 | -if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 161 | +if (filter_var($give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN)) { |
|
| 162 | 162 | $notice_message = ''; |
| 163 | 163 | $notice_type = 'warning'; |
| 164 | 164 | |
| 165 | - switch ( $status ) { |
|
| 165 | + switch ($status) { |
|
| 166 | 166 | case 'publish': |
| 167 | - $notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' ); |
|
| 167 | + $notice_message = __('Payment Complete: Thank you for your donation.', 'give'); |
|
| 168 | 168 | $notice_type = 'success'; |
| 169 | 169 | break; |
| 170 | 170 | case 'pending': |
| 171 | - $notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' ); |
|
| 171 | + $notice_message = __('Payment Pending: Your donation is currently processing.', 'give'); |
|
| 172 | 172 | $notice_type = 'warning'; |
| 173 | 173 | break; |
| 174 | 174 | case 'refunded': |
| 175 | - $notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' ); |
|
| 175 | + $notice_message = __('Payment Refunded: Your donation has been refunded.', 'give'); |
|
| 176 | 176 | $notice_type = 'warning'; |
| 177 | 177 | break; |
| 178 | 178 | case 'preapproval': |
| 179 | - $notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' ); |
|
| 179 | + $notice_message = __('Payment Preapproved: Thank you for your donation.', 'give'); |
|
| 180 | 180 | $notice_type = 'warning'; |
| 181 | 181 | break; |
| 182 | 182 | case 'failed': |
| 183 | - $notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' ); |
|
| 183 | + $notice_message = __('Payment Failed: Please contact the site owner for assistance.', 'give'); |
|
| 184 | 184 | $notice_type = 'error'; |
| 185 | 185 | break; |
| 186 | 186 | case 'cancelled': |
| 187 | - $notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' ); |
|
| 187 | + $notice_message = __('Payment Cancelled: Your donation has been cancelled.', 'give'); |
|
| 188 | 188 | $notice_type = 'error'; |
| 189 | 189 | break; |
| 190 | 190 | case 'abandoned': |
| 191 | - $notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' ); |
|
| 191 | + $notice_message = __('Payment Abandoned: This donation has not been completed.', 'give'); |
|
| 192 | 192 | $notice_type = 'error'; |
| 193 | 193 | break; |
| 194 | 194 | case 'revoked': |
| 195 | - $notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' ); |
|
| 195 | + $notice_message = __('Payment Revoked: Please contact the site owner for assistance.', 'give'); |
|
| 196 | 196 | $notice_type = 'error'; |
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( ! empty( $notice_message ) ) { |
|
| 200 | + if ( ! empty($notice_message)) { |
|
| 201 | 201 | /** |
| 202 | 202 | * Filters payment status notice for receipts. |
| 203 | 203 | * |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param string $status Payment status. |
| 213 | 213 | * @param int $donation_id Donation ID. |
| 214 | 214 | */ |
| 215 | - echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id ); |
|
| 215 | + echo apply_filters('give_receipt_status_notice', Give()->notices->print_frontend_notice($notice_message, false, $notice_type), $id, $status, $donation_id); |
|
| 216 | 216 | } |
| 217 | 217 | }// End if(). |
| 218 | 218 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * @param object $payment The payment object. |
| 227 | 227 | * @param array $give_receipt_args Receipt_argument. |
| 228 | 228 | */ |
| 229 | -do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args ); |
|
| 229 | +do_action('give_payment_receipt_before_table', $payment, $give_receipt_args); |
|
| 230 | 230 | ?> |
| 231 | 231 | |
| 232 | 232 | <table id="give_donation_receipt" class="give-table"> |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | * @param object $payment The payment object. |
| 243 | 243 | * @param array $give_receipt_args Receipt_argument. |
| 244 | 244 | */ |
| 245 | - do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args ); |
|
| 245 | + do_action('give_payment_receipt_header_before', $payment, $give_receipt_args); |
|
| 246 | 246 | ?> |
| 247 | 247 | <tr> |
| 248 | 248 | <th scope="colgroup" colspan="2"> |
| 249 | - <span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span> |
|
| 249 | + <span class="give-receipt-thead-text"><?php esc_html_e('Donation Receipt', 'give') ?></span> |
|
| 250 | 250 | </th> |
| 251 | 251 | </tr> |
| 252 | 252 | <?php |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @param object $payment The payment object. |
| 261 | 261 | * @param array $give_receipt_args Receipt_argument. |
| 262 | 262 | */ |
| 263 | - do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args ); |
|
| 263 | + do_action('give_payment_receipt_header_after', $payment, $give_receipt_args); |
|
| 264 | 264 | ?> |
| 265 | 265 | </thead> |
| 266 | 266 | |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | * @param object $payment The payment object. |
| 277 | 277 | * @param array $give_receipt_args Receipt_argument. |
| 278 | 278 | */ |
| 279 | - do_action( 'give_payment_receipt_before', $payment, $give_receipt_args ); |
|
| 279 | + do_action('give_payment_receipt_before', $payment, $give_receipt_args); |
|
| 280 | 280 | ?> |
| 281 | 281 | |
| 282 | - <?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?> |
|
| 283 | - <?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
|
| 282 | + <?php foreach ($give_receipt_args['donation_receipt'] as $receipt_item) { ?> |
|
| 283 | + <?php if (filter_var($receipt_item['display'], FILTER_VALIDATE_BOOLEAN)) : ?> |
|
| 284 | 284 | <tr> |
| 285 | 285 | <td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td> |
| 286 | 286 | <td><?php echo $receipt_item['value']; ?></td> |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @param object $payment The payment object. |
| 300 | 300 | * @param array $give_receipt_args Receipt_argument. |
| 301 | 301 | */ |
| 302 | - do_action( 'give_payment_receipt_after', $payment, $give_receipt_args ); |
|
| 302 | + do_action('give_payment_receipt_after', $payment, $give_receipt_args); |
|
| 303 | 303 | ?> |
| 304 | 304 | </tbody> |
| 305 | 305 | </table> |
@@ -315,5 +315,5 @@ discard block |
||
| 315 | 315 | * @param object $payment The payment object. |
| 316 | 316 | * @param array $give_receipt_args Receipt_argument. |
| 317 | 317 | */ |
| 318 | -do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args ); |
|
| 318 | +do_action('give_payment_receipt_after_table', $payment, $give_receipt_args); |
|
| 319 | 319 | ?> |