@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | * @since 1.8.17 |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; // Exit if accessed directly |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Give_Import_Core_Settings' ) ) { |
|
18 | +if ( ! class_exists('Give_Import_Core_Settings')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Give_Import_Core_Settings. |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return static |
69 | 69 | */ |
70 | 70 | public static function get_instance() { |
71 | - if ( null === static::$instance ) { |
|
71 | + if (null === static::$instance) { |
|
72 | 72 | self::$instance = new static(); |
73 | 73 | } |
74 | 74 | |
@@ -95,26 +95,26 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | private function setup_hooks() { |
98 | - if ( ! $this->is_donations_import_page() ) { |
|
98 | + if ( ! $this->is_donations_import_page()) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Do not render main import tools page. |
103 | - remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) ); |
|
103 | + remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',)); |
|
104 | 104 | |
105 | 105 | // Render donation import page |
106 | - add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) ); |
|
106 | + add_action('give_admin_field_tools_import', array($this, 'render_page')); |
|
107 | 107 | |
108 | 108 | // Print the HTML. |
109 | - add_action( 'give_tools_import_core_settings_form_start', array( $this, 'html' ), 10 ); |
|
109 | + add_action('give_tools_import_core_settings_form_start', array($this, 'html'), 10); |
|
110 | 110 | |
111 | 111 | // Run when form submit. |
112 | - add_action( 'give-tools_save_import', array( $this, 'save' ) ); |
|
112 | + add_action('give-tools_save_import', array($this, 'save')); |
|
113 | 113 | |
114 | - add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 ); |
|
114 | + add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1); |
|
115 | 115 | |
116 | 116 | // Used to add submit button. |
117 | - add_action( 'give_tools_import_core_settings_form_end', array( $this, 'submit' ), 10 ); |
|
117 | + add_action('give_tools_import_core_settings_form_end', array($this, 'submit'), 10); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return mixed |
128 | 128 | */ |
129 | - public function update_notices( $messages ) { |
|
130 | - if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) { |
|
131 | - unset( $messages['give-setting-updated'] ); |
|
129 | + public function update_notices($messages) { |
|
130 | + if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) { |
|
131 | + unset($messages['give-setting-updated']); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | return $messages; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @since 1.8.17 |
141 | 141 | */ |
142 | 142 | public function submit() { |
143 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
143 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
144 | 144 | ?> |
145 | 145 | <input type="hidden" class="import-step" id="import-step" name="step" value="<?php echo $this->get_step(); ?>"/> |
146 | 146 | <input type="hidden" class="importer-type" value="<?php echo $this->importer_type; ?>"/> |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | id="<?php echo "step-{$step}"; ?>"> |
164 | 164 | <tbody> |
165 | 165 | <?php |
166 | - switch ( $this->get_step() ) { |
|
166 | + switch ($this->get_step()) { |
|
167 | 167 | case 1: |
168 | 168 | $this->render_upload_html(); |
169 | 169 | break; |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | public function import_success() { |
191 | 191 | // Imported successfully |
192 | 192 | |
193 | - $success = (bool) ( isset( $_GET['success'] ) ? give_clean( $_GET['success'] ) : false ); |
|
194 | - $undo = (bool) ( isset( $_GET['undo'] ) ? give_clean( $_GET['undo'] ) : false ); |
|
193 | + $success = (bool) (isset($_GET['success']) ? give_clean($_GET['success']) : false); |
|
194 | + $undo = (bool) (isset($_GET['undo']) ? give_clean($_GET['undo']) : false); |
|
195 | 195 | $query_arg_setting = array( |
196 | 196 | 'post_type' => 'give_forms', |
197 | 197 | 'page' => 'give-settings', |
198 | 198 | ); |
199 | 199 | |
200 | - if ( $undo ) { |
|
200 | + if ($undo) { |
|
201 | 201 | $success = false; |
202 | 202 | } |
203 | 203 | |
@@ -210,30 +210,30 @@ discard block |
||
210 | 210 | 'undo' => 'true', |
211 | 211 | ); |
212 | 212 | |
213 | - $title = __( 'Settings Importing Completed!', 'give' ); |
|
214 | - if ( $success ) { |
|
213 | + $title = __('Settings Importing Completed!', 'give'); |
|
214 | + if ($success) { |
|
215 | 215 | $query_arg_success['undo'] = '1'; |
216 | 216 | $query_arg_success['step'] = '3'; |
217 | 217 | $query_arg_success['success'] = '1'; |
218 | - $text = __( 'Undo Importing', 'give' ); |
|
218 | + $text = __('Undo Importing', 'give'); |
|
219 | 219 | } else { |
220 | - if ( $undo ) { |
|
221 | - $host_give_options = get_option( 'give_settings_old', array() ); |
|
222 | - update_option( 'give_settings', $host_give_options ); |
|
223 | - $title = __( 'Undo of Setting Imported Completed!', 'give' ); |
|
220 | + if ($undo) { |
|
221 | + $host_give_options = get_option('give_settings_old', array()); |
|
222 | + update_option('give_settings', $host_give_options); |
|
223 | + $title = __('Undo of Setting Imported Completed!', 'give'); |
|
224 | 224 | } else { |
225 | - $title = __( 'Failed to import', 'give' ); |
|
225 | + $title = __('Failed to import', 'give'); |
|
226 | 226 | } |
227 | 227 | |
228 | - $text = __( 'Importing Again', 'give' ); |
|
228 | + $text = __('Importing Again', 'give'); |
|
229 | 229 | } |
230 | 230 | ?> |
231 | 231 | <tr valign="top" class="give-import-dropdown"> |
232 | 232 | <th colspan="2"> |
233 | 233 | <h2><?php echo $title; ?></h2> |
234 | 234 | <p> |
235 | - <a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg_success, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a> |
|
236 | - <a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg_setting, admin_url( 'edit.php' ) ); ?>"><?php echo __( 'View Settings', 'give' ); ?></a> |
|
235 | + <a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg_success, admin_url('edit.php')); ?>"><?php echo $text; ?></a> |
|
236 | + <a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg_setting, admin_url('edit.php')); ?>"><?php echo __('View Settings', 'give'); ?></a> |
|
237 | 237 | </p> |
238 | 238 | </th> |
239 | 239 | </tr> |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | * @since 1.8.17 |
247 | 247 | */ |
248 | 248 | public function start_import() { |
249 | - $type = ( ! empty( $_GET['type'] ) ? give_clean( $_GET['type'] ) : 'replace' ); |
|
250 | - $file_name = ( ! empty( $_GET['file_name'] ) ? give_clean( $_GET['file_name'] ) : '' ); |
|
249 | + $type = ( ! empty($_GET['type']) ? give_clean($_GET['type']) : 'replace'); |
|
250 | + $file_name = ( ! empty($_GET['file_name']) ? give_clean($_GET['file_name']) : ''); |
|
251 | 251 | |
252 | 252 | ?> |
253 | 253 | <tr valign="top" class="give-import-dropdown"> |
254 | 254 | <th colspan="2"> |
255 | - <h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2> |
|
256 | - <p class="give-field-description"><?php esc_html_e( 'Your settings are now being imported...', 'give' ) ?></p> |
|
255 | + <h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2> |
|
256 | + <p class="give-field-description"><?php esc_html_e('Your settings are now being imported...', 'give') ?></p> |
|
257 | 257 | </th> |
258 | 258 | </tr> |
259 | 259 | |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | $step = $this->get_step(); |
287 | 287 | ?> |
288 | 288 | <ol class="give-progress-steps"> |
289 | - <li class="<?php echo( 1 === $step ? 'active' : '' ); ?>"> |
|
290 | - <?php esc_html_e( 'Upload JSON file', 'give' ); ?> |
|
289 | + <li class="<?php echo(1 === $step ? 'active' : ''); ?>"> |
|
290 | + <?php esc_html_e('Upload JSON file', 'give'); ?> |
|
291 | 291 | </li> |
292 | - <li class="<?php echo( 2 === $step ? 'active' : '' ); ?>"> |
|
293 | - <?php esc_html_e( 'Import', 'give' ); ?> |
|
292 | + <li class="<?php echo(2 === $step ? 'active' : ''); ?>"> |
|
293 | + <?php esc_html_e('Import', 'give'); ?> |
|
294 | 294 | </li> |
295 | - <li class="<?php echo( 3 === $step ? 'active' : '' ); ?>"> |
|
296 | - <?php esc_html_e( 'Done!', 'give' ); ?> |
|
295 | + <li class="<?php echo(3 === $step ? 'active' : ''); ?>"> |
|
296 | + <?php esc_html_e('Done!', 'give'); ?> |
|
297 | 297 | </li> |
298 | 298 | </ol> |
299 | 299 | <?php |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | * @return int $step on which step doest the import is on. |
308 | 308 | */ |
309 | 309 | public function get_step() { |
310 | - $step = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 ); |
|
310 | + $step = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0); |
|
311 | 311 | $on_step = 1; |
312 | 312 | |
313 | - if ( empty( $step ) || 1 === $step ) { |
|
313 | + if (empty($step) || 1 === $step) { |
|
314 | 314 | $on_step = 1; |
315 | - } elseif ( 2 === $step ) { |
|
315 | + } elseif (2 === $step) { |
|
316 | 316 | $on_step = 2; |
317 | - } elseif ( 3 === $step ) { |
|
317 | + } elseif (3 === $step) { |
|
318 | 318 | $on_step = 3; |
319 | 319 | } |
320 | 320 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @since 1.8.17 |
328 | 328 | */ |
329 | 329 | public function render_page() { |
330 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-core-settings.php'; |
|
330 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-core-settings.php'; |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -339,28 +339,28 @@ discard block |
||
339 | 339 | * @return void |
340 | 340 | */ |
341 | 341 | public function render_upload_html() { |
342 | - $json = ( isset( $_POST['json'] ) ? give_clean( $_POST['json'] ) : '' ); |
|
343 | - $type = ( isset( $_POST['type'] ) ? give_clean( $_POST['type'] ) : 'merge' ); |
|
342 | + $json = (isset($_POST['json']) ? give_clean($_POST['json']) : ''); |
|
343 | + $type = (isset($_POST['type']) ? give_clean($_POST['type']) : 'merge'); |
|
344 | 344 | $step = $this->get_step(); |
345 | 345 | |
346 | 346 | ?> |
347 | 347 | <tr valign="top"> |
348 | 348 | <th colspan="2"> |
349 | - <h2 id="give-import-title"><?php esc_html_e( 'Import Core Settings from a JSON file', 'give' ) ?></h2> |
|
350 | - <p class="give-field-description"><?php esc_html_e( 'This tool allows you to import Give settings from another Give installation. Settings imported contain data from Give core as well as any of our Premium Add-ons.', 'give' ) ?></p> |
|
349 | + <h2 id="give-import-title"><?php esc_html_e('Import Core Settings from a JSON file', 'give') ?></h2> |
|
350 | + <p class="give-field-description"><?php esc_html_e('This tool allows you to import Give settings from another Give installation. Settings imported contain data from Give core as well as any of our Premium Add-ons.', 'give') ?></p> |
|
351 | 351 | </th> |
352 | 352 | </tr> |
353 | 353 | |
354 | 354 | <tr valign="top"> |
355 | 355 | <th scope="row" class="titledesc"> |
356 | - <label for="json"><?php esc_html_e( 'Choose a JSON file:', 'give' ) ?></label> |
|
356 | + <label for="json"><?php esc_html_e('Choose a JSON file:', 'give') ?></label> |
|
357 | 357 | </th> |
358 | 358 | <td class="give-forminp"> |
359 | 359 | <div class="give-field-wrap"> |
360 | 360 | <label for="json"> |
361 | 361 | <input type="file" name="json" class="give-upload-json-file" value="<?php echo $json; ?>" |
362 | 362 | accept=".json"> |
363 | - <p class="give-field-description"><?php esc_html_e( 'The file type must be JSON.', 'give' )?></p> |
|
363 | + <p class="give-field-description"><?php esc_html_e('The file type must be JSON.', 'give')?></p> |
|
364 | 364 | </label> |
365 | 365 | </div> |
366 | 366 | </td> |
@@ -369,20 +369,20 @@ discard block |
||
369 | 369 | $settings = array( |
370 | 370 | array( |
371 | 371 | 'id' => 'type', |
372 | - 'name' => __( 'Merge Type:', 'give' ), |
|
373 | - 'description' => __( 'Select "Merge" to retain existing settings, or "Replace" to overwrite with the settings from the JSON file', 'give' ), |
|
372 | + 'name' => __('Merge Type:', 'give'), |
|
373 | + 'description' => __('Select "Merge" to retain existing settings, or "Replace" to overwrite with the settings from the JSON file', 'give'), |
|
374 | 374 | 'default' => $type, |
375 | 375 | 'type' => 'radio_inline', |
376 | 376 | 'options' => array( |
377 | - 'merge' => __( 'Merge', 'give' ), |
|
378 | - 'replace' => __( 'Replace', 'give' ), |
|
377 | + 'merge' => __('Merge', 'give'), |
|
378 | + 'replace' => __('Replace', 'give'), |
|
379 | 379 | ), |
380 | 380 | ), |
381 | 381 | ); |
382 | 382 | |
383 | - $settings = apply_filters( 'give_import_core_setting_html', $settings ); |
|
383 | + $settings = apply_filters('give_import_core_setting_html', $settings); |
|
384 | 384 | |
385 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
385 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
386 | 386 | ?> |
387 | 387 | <tr valign="top"> |
388 | 388 | <th></th> |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | <input type="submit" |
391 | 391 | class="button button-primary button-large button-secondary <?php echo "step-{$step}"; ?>" |
392 | 392 | id="recount-stats-submit" |
393 | - value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/> |
|
393 | + value="<?php esc_attr_e('Submit', 'give'); ?>"/> |
|
394 | 394 | </th> |
395 | 395 | </tr> |
396 | 396 | <?php |
@@ -407,20 +407,20 @@ discard block |
||
407 | 407 | $step = $this->get_step(); |
408 | 408 | |
409 | 409 | // Validation for first step. |
410 | - if ( 1 === $step ) { |
|
411 | - $type = ( ! empty( $_REQUEST['type'] ) ? give_clean( $_REQUEST['type'] ) : 'replace' ); |
|
410 | + if (1 === $step) { |
|
411 | + $type = ( ! empty($_REQUEST['type']) ? give_clean($_REQUEST['type']) : 'replace'); |
|
412 | 412 | $core_settings = self::upload_widget_settings_file(); |
413 | - if ( ! empty( $core_settings['error'] ) ) { |
|
414 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload a valid JSON settings file.', 'give' ) ); |
|
413 | + if ( ! empty($core_settings['error'])) { |
|
414 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload a valid JSON settings file.', 'give')); |
|
415 | 415 | } else { |
416 | - $file_path = explode( '/', $core_settings['file'] ); |
|
417 | - $count = ( count( $file_path ) - 1 ); |
|
418 | - $url = give_import_page_url( (array) apply_filters( 'give_import_core_settings_importing_url', array( |
|
416 | + $file_path = explode('/', $core_settings['file']); |
|
417 | + $count = (count($file_path) - 1); |
|
418 | + $url = give_import_page_url((array) apply_filters('give_import_core_settings_importing_url', array( |
|
419 | 419 | 'step' => '2', |
420 | 420 | 'importer-type' => $this->importer_type, |
421 | 421 | 'type' => $type, |
422 | - 'file_name' => $file_path[ $count ], |
|
423 | - ) ) ); |
|
422 | + 'file_name' => $file_path[$count], |
|
423 | + ))); |
|
424 | 424 | |
425 | 425 | ?> |
426 | 426 | <script type="text/javascript"> |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @return bool |
439 | 439 | */ |
440 | 440 | private function is_donations_import_page() { |
441 | - return 'import' === give_get_current_setting_tab() && isset( $_GET['importer-type'] ) && $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
441 | + return 'import' === give_get_current_setting_tab() && isset($_GET['importer-type']) && $this->importer_type === give_clean($_GET['importer-type']); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public static function upload_widget_settings_file() { |
449 | 449 | $upload = false; |
450 | - if ( isset( $_FILES['json'] ) ) { |
|
451 | - add_filter( 'upload_mimes', array( __CLASS__, 'json_upload_mimes' ) ); |
|
450 | + if (isset($_FILES['json'])) { |
|
451 | + add_filter('upload_mimes', array(__CLASS__, 'json_upload_mimes')); |
|
452 | 452 | |
453 | - $upload = wp_handle_upload( $_FILES['json'], array( 'test_form' => false ) ); |
|
453 | + $upload = wp_handle_upload($_FILES['json'], array('test_form' => false)); |
|
454 | 454 | |
455 | - remove_filter( 'upload_mimes', array( __CLASS__, 'json_upload_mimes' ) ); |
|
455 | + remove_filter('upload_mimes', array(__CLASS__, 'json_upload_mimes')); |
|
456 | 456 | } else { |
457 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) ); |
|
457 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give')); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | return $upload; |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @param array $existing_mimes |
467 | 467 | */ |
468 | - public static function json_upload_mimes( $existing_mimes = array() ) { |
|
468 | + public static function json_upload_mimes($existing_mimes = array()) { |
|
469 | 469 | $existing_mimes['json'] = 'application/json'; |
470 | 470 | |
471 | 471 | return $existing_mimes; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /* @var WPDB $wpdb */ |
51 | 51 | global $wpdb; |
52 | 52 | |
53 | - $wpdb->paymentmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta'; |
|
53 | + $wpdb->paymentmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta'; |
|
54 | 54 | $this->primary_key = 'meta_id'; |
55 | 55 | $this->version = '1.0'; |
56 | 56 | |
@@ -84,6 +84,6 @@ discard block |
||
84 | 84 | * @return bool |
85 | 85 | */ |
86 | 86 | protected function is_custom_meta_table_active() { |
87 | - return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ); |
|
87 | + return give_has_upgrade_completed('v20_move_metadata_into_new_table'); |
|
88 | 88 | } |
89 | 89 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /* @var WPDB $wpdb */ |
51 | 51 | global $wpdb; |
52 | 52 | |
53 | - $wpdb->logmeta = $this->table_name = $wpdb->prefix . 'give_logmeta'; |
|
53 | + $wpdb->logmeta = $this->table_name = $wpdb->prefix.'give_logmeta'; |
|
54 | 54 | $this->primary_key = 'meta_id'; |
55 | 55 | $this->version = '1.0'; |
56 | 56 | |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return bool |
88 | 88 | */ |
89 | - public function delete_row( $log_id = 0 ) { |
|
89 | + public function delete_row($log_id = 0) { |
|
90 | 90 | /* @var WPDB $wpdb */ |
91 | 91 | global $wpdb; |
92 | 92 | |
93 | 93 | // Row ID must be positive integer |
94 | - $log_id = absint( $log_id ); |
|
94 | + $log_id = absint($log_id); |
|
95 | 95 | |
96 | - if ( empty( $log_id ) ) { |
|
96 | + if (empty($log_id)) { |
|
97 | 97 | return false; |
98 | 98 | } |
99 | 99 | |
100 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) { |
|
100 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return bool |
116 | 116 | */ |
117 | - protected function is_valid_post_type( $ID ) { |
|
117 | + protected function is_valid_post_type($ID) { |
|
118 | 118 | return $ID && true; |
119 | 119 | } |
120 | 120 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /* @var WPDB $wpdb */ |
54 | 54 | global $wpdb; |
55 | 55 | |
56 | - $wpdb->donormeta = $this->table_name = $wpdb->prefix . 'give_donormeta'; |
|
56 | + $wpdb->donormeta = $this->table_name = $wpdb->prefix.'give_donormeta'; |
|
57 | 57 | $this->primary_key = 'meta_id'; |
58 | 58 | $this->version = '1.0'; |
59 | 59 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return bool False for failure. True for success. |
92 | 92 | */ |
93 | - public function delete_all_meta( $donor_id = 0 ) { |
|
93 | + public function delete_all_meta($donor_id = 0) { |
|
94 | 94 | global $wpdb; |
95 | - $status = $wpdb->delete( $this->table_name, array( 'donor_id' => $donor_id ), array( '%d' ) ); |
|
95 | + $status = $wpdb->delete($this->table_name, array('donor_id' => $donor_id), array('%d')); |
|
96 | 96 | |
97 | - if( $status ) { |
|
98 | - Give_Cache::delete_group( $donor_id, 'give-donors' ); |
|
97 | + if ($status) { |
|
98 | + Give_Cache::delete_group($donor_id, 'give-donors'); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | global $wpdb; |
112 | 112 | |
113 | 113 | if ( |
114 | - ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) && |
|
115 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) ) |
|
114 | + ! give_has_upgrade_completed('v20_rename_donor_tables') && |
|
115 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta")) |
|
116 | 116 | ) { |
117 | 117 | $wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta"; |
118 | 118 | $this->meta_type = 'customer'; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - protected function is_valid_post_type( $ID ) { |
|
134 | + protected function is_valid_post_type($ID) { |
|
135 | 135 | return $ID && true; |
136 | 136 | } |
137 | 137 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Constructor. |
50 | 50 | */ |
51 | - public function __construct( $_step = 1 ) { |
|
52 | - parent::__construct( $_step ); |
|
51 | + public function __construct($_step = 1) { |
|
52 | + parent::__construct($_step); |
|
53 | 53 | |
54 | 54 | $this->is_writable = true; |
55 | 55 | } |
@@ -66,32 +66,32 @@ discard block |
||
66 | 66 | |
67 | 67 | $args = array( |
68 | 68 | 'number' => $this->per_step, |
69 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
69 | + 'offset' => $this->per_step * ($this->step - 1), |
|
70 | 70 | 'orderby' => 'id', |
71 | 71 | 'order' => 'DESC', |
72 | 72 | ); |
73 | 73 | |
74 | - $donors = Give()->donors->get_donors( $args ); |
|
74 | + $donors = Give()->donors->get_donors($args); |
|
75 | 75 | |
76 | - if ( $donors ) { |
|
76 | + if ($donors) { |
|
77 | 77 | |
78 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
78 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
79 | 79 | |
80 | - foreach ( $donors as $donor ) { |
|
80 | + foreach ($donors as $donor) { |
|
81 | 81 | |
82 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
82 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
83 | 83 | |
84 | 84 | $attached_args = array( |
85 | 85 | 'post__in' => $attached_payment_ids, |
86 | - 'number' => - 1, |
|
86 | + 'number' => -1, |
|
87 | 87 | 'status' => $allowed_payment_status, |
88 | 88 | ); |
89 | 89 | |
90 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
90 | + $attached_payments = (array) give_get_payments($attached_args); |
|
91 | 91 | |
92 | 92 | $unattached_args = array( |
93 | 93 | 'post__not_in' => $attached_payment_ids, |
94 | - 'number' => - 1, |
|
94 | + 'number' => -1, |
|
95 | 95 | 'status' => $allowed_payment_status, |
96 | 96 | 'meta_query' => array( |
97 | 97 | array( |
@@ -102,29 +102,29 @@ discard block |
||
102 | 102 | ), |
103 | 103 | ); |
104 | 104 | |
105 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
105 | + $unattached_payments = give_get_payments($unattached_args); |
|
106 | 106 | |
107 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
107 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
108 | 108 | |
109 | 109 | $purchase_value = 0.00; |
110 | 110 | $purchase_count = 0; |
111 | 111 | $payment_ids = array(); |
112 | 112 | |
113 | - if ( $payments ) { |
|
113 | + if ($payments) { |
|
114 | 114 | |
115 | - foreach ( $payments as $payment ) { |
|
115 | + foreach ($payments as $payment) { |
|
116 | 116 | |
117 | 117 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
118 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
118 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
119 | 119 | |
120 | - if ( true === $should_process_payment ) { |
|
120 | + if (true === $should_process_payment) { |
|
121 | 121 | |
122 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
123 | - $purchase_value += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) ); |
|
122 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
123 | + $purchase_value += (float) give_donation_amount($payment->ID, array('type' => 'stats')); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
127 | - $purchase_count ++; |
|
126 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
127 | + $purchase_count++; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - $payment_ids = implode( ',', $payment_ids ); |
|
135 | + $payment_ids = implode(',', $payment_ids); |
|
136 | 136 | |
137 | 137 | $donor_update_data = array( |
138 | 138 | 'purchase_count' => $purchase_count, |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | 'payment_ids' => $payment_ids, |
141 | 141 | ); |
142 | 142 | |
143 | - $donor_instance = new Give_Donor( $donor->id ); |
|
144 | - $donor_instance->update( $donor_update_data ); |
|
143 | + $donor_instance = new Give_Donor($donor->id); |
|
144 | + $donor_instance->update($donor_update_data); |
|
145 | 145 | |
146 | 146 | }// End foreach(). |
147 | 147 | |
@@ -161,21 +161,21 @@ discard block |
||
161 | 161 | public function get_percentage_complete() { |
162 | 162 | |
163 | 163 | $args = array( |
164 | - 'number' => - 1, |
|
164 | + 'number' => -1, |
|
165 | 165 | 'orderby' => 'id', |
166 | 166 | 'order' => 'DESC', |
167 | 167 | ); |
168 | 168 | |
169 | - $donors = Give()->donors->get_donors( $args ); |
|
170 | - $total = count( $donors ); |
|
169 | + $donors = Give()->donors->get_donors($args); |
|
170 | + $total = count($donors); |
|
171 | 171 | |
172 | 172 | $percentage = 100; |
173 | 173 | |
174 | - if ( $total > 0 ) { |
|
175 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
174 | + if ($total > 0) { |
|
175 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
176 | 176 | } |
177 | 177 | |
178 | - if ( $percentage > 100 ) { |
|
178 | + if ($percentage > 100) { |
|
179 | 179 | $percentage = 100; |
180 | 180 | } |
181 | 181 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param array $request The Form Data passed into the batch processing |
191 | 191 | */ |
192 | - public function set_properties( $request ) { |
|
192 | + public function set_properties($request) { |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function process_step() { |
202 | 202 | |
203 | - if ( ! $this->can_export() ) { |
|
204 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
203 | + if ( ! $this->can_export()) { |
|
204 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array( |
|
205 | 205 | 'response' => 403, |
206 | - ) ); |
|
206 | + )); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | $had_data = $this->get_data(); |
210 | 210 | |
211 | - if ( $had_data ) { |
|
211 | + if ($had_data) { |
|
212 | 212 | $this->done = false; |
213 | 213 | |
214 | 214 | return true; |
215 | 215 | } else { |
216 | 216 | $this->done = true; |
217 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
217 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
218 | 218 | |
219 | 219 | return false; |
220 | 220 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Constructor. |
55 | 55 | */ |
56 | - public function __construct( $_step = 1 ) { |
|
57 | - parent::__construct( $_step ); |
|
56 | + public function __construct($_step = 1) { |
|
57 | + parent::__construct($_step); |
|
58 | 58 | |
59 | 59 | $this->is_writable = true; |
60 | 60 | } |
@@ -69,59 +69,59 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get_data() { |
71 | 71 | |
72 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
72 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
73 | 73 | |
74 | - if ( $this->step == 1 ) { |
|
75 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
74 | + if ($this->step == 1) { |
|
75 | + $this->delete_data('give_temp_recount_form_stats'); |
|
76 | 76 | } |
77 | 77 | |
78 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
78 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
79 | 79 | |
80 | - if ( false === $totals ) { |
|
80 | + if (false === $totals) { |
|
81 | 81 | $totals = array( |
82 | 82 | 'earnings' => (float) 0, |
83 | 83 | 'sales' => 0, |
84 | 84 | ); |
85 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
85 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
86 | 86 | } |
87 | 87 | |
88 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
88 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
89 | 89 | 'give_forms' => $this->form_id, |
90 | 90 | 'number' => $this->per_step, |
91 | 91 | 'status' => $accepted_statuses, |
92 | 92 | 'paged' => $this->step, |
93 | 93 | 'fields' => 'ids', |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | - $payments = new Give_Payments_Query( $args ); |
|
96 | + $payments = new Give_Payments_Query($args); |
|
97 | 97 | $payments = $payments->get_payments(); |
98 | 98 | |
99 | - if ( $payments ) { |
|
100 | - foreach ( $payments as $payment ) { |
|
99 | + if ($payments) { |
|
100 | + foreach ($payments as $payment) { |
|
101 | 101 | |
102 | 102 | // Ensure acceptable status only. |
103 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
103 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Ensure only payments for this form are counted. |
108 | - if ( $payment->form_id != $this->form_id ) { |
|
108 | + if ($payment->form_id != $this->form_id) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - $totals['sales'] ++; |
|
112 | + $totals['sales']++; |
|
113 | 113 | $totals['earnings'] += $payment->total; |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
117 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
118 | 118 | |
119 | 119 | return true; |
120 | 120 | } |
121 | 121 | |
122 | 122 | |
123 | - give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
124 | - give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
123 | + give_update_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
124 | + give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
125 | 125 | |
126 | 126 | return false; |
127 | 127 | } |
@@ -133,35 +133,35 @@ discard block |
||
133 | 133 | * @return int |
134 | 134 | */ |
135 | 135 | public function get_percentage_complete() { |
136 | - if ( $this->step == 1 ) { |
|
137 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
136 | + if ($this->step == 1) { |
|
137 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
138 | 138 | } |
139 | 139 | |
140 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
141 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
140 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
141 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
142 | 142 | |
143 | - if ( false === $total ) { |
|
143 | + if (false === $total) { |
|
144 | 144 | $total = 0; |
145 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
145 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
146 | 146 | 'give_forms' => $this->form_id, |
147 | - 'number' => - 1, |
|
147 | + 'number' => -1, |
|
148 | 148 | 'status' => $accepted_statuses, |
149 | 149 | 'fields' => 'ids', |
150 | - ) ); |
|
150 | + )); |
|
151 | 151 | |
152 | - $payments = new Give_Payments_Query( $args ); |
|
153 | - $total = count( $payments->get_payments() ); |
|
154 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
152 | + $payments = new Give_Payments_Query($args); |
|
153 | + $total = count($payments->get_payments()); |
|
154 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | $percentage = 100; |
159 | 159 | |
160 | - if ( $total > 0 ) { |
|
161 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
160 | + if ($total > 0) { |
|
161 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
162 | 162 | } |
163 | 163 | |
164 | - if ( $percentage > 100 ) { |
|
164 | + if ($percentage > 100) { |
|
165 | 165 | $percentage = 100; |
166 | 166 | } |
167 | 167 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @param array $request The Form Data passed into the batch processing |
177 | 177 | */ |
178 | - public function set_properties( $request ) { |
|
179 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
178 | + public function set_properties($request) { |
|
179 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -187,21 +187,21 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function process_step() { |
189 | 189 | |
190 | - if ( ! $this->can_export() ) { |
|
191 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
190 | + if ( ! $this->can_export()) { |
|
191 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $had_data = $this->get_data(); |
195 | 195 | |
196 | - if ( $had_data ) { |
|
196 | + if ($had_data) { |
|
197 | 197 | $this->done = false; |
198 | 198 | |
199 | 199 | return true; |
200 | 200 | } else { |
201 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
202 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
201 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
202 | + $this->delete_data('give_temp_recount_form_stats'); |
|
203 | 203 | $this->done = true; |
204 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
204 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
205 | 205 | |
206 | 206 | return false; |
207 | 207 | } |
@@ -235,17 +235,17 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return mixed Returns the data from the database |
237 | 237 | */ |
238 | - private function get_stored_data( $key ) { |
|
238 | + private function get_stored_data($key) { |
|
239 | 239 | global $wpdb; |
240 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
240 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
241 | 241 | |
242 | - if ( empty( $value ) ) { |
|
242 | + if (empty($value)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | - $maybe_json = json_decode( $value ); |
|
247 | - if ( ! is_null( $maybe_json ) ) { |
|
248 | - $value = json_decode( $value, true ); |
|
246 | + $maybe_json = json_decode($value); |
|
247 | + if ( ! is_null($maybe_json)) { |
|
248 | + $value = json_decode($value, true); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | return $value; |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return void |
263 | 263 | */ |
264 | - private function store_data( $key, $value ) { |
|
264 | + private function store_data($key, $value) { |
|
265 | 265 | global $wpdb; |
266 | 266 | |
267 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
267 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
268 | 268 | |
269 | 269 | $data = array( |
270 | 270 | 'option_name' => $key, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | '%s', |
279 | 279 | ); |
280 | 280 | |
281 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
281 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return void |
292 | 292 | */ |
293 | - private function delete_data( $key ) { |
|
293 | + private function delete_data($key) { |
|
294 | 294 | global $wpdb; |
295 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
295 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | } |
299 | 299 | \ 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 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -61,49 +61,49 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function get_data() { |
63 | 63 | |
64 | - if ( $this->step == 1 ) { |
|
65 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
64 | + if ($this->step == 1) { |
|
65 | + $this->delete_data('give_temp_recount_earnings'); |
|
66 | 66 | } |
67 | 67 | |
68 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
68 | + $total = get_option('give_temp_recount_earnings', false); |
|
69 | 69 | |
70 | - if ( false === $total ) { |
|
70 | + if (false === $total) { |
|
71 | 71 | $total = (float) 0; |
72 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
72 | + $this->store_data('give_temp_recount_earnings', $total); |
|
73 | 73 | } |
74 | 74 | |
75 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
75 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
76 | 76 | |
77 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
77 | + $args = apply_filters('give_recount_earnings_args', array( |
|
78 | 78 | 'number' => $this->per_step, |
79 | 79 | 'page' => $this->step, |
80 | 80 | 'status' => $accepted_statuses, |
81 | 81 | 'fields' => 'ids' |
82 | - ) ); |
|
82 | + )); |
|
83 | 83 | |
84 | - $payments = give_get_payments( $args ); |
|
84 | + $payments = give_get_payments($args); |
|
85 | 85 | |
86 | - if ( ! empty( $payments ) ) { |
|
86 | + if ( ! empty($payments)) { |
|
87 | 87 | |
88 | - foreach ( $payments as $payment ) { |
|
88 | + foreach ($payments as $payment) { |
|
89 | 89 | |
90 | - $total += (float) give_donation_amount( $payment, array( 'type' => 'stats' ) ); |
|
90 | + $total += (float) give_donation_amount($payment, array('type' => 'stats')); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - if ( $total < 0 ) { |
|
94 | + if ($total < 0) { |
|
95 | 95 | $totals = 0; |
96 | 96 | } |
97 | 97 | |
98 | - $total = round( $total, give_get_price_decimals() ); |
|
98 | + $total = round($total, give_get_price_decimals()); |
|
99 | 99 | |
100 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
100 | + $this->store_data('give_temp_recount_earnings', $total); |
|
101 | 101 | |
102 | 102 | return true; |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - update_option( 'give_earnings_total', $total ); |
|
106 | + update_option('give_earnings_total', $total); |
|
107 | 107 | |
108 | 108 | return false; |
109 | 109 | |
@@ -117,25 +117,25 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function get_percentage_complete() { |
119 | 119 | |
120 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
120 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
121 | 121 | |
122 | - if ( false === $total ) { |
|
123 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
122 | + if (false === $total) { |
|
123 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
124 | 124 | |
125 | - $counts = give_count_payments( $args ); |
|
126 | - $total = absint( $counts->publish ); |
|
127 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
125 | + $counts = give_count_payments($args); |
|
126 | + $total = absint($counts->publish); |
|
127 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
128 | 128 | |
129 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
129 | + $this->store_data('give_recount_earnings_total', $total); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $percentage = 100; |
133 | 133 | |
134 | - if ( $total > 0 ) { |
|
135 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
134 | + if ($total > 0) { |
|
135 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( $percentage > 100 ) { |
|
138 | + if ($percentage > 100) { |
|
139 | 139 | $percentage = 100; |
140 | 140 | } |
141 | 141 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @param array $request The Form Data passed into the batch processing |
151 | 151 | */ |
152 | - public function set_properties( $request ) { |
|
152 | + public function set_properties($request) { |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -160,21 +160,21 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function process_step() { |
162 | 162 | |
163 | - if ( ! $this->can_export() ) { |
|
164 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
163 | + if ( ! $this->can_export()) { |
|
164 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | $had_data = $this->get_data(); |
168 | 168 | |
169 | - if ( $had_data ) { |
|
169 | + if ($had_data) { |
|
170 | 170 | $this->done = false; |
171 | 171 | |
172 | 172 | return true; |
173 | 173 | } else { |
174 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
175 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
174 | + $this->delete_data('give_recount_earnings_total'); |
|
175 | + $this->delete_data('give_temp_recount_earnings'); |
|
176 | 176 | $this->done = true; |
177 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
177 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
178 | 178 | |
179 | 179 | return false; |
180 | 180 | } |
@@ -211,17 +211,17 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return mixed Returns the data from the database |
213 | 213 | */ |
214 | - private function get_stored_data( $key ) { |
|
214 | + private function get_stored_data($key) { |
|
215 | 215 | global $wpdb; |
216 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
216 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
217 | 217 | |
218 | - if ( empty( $value ) ) { |
|
218 | + if (empty($value)) { |
|
219 | 219 | return false; |
220 | 220 | } |
221 | 221 | |
222 | - $maybe_json = json_decode( $value ); |
|
223 | - if ( ! is_null( $maybe_json ) ) { |
|
224 | - $value = json_decode( $value, true ); |
|
222 | + $maybe_json = json_decode($value); |
|
223 | + if ( ! is_null($maybe_json)) { |
|
224 | + $value = json_decode($value, true); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $value; |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - private function store_data( $key, $value ) { |
|
240 | + private function store_data($key, $value) { |
|
241 | 241 | global $wpdb; |
242 | 242 | |
243 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
243 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
244 | 244 | |
245 | 245 | $data = array( |
246 | 246 | 'option_name' => $key, |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | '%s', |
255 | 255 | ); |
256 | 256 | |
257 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
257 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return void |
268 | 268 | */ |
269 | - private function delete_data( $key ) { |
|
269 | + private function delete_data($key) { |
|
270 | 270 | global $wpdb; |
271 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
271 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | * @return array|bool $data The data for the CSV file |
63 | 63 | */ |
64 | 64 | public function get_data() { |
65 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids' ); |
|
65 | + $items = $this->get_stored_data('give_temp_delete_test_ids'); |
|
66 | 66 | |
67 | - if ( ! is_array( $items ) ) { |
|
67 | + if ( ! is_array($items)) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | |
71 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
72 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
73 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
71 | + $offset = ($this->step - 1) * $this->per_step; |
|
72 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
73 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
74 | 74 | |
75 | - if ( $step_items ) { |
|
76 | - foreach ( $step_items as $item ) { |
|
75 | + if ($step_items) { |
|
76 | + foreach ($step_items as $item) { |
|
77 | 77 | // Delete the main payment. |
78 | - give_delete_donation( absint( $item['id'] ) ); |
|
78 | + give_delete_donation(absint($item['id'])); |
|
79 | 79 | } |
80 | 80 | return true; |
81 | 81 | } |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_percentage_complete() { |
93 | 93 | |
94 | - $items = $this->get_stored_data( 'give_temp_delete_test_ids', false ); |
|
95 | - $total = count( $items ); |
|
94 | + $items = $this->get_stored_data('give_temp_delete_test_ids', false); |
|
95 | + $total = count($items); |
|
96 | 96 | |
97 | 97 | $percentage = 100; |
98 | 98 | |
99 | - if ( $total > 0 ) { |
|
100 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
99 | + if ($total > 0) { |
|
100 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $percentage > 100 ) { |
|
103 | + if ($percentage > 100) { |
|
104 | 104 | $percentage = 100; |
105 | 105 | } |
106 | 106 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param array $request The Form Data passed into the batch processing |
116 | 116 | */ |
117 | - public function set_properties( $request ) { |
|
117 | + public function set_properties($request) { |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,29 +125,29 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function process_step() { |
127 | 127 | |
128 | - if ( ! $this->can_export() ) { |
|
129 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
128 | + if ( ! $this->can_export()) { |
|
129 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $had_data = $this->get_data(); |
133 | 133 | |
134 | - if ( $had_data ) { |
|
134 | + if ($had_data) { |
|
135 | 135 | $this->done = false; |
136 | 136 | |
137 | 137 | return true; |
138 | 138 | } else { |
139 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
140 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
139 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
140 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
141 | 141 | |
142 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
142 | + $this->delete_data('give_temp_delete_test_ids'); |
|
143 | 143 | |
144 | 144 | // Reset the sequential order numbers |
145 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
146 | - delete_option( 'give_last_payment_number' ); |
|
145 | + if (give_get_option('enable_sequential')) { |
|
146 | + delete_option('give_last_payment_number'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $this->done = true; |
150 | - $this->message = __( 'Test transactions successfully deleted.', 'give' ); |
|
150 | + $this->message = __('Test transactions successfully deleted.', 'give'); |
|
151 | 151 | |
152 | 152 | return false; |
153 | 153 | } |
@@ -180,27 +180,27 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function pre_fetch() { |
182 | 182 | |
183 | - if ( $this->step == 1 ) { |
|
184 | - $this->delete_data( 'give_temp_delete_test_ids' ); |
|
183 | + if ($this->step == 1) { |
|
184 | + $this->delete_data('give_temp_delete_test_ids'); |
|
185 | 185 | } |
186 | 186 | |
187 | - $items = get_option( 'give_temp_delete_test_ids', false ); |
|
187 | + $items = get_option('give_temp_delete_test_ids', false); |
|
188 | 188 | |
189 | - if ( false === $items ) { |
|
189 | + if (false === $items) { |
|
190 | 190 | $items = array(); |
191 | 191 | |
192 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
192 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
193 | 193 | 'post_status' => 'any', |
194 | - 'number' => - 1, |
|
194 | + 'number' => -1, |
|
195 | 195 | 'meta_key' => '_give_payment_mode', |
196 | 196 | 'meta_value' => 'test' |
197 | - ) ); |
|
197 | + )); |
|
198 | 198 | |
199 | - $posts = new Give_Payments_Query( $args ); |
|
199 | + $posts = new Give_Payments_Query($args); |
|
200 | 200 | $payments = $posts->get_payments(); |
201 | 201 | |
202 | 202 | /* @var Give_Payment $payment */ |
203 | - foreach ( $payments as $payment ) { |
|
203 | + foreach ($payments as $payment) { |
|
204 | 204 | $items[] = array( |
205 | 205 | 'id' => (int) $payment->ID, |
206 | 206 | 'type' => 'give_payment', |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | |
210 | 210 | // Allow filtering of items to remove with an unassociative array for each item. |
211 | 211 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method. |
212 | - $items = apply_filters( 'give_delete_test_items', $items ); |
|
212 | + $items = apply_filters('give_delete_test_items', $items); |
|
213 | 213 | |
214 | - $this->store_data( 'give_temp_delete_test_ids', $items ); |
|
214 | + $this->store_data('give_temp_delete_test_ids', $items); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return mixed Returns the data from the database |
227 | 227 | */ |
228 | - private function get_stored_data( $key ) { |
|
228 | + private function get_stored_data($key) { |
|
229 | 229 | global $wpdb; |
230 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
230 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
231 | 231 | |
232 | - if ( empty( $value ) ) { |
|
232 | + if (empty($value)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - $maybe_json = json_decode( $value ); |
|
237 | - if ( ! is_null( $maybe_json ) ) { |
|
238 | - $value = json_decode( $value, true ); |
|
236 | + $maybe_json = json_decode($value); |
|
237 | + if ( ! is_null($maybe_json)) { |
|
238 | + $value = json_decode($value, true); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return $value; |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return void |
253 | 253 | */ |
254 | - private function store_data( $key, $value ) { |
|
254 | + private function store_data($key, $value) { |
|
255 | 255 | global $wpdb; |
256 | 256 | |
257 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
257 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
258 | 258 | |
259 | 259 | $data = array( |
260 | 260 | 'option_name' => $key, |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | '%s', |
269 | 269 | ); |
270 | 270 | |
271 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
271 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return void |
282 | 282 | */ |
283 | - private function delete_data( $key ) { |
|
283 | + private function delete_data($key) { |
|
284 | 284 | global $wpdb; |
285 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
285 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | } |
@@ -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 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Constructor. |
75 | 75 | */ |
76 | - public function __construct( $_step = 1 ) { |
|
77 | - parent::__construct( $_step ); |
|
76 | + public function __construct($_step = 1) { |
|
77 | + parent::__construct($_step); |
|
78 | 78 | |
79 | 79 | $this->is_writable = true; |
80 | 80 | } |
@@ -89,108 +89,106 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function get_data() { |
91 | 91 | |
92 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
93 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
94 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
95 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
92 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
93 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
94 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
95 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
96 | 96 | |
97 | - if ( false === $totals ) { |
|
97 | + if (false === $totals) { |
|
98 | 98 | $totals = array(); |
99 | 99 | } |
100 | 100 | |
101 | - if ( false === $payment_items ) { |
|
101 | + if (false === $payment_items) { |
|
102 | 102 | $payment_items = array(); |
103 | 103 | } |
104 | 104 | |
105 | - if ( false === $processed_payments ) { |
|
105 | + if (false === $processed_payments) { |
|
106 | 106 | $processed_payments = array(); |
107 | 107 | } |
108 | 108 | |
109 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
109 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
110 | 110 | |
111 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
111 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
112 | 112 | |
113 | - if ( empty( $payments ) ) { |
|
114 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
113 | + if (empty($payments)) { |
|
114 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
115 | 115 | 'give_forms' => $all_forms, |
116 | 116 | 'number' => $this->per_step, |
117 | 117 | 'status' => $accepted_statuses, |
118 | 118 | 'paged' => $this->step, |
119 | 119 | 'output' => 'give_payments', |
120 | - ) ); |
|
120 | + )); |
|
121 | 121 | |
122 | - $payments_query = new Give_Payments_Query( $args ); |
|
122 | + $payments_query = new Give_Payments_Query($args); |
|
123 | 123 | $payments = $payments_query->get_payments(); |
124 | 124 | } |
125 | 125 | |
126 | - if ( ! empty( $payments ) ) { |
|
126 | + if ( ! empty($payments)) { |
|
127 | 127 | |
128 | 128 | //Loop through payments |
129 | - foreach ( $payments as $payment ) { |
|
129 | + foreach ($payments as $payment) { |
|
130 | 130 | |
131 | - $payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) ); |
|
132 | - $payment = new Give_Payment( $payment_id ); |
|
131 | + $payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false)); |
|
132 | + $payment = new Give_Payment($payment_id); |
|
133 | 133 | |
134 | 134 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
135 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
135 | + if (in_array($payment->ID, $processed_payments)) { |
|
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Verify accepted status. |
140 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
140 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
141 | 141 | $processed_payments[] = $payment->ID; |
142 | 142 | continue; |
143 | 143 | } |
144 | 144 | |
145 | - $payment_item = $payment_items[ $payment->ID ]; |
|
145 | + $payment_item = $payment_items[$payment->ID]; |
|
146 | 146 | |
147 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
147 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
148 | 148 | |
149 | 149 | // Must have a form ID. |
150 | - if ( empty( $form_id ) ) { |
|
150 | + if (empty($form_id)) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | |
154 | 154 | // Form ID must be within $all_forms array to be validated. |
155 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
155 | + if ( ! in_array($form_id, $all_forms)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Set Sales count |
160 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
161 | - ++ $totals[ $form_id ]['sales'] : |
|
162 | - 1; |
|
160 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
161 | + ++$totals[$form_id]['sales'] : 1; |
|
163 | 162 | |
164 | 163 | // Set Total Earnings |
165 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
166 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
167 | - $payment_item['price']; |
|
164 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
165 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
168 | 166 | |
169 | 167 | $processed_payments[] = $payment->ID; |
170 | 168 | } |
171 | 169 | |
172 | 170 | // Get the list of form ids which does not contain any payment record. |
173 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
174 | - foreach ( $remaining_form_ids as $form_id ) { |
|
171 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
172 | + foreach ($remaining_form_ids as $form_id) { |
|
175 | 173 | //If array key doesn't exist, create it |
176 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
177 | - $totals[ $form_id ] = array( |
|
174 | + if ( ! array_key_exists($form_id, $totals)) { |
|
175 | + $totals[$form_id] = array( |
|
178 | 176 | 'sales' => (int) 0, |
179 | 177 | 'earnings' => (float) 0, |
180 | 178 | ); |
181 | 179 | } |
182 | 180 | } |
183 | 181 | |
184 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
185 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
182 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
183 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
186 | 184 | |
187 | 185 | return true; |
188 | 186 | } |
189 | 187 | |
190 | 188 | |
191 | - foreach ( $totals as $key => $stats ) { |
|
192 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
193 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
189 | + foreach ($totals as $key => $stats) { |
|
190 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
191 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
194 | 192 | } |
195 | 193 | |
196 | 194 | return false; |
@@ -205,20 +203,20 @@ discard block |
||
205 | 203 | */ |
206 | 204 | public function get_percentage_complete() { |
207 | 205 | |
208 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
206 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
209 | 207 | |
210 | - if ( false === $total ) { |
|
208 | + if (false === $total) { |
|
211 | 209 | $this->pre_fetch(); |
212 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
210 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
213 | 211 | } |
214 | 212 | |
215 | 213 | $percentage = 100; |
216 | 214 | |
217 | - if ( $total > 0 ) { |
|
218 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
215 | + if ($total > 0) { |
|
216 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
219 | 217 | } |
220 | 218 | |
221 | - if ( $percentage > 100 ) { |
|
219 | + if ($percentage > 100) { |
|
222 | 220 | $percentage = 100; |
223 | 221 | } |
224 | 222 | |
@@ -232,8 +230,8 @@ discard block |
||
232 | 230 | * |
233 | 231 | * @param array $request The Form Data passed into the batch processing |
234 | 232 | */ |
235 | - public function set_properties( $request ) { |
|
236 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
233 | + public function set_properties($request) { |
|
234 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
237 | 235 | } |
238 | 236 | |
239 | 237 | /** |
@@ -244,25 +242,25 @@ discard block |
||
244 | 242 | */ |
245 | 243 | public function process_step() { |
246 | 244 | |
247 | - if ( ! $this->can_export() ) { |
|
248 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
245 | + if ( ! $this->can_export()) { |
|
246 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
249 | 247 | } |
250 | 248 | |
251 | 249 | $had_data = $this->get_data(); |
252 | 250 | |
253 | - if ( $had_data ) { |
|
251 | + if ($had_data) { |
|
254 | 252 | $this->done = false; |
255 | 253 | |
256 | 254 | return true; |
257 | 255 | } else { |
258 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
259 | - $this->delete_data( 'give_recount_all_total' ); |
|
260 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
261 | - $this->delete_data( 'give_temp_payment_items' ); |
|
262 | - $this->delete_data( 'give_temp_form_ids' ); |
|
263 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
256 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
257 | + $this->delete_data('give_recount_all_total'); |
|
258 | + $this->delete_data('give_temp_recount_all_stats'); |
|
259 | + $this->delete_data('give_temp_payment_items'); |
|
260 | + $this->delete_data('give_temp_form_ids'); |
|
261 | + $this->delete_data('give_temp_processed_payments'); |
|
264 | 262 | $this->done = true; |
265 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
263 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
266 | 264 | |
267 | 265 | return false; |
268 | 266 | } |
@@ -298,70 +296,70 @@ discard block |
||
298 | 296 | */ |
299 | 297 | public function pre_fetch() { |
300 | 298 | |
301 | - if ( 1 == $this->step ) { |
|
302 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
303 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
304 | - $this->delete_data( 'give_temp_payment_items' ); |
|
305 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
306 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
299 | + if (1 == $this->step) { |
|
300 | + $this->delete_data('give_temp_recount_all_total'); |
|
301 | + $this->delete_data('give_temp_recount_all_stats'); |
|
302 | + $this->delete_data('give_temp_payment_items'); |
|
303 | + $this->delete_data('give_temp_processed_payments'); |
|
304 | + $this->delete_data('give_temp_all_payments_data'); |
|
307 | 305 | } |
308 | 306 | |
309 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
310 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
307 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
308 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
311 | 309 | |
312 | - if ( false === $total ) { |
|
310 | + if (false === $total) { |
|
313 | 311 | |
314 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
312 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
315 | 313 | |
316 | - if ( false === $payment_items ) { |
|
314 | + if (false === $payment_items) { |
|
317 | 315 | $payment_items = array(); |
318 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
316 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
319 | 317 | } |
320 | 318 | |
321 | 319 | $args = array( |
322 | 320 | 'post_status' => 'publish', |
323 | 321 | 'post_type' => 'give_forms', |
324 | - 'posts_per_page' => - 1, |
|
322 | + 'posts_per_page' => -1, |
|
325 | 323 | 'fields' => 'ids', |
326 | 324 | ); |
327 | 325 | |
328 | - $all_forms = get_posts( $args ); |
|
326 | + $all_forms = get_posts($args); |
|
329 | 327 | |
330 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
328 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
331 | 329 | |
332 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
330 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
333 | 331 | 'give_forms' => $all_forms, |
334 | 332 | 'number' => $this->per_step, |
335 | 333 | 'status' => $accepted_statuses, |
336 | 334 | 'page' => $this->step, |
337 | 335 | 'output' => 'payments', |
338 | - ) ); |
|
336 | + )); |
|
339 | 337 | |
340 | - $payments_query = new Give_Payments_Query( $args ); |
|
338 | + $payments_query = new Give_Payments_Query($args); |
|
341 | 339 | $payments = $payments_query->get_payments(); |
342 | 340 | |
343 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
341 | + $total = wp_count_posts('give_payment')->publish; |
|
344 | 342 | |
345 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
343 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
346 | 344 | |
347 | - if ( $payments ) { |
|
345 | + if ($payments) { |
|
348 | 346 | |
349 | - foreach ( $payments as $payment ) { |
|
347 | + foreach ($payments as $payment) { |
|
350 | 348 | |
351 | 349 | $form_id = $payment->form_id; |
352 | 350 | |
353 | 351 | //If for some reason somehow the form_ID isn't set check payment meta |
354 | - if ( empty( $payment->form_id ) ) { |
|
352 | + if (empty($payment->form_id)) { |
|
355 | 353 | $payment_meta = $payment->get_meta(); |
356 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
354 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
357 | 355 | } |
358 | 356 | |
359 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
357 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
360 | 358 | continue; |
361 | 359 | } |
362 | 360 | |
363 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
364 | - $payment_items[ $payment->ID ] = array( |
|
361 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
362 | + $payment_items[$payment->ID] = array( |
|
365 | 363 | 'id' => $form_id, |
366 | 364 | 'payment_id' => $payment->ID, |
367 | 365 | 'price' => $payment->total, |
@@ -369,8 +367,8 @@ discard block |
||
369 | 367 | } |
370 | 368 | } |
371 | 369 | } |
372 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
373 | - $this->store_data( 'give_recount_all_total', $total ); |
|
370 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
371 | + $this->store_data('give_recount_all_total', $total); |
|
374 | 372 | } |
375 | 373 | |
376 | 374 | } |
@@ -384,17 +382,17 @@ discard block |
||
384 | 382 | * |
385 | 383 | * @return mixed Returns the data from the database |
386 | 384 | */ |
387 | - private function get_stored_data( $key ) { |
|
385 | + private function get_stored_data($key) { |
|
388 | 386 | global $wpdb; |
389 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
390 | - if ( empty( $value ) ) { |
|
387 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
388 | + if (empty($value)) { |
|
391 | 389 | return false; |
392 | 390 | } |
393 | 391 | |
394 | - $maybe_json = json_decode( $value ); |
|
392 | + $maybe_json = json_decode($value); |
|
395 | 393 | |
396 | - if ( ! is_null( $maybe_json ) ) { |
|
397 | - $value = json_decode( $value, true ); |
|
394 | + if ( ! is_null($maybe_json)) { |
|
395 | + $value = json_decode($value, true); |
|
398 | 396 | } |
399 | 397 | |
400 | 398 | return $value; |
@@ -410,10 +408,10 @@ discard block |
||
410 | 408 | * |
411 | 409 | * @return void |
412 | 410 | */ |
413 | - private function store_data( $key, $value ) { |
|
411 | + private function store_data($key, $value) { |
|
414 | 412 | global $wpdb; |
415 | 413 | |
416 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
414 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
417 | 415 | |
418 | 416 | $data = array( |
419 | 417 | 'option_name' => $key, |
@@ -427,7 +425,7 @@ discard block |
||
427 | 425 | '%s', |
428 | 426 | ); |
429 | 427 | |
430 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
428 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
431 | 429 | } |
432 | 430 | |
433 | 431 | /** |
@@ -439,9 +437,9 @@ discard block |
||
439 | 437 | * |
440 | 438 | * @return void |
441 | 439 | */ |
442 | - private function delete_data( $key ) { |
|
440 | + private function delete_data($key) { |
|
443 | 441 | global $wpdb; |
444 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
442 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
445 | 443 | } |
446 | 444 | |
447 | 445 | } |