@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -80,104 +80,102 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function get_data() { |
| 82 | 82 | |
| 83 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
| 84 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 85 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
| 86 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 83 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
| 84 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 85 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
| 86 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 87 | 87 | |
| 88 | - if ( false === $totals ) { |
|
| 88 | + if (false === $totals) { |
|
| 89 | 89 | $totals = array(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if ( false === $payment_items ) { |
|
| 92 | + if (false === $payment_items) { |
|
| 93 | 93 | $payment_items = array(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if ( false === $processed_payments ) { |
|
| 96 | + if (false === $processed_payments) { |
|
| 97 | 97 | $processed_payments = array(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
| 100 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
| 101 | 101 | |
| 102 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
| 102 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
| 103 | 103 | |
| 104 | - if ( false === $payments ) { |
|
| 105 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 104 | + if (false === $payments) { |
|
| 105 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 106 | 106 | 'post_parent__in' => $all_forms, |
| 107 | 107 | 'number' => $this->per_step, |
| 108 | 108 | 'status' => 'publish', |
| 109 | 109 | 'paged' => $this->step, |
| 110 | 110 | 'output' => 'payments', |
| 111 | - ) ); |
|
| 111 | + )); |
|
| 112 | 112 | |
| 113 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 113 | + $payments_query = new Give_Payments_Query($args); |
|
| 114 | 114 | $payments = $payments_query->get_payments(); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $payments ) { |
|
| 117 | + if ($payments) { |
|
| 118 | 118 | |
| 119 | 119 | //Loop through payments |
| 120 | - foreach ( $payments as $payment ) { |
|
| 120 | + foreach ($payments as $payment) { |
|
| 121 | 121 | |
| 122 | 122 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
| 123 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
| 123 | + if (in_array($payment->ID, $processed_payments)) { |
|
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // Verify accepted status |
| 128 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 128 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 129 | 129 | $processed_payments[] = $payment->ID; |
| 130 | 130 | continue; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $payment_item = $payment_items[ $payment->ID ]; |
|
| 133 | + $payment_item = $payment_items[$payment->ID]; |
|
| 134 | 134 | |
| 135 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
| 135 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
| 136 | 136 | |
| 137 | 137 | //Must have a form ID |
| 138 | - if ( empty( $form_id ) ) { |
|
| 138 | + if (empty($form_id)) { |
|
| 139 | 139 | continue; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | //Form ID must be within $all_forms array to be validated |
| 143 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
| 143 | + if ( ! in_array($form_id, $all_forms)) { |
|
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Set Sales count |
| 148 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
| 149 | - ++ $totals[ $form_id ]['sales'] : |
|
| 150 | - 1; |
|
| 148 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
| 149 | + ++$totals[$form_id]['sales'] : 1; |
|
| 151 | 150 | |
| 152 | 151 | // Set Total Earnings |
| 153 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
| 154 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
| 155 | - $payment_item['price']; |
|
| 152 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
| 153 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
| 156 | 154 | |
| 157 | 155 | $processed_payments[] = $payment->ID; |
| 158 | 156 | } |
| 159 | 157 | |
| 160 | 158 | // Get the list of form ids which does not contain any payment record. |
| 161 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
| 162 | - foreach ( $remaining_form_ids as $form_id ) { |
|
| 159 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
| 160 | + foreach ($remaining_form_ids as $form_id) { |
|
| 163 | 161 | //If array key doesn't exist, create it |
| 164 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
| 165 | - $totals[ $form_id ] = array( |
|
| 162 | + if ( ! array_key_exists($form_id, $totals)) { |
|
| 163 | + $totals[$form_id] = array( |
|
| 166 | 164 | 'sales' => (int) 0, |
| 167 | 165 | 'earnings' => (float) 0, |
| 168 | 166 | ); |
| 169 | 167 | } |
| 170 | 168 | } |
| 171 | 169 | |
| 172 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
| 173 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
| 170 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
| 171 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
| 174 | 172 | |
| 175 | 173 | return true; |
| 176 | 174 | } |
| 177 | 175 | |
| 178 | - foreach ( $totals as $key => $stats ) { |
|
| 179 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
| 180 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
| 176 | + foreach ($totals as $key => $stats) { |
|
| 177 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
| 178 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
| 181 | 179 | } |
| 182 | 180 | |
| 183 | 181 | return false; |
@@ -192,20 +190,20 @@ discard block |
||
| 192 | 190 | */ |
| 193 | 191 | public function get_percentage_complete() { |
| 194 | 192 | |
| 195 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 193 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 196 | 194 | |
| 197 | - if ( false === $total ) { |
|
| 195 | + if (false === $total) { |
|
| 198 | 196 | $this->pre_fetch(); |
| 199 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
| 197 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
| 200 | 198 | } |
| 201 | 199 | |
| 202 | 200 | $percentage = 100; |
| 203 | 201 | |
| 204 | - if ( $total > 0 ) { |
|
| 205 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 202 | + if ($total > 0) { |
|
| 203 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 206 | 204 | } |
| 207 | 205 | |
| 208 | - if ( $percentage > 100 ) { |
|
| 206 | + if ($percentage > 100) { |
|
| 209 | 207 | $percentage = 100; |
| 210 | 208 | } |
| 211 | 209 | |
@@ -219,8 +217,8 @@ discard block |
||
| 219 | 217 | * |
| 220 | 218 | * @param array $request The Form Data passed into the batch processing |
| 221 | 219 | */ |
| 222 | - public function set_properties( $request ) { |
|
| 223 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 220 | + public function set_properties($request) { |
|
| 221 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 224 | 222 | } |
| 225 | 223 | |
| 226 | 224 | /** |
@@ -231,35 +229,35 @@ discard block |
||
| 231 | 229 | */ |
| 232 | 230 | public function process_step() { |
| 233 | 231 | |
| 234 | - if ( ! $this->can_export() ) { |
|
| 235 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 232 | + if ( ! $this->can_export()) { |
|
| 233 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 236 | 234 | } |
| 237 | 235 | |
| 238 | 236 | $had_data = $this->get_data(); |
| 239 | 237 | |
| 240 | - if ( $had_data ) { |
|
| 238 | + if ($had_data) { |
|
| 241 | 239 | $this->done = false; |
| 242 | 240 | |
| 243 | 241 | return true; |
| 244 | 242 | } else { |
| 245 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 246 | - $this->delete_data( 'give_recount_all_total' ); |
|
| 247 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 248 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 249 | - $this->delete_data( 'give_temp_form_ids' ); |
|
| 250 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 243 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 244 | + $this->delete_data('give_recount_all_total'); |
|
| 245 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 246 | + $this->delete_data('give_temp_payment_items'); |
|
| 247 | + $this->delete_data('give_temp_form_ids'); |
|
| 248 | + $this->delete_data('give_temp_processed_payments'); |
|
| 251 | 249 | $this->done = true; |
| 252 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
| 250 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
| 253 | 251 | |
| 254 | 252 | return false; |
| 255 | 253 | } |
| 256 | 254 | } |
| 257 | 255 | |
| 258 | 256 | public function headers() { |
| 259 | - ignore_user_abort( true ); |
|
| 257 | + ignore_user_abort(true); |
|
| 260 | 258 | |
| 261 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 262 | - set_time_limit( 0 ); |
|
| 259 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 260 | + set_time_limit(0); |
|
| 263 | 261 | } |
| 264 | 262 | } |
| 265 | 263 | |
@@ -286,69 +284,69 @@ discard block |
||
| 286 | 284 | */ |
| 287 | 285 | public function pre_fetch() { |
| 288 | 286 | |
| 289 | - if ( $this->step == 1 ) { |
|
| 290 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
| 291 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
| 292 | - $this->delete_data( 'give_temp_payment_items' ); |
|
| 293 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
| 294 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
| 287 | + if ($this->step == 1) { |
|
| 288 | + $this->delete_data('give_temp_recount_all_total'); |
|
| 289 | + $this->delete_data('give_temp_recount_all_stats'); |
|
| 290 | + $this->delete_data('give_temp_payment_items'); |
|
| 291 | + $this->delete_data('give_temp_processed_payments'); |
|
| 292 | + $this->delete_data('give_temp_all_payments_data'); |
|
| 295 | 293 | } |
| 296 | 294 | |
| 297 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 298 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
| 295 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 296 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
| 299 | 297 | |
| 300 | - if ( false === $total ) { |
|
| 298 | + if (false === $total) { |
|
| 301 | 299 | $total = 0; |
| 302 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
| 300 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
| 303 | 301 | |
| 304 | - if ( false === $payment_items ) { |
|
| 302 | + if (false === $payment_items) { |
|
| 305 | 303 | $payment_items = array(); |
| 306 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 304 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 307 | 305 | } |
| 308 | 306 | |
| 309 | 307 | $args = array( |
| 310 | 308 | 'post_status' => 'publish', |
| 311 | 309 | 'post_type' => 'give_forms', |
| 312 | - 'posts_per_page' => - 1, |
|
| 310 | + 'posts_per_page' => -1, |
|
| 313 | 311 | 'fields' => 'ids', |
| 314 | 312 | ); |
| 315 | 313 | |
| 316 | - $all_forms = get_posts( $args ); |
|
| 317 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
| 314 | + $all_forms = get_posts($args); |
|
| 315 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
| 318 | 316 | |
| 319 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 317 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 320 | 318 | 'post_parent__in' => $all_forms, |
| 321 | 319 | 'number' => $this->per_step, |
| 322 | 320 | 'status' => 'publish', |
| 323 | 321 | 'page' => $this->step, |
| 324 | 322 | 'output' => 'payments', |
| 325 | - ) ); |
|
| 323 | + )); |
|
| 326 | 324 | |
| 327 | - $payments_query = new Give_Payments_Query( $args ); |
|
| 325 | + $payments_query = new Give_Payments_Query($args); |
|
| 328 | 326 | $payments = $payments_query->get_payments(); |
| 329 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
| 327 | + $total = wp_count_posts('give_payment')->publish; |
|
| 330 | 328 | |
| 331 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
| 329 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
| 332 | 330 | |
| 333 | - if ( $payments ) { |
|
| 331 | + if ($payments) { |
|
| 334 | 332 | |
| 335 | - foreach ( $payments as $payment ) { |
|
| 333 | + foreach ($payments as $payment) { |
|
| 336 | 334 | |
| 337 | - $payment = new Give_Payment( $payment->ID ); |
|
| 335 | + $payment = new Give_Payment($payment->ID); |
|
| 338 | 336 | $form_id = $payment->form_id; |
| 339 | 337 | |
| 340 | 338 | //If for some reason somehow the form_ID isn't set check payment meta |
| 341 | - if ( empty( $payment->form_id ) ) { |
|
| 339 | + if (empty($payment->form_id)) { |
|
| 342 | 340 | $payment_meta = $payment->get_meta(); |
| 343 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
| 341 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
| 344 | 342 | } |
| 345 | 343 | |
| 346 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 344 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 347 | 345 | continue; |
| 348 | 346 | } |
| 349 | 347 | |
| 350 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
| 351 | - $payment_items[ $payment->ID ] = array( |
|
| 348 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
| 349 | + $payment_items[$payment->ID] = array( |
|
| 352 | 350 | 'id' => $form_id, |
| 353 | 351 | 'payment_id' => $payment->ID, |
| 354 | 352 | 'price' => $payment->total, |
@@ -359,8 +357,8 @@ discard block |
||
| 359 | 357 | |
| 360 | 358 | } |
| 361 | 359 | |
| 362 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
| 363 | - $this->store_data( 'give_recount_all_total', $total ); |
|
| 360 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
| 361 | + $this->store_data('give_recount_all_total', $total); |
|
| 364 | 362 | } |
| 365 | 363 | |
| 366 | 364 | } |
@@ -374,17 +372,17 @@ discard block |
||
| 374 | 372 | * |
| 375 | 373 | * @return mixed Returns the data from the database |
| 376 | 374 | */ |
| 377 | - private function get_stored_data( $key ) { |
|
| 375 | + private function get_stored_data($key) { |
|
| 378 | 376 | global $wpdb; |
| 379 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 377 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 380 | 378 | |
| 381 | - if ( empty( $value ) ) { |
|
| 379 | + if (empty($value)) { |
|
| 382 | 380 | return false; |
| 383 | 381 | } |
| 384 | 382 | |
| 385 | - $maybe_json = json_decode( $value ); |
|
| 386 | - if ( ! is_null( $maybe_json ) ) { |
|
| 387 | - $value = json_decode( $value, true ); |
|
| 383 | + $maybe_json = json_decode($value); |
|
| 384 | + if ( ! is_null($maybe_json)) { |
|
| 385 | + $value = json_decode($value, true); |
|
| 388 | 386 | } |
| 389 | 387 | |
| 390 | 388 | return $value; |
@@ -400,10 +398,10 @@ discard block |
||
| 400 | 398 | * |
| 401 | 399 | * @return void |
| 402 | 400 | */ |
| 403 | - private function store_data( $key, $value ) { |
|
| 401 | + private function store_data($key, $value) { |
|
| 404 | 402 | global $wpdb; |
| 405 | 403 | |
| 406 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 404 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 407 | 405 | |
| 408 | 406 | $data = array( |
| 409 | 407 | 'option_name' => $key, |
@@ -417,7 +415,7 @@ discard block |
||
| 417 | 415 | '%s', |
| 418 | 416 | ); |
| 419 | 417 | |
| 420 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 418 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 421 | 419 | } |
| 422 | 420 | |
| 423 | 421 | /** |
@@ -429,9 +427,9 @@ discard block |
||
| 429 | 427 | * |
| 430 | 428 | * @return void |
| 431 | 429 | */ |
| 432 | - private function delete_data( $key ) { |
|
| 430 | + private function delete_data($key) { |
|
| 433 | 431 | global $wpdb; |
| 434 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 432 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 435 | 433 | } |
| 436 | 434 | |
| 437 | 435 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -53,40 +53,40 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function get_data() { |
| 55 | 55 | |
| 56 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 57 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id ); |
|
| 56 | + $donor = new Give_Donor($this->customer_id); |
|
| 57 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id); |
|
| 58 | 58 | |
| 59 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 60 | - $step_items = array_slice( $payments, $offset, $this->per_step ); |
|
| 59 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 60 | + $step_items = array_slice($payments, $offset, $this->per_step); |
|
| 61 | 61 | |
| 62 | - if ( count( $step_items ) > 0 ) { |
|
| 63 | - $pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 62 | + if (count($step_items) > 0) { |
|
| 63 | + $pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 64 | 64 | $step_total = 0; |
| 65 | 65 | |
| 66 | - $found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 66 | + $found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id); |
|
| 67 | 67 | |
| 68 | - foreach ( $step_items as $payment ) { |
|
| 69 | - $payment = get_post( $payment->ID ); |
|
| 68 | + foreach ($step_items as $payment) { |
|
| 69 | + $payment = get_post($payment->ID); |
|
| 70 | 70 | |
| 71 | - if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) { |
|
| 71 | + if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) { |
|
| 72 | 72 | |
| 73 | - $missing_payments = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 73 | + $missing_payments = $this->get_stored_data('give_stats_missing_payments'.$donor->id); |
|
| 74 | 74 | $missing_payments[] = $payment->ID; |
| 75 | - $this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments ); |
|
| 75 | + $this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments); |
|
| 76 | 76 | |
| 77 | 77 | continue; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
| 81 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
| 81 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
| 82 | 82 | |
| 83 | - if ( true === $should_process_payment ) { |
|
| 83 | + if (true === $should_process_payment) { |
|
| 84 | 84 | |
| 85 | 85 | $found_payment_ids[] = $payment->ID; |
| 86 | 86 | |
| 87 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
| 88 | - $payment_amount = give_get_payment_amount( $payment->ID ); |
|
| 89 | - $step_total += $payment_amount; |
|
| 87 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
| 88 | + $payment_amount = give_get_payment_amount($payment->ID); |
|
| 89 | + $step_total += $payment_amount; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | } |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $updated_total = $pending_total + $step_total; |
| 97 | - $this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total ); |
|
| 98 | - $this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids ); |
|
| 97 | + $this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total); |
|
| 98 | + $this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids); |
|
| 99 | 99 | |
| 100 | 100 | return true; |
| 101 | 101 | } |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function get_percentage_complete() { |
| 114 | 114 | |
| 115 | - $payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 116 | - $total = count( $payments ); |
|
| 115 | + $payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 116 | + $total = count($payments); |
|
| 117 | 117 | |
| 118 | 118 | $percentage = 100; |
| 119 | 119 | |
| 120 | - if ( $total > 0 ) { |
|
| 121 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 120 | + if ($total > 0) { |
|
| 121 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( $percentage > 100 ) { |
|
| 124 | + if ($percentage > 100) { |
|
| 125 | 125 | $percentage = 100; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param array $request The Form Data passed into the batch processing |
| 137 | 137 | */ |
| 138 | - public function set_properties( $request ) { |
|
| 139 | - $this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false; |
|
| 138 | + public function set_properties($request) { |
|
| 139 | + $this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,63 +147,63 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function process_step() { |
| 149 | 149 | |
| 150 | - if ( ! $this->can_export() ) { |
|
| 151 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 150 | + if ( ! $this->can_export()) { |
|
| 151 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $had_data = $this->get_data(); |
| 155 | 155 | |
| 156 | - if ( $had_data ) { |
|
| 156 | + if ($had_data) { |
|
| 157 | 157 | $this->done = false; |
| 158 | 158 | |
| 159 | 159 | return true; |
| 160 | 160 | } else { |
| 161 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 162 | - $payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() ); |
|
| 163 | - $this->delete_data( 'give_stats_found_payments_' . $donor->id ); |
|
| 161 | + $donor = new Give_Donor($this->customer_id); |
|
| 162 | + $payment_ids = get_option('give_stats_found_payments_'.$donor->id, array()); |
|
| 163 | + $this->delete_data('give_stats_found_payments_'.$donor->id); |
|
| 164 | 164 | |
| 165 | - $removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) ); |
|
| 165 | + $removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array())); |
|
| 166 | 166 | |
| 167 | 167 | // Find non-existing payments (deleted) and total up the donation count |
| 168 | 168 | $purchase_count = 0; |
| 169 | - foreach ( $payment_ids as $key => $payment_id ) { |
|
| 170 | - if ( in_array( $payment_id, $removed_payments ) ) { |
|
| 171 | - unset( $payment_ids[ $key ] ); |
|
| 169 | + foreach ($payment_ids as $key => $payment_id) { |
|
| 170 | + if (in_array($payment_id, $removed_payments)) { |
|
| 171 | + unset($payment_ids[$key]); |
|
| 172 | 172 | continue; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $payment = get_post( $payment_id ); |
|
| 176 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
| 177 | - $purchase_count ++; |
|
| 175 | + $payment = get_post($payment_id); |
|
| 176 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
| 177 | + $purchase_count++; |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $this->delete_data( 'give_stats_missing_payments' . $donor->id ); |
|
| 181 | + $this->delete_data('give_stats_missing_payments'.$donor->id); |
|
| 182 | 182 | |
| 183 | - $pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 184 | - $this->delete_data( 'give_stats_donor_pending_total' . $donor->id ); |
|
| 185 | - $this->delete_data( 'give_recount_donor_stats_' . $donor->id ); |
|
| 186 | - $this->delete_data( 'give_recount_donor_payments_' . $this->customer_id ); |
|
| 183 | + $pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id); |
|
| 184 | + $this->delete_data('give_stats_donor_pending_total'.$donor->id); |
|
| 185 | + $this->delete_data('give_recount_donor_stats_'.$donor->id); |
|
| 186 | + $this->delete_data('give_recount_donor_payments_'.$this->customer_id); |
|
| 187 | 187 | |
| 188 | - $payment_ids = implode( ',', $payment_ids ); |
|
| 189 | - $donor->update( array( |
|
| 188 | + $payment_ids = implode(',', $payment_ids); |
|
| 189 | + $donor->update(array( |
|
| 190 | 190 | 'payment_ids' => $payment_ids, |
| 191 | 191 | 'purchase_count' => $purchase_count, |
| 192 | 192 | 'purchase_value' => $pending_total, |
| 193 | - ) ); |
|
| 193 | + )); |
|
| 194 | 194 | |
| 195 | 195 | $this->done = true; |
| 196 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
| 196 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
| 197 | 197 | |
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function headers() { |
| 203 | - ignore_user_abort( true ); |
|
| 203 | + ignore_user_abort(true); |
|
| 204 | 204 | |
| 205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 206 | - set_time_limit( 0 ); |
|
| 205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 206 | + set_time_limit(0); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -230,26 +230,26 @@ discard block |
||
| 230 | 230 | * @return void |
| 231 | 231 | */ |
| 232 | 232 | public function pre_fetch() { |
| 233 | - if ( $this->step === 1 ) { |
|
| 234 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
| 233 | + if ($this->step === 1) { |
|
| 234 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
| 235 | 235 | |
| 236 | 236 | // Before we start, let's zero out the customer's data |
| 237 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 238 | - $donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) ); |
|
| 237 | + $donor = new Give_Donor($this->customer_id); |
|
| 238 | + $donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0)); |
|
| 239 | 239 | |
| 240 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
| 240 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
| 241 | 241 | |
| 242 | 242 | $attached_args = array( |
| 243 | 243 | 'post__in' => $attached_payment_ids, |
| 244 | - 'number' => - 1, |
|
| 244 | + 'number' => -1, |
|
| 245 | 245 | 'status' => $allowed_payment_status, |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - $attached_payments = give_get_payments( $attached_args ); |
|
| 248 | + $attached_payments = give_get_payments($attached_args); |
|
| 249 | 249 | |
| 250 | 250 | $unattached_args = array( |
| 251 | 251 | 'post__not_in' => $attached_payment_ids, |
| 252 | - 'number' => - 1, |
|
| 252 | + 'number' => -1, |
|
| 253 | 253 | 'status' => $allowed_payment_status, |
| 254 | 254 | 'meta_query' => array( |
| 255 | 255 | array( |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | ), |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
| 262 | + $unattached_payments = give_get_payments($unattached_args); |
|
| 263 | 263 | |
| 264 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
| 264 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
| 265 | 265 | |
| 266 | - $this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments ); |
|
| 266 | + $this->store_data('give_recount_donor_payments_'.$donor->id, $payments); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -276,17 +276,17 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return mixed Returns the data from the database |
| 278 | 278 | */ |
| 279 | - private function get_stored_data( $key ) { |
|
| 279 | + private function get_stored_data($key) { |
|
| 280 | 280 | global $wpdb; |
| 281 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 281 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 282 | 282 | |
| 283 | - if ( empty( $value ) ) { |
|
| 283 | + if (empty($value)) { |
|
| 284 | 284 | return false; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $maybe_json = json_decode( $value ); |
|
| 288 | - if ( ! is_null( $maybe_json ) ) { |
|
| 289 | - $value = json_decode( $value, true ); |
|
| 287 | + $maybe_json = json_decode($value); |
|
| 288 | + if ( ! is_null($maybe_json)) { |
|
| 289 | + $value = json_decode($value, true); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | return $value; |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return void |
| 304 | 304 | */ |
| 305 | - private function store_data( $key, $value ) { |
|
| 305 | + private function store_data($key, $value) { |
|
| 306 | 306 | global $wpdb; |
| 307 | 307 | |
| 308 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 308 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 309 | 309 | |
| 310 | 310 | $data = array( |
| 311 | 311 | 'option_name' => $key, |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | '%s', |
| 320 | 320 | ); |
| 321 | 321 | |
| 322 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 322 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | - private function delete_data( $key ) { |
|
| 334 | + private function delete_data($key) { |
|
| 335 | 335 | global $wpdb; |
| 336 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 336 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -59,58 +59,58 @@ discard block |
||
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | 61 | public function get_data() { |
| 62 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 62 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 63 | 63 | |
| 64 | - if ( $this->step == 1 ) { |
|
| 65 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 64 | + if ($this->step == 1) { |
|
| 65 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
| 68 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
| 69 | 69 | |
| 70 | - if ( false === $totals ) { |
|
| 70 | + if (false === $totals) { |
|
| 71 | 71 | $totals = array( |
| 72 | 72 | 'earnings' => (float) 0, |
| 73 | 73 | 'sales' => 0, |
| 74 | 74 | ); |
| 75 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 75 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
| 78 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
| 79 | 79 | 'give_forms' => $this->form_id, |
| 80 | 80 | 'number' => $this->per_step, |
| 81 | 81 | 'status' => $accepted_statuses, |
| 82 | 82 | 'paged' => $this->step, |
| 83 | 83 | 'fields' => 'ids', |
| 84 | - ) ); |
|
| 84 | + )); |
|
| 85 | 85 | |
| 86 | - $payments = new Give_Payments_Query( $args ); |
|
| 86 | + $payments = new Give_Payments_Query($args); |
|
| 87 | 87 | $payments = $payments->get_payments(); |
| 88 | 88 | |
| 89 | - if ( $payments ) { |
|
| 90 | - foreach ( $payments as $payment ) { |
|
| 89 | + if ($payments) { |
|
| 90 | + foreach ($payments as $payment) { |
|
| 91 | 91 | //Ensure acceptible status only |
| 92 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
| 92 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
| 93 | 93 | continue; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | //Ensure only payments for this form are counted |
| 97 | - if ( $payment->form_id != $this->form_id ) { |
|
| 97 | + if ($payment->form_id != $this->form_id) { |
|
| 98 | 98 | continue; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $totals['sales'] ++; |
|
| 101 | + $totals['sales']++; |
|
| 102 | 102 | $totals['earnings'] += $payment->total; |
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
| 106 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
| 107 | 107 | |
| 108 | 108 | return true; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
| 113 | - give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
| 112 | + give_update_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
| 113 | + give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
| 114 | 114 | |
| 115 | 115 | return false; |
| 116 | 116 | } |
@@ -122,35 +122,35 @@ discard block |
||
| 122 | 122 | * @return int |
| 123 | 123 | */ |
| 124 | 124 | public function get_percentage_complete() { |
| 125 | - if ( $this->step == 1 ) { |
|
| 126 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 125 | + if ($this->step == 1) { |
|
| 126 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 130 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
| 129 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 130 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
| 131 | 131 | |
| 132 | - if ( false === $total ) { |
|
| 132 | + if (false === $total) { |
|
| 133 | 133 | $total = 0; |
| 134 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
| 134 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
| 135 | 135 | 'give_forms' => $this->form_id, |
| 136 | - 'number' => - 1, |
|
| 136 | + 'number' => -1, |
|
| 137 | 137 | 'status' => $accepted_statuses, |
| 138 | 138 | 'fields' => 'ids', |
| 139 | - ) ); |
|
| 139 | + )); |
|
| 140 | 140 | |
| 141 | - $payments = new Give_Payments_Query( $args ); |
|
| 142 | - $total = count( $payments->get_payments() ); |
|
| 143 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
| 141 | + $payments = new Give_Payments_Query($args); |
|
| 142 | + $total = count($payments->get_payments()); |
|
| 143 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
| 144 | 144 | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $percentage = 100; |
| 148 | 148 | |
| 149 | - if ( $total > 0 ) { |
|
| 150 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 149 | + if ($total > 0) { |
|
| 150 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( $percentage > 100 ) { |
|
| 153 | + if ($percentage > 100) { |
|
| 154 | 154 | $percentage = 100; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @param array $request The Form Data passed into the batch processing |
| 166 | 166 | */ |
| 167 | - public function set_properties( $request ) { |
|
| 168 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
| 167 | + public function set_properties($request) { |
|
| 168 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -176,31 +176,31 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function process_step() { |
| 178 | 178 | |
| 179 | - if ( ! $this->can_export() ) { |
|
| 180 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 179 | + if ( ! $this->can_export()) { |
|
| 180 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $had_data = $this->get_data(); |
| 184 | 184 | |
| 185 | - if ( $had_data ) { |
|
| 185 | + if ($had_data) { |
|
| 186 | 186 | $this->done = false; |
| 187 | 187 | |
| 188 | 188 | return true; |
| 189 | 189 | } else { |
| 190 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
| 191 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
| 190 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
| 191 | + $this->delete_data('give_temp_recount_form_stats'); |
|
| 192 | 192 | $this->done = true; |
| 193 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
| 193 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
| 194 | 194 | |
| 195 | 195 | return false; |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | public function headers() { |
| 200 | - ignore_user_abort( true ); |
|
| 200 | + ignore_user_abort(true); |
|
| 201 | 201 | |
| 202 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 203 | - set_time_limit( 0 ); |
|
| 202 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 203 | + set_time_limit(0); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
@@ -228,17 +228,17 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return mixed Returns the data from the database |
| 230 | 230 | */ |
| 231 | - private function get_stored_data( $key ) { |
|
| 231 | + private function get_stored_data($key) { |
|
| 232 | 232 | global $wpdb; |
| 233 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 233 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 234 | 234 | |
| 235 | - if ( empty( $value ) ) { |
|
| 235 | + if (empty($value)) { |
|
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $maybe_json = json_decode( $value ); |
|
| 240 | - if ( ! is_null( $maybe_json ) ) { |
|
| 241 | - $value = json_decode( $value, true ); |
|
| 239 | + $maybe_json = json_decode($value); |
|
| 240 | + if ( ! is_null($maybe_json)) { |
|
| 241 | + $value = json_decode($value, true); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | return $value; |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @return void |
| 256 | 256 | */ |
| 257 | - private function store_data( $key, $value ) { |
|
| 257 | + private function store_data($key, $value) { |
|
| 258 | 258 | global $wpdb; |
| 259 | 259 | |
| 260 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 260 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 261 | 261 | |
| 262 | 262 | $data = array( |
| 263 | 263 | 'option_name' => $key, |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | '%s', |
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 274 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return void |
| 285 | 285 | */ |
| 286 | - private function delete_data( $key ) { |
|
| 286 | + private function delete_data($key) { |
|
| 287 | 287 | global $wpdb; |
| 288 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 288 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
| 292 | 292 | \ No newline at end of file |
@@ -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 | |
@@ -58,16 +58,16 @@ discard block |
||
| 58 | 58 | public function get_data() { |
| 59 | 59 | global $wpdb; |
| 60 | 60 | |
| 61 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 61 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 62 | 62 | |
| 63 | - if ( ! is_array( $items ) ) { |
|
| 63 | + if ( ! is_array($items)) { |
|
| 64 | 64 | return false; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 68 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 67 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 68 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 69 | 69 | |
| 70 | - if ( $step_items ) { |
|
| 70 | + if ($step_items) { |
|
| 71 | 71 | |
| 72 | 72 | $step_ids = array( |
| 73 | 73 | 'customers' => array(), |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | 'other' => array(), |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - foreach ( $step_items as $item ) { |
|
| 78 | + foreach ($step_items as $item) { |
|
| 79 | 79 | |
| 80 | - switch ( $item['type'] ) { |
|
| 80 | + switch ($item['type']) { |
|
| 81 | 81 | case 'customer': |
| 82 | 82 | $step_ids['customers'][] = $item['id']; |
| 83 | 83 | break; |
@@ -85,26 +85,26 @@ discard block |
||
| 85 | 85 | $step_ids['give_forms'][] = $item['id']; |
| 86 | 86 | break; |
| 87 | 87 | default: |
| 88 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
| 89 | - $step_ids[ $item_type ][] = $item['id']; |
|
| 88 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
| 89 | + $step_ids[$item_type][] = $item['id']; |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $sql = array(); |
| 95 | 95 | |
| 96 | - foreach ( $step_ids as $type => $ids ) { |
|
| 96 | + foreach ($step_ids as $type => $ids) { |
|
| 97 | 97 | |
| 98 | - if ( empty( $ids ) ) { |
|
| 98 | + if (empty($ids)) { |
|
| 99 | 99 | continue; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $ids = implode( ',', $ids ); |
|
| 102 | + $ids = implode(',', $ids); |
|
| 103 | 103 | |
| 104 | - switch ( $type ) { |
|
| 104 | + switch ($type) { |
|
| 105 | 105 | case 'customers': |
| 106 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
| 107 | - $meta_table_name = $wpdb->prefix . 'give_customermeta'; |
|
| 106 | + $table_name = $wpdb->prefix.'give_customers'; |
|
| 107 | + $meta_table_name = $wpdb->prefix.'give_customermeta'; |
|
| 108 | 108 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
| 109 | 109 | $sql[] = "DELETE FROM $meta_table_name WHERE customer_id IN ($ids)"; |
| 110 | 110 | break; |
@@ -120,16 +120,16 @@ discard block |
||
| 120 | 120 | break; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
| 123 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
| 124 | 124 | // Allows other types of custom post types to filter on their own post_type |
| 125 | 125 | // and add items to the query list, for the IDs found in their post type. |
| 126 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
| 126 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( ! empty( $sql ) ) { |
|
| 131 | - foreach ( $sql as $query ) { |
|
| 132 | - $wpdb->query( $query ); |
|
| 130 | + if ( ! empty($sql)) { |
|
| 131 | + foreach ($sql as $query) { |
|
| 132 | + $wpdb->query($query); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function get_percentage_complete() { |
| 151 | 151 | |
| 152 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 153 | - $total = count( $items ); |
|
| 152 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 153 | + $total = count($items); |
|
| 154 | 154 | |
| 155 | 155 | $percentage = 100; |
| 156 | 156 | |
| 157 | - if ( $total > 0 ) { |
|
| 158 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 157 | + if ($total > 0) { |
|
| 158 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( $percentage > 100 ) { |
|
| 161 | + if ($percentage > 100) { |
|
| 162 | 162 | $percentage = 100; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @param array $request The Form Data passed into the batch processing. |
| 174 | 174 | */ |
| 175 | - public function set_properties( $request ) { |
|
| 175 | + public function set_properties($request) { |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -183,31 +183,31 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function process_step() { |
| 185 | 185 | |
| 186 | - if ( ! $this->can_export() ) { |
|
| 187 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 186 | + if ( ! $this->can_export()) { |
|
| 187 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array( |
|
| 188 | 188 | 'response' => 403, |
| 189 | - ) ); |
|
| 189 | + )); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $had_data = $this->get_data(); |
| 193 | 193 | |
| 194 | - if ( $had_data ) { |
|
| 194 | + if ($had_data) { |
|
| 195 | 195 | $this->done = false; |
| 196 | 196 | |
| 197 | 197 | return true; |
| 198 | 198 | } else { |
| 199 | - update_option( 'give_earnings_total', 0 ); |
|
| 200 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 199 | + update_option('give_earnings_total', 0); |
|
| 200 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 201 | 201 | |
| 202 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 202 | + $this->delete_data('give_temp_reset_ids'); |
|
| 203 | 203 | |
| 204 | 204 | // Reset the sequential order numbers |
| 205 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 206 | - delete_option( 'give_last_payment_number' ); |
|
| 205 | + if (give_get_option('enable_sequential')) { |
|
| 206 | + delete_option('give_last_payment_number'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $this->done = true; |
| 210 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
| 210 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
| 211 | 211 | |
| 212 | 212 | return false; |
| 213 | 213 | } |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | * Headers |
| 218 | 218 | */ |
| 219 | 219 | public function headers() { |
| 220 | - ignore_user_abort( true ); |
|
| 220 | + ignore_user_abort(true); |
|
| 221 | 221 | |
| 222 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 223 | - set_time_limit( 0 ); |
|
| 222 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 223 | + set_time_limit(0); |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
@@ -244,26 +244,26 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function pre_fetch() { |
| 246 | 246 | |
| 247 | - if ( $this->step == 1 ) { |
|
| 248 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 247 | + if ($this->step == 1) { |
|
| 248 | + $this->delete_data('give_temp_reset_ids'); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
| 251 | + $items = get_option('give_temp_reset_ids', false); |
|
| 252 | 252 | |
| 253 | - if ( false === $items ) { |
|
| 253 | + if (false === $items) { |
|
| 254 | 254 | $items = array(); |
| 255 | 255 | |
| 256 | - $give_types_for_reset = array( 'give_forms', 'give_payment' ); |
|
| 257 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
| 256 | + $give_types_for_reset = array('give_forms', 'give_payment'); |
|
| 257 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
| 258 | 258 | |
| 259 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 259 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 260 | 260 | 'post_type' => $give_types_for_reset, |
| 261 | 261 | 'post_status' => 'any', |
| 262 | - 'posts_per_page' => - 1, |
|
| 263 | - ) ); |
|
| 262 | + 'posts_per_page' => -1, |
|
| 263 | + )); |
|
| 264 | 264 | |
| 265 | - $posts = get_posts( $args ); |
|
| 266 | - foreach ( $posts as $post ) { |
|
| 265 | + $posts = get_posts($args); |
|
| 266 | + foreach ($posts as $post) { |
|
| 267 | 267 | $items[] = array( |
| 268 | 268 | 'id' => (int) $post->ID, |
| 269 | 269 | 'type' => $post->post_type, |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $donor_args = array( |
| 274 | - 'number' => - 1, |
|
| 274 | + 'number' => -1, |
|
| 275 | 275 | ); |
| 276 | - $donors = Give()->donors->get_donors( $donor_args ); |
|
| 277 | - foreach ( $donors as $donor ) { |
|
| 276 | + $donors = Give()->donors->get_donors($donor_args); |
|
| 277 | + foreach ($donors as $donor) { |
|
| 278 | 278 | $items[] = array( |
| 279 | 279 | 'id' => (int) $donor->id, |
| 280 | 280 | 'type' => 'customer', |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | // Allow filtering of items to remove with an unassociative array for each item |
| 285 | 285 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
| 286 | - $items = apply_filters( 'give_reset_items', $items ); |
|
| 286 | + $items = apply_filters('give_reset_items', $items); |
|
| 287 | 287 | |
| 288 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
| 288 | + $this->store_data('give_temp_reset_ids', $items); |
|
| 289 | 289 | }// End if(). |
| 290 | 290 | |
| 291 | 291 | } |
@@ -299,17 +299,17 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @return mixed Returns the data from the database. |
| 301 | 301 | */ |
| 302 | - private function get_stored_data( $key ) { |
|
| 302 | + private function get_stored_data($key) { |
|
| 303 | 303 | global $wpdb; |
| 304 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 304 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 305 | 305 | |
| 306 | - if ( empty( $value ) ) { |
|
| 306 | + if (empty($value)) { |
|
| 307 | 307 | return false; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $maybe_json = json_decode( $value ); |
|
| 311 | - if ( ! is_null( $maybe_json ) ) { |
|
| 312 | - $value = json_decode( $value, true ); |
|
| 310 | + $maybe_json = json_decode($value); |
|
| 311 | + if ( ! is_null($maybe_json)) { |
|
| 312 | + $value = json_decode($value, true); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | return $value; |
@@ -325,10 +325,10 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @return void |
| 327 | 327 | */ |
| 328 | - private function store_data( $key, $value ) { |
|
| 328 | + private function store_data($key, $value) { |
|
| 329 | 329 | global $wpdb; |
| 330 | 330 | |
| 331 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 331 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 332 | 332 | |
| 333 | 333 | $data = array( |
| 334 | 334 | 'option_name' => $key, |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | '%s', |
| 343 | 343 | ); |
| 344 | 344 | |
| 345 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 345 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return void |
| 356 | 356 | */ |
| 357 | - private function delete_data( $key ) { |
|
| 357 | + private function delete_data($key) { |
|
| 358 | 358 | global $wpdb; |
| 359 | - $wpdb->delete( $wpdb->options, array( |
|
| 359 | + $wpdb->delete($wpdb->options, array( |
|
| 360 | 360 | 'option_name' => $key, |
| 361 | - ) ); |
|
| 361 | + )); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | } |
| 365 | 365 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | * @since 1.5 |
| 21 | 21 | */ |
| 22 | 22 | function give_register_batch_recount_export_classes() { |
| 23 | - add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 ); |
|
| 23 | + add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 ); |
|
| 26 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -35,39 +35,39 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | -function give_include_batch_export_class( $class ) { |
|
| 39 | - switch ( $class ) { |
|
| 38 | +function give_include_batch_export_class($class) { |
|
| 39 | + switch ($class) { |
|
| 40 | 40 | |
| 41 | 41 | case 'Give_Tools_Delete_Donors': |
| 42 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
| 42 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
| 43 | 43 | break; |
| 44 | 44 | |
| 45 | 45 | case 'Give_Tools_Import_Donors': |
| 46 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
| 46 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
| 47 | 47 | break; |
| 48 | 48 | |
| 49 | 49 | case 'Give_Tools_Delete_Test_Transactions': |
| 50 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
| 50 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
| 51 | 51 | break; |
| 52 | 52 | |
| 53 | 53 | case 'Give_Tools_Recount_Donor_Stats': |
| 54 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
| 54 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
| 55 | 55 | break; |
| 56 | 56 | |
| 57 | 57 | case 'Give_Tools_Reset_Stats': |
| 58 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
| 58 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
| 59 | 59 | break; |
| 60 | 60 | |
| 61 | 61 | case 'Give_Tools_Recount_All_Stats': |
| 62 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
| 62 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
| 63 | 63 | break; |
| 64 | 64 | |
| 65 | 65 | case 'Give_Tools_Recount_Form_Stats': |
| 66 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
| 66 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
| 67 | 67 | break; |
| 68 | 68 | |
| 69 | 69 | case 'Give_Tools_Recount_Income': |
| 70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
| 70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -53,49 +53,49 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function get_data() { |
| 55 | 55 | |
| 56 | - if ( $this->step == 1 ) { |
|
| 57 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 56 | + if ($this->step == 1) { |
|
| 57 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
| 60 | + $total = get_option('give_temp_recount_earnings', false); |
|
| 61 | 61 | |
| 62 | - if ( false === $total ) { |
|
| 62 | + if (false === $total) { |
|
| 63 | 63 | $total = (float) 0; |
| 64 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 64 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 67 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 68 | 68 | |
| 69 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
| 69 | + $args = apply_filters('give_recount_earnings_args', array( |
|
| 70 | 70 | 'number' => $this->per_step, |
| 71 | 71 | 'page' => $this->step, |
| 72 | 72 | 'status' => $accepted_statuses, |
| 73 | 73 | 'fields' => 'ids' |
| 74 | - ) ); |
|
| 74 | + )); |
|
| 75 | 75 | |
| 76 | - $payments = give_get_payments( $args ); |
|
| 76 | + $payments = give_get_payments($args); |
|
| 77 | 77 | |
| 78 | - if ( ! empty( $payments ) ) { |
|
| 78 | + if ( ! empty($payments)) { |
|
| 79 | 79 | |
| 80 | - foreach ( $payments as $payment ) { |
|
| 80 | + foreach ($payments as $payment) { |
|
| 81 | 81 | |
| 82 | - $total += give_get_payment_amount( $payment ); |
|
| 82 | + $total += give_get_payment_amount($payment); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( $total < 0 ) { |
|
| 86 | + if ($total < 0) { |
|
| 87 | 87 | $totals = 0; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $total = round( $total, give_currency_decimal_filter() ); |
|
| 90 | + $total = round($total, give_currency_decimal_filter()); |
|
| 91 | 91 | |
| 92 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 92 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 93 | 93 | |
| 94 | 94 | return true; |
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - update_option( 'give_earnings_total', $total ); |
|
| 98 | + update_option('give_earnings_total', $total); |
|
| 99 | 99 | |
| 100 | 100 | return false; |
| 101 | 101 | |
@@ -109,25 +109,25 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function get_percentage_complete() { |
| 111 | 111 | |
| 112 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
| 112 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
| 113 | 113 | |
| 114 | - if ( false === $total ) { |
|
| 115 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
| 114 | + if (false === $total) { |
|
| 115 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
| 116 | 116 | |
| 117 | - $counts = give_count_payments( $args ); |
|
| 118 | - $total = absint( $counts->publish ); |
|
| 119 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
| 117 | + $counts = give_count_payments($args); |
|
| 118 | + $total = absint($counts->publish); |
|
| 119 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
| 120 | 120 | |
| 121 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
| 121 | + $this->store_data('give_recount_earnings_total', $total); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $percentage = 100; |
| 125 | 125 | |
| 126 | - if ( $total > 0 ) { |
|
| 127 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 126 | + if ($total > 0) { |
|
| 127 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( $percentage > 100 ) { |
|
| 130 | + if ($percentage > 100) { |
|
| 131 | 131 | $percentage = 100; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @param array $request The Form Data passed into the batch processing |
| 143 | 143 | */ |
| 144 | - public function set_properties( $request ) { |
|
| 144 | + public function set_properties($request) { |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -152,21 +152,21 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function process_step() { |
| 154 | 154 | |
| 155 | - if ( ! $this->can_export() ) { |
|
| 156 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 155 | + if ( ! $this->can_export()) { |
|
| 156 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $had_data = $this->get_data(); |
| 160 | 160 | |
| 161 | - if ( $had_data ) { |
|
| 161 | + if ($had_data) { |
|
| 162 | 162 | $this->done = false; |
| 163 | 163 | |
| 164 | 164 | return true; |
| 165 | 165 | } else { |
| 166 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
| 167 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 166 | + $this->delete_data('give_recount_earnings_total'); |
|
| 167 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 168 | 168 | $this->done = true; |
| 169 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
| 169 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
| 170 | 170 | |
| 171 | 171 | return false; |
| 172 | 172 | } |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | * Headers. |
| 177 | 177 | */ |
| 178 | 178 | public function headers() { |
| 179 | - ignore_user_abort( true ); |
|
| 179 | + ignore_user_abort(true); |
|
| 180 | 180 | |
| 181 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 182 | - set_time_limit( 0 ); |
|
| 181 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 182 | + set_time_limit(0); |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
@@ -207,17 +207,17 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return mixed Returns the data from the database |
| 209 | 209 | */ |
| 210 | - private function get_stored_data( $key ) { |
|
| 210 | + private function get_stored_data($key) { |
|
| 211 | 211 | global $wpdb; |
| 212 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 212 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 213 | 213 | |
| 214 | - if ( empty( $value ) ) { |
|
| 214 | + if (empty($value)) { |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $maybe_json = json_decode( $value ); |
|
| 219 | - if ( ! is_null( $maybe_json ) ) { |
|
| 220 | - $value = json_decode( $value, true ); |
|
| 218 | + $maybe_json = json_decode($value); |
|
| 219 | + if ( ! is_null($maybe_json)) { |
|
| 220 | + $value = json_decode($value, true); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | return $value; |
@@ -233,10 +233,10 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return void |
| 235 | 235 | */ |
| 236 | - private function store_data( $key, $value ) { |
|
| 236 | + private function store_data($key, $value) { |
|
| 237 | 237 | global $wpdb; |
| 238 | 238 | |
| 239 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 239 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 240 | 240 | |
| 241 | 241 | $data = array( |
| 242 | 242 | 'option_name' => $key, |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | '%s', |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 253 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | - private function delete_data( $key ) { |
|
| 265 | + private function delete_data($key) { |
|
| 266 | 266 | global $wpdb; |
| 267 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 267 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | } |
@@ -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 | |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | public function get_data() { |
| 56 | 56 | global $wpdb; |
| 57 | 57 | |
| 58 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
| 58 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
| 59 | 59 | |
| 60 | - if ( ! is_array( $items ) ) { |
|
| 60 | + if ( ! is_array($items)) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 64 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 66 | 66 | |
| 67 | - if ( $step_items ) { |
|
| 67 | + if ($step_items) { |
|
| 68 | 68 | |
| 69 | 69 | $step_ids = array( |
| 70 | 70 | 'other' => array(), |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | - foreach ( $step_items as $item ) { |
|
| 73 | + foreach ($step_items as $item) { |
|
| 74 | 74 | |
| 75 | 75 | $step_ids['other'][] = $item['id']; |
| 76 | 76 | |
@@ -78,31 +78,31 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | $sql = array(); |
| 80 | 80 | |
| 81 | - foreach ( $step_ids as $type => $ids ) { |
|
| 81 | + foreach ($step_ids as $type => $ids) { |
|
| 82 | 82 | |
| 83 | - if ( empty( $ids ) ) { |
|
| 83 | + if (empty($ids)) { |
|
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $parent_query = ''; |
| 88 | 88 | |
| 89 | - switch ( $type ) { |
|
| 89 | + switch ($type) { |
|
| 90 | 90 | case 'other': |
| 91 | 91 | |
| 92 | - $temp_ids = implode( ',', $ids ); |
|
| 92 | + $temp_ids = implode(',', $ids); |
|
| 93 | 93 | |
| 94 | 94 | // Get all the test logs of the donations ids. |
| 95 | 95 | $parent_query = "SELECT DISTINCT post_id as id FROM $wpdb->postmeta WHERE meta_key = '_give_log_payment_id' AND meta_value IN ( $temp_ids )"; |
| 96 | - $parent_ids = $wpdb->get_results( $parent_query, 'ARRAY_A' ); |
|
| 96 | + $parent_ids = $wpdb->get_results($parent_query, 'ARRAY_A'); |
|
| 97 | 97 | |
| 98 | 98 | // List of all test logs. |
| 99 | - if ( $parent_ids ) { |
|
| 100 | - foreach ( $parent_ids as $parent_id ) { |
|
| 99 | + if ($parent_ids) { |
|
| 100 | + foreach ($parent_ids as $parent_id) { |
|
| 101 | 101 | // Adding all the test log in post ids that are going to get deleted. |
| 102 | 102 | $ids[] = $parent_id['id']; |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | - $ids = implode( ',', $ids ); |
|
| 105 | + $ids = implode(',', $ids); |
|
| 106 | 106 | |
| 107 | 107 | $sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)"; |
| 108 | 108 | $sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)"; |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if ( ! empty( $sql ) ) { |
|
| 117 | - foreach ( $sql as $query ) { |
|
| 118 | - $wpdb->query( $query ); |
|
| 116 | + if ( ! empty($sql)) { |
|
| 117 | + foreach ($sql as $query) { |
|
| 118 | + $wpdb->query($query); |
|
| 119 | 119 | } |
| 120 | - do_action( 'give_delete_log_cache' ); |
|
| 120 | + do_action('give_delete_log_cache'); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | return true; |
@@ -134,16 +134,16 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function get_percentage_complete() { |
| 136 | 136 | |
| 137 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
| 138 | - $total = count( $items ); |
|
| 137 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
| 138 | + $total = count($items); |
|
| 139 | 139 | |
| 140 | 140 | $percentage = 100; |
| 141 | 141 | |
| 142 | - if ( $total > 0 ) { |
|
| 143 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 142 | + if ($total > 0) { |
|
| 143 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( $percentage > 100 ) { |
|
| 146 | + if ($percentage > 100) { |
|
| 147 | 147 | $percentage = 100; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @param array $request The Form Data passed into the batch processing |
| 159 | 159 | */ |
| 160 | - public function set_properties( $request ) { |
|
| 160 | + public function set_properties($request) { |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -168,29 +168,29 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function process_step() { |
| 170 | 170 | |
| 171 | - if ( ! $this->can_export() ) { |
|
| 172 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 171 | + if ( ! $this->can_export()) { |
|
| 172 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $had_data = $this->get_data(); |
| 176 | 176 | |
| 177 | - if ( $had_data ) { |
|
| 177 | + if ($had_data) { |
|
| 178 | 178 | $this->done = false; |
| 179 | 179 | |
| 180 | 180 | return true; |
| 181 | 181 | } else { |
| 182 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
| 183 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 182 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
| 183 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 184 | 184 | |
| 185 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
| 185 | + $this->delete_data('give_temp_delete_test_ids'); |
|
| 186 | 186 | |
| 187 | 187 | // Reset the sequential order numbers |
| 188 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 189 | - delete_option( 'give_last_payment_number' ); |
|
| 188 | + if (give_get_option('enable_sequential')) { |
|
| 189 | + delete_option('give_last_payment_number'); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $this->done = true; |
| 193 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
| 193 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
| 194 | 194 | |
| 195 | 195 | return false; |
| 196 | 196 | } |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | * Headers |
| 201 | 201 | */ |
| 202 | 202 | public function headers() { |
| 203 | - ignore_user_abort( true ); |
|
| 203 | + ignore_user_abort(true); |
|
| 204 | 204 | |
| 205 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 206 | - set_time_limit( 0 ); |
|
| 205 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 206 | + set_time_limit(0); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -227,27 +227,27 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public function pre_fetch() { |
| 229 | 229 | |
| 230 | - if ( $this->step == 1 ) { |
|
| 231 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
| 230 | + if ($this->step == 1) { |
|
| 231 | + $this->delete_data('give_temp_delete_test_ids'); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
| 234 | + $items = get_option('give_temp_delete_test_ids', false); |
|
| 235 | 235 | |
| 236 | - if ( false === $items ) { |
|
| 236 | + if (false === $items) { |
|
| 237 | 237 | $items = array(); |
| 238 | 238 | |
| 239 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 239 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 240 | 240 | 'post_status' => 'any', |
| 241 | - 'number' => - 1, |
|
| 241 | + 'number' => -1, |
|
| 242 | 242 | 'meta_key' => '_give_payment_mode', |
| 243 | 243 | 'meta_value' => 'test' |
| 244 | - ) ); |
|
| 244 | + )); |
|
| 245 | 245 | |
| 246 | - $posts = new Give_Payments_Query( $args ); |
|
| 246 | + $posts = new Give_Payments_Query($args); |
|
| 247 | 247 | $payments = $posts->get_payments(); |
| 248 | 248 | |
| 249 | 249 | /* @var Give_Payment $payment */ |
| 250 | - foreach ( $payments as $payment ) { |
|
| 250 | + foreach ($payments as $payment) { |
|
| 251 | 251 | $items[] = array( |
| 252 | 252 | 'id' => (int) $payment->ID, |
| 253 | 253 | 'type' => 'give_payment', |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | // Allow filtering of items to remove with an unassociative array for each item. |
| 258 | 258 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
| 259 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
| 259 | + $items = apply_filters('give_delete_test_items', $items); |
|
| 260 | 260 | |
| 261 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
| 261 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | } |
@@ -272,17 +272,17 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return mixed Returns the data from the database |
| 274 | 274 | */ |
| 275 | - private function get_stored_data( $key ) { |
|
| 275 | + private function get_stored_data($key) { |
|
| 276 | 276 | global $wpdb; |
| 277 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 277 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 278 | 278 | |
| 279 | - if ( empty( $value ) ) { |
|
| 279 | + if (empty($value)) { |
|
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - $maybe_json = json_decode( $value ); |
|
| 284 | - if ( ! is_null( $maybe_json ) ) { |
|
| 285 | - $value = json_decode( $value, true ); |
|
| 283 | + $maybe_json = json_decode($value); |
|
| 284 | + if ( ! is_null($maybe_json)) { |
|
| 285 | + $value = json_decode($value, true); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | return $value; |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return void |
| 300 | 300 | */ |
| 301 | - private function store_data( $key, $value ) { |
|
| 301 | + private function store_data($key, $value) { |
|
| 302 | 302 | global $wpdb; |
| 303 | 303 | |
| 304 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 304 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 305 | 305 | |
| 306 | 306 | $data = array( |
| 307 | 307 | 'option_name' => $key, |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | '%s', |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 318 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -327,9 +327,9 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @return void |
| 329 | 329 | */ |
| 330 | - private function delete_data( $key ) { |
|
| 330 | + private function delete_data($key) { |
|
| 331 | 331 | global $wpdb; |
| 332 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 332 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | } |
@@ -65,18 +65,18 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param $args |
| 67 | 67 | */ |
| 68 | - public function __construct( $args ) { |
|
| 68 | + public function __construct($args) { |
|
| 69 | 69 | |
| 70 | 70 | // Only for admins. |
| 71 | - if ( ! is_admin() ) { |
|
| 71 | + if ( ! is_admin()) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - foreach ( $args as $key => $arg ) { |
|
| 75 | + foreach ($args as $key => $arg) { |
|
| 76 | 76 | $this->$key = $arg; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
| 79 | + add_action('admin_init', array($this, 'init')); |
|
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | } |
@@ -87,19 +87,19 @@ discard block |
||
| 87 | 87 | function init() { |
| 88 | 88 | |
| 89 | 89 | // First get user's locale (4.7+). |
| 90 | - $this->locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 90 | + $this->locale = function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 91 | 91 | |
| 92 | 92 | // This plugin is en_US native. |
| 93 | - if ( 'en_US' === $this->locale ) { |
|
| 93 | + if ('en_US' === $this->locale) { |
|
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | if ( |
| 98 | 98 | ! $this->hide_promo() |
| 99 | - && ( ! empty( $_GET['post_type'] ) && 'give_forms' === $_GET['post_type'] ) |
|
| 100 | - && ( ! empty( $_GET['page'] ) && 'give-settings' === $_GET['page'] ) |
|
| 99 | + && ( ! empty($_GET['post_type']) && 'give_forms' === $_GET['post_type']) |
|
| 100 | + && ( ! empty($_GET['page']) && 'give-settings' === $_GET['page']) |
|
| 101 | 101 | ) { |
| 102 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
| 102 | + add_action($this->hook, array($this, 'promo')); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -112,11 +112,11 @@ discard block |
||
| 112 | 112 | * @return bool |
| 113 | 113 | */ |
| 114 | 114 | private function hide_promo() { |
| 115 | - $hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true ); |
|
| 116 | - if ( ! $hide_promo ) { |
|
| 117 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
| 115 | + $hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true); |
|
| 116 | + if ( ! $hide_promo) { |
|
| 117 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
| 118 | 118 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
| 119 | - Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true ); |
|
| 119 | + Give_Cache::set('give_i18n_give_promo_hide', true, null, true); |
|
| 120 | 120 | $hide_promo = true; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -135,20 +135,20 @@ discard block |
||
| 135 | 135 | $message = false; |
| 136 | 136 | |
| 137 | 137 | // Using a translation less than 90% complete. |
| 138 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
| 139 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
| 140 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
| 141 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
| 142 | - } elseif ( ! $this->translation_exists ) { |
|
| 143 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
| 138 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
| 139 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
| 140 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
| 141 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
| 142 | + } elseif ( ! $this->translation_exists) { |
|
| 143 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Links. |
| 147 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
| 148 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
| 147 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
| 148 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
| 149 | 149 | |
| 150 | 150 | // Message. |
| 151 | - $message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link ); |
|
| 151 | + $message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link); |
|
| 152 | 152 | |
| 153 | 153 | return $message; |
| 154 | 154 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $this->translation_details(); |
| 163 | 163 | $message = $this->promo_message(); |
| 164 | 164 | |
| 165 | - if ( $message ) { ?> |
|
| 165 | + if ($message) { ?> |
|
| 166 | 166 | |
| 167 | 167 | <style> |
| 168 | 168 | /* Banner specific styles */ |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | style="font-size: 110px; text-decoration: none;"></span></a> |
| 228 | 228 | |
| 229 | 229 | <div class="give-i18n-notice-content"> |
| 230 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 230 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 231 | 231 | |
| 232 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
| 232 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
| 233 | 233 | <p><?php echo $message; ?></p> |
| 234 | 234 | <p> |
| 235 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
| 235 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
| 236 | 236 | </p> |
| 237 | 237 | </div> |
| 238 | 238 | </div> |
@@ -249,11 +249,11 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | private function find_or_initialize_translation_details() { |
| 251 | 251 | |
| 252 | - $set = Give_Cache::get( "give_i18n_give_{$this->locale}", true ); |
|
| 252 | + $set = Give_Cache::get("give_i18n_give_{$this->locale}", true); |
|
| 253 | 253 | |
| 254 | - if ( ! $set ) { |
|
| 254 | + if ( ! $set) { |
|
| 255 | 255 | $set = $this->retrieve_translation_details(); |
| 256 | - Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true ); |
|
| 256 | + Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | return $set; |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | private function translation_details() { |
| 268 | 268 | $set = $this->find_or_initialize_translation_details(); |
| 269 | 269 | |
| 270 | - $this->translation_exists = ! is_null( $set ); |
|
| 271 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
| 270 | + $this->translation_exists = ! is_null($set); |
|
| 271 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
| 272 | 272 | |
| 273 | - $this->parse_translation_set( $set ); |
|
| 273 | + $this->parse_translation_set($set); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -282,26 +282,26 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | private function retrieve_translation_details() { |
| 284 | 284 | |
| 285 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
| 285 | + $api_url = trailingslashit($this->glotpress_url); |
|
| 286 | 286 | |
| 287 | - $resp = wp_remote_get( $api_url ); |
|
| 287 | + $resp = wp_remote_get($api_url); |
|
| 288 | 288 | |
| 289 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
| 289 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
| 290 | 290 | return null; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - $body = wp_remote_retrieve_body( $resp ); |
|
| 294 | - unset( $resp ); |
|
| 293 | + $body = wp_remote_retrieve_body($resp); |
|
| 294 | + unset($resp); |
|
| 295 | 295 | |
| 296 | - if ( $body ) { |
|
| 297 | - $body = json_decode( $body ); |
|
| 296 | + if ($body) { |
|
| 297 | + $body = json_decode($body); |
|
| 298 | 298 | |
| 299 | - foreach ( $body->translation_sets as $set ) { |
|
| 300 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
| 299 | + foreach ($body->translation_sets as $set) { |
|
| 300 | + if ( ! property_exists($set, 'wp_locale')) { |
|
| 301 | 301 | continue; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ( $this->locale == $set->wp_locale ) { |
|
| 304 | + if ($this->locale == $set->wp_locale) { |
|
| 305 | 305 | return $set; |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -317,8 +317,8 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @access private |
| 319 | 319 | */ |
| 320 | - private function parse_translation_set( $set ) { |
|
| 321 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
| 320 | + private function parse_translation_set($set) { |
|
| 321 | + if ($this->translation_exists && is_object($set)) { |
|
| 322 | 322 | $this->locale_name = $set->name; |
| 323 | 323 | $this->percent_translated = $set->percent_translated; |
| 324 | 324 | } else { |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | -$give_i18n = new Give_i18n_Banner( array( |
|
| 331 | +$give_i18n = new Give_i18n_Banner(array( |
|
| 332 | 332 | 'hook' => 'admin_notices', |
| 333 | 333 | 'glotpress_url' => 'https://translate.wordpress.org/api/projects/wp-plugins/give/stable/', |
| 334 | - ) ); |
|
| 334 | + )); |
|
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
| 31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
| 32 | 32 | |
| 33 | 33 | // Make sure that payments are only completed once. |
| 34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
| 34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
| 39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
| 39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $payment = new Give_Payment( $payment_id ); |
|
| 43 | + $payment = new Give_Payment($payment_id); |
|
| 44 | 44 | |
| 45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
| 45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
| 46 | 46 | $payment_meta = $payment->payment_meta; |
| 47 | 47 | $completed_date = $payment->completed_date; |
| 48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param int $payment_id The ID of the payment. |
| 60 | 60 | */ |
| 61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
| 61 | + do_action('give_pre_complete_donation', $payment_id); |
|
| 62 | 62 | |
| 63 | 63 | // Ensure these actions only run once, ever. |
| 64 | - if ( empty( $completed_date ) ) { |
|
| 64 | + if (empty($completed_date)) { |
|
| 65 | 65 | |
| 66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
| 66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
| 74 | 74 | * @param int $payment_id The ID number of the payment. |
| 75 | 75 | * @param array $payment_meta The payment meta. |
| 76 | 76 | */ |
| 77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
| 77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Increase the earnings for this form ID. |
| 82 | - give_increase_earnings( $form_id, $amount ); |
|
| 83 | - give_increase_donation_count( $form_id ); |
|
| 82 | + give_increase_earnings($form_id, $amount); |
|
| 83 | + give_increase_donation_count($form_id); |
|
| 84 | 84 | |
| 85 | 85 | // @todo: Refresh only range related stat cache |
| 86 | 86 | give_delete_donation_stats(); |
| 87 | 87 | |
| 88 | 88 | // Increase the donor's donation stats. |
| 89 | - $donor = new Give_Donor( $donor_id ); |
|
| 89 | + $donor = new Give_Donor($donor_id); |
|
| 90 | 90 | $donor->increase_purchase_count(); |
| 91 | - $donor->increase_value( $amount ); |
|
| 91 | + $donor->increase_value($amount); |
|
| 92 | 92 | |
| 93 | - give_increase_total_earnings( $amount ); |
|
| 93 | + give_increase_total_earnings($amount); |
|
| 94 | 94 | |
| 95 | 95 | // Ensure this action only runs once ever. |
| 96 | - if ( empty( $completed_date ) ) { |
|
| 96 | + if (empty($completed_date)) { |
|
| 97 | 97 | |
| 98 | 98 | // Save the completed date. |
| 99 | - $payment->completed_date = current_time( 'mysql' ); |
|
| 99 | + $payment->completed_date = current_time('mysql'); |
|
| 100 | 100 | $payment->save(); |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param int $payment_id The ID of the payment. |
| 108 | 108 | */ |
| 109 | - do_action( 'give_complete_donation', $payment_id ); |
|
| 109 | + do_action('give_complete_donation', $payment_id); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
| 114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
| 128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
| 129 | 129 | |
| 130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
| 131 | 131 | $stati = give_get_payment_statuses(); |
| 132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
| 133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
| 132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
| 133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
| 134 | 134 | |
| 135 | 135 | // translators: 1: old status 2: new status. |
| 136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
| 136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
| 137 | 137 | |
| 138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
| 138 | + give_insert_payment_note($payment_id, $status_change); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
| 141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
| 154 | 154 | * |
| 155 | 155 | * @return void |
| 156 | 156 | */ |
| 157 | -function give_update_old_payments_with_totals( $data ) { |
|
| 158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
| 157 | +function give_update_old_payments_with_totals($data) { |
|
| 158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
| 162 | + if (get_option('give_payment_totals_upgraded')) { |
|
| 163 | 163 | return; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $payments = give_get_payments( array( |
|
| 166 | + $payments = give_get_payments(array( |
|
| 167 | 167 | 'offset' => 0, |
| 168 | - 'number' => - 1, |
|
| 168 | + 'number' => -1, |
|
| 169 | 169 | 'mode' => 'all', |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | - if ( $payments ) { |
|
| 173 | - foreach ( $payments as $payment ) { |
|
| 172 | + if ($payments) { |
|
| 173 | + foreach ($payments as $payment) { |
|
| 174 | 174 | |
| 175 | - $payment = new Give_Payment( $payment->ID ); |
|
| 175 | + $payment = new Give_Payment($payment->ID); |
|
| 176 | 176 | $meta = $payment->get_meta(); |
| 177 | 177 | |
| 178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
| 184 | + add_option('give_payment_totals_upgraded', 1); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
| 187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
| 198 | 198 | function give_mark_abandoned_donations() { |
| 199 | 199 | $args = array( |
| 200 | 200 | 'status' => 'pending', |
| 201 | - 'number' => - 1, |
|
| 201 | + 'number' => -1, |
|
| 202 | 202 | 'output' => 'give_payments', |
| 203 | 203 | ); |
| 204 | 204 | |
| 205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 206 | 206 | |
| 207 | - $payments = give_get_payments( $args ); |
|
| 207 | + $payments = give_get_payments($args); |
|
| 208 | 208 | |
| 209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 210 | 210 | |
| 211 | - if ( $payments ) { |
|
| 211 | + if ($payments) { |
|
| 212 | 212 | /** |
| 213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
| 214 | 214 | * |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
| 218 | 218 | */ |
| 219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
| 219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
| 220 | 220 | |
| 221 | - foreach ( $payments as $payment ) { |
|
| 222 | - $gateway = give_get_payment_gateway( $payment ); |
|
| 221 | + foreach ($payments as $payment) { |
|
| 222 | + $gateway = give_get_payment_gateway($payment); |
|
| 223 | 223 | |
| 224 | 224 | // Skip payment gateways. |
| 225 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
| 225 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
| 226 | 226 | continue; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
| 235 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return void |
| 246 | 246 | */ |
| 247 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
| 247 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
| 248 | 248 | // Monthly stats. |
| 249 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 249 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 250 | 250 | |
| 251 | 251 | // @todo: Refresh only range related stat cache |
| 252 | 252 | give_delete_donation_stats(); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
| 255 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
| 256 | 256 | |
| 257 | 257 | /* |
| 258 | 258 | * Add meta in payment that store page id and page url. |
@@ -264,18 +264,18 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @param {integer} $payment_id Payment id for which the meta value should be updated. |
| 266 | 266 | */ |
| 267 | -function give_payment_save_page_data( $payment_id ) { |
|
| 268 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
| 267 | +function give_payment_save_page_data($payment_id) { |
|
| 268 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
| 269 | 269 | // Check $page_url is not empty. |
| 270 | - if ( $page_url ) { |
|
| 271 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
| 272 | - $page_id = url_to_postid( $page_url ); |
|
| 270 | + if ($page_url) { |
|
| 271 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
| 272 | + $page_id = url_to_postid($page_url); |
|
| 273 | 273 | // Check $page_id is not empty. |
| 274 | - if ( $page_id ) { |
|
| 275 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
| 274 | + if ($page_id) { |
|
| 275 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Fire when payment is save. |
| 281 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
| 282 | 281 | \ No newline at end of file |
| 282 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
| 283 | 283 | \ No newline at end of file |