@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /* @var WPDB $wpdb */ |
| 51 | 51 | global $wpdb; |
| 52 | 52 | |
| 53 | - $wpdb->formmeta = $this->table_name = $wpdb->prefix . 'give_formmeta'; |
|
| 53 | + $wpdb->formmeta = $this->table_name = $wpdb->prefix.'give_formmeta'; |
|
| 54 | 54 | $this->primary_key = 'meta_id'; |
| 55 | 55 | $this->version = '1.0'; |
| 56 | 56 | |
@@ -84,6 +84,6 @@ discard block |
||
| 84 | 84 | * @return bool |
| 85 | 85 | */ |
| 86 | 86 | protected function is_custom_meta_table_active() { |
| 87 | - return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ); |
|
| 87 | + return give_has_upgrade_completed('v20_move_metadata_into_new_table'); |
|
| 88 | 88 | } |
| 89 | 89 | } |
@@ -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_Logs' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Logs')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Logs. |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct() { |
| 36 | 36 | $this->id = 'logs'; |
| 37 | - $this->label = __( 'Logs', 'give' ); |
|
| 37 | + $this->label = __('Logs', 'give'); |
|
| 38 | 38 | |
| 39 | 39 | $this->default_tab = 'sales'; |
| 40 | 40 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function get_settings() { |
| 52 | 52 | // Get settings. |
| 53 | - $settings = apply_filters( 'give_settings_logs', array( |
|
| 53 | + $settings = apply_filters('give_settings_logs', array( |
|
| 54 | 54 | array( |
| 55 | 55 | 'id' => 'give_tools_logs', |
| 56 | 56 | 'type' => 'title', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | ), |
| 59 | 59 | array( |
| 60 | 60 | 'id' => 'logs', |
| 61 | - 'name' => __( 'Log', 'give' ), |
|
| 61 | + 'name' => __('Log', 'give'), |
|
| 62 | 62 | 'type' => 'logs', |
| 63 | 63 | |
| 64 | 64 | ), |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | 'type' => 'sectionend', |
| 68 | 68 | 'table_html' => false, |
| 69 | 69 | ), |
| 70 | - ) ); |
|
| 70 | + )); |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Filter the settings. |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param array $settings |
| 78 | 78 | */ |
| 79 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 79 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 80 | 80 | |
| 81 | 81 | // Output. |
| 82 | 82 | return $settings; |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function get_sections() { |
| 92 | 92 | $sections = array( |
| 93 | - 'sales' => __( 'Donations', 'give' ), |
|
| 94 | - 'gateway_errors' => __( 'Payment Errors', 'give' ), |
|
| 95 | - 'api_requests' => __( 'API Requests', 'give' ), |
|
| 96 | - 'updates' => __( 'Updates', 'give' ), |
|
| 93 | + 'sales' => __('Donations', 'give'), |
|
| 94 | + 'gateway_errors' => __('Payment Errors', 'give'), |
|
| 95 | + 'api_requests' => __('API Requests', 'give'), |
|
| 96 | + 'updates' => __('Updates', 'give'), |
|
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | - $sections = apply_filters( 'give_log_views', $sections ); |
|
| 99 | + $sections = apply_filters('give_log_views', $sections); |
|
| 100 | 100 | |
| 101 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
| 101 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_get_logs_tab() { |
| 24 | 24 | |
| 25 | - require( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php' ); |
|
| 25 | + require(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'); |
|
| 26 | 26 | |
| 27 | 27 | // Get current section. |
| 28 | 28 | $current_section = $_GET['section'] = give_get_current_setting_section(); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @since 1.0 |
| 34 | 34 | */ |
| 35 | - do_action( "give_logs_view_{$current_section}" ); |
|
| 35 | + do_action("give_logs_view_{$current_section}"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function give_logs_view_sales() { |
| 48 | 48 | |
| 49 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-sales-logs-list-table.php'; |
|
| 49 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-sales-logs-list-table.php'; |
|
| 50 | 50 | |
| 51 | 51 | $logs_table = new Give_Sales_Log_Table(); |
| 52 | 52 | $logs_table->prepare_items(); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @since 1.8.12 |
| 61 | 61 | */ |
| 62 | - do_action( 'give_logs_donations_top' ); |
|
| 62 | + do_action('give_logs_donations_top'); |
|
| 63 | 63 | |
| 64 | 64 | $logs_table->display(); ?> |
| 65 | 65 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @since 1.8.12 |
| 75 | 75 | */ |
| 76 | - do_action( 'give_logs_donations_bottom' ); |
|
| 76 | + do_action('give_logs_donations_bottom'); |
|
| 77 | 77 | ?> |
| 78 | 78 | |
| 79 | 79 | </div> |
| 80 | 80 | <?php |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -add_action( 'give_logs_view_sales', 'give_logs_view_sales' ); |
|
| 83 | +add_action('give_logs_view_sales', 'give_logs_view_sales'); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Update Logs |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | 92 | function give_logs_view_updates() { |
| 93 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-update-logs-list-table.php' ); |
|
| 93 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-update-logs-list-table.php'); |
|
| 94 | 94 | |
| 95 | 95 | $logs_table = new Give_Update_Log_Table(); |
| 96 | 96 | $logs_table->prepare_items(); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @since 2.0.1 |
| 105 | 105 | */ |
| 106 | - do_action( 'give_logs_update_top' ); |
|
| 106 | + do_action('give_logs_update_top'); |
|
| 107 | 107 | |
| 108 | 108 | $logs_table->display(); ?> |
| 109 | 109 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @since 2.0.1 |
| 119 | 119 | */ |
| 120 | - do_action( 'give_logs_update_bottom' ); |
|
| 120 | + do_action('give_logs_update_bottom'); |
|
| 121 | 121 | ?> |
| 122 | 122 | |
| 123 | 123 | </div> |
| 124 | 124 | <?php |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | -add_action( 'give_logs_view_updates', 'give_logs_view_updates' ); |
|
| 127 | +add_action('give_logs_view_updates', 'give_logs_view_updates'); |
|
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * Gateway Error Logs |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @return void |
| 136 | 136 | */ |
| 137 | 137 | function give_logs_view_gateway_errors() { |
| 138 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-gateway-error-logs-list-table.php' ); |
|
| 138 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-gateway-error-logs-list-table.php'); |
|
| 139 | 139 | |
| 140 | 140 | $logs_table = new Give_Gateway_Error_Log_Table(); |
| 141 | 141 | $logs_table->prepare_items(); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @since 1.8.12 |
| 150 | 150 | */ |
| 151 | - do_action( 'give_logs_payment_error_top' ); |
|
| 151 | + do_action('give_logs_payment_error_top'); |
|
| 152 | 152 | |
| 153 | 153 | $logs_table->display(); ?> |
| 154 | 154 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @since 1.8.12 |
| 164 | 164 | */ |
| 165 | - do_action( 'give_logs_payment_error_bottom' ); |
|
| 165 | + do_action('give_logs_payment_error_bottom'); |
|
| 166 | 166 | ?> |
| 167 | 167 | |
| 168 | 168 | </div> |
| 169 | 169 | <?php |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | -add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' ); |
|
| 172 | +add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors'); |
|
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * API Request Logs |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @return void |
| 181 | 181 | */ |
| 182 | 182 | function give_logs_view_api_requests() { |
| 183 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-api-requests-logs-list-table.php' ); |
|
| 183 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-api-requests-logs-list-table.php'); |
|
| 184 | 184 | |
| 185 | 185 | $logs_table = new Give_API_Request_Log_Table(); |
| 186 | 186 | $logs_table->prepare_items(); |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @since 1.0 |
| 192 | 192 | */ |
| 193 | - do_action( 'give_logs_api_requests_top' ); |
|
| 193 | + do_action('give_logs_api_requests_top'); |
|
| 194 | 194 | |
| 195 | - $logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' ); |
|
| 195 | + $logs_table->search_box(esc_html__('Search', 'give'), 'give-api-requests'); |
|
| 196 | 196 | $logs_table->display(); |
| 197 | 197 | ?> |
| 198 | 198 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @since 1.0 |
| 208 | 208 | */ |
| 209 | - do_action( 'give_logs_api_requests_bottom' ); |
|
| 209 | + do_action('give_logs_api_requests_bottom'); |
|
| 210 | 210 | } |
| 211 | -add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' ); |
|
| 211 | +add_action('give_logs_view_api_requests', 'give_logs_view_api_requests'); |
|
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | 214 | * Renders the log views drop down. |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | $current_section = give_get_current_setting_section(); |
| 221 | 221 | |
| 222 | 222 | // If there are not any event attach to action then do not show form. |
| 223 | - if ( ! has_action( 'give_log_view_actions' ) ) { |
|
| 223 | + if ( ! has_action('give_log_view_actions')) { |
|
| 224 | 224 | return; |
| 225 | 225 | } |
| 226 | 226 | ?> |
| 227 | - <form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs§ion=' . $current_section; ?>"> |
|
| 227 | + <form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs§ion='.$current_section; ?>"> |
|
| 228 | 228 | <?php |
| 229 | 229 | /** |
| 230 | 230 | * Fires after displaying the reports page views drop down. |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @since 1.0 |
| 235 | 235 | */ |
| 236 | - do_action( 'give_log_view_actions' ); |
|
| 236 | + do_action('give_log_view_actions'); |
|
| 237 | 237 | ?> |
| 238 | 238 | |
| 239 | 239 | <input type="hidden" name="post_type" value="give_forms"/> |
| 240 | 240 | <input type="hidden" name="page" value="give-tools"/> |
| 241 | 241 | <input type="hidden" name="tab" value="logs"/> |
| 242 | 242 | |
| 243 | - <?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 243 | + <?php submit_button(esc_html__('Apply', 'give'), 'secondary', 'submit', false); ?> |
|
| 244 | 244 | </form> |
| 245 | 245 | <?php |
| 246 | 246 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | -function give_tools_set_form_method( $method ) { |
|
| 255 | +function give_tools_set_form_method($method) { |
|
| 256 | 256 | return 'get'; |
| 257 | 257 | } |
| 258 | -add_filter( 'give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10 ); |
|
| 258 | +add_filter('give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10); |
|
@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /* @var WPDB $wpdb */ |
| 51 | 51 | global $wpdb; |
| 52 | 52 | |
| 53 | - $wpdb->logmeta = $this->table_name = $wpdb->prefix . 'give_logmeta'; |
|
| 53 | + $wpdb->logmeta = $this->table_name = $wpdb->prefix.'give_logmeta'; |
|
| 54 | 54 | $this->primary_key = 'meta_id'; |
| 55 | 55 | $this->version = '1.0'; |
| 56 | 56 | |
@@ -86,18 +86,18 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return bool |
| 88 | 88 | */ |
| 89 | - public function delete_row( $log_id = 0 ) { |
|
| 89 | + public function delete_row($log_id = 0) { |
|
| 90 | 90 | /* @var WPDB $wpdb */ |
| 91 | 91 | global $wpdb; |
| 92 | 92 | |
| 93 | 93 | // Row ID must be positive integer |
| 94 | - $log_id = absint( $log_id ); |
|
| 94 | + $log_id = absint($log_id); |
|
| 95 | 95 | |
| 96 | - if ( empty( $log_id ) ) { |
|
| 96 | + if (empty($log_id)) { |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) { |
|
| 100 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) { |
|
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return bool |
| 116 | 116 | */ |
| 117 | - protected function is_valid_post_type( $ID ) { |
|
| 117 | + protected function is_valid_post_type($ID) { |
|
| 118 | 118 | return $ID && true; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -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 | |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * Constructor. |
| 50 | 50 | */ |
| 51 | - public function __construct( $_step = 1 ) { |
|
| 52 | - parent::__construct( $_step ); |
|
| 51 | + public function __construct($_step = 1) { |
|
| 52 | + parent::__construct($_step); |
|
| 53 | 53 | |
| 54 | 54 | $this->is_writable = true; |
| 55 | 55 | } |
@@ -66,32 +66,32 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $args = array( |
| 68 | 68 | 'number' => $this->per_step, |
| 69 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
| 69 | + 'offset' => $this->per_step * ($this->step - 1), |
|
| 70 | 70 | 'orderby' => 'id', |
| 71 | 71 | 'order' => 'DESC', |
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | - $donors = Give()->donors->get_donors( $args ); |
|
| 74 | + $donors = Give()->donors->get_donors($args); |
|
| 75 | 75 | |
| 76 | - if ( $donors ) { |
|
| 76 | + if ($donors) { |
|
| 77 | 77 | |
| 78 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 78 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 79 | 79 | |
| 80 | - foreach ( $donors as $donor ) { |
|
| 80 | + foreach ($donors as $donor) { |
|
| 81 | 81 | |
| 82 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
| 82 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
| 83 | 83 | |
| 84 | 84 | $attached_args = array( |
| 85 | 85 | 'post__in' => $attached_payment_ids, |
| 86 | - 'number' => - 1, |
|
| 86 | + 'number' => -1, |
|
| 87 | 87 | 'status' => $allowed_payment_status, |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
| 90 | + $attached_payments = (array) give_get_payments($attached_args); |
|
| 91 | 91 | |
| 92 | 92 | $unattached_args = array( |
| 93 | 93 | 'post__not_in' => $attached_payment_ids, |
| 94 | - 'number' => - 1, |
|
| 94 | + 'number' => -1, |
|
| 95 | 95 | 'status' => $allowed_payment_status, |
| 96 | 96 | 'meta_query' => array( |
| 97 | 97 | array( |
@@ -102,29 +102,29 @@ discard block |
||
| 102 | 102 | ), |
| 103 | 103 | ); |
| 104 | 104 | |
| 105 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 105 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 106 | 106 | |
| 107 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 107 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 108 | 108 | |
| 109 | 109 | $purchase_value = 0.00; |
| 110 | 110 | $purchase_count = 0; |
| 111 | 111 | $payment_ids = array(); |
| 112 | 112 | |
| 113 | - if ( $payments ) { |
|
| 113 | + if ($payments) { |
|
| 114 | 114 | |
| 115 | - foreach ( $payments as $payment ) { |
|
| 115 | + foreach ($payments as $payment) { |
|
| 116 | 116 | |
| 117 | 117 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 118 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 118 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 119 | 119 | |
| 120 | - if ( true === $should_process_payment ) { |
|
| 120 | + if (true === $should_process_payment) { |
|
| 121 | 121 | |
| 122 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
| 123 | - $purchase_value += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
| 122 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
| 123 | + $purchase_value += (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
| 127 | - $purchase_count ++; |
|
| 126 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
| 127 | + $purchase_count++; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 135 | + $payment_ids = implode(',', $payment_ids); |
|
| 136 | 136 | |
| 137 | 137 | $donor_update_data = array( |
| 138 | 138 | 'purchase_count' => $purchase_count, |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | 'payment_ids' => $payment_ids, |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - $donor_instance = new Give_Donor( $donor->id ); |
|
| 144 | - $donor_instance->update( $donor_update_data ); |
|
| 143 | + $donor_instance = new Give_Donor($donor->id); |
|
| 144 | + $donor_instance->update($donor_update_data); |
|
| 145 | 145 | |
| 146 | 146 | }// End foreach(). |
| 147 | 147 | |
@@ -161,21 +161,21 @@ discard block |
||
| 161 | 161 | public function get_percentage_complete() { |
| 162 | 162 | |
| 163 | 163 | $args = array( |
| 164 | - 'number' => - 1, |
|
| 164 | + 'number' => -1, |
|
| 165 | 165 | 'orderby' => 'id', |
| 166 | 166 | 'order' => 'DESC', |
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | - $donors = Give()->donors->get_donors( $args ); |
|
| 170 | - $total = count( $donors ); |
|
| 169 | + $donors = Give()->donors->get_donors($args); |
|
| 170 | + $total = count($donors); |
|
| 171 | 171 | |
| 172 | 172 | $percentage = 100; |
| 173 | 173 | |
| 174 | - if ( $total > 0 ) { |
|
| 175 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 174 | + if ($total > 0) { |
|
| 175 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ( $percentage > 100 ) { |
|
| 178 | + if ($percentage > 100) { |
|
| 179 | 179 | $percentage = 100; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @param array $request The Form Data passed into the batch processing |
| 191 | 191 | */ |
| 192 | - public function set_properties( $request ) { |
|
| 192 | + public function set_properties($request) { |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -200,21 +200,21 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function process_step() { |
| 202 | 202 | |
| 203 | - if ( ! $this->can_export() ) { |
|
| 204 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 203 | + if ( ! $this->can_export()) { |
|
| 204 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array( |
|
| 205 | 205 | 'response' => 403, |
| 206 | - ) ); |
|
| 206 | + )); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $had_data = $this->get_data(); |
| 210 | 210 | |
| 211 | - if ( $had_data ) { |
|
| 211 | + if ($had_data) { |
|
| 212 | 212 | $this->done = false; |
| 213 | 213 | |
| 214 | 214 | return true; |
| 215 | 215 | } else { |
| 216 | 216 | $this->done = true; |
| 217 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
| 217 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
| 218 | 218 | |
| 219 | 219 | return false; |
| 220 | 220 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Constructor. |
| 48 | 48 | */ |
| 49 | - public function __construct( $_step = 1 ) { |
|
| 50 | - parent::__construct( $_step ); |
|
| 49 | + public function __construct($_step = 1) { |
|
| 50 | + parent::__construct($_step); |
|
| 51 | 51 | |
| 52 | 52 | $this->is_writable = true; |
| 53 | 53 | } |
@@ -62,40 +62,40 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function get_data() { |
| 64 | 64 | |
| 65 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 66 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
| 65 | + $donor = new Give_Donor($this->customer_id); |
|
| 66 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
| 67 | 67 | |
| 68 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 69 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 68 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 69 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 70 | 70 | |
| 71 | - if ( count( $step_items ) > 0 ) { |
|
| 72 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 71 | + if (count($step_items) > 0) { |
|
| 72 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 73 | 73 | $step_total = 0; |
| 74 | 74 | |
| 75 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 75 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
| 76 | 76 | |
| 77 | - foreach ( $step_items as $payment ) { |
|
| 78 | - $payment = get_post( $payment->ID ); |
|
| 77 | + foreach ($step_items as $payment) { |
|
| 78 | + $payment = get_post($payment->ID); |
|
| 79 | 79 | |
| 80 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 80 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 81 | 81 | |
| 82 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 82 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
| 83 | 83 | $missing_payments[] = $payment->ID; |
| 84 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
| 84 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
| 85 | 85 | |
| 86 | 86 | continue; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 90 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 90 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 91 | 91 | |
| 92 | - if ( true === $should_process_payment ) { |
|
| 92 | + if (true === $should_process_payment) { |
|
| 93 | 93 | |
| 94 | 94 | $found_payment_ids[] = $payment->ID; |
| 95 | 95 | |
| 96 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
| 97 | - $payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
| 98 | - $step_total += $payment_amount; |
|
| 96 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
| 97 | + $payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
| 98 | + $step_total += $payment_amount; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $updated_total = $pending_total + $step_total; |
| 106 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
| 107 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
| 106 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
| 107 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
| 108 | 108 | |
| 109 | 109 | return true; |
| 110 | 110 | } |
@@ -121,16 +121,16 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function get_percentage_complete() { |
| 123 | 123 | |
| 124 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 125 | - $total = count( $payments ); |
|
| 124 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 125 | + $total = count($payments); |
|
| 126 | 126 | |
| 127 | 127 | $percentage = 100; |
| 128 | 128 | |
| 129 | - if ( $total > 0 ) { |
|
| 130 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 129 | + if ($total > 0) { |
|
| 130 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if ( $percentage > 100 ) { |
|
| 133 | + if ($percentage > 100) { |
|
| 134 | 134 | $percentage = 100; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param array $request The Form Data passed into the batch processing |
| 146 | 146 | */ |
| 147 | - public function set_properties( $request ) { |
|
| 148 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 147 | + public function set_properties($request) { |
|
| 148 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -156,53 +156,53 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function process_step() { |
| 158 | 158 | |
| 159 | - if ( ! $this->can_export() ) { |
|
| 160 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 159 | + if ( ! $this->can_export()) { |
|
| 160 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $had_data = $this->get_data(); |
| 164 | 164 | |
| 165 | - if ( $had_data ) { |
|
| 165 | + if ($had_data) { |
|
| 166 | 166 | $this->done = false; |
| 167 | 167 | |
| 168 | 168 | return true; |
| 169 | 169 | } else { |
| 170 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 171 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
| 172 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 170 | + $donor = new Give_Donor($this->customer_id); |
|
| 171 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
| 172 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
| 173 | 173 | |
| 174 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
| 174 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
| 175 | 175 | |
| 176 | 176 | // Find non-existing payments (deleted) and total up the donation count |
| 177 | 177 | $purchase_count = 0; |
| 178 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 179 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 180 | - unset( $payment_ids[ $key ] ); |
|
| 178 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 179 | + if (in_array($payment_id, $removed_payments)) { |
|
| 180 | + unset($payment_ids[$key]); |
|
| 181 | 181 | continue; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $payment = get_post( $payment_id ); |
|
| 185 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
| 186 | - $purchase_count ++; |
|
| 184 | + $payment = get_post($payment_id); |
|
| 185 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
| 186 | + $purchase_count++; |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 190 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
| 191 | 191 | |
| 192 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 193 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 194 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
| 195 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 192 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 193 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
| 194 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
| 195 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 196 | 196 | |
| 197 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 198 | - $donor->update( array( |
|
| 197 | + $payment_ids = implode(',', $payment_ids); |
|
| 198 | + $donor->update(array( |
|
| 199 | 199 | 'payment_ids' => $payment_ids, |
| 200 | 200 | 'purchase_count' => $purchase_count, |
| 201 | 201 | 'purchase_value' => $pending_total, |
| 202 | - ) ); |
|
| 202 | + )); |
|
| 203 | 203 | |
| 204 | 204 | $this->done = true; |
| 205 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
| 205 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
| 206 | 206 | |
| 207 | 207 | return false; |
| 208 | 208 | } |
@@ -235,26 +235,26 @@ discard block |
||
| 235 | 235 | * @return void |
| 236 | 236 | */ |
| 237 | 237 | public function pre_fetch() { |
| 238 | - if ( $this->step === 1 ) { |
|
| 239 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 238 | + if ($this->step === 1) { |
|
| 239 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 240 | 240 | |
| 241 | 241 | // Before we start, let's zero out the customer's data |
| 242 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 243 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
| 242 | + $donor = new Give_Donor($this->customer_id); |
|
| 243 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
| 244 | 244 | |
| 245 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
| 245 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
| 246 | 246 | |
| 247 | 247 | $attached_args = array( |
| 248 | 248 | 'post__in' => $attached_payment_ids, |
| 249 | - 'number' => - 1, |
|
| 249 | + 'number' => -1, |
|
| 250 | 250 | 'status' => $allowed_payment_status, |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - $attached_payments = give_get_payments( $attached_args ); |
|
| 253 | + $attached_payments = give_get_payments($attached_args); |
|
| 254 | 254 | |
| 255 | 255 | $unattached_args = array( |
| 256 | 256 | 'post__not_in' => $attached_payment_ids, |
| 257 | - 'number' => - 1, |
|
| 257 | + 'number' => -1, |
|
| 258 | 258 | 'status' => $allowed_payment_status, |
| 259 | 259 | 'meta_query' => array( |
| 260 | 260 | array( |
@@ -264,11 +264,11 @@ discard block |
||
| 264 | 264 | ), |
| 265 | 265 | ); |
| 266 | 266 | |
| 267 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 267 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 268 | 268 | |
| 269 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 269 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 270 | 270 | |
| 271 | - $this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments ); |
|
| 271 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @return mixed Returns the data from the database |
| 283 | 283 | */ |
| 284 | - private function get_stored_data( $key ) { |
|
| 284 | + private function get_stored_data($key) { |
|
| 285 | 285 | global $wpdb; |
| 286 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 286 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 287 | 287 | |
| 288 | - if ( empty( $value ) ) { |
|
| 288 | + if (empty($value)) { |
|
| 289 | 289 | return false; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $maybe_json = json_decode( $value ); |
|
| 293 | - if ( ! is_null( $maybe_json ) ) { |
|
| 294 | - $value = json_decode( $value, true ); |
|
| 292 | + $maybe_json = json_decode($value); |
|
| 293 | + if ( ! is_null($maybe_json)) { |
|
| 294 | + $value = json_decode($value, true); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | return $value; |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return void |
| 309 | 309 | */ |
| 310 | - private function store_data( $key, $value ) { |
|
| 310 | + private function store_data($key, $value) { |
|
| 311 | 311 | global $wpdb; |
| 312 | 312 | |
| 313 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 313 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 314 | 314 | |
| 315 | 315 | $data = array( |
| 316 | 316 | 'option_name' => $key, |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | '%s', |
| 325 | 325 | ); |
| 326 | 326 | |
| 327 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 327 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @return void |
| 338 | 338 | */ |
| 339 | - private function delete_data( $key ) { |
|
| 339 | + private function delete_data($key) { |
|
| 340 | 340 | global $wpdb; |
| 341 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 341 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | } |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | 23 | function give_get_templates_dir() { |
| 24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
| 24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function give_get_templates_url() { |
| 34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
| 34 | + return GIVE_PLUGIN_URL.'templates'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -44,24 +44,24 @@ discard block |
||
| 44 | 44 | * @param string $template_path Template file path. Default is empty. |
| 45 | 45 | * @param string $default_path Default path. Default is empty. |
| 46 | 46 | */ |
| 47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 49 | - extract( $args ); |
|
| 47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 48 | + if ( ! empty($args) && is_array($args)) { |
|
| 49 | + extract($args); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $template_names = "{$template_name}.php"; |
| 53 | 53 | |
| 54 | - $located = give_get_locate_template( $template_names, $template_path, $default_path ); |
|
| 54 | + $located = give_get_locate_template($template_names, $template_path, $default_path); |
|
| 55 | 55 | |
| 56 | - if ( ! file_exists( $located ) ) { |
|
| 56 | + if ( ! file_exists($located)) { |
|
| 57 | 57 | /* translators: %s: the template */ |
| 58 | - Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
| 58 | + Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
| 59 | 59 | |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Allow 3rd party plugin filter template file from their plugin. |
| 64 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 64 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Fires in give template, before the file is included. |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * @param string $located Template file filter by 3rd party plugin. |
| 76 | 76 | * @param array $args Passed arguments. |
| 77 | 77 | */ |
| 78 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 78 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
| 79 | 79 | |
| 80 | - include( $located ); |
|
| 80 | + include($located); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Fires in give template, after the file is included. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $located Template file filter by 3rd party plugin. |
| 92 | 92 | * @param array $args Passed arguments. |
| 93 | 93 | */ |
| 94 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 94 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
| 110 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Fires in give template part, before the template part is retrieved. |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | * @param string $slug Template part file slug {slug}.php. |
| 120 | 120 | * @param string $name Template part file name {slug}-{name}.php. |
| 121 | 121 | */ |
| 122 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
| 122 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
| 123 | 123 | |
| 124 | 124 | // Setup possible parts |
| 125 | 125 | $templates = array(); |
| 126 | - if ( isset( $name ) ) { |
|
| 127 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 126 | + if (isset($name)) { |
|
| 127 | + $templates[] = $slug.'-'.$name.'.php'; |
|
| 128 | 128 | } |
| 129 | - $templates[] = $slug . '.php'; |
|
| 129 | + $templates[] = $slug.'.php'; |
|
| 130 | 130 | |
| 131 | 131 | // Allow template parts to be filtered |
| 132 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
| 132 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
| 133 | 133 | |
| 134 | 134 | // Return the part that is found |
| 135 | - return give_locate_template( $templates, $load, false ); |
|
| 135 | + return give_locate_template($templates, $load, false); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -153,37 +153,37 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @return string The template filename if one is located. |
| 155 | 155 | */ |
| 156 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
| 156 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
| 157 | 157 | // No file found yet |
| 158 | 158 | $located = false; |
| 159 | 159 | |
| 160 | 160 | // Try to find a template file |
| 161 | - foreach ( (array) $template_names as $template_name ) { |
|
| 161 | + foreach ((array) $template_names as $template_name) { |
|
| 162 | 162 | |
| 163 | 163 | // Continue if template is empty |
| 164 | - if ( empty( $template_name ) ) { |
|
| 164 | + if (empty($template_name)) { |
|
| 165 | 165 | continue; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Trim off any slashes from the template name |
| 169 | - $template_name = ltrim( $template_name, '/' ); |
|
| 169 | + $template_name = ltrim($template_name, '/'); |
|
| 170 | 170 | |
| 171 | 171 | // try locating this template file by looping through the template paths |
| 172 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
| 172 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
| 173 | 173 | |
| 174 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 175 | - $located = $template_path . $template_name; |
|
| 174 | + if (file_exists($template_path.$template_name)) { |
|
| 175 | + $located = $template_path.$template_name; |
|
| 176 | 176 | break; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ( $located ) { |
|
| 180 | + if ($located) { |
|
| 181 | 181 | break; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 186 | - load_template( $located, $require_once ); |
|
| 185 | + if ((true == $load) && ! empty($located)) { |
|
| 186 | + load_template($located, $require_once); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return $located; |
@@ -207,26 +207,26 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return string |
| 209 | 209 | */ |
| 210 | -function give_get_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 211 | - if ( ! $template_path ) { |
|
| 212 | - $template_path = give_get_theme_template_dir_name() . '/'; |
|
| 210 | +function give_get_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 211 | + if ( ! $template_path) { |
|
| 212 | + $template_path = give_get_theme_template_dir_name().'/'; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( ! $default_path ) { |
|
| 216 | - $default_path = GIVE_PLUGIN_DIR . 'templates/'; |
|
| 215 | + if ( ! $default_path) { |
|
| 216 | + $default_path = GIVE_PLUGIN_DIR.'templates/'; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Look within passed path within the theme - this is priority. |
| 220 | 220 | $template = locate_template( |
| 221 | 221 | array( |
| 222 | - trailingslashit( $template_path ) . $template_name, |
|
| 222 | + trailingslashit($template_path).$template_name, |
|
| 223 | 223 | $template_name, |
| 224 | 224 | ) |
| 225 | 225 | ); |
| 226 | 226 | |
| 227 | 227 | // Get default template/ |
| 228 | - if ( ! $template ) { |
|
| 229 | - $template = $default_path . $template_name; |
|
| 228 | + if ( ! $template) { |
|
| 229 | + $template = $default_path.$template_name; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @since 2.0.3 |
| 236 | 236 | */ |
| 237 | - return apply_filters( 'give_get_locate_template', $template, $template_name, $template_path ); |
|
| 237 | + return apply_filters('give_get_locate_template', $template, $template_name, $template_path); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -248,17 +248,17 @@ discard block |
||
| 248 | 248 | $template_dir = give_get_theme_template_dir_name(); |
| 249 | 249 | |
| 250 | 250 | $file_paths = array( |
| 251 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 252 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 251 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
| 252 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
| 253 | 253 | 100 => give_get_templates_dir(), |
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
| 256 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
| 257 | 257 | |
| 258 | 258 | // sort the file paths based on priority |
| 259 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 259 | + ksort($file_paths, SORT_NUMERIC); |
|
| 260 | 260 | |
| 261 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 261 | + return array_map('trailingslashit', $file_paths); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | 272 | function give_get_theme_template_dir_name() { |
| 273 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
| 273 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | * @return void |
| 281 | 281 | */ |
| 282 | 282 | function give_version_in_header() { |
| 283 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
| 283 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
| 286 | +add_action('wp_head', 'give_version_in_header'); |
|
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Determines if we're currently on the Donations History page. |
@@ -293,9 +293,9 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | function give_is_donation_history_page() { |
| 295 | 295 | |
| 296 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
| 296 | + $ret = is_page(give_get_option('history_page')); |
|
| 297 | 297 | |
| 298 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
| 298 | + return apply_filters('give_is_donation_history_page', $ret); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -307,25 +307,25 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return array Modified array of classes |
| 309 | 309 | */ |
| 310 | -function give_add_body_classes( $class ) { |
|
| 310 | +function give_add_body_classes($class) { |
|
| 311 | 311 | $classes = (array) $class; |
| 312 | 312 | |
| 313 | - if ( give_is_success_page() ) { |
|
| 313 | + if (give_is_success_page()) { |
|
| 314 | 314 | $classes[] = 'give-success'; |
| 315 | 315 | $classes[] = 'give-page'; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( give_is_failed_transaction_page() ) { |
|
| 318 | + if (give_is_failed_transaction_page()) { |
|
| 319 | 319 | $classes[] = 'give-failed-transaction'; |
| 320 | 320 | $classes[] = 'give-page'; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( give_is_donation_history_page() ) { |
|
| 323 | + if (give_is_donation_history_page()) { |
|
| 324 | 324 | $classes[] = 'give-donation-history'; |
| 325 | 325 | $classes[] = 'give-page'; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( give_is_test_mode() ) { |
|
| 328 | + if (give_is_test_mode()) { |
|
| 329 | 329 | $classes[] = 'give-test-mode'; |
| 330 | 330 | $classes[] = 'give-page'; |
| 331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | /* @var WP_Theme $current_theme */ |
| 335 | 335 | $current_theme = wp_get_theme(); |
| 336 | 336 | |
| 337 | - switch ( $current_theme->get_template() ) { |
|
| 337 | + switch ($current_theme->get_template()) { |
|
| 338 | 338 | |
| 339 | 339 | case 'Divi': |
| 340 | 340 | $classes[] = 'give-divi'; |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - return array_unique( $classes ); |
|
| 354 | + return array_unique($classes); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
| 357 | +add_filter('body_class', 'give_add_body_classes'); |
|
| 358 | 358 | |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -370,22 +370,22 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | * @return array |
| 372 | 372 | */ |
| 373 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
| 374 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
| 373 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
| 374 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
| 375 | 375 | return $classes; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
| 379 | 379 | |
| 380 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
| 381 | - unset( $classes[ $key ] ); |
|
| 380 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
| 381 | + unset($classes[$key]); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | return $classes; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | |
| 388 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
| 388 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * Get the placeholder image URL for forms etc |
@@ -395,74 +395,74 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | function give_get_placeholder_img_src() { |
| 397 | 397 | |
| 398 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
| 398 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
| 399 | 399 | |
| 400 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
| 400 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | /** |
| 405 | 405 | * Global |
| 406 | 406 | */ |
| 407 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
| 407 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
| 408 | 408 | |
| 409 | 409 | /** |
| 410 | 410 | * Output the start of the page wrapper. |
| 411 | 411 | */ |
| 412 | 412 | function give_output_content_wrapper() { |
| 413 | - give_get_template_part( 'global/wrapper-start' ); |
|
| 413 | + give_get_template_part('global/wrapper-start'); |
|
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
| 416 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Output the end of the page wrapper. |
| 420 | 420 | */ |
| 421 | 421 | function give_output_content_wrapper_end() { |
| 422 | - give_get_template_part( 'global/wrapper-end' ); |
|
| 422 | + give_get_template_part('global/wrapper-end'); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | 427 | * Single Give Form |
| 428 | 428 | */ |
| 429 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
| 429 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
| 430 | 430 | function give_left_sidebar_pre_wrap() { |
| 431 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
| 431 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
| 435 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
| 436 | 436 | function give_left_sidebar_post_wrap() { |
| 437 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
| 437 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
| 441 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
| 442 | 442 | function give_get_forms_sidebar() { |
| 443 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
| 443 | + give_get_template_part('single-give-form/sidebar'); |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
| 447 | +if ( ! function_exists('give_show_form_images')) { |
|
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | 450 | * Output the donation form featured image. |
| 451 | 451 | */ |
| 452 | 452 | function give_show_form_images() { |
| 453 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 454 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
| 453 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 454 | + give_get_template_part('single-give-form/featured-image'); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
| 459 | +if ( ! function_exists('give_template_single_title')) { |
|
| 460 | 460 | |
| 461 | 461 | /** |
| 462 | 462 | * Output the form title. |
| 463 | 463 | */ |
| 464 | 464 | function give_template_single_title() { |
| 465 | - give_get_template_part( 'single-give-form/title' ); |
|
| 465 | + give_get_template_part('single-give-form/title'); |
|
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * Conditional Functions |
| 471 | 471 | */ |
| 472 | 472 | |
| 473 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
| 473 | +if ( ! function_exists('is_give_form')) { |
|
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | 476 | * is_give_form |
@@ -482,11 +482,11 @@ discard block |
||
| 482 | 482 | * @return bool |
| 483 | 483 | */ |
| 484 | 484 | function is_give_form() { |
| 485 | - return is_singular( array( 'give_form' ) ); |
|
| 485 | + return is_singular(array('give_form')); |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
| 489 | +if ( ! function_exists('is_give_category')) { |
|
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | 492 | * is_give_category |
@@ -501,12 +501,12 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @return bool |
| 503 | 503 | */ |
| 504 | - function is_give_category( $term = '' ) { |
|
| 505 | - return is_tax( 'give_forms_category', $term ); |
|
| 504 | + function is_give_category($term = '') { |
|
| 505 | + return is_tax('give_forms_category', $term); |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
| 509 | +if ( ! function_exists('is_give_tag')) { |
|
| 510 | 510 | |
| 511 | 511 | /** |
| 512 | 512 | * is_give_tag |
@@ -521,12 +521,12 @@ discard block |
||
| 521 | 521 | * |
| 522 | 522 | * @return bool |
| 523 | 523 | */ |
| 524 | - function is_give_tag( $term = '' ) { |
|
| 525 | - return is_tax( 'give_forms_tag', $term ); |
|
| 524 | + function is_give_tag($term = '') { |
|
| 525 | + return is_tax('give_forms_tag', $term); |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
| 529 | +if ( ! function_exists('is_give_taxonomy')) { |
|
| 530 | 530 | |
| 531 | 531 | /** |
| 532 | 532 | * is_give_taxonomy |
@@ -538,6 +538,6 @@ discard block |
||
| 538 | 538 | * @return bool |
| 539 | 539 | */ |
| 540 | 540 | function is_give_taxonomy() { |
| 541 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
| 541 | + return is_tax(get_object_taxonomies('give_form')); |
|
| 542 | 542 | } |
| 543 | 543 | } |
@@ -202,8 +202,8 @@ |
||
| 202 | 202 | // 2. Processing percentage greater then 100% |
| 203 | 203 | if( ( |
| 204 | 204 | 101 < $resume_update['total_percentage'] ) || |
| 205 | - ( $give_updates->get_total_db_update_count() < $resume_update['update'] ) || |
|
| 206 | - ! in_array( $resume_update['update_info']['id'], $give_updates->get_update_ids() ) |
|
| 205 | + ( $give_updates->get_total_db_update_count() < $resume_update['update'] ) || |
|
| 206 | + ! in_array( $resume_update['update_info']['id'], $give_updates->get_update_ids() ) |
|
| 207 | 207 | ) { |
| 208 | 208 | if( ! $this->is_paused_process() ){ |
| 209 | 209 | $give_updates->__pause_db_update(true); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @category Class |
| 12 | 12 | * @author WordImpress |
| 13 | 13 | */ |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | * Updater will still run via cron job if this fails for any reason. |
| 32 | 32 | */ |
| 33 | 33 | public function dispatch() { |
| 34 | - if ( give_test_ajax_works() ) { |
|
| 34 | + if (give_test_ajax_works()) { |
|
| 35 | 35 | parent::dispatch(); |
| 36 | - } elseif ( wp_doing_ajax() ) { |
|
| 36 | + } elseif (wp_doing_ajax()) { |
|
| 37 | 37 | $this->maybe_handle(); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | 60 | public function has_queue() { |
| 61 | - return ( ! parent::is_queue_empty() ); |
|
| 61 | + return ( ! parent::is_queue_empty()); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | protected function lock_process() { |
| 76 | 76 | // Check if admin want to pause upgrade. |
| 77 | - if( get_option('give_pause_upgrade') ) { |
|
| 77 | + if (get_option('give_pause_upgrade')) { |
|
| 78 | 78 | self::flush_cache(); |
| 79 | 79 | |
| 80 | - delete_option( 'give_paused_batches' ); |
|
| 80 | + delete_option('give_paused_batches'); |
|
| 81 | 81 | |
| 82 | - Give_Updates::get_instance()->__pause_db_update( true ); |
|
| 82 | + Give_Updates::get_instance()->__pause_db_update(true); |
|
| 83 | 83 | |
| 84 | 84 | delete_option('give_pause_upgrade'); |
| 85 | 85 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @since 2.0.1 |
| 90 | 90 | */ |
| 91 | - do_action( 'give_pause_db_upgrade', Give_Updates::get_instance() ); |
|
| 91 | + do_action('give_pause_db_upgrade', Give_Updates::get_instance()); |
|
| 92 | 92 | |
| 93 | 93 | wp_die(); |
| 94 | 94 | } |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $this->start_time = time(); // Set start time of current process. |
| 98 | 98 | |
| 99 | - $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute |
|
| 100 | - $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); |
|
| 99 | + $lock_duration = (property_exists($this, 'queue_lock_time')) ? $this->queue_lock_time : 60; // 1 minute |
|
| 100 | + $lock_duration = apply_filters($this->identifier.'_queue_lock_time', $lock_duration); |
|
| 101 | 101 | |
| 102 | - set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); |
|
| 102 | + set_site_transient($this->identifier.'_process_lock', microtime(), $lock_duration); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | * and data exists in the queue. |
| 110 | 110 | */ |
| 111 | 111 | public function handle_cron_healthcheck() { |
| 112 | - if ( $this->is_process_running() || $this->is_paused_process() ) { |
|
| 112 | + if ($this->is_process_running() || $this->is_paused_process()) { |
|
| 113 | 113 | // Background process already running. |
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $this->is_queue_empty() ) { |
|
| 117 | + if ($this->is_queue_empty()) { |
|
| 118 | 118 | // No data to process. |
| 119 | 119 | $this->clear_scheduled_event(); |
| 120 | 120 | |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | * Schedule fallback event. |
| 129 | 129 | */ |
| 130 | 130 | protected function schedule_event() { |
| 131 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) && ! $this->is_paused_process() ) { |
|
| 132 | - wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
| 131 | + if ( ! wp_next_scheduled($this->cron_hook_identifier) && ! $this->is_paused_process()) { |
|
| 132 | + wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -145,13 +145,13 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return mixed |
| 147 | 147 | */ |
| 148 | - protected function task( $update ) { |
|
| 148 | + protected function task($update) { |
|
| 149 | 149 | // Pause upgrade immediately if admin pausing upgrades. |
| 150 | - if( $this->is_paused_process() ) { |
|
| 150 | + if ($this->is_paused_process()) { |
|
| 151 | 151 | wp_die(); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ( empty( $update ) ) { |
|
| 154 | + if (empty($update)) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | 'update_info' => $update, |
| 169 | 169 | 'step' => 1, |
| 170 | 170 | 'update' => 1, |
| 171 | - 'heading' => sprintf( 'Update %s of {update_count}', 1 ), |
|
| 171 | + 'heading' => sprintf('Update %s of {update_count}', 1), |
|
| 172 | 172 | 'percentage' => $give_updates->percentage, |
| 173 | 173 | 'total_percentage' => 0, |
| 174 | 174 | ) |
@@ -177,22 +177,22 @@ discard block |
||
| 177 | 177 | // Continuously skip update if previous update does not complete yet. |
| 178 | 178 | if ( |
| 179 | 179 | $resume_update['update_info']['id'] !== $update['id'] && |
| 180 | - ! give_has_upgrade_completed( $resume_update['update_info']['id'] ) |
|
| 180 | + ! give_has_upgrade_completed($resume_update['update_info']['id']) |
|
| 181 | 181 | ) { |
| 182 | 182 | return $update; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Set params. |
| 186 | 186 | $resume_update['update_info'] = $update; |
| 187 | - $give_updates->step = absint( $resume_update['step'] ); |
|
| 188 | - $give_updates->update = absint( $resume_update['update'] ); |
|
| 189 | - $is_parent_update_completed = $give_updates->is_parent_updates_completed( $update ); |
|
| 187 | + $give_updates->step = absint($resume_update['step']); |
|
| 188 | + $give_updates->update = absint($resume_update['update']); |
|
| 189 | + $is_parent_update_completed = $give_updates->is_parent_updates_completed($update); |
|
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | // Skip update if dependency update does not complete yet. |
| 193 | - if ( empty( $is_parent_update_completed ) ) { |
|
| 193 | + if (empty($is_parent_update_completed)) { |
|
| 194 | 194 | // @todo: set error when you have only one update with invalid dependency |
| 195 | - if ( ! is_null( $is_parent_update_completed ) ) { |
|
| 195 | + if ( ! is_null($is_parent_update_completed)) { |
|
| 196 | 196 | return $update; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -203,23 +203,23 @@ discard block |
||
| 203 | 203 | // Pause upgrade immediately if found following: |
| 204 | 204 | // 1. Running update number greater then total update count |
| 205 | 205 | // 2. Processing percentage greater then 100% |
| 206 | - if( ( |
|
| 206 | + if (( |
|
| 207 | 207 | 101 < $resume_update['total_percentage'] ) || |
| 208 | - ( $give_updates->get_total_db_update_count() < $resume_update['update'] ) || |
|
| 209 | - ! in_array( $resume_update['update_info']['id'], $give_updates->get_update_ids() ) |
|
| 208 | + ($give_updates->get_total_db_update_count() < $resume_update['update']) || |
|
| 209 | + ! in_array($resume_update['update_info']['id'], $give_updates->get_update_ids()) |
|
| 210 | 210 | ) { |
| 211 | - if( ! $this->is_paused_process() ){ |
|
| 211 | + if ( ! $this->is_paused_process()) { |
|
| 212 | 212 | $give_updates->__pause_db_update(true); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - update_option( 'give_upgrade_error', 1, false ); |
|
| 215 | + update_option('give_upgrade_error', 1, false); |
|
| 216 | 216 | |
| 217 | - $log_data = 'Update Task' . "\n"; |
|
| 217 | + $log_data = 'Update Task'."\n"; |
|
| 218 | 218 | $log_data .= "Total update count: {$give_updates->get_total_db_update_count()}\n"; |
| 219 | - $log_data .= 'Update IDs: ' . print_r( $give_updates->get_update_ids() , true ); |
|
| 220 | - $log_data .= 'Update: ' . print_r( $resume_update , true ); |
|
| 219 | + $log_data .= 'Update IDs: '.print_r($give_updates->get_update_ids(), true); |
|
| 220 | + $log_data .= 'Update: '.print_r($resume_update, true); |
|
| 221 | 221 | |
| 222 | - Give()->logs->add( 'Update Error', $log_data, 0, 'update' ); |
|
| 222 | + Give()->logs->add('Update Error', $log_data, 0, 'update'); |
|
| 223 | 223 | |
| 224 | 224 | wp_die(); |
| 225 | 225 | } |
@@ -227,25 +227,25 @@ discard block |
||
| 227 | 227 | // Disable cache. |
| 228 | 228 | Give_Cache::disable(); |
| 229 | 229 | |
| 230 | - try{ |
|
| 230 | + try { |
|
| 231 | 231 | // Run update. |
| 232 | - if ( is_array( $update['callback'] ) ) { |
|
| 232 | + if (is_array($update['callback'])) { |
|
| 233 | 233 | $update['callback'][0]->$update['callback'][1](); |
| 234 | 234 | } else { |
| 235 | 235 | $update['callback'](); |
| 236 | 236 | } |
| 237 | - } catch ( Exception $e ){ |
|
| 237 | + } catch (Exception $e) { |
|
| 238 | 238 | |
| 239 | - if( ! $this->is_paused_process() ){ |
|
| 239 | + if ( ! $this->is_paused_process()) { |
|
| 240 | 240 | $give_updates->__pause_db_update(true); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $log_data = 'Update Task' . "\n"; |
|
| 244 | - $log_data .= print_r( $resume_update, true ) . "\n\n"; |
|
| 243 | + $log_data = 'Update Task'."\n"; |
|
| 244 | + $log_data .= print_r($resume_update, true)."\n\n"; |
|
| 245 | 245 | $log_data .= "Error\n {$e->getMessage()}"; |
| 246 | 246 | |
| 247 | - Give()->logs->add( 'Update Error', $log_data, 0, 'update' ); |
|
| 248 | - update_option( 'give_upgrade_error', 1, false ); |
|
| 247 | + Give()->logs->add('Update Error', $log_data, 0, 'update'); |
|
| 248 | + update_option('give_upgrade_error', 1, false); |
|
| 249 | 249 | |
| 250 | 250 | wp_die(); |
| 251 | 251 | } |
@@ -253,21 +253,21 @@ discard block |
||
| 253 | 253 | // Set update info. |
| 254 | 254 | $doing_upgrade_args = array( |
| 255 | 255 | 'update_info' => $update, |
| 256 | - 'step' => ++ $give_updates->step, |
|
| 256 | + 'step' => ++$give_updates->step, |
|
| 257 | 257 | 'update' => $give_updates->update, |
| 258 | - 'heading' => sprintf( 'Update %s of %s', $give_updates->update, get_option( 'give_db_update_count' ) ), |
|
| 258 | + 'heading' => sprintf('Update %s of %s', $give_updates->update, get_option('give_db_update_count')), |
|
| 259 | 259 | 'percentage' => $give_updates->percentage, |
| 260 | 260 | 'total_percentage' => $give_updates->get_db_update_processing_percentage(), |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | 263 | // Cache upgrade. |
| 264 | - update_option( 'give_doing_upgrade', $doing_upgrade_args, false ); |
|
| 264 | + update_option('give_doing_upgrade', $doing_upgrade_args, false); |
|
| 265 | 265 | |
| 266 | 266 | // Enable cache. |
| 267 | 267 | Give_Cache::enable(); |
| 268 | 268 | |
| 269 | 269 | // Check if current update completed or not. |
| 270 | - if ( give_has_upgrade_completed( $update['id'] ) ) { |
|
| 270 | + if (give_has_upgrade_completed($update['id'])) { |
|
| 271 | 271 | return false; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -281,23 +281,23 @@ discard block |
||
| 281 | 281 | * performed, or, call parent::complete(). |
| 282 | 282 | */ |
| 283 | 283 | public function complete() { |
| 284 | - if ( $this->is_paused_process() ) { |
|
| 284 | + if ($this->is_paused_process()) { |
|
| 285 | 285 | return false; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | parent::complete(); |
| 289 | 289 | |
| 290 | - delete_option( 'give_pause_upgrade' ); |
|
| 291 | - delete_option( 'give_upgrade_error' ); |
|
| 292 | - delete_option( 'give_db_update_count' ); |
|
| 293 | - delete_option( 'give_doing_upgrade' ); |
|
| 294 | - add_option( 'give_show_db_upgrade_complete_notice', 1, '', false ); |
|
| 290 | + delete_option('give_pause_upgrade'); |
|
| 291 | + delete_option('give_upgrade_error'); |
|
| 292 | + delete_option('give_db_update_count'); |
|
| 293 | + delete_option('give_doing_upgrade'); |
|
| 294 | + add_option('give_show_db_upgrade_complete_notice', 1, '', false); |
|
| 295 | 295 | |
| 296 | 296 | // Flush cache. |
| 297 | - Give_Cache::flush_cache( true ); |
|
| 297 | + Give_Cache::flush_cache(true); |
|
| 298 | 298 | |
| 299 | - if ( $cache_keys = Give_Cache::get_options_like( '' ) ) { |
|
| 300 | - Give_Cache::delete( $cache_keys ); |
|
| 299 | + if ($cache_keys = Give_Cache::get_options_like('')) { |
|
| 300 | + Give_Cache::delete($cache_keys); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
@@ -307,19 +307,19 @@ discard block |
||
| 307 | 307 | * @return int |
| 308 | 308 | */ |
| 309 | 309 | protected function get_memory_limit() { |
| 310 | - if ( function_exists( 'ini_get' ) ) { |
|
| 311 | - $memory_limit = ini_get( 'memory_limit' ); |
|
| 310 | + if (function_exists('ini_get')) { |
|
| 311 | + $memory_limit = ini_get('memory_limit'); |
|
| 312 | 312 | } else { |
| 313 | 313 | // Sensible default. |
| 314 | 314 | $memory_limit = '128M'; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - if ( ! $memory_limit || '-1' === $memory_limit ) { |
|
| 317 | + if ( ! $memory_limit || '-1' === $memory_limit) { |
|
| 318 | 318 | // Unlimited, set to 32GB. |
| 319 | 319 | $memory_limit = '32000M'; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - return intval( $memory_limit ) * 1024 * 1024; |
|
| 322 | + return intval($memory_limit) * 1024 * 1024; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -332,17 +332,17 @@ discard block |
||
| 332 | 332 | // Don't lock up other requests while processing |
| 333 | 333 | session_write_close(); |
| 334 | 334 | |
| 335 | - if ( $this->is_process_running() || $this->is_paused_process() ) { |
|
| 335 | + if ($this->is_process_running() || $this->is_paused_process()) { |
|
| 336 | 336 | // Background process already running. |
| 337 | 337 | wp_die(); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( $this->is_queue_empty() ) { |
|
| 340 | + if ($this->is_queue_empty()) { |
|
| 341 | 341 | // No data to process. |
| 342 | 342 | wp_die(); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 345 | + check_ajax_referer($this->identifier, 'nonce'); |
|
| 346 | 346 | |
| 347 | 347 | $this->handle(); |
| 348 | 348 | |
@@ -361,36 +361,36 @@ discard block |
||
| 361 | 361 | do { |
| 362 | 362 | $batch = $this->get_batch(); |
| 363 | 363 | |
| 364 | - foreach ( $batch->data as $key => $value ) { |
|
| 365 | - $task = $this->task( $value ); |
|
| 364 | + foreach ($batch->data as $key => $value) { |
|
| 365 | + $task = $this->task($value); |
|
| 366 | 366 | |
| 367 | - if ( false !== $task ) { |
|
| 368 | - $batch->data[ $key ] = $task; |
|
| 367 | + if (false !== $task) { |
|
| 368 | + $batch->data[$key] = $task; |
|
| 369 | 369 | } else { |
| 370 | - unset( $batch->data[ $key ] ); |
|
| 370 | + unset($batch->data[$key]); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if ( $this->time_exceeded() || $this->memory_exceeded() ) { |
|
| 373 | + if ($this->time_exceeded() || $this->memory_exceeded()) { |
|
| 374 | 374 | // Batch limits reached. |
| 375 | 375 | break; |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Update or delete current batch. |
| 380 | - if ( ! empty( $batch->data ) ) { |
|
| 381 | - $this->update( $batch->key, $batch->data ); |
|
| 380 | + if ( ! empty($batch->data)) { |
|
| 381 | + $this->update($batch->key, $batch->data); |
|
| 382 | 382 | } else { |
| 383 | - $this->delete( $batch->key ); |
|
| 383 | + $this->delete($batch->key); |
|
| 384 | 384 | } |
| 385 | - } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); |
|
| 385 | + } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty()); |
|
| 386 | 386 | |
| 387 | 387 | $this->unlock_process(); |
| 388 | 388 | |
| 389 | 389 | // Start next batch or complete process. |
| 390 | - if ( ! $this->is_queue_empty() ) { |
|
| 390 | + if ( ! $this->is_queue_empty()) { |
|
| 391 | 391 | |
| 392 | 392 | // Dispatch only if ajax works. |
| 393 | - if( give_test_ajax_works() ) { |
|
| 393 | + if (give_test_ajax_works()) { |
|
| 394 | 394 | $this->dispatch(); |
| 395 | 395 | } |
| 396 | 396 | } else { |
@@ -408,13 +408,13 @@ discard block |
||
| 408 | 408 | * @access public |
| 409 | 409 | * @return bool |
| 410 | 410 | */ |
| 411 | - public function is_paused_process(){ |
|
| 411 | + public function is_paused_process() { |
|
| 412 | 412 | // Delete cache. |
| 413 | - wp_cache_delete( 'give_paused_batches', 'options' ); |
|
| 413 | + wp_cache_delete('give_paused_batches', 'options'); |
|
| 414 | 414 | |
| 415 | 415 | $paused_batches = get_option('give_paused_batches'); |
| 416 | 416 | |
| 417 | - return ! empty( $paused_batches ); |
|
| 417 | + return ! empty($paused_batches); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | |
@@ -460,8 +460,8 @@ discard block |
||
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | 462 | |
| 463 | - foreach ( $options as $option ) { |
|
| 464 | - wp_cache_delete( $option, 'options' ); |
|
| 463 | + foreach ($options as $option) { |
|
| 464 | + wp_cache_delete($option, 'options'); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | } |
@@ -505,7 +505,7 @@ |
||
| 505 | 505 | * |
| 506 | 506 | * @param string $main_file Plugin Main File. |
| 507 | 507 | * |
| 508 | - * @return bool|mixed|string |
|
| 508 | + * @return string |
|
| 509 | 509 | */ |
| 510 | 510 | public function get_plugin_folder_name( $main_file ) { |
| 511 | 511 | // Remove plugin file and get the Add-on's folder name only. |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly. |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if ( ! defined('ABSPATH')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | * 'testing' => false, // (required) Never leave as "true" in production!!! |
| 36 | 36 | * } |
| 37 | 37 | */ |
| 38 | - function __construct( $_banner_details ) { |
|
| 38 | + function __construct($_banner_details) { |
|
| 39 | 39 | global $give_addons, $pagenow; |
| 40 | 40 | |
| 41 | 41 | // Append add-on information to the global variable. |
| 42 | 42 | $give_addons[] = $_banner_details; |
| 43 | 43 | |
| 44 | - if ( 'plugins.php' === $pagenow ) { |
|
| 44 | + if ('plugins.php' === $pagenow) { |
|
| 45 | 45 | |
| 46 | 46 | // Get the current user. |
| 47 | 47 | $current_user = wp_get_current_user(); |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | $this->add_addon_activate_meta(); |
| 55 | 55 | |
| 56 | 56 | // Check if notice callback is already hooked. |
| 57 | - if ( ! $this->is_banner_notice_hooked() ) { |
|
| 57 | + if ( ! $this->is_banner_notice_hooked()) { |
|
| 58 | 58 | // If multiple add-on are activated then show activation banner in tab view. |
| 59 | - add_action( 'admin_notices', array( $this, 'addon_activation_banner_notices' ), 10 ); |
|
| 59 | + add_action('admin_notices', array($this, 'addon_activation_banner_notices'), 10); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string |
| 71 | 71 | */ |
| 72 | - public static function get_banner_user_meta_key( $addon_banner_key ) { |
|
| 73 | - $addon_slug = sanitize_text_field( $addon_banner_key ); |
|
| 72 | + public static function get_banner_user_meta_key($addon_banner_key) { |
|
| 73 | + $addon_slug = sanitize_text_field($addon_banner_key); |
|
| 74 | 74 | |
| 75 | 75 | return "give_addon_{$addon_slug}_active_by_user"; |
| 76 | 76 | } |
@@ -85,24 +85,24 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function init() { |
| 87 | 87 | // Get the current page to add the notice to |
| 88 | - add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) ); |
|
| 88 | + add_action('current_screen', array($this, 'give_addon_notice_ignore')); |
|
| 89 | 89 | |
| 90 | 90 | // Get the Give add-ons. |
| 91 | 91 | $give_addons = $this->get_plugin_file_names(); |
| 92 | 92 | |
| 93 | - if ( ! empty( $give_addons ) ) { |
|
| 93 | + if ( ! empty($give_addons)) { |
|
| 94 | 94 | |
| 95 | 95 | // Go through each of the add-on and hook deactivate action. |
| 96 | - foreach ( $give_addons as $addon_name => $give_addon ) { |
|
| 96 | + foreach ($give_addons as $addon_name => $give_addon) { |
|
| 97 | 97 | |
| 98 | 98 | // Testing? |
| 99 | - if ( true === $give_addon['testing'] ) { |
|
| 100 | - $nag_meta_key = 'give_addon_activation_ignore_' . $addon_name; |
|
| 101 | - delete_user_meta( $this->user_id, $nag_meta_key ); |
|
| 99 | + if (true === $give_addon['testing']) { |
|
| 100 | + $nag_meta_key = 'give_addon_activation_ignore_'.$addon_name; |
|
| 101 | + delete_user_meta($this->user_id, $nag_meta_key); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Add deactivate hook. |
| 105 | - add_action( 'deactivate_' . $give_addon['plugin_main_file'], array( $this, 'remove_addon_activate_meta' ) ); |
|
| 105 | + add_action('deactivate_'.$give_addon['plugin_main_file'], array($this, 'remove_addon_activate_meta')); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -118,29 +118,29 @@ discard block |
||
| 118 | 118 | global $give_addons; |
| 119 | 119 | |
| 120 | 120 | // Get recently activated plugins. |
| 121 | - $active_plugins = get_option( 'active_plugins' ); |
|
| 121 | + $active_plugins = get_option('active_plugins'); |
|
| 122 | 122 | |
| 123 | 123 | $file_names = array(); |
| 124 | 124 | |
| 125 | - if ( empty( $give_addons ) ) { |
|
| 125 | + if (empty($give_addons)) { |
|
| 126 | 126 | return $file_names; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Go through each addon and get the plugin file url. |
| 130 | - foreach ( $give_addons as $give_addon ) { |
|
| 130 | + foreach ($give_addons as $give_addon) { |
|
| 131 | 131 | $file_name = ''; |
| 132 | - $file_path = explode( '/plugins/', $give_addon['file'] ); |
|
| 133 | - if ( $file_path ) { |
|
| 134 | - $file_path = array_pop( $file_path ); |
|
| 135 | - $file_name = current( explode( '/', $file_path ) ); |
|
| 132 | + $file_path = explode('/plugins/', $give_addon['file']); |
|
| 133 | + if ($file_path) { |
|
| 134 | + $file_path = array_pop($file_path); |
|
| 135 | + $file_name = current(explode('/', $file_path)); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if ( ! empty( $file_name ) ) { |
|
| 139 | - foreach ( $active_plugins as $plugin ) { |
|
| 140 | - if ( false !== strpos( $plugin, $file_name ) ) { |
|
| 141 | - $add_on_key = sanitize_title( $give_addon['name'] ); |
|
| 138 | + if ( ! empty($file_name)) { |
|
| 139 | + foreach ($active_plugins as $plugin) { |
|
| 140 | + if (false !== strpos($plugin, $file_name)) { |
|
| 141 | + $add_on_key = sanitize_title($give_addon['name']); |
|
| 142 | 142 | $give_addon['plugin_main_file'] = $plugin; // Include plugin file. |
| 143 | - $file_names[ $add_on_key ] = $give_addon; |
|
| 143 | + $file_names[$add_on_key] = $give_addon; |
|
| 144 | 144 | break; |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -160,16 +160,16 @@ discard block |
||
| 160 | 160 | // Get all activated add-ons. |
| 161 | 161 | $give_addons = $this->get_plugin_file_names(); |
| 162 | 162 | |
| 163 | - if ( ! empty( $give_addons ) ) { |
|
| 163 | + if ( ! empty($give_addons)) { |
|
| 164 | 164 | |
| 165 | 165 | // Go through rach add-ons and add meta data. |
| 166 | - foreach ( $give_addons as $banner_addon_name => $addon ) { |
|
| 166 | + foreach ($give_addons as $banner_addon_name => $addon) { |
|
| 167 | 167 | |
| 168 | 168 | // User meta key. |
| 169 | - $user_id = __give_get_active_by_user_meta( $banner_addon_name ); |
|
| 169 | + $user_id = __give_get_active_by_user_meta($banner_addon_name); |
|
| 170 | 170 | |
| 171 | - if ( ! $user_id ) { |
|
| 172 | - update_option( self::get_banner_user_meta_key( $banner_addon_name ), $this->user_id, false ); |
|
| 171 | + if ( ! $user_id) { |
|
| 172 | + update_option(self::get_banner_user_meta_key($banner_addon_name), $this->user_id, false); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | global $wp_filter; |
| 187 | 187 | $notice_already_hooked = false; |
| 188 | 188 | |
| 189 | - if ( isset( $wp_filter['admin_notices']->callbacks[10] ) ) { |
|
| 189 | + if (isset($wp_filter['admin_notices']->callbacks[10])) { |
|
| 190 | 190 | // Get all of the hooks. |
| 191 | - $admin_notice_callbacks = array_keys( $wp_filter['admin_notices']->callbacks[10] ); |
|
| 191 | + $admin_notice_callbacks = array_keys($wp_filter['admin_notices']->callbacks[10]); |
|
| 192 | 192 | |
| 193 | - if ( ! empty( $admin_notice_callbacks ) ) { |
|
| 194 | - foreach ( $admin_notice_callbacks as $key ) { |
|
| 193 | + if ( ! empty($admin_notice_callbacks)) { |
|
| 194 | + foreach ($admin_notice_callbacks as $key) { |
|
| 195 | 195 | //If the key is found in your string, set $found to true |
| 196 | - if ( false !== strpos( $key, 'addon_activation_banner_notices' ) ) { |
|
| 196 | + if (false !== strpos($key, 'addon_activation_banner_notices')) { |
|
| 197 | 197 | $notice_already_hooked = true; |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | global $pagenow, $give_addons; |
| 213 | 213 | |
| 214 | 214 | // Bailout. |
| 215 | - if ( 'plugins.php' !== $pagenow ) { |
|
| 215 | + if ('plugins.php' !== $pagenow) { |
|
| 216 | 216 | return false; |
| 217 | 217 | } |
| 218 | 218 | |
@@ -224,55 +224,55 @@ discard block |
||
| 224 | 224 | $latest_addon = array(); |
| 225 | 225 | |
| 226 | 226 | // Get the plugin folder name, because many give-addon not sending proper plugin_file. |
| 227 | - if ( ! empty( $recent_activated ) ) { |
|
| 228 | - foreach ( $recent_activated as $recent_addon ) { |
|
| 227 | + if ( ! empty($recent_activated)) { |
|
| 228 | + foreach ($recent_activated as $recent_addon) { |
|
| 229 | 229 | // Get the add-on folder name. |
| 230 | - $latest_addon[] = substr( $recent_addon, 0, strpos( $recent_addon, '/' ) ); |
|
| 230 | + $latest_addon[] = substr($recent_addon, 0, strpos($recent_addon, '/')); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // Go through each of the give add-on. |
| 235 | - foreach ( $give_addons as $addon ) { |
|
| 236 | - $addon_sanitized_name = sanitize_title( $addon['name'] ); |
|
| 235 | + foreach ($give_addons as $addon) { |
|
| 236 | + $addon_sanitized_name = sanitize_title($addon['name']); |
|
| 237 | 237 | |
| 238 | 238 | // Get the add-on dismiss status. |
| 239 | - $add_on_state = get_user_meta( $this->user_id, "give_addon_activation_ignore_{$addon_sanitized_name}", true ); |
|
| 239 | + $add_on_state = get_user_meta($this->user_id, "give_addon_activation_ignore_{$addon_sanitized_name}", true); |
|
| 240 | 240 | |
| 241 | 241 | // Get the option key. |
| 242 | - $activate_by_user = (int) __give_get_active_by_user_meta( $addon_sanitized_name ); |
|
| 242 | + $activate_by_user = (int) __give_get_active_by_user_meta($addon_sanitized_name); |
|
| 243 | 243 | |
| 244 | 244 | // Remove plugin file and get the Add-on's folder name only. |
| 245 | - $file_path = $this->get_plugin_folder_name( $addon['file'] ); |
|
| 245 | + $file_path = $this->get_plugin_folder_name($addon['file']); |
|
| 246 | 246 | |
| 247 | 247 | // If add-on were never dismissed. |
| 248 | - if ( 'true' !== $add_on_state && $this->user_id === $activate_by_user ) { |
|
| 249 | - if ( ! empty( $latest_addon ) && ( in_array( $file_path, $latest_addon, true ) || empty( $latest_addon ) ) ) { |
|
| 248 | + if ('true' !== $add_on_state && $this->user_id === $activate_by_user) { |
|
| 249 | + if ( ! empty($latest_addon) && (in_array($file_path, $latest_addon, true) || empty($latest_addon))) { |
|
| 250 | 250 | $addon_to_display[] = $addon; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - if ( ! empty( $addon_to_display ) ) { |
|
| 255 | + if ( ! empty($addon_to_display)) { |
|
| 256 | 256 | ob_start(); |
| 257 | 257 | |
| 258 | 258 | // Output inline styles here because there's no reason |
| 259 | 259 | // to enqueued them after the alert is dismissed. |
| 260 | 260 | $this->print_css_js(); |
| 261 | 261 | ?> |
| 262 | - <div class="<?php echo ( 1 !== count( $addon_to_display ) ) ? 'give-alert-tab-wrapper' : ''; ?> updated give-addon-alert give-notice"> |
|
| 262 | + <div class="<?php echo (1 !== count($addon_to_display)) ? 'give-alert-tab-wrapper' : ''; ?> updated give-addon-alert give-notice"> |
|
| 263 | 263 | <?php |
| 264 | 264 | // If multiple add-on are activated. |
| 265 | - if ( 1 !== count( $addon_to_display ) ) { |
|
| 265 | + if (1 !== count($addon_to_display)) { |
|
| 266 | 266 | ?> |
| 267 | 267 | <div class="give-vertical-tab"> |
| 268 | 268 | <div class="give-addon-tab-list"> |
| 269 | 269 | <ul class="give-alert-addon-list"> |
| 270 | 270 | <?php |
| 271 | 271 | $is_first = true; |
| 272 | - foreach ( $addon_to_display as $banner ) { |
|
| 272 | + foreach ($addon_to_display as $banner) { |
|
| 273 | 273 | ?> |
| 274 | - <li class="give-tab-list<?php echo ( true === $is_first ) ? ' active' : ''; ?>" id="give-addon-<?php echo esc_attr( basename( $banner['file'], '.php' ) ); ?>"> |
|
| 275 | - <a href="#"><?php echo esc_html( $banner['name'] ); ?></a> |
|
| 274 | + <li class="give-tab-list<?php echo (true === $is_first) ? ' active' : ''; ?>" id="give-addon-<?php echo esc_attr(basename($banner['file'], '.php')); ?>"> |
|
| 275 | + <a href="#"><?php echo esc_html($banner['name']); ?></a> |
|
| 276 | 276 | </li> |
| 277 | 277 | <?php |
| 278 | 278 | $is_first = false; |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | </ul> |
| 283 | 283 | </div> |
| 284 | 284 | <div class="give-right-side-block"> |
| 285 | - <?php foreach ( $addon_to_display as $banner ) : ?> |
|
| 286 | - <div class="give-tab-details <?php echo ( true === $is_first ) ? ' active' : ''; ?> " id="give-addon-<?php echo esc_attr( basename( $banner['file'], '.php' ) ); ?>"> |
|
| 285 | + <?php foreach ($addon_to_display as $banner) : ?> |
|
| 286 | + <div class="give-tab-details <?php echo (true === $is_first) ? ' active' : ''; ?> " id="give-addon-<?php echo esc_attr(basename($banner['file'], '.php')); ?>"> |
|
| 287 | 287 | <?php |
| 288 | 288 | // Render single add banner. |
| 289 | - $this->render_single_addon_banner( $banner, false ); |
|
| 289 | + $this->render_single_addon_banner($banner, false); |
|
| 290 | 290 | $is_first = false; |
| 291 | 291 | ?> |
| 292 | 292 | </div> |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | </div> |
| 296 | 296 | <?php |
| 297 | 297 | } else { |
| 298 | - $this->render_single_addon_banner( $addon_to_display[0], true ); |
|
| 298 | + $this->render_single_addon_banner($addon_to_display[0], true); |
|
| 299 | 299 | } |
| 300 | 300 | ?> |
| 301 | 301 | </div> |
@@ -303,12 +303,12 @@ discard block |
||
| 303 | 303 | $notice_html = ob_get_clean(); |
| 304 | 304 | |
| 305 | 305 | // Register notice. |
| 306 | - Give()->notices->register_notice( array( |
|
| 306 | + Give()->notices->register_notice(array( |
|
| 307 | 307 | 'id' => 'give_add_on_activation_notice', |
| 308 | 308 | 'type' => 'updated', |
| 309 | 309 | 'description_html' => $notice_html, |
| 310 | 310 | 'show' => true, |
| 311 | - ) ); |
|
| 311 | + )); |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @param array $banner_arr Banner options. |
| 321 | 321 | * @param bool $is_single Is single. |
| 322 | 322 | */ |
| 323 | - private function render_single_addon_banner( $banner_arr, $is_single ) { |
|
| 323 | + private function render_single_addon_banner($banner_arr, $is_single) { |
|
| 324 | 324 | // Get all give add-on. |
| 325 | 325 | $give_addons = give_get_plugins(); |
| 326 | 326 | |
@@ -328,80 +328,80 @@ discard block |
||
| 328 | 328 | $plugin_file = $banner_arr['file']; |
| 329 | 329 | |
| 330 | 330 | // Get the plugin main file. |
| 331 | - foreach ( $give_addons as $main_file => $addon ) { |
|
| 331 | + foreach ($give_addons as $main_file => $addon) { |
|
| 332 | 332 | // Plugin should be activated. |
| 333 | - if ( ! is_plugin_active( $main_file ) ) { |
|
| 333 | + if ( ! is_plugin_active($main_file)) { |
|
| 334 | 334 | continue; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | if ( |
| 338 | - isset( $banner_arr['name'] ) |
|
| 338 | + isset($banner_arr['name']) |
|
| 339 | 339 | && 'add-on' === $addon['Type'] |
| 340 | - && $this->get_plugin_folder_name( $main_file ) === $this->get_plugin_folder_name( $plugin_file ) |
|
| 340 | + && $this->get_plugin_folder_name($main_file) === $this->get_plugin_folder_name($plugin_file) |
|
| 341 | 341 | ) { |
| 342 | - $plugin_file = WP_PLUGIN_DIR . '/' . $main_file; |
|
| 342 | + $plugin_file = WP_PLUGIN_DIR.'/'.$main_file; |
|
| 343 | 343 | break; |
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // Create dismiss URL. |
| 348 | 348 | $dismiss_url = $is_single |
| 349 | - ? admin_url( 'plugins.php?give_addon_activation_ignore=1&give_addon=' . sanitize_title( $banner_arr['name'] ) ) |
|
| 350 | - : admin_url( 'plugins.php?give_addon_activation_ignore=1&give_addon=all' ); |
|
| 349 | + ? admin_url('plugins.php?give_addon_activation_ignore=1&give_addon='.sanitize_title($banner_arr['name'])) |
|
| 350 | + : admin_url('plugins.php?give_addon_activation_ignore=1&give_addon=all'); |
|
| 351 | 351 | |
| 352 | 352 | // Get the add-on details. |
| 353 | - $plugin_data = get_plugin_data( $plugin_file ); |
|
| 353 | + $plugin_data = get_plugin_data($plugin_file); |
|
| 354 | 354 | ?> |
| 355 | - <img src="<?php echo esc_url( GIVE_PLUGIN_URL . 'assets/dist/images/give-icon-full-circle.svg' ); ?>" class="give-logo" /> |
|
| 355 | + <img src="<?php echo esc_url(GIVE_PLUGIN_URL.'assets/dist/images/give-icon-full-circle.svg'); ?>" class="give-logo" /> |
|
| 356 | 356 | <div class="give-alert-message"> |
| 357 | 357 | <h3> |
| 358 | 358 | <?php |
| 359 | 359 | printf( |
| 360 | 360 | /* translators: %s: Add-on name */ |
| 361 | 361 | '%s<span>%s</span>', |
| 362 | - __( 'New Give Add-on Activated: ', 'give' ), |
|
| 363 | - esc_html( $banner_arr['name'] ) |
|
| 362 | + __('New Give Add-on Activated: ', 'give'), |
|
| 363 | + esc_html($banner_arr['name']) |
|
| 364 | 364 | ); |
| 365 | 365 | ?> |
| 366 | 366 | </h3> |
| 367 | - <a href="<?php echo esc_url( $dismiss_url ); ?>" class="dismiss"> |
|
| 367 | + <a href="<?php echo esc_url($dismiss_url); ?>" class="dismiss"> |
|
| 368 | 368 | <span class="dashicons dashicons-dismiss"></span> |
| 369 | 369 | </a> |
| 370 | 370 | <div class="alert-actions"> |
| 371 | 371 | <?php |
| 372 | 372 | //Point them to your settings page. |
| 373 | - if ( ! empty( $plugin_data['Description'] ) ) { |
|
| 373 | + if ( ! empty($plugin_data['Description'])) { |
|
| 374 | 374 | ?> |
| 375 | 375 | <span class="give-addon-description"> |
| 376 | - <em><?php echo esc_html( strip_tags( $plugin_data['Description'] ) ); ?></em></span><br /> |
|
| 376 | + <em><?php echo esc_html(strip_tags($plugin_data['Description'])); ?></em></span><br /> |
|
| 377 | 377 | <?php |
| 378 | 378 | } |
| 379 | - if ( isset( $banner_arr['settings_url'] ) ) { |
|
| 379 | + if (isset($banner_arr['settings_url'])) { |
|
| 380 | 380 | printf( |
| 381 | 381 | '<a href="%s"><span class="dashicons dashicons-admin-settings"></span>%s</a>', |
| 382 | - esc_url( $banner_arr['settings_url'] ), |
|
| 383 | - esc_html__( 'Go to Settings', 'give' ) |
|
| 382 | + esc_url($banner_arr['settings_url']), |
|
| 383 | + esc_html__('Go to Settings', 'give') |
|
| 384 | 384 | ); |
| 385 | 385 | } |
| 386 | 386 | // Show them how to configure the Addon. |
| 387 | - if ( isset( $banner_arr['documentation_url'] ) ) { |
|
| 387 | + if (isset($banner_arr['documentation_url'])) { |
|
| 388 | 388 | printf( |
| 389 | 389 | '<a href="%s" target="_blank"><span class="dashicons dashicons-media-text"></span>%s</a>', |
| 390 | - esc_url( $banner_arr['documentation_url'] ), |
|
| 390 | + esc_url($banner_arr['documentation_url']), |
|
| 391 | 391 | sprintf( |
| 392 | 392 | /* translators: %s: Add-on name */ |
| 393 | - esc_html__( 'Documentation: %s Add-on', 'give' ), |
|
| 394 | - esc_html( $banner_arr['name'] ) |
|
| 393 | + esc_html__('Documentation: %s Add-on', 'give'), |
|
| 394 | + esc_html($banner_arr['name']) |
|
| 395 | 395 | ) |
| 396 | 396 | ); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | //Let them signup for plugin updates |
| 400 | - if ( isset( $banner_arr['support_url'] ) ) { |
|
| 400 | + if (isset($banner_arr['support_url'])) { |
|
| 401 | 401 | printf( |
| 402 | 402 | '<a href="%s" target="_blank"><span class="dashicons dashicons-sos"></span>%s</a>', |
| 403 | - esc_url( $banner_arr['support_url'] ), |
|
| 404 | - esc_html__( 'Get Support', 'give' ) |
|
| 403 | + esc_url($banner_arr['support_url']), |
|
| 404 | + esc_html__('Get Support', 'give') |
|
| 405 | 405 | ); |
| 406 | 406 | } |
| 407 | 407 | ?> |
@@ -424,30 +424,30 @@ discard block |
||
| 424 | 424 | * See here: http://codex.wordpress.org/Function_Reference/add_user_meta |
| 425 | 425 | */ |
| 426 | 426 | if ( |
| 427 | - isset( $_GET['give_addon'], $_GET['give_addon_activation_ignore'] ) |
|
| 427 | + isset($_GET['give_addon'], $_GET['give_addon_activation_ignore']) |
|
| 428 | 428 | && '1' === $_GET['give_addon_activation_ignore'] |
| 429 | 429 | ) { |
| 430 | 430 | // Get the value of the 'give_addon' query string. |
| 431 | - $addon_query_arg = sanitize_text_field( wp_unslash( $_GET['give_addon'] ) ); |
|
| 431 | + $addon_query_arg = sanitize_text_field(wp_unslash($_GET['give_addon'])); |
|
| 432 | 432 | $deactivated_addons = array(); |
| 433 | 433 | |
| 434 | 434 | // If All add-on requested to dismiss. |
| 435 | - if ( 'all' === $addon_query_arg ) { |
|
| 435 | + if ('all' === $addon_query_arg) { |
|
| 436 | 436 | // Get all activated add-ons. |
| 437 | 437 | $give_addons = $this->get_plugin_file_names(); |
| 438 | 438 | |
| 439 | - if ( ! empty( $give_addons ) ) { |
|
| 440 | - $deactivated_addons = array_keys( $give_addons ); |
|
| 439 | + if ( ! empty($give_addons)) { |
|
| 440 | + $deactivated_addons = array_keys($give_addons); |
|
| 441 | 441 | } |
| 442 | 442 | } else { |
| 443 | 443 | // Store the addon to deactivate. |
| 444 | 444 | $deactivated_addons[] = $addon_query_arg; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if ( ! empty( $deactivated_addons ) ) { |
|
| 448 | - foreach ( $deactivated_addons as $addon ) { |
|
| 447 | + if ( ! empty($deactivated_addons)) { |
|
| 448 | + foreach ($deactivated_addons as $addon) { |
|
| 449 | 449 | // Record it user meta. |
| 450 | - add_user_meta( $this->user_id, "give_addon_activation_ignore_{$addon}", 'true', true ); |
|
| 450 | + add_user_meta($this->user_id, "give_addon_activation_ignore_{$addon}", 'true', true); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | } |
@@ -462,26 +462,26 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | public function remove_addon_activate_meta() { |
| 464 | 464 | // Get the hook name and then grab the plugin file from it. |
| 465 | - $plugin_file = str_replace( 'deactivate_', '', current_action() ); |
|
| 465 | + $plugin_file = str_replace('deactivate_', '', current_action()); |
|
| 466 | 466 | |
| 467 | 467 | // Get all activated add-ons. |
| 468 | 468 | $give_addons = $this->get_plugin_file_names(); |
| 469 | 469 | |
| 470 | - if ( ! empty( $give_addons ) ) { |
|
| 471 | - foreach ( $give_addons as $banner_addon_name => $addon ) { |
|
| 472 | - if ( $plugin_file === $addon['plugin_main_file'] ) { |
|
| 470 | + if ( ! empty($give_addons)) { |
|
| 471 | + foreach ($give_addons as $banner_addon_name => $addon) { |
|
| 472 | + if ($plugin_file === $addon['plugin_main_file']) { |
|
| 473 | 473 | |
| 474 | 474 | // Get the user meta key. |
| 475 | - $user_id = (int) __give_get_active_by_user_meta( $banner_addon_name ); |
|
| 475 | + $user_id = (int) __give_get_active_by_user_meta($banner_addon_name); |
|
| 476 | 476 | |
| 477 | - if ( $user_id ) { |
|
| 477 | + if ($user_id) { |
|
| 478 | 478 | // Get user meta for this add-on. |
| 479 | 479 | $nag_meta_key = "give_addon_activation_ignore_{$banner_addon_name}"; |
| 480 | 480 | |
| 481 | 481 | // Delete plugin activation option key. |
| 482 | - delete_option( self::get_banner_user_meta_key( $banner_addon_name ) ); |
|
| 482 | + delete_option(self::get_banner_user_meta_key($banner_addon_name)); |
|
| 483 | 483 | // Delete user meta of plugin activation. |
| 484 | - delete_user_meta( $user_id, $nag_meta_key ); |
|
| 484 | + delete_user_meta($user_id, $nag_meta_key); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | } |
@@ -508,11 +508,11 @@ discard block |
||
| 508 | 508 | * |
| 509 | 509 | * @return bool|mixed|string |
| 510 | 510 | */ |
| 511 | - public function get_plugin_folder_name( $main_file ) { |
|
| 511 | + public function get_plugin_folder_name($main_file) { |
|
| 512 | 512 | // Remove plugin file and get the Add-on's folder name only. |
| 513 | - $file_path = explode( '/plugins/', $main_file ); |
|
| 514 | - $addon_file_path = array_pop( $file_path ); |
|
| 515 | - $addon_file_path = substr( $addon_file_path, 0, strpos( $addon_file_path, '/' ) ); |
|
| 513 | + $file_path = explode('/plugins/', $main_file); |
|
| 514 | + $addon_file_path = array_pop($file_path); |
|
| 515 | + $addon_file_path = substr($addon_file_path, 0, strpos($addon_file_path, '/')); |
|
| 516 | 516 | |
| 517 | 517 | return $addon_file_path; |
| 518 | 518 | } |