@@ -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 | |
@@ -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 | /** |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return array |
270 | 270 | */ |
271 | -function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
271 | +function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) { |
|
272 | 272 | // Bailout. |
273 | 273 | if ( |
274 | - 'give_payment' !== get_post_type( $object_id ) || |
|
274 | + 'give_payment' !== get_post_type($object_id) || |
|
275 | 275 | '_give_payment_meta' !== $meta_key || |
276 | - ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) |
|
276 | + ! give_has_upgrade_completed('v20_upgrades_payment_metadata') |
|
277 | 277 | ) { |
278 | 278 | return $check; |
279 | 279 | } |
@@ -281,73 +281,69 @@ discard block |
||
281 | 281 | $cache_key = "_give_payment_meta_{$object_id}"; |
282 | 282 | |
283 | 283 | // Get already calculate payment meta from cache. |
284 | - $payment_meta = Give_Cache::get_db_query( $cache_key ); |
|
284 | + $payment_meta = Give_Cache::get_db_query($cache_key); |
|
285 | 285 | |
286 | - if ( is_null( $payment_meta ) ) { |
|
286 | + if (is_null($payment_meta)) { |
|
287 | 287 | // Remove filter. |
288 | - remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 ); |
|
288 | + remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999); |
|
289 | 289 | |
290 | - $donation = new Give_Payment( $object_id ); |
|
290 | + $donation = new Give_Payment($object_id); |
|
291 | 291 | |
292 | 292 | // Get all payment meta. |
293 | - $payment_meta = give_get_meta( $object_id ); |
|
293 | + $payment_meta = give_get_meta($object_id); |
|
294 | 294 | |
295 | 295 | // Set default value to array. |
296 | - if ( empty( $payment_meta ) ) { |
|
296 | + if (empty($payment_meta)) { |
|
297 | 297 | return $check; |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Convert all meta key value to string instead of array |
301 | - array_walk( $payment_meta, function ( &$meta, $key ) { |
|
302 | - $meta = current( $meta ); |
|
301 | + array_walk($payment_meta, function(&$meta, $key) { |
|
302 | + $meta = current($meta); |
|
303 | 303 | } ); |
304 | 304 | |
305 | 305 | /** |
306 | 306 | * Add backward compatibility to old meta keys. |
307 | 307 | */ |
308 | 308 | // Donation key. |
309 | - $payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
309 | + $payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
310 | 310 | |
311 | 311 | // Donation form. |
312 | - $payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : ''; |
|
312 | + $payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : ''; |
|
313 | 313 | |
314 | 314 | // Donor email. |
315 | - $payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
316 | - $payment_meta['email'] = ! empty( $payment_meta['email'] ) ? |
|
317 | - $payment_meta['email'] : |
|
318 | - Give()->donors->get_column( 'email', $donation->donor_id ); |
|
315 | + $payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
316 | + $payment_meta['email'] = ! empty($payment_meta['email']) ? |
|
317 | + $payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id); |
|
319 | 318 | |
320 | 319 | // Form id. |
321 | - $payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : ''; |
|
320 | + $payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : ''; |
|
322 | 321 | |
323 | 322 | // Price id. |
324 | - $payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : ''; |
|
323 | + $payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : ''; |
|
325 | 324 | |
326 | 325 | // Date. |
327 | - $payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : ''; |
|
328 | - $payment_meta['date'] = ! empty( $payment_meta['date'] ) ? |
|
329 | - $payment_meta['date'] : |
|
330 | - get_post_field( 'post_date', $object_id ); |
|
326 | + $payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : ''; |
|
327 | + $payment_meta['date'] = ! empty($payment_meta['date']) ? |
|
328 | + $payment_meta['date'] : get_post_field('post_date', $object_id); |
|
331 | 329 | |
332 | 330 | |
333 | 331 | // Currency. |
334 | - $payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : ''; |
|
332 | + $payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : ''; |
|
335 | 333 | |
336 | 334 | // Decode donor data. |
337 | - $donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
338 | - $donor = new Give_Donor( $donor_id ); |
|
335 | + $donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
336 | + $donor = new Give_Donor($donor_id); |
|
339 | 337 | |
340 | 338 | // Donor first name. |
341 | - $donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
342 | - $donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ? |
|
343 | - $donor_data['first_name'] : |
|
344 | - $donor->get_first_name(); |
|
339 | + $donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
340 | + $donor_data['first_name'] = ! empty($donor_data['first_name']) ? |
|
341 | + $donor_data['first_name'] : $donor->get_first_name(); |
|
345 | 342 | |
346 | 343 | // Donor last name. |
347 | - $donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
348 | - $donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ? |
|
349 | - $donor_data['last_name'] : |
|
350 | - $donor->get_last_name(); |
|
344 | + $donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
345 | + $donor_data['last_name'] = ! empty($donor_data['last_name']) ? |
|
346 | + $donor_data['last_name'] : $donor->get_last_name(); |
|
351 | 347 | |
352 | 348 | // Donor email. |
353 | 349 | $donor_data['email'] = $payment_meta['email']; |
@@ -358,63 +354,63 @@ discard block |
||
358 | 354 | $donor_data['address'] = false; |
359 | 355 | |
360 | 356 | // Address1. |
361 | - $address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
362 | - if ( $address1 ) { |
|
357 | + $address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
358 | + if ($address1) { |
|
363 | 359 | $donor_data['address']['line1'] = $address1; |
364 | 360 | } |
365 | 361 | |
366 | 362 | // Address2. |
367 | - $address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
368 | - if ( $address2 ) { |
|
363 | + $address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
364 | + if ($address2) { |
|
369 | 365 | $donor_data['address']['line2'] = $address2; |
370 | 366 | } |
371 | 367 | |
372 | 368 | // City. |
373 | - $city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
374 | - if ( $city ) { |
|
369 | + $city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
370 | + if ($city) { |
|
375 | 371 | $donor_data['address']['city'] = $city; |
376 | 372 | } |
377 | 373 | |
378 | 374 | // Zip. |
379 | - $zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
380 | - if ( $zip ) { |
|
375 | + $zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
376 | + if ($zip) { |
|
381 | 377 | $donor_data['address']['zip'] = $zip; |
382 | 378 | } |
383 | 379 | |
384 | 380 | // State. |
385 | - $state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
386 | - if ( $state ) { |
|
381 | + $state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
382 | + if ($state) { |
|
387 | 383 | $donor_data['address']['state'] = $state; |
388 | 384 | } |
389 | 385 | |
390 | 386 | // Country. |
391 | - $country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
392 | - if ( $country ) { |
|
387 | + $country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
388 | + if ($country) { |
|
393 | 389 | $donor_data['address']['country'] = $country; |
394 | 390 | } |
395 | 391 | |
396 | 392 | $payment_meta['user_info'] = $donor_data; |
397 | 393 | |
398 | 394 | // Add filter |
399 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
395 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
400 | 396 | |
401 | 397 | // Set custom meta key into payment meta. |
402 | - if ( ! empty( $payment_meta['_give_payment_meta'] ) ) { |
|
403 | - $payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta ); |
|
398 | + if ( ! empty($payment_meta['_give_payment_meta'])) { |
|
399 | + $payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta); |
|
404 | 400 | } |
405 | 401 | |
406 | 402 | // Set cache. |
407 | - Give_Cache::set_db_query( $cache_key, $payment_meta ); |
|
403 | + Give_Cache::set_db_query($cache_key, $payment_meta); |
|
408 | 404 | } |
409 | 405 | |
410 | - if ( $single ) { |
|
406 | + if ($single) { |
|
411 | 407 | /** |
412 | 408 | * Filter the payment meta |
413 | 409 | * Add custom meta key to payment meta |
414 | 410 | * |
415 | 411 | * @since 2.0 |
416 | 412 | */ |
417 | - $new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key ); |
|
413 | + $new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key); |
|
418 | 414 | |
419 | 415 | $payment_meta = $new_payment_meta; |
420 | 416 | } |
@@ -422,7 +418,7 @@ discard block |
||
422 | 418 | return $payment_meta; |
423 | 419 | } |
424 | 420 | |
425 | -add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
421 | +add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
426 | 422 | |
427 | 423 | /** |
428 | 424 | * Add meta in payment that store page id and page url. |
@@ -434,19 +430,19 @@ discard block |
||
434 | 430 | * |
435 | 431 | * @param int $payment_id Payment id for which the meta value should be updated. |
436 | 432 | */ |
437 | -function give_payment_save_page_data( $payment_id ) { |
|
438 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
433 | +function give_payment_save_page_data($payment_id) { |
|
434 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
439 | 435 | |
440 | 436 | // Check $page_url is not empty. |
441 | - if ( $page_url ) { |
|
442 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
443 | - $page_id = url_to_postid( $page_url ); |
|
437 | + if ($page_url) { |
|
438 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
439 | + $page_id = url_to_postid($page_url); |
|
444 | 440 | // Check $page_id is not empty. |
445 | - if ( $page_id ) { |
|
446 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
441 | + if ($page_id) { |
|
442 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
447 | 443 | } |
448 | 444 | } |
449 | 445 | } |
450 | 446 | |
451 | 447 | // Fire when payment is save. |
452 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
453 | 448 | \ No newline at end of file |
449 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
454 | 450 | \ No newline at end of file |
@@ -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 | |
@@ -75,40 +75,40 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function __construct() { |
77 | 77 | // Bailout. |
78 | - if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) { |
|
78 | + if (empty($this->supports) || ! $this->is_custom_meta_table_active()) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - if ( in_array( 'add_post_metadata', $this->supports ) ) { |
|
83 | - add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 ); |
|
82 | + if (in_array('add_post_metadata', $this->supports)) { |
|
83 | + add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5); |
|
84 | 84 | } |
85 | 85 | |
86 | - if ( in_array( 'get_post_metadata', $this->supports ) ) { |
|
87 | - add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 0, 4 ); |
|
86 | + if (in_array('get_post_metadata', $this->supports)) { |
|
87 | + add_filter('get_post_metadata', array($this, '__get_meta'), 0, 4); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( in_array( 'update_post_metadata', $this->supports ) ) { |
|
91 | - add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 ); |
|
90 | + if (in_array('update_post_metadata', $this->supports)) { |
|
91 | + add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( in_array( 'delete_post_metadata', $this->supports ) ) { |
|
95 | - add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 ); |
|
94 | + if (in_array('delete_post_metadata', $this->supports)) { |
|
95 | + add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( in_array( 'posts_where', $this->supports ) ) { |
|
99 | - add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
98 | + if (in_array('posts_where', $this->supports)) { |
|
99 | + add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
100 | 100 | } |
101 | 101 | |
102 | - if ( in_array( 'posts_join', $this->supports ) ) { |
|
103 | - add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
102 | + if (in_array('posts_join', $this->supports)) { |
|
103 | + add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( in_array( 'posts_groupby', $this->supports ) ) { |
|
107 | - add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
106 | + if (in_array('posts_groupby', $this->supports)) { |
|
107 | + add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
108 | 108 | } |
109 | 109 | |
110 | - if ( in_array( 'posts_orderby', $this->supports ) ) { |
|
111 | - add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
110 | + if (in_array('posts_orderby', $this->supports)) { |
|
111 | + add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -126,16 +126,16 @@ discard block |
||
126 | 126 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
127 | 127 | * is true. |
128 | 128 | */ |
129 | - public function get_meta( $id = 0, $meta_key = '', $single = false ) { |
|
130 | - $id = $this->sanitize_id( $id ); |
|
129 | + public function get_meta($id = 0, $meta_key = '', $single = false) { |
|
130 | + $id = $this->sanitize_id($id); |
|
131 | 131 | |
132 | 132 | // Bailout. |
133 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
133 | + if ( ! $this->is_valid_post_type($id)) { |
|
134 | 134 | return $this->check; |
135 | 135 | } |
136 | 136 | |
137 | - if ( $this->raw_result ) { |
|
138 | - if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) { |
|
137 | + if ($this->raw_result) { |
|
138 | + if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) { |
|
139 | 139 | $value = ''; |
140 | 140 | } |
141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $this->raw_result = false; |
144 | 144 | |
145 | 145 | } else { |
146 | - $value = get_metadata( $this->meta_type, $id, $meta_key, $single ); |
|
146 | + $value = get_metadata($this->meta_type, $id, $meta_key, $single); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $value; |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return int|bool False for failure. True for success. |
167 | 167 | */ |
168 | - public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
169 | - $id = $this->sanitize_id( $id ); |
|
168 | + public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
169 | + $id = $this->sanitize_id($id); |
|
170 | 170 | |
171 | 171 | // Bailout. |
172 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
172 | + if ( ! $this->is_valid_post_type($id)) { |
|
173 | 173 | return $this->check; |
174 | 174 | } |
175 | 175 | |
176 | - $meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
|
176 | + $meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique); |
|
177 | 177 | |
178 | - if ( $meta_id ) { |
|
179 | - $this->delete_cache( $id ); |
|
178 | + if ($meta_id) { |
|
179 | + $this->delete_cache($id); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | return $meta_id; |
@@ -202,18 +202,18 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return int|bool False on failure, true if success. |
204 | 204 | */ |
205 | - public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
206 | - $id = $this->sanitize_id( $id ); |
|
205 | + public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
206 | + $id = $this->sanitize_id($id); |
|
207 | 207 | |
208 | 208 | // Bailout. |
209 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
209 | + if ( ! $this->is_valid_post_type($id)) { |
|
210 | 210 | return $this->check; |
211 | 211 | } |
212 | 212 | |
213 | - $meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
|
213 | + $meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value); |
|
214 | 214 | |
215 | - if ( $meta_id ) { |
|
216 | - $this->delete_cache( $id ); |
|
215 | + if ($meta_id) { |
|
216 | + $this->delete_cache($id); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | return $meta_id; |
@@ -236,18 +236,18 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return bool False for failure. True for success. |
238 | 238 | */ |
239 | - public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
|
240 | - $id = $this->sanitize_id( $id ); |
|
239 | + public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') { |
|
240 | + $id = $this->sanitize_id($id); |
|
241 | 241 | |
242 | 242 | // Bailout. |
243 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
243 | + if ( ! $this->is_valid_post_type($id)) { |
|
244 | 244 | return $this->check; |
245 | 245 | } |
246 | 246 | |
247 | - $is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
|
247 | + $is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all); |
|
248 | 248 | |
249 | - if ( $is_meta_deleted ) { |
|
250 | - $this->delete_cache( $id ); |
|
249 | + if ($is_meta_deleted) { |
|
250 | + $this->delete_cache($id); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | return $is_meta_deleted; |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function __rename_meta_table_name_in_query( $clause, $wp_query ) { |
|
267 | + public function __rename_meta_table_name_in_query($clause, $wp_query) { |
|
268 | 268 | // Add new table to sql query. |
269 | - if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) { |
|
270 | - $clause = $this->__rename_meta_table_name( $clause, current_filter() ); |
|
269 | + if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) { |
|
270 | + $clause = $this->__rename_meta_table_name($clause, current_filter()); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | return $clause; |
@@ -282,39 +282,39 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return mixed |
284 | 284 | */ |
285 | - public function __rename_meta_table_name( $clause, $filter ){ |
|
285 | + public function __rename_meta_table_name($clause, $filter) { |
|
286 | 286 | global $wpdb; |
287 | 287 | |
288 | - $clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause ); |
|
289 | - $clause = str_replace( $wpdb->postmeta, $this->table_name, $clause ); |
|
288 | + $clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause); |
|
289 | + $clause = str_replace($wpdb->postmeta, $this->table_name, $clause); |
|
290 | 290 | |
291 | - switch( $filter ) { |
|
291 | + switch ($filter) { |
|
292 | 292 | case 'posts_join': |
293 | - $joins = array( 'INNER JOIN', 'LEFT JOIN' ); |
|
293 | + $joins = array('INNER JOIN', 'LEFT JOIN'); |
|
294 | 294 | |
295 | - foreach ( $joins as $join ) { |
|
296 | - if( false !== strpos( $clause, $join ) ) { |
|
297 | - $clause = explode( $join, $clause ); |
|
295 | + foreach ($joins as $join) { |
|
296 | + if (false !== strpos($clause, $join)) { |
|
297 | + $clause = explode($join, $clause); |
|
298 | 298 | |
299 | - foreach ( $clause as $key => $clause_part ) { |
|
300 | - if( empty( $clause_part ) ) { |
|
299 | + foreach ($clause as $key => $clause_part) { |
|
300 | + if (empty($clause_part)) { |
|
301 | 301 | continue; |
302 | 302 | } |
303 | 303 | |
304 | - preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name ); |
|
304 | + preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name); |
|
305 | 305 | |
306 | - if( isset( $alias_table_name[1] ) ) { |
|
307 | - $clause[$key] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part ); |
|
306 | + if (isset($alias_table_name[1])) { |
|
307 | + $clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | - $clause = implode( "{$join} ", $clause ); |
|
311 | + $clause = implode("{$join} ", $clause); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | break; |
315 | 315 | |
316 | 316 | case 'posts_where': |
317 | - $clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( "mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id" ), $clause ); |
|
317 | + $clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array("mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id"), $clause); |
|
318 | 318 | break; |
319 | 319 | } |
320 | 320 | |
@@ -332,19 +332,19 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return bool |
334 | 334 | */ |
335 | - protected function is_post_type_query( $wp_query ) { |
|
335 | + protected function is_post_type_query($wp_query) { |
|
336 | 336 | $status = false; |
337 | 337 | |
338 | 338 | // Check if it is payment query. |
339 | - if ( ! empty( $wp_query->query['post_type'] ) ) { |
|
339 | + if ( ! empty($wp_query->query['post_type'])) { |
|
340 | 340 | if ( |
341 | - is_string( $wp_query->query['post_type'] ) && |
|
341 | + is_string($wp_query->query['post_type']) && |
|
342 | 342 | $this->post_type === $wp_query->query['post_type'] |
343 | 343 | ) { |
344 | 344 | $status = true; |
345 | 345 | } elseif ( |
346 | - is_array( $wp_query->query['post_type'] ) && |
|
347 | - in_array( $this->post_type, $wp_query->query['post_type'] ) |
|
346 | + is_array($wp_query->query['post_type']) && |
|
347 | + in_array($this->post_type, $wp_query->query['post_type']) |
|
348 | 348 | ) { |
349 | 349 | $status = true; |
350 | 350 | } |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return bool |
365 | 365 | */ |
366 | - protected function is_valid_post_type( $ID ) { |
|
367 | - return $ID && ( $this->post_type === get_post_type( $ID ) ); |
|
366 | + protected function is_valid_post_type($ID) { |
|
367 | + return $ID && ($this->post_type === get_post_type($ID)); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return void |
392 | 392 | */ |
393 | - private function delete_cache( $id, $meta_type = '' ) { |
|
394 | - $meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type; |
|
393 | + private function delete_cache($id, $meta_type = '') { |
|
394 | + $meta_type = empty($meta_type) ? $this->meta_type : $meta_type; |
|
395 | 395 | |
396 | 396 | $group = array( |
397 | 397 | // 'form' => 'give-forms', |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | // 'log' => 'give-logs', |
402 | 402 | ); |
403 | 403 | |
404 | - if ( array_key_exists( $meta_type, $group ) ) { |
|
405 | - Give_Cache::delete_group( $id, $group[ $meta_type ] ); |
|
404 | + if (array_key_exists($meta_type, $group)) { |
|
405 | + Give_Cache::delete_group($id, $group[$meta_type]); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * |
418 | 418 | * @return mixed |
419 | 419 | */ |
420 | - public function __call( $name, $arguments ) { |
|
421 | - switch ( $name ) { |
|
420 | + public function __call($name, $arguments) { |
|
421 | + switch ($name) { |
|
422 | 422 | case '__add_meta': |
423 | 423 | $this->check = $arguments[0]; |
424 | 424 | $id = $arguments[1]; |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | $unique = $arguments[4]; |
428 | 428 | |
429 | 429 | // Bailout. |
430 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
430 | + if ( ! $this->is_valid_post_type($id)) { |
|
431 | 431 | return $this->check; |
432 | 432 | } |
433 | 433 | |
434 | - return $this->add_meta( $id, $meta_key, $meta_value, $unique ); |
|
434 | + return $this->add_meta($id, $meta_key, $meta_value, $unique); |
|
435 | 435 | |
436 | 436 | case '__get_meta': |
437 | 437 | $this->check = $arguments[0]; |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | $single = $arguments[3]; |
441 | 441 | |
442 | 442 | // Bailout. |
443 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
443 | + if ( ! $this->is_valid_post_type($id)) { |
|
444 | 444 | return $this->check; |
445 | 445 | } |
446 | 446 | |
447 | 447 | $this->raw_result = true; |
448 | 448 | |
449 | - return $this->get_meta( $id, $meta_key, $single ); |
|
449 | + return $this->get_meta($id, $meta_key, $single); |
|
450 | 450 | |
451 | 451 | case '__update_meta': |
452 | 452 | $this->check = $arguments[0]; |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | $meta_value = $arguments[3]; |
456 | 456 | |
457 | 457 | // Bailout. |
458 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
458 | + if ( ! $this->is_valid_post_type($id)) { |
|
459 | 459 | return $this->check; |
460 | 460 | } |
461 | 461 | |
462 | - return $this->update_meta( $id, $meta_key, $meta_value ); |
|
462 | + return $this->update_meta($id, $meta_key, $meta_value); |
|
463 | 463 | |
464 | 464 | case '__delete_meta': |
465 | 465 | $this->check = $arguments[0]; |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | $delete_all = $arguments[3]; |
470 | 470 | |
471 | 471 | // Bailout. |
472 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
472 | + if ( ! $this->is_valid_post_type($id)) { |
|
473 | 473 | return $this->check; |
474 | 474 | } |
475 | 475 | |
476 | - return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all ); |
|
476 | + return $this->delete_meta($id, $meta_key, $meta_value, $delete_all); |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | KEY meta_key (meta_key({$this->min_index_length})) |
499 | 499 | ) {$charset_collate};"; |
500 | 500 | |
501 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
502 | - dbDelta( $sql ); |
|
501 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
502 | + dbDelta($sql); |
|
503 | 503 | |
504 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
504 | + update_option($this->table_name.'_db_version', $this->version); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | \ No newline at end of file |
@@ -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 | } |
@@ -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,7 +53,7 @@ discard block |
||
53 | 53 | * @return static |
54 | 54 | */ |
55 | 55 | public static function get_instance() { |
56 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
56 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
57 | 57 | self::$instance = new Give_Cache(); |
58 | 58 | } |
59 | 59 | |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setup() { |
70 | 70 | // Currently enable cache only for backend. |
71 | - self::$instance->is_cache = give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) && is_admin(); |
|
71 | + self::$instance->is_cache = give_is_setting_enabled(give_get_option('cache', 'enabled')) && is_admin(); |
|
72 | 72 | |
73 | 73 | // weekly delete all expired cache. |
74 | - Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) ); |
|
74 | + Give_Cron::add_weekly_event(array($this, 'delete_all_expired')); |
|
75 | 75 | |
76 | - add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) ); |
|
77 | - add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) ); |
|
78 | - add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 ); |
|
79 | - add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 ); |
|
76 | + add_action('save_post_give_forms', array($this, 'delete_form_related_cache')); |
|
77 | + add_action('save_post_give_payment', array($this, 'delete_payment_related_cache')); |
|
78 | + add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3); |
|
79 | + add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3); |
|
80 | 80 | |
81 | - add_action( 'give_save_settings_give_settings', array( $this, 'flush_cache' ) ); |
|
81 | + add_action('give_save_settings_give_settings', array($this, 'flush_cache')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -92,18 +92,18 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string |
94 | 94 | */ |
95 | - public static function get_key( $action, $query_args = null, $is_prefix = true ) { |
|
95 | + public static function get_key($action, $query_args = null, $is_prefix = true) { |
|
96 | 96 | // Bailout. |
97 | - if ( empty( $action ) ) { |
|
98 | - return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) ); |
|
97 | + if (empty($action)) { |
|
98 | + return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give')); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | // Set cache key. |
102 | 102 | $cache_key = $is_prefix ? "give_cache_{$action}" : $action; |
103 | 103 | |
104 | 104 | // Bailout. |
105 | - if ( ! empty( $query_args ) ) { |
|
106 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
105 | + if ( ! empty($query_args)) { |
|
106 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @since 2.0 |
113 | 113 | */ |
114 | - return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args ); |
|
114 | + return apply_filters('give_get_cache_key', $cache_key, $action, $query_args); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -125,26 +125,26 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return mixed |
127 | 127 | */ |
128 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
129 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
130 | - if ( ! $custom_key ) { |
|
131 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
128 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
129 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
130 | + if ( ! $custom_key) { |
|
131 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
132 | 132 | } |
133 | 133 | |
134 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
134 | + $cache_key = self::get_key($cache_key, $query_args); |
|
135 | 135 | } |
136 | 136 | |
137 | - $option = get_option( $cache_key ); |
|
137 | + $option = get_option($cache_key); |
|
138 | 138 | |
139 | 139 | // Backward compatibility (<1.8.7). |
140 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
140 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
141 | 141 | return $option; |
142 | 142 | } |
143 | 143 | |
144 | 144 | // Get current time. |
145 | - $current_time = current_time( 'timestamp', 1 ); |
|
145 | + $current_time = current_time('timestamp', 1); |
|
146 | 146 | |
147 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
147 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
148 | 148 | $option = $option['data']; |
149 | 149 | } else { |
150 | 150 | $option = false; |
@@ -166,23 +166,23 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return mixed |
168 | 168 | */ |
169 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
170 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
171 | - if ( ! $custom_key ) { |
|
172 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
169 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
170 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
171 | + if ( ! $custom_key) { |
|
172 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
173 | 173 | } |
174 | 174 | |
175 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
175 | + $cache_key = self::get_key($cache_key, $query_args); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $option_value = array( |
179 | 179 | 'data' => $data, |
180 | - 'expiration' => ! is_null( $expiration ) |
|
181 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
180 | + 'expiration' => ! is_null($expiration) |
|
181 | + ? ($expiration + current_time('timestamp', 1)) |
|
182 | 182 | : null, |
183 | 183 | ); |
184 | 184 | |
185 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
185 | + $result = update_option($cache_key, $option_value, 'no'); |
|
186 | 186 | |
187 | 187 | return $result; |
188 | 188 | } |
@@ -198,27 +198,27 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return bool|WP_Error |
200 | 200 | */ |
201 | - public static function delete( $cache_keys ) { |
|
201 | + public static function delete($cache_keys) { |
|
202 | 202 | $result = true; |
203 | 203 | $invalid_keys = array(); |
204 | 204 | |
205 | - if ( ! empty( $cache_keys ) ) { |
|
206 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
205 | + if ( ! empty($cache_keys)) { |
|
206 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
207 | 207 | |
208 | - foreach ( $cache_keys as $cache_key ) { |
|
209 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
208 | + foreach ($cache_keys as $cache_key) { |
|
209 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
210 | 210 | $invalid_keys[] = $cache_key; |
211 | 211 | $result = false; |
212 | 212 | } |
213 | 213 | |
214 | - delete_option( $cache_key ); |
|
214 | + delete_option($cache_key); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! $result ) { |
|
218 | + if ( ! $result) { |
|
219 | 219 | $result = new WP_Error( |
220 | 220 | 'give_invalid_cache_key', |
221 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
221 | + __('Cache key format should be give_cache_*', 'give'), |
|
222 | 222 | $invalid_keys |
223 | 223 | ); |
224 | 224 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return bool |
241 | 241 | */ |
242 | - public static function delete_all_expired( $force = false ) { |
|
242 | + public static function delete_all_expired($force = false) { |
|
243 | 243 | global $wpdb; |
244 | 244 | $options = $wpdb->get_results( |
245 | 245 | $wpdb->prepare( |
@@ -253,30 +253,30 @@ discard block |
||
253 | 253 | ); |
254 | 254 | |
255 | 255 | // Bailout. |
256 | - if ( empty( $options ) ) { |
|
256 | + if (empty($options)) { |
|
257 | 257 | return false; |
258 | 258 | } |
259 | 259 | |
260 | - $current_time = current_time( 'timestamp', 1 ); |
|
260 | + $current_time = current_time('timestamp', 1); |
|
261 | 261 | |
262 | 262 | // Delete log cache. |
263 | - foreach ( $options as $option ) { |
|
264 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
263 | + foreach ($options as $option) { |
|
264 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
265 | 265 | |
266 | 266 | if ( |
267 | 267 | ( |
268 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
269 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
270 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
271 | - || empty( $option['option_value']['expiration'] ) |
|
272 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
268 | + ! self::is_valid_cache_key($option['option_name']) |
|
269 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
270 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
271 | + || empty($option['option_value']['expiration']) |
|
272 | + || ($current_time < $option['option_value']['expiration']) |
|
273 | 273 | ) |
274 | 274 | && ! $force |
275 | 275 | ) { |
276 | 276 | continue; |
277 | 277 | } |
278 | 278 | |
279 | - self::delete( $option['option_name'] ); |
|
279 | + self::delete($option['option_name']); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return array |
296 | 296 | */ |
297 | - public static function get_options_like( $option_name, $fields = false ) { |
|
297 | + public static function get_options_like($option_name, $fields = false) { |
|
298 | 298 | global $wpdb; |
299 | 299 | |
300 | 300 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
301 | 301 | |
302 | - if ( $fields ) { |
|
302 | + if ($fields) { |
|
303 | 303 | $options = $wpdb->get_results( |
304 | 304 | $wpdb->prepare( |
305 | 305 | "SELECT {$field_names } |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | ); |
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $options ) && $fields ) { |
|
327 | - foreach ( $options as $index => $option ) { |
|
328 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
329 | - $options[ $index ] = $option; |
|
326 | + if ( ! empty($options) && $fields) { |
|
327 | + foreach ($options as $index => $option) { |
|
328 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
329 | + $options[$index] = $option; |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @return bool |
345 | 345 | */ |
346 | - public static function is_valid_cache_key( $cache_key ) { |
|
347 | - $is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
346 | + public static function is_valid_cache_key($cache_key) { |
|
347 | + $is_valid = (false !== strpos($cache_key, 'give_cache_')); |
|
348 | 348 | |
349 | 349 | |
350 | 350 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @since 2.0 |
354 | 354 | */ |
355 | - return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key ); |
|
355 | + return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return mixed |
369 | 369 | */ |
370 | - public static function get_group( $id, $group = '' ) { |
|
370 | + public static function get_group($id, $group = '') { |
|
371 | 371 | $cached_data = null; |
372 | 372 | |
373 | 373 | // Bailout. |
374 | - if ( self::$instance->is_cache && ! empty( $id ) ) { |
|
375 | - $group = self::$instance->filter_group_name( $group ); |
|
374 | + if (self::$instance->is_cache && ! empty($id)) { |
|
375 | + $group = self::$instance->filter_group_name($group); |
|
376 | 376 | |
377 | - $cached_data = wp_cache_get( $id, $group ); |
|
377 | + $cached_data = wp_cache_get($id, $group); |
|
378 | 378 | $cached_data = false !== $cached_data ? $cached_data : null; |
379 | 379 | } |
380 | 380 | |
@@ -394,17 +394,17 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return bool |
396 | 396 | */ |
397 | - public static function set_group( $id, $data, $group = '', $expire = 0 ) { |
|
397 | + public static function set_group($id, $data, $group = '', $expire = 0) { |
|
398 | 398 | $status = false; |
399 | 399 | |
400 | 400 | // Bailout. |
401 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
401 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
402 | 402 | return $status; |
403 | 403 | } |
404 | 404 | |
405 | - $group = self::$instance->filter_group_name( $group ); |
|
405 | + $group = self::$instance->filter_group_name($group); |
|
406 | 406 | |
407 | - $status = wp_cache_set( $id, $data, $group, $expire ); |
|
407 | + $status = wp_cache_set($id, $data, $group, $expire); |
|
408 | 408 | |
409 | 409 | return $status; |
410 | 410 | } |
@@ -420,15 +420,15 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @return bool |
422 | 422 | */ |
423 | - public static function set_db_query( $id, $data ) { |
|
423 | + public static function set_db_query($id, $data) { |
|
424 | 424 | $status = false; |
425 | 425 | |
426 | 426 | // Bailout. |
427 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
427 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
428 | 428 | return $status; |
429 | 429 | } |
430 | 430 | |
431 | - return self::set_group( $id, $data, 'give-db-queries', 0 ); |
|
431 | + return self::set_group($id, $data, 'give-db-queries', 0); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @return mixed |
443 | 443 | */ |
444 | - public static function get_db_query( $id ) { |
|
445 | - return self::get_group( $id, 'give-db-queries' ); |
|
444 | + public static function get_db_query($id) { |
|
445 | + return self::get_group($id, 'give-db-queries'); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | /** |
@@ -457,20 +457,20 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @return bool |
459 | 459 | */ |
460 | - public static function delete_group( $ids, $group = '', $expire = 0 ) { |
|
460 | + public static function delete_group($ids, $group = '', $expire = 0) { |
|
461 | 461 | $status = false; |
462 | 462 | |
463 | 463 | // Bailout. |
464 | - if ( ! self::$instance->is_cache || empty( $ids ) ) { |
|
464 | + if ( ! self::$instance->is_cache || empty($ids)) { |
|
465 | 465 | return $status; |
466 | 466 | } |
467 | 467 | |
468 | - $group = self::$instance->filter_group_name( $group ); |
|
468 | + $group = self::$instance->filter_group_name($group); |
|
469 | 469 | |
470 | 470 | // Delete single or multiple cache items from cache. |
471 | - if ( ! is_array( $ids ) ) { |
|
472 | - $status = wp_cache_delete( $ids, $group, $expire ); |
|
473 | - self::$instance->get_incrementer( true ); |
|
471 | + if ( ! is_array($ids)) { |
|
472 | + $status = wp_cache_delete($ids, $group, $expire); |
|
473 | + self::$instance->get_incrementer(true); |
|
474 | 474 | |
475 | 475 | /** |
476 | 476 | * Fire action when cache deleted for specific id. |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | * @param string $group |
482 | 482 | * @param int $expire |
483 | 483 | */ |
484 | - do_action( "give_deleted_{$group}_cache", $ids, $group, $expire, $status ); |
|
484 | + do_action("give_deleted_{$group}_cache", $ids, $group, $expire, $status); |
|
485 | 485 | |
486 | 486 | } else { |
487 | - foreach ( $ids as $id ) { |
|
488 | - $status = wp_cache_delete( $id, $group, $expire ); |
|
489 | - self::$instance->get_incrementer( true ); |
|
487 | + foreach ($ids as $id) { |
|
488 | + $status = wp_cache_delete($id, $group, $expire); |
|
489 | + self::$instance->get_incrementer(true); |
|
490 | 490 | |
491 | 491 | /** |
492 | 492 | * Fire action when cache deleted for specific id . |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | * @param string $group |
498 | 498 | * @param int $expire |
499 | 499 | */ |
500 | - do_action( "give_deleted_{$group}_cache", $id, $group, $expire, $status ); |
|
500 | + do_action("give_deleted_{$group}_cache", $id, $group, $expire, $status); |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
@@ -514,30 +514,30 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @param int $form_id |
516 | 516 | */ |
517 | - public function delete_form_related_cache( $form_id ) { |
|
517 | + public function delete_form_related_cache($form_id) { |
|
518 | 518 | // If this is just a revision, don't send the email. |
519 | - if ( wp_is_post_revision( $form_id ) ) { |
|
519 | + if (wp_is_post_revision($form_id)) { |
|
520 | 520 | return; |
521 | 521 | } |
522 | 522 | |
523 | 523 | $donation_query = new Give_Payments_Query( |
524 | 524 | array( |
525 | - 'number' => - 1, |
|
525 | + 'number' => -1, |
|
526 | 526 | 'give_forms' => $form_id, |
527 | 527 | ) |
528 | 528 | ); |
529 | 529 | |
530 | 530 | $donations = $donation_query->get_payments(); |
531 | 531 | |
532 | - if ( ! empty( $donations ) ) { |
|
532 | + if ( ! empty($donations)) { |
|
533 | 533 | /* @var Give_Payment $donation */ |
534 | - foreach ( $donations as $donation ) { |
|
535 | - wp_cache_delete( $donation->ID, 'give-donations' ); |
|
536 | - wp_cache_delete( $donation->donor_id, 'give-donors' ); |
|
534 | + foreach ($donations as $donation) { |
|
535 | + wp_cache_delete($donation->ID, 'give-donations'); |
|
536 | + wp_cache_delete($donation->donor_id, 'give-donors'); |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
540 | - self::$instance->get_incrementer( true ); |
|
540 | + self::$instance->get_incrementer(true); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
@@ -549,22 +549,22 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @param int $donation_id |
551 | 551 | */ |
552 | - public function delete_payment_related_cache( $donation_id ) { |
|
552 | + public function delete_payment_related_cache($donation_id) { |
|
553 | 553 | // If this is just a revision, don't send the email. |
554 | - if ( wp_is_post_revision( $donation_id ) ) { |
|
554 | + if (wp_is_post_revision($donation_id)) { |
|
555 | 555 | return; |
556 | 556 | } |
557 | 557 | |
558 | 558 | /* @var Give_Payment $donation */ |
559 | - $donation = new Give_Payment( $donation_id ); |
|
559 | + $donation = new Give_Payment($donation_id); |
|
560 | 560 | |
561 | - if ( $donation && $donation->donor_id ) { |
|
562 | - wp_cache_delete( $donation->donor_id, 'give-donors' ); |
|
561 | + if ($donation && $donation->donor_id) { |
|
562 | + wp_cache_delete($donation->donor_id, 'give-donors'); |
|
563 | 563 | } |
564 | 564 | |
565 | - wp_cache_delete( $donation->ID, 'give-donations' ); |
|
565 | + wp_cache_delete($donation->ID, 'give-donations'); |
|
566 | 566 | |
567 | - self::$instance->get_incrementer( true ); |
|
567 | + self::$instance->get_incrementer(true); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -578,17 +578,17 @@ discard block |
||
578 | 578 | * @param string $group |
579 | 579 | * @param int $expire |
580 | 580 | */ |
581 | - public function delete_donor_related_cache( $id, $group, $expire ) { |
|
582 | - $donor = new Give_Donor( $id ); |
|
583 | - $donation_ids = array_map( 'trim', (array) explode( ',', trim( $donor->payment_ids ) ) ); |
|
581 | + public function delete_donor_related_cache($id, $group, $expire) { |
|
582 | + $donor = new Give_Donor($id); |
|
583 | + $donation_ids = array_map('trim', (array) explode(',', trim($donor->payment_ids))); |
|
584 | 584 | |
585 | - if ( ! empty( $donation_ids ) ) { |
|
586 | - foreach ( $donation_ids as $donation ) { |
|
587 | - wp_cache_delete( $donation, 'give-donations' ); |
|
585 | + if ( ! empty($donation_ids)) { |
|
586 | + foreach ($donation_ids as $donation) { |
|
587 | + wp_cache_delete($donation, 'give-donations'); |
|
588 | 588 | } |
589 | 589 | } |
590 | 590 | |
591 | - self::$instance->get_incrementer( true ); |
|
591 | + self::$instance->get_incrementer(true); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -602,15 +602,15 @@ discard block |
||
602 | 602 | * @param string $group |
603 | 603 | * @param int $expire |
604 | 604 | */ |
605 | - public function delete_donations_related_cache( $id, $group, $expire ) { |
|
605 | + public function delete_donations_related_cache($id, $group, $expire) { |
|
606 | 606 | /* @var Give_Payment $donation */ |
607 | - $donation = new Give_Payment( $id ); |
|
607 | + $donation = new Give_Payment($id); |
|
608 | 608 | |
609 | - if ( $donation && $donation->donor_id ) { |
|
610 | - wp_cache_delete( $donation->donor_id, 'give-donors' ); |
|
609 | + if ($donation && $donation->donor_id) { |
|
610 | + wp_cache_delete($donation->donor_id, 'give-donors'); |
|
611 | 611 | } |
612 | 612 | |
613 | - self::$instance->get_incrementer( true ); |
|
613 | + self::$instance->get_incrementer(true); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | |
@@ -628,12 +628,12 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @return string |
630 | 630 | */ |
631 | - private function get_incrementer( $refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries' ) { |
|
632 | - $incrementer_value = wp_cache_get( $incrementer_key ); |
|
631 | + private function get_incrementer($refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries') { |
|
632 | + $incrementer_value = wp_cache_get($incrementer_key); |
|
633 | 633 | |
634 | - if ( false === $incrementer_value || true === $refresh ) { |
|
635 | - $incrementer_value = microtime( true ); |
|
636 | - wp_cache_set( $incrementer_key, $incrementer_value ); |
|
634 | + if (false === $incrementer_value || true === $refresh) { |
|
635 | + $incrementer_value = microtime(true); |
|
636 | + wp_cache_set($incrementer_key, $incrementer_value); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | return $incrementer_value; |
@@ -650,11 +650,11 @@ discard block |
||
650 | 650 | public function flush_cache() { |
651 | 651 | if ( |
652 | 652 | Give_Admin_Settings::is_saving_settings() && |
653 | - isset( $_POST['cache'] ) && |
|
654 | - give_is_setting_enabled( give_clean( $_POST['cache'] ) ) |
|
653 | + isset($_POST['cache']) && |
|
654 | + give_is_setting_enabled(give_clean($_POST['cache'])) |
|
655 | 655 | ) { |
656 | - $this->get_incrementer( true ); |
|
657 | - $this->get_incrementer( true, 'give-cache-incrementer' ); |
|
656 | + $this->get_incrementer(true); |
|
657 | + $this->get_incrementer(true, 'give-cache-incrementer'); |
|
658 | 658 | } |
659 | 659 | } |
660 | 660 | |
@@ -669,11 +669,11 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @return mixed |
671 | 671 | */ |
672 | - private function filter_group_name( $group ) { |
|
673 | - if ( ! empty( $group ) ) { |
|
674 | - $incrementer = self::$instance->get_incrementer( false, 'give-cache-incrementer' ); |
|
672 | + private function filter_group_name($group) { |
|
673 | + if ( ! empty($group)) { |
|
674 | + $incrementer = self::$instance->get_incrementer(false, 'give-cache-incrementer'); |
|
675 | 675 | |
676 | - if ( 'give-db-queries' === $group ) { |
|
676 | + if ('give-db-queries' === $group) { |
|
677 | 677 | $incrementer = self::$instance->get_incrementer(); |
678 | 678 | } |
679 | 679 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -26,31 +26,31 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_test_ajax_works() { |
28 | 28 | // Handle ajax. |
29 | - if ( doing_action( 'wp_ajax_nopriv_give_test_ajax' ) ) { |
|
30 | - wp_die( 0, 200 ); |
|
29 | + if (doing_action('wp_ajax_nopriv_give_test_ajax')) { |
|
30 | + wp_die(0, 200); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // Check if the Airplane Mode plugin is installed. |
34 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
34 | + if (class_exists('Airplane_Mode_Core')) { |
|
35 | 35 | |
36 | 36 | $airplane = Airplane_Mode_Core::getInstance(); |
37 | 37 | |
38 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
38 | + if (method_exists($airplane, 'enabled')) { |
|
39 | 39 | |
40 | - if ( $airplane->enabled() ) { |
|
40 | + if ($airplane->enabled()) { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } else { |
44 | 44 | |
45 | - if ( 'on' === $airplane->check_status() ) { |
|
45 | + if ('on' === $airplane->check_status()) { |
|
46 | 46 | return true; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - add_filter( 'block_local_requests', '__return_false' ); |
|
51 | + add_filter('block_local_requests', '__return_false'); |
|
52 | 52 | |
53 | - if ( Give_Cache::get( '_give_ajax_works', true ) ) { |
|
53 | + if (Give_Cache::get('_give_ajax_works', true)) { |
|
54 | 54 | return true; |
55 | 55 | } |
56 | 56 | |
@@ -62,41 +62,41 @@ discard block |
||
62 | 62 | ), |
63 | 63 | ); |
64 | 64 | |
65 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
65 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
66 | 66 | |
67 | 67 | $works = true; |
68 | 68 | |
69 | - if ( is_wp_error( $ajax ) ) { |
|
69 | + if (is_wp_error($ajax)) { |
|
70 | 70 | |
71 | 71 | $works = false; |
72 | 72 | |
73 | 73 | } else { |
74 | 74 | |
75 | - if ( empty( $ajax['response'] ) ) { |
|
75 | + if (empty($ajax['response'])) { |
|
76 | 76 | $works = false; |
77 | 77 | } |
78 | 78 | |
79 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
79 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
80 | 80 | $works = false; |
81 | 81 | } |
82 | 82 | |
83 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
83 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
84 | 84 | $works = false; |
85 | 85 | } |
86 | 86 | |
87 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
87 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
88 | 88 | $works = false; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - if ( $works ) { |
|
93 | - Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true ); |
|
92 | + if ($works) { |
|
93 | + Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true); |
|
94 | 94 | } |
95 | 95 | |
96 | - return apply_filters( 'give_test_ajax_works', $works ); |
|
96 | + return apply_filters('give_test_ajax_works', $works); |
|
97 | 97 | } |
98 | 98 | |
99 | -add_action( 'wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works' ); |
|
99 | +add_action('wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works'); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Get AJAX URL |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | -function give_get_ajax_url( $query = array() ) { |
|
111 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
110 | +function give_get_ajax_url($query = array()) { |
|
111 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
112 | 112 | |
113 | 113 | $current_url = give_get_current_page_url(); |
114 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
114 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
115 | 115 | |
116 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
117 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
116 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
117 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $query ) ) { |
|
121 | - $ajax_url = add_query_arg( $query, $ajax_url ); |
|
120 | + if ( ! empty($query)) { |
|
121 | + $ajax_url = add_query_arg($query, $ajax_url); |
|
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
124 | + return apply_filters('give_ajax_url', $ajax_url); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @since 1.7 |
139 | 139 | */ |
140 | - do_action( 'give_donation_form_login_fields' ); |
|
140 | + do_action('give_donation_form_login_fields'); |
|
141 | 141 | |
142 | 142 | give_die(); |
143 | 143 | } |
144 | 144 | |
145 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
145 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Load Checkout Fields |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | function give_load_checkout_fields() { |
155 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
155 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
156 | 156 | |
157 | 157 | ob_start(); |
158 | 158 | |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @since 1.7 |
163 | 163 | */ |
164 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
164 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
165 | 165 | |
166 | 166 | $fields = ob_get_clean(); |
167 | 167 | |
168 | - wp_send_json( array( |
|
169 | - 'fields' => wp_json_encode( $fields ), |
|
170 | - 'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ), |
|
171 | - ) ); |
|
168 | + wp_send_json(array( |
|
169 | + 'fields' => wp_json_encode($fields), |
|
170 | + 'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)), |
|
171 | + )); |
|
172 | 172 | } |
173 | 173 | |
174 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
175 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
174 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
175 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | function give_ajax_get_form_title() { |
185 | - if ( isset( $_POST['form_id'] ) ) { |
|
186 | - $title = get_the_title( $_POST['form_id'] ); |
|
187 | - if ( $title ) { |
|
185 | + if (isset($_POST['form_id'])) { |
|
186 | + $title = get_the_title($_POST['form_id']); |
|
187 | + if ($title) { |
|
188 | 188 | echo $title; |
189 | 189 | } else { |
190 | 190 | echo 'fail'; |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | give_die(); |
194 | 194 | } |
195 | 195 | |
196 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
197 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
196 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
197 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Retrieve a states drop down |
@@ -208,41 +208,41 @@ discard block |
||
208 | 208 | $show_field = true; |
209 | 209 | $states_require = true; |
210 | 210 | // Get the Country code from the $_POST. |
211 | - $country = sanitize_text_field( $_POST['country'] ); |
|
211 | + $country = sanitize_text_field($_POST['country']); |
|
212 | 212 | |
213 | 213 | // Get the field name from the $_POST. |
214 | - $field_name = sanitize_text_field( $_POST['field_name'] ); |
|
214 | + $field_name = sanitize_text_field($_POST['field_name']); |
|
215 | 215 | |
216 | - $label = __( 'State', 'give' ); |
|
216 | + $label = __('State', 'give'); |
|
217 | 217 | $states_label = give_get_states_label(); |
218 | 218 | |
219 | 219 | $default_state = ''; |
220 | - if ( $country === give_get_country() ) { |
|
220 | + if ($country === give_get_country()) { |
|
221 | 221 | $default_state = give_get_state(); |
222 | 222 | } |
223 | 223 | |
224 | 224 | // Check if $country code exists in the array key for states label. |
225 | - if ( array_key_exists( $country, $states_label ) ) { |
|
226 | - $label = $states_label[ $country ]; |
|
225 | + if (array_key_exists($country, $states_label)) { |
|
226 | + $label = $states_label[$country]; |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( empty( $country ) ) { |
|
229 | + if (empty($country)) { |
|
230 | 230 | $country = give_get_country(); |
231 | 231 | } |
232 | 232 | |
233 | - $states = give_get_states( $country ); |
|
234 | - if ( ! empty( $states ) ) { |
|
235 | - $args = array( |
|
233 | + $states = give_get_states($country); |
|
234 | + if ( ! empty($states)) { |
|
235 | + $args = array( |
|
236 | 236 | 'name' => $field_name, |
237 | 237 | 'id' => $field_name, |
238 | - 'class' => $field_name . ' give-select', |
|
238 | + 'class' => $field_name.' give-select', |
|
239 | 239 | 'options' => $states, |
240 | 240 | 'show_option_all' => false, |
241 | 241 | 'show_option_none' => false, |
242 | 242 | 'placeholder' => $label, |
243 | 243 | 'selected' => $default_state, |
244 | 244 | ); |
245 | - $data = Give()->html->select( $args ); |
|
245 | + $data = Give()->html->select($args); |
|
246 | 246 | $states_found = true; |
247 | 247 | } else { |
248 | 248 | $data = 'nostates'; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $no_states_country = give_no_states_country_list(); |
252 | 252 | |
253 | 253 | // Check if $country code exists in the array key. |
254 | - if ( array_key_exists( $country, $no_states_country ) ) { |
|
254 | + if (array_key_exists($country, $no_states_country)) { |
|
255 | 255 | $show_field = false; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $states_not_required_country_list = give_states_not_required_country_list(); |
260 | 260 | |
261 | 261 | // Check if $country code exists in the array key. |
262 | - if ( array_key_exists( $country, $states_not_required_country_list ) ) { |
|
262 | + if (array_key_exists($country, $states_not_required_country_list)) { |
|
263 | 263 | $states_require = false; |
264 | 264 | } |
265 | 265 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | 'data' => $data, |
273 | 273 | 'default_state' => $default_state, |
274 | 274 | ); |
275 | - wp_send_json( $response ); |
|
275 | + wp_send_json($response); |
|
276 | 276 | } |
277 | 277 | |
278 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
279 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
278 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
279 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Retrieve donation forms via AJAX for chosen dropdown search field. |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | function give_ajax_form_search() { |
289 | 289 | global $wpdb; |
290 | 290 | |
291 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
292 | - $excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() ); |
|
291 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
292 | + $excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array()); |
|
293 | 293 | |
294 | 294 | $results = array(); |
295 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
296 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
295 | + if (current_user_can('edit_give_forms')) { |
|
296 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
297 | 297 | } else { |
298 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
298 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( $items ) { |
|
301 | + if ($items) { |
|
302 | 302 | |
303 | - foreach ( $items as $item ) { |
|
303 | + foreach ($items as $item) { |
|
304 | 304 | |
305 | 305 | $results[] = array( |
306 | 306 | 'id' => $item->ID, |
@@ -311,18 +311,18 @@ discard block |
||
311 | 311 | |
312 | 312 | $items[] = array( |
313 | 313 | 'id' => 0, |
314 | - 'name' => __( 'No forms found.', 'give' ), |
|
314 | + 'name' => __('No forms found.', 'give'), |
|
315 | 315 | ); |
316 | 316 | |
317 | 317 | } |
318 | 318 | |
319 | - echo json_encode( $results ); |
|
319 | + echo json_encode($results); |
|
320 | 320 | |
321 | 321 | give_die(); |
322 | 322 | } |
323 | 323 | |
324 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
325 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
324 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
325 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Search the donors database via Ajax |
@@ -334,38 +334,38 @@ discard block |
||
334 | 334 | function give_ajax_donor_search() { |
335 | 335 | global $wpdb; |
336 | 336 | |
337 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
337 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
338 | 338 | $results = array(); |
339 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
339 | + if ( ! current_user_can('view_give_reports')) { |
|
340 | 340 | $donors = array(); |
341 | 341 | } else { |
342 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
342 | + $donors = $wpdb->get_results("SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $donors ) { |
|
345 | + if ($donors) { |
|
346 | 346 | |
347 | - foreach ( $donors as $donor ) { |
|
347 | + foreach ($donors as $donor) { |
|
348 | 348 | |
349 | 349 | $results[] = array( |
350 | 350 | 'id' => $donor->id, |
351 | - 'name' => $donor->name . ' (' . $donor->email . ')', |
|
351 | + 'name' => $donor->name.' ('.$donor->email.')', |
|
352 | 352 | ); |
353 | 353 | } |
354 | 354 | } else { |
355 | 355 | |
356 | 356 | $donors[] = array( |
357 | 357 | 'id' => 0, |
358 | - 'name' => __( 'No donors found.', 'give' ), |
|
358 | + 'name' => __('No donors found.', 'give'), |
|
359 | 359 | ); |
360 | 360 | |
361 | 361 | } |
362 | 362 | |
363 | - echo json_encode( $results ); |
|
363 | + echo json_encode($results); |
|
364 | 364 | |
365 | 365 | give_die(); |
366 | 366 | } |
367 | 367 | |
368 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
368 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
369 | 369 | |
370 | 370 | |
371 | 371 | /** |
@@ -377,39 +377,39 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_ajax_search_users() { |
379 | 379 | |
380 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
380 | + if (current_user_can('manage_give_settings')) { |
|
381 | 381 | |
382 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
382 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
383 | 383 | |
384 | 384 | $get_users_args = array( |
385 | 385 | 'number' => 9999, |
386 | - 'search' => $search . '*', |
|
386 | + 'search' => $search.'*', |
|
387 | 387 | ); |
388 | 388 | |
389 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
389 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
390 | 390 | |
391 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search ); |
|
391 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search); |
|
392 | 392 | $results = array(); |
393 | 393 | |
394 | - if ( $found_users ) { |
|
394 | + if ($found_users) { |
|
395 | 395 | |
396 | - foreach ( $found_users as $user ) { |
|
396 | + foreach ($found_users as $user) { |
|
397 | 397 | |
398 | 398 | $results[] = array( |
399 | 399 | 'id' => $user->ID, |
400 | - 'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ), |
|
400 | + 'name' => esc_html($user->user_login.' ('.$user->user_email.')'), |
|
401 | 401 | ); |
402 | 402 | } |
403 | 403 | } else { |
404 | 404 | |
405 | 405 | $results[] = array( |
406 | 406 | 'id' => 0, |
407 | - 'name' => __( 'No users found.', 'give' ), |
|
407 | + 'name' => __('No users found.', 'give'), |
|
408 | 408 | ); |
409 | 409 | |
410 | 410 | } |
411 | 411 | |
412 | - echo json_encode( $results ); |
|
412 | + echo json_encode($results); |
|
413 | 413 | |
414 | 414 | }// End if(). |
415 | 415 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | } |
419 | 419 | |
420 | -add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' ); |
|
420 | +add_action('wp_ajax_give_user_search', 'give_ajax_search_users'); |
|
421 | 421 | |
422 | 422 | |
423 | 423 | /** |
@@ -429,32 +429,32 @@ discard block |
||
429 | 429 | */ |
430 | 430 | function give_check_for_form_price_variations() { |
431 | 431 | |
432 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
433 | - die( '-1' ); |
|
432 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
433 | + die('-1'); |
|
434 | 434 | } |
435 | 435 | |
436 | - $form_id = intval( $_POST['form_id'] ); |
|
437 | - $form = get_post( $form_id ); |
|
436 | + $form_id = intval($_POST['form_id']); |
|
437 | + $form = get_post($form_id); |
|
438 | 438 | |
439 | - if ( 'give_forms' != $form->post_type ) { |
|
440 | - die( '-2' ); |
|
439 | + if ('give_forms' != $form->post_type) { |
|
440 | + die('-2'); |
|
441 | 441 | } |
442 | 442 | |
443 | - if ( give_has_variable_prices( $form_id ) ) { |
|
444 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
443 | + if (give_has_variable_prices($form_id)) { |
|
444 | + $variable_prices = give_get_variable_prices($form_id); |
|
445 | 445 | |
446 | - if ( $variable_prices ) { |
|
446 | + if ($variable_prices) { |
|
447 | 447 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
448 | 448 | |
449 | - if ( isset( $_POST['all_prices'] ) ) { |
|
450 | - $ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
449 | + if (isset($_POST['all_prices'])) { |
|
450 | + $ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>'; |
|
451 | 451 | } |
452 | 452 | |
453 | - foreach ( $variable_prices as $key => $price ) { |
|
453 | + foreach ($variable_prices as $key => $price) { |
|
454 | 454 | |
455 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
455 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))); |
|
456 | 456 | |
457 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
457 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
458 | 458 | } |
459 | 459 | $ajax_response .= '</select>'; |
460 | 460 | echo $ajax_response; |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | give_die(); |
465 | 465 | } |
466 | 466 | |
467 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
467 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
468 | 468 | |
469 | 469 | |
470 | 470 | /** |
@@ -475,28 +475,28 @@ discard block |
||
475 | 475 | * @return void |
476 | 476 | */ |
477 | 477 | function give_check_for_form_price_variations_html() { |
478 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
478 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
479 | 479 | wp_die(); |
480 | 480 | } |
481 | 481 | |
482 | - $form_id = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false; |
|
483 | - $payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false; |
|
484 | - if ( empty( $form_id ) || empty( $payment_id ) ) { |
|
482 | + $form_id = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false; |
|
483 | + $payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false; |
|
484 | + if (empty($form_id) || empty($payment_id)) { |
|
485 | 485 | wp_die(); |
486 | 486 | } |
487 | 487 | |
488 | - $form = get_post( $form_id ); |
|
489 | - if ( ! empty( $form->post_type ) && 'give_forms' != $form->post_type ) { |
|
488 | + $form = get_post($form_id); |
|
489 | + if ( ! empty($form->post_type) && 'give_forms' != $form->post_type) { |
|
490 | 490 | wp_die(); |
491 | 491 | } |
492 | 492 | |
493 | - if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) { |
|
494 | - esc_html_e( 'n/a', 'give' ); |
|
493 | + if ( ! give_has_variable_prices($form_id) || ! $form_id) { |
|
494 | + esc_html_e('n/a', 'give'); |
|
495 | 495 | } else { |
496 | 496 | $prices_atts = array(); |
497 | - if ( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
498 | - foreach ( $variable_prices as $variable_price ) { |
|
499 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ); |
|
497 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
498 | + foreach ($variable_prices as $variable_price) { |
|
499 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false)); |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -507,12 +507,12 @@ discard block |
||
507 | 507 | 'chosen' => true, |
508 | 508 | 'show_option_all' => '', |
509 | 509 | 'show_option_none' => '', |
510 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
510 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
511 | 511 | ); |
512 | 512 | |
513 | - if ( $payment_id ) { |
|
513 | + if ($payment_id) { |
|
514 | 514 | // Payment object. |
515 | - $payment = new Give_Payment( $payment_id ); |
|
515 | + $payment = new Give_Payment($payment_id); |
|
516 | 516 | |
517 | 517 | // Payment meta. |
518 | 518 | $payment_meta = $payment->get_meta(); |
@@ -520,13 +520,13 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | // Render variable prices select tag html. |
523 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
523 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | give_die(); |
527 | 527 | } |
528 | 528 | |
529 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
529 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
|
530 | 530 | |
531 | 531 | /** |
532 | 532 | * Send Confirmation Email For Complete Donation History Access. |
@@ -538,24 +538,24 @@ discard block |
||
538 | 538 | function give_confirm_email_for_donation_access() { |
539 | 539 | |
540 | 540 | // Verify Security using Nonce. |
541 | - if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) { |
|
541 | + if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) { |
|
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // Bail Out, if email is empty. |
546 | - if ( empty( $_POST['email'] ) ) { |
|
546 | + if (empty($_POST['email'])) { |
|
547 | 547 | return false; |
548 | 548 | } |
549 | 549 | |
550 | - $donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) ); |
|
551 | - if ( Give()->email_access->can_send_email( $donor->id ) ) { |
|
550 | + $donor = Give()->donors->get_donor_by('email', give_clean($_POST['email'])); |
|
551 | + if (Give()->email_access->can_send_email($donor->id)) { |
|
552 | 552 | $return = array(); |
553 | - $email_sent = Give()->email_access->send_email( $donor->id, $donor->email ); |
|
553 | + $email_sent = Give()->email_access->send_email($donor->id, $donor->email); |
|
554 | 554 | |
555 | - if ( ! $email_sent ) { |
|
555 | + if ( ! $email_sent) { |
|
556 | 556 | $return['status'] = 'error'; |
557 | 557 | $return['message'] = Give()->notices->print_frontend_notice( |
558 | - __( 'Unable to send email. Please try again.', 'give' ), |
|
558 | + __('Unable to send email. Please try again.', 'give'), |
|
559 | 559 | false, |
560 | 560 | 'error' |
561 | 561 | ); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | |
564 | 564 | $return['status'] = 'success'; |
565 | 565 | $return['message'] = Give()->notices->print_frontend_notice( |
566 | - __( 'Please check your email and click on the link to access your complete donation history.', 'give' ), |
|
566 | + __('Please check your email and click on the link to access your complete donation history.', 'give'), |
|
567 | 567 | false, |
568 | 568 | 'success' |
569 | 569 | ); |
@@ -574,16 +574,16 @@ discard block |
||
574 | 574 | $return['status'] = 'error'; |
575 | 575 | $return['message'] = Give()->notices->print_frontend_notice( |
576 | 576 | sprintf( |
577 | - __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
|
578 | - sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
|
577 | + __('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'), |
|
578 | + sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value) |
|
579 | 579 | ), |
580 | 580 | false, |
581 | 581 | 'error' |
582 | 582 | ); |
583 | 583 | } |
584 | 584 | |
585 | - echo json_encode( $return ); |
|
585 | + echo json_encode($return); |
|
586 | 586 | give_die(); |
587 | 587 | } |
588 | 588 | |
589 | -add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' ); |
|
590 | 589 | \ No newline at end of file |
590 | +add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access'); |
|
591 | 591 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @category Class |
12 | 12 | * @author WordImpress |
13 | 13 | */ |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | * and data exists in the queue. |
55 | 55 | */ |
56 | 56 | public function handle_cron_healthcheck() { |
57 | - if ( $this->is_process_running() || $this->is_paused_process() ) { |
|
57 | + if ($this->is_process_running() || $this->is_paused_process()) { |
|
58 | 58 | // Background process already running. |
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - if ( $this->is_queue_empty() ) { |
|
62 | + if ($this->is_queue_empty()) { |
|
63 | 63 | // No data to process. |
64 | 64 | $this->clear_scheduled_event(); |
65 | 65 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * Schedule fallback event. |
74 | 74 | */ |
75 | 75 | protected function schedule_event() { |
76 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) && ! $this->is_paused_process() ) { |
|
77 | - wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
76 | + if ( ! wp_next_scheduled($this->cron_hook_identifier) && ! $this->is_paused_process()) { |
|
77 | + wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return mixed |
92 | 92 | */ |
93 | - protected function task( $update ) { |
|
93 | + protected function task($update) { |
|
94 | 94 | // Pause upgrade immediately if admin pausing upgrades. |
95 | - if( $this->is_paused_process() ) { |
|
95 | + if ($this->is_paused_process()) { |
|
96 | 96 | wp_die(); |
97 | 97 | } |
98 | 98 | |
99 | - if ( empty( $update ) ) { |
|
99 | + if (empty($update)) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'update_info' => $update, |
111 | 111 | 'step' => 1, |
112 | 112 | 'update' => 1, |
113 | - 'heading' => sprintf( 'Update %s of {update_count}', 1 ), |
|
113 | + 'heading' => sprintf('Update %s of {update_count}', 1), |
|
114 | 114 | 'percentage' => $give_updates->percentage, |
115 | 115 | ) |
116 | 116 | ); |
@@ -118,22 +118,22 @@ discard block |
||
118 | 118 | // Continuously skip update if previous update does not complete yet. |
119 | 119 | if ( |
120 | 120 | $resume_update['update_info']['id'] !== $update['id'] && |
121 | - ! give_has_upgrade_completed( $resume_update['update_info']['id'] ) |
|
121 | + ! give_has_upgrade_completed($resume_update['update_info']['id']) |
|
122 | 122 | ) { |
123 | 123 | return $update; |
124 | 124 | } |
125 | 125 | |
126 | 126 | // Set params. |
127 | 127 | $resume_update['update_info'] = $update; |
128 | - $give_updates->step = absint( $resume_update['step'] ); |
|
129 | - $give_updates->update = absint( $resume_update['update'] ); |
|
130 | - $is_parent_update_completed = $give_updates->is_parent_updates_completed( $update ); |
|
128 | + $give_updates->step = absint($resume_update['step']); |
|
129 | + $give_updates->update = absint($resume_update['update']); |
|
130 | + $is_parent_update_completed = $give_updates->is_parent_updates_completed($update); |
|
131 | 131 | |
132 | 132 | |
133 | 133 | // Skip update if dependency update does not complete yet. |
134 | - if ( empty( $is_parent_update_completed ) ) { |
|
134 | + if (empty($is_parent_update_completed)) { |
|
135 | 135 | // @todo: set error when you have only one update with invalid dependency |
136 | - if ( ! is_null( $is_parent_update_completed ) ) { |
|
136 | + if ( ! is_null($is_parent_update_completed)) { |
|
137 | 137 | return $update; |
138 | 138 | } |
139 | 139 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | Give_Cache::disable(); |
145 | 145 | |
146 | 146 | // Run update. |
147 | - if ( is_array( $update['callback'] ) ) { |
|
147 | + if (is_array($update['callback'])) { |
|
148 | 148 | $update['callback'][0]->$update['callback'][1](); |
149 | 149 | } else { |
150 | 150 | $update['callback'](); |
@@ -153,21 +153,21 @@ discard block |
||
153 | 153 | // Set update info. |
154 | 154 | $doing_upgrade_args = array( |
155 | 155 | 'update_info' => $update, |
156 | - 'step' => ++ $give_updates->step, |
|
156 | + 'step' => ++$give_updates->step, |
|
157 | 157 | 'update' => $give_updates->update, |
158 | - 'heading' => sprintf( 'Update %s of %s', $give_updates->update, get_option( 'give_db_update_count' ) ), |
|
158 | + 'heading' => sprintf('Update %s of %s', $give_updates->update, get_option('give_db_update_count')), |
|
159 | 159 | 'percentage' => $give_updates->percentage, |
160 | 160 | 'total_percentage' => $give_updates->get_db_update_processing_percentage(), |
161 | 161 | ); |
162 | 162 | |
163 | 163 | // Cache upgrade. |
164 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
164 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
165 | 165 | |
166 | 166 | // Enable cache. |
167 | 167 | Give_Cache::enable(); |
168 | 168 | |
169 | 169 | // Check if current update completed or not. |
170 | - if ( give_has_upgrade_completed( $update['id'] ) ) { |
|
170 | + if (give_has_upgrade_completed($update['id'])) { |
|
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | |
@@ -181,21 +181,21 @@ discard block |
||
181 | 181 | * performed, or, call parent::complete(). |
182 | 182 | */ |
183 | 183 | protected function complete() { |
184 | - if( $this->is_paused_process() ) { |
|
184 | + if ($this->is_paused_process()) { |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | |
188 | 188 | parent::complete(); |
189 | 189 | |
190 | - delete_option( 'give_db_update_count' ); |
|
191 | - delete_option( 'give_doing_upgrade' ); |
|
192 | - add_option( 'give_show_db_upgrade_complete_notice', 1, '', 'no' ); |
|
190 | + delete_option('give_db_update_count'); |
|
191 | + delete_option('give_doing_upgrade'); |
|
192 | + add_option('give_show_db_upgrade_complete_notice', 1, '', 'no'); |
|
193 | 193 | |
194 | 194 | // Flush cache. |
195 | 195 | Give_Cache::get_instance()->flush_cache(); |
196 | 196 | |
197 | - if( $cache_keys = Give_Cache::get_options_like('') ) { |
|
198 | - Give_Cache::delete( $cache_keys ); |
|
197 | + if ($cache_keys = Give_Cache::get_options_like('')) { |
|
198 | + Give_Cache::delete($cache_keys); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -205,19 +205,19 @@ discard block |
||
205 | 205 | * @return int |
206 | 206 | */ |
207 | 207 | protected function get_memory_limit() { |
208 | - if ( function_exists( 'ini_get' ) ) { |
|
209 | - $memory_limit = ini_get( 'memory_limit' ); |
|
208 | + if (function_exists('ini_get')) { |
|
209 | + $memory_limit = ini_get('memory_limit'); |
|
210 | 210 | } else { |
211 | 211 | // Sensible default. |
212 | 212 | $memory_limit = '128M'; |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! $memory_limit || '-1' === $memory_limit ) { |
|
215 | + if ( ! $memory_limit || '-1' === $memory_limit) { |
|
216 | 216 | // Unlimited, set to 32GB. |
217 | 217 | $memory_limit = '32000M'; |
218 | 218 | } |
219 | 219 | |
220 | - return intval( $memory_limit ) * 1024 * 1024; |
|
220 | + return intval($memory_limit) * 1024 * 1024; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -230,17 +230,17 @@ discard block |
||
230 | 230 | // Don't lock up other requests while processing |
231 | 231 | session_write_close(); |
232 | 232 | |
233 | - if ( $this->is_process_running() || $this->is_paused_process() ) { |
|
233 | + if ($this->is_process_running() || $this->is_paused_process()) { |
|
234 | 234 | // Background process already running. |
235 | 235 | wp_die(); |
236 | 236 | } |
237 | 237 | |
238 | - if ( $this->is_queue_empty() ) { |
|
238 | + if ($this->is_queue_empty()) { |
|
239 | 239 | // No data to process. |
240 | 240 | wp_die(); |
241 | 241 | } |
242 | 242 | |
243 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
243 | + check_ajax_referer($this->identifier, 'nonce'); |
|
244 | 244 | |
245 | 245 | $this->handle(); |
246 | 246 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | * @access public |
256 | 256 | * @return bool |
257 | 257 | */ |
258 | - public function is_paused_process(){ |
|
258 | + public function is_paused_process() { |
|
259 | 259 | // Not using get_option because i am facing some caching releated issue. |
260 | 260 | global $wpdb; |
261 | 261 | |
262 | - $options = $wpdb->get_results( "SELECT * FROM $wpdb->options WHERE option_name='give_paused_batches' LIMIT 1" ); |
|
262 | + $options = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name='give_paused_batches' LIMIT 1"); |
|
263 | 263 | |
264 | - return ! empty( $options ); |
|
264 | + return ! empty($options); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly. |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | * @param callable $func Hook to run when email tag is found |
57 | 57 | * @param string $context Email tag category |
58 | 58 | */ |
59 | - public function add( $tag, $description, $func, $context = '' ) { |
|
60 | - if ( is_callable( $func ) ) { |
|
61 | - $this->tags[ $tag ] = array( |
|
59 | + public function add($tag, $description, $func, $context = '') { |
|
60 | + if (is_callable($func)) { |
|
61 | + $this->tags[$tag] = array( |
|
62 | 62 | 'tag' => $tag, |
63 | 63 | 'description' => $description, |
64 | 64 | 'func' => $func, |
65 | - 'context' => give_check_variable( $context, 'empty', 'general' ), |
|
65 | + 'context' => give_check_variable($context, 'empty', 'general'), |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param string $tag Email tag to remove hook from |
76 | 76 | */ |
77 | - public function remove( $tag ) { |
|
78 | - unset( $this->tags[ $tag ] ); |
|
77 | + public function remove($tag) { |
|
78 | + unset($this->tags[$tag]); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - public function email_tag_exists( $tag ) { |
|
91 | - return array_key_exists( $tag, $this->tags ); |
|
90 | + public function email_tag_exists($tag) { |
|
91 | + return array_key_exists($tag, $this->tags); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -102,23 +102,23 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public function get_tags( $context_type = 'all', $field = '' ) { |
|
105 | + public function get_tags($context_type = 'all', $field = '') { |
|
106 | 106 | $tags = $this->tags; |
107 | 107 | |
108 | - if ( 'all' !== $context_type ) { |
|
108 | + if ('all' !== $context_type) { |
|
109 | 109 | $tags = array(); |
110 | 110 | |
111 | - foreach ( $this->tags as $tag ) { |
|
112 | - if ( empty( $tag['context'] ) || $context_type !== $tag['context'] ) { |
|
111 | + foreach ($this->tags as $tag) { |
|
112 | + if (empty($tag['context']) || $context_type !== $tag['context']) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
116 | - $tags[ $tag['tag'] ] = $tag; |
|
116 | + $tags[$tag['tag']] = $tag; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $tags ) && ! empty( $field ) ) { |
|
121 | - $tags = wp_list_pluck( $tags, $field ); |
|
120 | + if ( ! empty($tags) && ! empty($field)) { |
|
121 | + $tags = wp_list_pluck($tags, $field); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | return $tags; |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return string Content with email tags filtered out. |
138 | 138 | */ |
139 | - public function do_tags( $content, $tag_args ) { |
|
139 | + public function do_tags($content, $tag_args) { |
|
140 | 140 | |
141 | 141 | // Check if there is at least one tag added. |
142 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
142 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
143 | 143 | return $content; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $this->tag_args = $tag_args; |
147 | 147 | |
148 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
148 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
149 | 149 | |
150 | 150 | $this->tag_args = null; |
151 | 151 | |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return mixed |
163 | 163 | */ |
164 | - public function do_tag( $m ) { |
|
164 | + public function do_tag($m) { |
|
165 | 165 | |
166 | 166 | // Get tag |
167 | 167 | $tag = $m[1]; |
168 | 168 | |
169 | 169 | // Return tag if tag not set |
170 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
170 | + if ( ! $this->email_tag_exists($tag)) { |
|
171 | 171 | return $m[0]; |
172 | 172 | } |
173 | 173 | |
174 | - return call_user_func( $this->tags[ $tag ]['func'], $this->tag_args, $tag ); |
|
174 | + return call_user_func($this->tags[$tag]['func'], $this->tag_args, $tag); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param callable $func Hook to run when email tag is found |
187 | 187 | * @param string $context Email tag category |
188 | 188 | */ |
189 | -function give_add_email_tag( $tag, $description, $func, $context = '' ) { |
|
190 | - Give()->email_tags->add( $tag, $description, $func, $context ); |
|
189 | +function give_add_email_tag($tag, $description, $func, $context = '') { |
|
190 | + Give()->email_tags->add($tag, $description, $func, $context); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param string $tag Email tag to remove hook from |
199 | 199 | */ |
200 | -function give_remove_email_tag( $tag ) { |
|
201 | - Give()->email_tags->remove( $tag ); |
|
200 | +function give_remove_email_tag($tag) { |
|
201 | + Give()->email_tags->remove($tag); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return bool |
212 | 212 | */ |
213 | -function give_email_tag_exists( $tag ) { |
|
214 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
213 | +function give_email_tag_exists($tag) { |
|
214 | + return Give()->email_tags->email_tag_exists($tag); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | $email_tags = give_get_email_tags(); |
239 | 239 | |
240 | 240 | ob_start(); |
241 | - if ( count( $email_tags ) > 0 ) : ?> |
|
241 | + if (count($email_tags) > 0) : ?> |
|
242 | 242 | <div class="give-email-tags-wrap"> |
243 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
243 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
244 | 244 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
245 | 245 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
246 | 246 | </span> |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string Content with email tags filtered out. |
266 | 266 | */ |
267 | -function give_do_email_tags( $content, $tag_args ) { |
|
267 | +function give_do_email_tags($content, $tag_args) { |
|
268 | 268 | // Backward compatibility < 2.0 |
269 | - if ( ! is_array( $tag_args ) ) { |
|
270 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
269 | + if ( ! is_array($tag_args)) { |
|
270 | + $tag_args = array('payment_id' => $tag_args); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Replace all tags |
274 | - $content = Give()->email_tags->do_tags( $content, $tag_args ); |
|
274 | + $content = Give()->email_tags->do_tags($content, $tag_args); |
|
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Filter the filtered content text. |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @since 1.0 |
280 | 280 | * @since 2.0 $payment_meta, $payment_id removed and $tag_args added. |
281 | 281 | */ |
282 | - $content = apply_filters( 'give_email_template_tags', $content, $tag_args ); |
|
282 | + $content = apply_filters('give_email_template_tags', $content, $tag_args); |
|
283 | 283 | |
284 | 284 | // Return content |
285 | 285 | return $content; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @since 1.0 |
300 | 300 | */ |
301 | - do_action( 'give_add_email_tags' ); |
|
301 | + do_action('give_add_email_tags'); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
304 | +add_action('init', 'give_load_email_tags', - 999); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -316,67 +316,67 @@ discard block |
||
316 | 316 | /* Donation Payment */ |
317 | 317 | array( |
318 | 318 | 'tag' => 'donation', |
319 | - 'description' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
319 | + 'description' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'), |
|
320 | 320 | 'function' => 'give_email_tag_donation', |
321 | 321 | 'context' => 'donation', |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'amount', |
325 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
325 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_amount', |
327 | 327 | 'context' => 'donation', |
328 | 328 | ), |
329 | 329 | array( |
330 | 330 | 'tag' => 'price', |
331 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
331 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
332 | 332 | 'function' => 'give_email_tag_price', |
333 | 333 | 'context' => 'donation', |
334 | 334 | ), |
335 | 335 | array( |
336 | 336 | 'tag' => 'billing_address', |
337 | - 'description' => esc_html__( 'The donor\'s billing address.', 'give' ), |
|
337 | + 'description' => esc_html__('The donor\'s billing address.', 'give'), |
|
338 | 338 | 'function' => 'give_email_tag_billing_address', |
339 | 339 | 'context' => 'donation', |
340 | 340 | ), |
341 | 341 | array( |
342 | 342 | 'tag' => 'date', |
343 | - 'description' => esc_html__( 'The date of the donation.', 'give' ), |
|
343 | + 'description' => esc_html__('The date of the donation.', 'give'), |
|
344 | 344 | 'function' => 'give_email_tag_date', |
345 | 345 | 'context' => 'donation', |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'tag' => 'payment_id', |
349 | - 'description' => esc_html__( 'The unique ID number for this donation.', 'give' ), |
|
349 | + 'description' => esc_html__('The unique ID number for this donation.', 'give'), |
|
350 | 350 | 'function' => 'give_email_tag_payment_id', |
351 | 351 | 'context' => 'donation', |
352 | 352 | ), |
353 | 353 | array( |
354 | 354 | 'tag' => 'payment_method', |
355 | - 'description' => esc_html__( 'The method of payment used for this donation.', 'give' ), |
|
355 | + 'description' => esc_html__('The method of payment used for this donation.', 'give'), |
|
356 | 356 | 'function' => 'give_email_tag_payment_method', |
357 | 357 | 'context' => 'donation', |
358 | 358 | ), |
359 | 359 | array( |
360 | 360 | 'tag' => 'payment_total', |
361 | - 'description' => esc_html__( 'The payment total for this donation.', 'give' ), |
|
361 | + 'description' => esc_html__('The payment total for this donation.', 'give'), |
|
362 | 362 | 'function' => 'give_email_tag_payment_total', |
363 | 363 | 'context' => 'donation', |
364 | 364 | ), |
365 | 365 | array( |
366 | 366 | 'tag' => 'receipt_id', |
367 | - 'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ), |
|
367 | + 'description' => esc_html__('The unique ID number for this donation receipt.', 'give'), |
|
368 | 368 | 'function' => 'give_email_tag_receipt_id', |
369 | 369 | 'context' => 'donation', |
370 | 370 | ), |
371 | 371 | array( |
372 | 372 | 'tag' => 'receipt_link', |
373 | - 'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
373 | + 'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
374 | 374 | 'function' => 'give_email_tag_receipt_link', |
375 | 375 | 'context' => 'donation', |
376 | 376 | ), |
377 | 377 | array( |
378 | 378 | 'tag' => 'receipt_link_url', |
379 | - 'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
379 | + 'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
380 | 380 | 'function' => 'give_email_tag_receipt_link_url', |
381 | 381 | 'context' => 'donation', |
382 | 382 | ), |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | /* Donation Form */ |
385 | 385 | array( |
386 | 386 | 'tag' => 'form_title', |
387 | - 'description' => esc_html__( 'The donation form name.', 'give' ), |
|
387 | + 'description' => esc_html__('The donation form name.', 'give'), |
|
388 | 388 | 'function' => 'give_email_tag_form_title', |
389 | 389 | 'context' => 'form', |
390 | 390 | ), |
@@ -392,31 +392,31 @@ discard block |
||
392 | 392 | /* Donor */ |
393 | 393 | array( |
394 | 394 | 'tag' => 'name', |
395 | - 'description' => esc_html__( 'The donor\'s first name.', 'give' ), |
|
395 | + 'description' => esc_html__('The donor\'s first name.', 'give'), |
|
396 | 396 | 'function' => 'give_email_tag_first_name', |
397 | 397 | 'context' => 'donor', |
398 | 398 | ), |
399 | 399 | array( |
400 | 400 | 'tag' => 'fullname', |
401 | - 'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ), |
|
401 | + 'description' => esc_html__('The donor\'s full name, first and last.', 'give'), |
|
402 | 402 | 'function' => 'give_email_tag_fullname', |
403 | 403 | 'context' => 'donor', |
404 | 404 | ), |
405 | 405 | array( |
406 | 406 | 'tag' => 'username', |
407 | - 'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
407 | + 'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
408 | 408 | 'function' => 'give_email_tag_username', |
409 | 409 | 'context' => 'donor', |
410 | 410 | ), |
411 | 411 | array( |
412 | 412 | 'tag' => 'user_email', |
413 | - 'description' => esc_html__( 'The donor\'s email address.', 'give' ), |
|
413 | + 'description' => esc_html__('The donor\'s email address.', 'give'), |
|
414 | 414 | 'function' => 'give_email_tag_user_email', |
415 | 415 | 'context' => 'donor', |
416 | 416 | ), |
417 | 417 | array( |
418 | 418 | 'tag' => 'email_access_link', |
419 | - 'description' => esc_html__( 'The donor\'s email access link.', 'give' ), |
|
419 | + 'description' => esc_html__('The donor\'s email access link.', 'give'), |
|
420 | 420 | 'function' => 'give_email_tag_email_access_link', |
421 | 421 | 'context' => 'donor', |
422 | 422 | ), |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | /* General */ |
425 | 425 | array( |
426 | 426 | 'tag' => 'sitename', |
427 | - 'description' => esc_html__( 'The name of your site.', 'give' ), |
|
427 | + 'description' => esc_html__('The name of your site.', 'give'), |
|
428 | 428 | 'function' => 'give_email_tag_sitename', |
429 | 429 | 'context' => 'general', |
430 | 430 | ), |
431 | 431 | |
432 | 432 | array( |
433 | 433 | 'tag' => 'reset_password_link', |
434 | - 'description' => esc_html__( 'The reset password link for user.', 'give' ), |
|
434 | + 'description' => esc_html__('The reset password link for user.', 'give'), |
|
435 | 435 | 'function' => 'give_email_tag_reset_password_link', |
436 | 436 | 'context' => 'general', |
437 | 437 | ), |
@@ -439,21 +439,21 @@ discard block |
||
439 | 439 | ); |
440 | 440 | |
441 | 441 | // Apply give_email_tags filter |
442 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
442 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
443 | 443 | |
444 | 444 | // Add email tags |
445 | - foreach ( $email_tags as $email_tag ) { |
|
445 | + foreach ($email_tags as $email_tag) { |
|
446 | 446 | give_add_email_tag( |
447 | 447 | $email_tag['tag'], |
448 | 448 | $email_tag['description'], |
449 | 449 | $email_tag['function'], |
450 | - ( ! empty( $email_tag['context'] ) ? $email_tag['context'] : '' ) |
|
450 | + ( ! empty($email_tag['context']) ? $email_tag['context'] : '') |
|
451 | 451 | ); |
452 | 452 | } |
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
456 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
457 | 457 | |
458 | 458 | |
459 | 459 | /** |
@@ -465,26 +465,26 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string $firstname |
467 | 467 | */ |
468 | -function give_email_tag_first_name( $tag_args ) { |
|
468 | +function give_email_tag_first_name($tag_args) { |
|
469 | 469 | $user_info = array(); |
470 | 470 | $firstname = ''; |
471 | 471 | |
472 | 472 | // Backward compatibility. |
473 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
473 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
474 | 474 | |
475 | - switch ( true ) { |
|
476 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
477 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
475 | + switch (true) { |
|
476 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
477 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
478 | 478 | |
479 | 479 | // Get firstname. |
480 | - if ( ! empty( $payment->user_info ) ) { |
|
481 | - $email_names = give_get_email_names( $payment->user_info ); |
|
480 | + if ( ! empty($payment->user_info)) { |
|
481 | + $email_names = give_get_email_names($payment->user_info); |
|
482 | 482 | $firstname = $email_names['name']; |
483 | 483 | } |
484 | 484 | break; |
485 | 485 | |
486 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
487 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
486 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
487 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
488 | 488 | $firstname = $donor->get_first_name(); |
489 | 489 | break; |
490 | 490 | |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @since 2.0 |
495 | 495 | */ |
496 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
497 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
496 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
497 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
498 | 498 | $firstname = $donor->get_first_name(); |
499 | 499 | break; |
500 | 500 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @param string $firstname |
508 | 508 | * @param array $tag_args |
509 | 509 | */ |
510 | - $firstname = apply_filters( 'give_email_tag_first_name', $firstname, $tag_args ); |
|
510 | + $firstname = apply_filters('give_email_tag_first_name', $firstname, $tag_args); |
|
511 | 511 | |
512 | 512 | return $firstname; |
513 | 513 | } |
@@ -521,26 +521,26 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string $fullname |
523 | 523 | */ |
524 | -function give_email_tag_fullname( $tag_args ) { |
|
524 | +function give_email_tag_fullname($tag_args) { |
|
525 | 525 | $fullname = ''; |
526 | 526 | |
527 | 527 | // Backward compatibility. |
528 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
528 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
529 | 529 | |
530 | - switch ( true ) { |
|
531 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
532 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
530 | + switch (true) { |
|
531 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
532 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
533 | 533 | |
534 | 534 | // Get fullname. |
535 | - if ( ! empty( $payment->user_info ) ) { |
|
536 | - $email_names = give_get_email_names( $payment->user_info ); |
|
535 | + if ( ! empty($payment->user_info)) { |
|
536 | + $email_names = give_get_email_names($payment->user_info); |
|
537 | 537 | $fullname = $email_names['fullname']; |
538 | 538 | } |
539 | 539 | break; |
540 | 540 | |
541 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
542 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
543 | - $fullname = trim( "{$donor->get_first_name()} {$donor->get_last_name()}" ); |
|
541 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
542 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
543 | + $fullname = trim("{$donor->get_first_name()} {$donor->get_last_name()}"); |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @since 2.0 |
550 | 550 | */ |
551 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
552 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
551 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
552 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
553 | 553 | $fullname = $donor->name; |
554 | 554 | break; |
555 | 555 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @param string $fullname |
563 | 563 | * @param array $tag_args |
564 | 564 | */ |
565 | - $fullname = apply_filters( 'give_email_tag_fullname', $fullname, $tag_args ); |
|
565 | + $fullname = apply_filters('give_email_tag_fullname', $fullname, $tag_args); |
|
566 | 566 | |
567 | 567 | return $fullname; |
568 | 568 | } |
@@ -576,25 +576,25 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return string username. |
578 | 578 | */ |
579 | -function give_email_tag_username( $tag_args ) { |
|
579 | +function give_email_tag_username($tag_args) { |
|
580 | 580 | $username = ''; |
581 | 581 | |
582 | 582 | // Backward compatibility. |
583 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
583 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
584 | 584 | |
585 | - switch ( true ) { |
|
586 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
587 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
585 | + switch (true) { |
|
586 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
587 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
588 | 588 | |
589 | 589 | // Get username. |
590 | - if ( ! empty( $payment->user_info ) ) { |
|
591 | - $email_names = give_get_email_names( $payment->user_info ); |
|
590 | + if ( ! empty($payment->user_info)) { |
|
591 | + $email_names = give_get_email_names($payment->user_info); |
|
592 | 592 | $username = $email_names['username']; |
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
596 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
597 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
596 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
597 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
598 | 598 | $username = $user_info->user_login; |
599 | 599 | break; |
600 | 600 | |
@@ -603,10 +603,10 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @since 2.0 |
605 | 605 | */ |
606 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
607 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
608 | - if ( ! empty( $donor->id ) && ! empty( $donor->user_id ) ) { |
|
609 | - $user_info = get_user_by( 'id', $donor->user_id ); |
|
606 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
607 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
608 | + if ( ! empty($donor->id) && ! empty($donor->user_id)) { |
|
609 | + $user_info = get_user_by('id', $donor->user_id); |
|
610 | 610 | $username = $user_info->user_login; |
611 | 611 | } |
612 | 612 | break; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @param string $username |
621 | 621 | * @param array $tag_args |
622 | 622 | */ |
623 | - $username = apply_filters( 'give_email_tag_username', $username, $tag_args ); |
|
623 | + $username = apply_filters('give_email_tag_username', $username, $tag_args); |
|
624 | 624 | |
625 | 625 | return $username; |
626 | 626 | } |
@@ -634,20 +634,20 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return string user_email |
636 | 636 | */ |
637 | -function give_email_tag_user_email( $tag_args ) { |
|
637 | +function give_email_tag_user_email($tag_args) { |
|
638 | 638 | $email = ''; |
639 | 639 | |
640 | 640 | // Backward compatibility. |
641 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
641 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
642 | 642 | |
643 | - switch ( true ) { |
|
644 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
645 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
643 | + switch (true) { |
|
644 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
645 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
646 | 646 | $email = $payment->email; |
647 | 647 | break; |
648 | 648 | |
649 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
650 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
649 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
650 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
651 | 651 | $email = $user_info->user_email; |
652 | 652 | break; |
653 | 653 | |
@@ -656,9 +656,9 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @since 2.0 |
658 | 658 | */ |
659 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
660 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
661 | - $email = $donor->email; |
|
659 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
660 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
661 | + $email = $donor->email; |
|
662 | 662 | break; |
663 | 663 | } |
664 | 664 | |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @param string $email |
671 | 671 | * @param array $tag_args |
672 | 672 | */ |
673 | - $email = apply_filters( 'give_email_tag_user_email', $email, $tag_args ); |
|
673 | + $email = apply_filters('give_email_tag_user_email', $email, $tag_args); |
|
674 | 674 | |
675 | 675 | return $email; |
676 | 676 | } |
@@ -684,22 +684,22 @@ discard block |
||
684 | 684 | * |
685 | 685 | * @return string billing_address |
686 | 686 | */ |
687 | -function give_email_tag_billing_address( $tag_args ) { |
|
687 | +function give_email_tag_billing_address($tag_args) { |
|
688 | 688 | $address = ''; |
689 | 689 | |
690 | 690 | // Backward compatibility. |
691 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
691 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
692 | 692 | |
693 | - switch ( true ) { |
|
694 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
695 | - $donation = new Give_Payment( $tag_args['payment_id'] ); |
|
696 | - $address = $donation->address['line1'] . "\n"; |
|
693 | + switch (true) { |
|
694 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
695 | + $donation = new Give_Payment($tag_args['payment_id']); |
|
696 | + $address = $donation->address['line1']."\n"; |
|
697 | 697 | |
698 | - if ( ! empty( $donation->address['line2'] ) ) { |
|
699 | - $address .= $donation->address['line2'] . "\n"; |
|
698 | + if ( ! empty($donation->address['line2'])) { |
|
699 | + $address .= $donation->address['line2']."\n"; |
|
700 | 700 | } |
701 | 701 | |
702 | - $address .= $donation->address['city'] . ' ' . $donation->address['zip'] . ' ' . $donation->address['state'] . "\n"; |
|
702 | + $address .= $donation->address['city'].' '.$donation->address['zip'].' '.$donation->address['state']."\n"; |
|
703 | 703 | $address .= $donation->address['country']; |
704 | 704 | break; |
705 | 705 | } |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @param string $address |
713 | 713 | * @param array $tag_args |
714 | 714 | */ |
715 | - $address = apply_filters( 'give_email_tag_billing_address', $address, $tag_args ); |
|
715 | + $address = apply_filters('give_email_tag_billing_address', $address, $tag_args); |
|
716 | 716 | |
717 | 717 | return $address; |
718 | 718 | } |
@@ -726,16 +726,16 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return string date |
728 | 728 | */ |
729 | -function give_email_tag_date( $tag_args ) { |
|
729 | +function give_email_tag_date($tag_args) { |
|
730 | 730 | $date = ''; |
731 | 731 | |
732 | 732 | // Backward compatibility. |
733 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
733 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
734 | 734 | |
735 | - switch ( true ) { |
|
736 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
737 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
738 | - $date = date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
735 | + switch (true) { |
|
736 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
737 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
738 | + $date = date_i18n(give_date_format(), strtotime($payment->date)); |
|
739 | 739 | break; |
740 | 740 | } |
741 | 741 | |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * @param string $date |
748 | 748 | * @param array $tag_args |
749 | 749 | */ |
750 | - $date = apply_filters( 'give_email_tag_date', $date, $tag_args ); |
|
750 | + $date = apply_filters('give_email_tag_date', $date, $tag_args); |
|
751 | 751 | |
752 | 752 | return $date; |
753 | 753 | } |
@@ -761,17 +761,17 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @return string amount |
763 | 763 | */ |
764 | -function give_email_tag_amount( $tag_args ) { |
|
764 | +function give_email_tag_amount($tag_args) { |
|
765 | 765 | $amount = ''; |
766 | 766 | |
767 | 767 | // Backward compatibility. |
768 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
768 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
769 | 769 | |
770 | - switch ( true ) { |
|
771 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
772 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
773 | - $give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), array( 'currency_code' => $payment->currency ) ); |
|
774 | - $amount = html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
770 | + switch (true) { |
|
771 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
772 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
773 | + $give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), array('currency_code' => $payment->currency)); |
|
774 | + $amount = html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
775 | 775 | break; |
776 | 776 | } |
777 | 777 | |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @param string $amount |
784 | 784 | * @param array $tag_args |
785 | 785 | */ |
786 | - $amount = apply_filters( 'give_email_tag_amount', $amount, $tag_args ); |
|
786 | + $amount = apply_filters('give_email_tag_amount', $amount, $tag_args); |
|
787 | 787 | |
788 | 788 | return $amount; |
789 | 789 | } |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @return string price |
799 | 799 | */ |
800 | -function give_email_tag_price( $tag_args ) { |
|
801 | - return give_email_tag_amount( $tag_args ); |
|
800 | +function give_email_tag_price($tag_args) { |
|
801 | + return give_email_tag_amount($tag_args); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | /** |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * |
811 | 811 | * @return int payment_id |
812 | 812 | */ |
813 | -function give_email_tag_payment_id( $tag_args ) { |
|
813 | +function give_email_tag_payment_id($tag_args) { |
|
814 | 814 | $payment_id = ''; |
815 | 815 | |
816 | 816 | // Backward compatibility. |
817 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
817 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
818 | 818 | |
819 | - switch ( true ) { |
|
820 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
821 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
819 | + switch (true) { |
|
820 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
821 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
822 | 822 | $payment_id = $payment->number; |
823 | 823 | break; |
824 | 824 | } |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | * @param string $payment_id |
832 | 832 | * @param array $tag_args |
833 | 833 | */ |
834 | - return apply_filters( 'give_email_tag_payment_id', $payment_id, $tag_args ); |
|
834 | + return apply_filters('give_email_tag_payment_id', $payment_id, $tag_args); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -843,15 +843,15 @@ discard block |
||
843 | 843 | * |
844 | 844 | * @return string receipt_id |
845 | 845 | */ |
846 | -function give_email_tag_receipt_id( $tag_args ) { |
|
846 | +function give_email_tag_receipt_id($tag_args) { |
|
847 | 847 | $receipt_id = ''; |
848 | 848 | |
849 | 849 | // Backward compatibility. |
850 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
850 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
851 | 851 | |
852 | - switch ( true ) { |
|
853 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
854 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
852 | + switch (true) { |
|
853 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
854 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
855 | 855 | $receipt_id = $payment->key; |
856 | 856 | break; |
857 | 857 | } |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @param string $receipt_id |
865 | 865 | * @param array $tag_args |
866 | 866 | */ |
867 | - return apply_filters( 'give_email_tag_receipt_id', $receipt_id, $tag_args ); |
|
867 | + return apply_filters('give_email_tag_receipt_id', $receipt_id, $tag_args); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -876,23 +876,23 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return string $form_title |
878 | 878 | */ |
879 | -function give_email_tag_donation( $tag_args ) { |
|
879 | +function give_email_tag_donation($tag_args) { |
|
880 | 880 | $donation_form_title = ''; |
881 | 881 | |
882 | 882 | // Backward compatibility. |
883 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
883 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
884 | 884 | |
885 | - switch ( true ) { |
|
886 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
887 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
888 | - $level_title = give_has_variable_prices( $payment->form_id ); |
|
885 | + switch (true) { |
|
886 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
887 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
888 | + $level_title = give_has_variable_prices($payment->form_id); |
|
889 | 889 | $separator = $level_title ? '-' : ''; |
890 | - $donation_form_title = strip_tags( give_check_variable( give_get_donation_form_title( |
|
890 | + $donation_form_title = strip_tags(give_check_variable(give_get_donation_form_title( |
|
891 | 891 | $payment, |
892 | 892 | array( |
893 | 893 | 'separator' => $separator, |
894 | 894 | ) |
895 | - ), 'empty', '' ) ); |
|
895 | + ), 'empty', '')); |
|
896 | 896 | break; |
897 | 897 | } |
898 | 898 | |
@@ -920,17 +920,17 @@ discard block |
||
920 | 920 | * |
921 | 921 | * @return string $form_title |
922 | 922 | */ |
923 | -function give_email_tag_form_title( $tag_args ) { |
|
923 | +function give_email_tag_form_title($tag_args) { |
|
924 | 924 | $donation_form_title = ''; |
925 | 925 | |
926 | 926 | // Backward compatibility. |
927 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
927 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
928 | 928 | |
929 | - switch ( true ) { |
|
930 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
931 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
929 | + switch (true) { |
|
930 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
931 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
932 | 932 | $payment_meta = $payment->payment_meta; |
933 | - $donation_form_title = strip_tags( give_check_variable( $payment_meta, 'empty', '', 'form_title' ) ); |
|
933 | + $donation_form_title = strip_tags(give_check_variable($payment_meta, 'empty', '', 'form_title')); |
|
934 | 934 | break; |
935 | 935 | } |
936 | 936 | |
@@ -958,19 +958,19 @@ discard block |
||
958 | 958 | * |
959 | 959 | * @return string gateway |
960 | 960 | */ |
961 | -function give_email_tag_payment_method( $tag_args ) { |
|
961 | +function give_email_tag_payment_method($tag_args) { |
|
962 | 962 | $payment_method = ''; |
963 | 963 | |
964 | 964 | // Backward compatibility. |
965 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
965 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
966 | 966 | |
967 | 967 | // Backward compatibility. |
968 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
968 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
969 | 969 | |
970 | - switch ( true ) { |
|
971 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
972 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
973 | - $payment_method = give_get_gateway_checkout_label( $payment->gateway ); |
|
970 | + switch (true) { |
|
971 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
972 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
973 | + $payment_method = give_get_gateway_checkout_label($payment->gateway); |
|
974 | 974 | break; |
975 | 975 | } |
976 | 976 | |
@@ -1001,16 +1001,16 @@ discard block |
||
1001 | 1001 | * |
1002 | 1002 | * @return string |
1003 | 1003 | */ |
1004 | -function give_email_tag_payment_total( $tag_args ) { |
|
1004 | +function give_email_tag_payment_total($tag_args) { |
|
1005 | 1005 | $payment_total = ''; |
1006 | 1006 | |
1007 | 1007 | // Backward compatibility. |
1008 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1008 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1009 | 1009 | |
1010 | - switch ( true ) { |
|
1011 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1012 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1013 | - $payment_total = give_currency_filter( $payment->total ); |
|
1010 | + switch (true) { |
|
1011 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1012 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1013 | + $payment_total = give_currency_filter($payment->total); |
|
1014 | 1014 | break; |
1015 | 1015 | } |
1016 | 1016 | |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | * |
1039 | 1039 | * @return string |
1040 | 1040 | */ |
1041 | -function give_email_tag_sitename( $tag_args = array() ) { |
|
1042 | - $sitename = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
1041 | +function give_email_tag_sitename($tag_args = array()) { |
|
1042 | + $sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
1043 | 1043 | |
1044 | 1044 | // Backward compatibility. |
1045 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1045 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1046 | 1046 | |
1047 | 1047 | /** |
1048 | 1048 | * Filter the {sitename} email template tag output. |
@@ -1068,26 +1068,26 @@ discard block |
||
1068 | 1068 | * |
1069 | 1069 | * @return string receipt_link |
1070 | 1070 | */ |
1071 | -function give_email_tag_receipt_link( $tag_args ) { |
|
1071 | +function give_email_tag_receipt_link($tag_args) { |
|
1072 | 1072 | // Backward compatibility. |
1073 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1073 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1074 | 1074 | |
1075 | - $receipt_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1075 | + $receipt_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1076 | 1076 | |
1077 | 1077 | // Bailout. |
1078 | - if ( give_get_option( 'email_template' ) === 'none' ) { |
|
1078 | + if (give_get_option('email_template') === 'none') { |
|
1079 | 1079 | return $receipt_url; |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | |
1083 | - $receipt_url = esc_url( add_query_arg( array( |
|
1084 | - 'payment_key' => give_get_payment_key( $tag_args['payment_id'] ), |
|
1085 | - ), give_get_history_page_uri() ) ); |
|
1083 | + $receipt_url = esc_url(add_query_arg(array( |
|
1084 | + 'payment_key' => give_get_payment_key($tag_args['payment_id']), |
|
1085 | + ), give_get_history_page_uri())); |
|
1086 | 1086 | |
1087 | - $formatted = sprintf( |
|
1087 | + $formatted = sprintf( |
|
1088 | 1088 | '<a href="%1$s">%2$s</a>', |
1089 | 1089 | $receipt_url, |
1090 | - __( 'View it in your browser »', 'give' ) |
|
1090 | + __('View it in your browser »', 'give') |
|
1091 | 1091 | ); |
1092 | 1092 | |
1093 | 1093 | /** |
@@ -1116,11 +1116,11 @@ discard block |
||
1116 | 1116 | * |
1117 | 1117 | * @return string receipt_url |
1118 | 1118 | */ |
1119 | -function give_email_tag_receipt_link_url( $tag_args ) { |
|
1119 | +function give_email_tag_receipt_link_url($tag_args) { |
|
1120 | 1120 | // Backward compatibility. |
1121 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1121 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1122 | 1122 | |
1123 | - $receipt_link_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1123 | + $receipt_link_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1124 | 1124 | |
1125 | 1125 | /** |
1126 | 1126 | * Filter the {receipt_link_url} email template tag output. |
@@ -1147,13 +1147,13 @@ discard block |
||
1147 | 1147 | * |
1148 | 1148 | * @return string |
1149 | 1149 | */ |
1150 | -function give_get_receipt_url( $payment_id ) { |
|
1150 | +function give_get_receipt_url($payment_id) { |
|
1151 | 1151 | $receipt_url = ''; |
1152 | 1152 | |
1153 | - if ( $payment_id ) { |
|
1154 | - $receipt_url = esc_url( add_query_arg( array( |
|
1155 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
1156 | - ), give_get_history_page_uri() ) ); |
|
1153 | + if ($payment_id) { |
|
1154 | + $receipt_url = esc_url(add_query_arg(array( |
|
1155 | + 'payment_key' => give_get_payment_key($payment_id), |
|
1156 | + ), give_get_history_page_uri())); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | return $receipt_url; |
@@ -1169,22 +1169,22 @@ discard block |
||
1169 | 1169 | * |
1170 | 1170 | * @return string |
1171 | 1171 | */ |
1172 | -function give_email_tag_email_access_link( $tag_args ) { |
|
1172 | +function give_email_tag_email_access_link($tag_args) { |
|
1173 | 1173 | $donor_id = 0; |
1174 | 1174 | $donor = array(); |
1175 | 1175 | $email_access_link = ''; |
1176 | 1176 | |
1177 | 1177 | // Backward compatibility. |
1178 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1178 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1179 | 1179 | |
1180 | - switch ( true ) { |
|
1181 | - case ! empty( $tag_args['donor_id'] ): |
|
1180 | + switch (true) { |
|
1181 | + case ! empty($tag_args['donor_id']): |
|
1182 | 1182 | $donor_id = $tag_args['donor_id']; |
1183 | - $donor = Give()->donors->get_by( 'id', $tag_args['donor_id'] ); |
|
1183 | + $donor = Give()->donors->get_by('id', $tag_args['donor_id']); |
|
1184 | 1184 | break; |
1185 | 1185 | |
1186 | - case ! empty( $tag_args['user_id'] ): |
|
1187 | - $donor = Give()->donors->get_by( 'user_id', $tag_args['user_id'] ); |
|
1186 | + case ! empty($tag_args['user_id']): |
|
1187 | + $donor = Give()->donors->get_by('user_id', $tag_args['user_id']); |
|
1188 | 1188 | $donor_id = $donor->id; |
1189 | 1189 | break; |
1190 | 1190 | |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | } |
1194 | 1194 | |
1195 | 1195 | // Set email access link if donor exist. |
1196 | - if ( $donor_id ) { |
|
1197 | - $verify_key = wp_generate_password( 20, false ); |
|
1196 | + if ($donor_id) { |
|
1197 | + $verify_key = wp_generate_password(20, false); |
|
1198 | 1198 | |
1199 | 1199 | // Generate a new verify key |
1200 | - Give()->email_access->set_verify_key( $donor_id, $donor->email, $verify_key ); |
|
1200 | + Give()->email_access->set_verify_key($donor_id, $donor->email, $verify_key); |
|
1201 | 1201 | |
1202 | 1202 | $access_url = add_query_arg( |
1203 | 1203 | array( |
@@ -1207,28 +1207,28 @@ discard block |
||
1207 | 1207 | ); |
1208 | 1208 | |
1209 | 1209 | // Add Payment Key to email access url, if it exists. |
1210 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
1210 | + if ( ! empty($_GET['payment_key'])) { |
|
1211 | 1211 | $access_url = add_query_arg( |
1212 | 1212 | array( |
1213 | - 'payment_key' => give_clean( $_GET['payment_key'] ), |
|
1213 | + 'payment_key' => give_clean($_GET['payment_key']), |
|
1214 | 1214 | ), |
1215 | 1215 | $access_url |
1216 | 1216 | ); |
1217 | 1217 | } |
1218 | 1218 | |
1219 | - if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1219 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1220 | 1220 | $email_access_link = sprintf( |
1221 | 1221 | '<a href="%1$s" target="_blank">%2$s</a>', |
1222 | - esc_url( $access_url ), |
|
1223 | - __( 'View your donation history »', 'give' ) |
|
1222 | + esc_url($access_url), |
|
1223 | + __('View your donation history »', 'give') |
|
1224 | 1224 | ); |
1225 | 1225 | |
1226 | 1226 | } else { |
1227 | 1227 | |
1228 | 1228 | $email_access_link = sprintf( |
1229 | 1229 | '%1$s: %2$s', |
1230 | - __( 'View your donation history', 'give' ), |
|
1231 | - esc_url( $access_url ) |
|
1230 | + __('View your donation history', 'give'), |
|
1231 | + esc_url($access_url) |
|
1232 | 1232 | ); |
1233 | 1233 | } |
1234 | 1234 | } |
@@ -1260,23 +1260,23 @@ discard block |
||
1260 | 1260 | * |
1261 | 1261 | * @return array |
1262 | 1262 | */ |
1263 | -function __give_20_bc_str_type_email_tag_param( $tag_args ) { |
|
1264 | - if ( ! is_array( $tag_args ) ) { |
|
1265 | - switch ( true ) { |
|
1266 | - case ( 'give_payment' === get_post_type( $tag_args ) ): |
|
1267 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
1263 | +function __give_20_bc_str_type_email_tag_param($tag_args) { |
|
1264 | + if ( ! is_array($tag_args)) { |
|
1265 | + switch (true) { |
|
1266 | + case ('give_payment' === get_post_type($tag_args)): |
|
1267 | + $tag_args = array('payment_id' => $tag_args); |
|
1268 | 1268 | break; |
1269 | 1269 | |
1270 | - case ( ! is_wp_error( get_user_by( 'id', $tag_args ) ) ): |
|
1271 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1270 | + case ( ! is_wp_error(get_user_by('id', $tag_args))): |
|
1271 | + $tag_args = array('user_id' => $tag_args); |
|
1272 | 1272 | break; |
1273 | 1273 | |
1274 | - case ( Give()->donors->get_by( 'id', $tag_args ) ): |
|
1275 | - $tag_args = array( 'donor_id' => $tag_args ); |
|
1274 | + case (Give()->donors->get_by('id', $tag_args)): |
|
1275 | + $tag_args = array('donor_id' => $tag_args); |
|
1276 | 1276 | break; |
1277 | 1277 | |
1278 | - case ( Give()->donors->get_by( 'user_id', $tag_args ) ): |
|
1279 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1278 | + case (Give()->donors->get_by('user_id', $tag_args)): |
|
1279 | + $tag_args = array('user_id' => $tag_args); |
|
1280 | 1280 | break; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1294,39 +1294,39 @@ discard block |
||
1294 | 1294 | * |
1295 | 1295 | * @return array |
1296 | 1296 | */ |
1297 | -function give_email_tag_reset_password_link( $tag_args, $payment_id ) { |
|
1297 | +function give_email_tag_reset_password_link($tag_args, $payment_id) { |
|
1298 | 1298 | |
1299 | 1299 | $reset_password_url = ''; |
1300 | 1300 | |
1301 | - switch ( true ) { |
|
1302 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1303 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1301 | + switch (true) { |
|
1302 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1303 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1304 | 1304 | $payment_id = $payment->number; |
1305 | 1305 | break; |
1306 | 1306 | |
1307 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
1308 | - $reset_password_url = give_get_reset_password_url( $tag_args['user_id'] ); |
|
1307 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
1308 | + $reset_password_url = give_get_reset_password_url($tag_args['user_id']); |
|
1309 | 1309 | break; |
1310 | 1310 | |
1311 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
1311 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
1312 | 1312 | /* @var Give_Donor $donor */ |
1313 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
1314 | - $reset_password_url = give_get_reset_password_url( $donor->user_id ); |
|
1313 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
1314 | + $reset_password_url = give_get_reset_password_url($donor->user_id); |
|
1315 | 1315 | break; |
1316 | 1316 | } |
1317 | 1317 | |
1318 | - if( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1318 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1319 | 1319 | // Generate link, if Email content type is html. |
1320 | 1320 | $reset_password_link = sprintf( |
1321 | 1321 | '<a href="%1$s" target="_blank">%2$s</a>', |
1322 | - esc_url( $reset_password_url ), |
|
1323 | - __( 'Reset your password »', 'give' ) |
|
1322 | + esc_url($reset_password_url), |
|
1323 | + __('Reset your password »', 'give') |
|
1324 | 1324 | ); |
1325 | - } else{ |
|
1325 | + } else { |
|
1326 | 1326 | $reset_password_link = sprintf( |
1327 | 1327 | '%1$s: %2$s', |
1328 | - __( 'Reset your password', 'give' ), |
|
1329 | - esc_url( $reset_password_url ) |
|
1328 | + __('Reset your password', 'give'), |
|
1329 | + esc_url($reset_password_url) |
|
1330 | 1330 | ); |
1331 | 1331 | } |
1332 | 1332 | |
@@ -1355,21 +1355,21 @@ discard block |
||
1355 | 1355 | * |
1356 | 1356 | * @return mixed|string |
1357 | 1357 | */ |
1358 | -function give_get_reset_password_url( $user_id ) { |
|
1358 | +function give_get_reset_password_url($user_id) { |
|
1359 | 1359 | $reset_password_url = ''; |
1360 | 1360 | |
1361 | 1361 | // Proceed further only, if user_id exists. |
1362 | - if ( $user_id ) { |
|
1362 | + if ($user_id) { |
|
1363 | 1363 | |
1364 | 1364 | // Get User Object Details. |
1365 | - $user = get_user_by( 'ID', $user_id ); |
|
1365 | + $user = get_user_by('ID', $user_id); |
|
1366 | 1366 | |
1367 | 1367 | // Prepare Reset Password URL. |
1368 | - $reset_password_url = esc_url( add_query_arg( array( |
|
1368 | + $reset_password_url = esc_url(add_query_arg(array( |
|
1369 | 1369 | 'action' => 'rp', |
1370 | - 'key' => get_password_reset_key( $user ), |
|
1370 | + 'key' => get_password_reset_key($user), |
|
1371 | 1371 | 'login' => $user->user_login, |
1372 | - ), wp_login_url() ) ); |
|
1372 | + ), wp_login_url())); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | return $reset_password_url; |