@@ -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. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return static |
78 | 78 | */ |
79 | 79 | public static function get_instance() { |
80 | - if ( null === static::$instance ) { |
|
80 | + if (null === static::$instance) { |
|
81 | 81 | self::$instance = new static(); |
82 | 82 | } |
83 | 83 | |
@@ -104,26 +104,26 @@ discard block |
||
104 | 104 | * @return void |
105 | 105 | */ |
106 | 106 | private function setup_hooks() { |
107 | - if ( ! $this->is_donations_import_page() ) { |
|
107 | + if ( ! $this->is_donations_import_page()) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Do not render main import tools page. |
112 | - remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) ); |
|
112 | + remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',)); |
|
113 | 113 | |
114 | 114 | // Render donation import page |
115 | - add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) ); |
|
115 | + add_action('give_admin_field_tools_import', array($this, 'render_page')); |
|
116 | 116 | |
117 | 117 | // Print the HTML. |
118 | - add_action( 'give_tools_import_core_settings_form_start', array( $this, 'html' ), 10 ); |
|
118 | + add_action('give_tools_import_core_settings_form_start', array($this, 'html'), 10); |
|
119 | 119 | |
120 | 120 | // Run when form submit. |
121 | - add_action( 'give-tools_save_import', array( $this, 'save' ) ); |
|
121 | + add_action('give-tools_save_import', array($this, 'save')); |
|
122 | 122 | |
123 | - add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 ); |
|
123 | + add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1); |
|
124 | 124 | |
125 | 125 | // Used to add submit button. |
126 | - add_action( 'give_tools_import_core_settings_form_end', array( $this, 'submit' ), 10 ); |
|
126 | + add_action('give_tools_import_core_settings_form_end', array($this, 'submit'), 10); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | - public function update_notices( $messages ) { |
|
139 | - if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) { |
|
140 | - unset( $messages['give-setting-updated'] ); |
|
138 | + public function update_notices($messages) { |
|
139 | + if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) { |
|
140 | + unset($messages['give-setting-updated']); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | return $messages; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @since 1.8.17 |
150 | 150 | */ |
151 | 151 | public function submit() { |
152 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
152 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
153 | 153 | ?> |
154 | 154 | <input type="hidden" class="import-step" id="import-step" name="step" value="<?php echo $this->get_step(); ?>"/> |
155 | 155 | <input type="hidden" class="importer-type" value="<?php echo $this->importer_type; ?>"/> |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | ?> |
170 | 170 | <section> |
171 | 171 | <table |
172 | - class="widefat export-options-table give-table <?php echo "step-{$step}"; ?> <?php echo( 1 === $step && ! empty( $this->is_json_valid ) ? 'give-hidden' : '' ); ?> " |
|
172 | + class="widefat export-options-table give-table <?php echo "step-{$step}"; ?> <?php echo(1 === $step && ! empty($this->is_json_valid) ? 'give-hidden' : ''); ?> " |
|
173 | 173 | id="<?php echo "step-{$step}"; ?>"> |
174 | 174 | <tbody> |
175 | 175 | <?php |
176 | - switch ( $step ) { |
|
176 | + switch ($step) { |
|
177 | 177 | case 1: |
178 | 178 | $this->render_upload_html(); |
179 | 179 | break; |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | public function import_success() { |
201 | 201 | // Imported successfully |
202 | 202 | |
203 | - $success = (bool) ( isset( $_GET['success'] ) ? give_clean( $_GET['success'] ) : false ); |
|
204 | - $undo = (bool) ( isset( $_GET['undo'] ) ? give_clean( $_GET['undo'] ) : false ); |
|
203 | + $success = (bool) (isset($_GET['success']) ? give_clean($_GET['success']) : false); |
|
204 | + $undo = (bool) (isset($_GET['undo']) ? give_clean($_GET['undo']) : false); |
|
205 | 205 | $query_arg_setting = array( |
206 | 206 | 'post_type' => 'give_forms', |
207 | 207 | 'page' => 'give-settings', |
208 | 208 | ); |
209 | 209 | |
210 | - if ( $undo ) { |
|
210 | + if ($undo) { |
|
211 | 211 | $success = false; |
212 | 212 | } |
213 | 213 | |
@@ -220,30 +220,30 @@ discard block |
||
220 | 220 | 'undo' => 'true', |
221 | 221 | ); |
222 | 222 | |
223 | - $title = __( 'Settings Importing Completed!', 'give' ); |
|
224 | - if ( $success ) { |
|
223 | + $title = __('Settings Importing Completed!', 'give'); |
|
224 | + if ($success) { |
|
225 | 225 | $query_arg_success['undo'] = '1'; |
226 | 226 | $query_arg_success['step'] = '3'; |
227 | 227 | $query_arg_success['success'] = '1'; |
228 | - $text = __( 'Undo Importing', 'give' ); |
|
228 | + $text = __('Undo Importing', 'give'); |
|
229 | 229 | } else { |
230 | - if ( $undo ) { |
|
231 | - $host_give_options = get_option( 'give_settings_old', array() ); |
|
232 | - update_option( 'give_settings', $host_give_options ); |
|
233 | - $title = __( 'Undo of Setting Imported Completed!', 'give' ); |
|
230 | + if ($undo) { |
|
231 | + $host_give_options = get_option('give_settings_old', array()); |
|
232 | + update_option('give_settings', $host_give_options); |
|
233 | + $title = __('Undo of Setting Imported Completed!', 'give'); |
|
234 | 234 | } else { |
235 | - $title = __( 'Failed to import', 'give' ); |
|
235 | + $title = __('Failed to import', 'give'); |
|
236 | 236 | } |
237 | 237 | |
238 | - $text = __( 'Importing Again', 'give' ); |
|
238 | + $text = __('Importing Again', 'give'); |
|
239 | 239 | } |
240 | 240 | ?> |
241 | 241 | <tr valign="top" class="give-import-dropdown"> |
242 | 242 | <th colspan="2"> |
243 | 243 | <h2><?php echo $title; ?></h2> |
244 | 244 | <p> |
245 | - <a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg_success, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a> |
|
246 | - <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> |
|
245 | + <a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg_success, admin_url('edit.php')); ?>"><?php echo $text; ?></a> |
|
246 | + <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> |
|
247 | 247 | </p> |
248 | 248 | </th> |
249 | 249 | </tr> |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | * @since 1.8.17 |
257 | 257 | */ |
258 | 258 | public function start_import() { |
259 | - $type = ( ! empty( $_GET['type'] ) ? give_clean( $_GET['type'] ) : 'replace' ); |
|
260 | - $file_name = ( ! empty( $_GET['file_name'] ) ? give_clean( $_GET['file_name'] ) : '' ); |
|
259 | + $type = ( ! empty($_GET['type']) ? give_clean($_GET['type']) : 'replace'); |
|
260 | + $file_name = ( ! empty($_GET['file_name']) ? give_clean($_GET['file_name']) : ''); |
|
261 | 261 | |
262 | 262 | ?> |
263 | 263 | <tr valign="top" class="give-import-dropdown"> |
264 | 264 | <th colspan="2"> |
265 | - <h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2> |
|
266 | - <p class="give-field-description"><?php esc_html_e( 'Your settings are now being imported...', 'give' ) ?></p> |
|
265 | + <h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2> |
|
266 | + <p class="give-field-description"><?php esc_html_e('Your settings are now being imported...', 'give') ?></p> |
|
267 | 267 | </th> |
268 | 268 | </tr> |
269 | 269 | |
@@ -290,14 +290,14 @@ discard block |
||
290 | 290 | $step = $this->get_step(); |
291 | 291 | ?> |
292 | 292 | <ol class="give-progress-steps"> |
293 | - <li class="<?php echo( 1 === $step ? 'active' : '' ); ?>"> |
|
294 | - <?php esc_html_e( 'Upload JSON file', 'give' ); ?> |
|
293 | + <li class="<?php echo(1 === $step ? 'active' : ''); ?>"> |
|
294 | + <?php esc_html_e('Upload JSON file', 'give'); ?> |
|
295 | 295 | </li> |
296 | - <li class="<?php echo( 2 === $step ? 'active' : '' ); ?>"> |
|
297 | - <?php esc_html_e( 'Import', 'give' ); ?> |
|
296 | + <li class="<?php echo(2 === $step ? 'active' : ''); ?>"> |
|
297 | + <?php esc_html_e('Import', 'give'); ?> |
|
298 | 298 | </li> |
299 | - <li class="<?php echo( 3 === $step ? 'active' : '' ); ?>"> |
|
300 | - <?php esc_html_e( 'Done!', 'give' ); ?> |
|
299 | + <li class="<?php echo(3 === $step ? 'active' : ''); ?>"> |
|
300 | + <?php esc_html_e('Done!', 'give'); ?> |
|
301 | 301 | </li> |
302 | 302 | </ol> |
303 | 303 | <?php |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | * @return int $step on which step doest the import is on. |
312 | 312 | */ |
313 | 313 | public function get_step() { |
314 | - $step = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 ); |
|
314 | + $step = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0); |
|
315 | 315 | $on_step = 1; |
316 | 316 | |
317 | - if ( empty( $step ) || 1 === $step ) { |
|
317 | + if (empty($step) || 1 === $step) { |
|
318 | 318 | $on_step = 1; |
319 | - } elseif ( 2 === $step ) { |
|
319 | + } elseif (2 === $step) { |
|
320 | 320 | $on_step = 2; |
321 | - } elseif ( 3 === $step ) { |
|
321 | + } elseif (3 === $step) { |
|
322 | 322 | $on_step = 3; |
323 | 323 | } |
324 | 324 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @since 1.8.17 |
332 | 332 | */ |
333 | 333 | public function render_page() { |
334 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-core-settings.php'; |
|
334 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-core-settings.php'; |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
@@ -343,28 +343,28 @@ discard block |
||
343 | 343 | * @return void |
344 | 344 | */ |
345 | 345 | public function render_upload_html() { |
346 | - $json = ( isset( $_POST['json'] ) ? give_clean( $_POST['json'] ) : '' ); |
|
347 | - $type = ( isset( $_POST['type'] ) ? give_clean( $_POST['type'] ) : 'merge' ); |
|
346 | + $json = (isset($_POST['json']) ? give_clean($_POST['json']) : ''); |
|
347 | + $type = (isset($_POST['type']) ? give_clean($_POST['type']) : 'merge'); |
|
348 | 348 | $step = $this->get_step(); |
349 | 349 | |
350 | 350 | ?> |
351 | 351 | <tr valign="top"> |
352 | 352 | <th colspan="2"> |
353 | - <h2 id="give-import-title"><?php esc_html_e( 'Import Core Settings from a JSON file', 'give' ) ?></h2> |
|
354 | - <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> |
|
353 | + <h2 id="give-import-title"><?php esc_html_e('Import Core Settings from a JSON file', 'give') ?></h2> |
|
354 | + <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> |
|
355 | 355 | </th> |
356 | 356 | </tr> |
357 | 357 | |
358 | 358 | <tr valign="top"> |
359 | 359 | <th scope="row" class="titledesc"> |
360 | - <label for="json"><?php esc_html_e( 'Choose a JSON file:', 'give' ) ?></label> |
|
360 | + <label for="json"><?php esc_html_e('Choose a JSON file:', 'give') ?></label> |
|
361 | 361 | </th> |
362 | 362 | <td class="give-forminp"> |
363 | 363 | <div class="give-field-wrap"> |
364 | 364 | <label for="json"> |
365 | 365 | <input type="file" name="json" class="give-upload-json-file" value="<?php echo $json; ?>" |
366 | 366 | accept=".json"> |
367 | - <p class="give-field-description"><?php esc_html_e( 'The file type must be JSON.', 'give' )?></p> |
|
367 | + <p class="give-field-description"><?php esc_html_e('The file type must be JSON.', 'give')?></p> |
|
368 | 368 | </label> |
369 | 369 | </div> |
370 | 370 | </td> |
@@ -373,21 +373,21 @@ discard block |
||
373 | 373 | $settings = array( |
374 | 374 | array( |
375 | 375 | 'id' => 'type', |
376 | - 'name' => __( 'Merge Type:', 'give' ), |
|
377 | - 'description' => __( 'Select "Merge" to retain existing settings, or "Replace" to overwrite with the settings from the JSON file', 'give' ), |
|
376 | + 'name' => __('Merge Type:', 'give'), |
|
377 | + 'description' => __('Select "Merge" to retain existing settings, or "Replace" to overwrite with the settings from the JSON file', 'give'), |
|
378 | 378 | 'default' => $type, |
379 | 379 | 'type' => 'radio_inline', |
380 | 380 | 'options' => array( |
381 | - 'merge' => __( 'Merge', 'give' ), |
|
382 | - 'replace' => __( 'Replace', 'give' ), |
|
381 | + 'merge' => __('Merge', 'give'), |
|
382 | + 'replace' => __('Replace', 'give'), |
|
383 | 383 | ), |
384 | 384 | ), |
385 | 385 | ); |
386 | 386 | |
387 | - $settings = apply_filters( 'give_import_core_setting_html', $settings ); |
|
387 | + $settings = apply_filters('give_import_core_setting_html', $settings); |
|
388 | 388 | |
389 | - if ( empty( $this->is_json_valid ) ) { |
|
390 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
389 | + if (empty($this->is_json_valid)) { |
|
390 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
391 | 391 | ?> |
392 | 392 | <tr valign="top"> |
393 | 393 | <th></th> |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | <input type="submit" |
396 | 396 | class="button button-primary button-large button-secondary <?php echo "step-{$step}"; ?>" |
397 | 397 | id="recount-stats-submit" |
398 | - value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/> |
|
398 | + value="<?php esc_attr_e('Submit', 'give'); ?>"/> |
|
399 | 399 | </th> |
400 | 400 | </tr> |
401 | 401 | <?php |
@@ -417,20 +417,20 @@ discard block |
||
417 | 417 | $step = $this->get_step(); |
418 | 418 | |
419 | 419 | // Validation for first step. |
420 | - if ( 1 === $step ) { |
|
421 | - $type = ( ! empty( $_REQUEST['type'] ) ? give_clean( $_REQUEST['type'] ) : 'replace' ); |
|
420 | + if (1 === $step) { |
|
421 | + $type = ( ! empty($_REQUEST['type']) ? give_clean($_REQUEST['type']) : 'replace'); |
|
422 | 422 | $core_settings = self::upload_widget_settings_file(); |
423 | - if ( ! empty( $core_settings['error'] ) ) { |
|
424 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload a valid JSON settings file.', 'give' ) ); |
|
423 | + if ( ! empty($core_settings['error'])) { |
|
424 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload a valid JSON settings file.', 'give')); |
|
425 | 425 | } else { |
426 | - $file_path = explode( '/', $core_settings['file'] ); |
|
427 | - $count = ( count( $file_path ) - 1 ); |
|
428 | - $url = give_import_page_url( (array) apply_filters( 'give_import_core_settings_importing_url', array( |
|
426 | + $file_path = explode('/', $core_settings['file']); |
|
427 | + $count = (count($file_path) - 1); |
|
428 | + $url = give_import_page_url((array) apply_filters('give_import_core_settings_importing_url', array( |
|
429 | 429 | 'step' => '2', |
430 | 430 | 'importer-type' => $this->importer_type, |
431 | 431 | 'type' => $type, |
432 | - 'file_name' => $file_path[ $count ], |
|
433 | - ) ) ); |
|
432 | + 'file_name' => $file_path[$count], |
|
433 | + ))); |
|
434 | 434 | |
435 | 435 | |
436 | 436 | $this->is_json_valid = $url; |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @return bool |
446 | 446 | */ |
447 | 447 | private function is_donations_import_page() { |
448 | - return 'import' === give_get_current_setting_tab() && isset( $_GET['importer-type'] ) && $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
448 | + return 'import' === give_get_current_setting_tab() && isset($_GET['importer-type']) && $this->importer_type === give_clean($_GET['importer-type']); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -454,14 +454,14 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public static function upload_widget_settings_file() { |
456 | 456 | $upload = false; |
457 | - if ( isset( $_FILES['json'] ) ) { |
|
458 | - add_filter( 'upload_mimes', array( __CLASS__, 'json_upload_mimes' ) ); |
|
457 | + if (isset($_FILES['json'])) { |
|
458 | + add_filter('upload_mimes', array(__CLASS__, 'json_upload_mimes')); |
|
459 | 459 | |
460 | - $upload = wp_handle_upload( $_FILES['json'], array( 'test_form' => false ) ); |
|
460 | + $upload = wp_handle_upload($_FILES['json'], array('test_form' => false)); |
|
461 | 461 | |
462 | - remove_filter( 'upload_mimes', array( __CLASS__, 'json_upload_mimes' ) ); |
|
462 | + remove_filter('upload_mimes', array(__CLASS__, 'json_upload_mimes')); |
|
463 | 463 | } else { |
464 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) ); |
|
464 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give')); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | return $upload; |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @param array $existing_mimes |
474 | 474 | */ |
475 | - public static function json_upload_mimes( $existing_mimes = array() ) { |
|
475 | + public static function json_upload_mimes($existing_mimes = array()) { |
|
476 | 476 | $existing_mimes['json'] = 'application/json'; |
477 | 477 | |
478 | 478 | 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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', __( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', __('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats(); ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date_i18n( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date_i18n(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - __( 'Happy %s!', 'give' ), |
|
55 | - date_i18n( 'l', current_time( 'timestamp' ) ) |
|
54 | + __('Happy %s!', 'give'), |
|
55 | + date_i18n('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today, array( 'sanitize' => false ) ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today, array('sanitize' => false))); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-donations-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - __( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, array( 'decimal' => false, 'sanitize' => false ) ) |
|
68 | + __('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, array('decimal' => false, 'sanitize' => false)) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php _e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php _e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php _e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php _e('This Week', 'give'); ?></th> |
|
80 | + <th><?php _e('This Month', 'give'); ?></th> |
|
81 | + <th><?php _e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ), array( 'sanitize' => false ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'), array('sanitize' => false))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php _e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ), array( 'sanitize' => false ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'), array('sanitize' => false))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php _e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'), array('sanitize' => false))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php _e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php _e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_quarter' ), array( 'sanitize' => false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_quarter'), array('sanitize' => false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Quarter', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php _e('This Quarter', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,24 +123,24 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | 127 | |
128 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
128 | + $num_posts = wp_count_posts('give_forms'); |
|
129 | 129 | |
130 | - if ( $num_posts && $num_posts->publish ) { |
|
130 | + if ($num_posts && $num_posts->publish) { |
|
131 | 131 | |
132 | 132 | $text = sprintf( |
133 | 133 | /* translators: %s: number of posts published */ |
134 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
134 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
135 | 135 | $num_posts->publish |
136 | 136 | ); |
137 | 137 | |
138 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
138 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
139 | 139 | |
140 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
140 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
141 | 141 | $text = sprintf( |
142 | 142 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
143 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
143 | + admin_url('edit.php?post_type=give_forms'), |
|
144 | 144 | $text |
145 | 145 | ); |
146 | 146 | } else { |
@@ -156,4 +156,4 @@ discard block |
||
156 | 156 | return $items; |
157 | 157 | } |
158 | 158 | |
159 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
159 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @return void |
25 | 25 | */ |
26 | 26 | function give_payment_history_page() { |
27 | - if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) { |
|
28 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php'; |
|
27 | + if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) { |
|
28 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php'; |
|
29 | 29 | } else { |
30 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php'; |
|
30 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php'; |
|
31 | 31 | $payments_table = new Give_Payment_History_Table(); |
32 | 32 | $payments_table->prepare_items(); |
33 | 33 | ?> |
@@ -41,23 +41,23 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @since 1.7 |
43 | 43 | */ |
44 | - do_action( 'give_payments_page_top' ); |
|
44 | + do_action('give_payments_page_top'); |
|
45 | 45 | ?> |
46 | 46 | <hr class="wp-header-end"> |
47 | 47 | |
48 | - <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
48 | + <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
49 | 49 | <input type="hidden" name="post_type" value="give_forms" /> |
50 | 50 | <input type="hidden" name="page" value="give-payment-history" /> |
51 | 51 | <?php $payments_table->views() ?> |
52 | 52 | <?php $payments_table->advanced_filters(); ?> |
53 | 53 | </form> |
54 | 54 | |
55 | - <form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
55 | + <form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
56 | 56 | <input type="hidden" name="post_type" value="give_forms" /> |
57 | 57 | <input type="hidden" name="page" value="give-payment-history" /> |
58 | 58 | <?php |
59 | - if ( ! empty( $_GET['donor'] ) ) { |
|
60 | - echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $_GET['donor'] ) ); |
|
59 | + if ( ! empty($_GET['donor'])) { |
|
60 | + echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($_GET['donor'])); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $payments_table->display(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @since 1.7 |
72 | 72 | */ |
73 | - do_action( 'give_payments_page_bottom' ); |
|
73 | + do_action('give_payments_page_bottom'); |
|
74 | 74 | ?> |
75 | 75 | |
76 | 76 | </div> |
@@ -87,29 +87,29 @@ discard block |
||
87 | 87 | * @param $title |
88 | 88 | * @return string |
89 | 89 | */ |
90 | -function give_view_donation_details_title( $admin_title, $title ) { |
|
90 | +function give_view_donation_details_title($admin_title, $title) { |
|
91 | 91 | |
92 | - if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) { |
|
92 | + if ('give_forms_page_give-payment-history' != get_current_screen()->base) { |
|
93 | 93 | return $admin_title; |
94 | 94 | } |
95 | 95 | |
96 | - if( ! isset( $_GET['give-action'] ) ) { |
|
96 | + if ( ! isset($_GET['give-action'])) { |
|
97 | 97 | return $admin_title; |
98 | 98 | } |
99 | 99 | |
100 | - switch( $_GET['give-action'] ) : |
|
100 | + switch ($_GET['give-action']) : |
|
101 | 101 | |
102 | 102 | case 'view-payment-details' : |
103 | 103 | $title = sprintf( |
104 | 104 | /* translators: %s: admin title */ |
105 | - esc_html__( 'View Donation Details - %s', 'give' ), |
|
105 | + esc_html__('View Donation Details - %s', 'give'), |
|
106 | 106 | $admin_title |
107 | 107 | ); |
108 | 108 | break; |
109 | 109 | case 'edit-payment' : |
110 | 110 | $title = sprintf( |
111 | 111 | /* translators: %s: admin title */ |
112 | - esc_html__( 'Edit Donation - %s', 'give' ), |
|
112 | + esc_html__('Edit Donation - %s', 'give'), |
|
113 | 113 | $admin_title |
114 | 114 | ); |
115 | 115 | break; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | return $title; |
122 | 122 | } |
123 | -add_filter( 'admin_title', 'give_view_donation_details_title', 10, 2 ); |
|
123 | +add_filter('admin_title', 'give_view_donation_details_title', 10, 2); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen. |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | * @param $context |
133 | 133 | * @return string |
134 | 134 | */ |
135 | -function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) { |
|
135 | +function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) { |
|
136 | 136 | |
137 | - $post = get_post( $post_id ); |
|
137 | + $post = get_post($post_id); |
|
138 | 138 | |
139 | - if( ! $post ) { |
|
139 | + if ( ! $post) { |
|
140 | 140 | return $url; |
141 | 141 | } |
142 | 142 | |
143 | - if( 'give_payment' != $post->post_type ) { |
|
143 | + if ('give_payment' != $post->post_type) { |
|
144 | 144 | return $url; |
145 | 145 | } |
146 | 146 | |
147 | - $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id ); |
|
147 | + $url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id); |
|
148 | 148 | |
149 | 149 | return $url; |
150 | 150 | } |
151 | -add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 ); |
|
151 | +add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3); |
@@ -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 | |
@@ -27,30 +27,30 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return mixed |
29 | 29 | */ |
30 | -function __give_sanitize_number_decimals_setting_field( $value ) { |
|
30 | +function __give_sanitize_number_decimals_setting_field($value) { |
|
31 | 31 | $value_changed = false; |
32 | 32 | $old_value = $value; |
33 | 33 | |
34 | - if ( isset( $_POST['decimal_separator'] ) ) { |
|
35 | - $value = ! empty( $_POST['decimal_separator'] ) ? $value : 0; |
|
34 | + if (isset($_POST['decimal_separator'])) { |
|
35 | + $value = ! empty($_POST['decimal_separator']) ? $value : 0; |
|
36 | 36 | $value_changed = true; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $value_changed && ( $old_value !== $value ) ) { |
|
40 | - Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give' ) ); |
|
39 | + if ($value_changed && ($old_value !== $value)) { |
|
40 | + Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give')); |
|
41 | 41 | } |
42 | 42 | |
43 | - $value = absint( $value ); |
|
43 | + $value = absint($value); |
|
44 | 44 | |
45 | - if ( 6 <= $value ) { |
|
45 | + if (6 <= $value) { |
|
46 | 46 | $value = 5; |
47 | - Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give' ) ); |
|
47 | + Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give')); |
|
48 | 48 | } |
49 | 49 | |
50 | - return absint( $value ); |
|
50 | + return absint($value); |
|
51 | 51 | } |
52 | 52 | |
53 | -add_filter( 'give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10 ); |
|
53 | +add_filter('give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
@@ -66,20 +66,20 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function __give_validate_decimal_separator_setting_field( $value ) { |
|
70 | - $thousand_separator = isset( $_POST['thousands_separator'] ) ? give_clean( $_POST['thousands_separator'] ) : ''; |
|
71 | - $decimal_separator = isset( $_POST['decimal_separator'] ) ? give_clean( $_POST['decimal_separator'] ) : ''; |
|
69 | +function __give_validate_decimal_separator_setting_field($value) { |
|
70 | + $thousand_separator = isset($_POST['thousands_separator']) ? give_clean($_POST['thousands_separator']) : ''; |
|
71 | + $decimal_separator = isset($_POST['decimal_separator']) ? give_clean($_POST['decimal_separator']) : ''; |
|
72 | 72 | |
73 | - if ( $decimal_separator === $thousand_separator ) { |
|
73 | + if ($decimal_separator === $thousand_separator) { |
|
74 | 74 | $value = ''; |
75 | 75 | $_POST['number_decimals'] = 0; |
76 | - Give_Admin_Settings::add_error( 'give-decimal-separator', __( 'The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give' ) ); |
|
76 | + Give_Admin_Settings::add_error('give-decimal-separator', __('The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give')); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $value; |
80 | 80 | } |
81 | 81 | |
82 | -add_filter( 'give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10 ); |
|
82 | +add_filter('give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Change $delimiter text to symbol. |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string $delimiter. |
92 | 92 | */ |
93 | -function __give_import_delimiter_set_callback( $delimiter ) { |
|
93 | +function __give_import_delimiter_set_callback($delimiter) { |
|
94 | 94 | $delimite_type = array( |
95 | 95 | 'csv' => ',', |
96 | 96 | 'tab-separated-values' => "\t", |
97 | 97 | ); |
98 | 98 | |
99 | - return ( array_key_exists( $delimiter, $delimite_type ) ? $delimite_type[ $delimiter ] : ',' ); |
|
99 | + return (array_key_exists($delimiter, $delimite_type) ? $delimite_type[$delimiter] : ','); |
|
100 | 100 | } |
101 | 101 | |
102 | -add_filter( 'give_import_delimiter_set', '__give_import_delimiter_set_callback', 10 ); |
|
102 | +add_filter('give_import_delimiter_set', '__give_import_delimiter_set_callback', 10); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Give unset the page id from the core setting data from the json files. |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return array $json_to_array |
113 | 113 | */ |
114 | -function give_import_core_settings_merge_pages( $json_to_array, $type ) { |
|
115 | - if ( 'merge' === $type ) { |
|
116 | - unset( $json_to_array['success_page'] ); |
|
117 | - unset( $json_to_array['failure_page'] ); |
|
118 | - unset( $json_to_array['history_page'] ); |
|
114 | +function give_import_core_settings_merge_pages($json_to_array, $type) { |
|
115 | + if ('merge' === $type) { |
|
116 | + unset($json_to_array['success_page']); |
|
117 | + unset($json_to_array['failure_page']); |
|
118 | + unset($json_to_array['history_page']); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return $json_to_array; |
122 | 122 | } |
123 | 123 | |
124 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2 ); |
|
124 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Give check the image size from the core setting data from the json files. |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return array $json_to_array |
135 | 135 | */ |
136 | -function give_import_core_settings_merge_image_size( $json_to_array, $type ) { |
|
137 | - if ( 'merge' === $type ) { |
|
136 | +function give_import_core_settings_merge_image_size($json_to_array, $type) { |
|
137 | + if ('merge' === $type) { |
|
138 | 138 | // Featured image sizes import under Display Options > Post Types > Featured Image Size. |
139 | 139 | if ( |
140 | - ! empty( $json_to_array['form_featured_img'] ) |
|
141 | - && ! empty( $json_to_array['featured_image_size'] ) |
|
142 | - && give_is_setting_enabled( $json_to_array['form_featured_img'] ) |
|
140 | + ! empty($json_to_array['form_featured_img']) |
|
141 | + && ! empty($json_to_array['featured_image_size']) |
|
142 | + && give_is_setting_enabled($json_to_array['form_featured_img']) |
|
143 | 143 | ) { |
144 | 144 | $images_sizes = get_intermediate_image_sizes(); |
145 | 145 | |
146 | - if ( ! in_array( $json_to_array['featured_image_size'], $images_sizes, true ) ) { |
|
147 | - unset( $json_to_array['featured_image_size'] ); |
|
146 | + if ( ! in_array($json_to_array['featured_image_size'], $images_sizes, true)) { |
|
147 | + unset($json_to_array['featured_image_size']); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | return $json_to_array; |
153 | 153 | } |
154 | 154 | |
155 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2 ); |
|
155 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Give upload the image logo from the core setting data from the json files. |
@@ -164,24 +164,24 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return array $json_to_array |
166 | 166 | */ |
167 | -function give_import_core_settings_merge_upload_image( $json_to_array, $type ) { |
|
168 | - if ( 'merge' === $type ) { |
|
167 | +function give_import_core_settings_merge_upload_image($json_to_array, $type) { |
|
168 | + if ('merge' === $type) { |
|
169 | 169 | // Emails > Email Settings > Logo. |
170 | - if ( ! empty( $json_to_array['email_logo'] ) ) { |
|
170 | + if ( ! empty($json_to_array['email_logo'])) { |
|
171 | 171 | |
172 | 172 | // Need to require these files. |
173 | - if ( ! function_exists( 'media_handle_upload' ) ) { |
|
174 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
175 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
176 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
173 | + if ( ! function_exists('media_handle_upload')) { |
|
174 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
175 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
176 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $url = $json_to_array['email_logo']; |
180 | - $new_url = media_sideload_image( $url, 0, null, 'src' ); |
|
181 | - if ( ! is_wp_error( $new_url ) ) { |
|
180 | + $new_url = media_sideload_image($url, 0, null, 'src'); |
|
181 | + if ( ! is_wp_error($new_url)) { |
|
182 | 182 | $json_to_array['email_logo'] = $new_url; |
183 | 183 | } else { |
184 | - unset( $json_to_array['email_logo'] ); |
|
184 | + unset($json_to_array['email_logo']); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | return $json_to_array; |
190 | 190 | } |
191 | 191 | |
192 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2 ); |
|
192 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2); |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * Give unset the license key from the core setting data from the json files. |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return array $json_to_array |
203 | 203 | */ |
204 | -function give_import_core_settings_merge_license_key( $json_to_array, $type ) { |
|
205 | - if ( 'merge' === $type ) { |
|
206 | - foreach ( $json_to_array as $key => $value ) { |
|
207 | - $is_license_key = strpos( '_license_key', $key ); |
|
208 | - if ( ! empty( $is_license_key ) ) { |
|
209 | - unset( $json_to_array[ $key ] ); |
|
204 | +function give_import_core_settings_merge_license_key($json_to_array, $type) { |
|
205 | + if ('merge' === $type) { |
|
206 | + foreach ($json_to_array as $key => $value) { |
|
207 | + $is_license_key = strpos('_license_key', $key); |
|
208 | + if ( ! empty($is_license_key)) { |
|
209 | + unset($json_to_array[$key]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | return $json_to_array; |
215 | 215 | } |
216 | 216 | |
217 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2 ); |
|
217 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2); |
|
218 | 218 | |
219 | 219 | /** |
220 | 220 | * Give merge the json data and setting data. |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return array $json_to_array |
229 | 229 | */ |
230 | -function give_import_core_settings_merge_data( $json_to_array, $type, $host_give_options ) { |
|
231 | - if ( 'merge' === $type ) { |
|
232 | - $json_to_array_merge = array_merge( $host_give_options, $json_to_array ); |
|
230 | +function give_import_core_settings_merge_data($json_to_array, $type, $host_give_options) { |
|
231 | + if ('merge' === $type) { |
|
232 | + $json_to_array_merge = array_merge($host_give_options, $json_to_array); |
|
233 | 233 | $json_to_array = $json_to_array_merge; |
234 | 234 | } |
235 | 235 | |
236 | 236 | return $json_to_array; |
237 | 237 | } |
238 | 238 | |
239 | -add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3 ); |
|
239 | +add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3); |
|
240 | 240 | |
241 | 241 | /** |
242 | 242 | * Backward Compatibility - Cleanup User Roles. |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return mixed |
249 | 249 | */ |
250 | -function give_bc_1817_cleanup_user_roles( $caps ) { |
|
250 | +function give_bc_1817_cleanup_user_roles($caps) { |
|
251 | 251 | |
252 | 252 | if ( |
253 | - ! give_has_upgrade_completed( 'v1817_cleanup_user_roles' ) && |
|
254 | - ! isset( $caps['view_give_payments'] ) |
|
253 | + ! give_has_upgrade_completed('v1817_cleanup_user_roles') && |
|
254 | + ! isset($caps['view_give_payments']) |
|
255 | 255 | ) { |
256 | 256 | give_v1817_process_cleanup_user_roles(); |
257 | 257 | } |
@@ -259,4 +259,4 @@ discard block |
||
259 | 259 | return $caps; |
260 | 260 | } |
261 | 261 | |
262 | -add_filter( 'user_has_cap', 'give_bc_1817_cleanup_user_roles' ); |
|
262 | +add_filter('user_has_cap', 'give_bc_1817_cleanup_user_roles'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return static |
56 | 56 | */ |
57 | 57 | public static function get_instance() { |
58 | - if ( null === static::$instance ) { |
|
58 | + if (null === static::$instance) { |
|
59 | 59 | self::$instance = new static(); |
60 | 60 | } |
61 | 61 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @access public |
80 | 80 | */ |
81 | 81 | public function setup_hooks() { |
82 | - add_action( 'init', array( $this, 'load_translated_texts' ), 999 ); |
|
82 | + add_action('init', array($this, 'load_translated_texts'), 999); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool|WP_Error false on success otherwise WP_Error object |
112 | 112 | */ |
113 | - public static function add_text( $args = array() ) { |
|
113 | + public static function add_text($args = array()) { |
|
114 | 114 | $error = false; |
115 | 115 | |
116 | 116 | // Set text params. |
@@ -126,43 +126,43 @@ discard block |
||
126 | 126 | |
127 | 127 | try { |
128 | 128 | // Check for errors. |
129 | - if ( empty( $args['text'] ) ) { |
|
129 | + if (empty($args['text'])) { |
|
130 | 130 | /* @var WP_Error $error */ |
131 | - $error = new WP_Error( 'EMPTY_TEXT', __( 'Empty string is not allowed.', 'give' ), $args ); |
|
132 | - throw new Exception( $error->get_error_message( 'EMPTY_TEXT' ) ); |
|
131 | + $error = new WP_Error('EMPTY_TEXT', __('Empty string is not allowed.', 'give'), $args); |
|
132 | + throw new Exception($error->get_error_message('EMPTY_TEXT')); |
|
133 | 133 | |
134 | - } elseif ( empty( $args['id'] ) ) { |
|
134 | + } elseif (empty($args['id'])) { |
|
135 | 135 | /* @var WP_Error $error */ |
136 | - $error = new WP_Error( 'EMPTY_ID', __( 'Empty ID is not allowed.', 'give' ), $args ); |
|
137 | - throw new Exception( $error->get_error_message( 'EMPTY_ID' ) ); |
|
136 | + $error = new WP_Error('EMPTY_ID', __('Empty ID is not allowed.', 'give'), $args); |
|
137 | + throw new Exception($error->get_error_message('EMPTY_ID')); |
|
138 | 138 | |
139 | 139 | } elseif ( |
140 | - empty( $args['group'] ) && |
|
141 | - array_key_exists( $args['id'], self::$text_configs ) |
|
140 | + empty($args['group']) && |
|
141 | + array_key_exists($args['id'], self::$text_configs) |
|
142 | 142 | ) { |
143 | 143 | /* @var WP_Error $error */ |
144 | - $error = new WP_Error( 'TEXT_ID_ALREADY_EXIST', __( 'Text ID without a group already exists.', 'give' ), $args ); |
|
145 | - throw new Exception( $error->get_error_message( 'TEXT_ID_ALREADY_EXIST' ) ); |
|
144 | + $error = new WP_Error('TEXT_ID_ALREADY_EXIST', __('Text ID without a group already exists.', 'give'), $args); |
|
145 | + throw new Exception($error->get_error_message('TEXT_ID_ALREADY_EXIST')); |
|
146 | 146 | |
147 | 147 | } elseif ( |
148 | - ! empty( $args['group'] ) && |
|
149 | - ! empty( self::$text_configs[ $args['group'] ] ) && |
|
150 | - array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) |
|
148 | + ! empty($args['group']) && |
|
149 | + ! empty(self::$text_configs[$args['group']]) && |
|
150 | + array_key_exists($args['id'], self::$text_configs[$args['group']]) |
|
151 | 151 | ) { |
152 | 152 | /* @var WP_Error $error */ |
153 | - $error = new WP_Error( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __( 'Text ID within a group already exists.', 'give' ), $args ); |
|
154 | - throw new Exception( $error->get_error_message( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST' ) ); |
|
153 | + $error = new WP_Error('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __('Text ID within a group already exists.', 'give'), $args); |
|
154 | + throw new Exception($error->get_error_message('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST')); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add text. |
159 | - if ( ! empty( $args['group'] ) ) { |
|
160 | - self::$text_configs[ $args['group'] ][ $args['id'] ] = $args; |
|
159 | + if ( ! empty($args['group'])) { |
|
160 | + self::$text_configs[$args['group']][$args['id']] = $args; |
|
161 | 161 | } else { |
162 | - self::$text_configs[ $args['id'] ] = $args; |
|
162 | + self::$text_configs[$args['id']] = $args; |
|
163 | 163 | } |
164 | - } catch ( Exception $e ) { |
|
165 | - error_log( $e->getMessage() ); |
|
164 | + } catch (Exception $e) { |
|
165 | + error_log($e->getMessage()); |
|
166 | 166 | }// End try(). |
167 | 167 | |
168 | 168 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @since 2.0 |
172 | 172 | */ |
173 | - self::$text_configs = apply_filters( 'give_texts', self::$text_configs ); |
|
173 | + self::$text_configs = apply_filters('give_texts', self::$text_configs); |
|
174 | 174 | |
175 | 175 | return $error; |
176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public static function add_label( $args = array() ) { |
|
188 | + public static function add_label($args = array()) { |
|
189 | 189 | // Set text params. |
190 | 190 | $args = wp_parse_args( |
191 | 191 | $args, |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $args['type'] = 'label'; |
200 | 200 | $args['id'] = "{$args['id']}_label"; |
201 | 201 | |
202 | - return self::add_text( $args ); |
|
202 | + return self::add_text($args); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - public static function add_tooltip( $args = array() ) { |
|
215 | + public static function add_tooltip($args = array()) { |
|
216 | 216 | // Set text params. |
217 | 217 | $args = wp_parse_args( |
218 | 218 | $args, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $args['type'] = 'tooltip'; |
227 | 227 | $args['id'] = "{$args['id']}_tooltip"; |
228 | 228 | |
229 | - return self::add_text( $args ); |
|
229 | + return self::add_text($args); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return string |
241 | 241 | */ |
242 | - public static function add_translation( $args = array() ) { |
|
242 | + public static function add_translation($args = array()) { |
|
243 | 243 | $args = wp_parse_args( |
244 | 244 | $args, |
245 | 245 | array( |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | ); |
251 | 251 | |
252 | 252 | // Bailout. |
253 | - if ( empty( $args['id'] ) ) { |
|
253 | + if (empty($args['id'])) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | - if ( ! empty( $args['group'] ) ) { |
|
258 | - self::$text_translations[ $args['group'] ][ $args['id'] ] = $args['text']; |
|
257 | + if ( ! empty($args['group'])) { |
|
258 | + self::$text_translations[$args['group']][$args['id']] = $args['text']; |
|
259 | 259 | } else { |
260 | - self::$text_translations[ $args['id'] ] = $args['text']; |
|
260 | + self::$text_translations[$args['id']] = $args['text']; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return string |
275 | 275 | */ |
276 | - public static function add_label_translation( $id, $group = '', $text = '' ) { |
|
277 | - return self::get_text( array( |
|
276 | + public static function add_label_translation($id, $group = '', $text = '') { |
|
277 | + return self::get_text(array( |
|
278 | 278 | 'id' => "{$id}_label", |
279 | 279 | 'group' => $group, |
280 | 280 | 'text' => $text, |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return string |
295 | 295 | */ |
296 | - public static function add_tooltip_translation( $id, $group = '', $text = '' ) { |
|
297 | - return self::get_text( array( |
|
296 | + public static function add_tooltip_translation($id, $group = '', $text = '') { |
|
297 | + return self::get_text(array( |
|
298 | 298 | 'id' => "{$id}_label", |
299 | 299 | 'group' => $group, |
300 | 300 | 'text' => $text, |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return string |
314 | 314 | */ |
315 | - public static function get_label( $id, $group = '' ) { |
|
316 | - return self::get_text( array( |
|
315 | + public static function get_label($id, $group = '') { |
|
316 | + return self::get_text(array( |
|
317 | 317 | 'id' => "{$id}_label", |
318 | 318 | 'group' => $group, |
319 | 319 | 'type' => 'label', |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return string |
333 | 333 | */ |
334 | - public static function get_tooltip( $id, $group = '' ) { |
|
335 | - return self::get_text( array( |
|
334 | + public static function get_tooltip($id, $group = '') { |
|
335 | + return self::get_text(array( |
|
336 | 336 | 'id' => "{$id}_tooltip", |
337 | 337 | 'group' => $group, |
338 | 338 | 'type' => 'tooltip', |
339 | - ) ); |
|
339 | + )); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - public static function get_text( $args = array() ) { |
|
352 | + public static function get_text($args = array()) { |
|
353 | 353 | $text = ''; |
354 | 354 | |
355 | 355 | // Bailout. |
356 | - if ( empty( $args ) ) { |
|
356 | + if (empty($args)) { |
|
357 | 357 | return $text; |
358 | 358 | } |
359 | 359 | |
@@ -369,40 +369,40 @@ discard block |
||
369 | 369 | |
370 | 370 | // Check if text exist. |
371 | 371 | if ( |
372 | - empty( $args['id'] ) || |
|
373 | - ( empty( $args['group'] ) && ! array_key_exists( $args['id'], self::$text_configs ) ) || |
|
374 | - ( ! empty( $args['group'] ) && ! empty( self::$text_configs[ $args['group'] ] ) && ! array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) ) |
|
372 | + empty($args['id']) || |
|
373 | + (empty($args['group']) && ! array_key_exists($args['id'], self::$text_configs)) || |
|
374 | + ( ! empty($args['group']) && ! empty(self::$text_configs[$args['group']]) && ! array_key_exists($args['id'], self::$text_configs[$args['group']])) |
|
375 | 375 | ) { |
376 | 376 | return $text; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Get text value. |
380 | 380 | if ( |
381 | - ! empty( $args['group'] ) && |
|
382 | - array_key_exists( $args['group'], self::$text_configs ) |
|
381 | + ! empty($args['group']) && |
|
382 | + array_key_exists($args['group'], self::$text_configs) |
|
383 | 383 | ) { |
384 | - $text = self::$text_configs[ $args['group'] ][ $args['id'] ]['text']; |
|
384 | + $text = self::$text_configs[$args['group']][$args['id']]['text']; |
|
385 | 385 | |
386 | 386 | // Get translated text if exist. |
387 | 387 | if ( |
388 | - ! empty( self::$text_translations ) && |
|
389 | - ! empty( self::$text_translations[ $args['group'] ] ) && |
|
390 | - array_key_exists( $args['id'], self::$text_translations[ $args['group'] ] ) |
|
388 | + ! empty(self::$text_translations) && |
|
389 | + ! empty(self::$text_translations[$args['group']]) && |
|
390 | + array_key_exists($args['id'], self::$text_translations[$args['group']]) |
|
391 | 391 | ) { |
392 | - $text = self::$text_translations[ $args['group'] ][ $args['id'] ]; |
|
392 | + $text = self::$text_translations[$args['group']][$args['id']]; |
|
393 | 393 | } |
394 | 394 | } elseif ( |
395 | - empty( $args['group'] ) && |
|
396 | - array_key_exists( $args['id'], self::$text_configs ) |
|
395 | + empty($args['group']) && |
|
396 | + array_key_exists($args['id'], self::$text_configs) |
|
397 | 397 | ) { |
398 | - $text = self::$text_configs[ $args['id'] ]['text']; |
|
398 | + $text = self::$text_configs[$args['id']]['text']; |
|
399 | 399 | |
400 | 400 | // Get translated text if exist. |
401 | 401 | if ( |
402 | - ! empty( self::$text_translations ) && |
|
403 | - array_key_exists( $args['id'], self::$text_translations ) |
|
402 | + ! empty(self::$text_translations) && |
|
403 | + array_key_exists($args['id'], self::$text_translations) |
|
404 | 404 | ) { |
405 | - $text = self::$text_translations[ $args['id'] ]; |
|
405 | + $text = self::$text_translations[$args['id']]; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @since 2.0 |
413 | 413 | */ |
414 | - $text = apply_filters( 'give_text', $text, $args, self::$text_configs, self::$text_translations ); |
|
414 | + $text = apply_filters('give_text', $text, $args, self::$text_configs, self::$text_translations); |
|
415 | 415 | |
416 | 416 | return $text; |
417 | 417 | } |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /* @var WPDB $wpdb */ |
36 | 36 | global $wpdb; |
37 | 37 | |
38 | - $this->table_name = $wpdb->prefix . 'give_sequential_ordering'; |
|
38 | + $this->table_name = $wpdb->prefix.'give_sequential_ordering'; |
|
39 | 39 | $this->primary_key = 'id'; |
40 | 40 | $this->version = '1.0'; |
41 | 41 | |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | PRIMARY KEY (id) |
109 | 109 | ) {$charset_collate};"; |
110 | 110 | |
111 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
112 | - dbDelta( $sql ); |
|
111 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
112 | + dbDelta($sql); |
|
113 | 113 | |
114 | - if ( ! empty( $payment_ID ) ) { |
|
114 | + if ( ! empty($payment_ID)) { |
|
115 | 115 | $auto_increment = $payment_ID + 1; |
116 | - $wpdb->query( "ALTER TABLE {$this->table_name} AUTO_INCREMENT={$auto_increment};" ); |
|
117 | - give_update_option( 'sequential-ordering_number', $auto_increment ); |
|
116 | + $wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$auto_increment};"); |
|
117 | + give_update_option('sequential-ordering_number', $auto_increment); |
|
118 | 118 | } else { |
119 | - give_update_option( 'sequential-ordering_number', 1 ); |
|
119 | + give_update_option('sequential-ordering_number', 1); |
|
120 | 120 | } |
121 | 121 | |
122 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
122 | + update_option($this->table_name.'_db_version', $this->version); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 |
@@ -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 | |
@@ -62,51 +62,51 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return bool If the gravatar exists or not |
64 | 64 | */ |
65 | - public function validate_gravatar( $id_or_email ) { |
|
65 | + public function validate_gravatar($id_or_email) { |
|
66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
67 | 67 | $email = ''; |
68 | - if ( is_numeric( $id_or_email ) ) { |
|
68 | + if (is_numeric($id_or_email)) { |
|
69 | 69 | $id = (int) $id_or_email; |
70 | - $user = get_userdata( $id ); |
|
71 | - if ( $user ) { |
|
70 | + $user = get_userdata($id); |
|
71 | + if ($user) { |
|
72 | 72 | $email = $user->user_email; |
73 | 73 | } |
74 | - } elseif ( is_object( $id_or_email ) ) { |
|
74 | + } elseif (is_object($id_or_email)) { |
|
75 | 75 | // No avatar for pingbacks or trackbacks |
76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
81 | + if ( ! empty($id_or_email->user_id)) { |
|
82 | 82 | $id = (int) $id_or_email->user_id; |
83 | - $user = get_userdata( $id ); |
|
84 | - if ( $user ) { |
|
83 | + $user = get_userdata($id); |
|
84 | + if ($user) { |
|
85 | 85 | $email = $user->user_email; |
86 | 86 | } |
87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
88 | 88 | $email = $id_or_email->comment_author_email; |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | $email = $id_or_email; |
92 | 92 | } |
93 | 93 | |
94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
94 | + $hashkey = md5(strtolower(trim($email))); |
|
95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
96 | 96 | |
97 | - $data = Give_Cache::get_group( $hashkey ); |
|
97 | + $data = Give_Cache::get_group($hashkey); |
|
98 | 98 | |
99 | - if ( is_null( $data ) ) { |
|
100 | - $response = wp_remote_head( $uri ); |
|
101 | - if ( is_wp_error( $response ) ) { |
|
99 | + if (is_null($data)) { |
|
100 | + $response = wp_remote_head($uri); |
|
101 | + if (is_wp_error($response)) { |
|
102 | 102 | $data = 'not200'; |
103 | 103 | } else { |
104 | 104 | $data = $response['response']['code']; |
105 | 105 | } |
106 | - Give_Cache::set_group( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
106 | + Give_Cache::set_group($hashkey, $data, $group = '', $expire = 60 * 5); |
|
107 | 107 | |
108 | 108 | } |
109 | - if ( $data == '200' ) { |
|
109 | + if ($data == '200') { |
|
110 | 110 | return true; |
111 | 111 | } else { |
112 | 112 | return false; |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array IDs if logs, false otherwise |
125 | 125 | */ |
126 | - public function get_log_ids( $form_id = '' ) { |
|
126 | + public function get_log_ids($form_id = '') { |
|
127 | 127 | // get log for this form |
128 | - $logs = Give()->logs->get_logs( $form_id ); |
|
128 | + $logs = Give()->logs->get_logs($form_id); |
|
129 | 129 | |
130 | - if ( $logs ) { |
|
130 | + if ($logs) { |
|
131 | 131 | $log_ids = array(); |
132 | 132 | |
133 | 133 | // make an array with all the donor IDs |
134 | - foreach ( $logs as $log ) { |
|
134 | + foreach ($logs as $log) { |
|
135 | 135 | $log_ids[] = $log->ID; |
136 | 136 | } |
137 | 137 | |
@@ -152,51 +152,51 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return mixed |
154 | 154 | */ |
155 | - public function get_payment_ids( $form_id = '' ) { |
|
155 | + public function get_payment_ids($form_id = '') { |
|
156 | 156 | |
157 | 157 | $give_options = give_get_settings(); |
158 | 158 | |
159 | - $log_ids = $this->get_log_ids( $form_id ); |
|
159 | + $log_ids = $this->get_log_ids($form_id); |
|
160 | 160 | |
161 | - if ( $log_ids ) { |
|
161 | + if ($log_ids) { |
|
162 | 162 | |
163 | 163 | $payment_ids = array(); |
164 | 164 | |
165 | - foreach ( $log_ids as $id ) { |
|
165 | + foreach ($log_ids as $id) { |
|
166 | 166 | // get the payment ID for each corresponding log ID |
167 | - $payment_ids[] = give_get_meta( $id, '_give_log_payment_id', true ); |
|
167 | + $payment_ids[] = give_get_meta($id, '_give_log_payment_id', true); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // remove donors who have donated more than once so we can have unique avatars |
171 | 171 | $unique_emails = array(); |
172 | 172 | |
173 | - foreach ( $payment_ids as $key => $id ) { |
|
173 | + foreach ($payment_ids as $key => $id) { |
|
174 | 174 | |
175 | - $email = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
175 | + $email = give_get_meta($id, '_give_payment_donor_email', true); |
|
176 | 176 | |
177 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
178 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
177 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
178 | + if ( ! $this->validate_gravatar($email)) { |
|
179 | 179 | continue; |
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - $unique_emails[ $id ] = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
183 | + $unique_emails[$id] = give_get_meta($id, '_give_payment_donor_email', true); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | |
187 | 187 | $unique_ids = array(); |
188 | 188 | |
189 | 189 | // strip duplicate emails |
190 | - $unique_emails = array_unique( $unique_emails ); |
|
190 | + $unique_emails = array_unique($unique_emails); |
|
191 | 191 | |
192 | 192 | // convert the unique IDs back into simple array |
193 | - foreach ( $unique_emails as $id => $email ) { |
|
193 | + foreach ($unique_emails as $id => $email) { |
|
194 | 194 | $unique_ids[] = $id; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // randomize the payment IDs if enabled |
198 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
199 | - shuffle( $unique_ids ); |
|
198 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
199 | + shuffle($unique_ids); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // return our unique IDs |
@@ -217,22 +217,22 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function gravatars( $form_id = false, $title = '' ) { |
|
220 | + public function gravatars($form_id = false, $title = '') { |
|
221 | 221 | |
222 | 222 | // unique $payment_ids |
223 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
223 | + $payment_ids = $this->get_payment_ids($form_id); |
|
224 | 224 | |
225 | 225 | $give_options = give_get_settings(); |
226 | 226 | |
227 | 227 | // return if no ID |
228 | - if ( ! $form_id ) { |
|
228 | + if ( ! $form_id) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // minimum amount of donations before showing gravatars |
233 | 233 | // if the number of items in array is not greater or equal to the number specified, then exit |
234 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
235 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
234 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
235 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | 238 | } |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | echo '<div id="give-purchase-gravatars">'; |
244 | 244 | |
245 | 245 | |
246 | - if ( isset ( $title ) ) { |
|
246 | + if (isset ($title)) { |
|
247 | 247 | |
248 | - if ( $title ) { |
|
249 | - echo wp_kses_post( apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ) ); |
|
250 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
251 | - echo wp_kses_post( apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ) ); |
|
248 | + if ($title) { |
|
249 | + echo wp_kses_post(apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>')); |
|
250 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
251 | + echo wp_kses_post(apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>')); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
255 | 255 | echo '<ul class="give-purchase-gravatars-list">'; |
256 | 256 | $i = 0; |
257 | 257 | |
258 | - if ( $payment_ids ) { |
|
259 | - foreach ( $payment_ids as $id ) { |
|
258 | + if ($payment_ids) { |
|
259 | + foreach ($payment_ids as $id) { |
|
260 | 260 | |
261 | 261 | // Give saves a blank option even when the control is turned off, hence the extra check |
262 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
262 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
263 | 263 | continue; |
264 | 264 | } |
265 | 265 | |
266 | 266 | // get the payment meta |
267 | - $payment_meta = give_get_meta( $id, '_give_payment_meta', true ); |
|
267 | + $payment_meta = give_get_meta($id, '_give_payment_meta', true); |
|
268 | 268 | |
269 | 269 | $user_info = $payment_meta['user_info']; |
270 | 270 | |
@@ -272,30 +272,30 @@ discard block |
||
272 | 272 | $name = $user_info['first_name']; |
273 | 273 | |
274 | 274 | // get donor's email |
275 | - $email = give_get_meta( $id, '_give_payment_donor_email', true ); |
|
275 | + $email = give_get_meta($id, '_give_payment_donor_email', true); |
|
276 | 276 | |
277 | 277 | // set gravatar size and provide filter |
278 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
278 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
279 | 279 | |
280 | 280 | // default image |
281 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
281 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
282 | 282 | |
283 | 283 | // assemble output |
284 | 284 | $output .= '<li>'; |
285 | 285 | |
286 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
286 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
287 | 287 | $output .= '</li>'; |
288 | 288 | |
289 | - $i ++; |
|
289 | + $i++; |
|
290 | 290 | |
291 | 291 | } // end foreach |
292 | 292 | } |
293 | 293 | |
294 | - echo wp_kses_post( $output ); |
|
294 | + echo wp_kses_post($output); |
|
295 | 295 | echo '</ul>'; |
296 | 296 | echo '</div>'; |
297 | 297 | |
298 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
298 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @return void |
308 | 308 | */ |
309 | 309 | public function register_widget() { |
310 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
310 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @return string |
323 | 323 | */ |
324 | - public function shortcode( $atts, $content = null ) { |
|
324 | + public function shortcode($atts, $content = null) { |
|
325 | 325 | |
326 | - $atts = shortcode_atts( array( |
|
326 | + $atts = shortcode_atts(array( |
|
327 | 327 | 'id' => '', |
328 | 328 | 'title' => '' |
329 | - ), $atts, 'give_donors_gravatars' ); |
|
329 | + ), $atts, 'give_donors_gravatars'); |
|
330 | 330 | |
331 | 331 | // if no ID is passed on single give_forms pages, get the correct ID |
332 | - if ( is_singular( 'give_forms' ) ) { |
|
332 | + if (is_singular('give_forms')) { |
|
333 | 333 | $id = get_the_ID(); |
334 | 334 | } |
335 | 335 | |
336 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
336 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
337 | 337 | |
338 | 338 | return $content; |
339 | 339 | |
@@ -349,56 +349,56 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return array Gravatar settings. |
351 | 351 | */ |
352 | - public function settings( $settings ) { |
|
352 | + public function settings($settings) { |
|
353 | 353 | |
354 | 354 | $give_gravatar_settings = array( |
355 | 355 | array( |
356 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
356 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
357 | 357 | 'desc' => '<hr>', |
358 | 358 | 'id' => 'give_title', |
359 | 359 | 'type' => 'give_title' |
360 | 360 | ), |
361 | 361 | array( |
362 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
363 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
362 | + 'name' => esc_html__('Heading', 'give'), |
|
363 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
364 | 364 | 'type' => 'text', |
365 | 365 | 'id' => 'give_donors_gravatars_heading' |
366 | 366 | ), |
367 | 367 | array( |
368 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
369 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
368 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
369 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
370 | 370 | 'type' => 'text_small', |
371 | 371 | 'id' => 'give_donors_gravatars_gravatar_size', |
372 | 372 | 'default' => '64' |
373 | 373 | ), |
374 | 374 | array( |
375 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
376 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
375 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
376 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
377 | 377 | 'type' => 'text_small', |
378 | 378 | 'id' => 'give_donors_gravatars_min_purchases_required', |
379 | 379 | ), |
380 | 380 | array( |
381 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
382 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
381 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
382 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
383 | 383 | 'type' => 'text', |
384 | 384 | 'id' => 'give_donors_gravatars_maximum_number', |
385 | 385 | 'default' => '20', |
386 | 386 | ), |
387 | 387 | array( |
388 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
389 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
388 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
389 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
390 | 390 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
391 | 391 | 'type' => 'checkbox', |
392 | 392 | ), |
393 | 393 | array( |
394 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
395 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
394 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
395 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
396 | 396 | 'id' => 'give_donors_gravatars_random_gravatars', |
397 | 397 | 'type' => 'checkbox', |
398 | 398 | ), |
399 | 399 | ); |
400 | 400 | |
401 | - return array_merge( $settings, $give_gravatar_settings ); |
|
401 | + return array_merge($settings, $give_gravatar_settings); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | // widget settings |
425 | 425 | $widget_ops = array( |
426 | 426 | 'classname' => 'give-donors-gravatars', |
427 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
427 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
428 | 428 | ); |
429 | 429 | |
430 | 430 | // widget control settings |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | // create the widget |
438 | 438 | parent::__construct( |
439 | 439 | 'give_donors_gravatars_widget', |
440 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
440 | + esc_html__('Give Donors Gravatars', 'give'), |
|
441 | 441 | $widget_ops, |
442 | 442 | $control_ops |
443 | 443 | ); |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @return void |
459 | 459 | */ |
460 | - public function widget( $args, $instance ) { |
|
460 | + public function widget($args, $instance) { |
|
461 | 461 | |
462 | 462 | $defaults = array( |
463 | 463 | 'before_widget' => '', |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | 'after_title' => '', |
467 | 467 | ); |
468 | 468 | |
469 | - $args = wp_parse_args( $args, $defaults ); |
|
469 | + $args = wp_parse_args($args, $defaults); |
|
470 | 470 | |
471 | - if ( ! is_singular( 'give_forms' ) ) { |
|
471 | + if ( ! is_singular('give_forms')) { |
|
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | 475 | // Variables from widget settings |
476 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
476 | + $title = apply_filters('widget_title', $instance['title']); |
|
477 | 477 | |
478 | 478 | $output = ''; |
479 | 479 | |
@@ -481,18 +481,18 @@ discard block |
||
481 | 481 | $output .= $args['before_widget']; |
482 | 482 | |
483 | 483 | // Display the widget title |
484 | - if ( $title ) { |
|
485 | - $output .= $args['before_title'] . $title . $args['after_title']; |
|
484 | + if ($title) { |
|
485 | + $output .= $args['before_title'].$title.$args['after_title']; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $gravatars = new Give_Donors_Gravatars(); |
489 | 489 | |
490 | - $output .= $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
490 | + $output .= $gravatars->gravatars(get_the_ID(), null); // remove title |
|
491 | 491 | |
492 | 492 | // Used by themes. Closes the widget |
493 | 493 | $output .= $args['after_widget']; |
494 | 494 | |
495 | - echo wp_kses_post( $output ); |
|
495 | + echo wp_kses_post($output); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -508,11 +508,11 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return array Updated settings to save. |
510 | 510 | */ |
511 | - public function update( $new_instance, $old_instance ) { |
|
511 | + public function update($new_instance, $old_instance) { |
|
512 | 512 | |
513 | 513 | $instance = $old_instance; |
514 | 514 | |
515 | - $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); |
|
515 | + $instance['title'] = wp_strip_all_tags($new_instance['title']); |
|
516 | 516 | |
517 | 517 | return $instance; |
518 | 518 | |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return void |
532 | 532 | */ |
533 | - public function form( $instance ) { |
|
533 | + public function form($instance) { |
|
534 | 534 | |
535 | 535 | // Set up some default widget settings. |
536 | 536 | $defaults = array( |
537 | 537 | 'title' => '', |
538 | 538 | ); |
539 | 539 | |
540 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
540 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
541 | 541 | |
542 | 542 | <!-- Title --> |
543 | 543 | <p> |
544 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
545 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
544 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
545 | + <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" /> |
|
546 | 546 | </p> |
547 | 547 | |
548 | 548 | <?php |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -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, $payment_id ); |
|
83 | - give_increase_donation_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount, $payment_id); |
|
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,14 +216,14 @@ 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 | 221 | /* @var Give_Payment $payment */ |
222 | - foreach ( $payments as $payment ) { |
|
223 | - $gateway = give_get_payment_gateway( $payment->ID ); |
|
222 | + foreach ($payments as $payment) { |
|
223 | + $gateway = give_get_payment_gateway($payment->ID); |
|
224 | 224 | |
225 | 225 | // Skip payment gateways. |
226 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
226 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
227 | 227 | continue; |
228 | 228 | } |
229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
236 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
237 | 237 | |
238 | 238 | |
239 | 239 | /** |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return void |
247 | 247 | */ |
248 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
248 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
249 | 249 | // Monthly stats. |
250 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
250 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
251 | 251 | |
252 | 252 | // @todo: Refresh only range related stat cache |
253 | 253 | give_delete_donation_stats(); |
254 | 254 | } |
255 | 255 | |
256 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
256 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | /** |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return array |
271 | 271 | */ |
272 | -function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) { |
|
272 | +function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) { |
|
273 | 273 | // Bailout. |
274 | 274 | if ( |
275 | - 'give_payment' !== get_post_type( $object_id ) || |
|
275 | + 'give_payment' !== get_post_type($object_id) || |
|
276 | 276 | '_give_payment_meta' !== $meta_key || |
277 | - ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) |
|
277 | + ! give_has_upgrade_completed('v20_upgrades_payment_metadata') |
|
278 | 278 | ) { |
279 | 279 | return $check; |
280 | 280 | } |
@@ -282,73 +282,69 @@ discard block |
||
282 | 282 | $cache_key = "_give_payment_meta_{$object_id}"; |
283 | 283 | |
284 | 284 | // Get already calculate payment meta from cache. |
285 | - $payment_meta = Give_Cache::get_db_query( $cache_key ); |
|
285 | + $payment_meta = Give_Cache::get_db_query($cache_key); |
|
286 | 286 | |
287 | - if ( is_null( $payment_meta ) ) { |
|
287 | + if (is_null($payment_meta)) { |
|
288 | 288 | // Remove filter. |
289 | - remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 ); |
|
289 | + remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999); |
|
290 | 290 | |
291 | - $donation = new Give_Payment( $object_id ); |
|
291 | + $donation = new Give_Payment($object_id); |
|
292 | 292 | |
293 | 293 | // Get all payment meta. |
294 | - $payment_meta = give_get_meta( $object_id ); |
|
294 | + $payment_meta = give_get_meta($object_id); |
|
295 | 295 | |
296 | 296 | // Set default value to array. |
297 | - if ( empty( $payment_meta ) ) { |
|
297 | + if (empty($payment_meta)) { |
|
298 | 298 | return $check; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Convert all meta key value to string instead of array |
302 | - array_walk( $payment_meta, function ( &$meta, $key ) { |
|
303 | - $meta = current( $meta ); |
|
302 | + array_walk($payment_meta, function(&$meta, $key) { |
|
303 | + $meta = current($meta); |
|
304 | 304 | } ); |
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Add backward compatibility to old meta keys. |
308 | 308 | */ |
309 | 309 | // Donation key. |
310 | - $payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
310 | + $payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : ''; |
|
311 | 311 | |
312 | 312 | // Donation form. |
313 | - $payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : ''; |
|
313 | + $payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : ''; |
|
314 | 314 | |
315 | 315 | // Donor email. |
316 | - $payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | - $payment_meta['email'] = ! empty( $payment_meta['email'] ) ? |
|
318 | - $payment_meta['email'] : |
|
319 | - Give()->donors->get_column( 'email', $donation->donor_id ); |
|
316 | + $payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : ''; |
|
317 | + $payment_meta['email'] = ! empty($payment_meta['email']) ? |
|
318 | + $payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id); |
|
320 | 319 | |
321 | 320 | // Form id. |
322 | - $payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : ''; |
|
321 | + $payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : ''; |
|
323 | 322 | |
324 | 323 | // Price id. |
325 | - $payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : ''; |
|
324 | + $payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : ''; |
|
326 | 325 | |
327 | 326 | // Date. |
328 | - $payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : ''; |
|
329 | - $payment_meta['date'] = ! empty( $payment_meta['date'] ) ? |
|
330 | - $payment_meta['date'] : |
|
331 | - get_post_field( 'post_date', $object_id ); |
|
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'] : get_post_field('post_date', $object_id); |
|
332 | 330 | |
333 | 331 | |
334 | 332 | // Currency. |
335 | - $payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : ''; |
|
333 | + $payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : ''; |
|
336 | 334 | |
337 | 335 | // Decode donor data. |
338 | - $donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
339 | - $donor = new Give_Donor( $donor_id ); |
|
336 | + $donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0; |
|
337 | + $donor = new Give_Donor($donor_id); |
|
340 | 338 | |
341 | 339 | // Donor first name. |
342 | - $donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
343 | - $donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ? |
|
344 | - $donor_data['first_name'] : |
|
345 | - $donor->get_first_name(); |
|
340 | + $donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : ''; |
|
341 | + $donor_data['first_name'] = ! empty($donor_data['first_name']) ? |
|
342 | + $donor_data['first_name'] : $donor->get_first_name(); |
|
346 | 343 | |
347 | 344 | // Donor last name. |
348 | - $donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
349 | - $donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ? |
|
350 | - $donor_data['last_name'] : |
|
351 | - $donor->get_last_name(); |
|
345 | + $donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : ''; |
|
346 | + $donor_data['last_name'] = ! empty($donor_data['last_name']) ? |
|
347 | + $donor_data['last_name'] : $donor->get_last_name(); |
|
352 | 348 | |
353 | 349 | // Donor email. |
354 | 350 | $donor_data['email'] = $payment_meta['email']; |
@@ -359,63 +355,63 @@ discard block |
||
359 | 355 | $donor_data['address'] = false; |
360 | 356 | |
361 | 357 | // Address1. |
362 | - $address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
363 | - if ( $address1 ) { |
|
358 | + $address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : ''; |
|
359 | + if ($address1) { |
|
364 | 360 | $donor_data['address']['line1'] = $address1; |
365 | 361 | } |
366 | 362 | |
367 | 363 | // Address2. |
368 | - $address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
369 | - if ( $address2 ) { |
|
364 | + $address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : ''; |
|
365 | + if ($address2) { |
|
370 | 366 | $donor_data['address']['line2'] = $address2; |
371 | 367 | } |
372 | 368 | |
373 | 369 | // City. |
374 | - $city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
375 | - if ( $city ) { |
|
370 | + $city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : ''; |
|
371 | + if ($city) { |
|
376 | 372 | $donor_data['address']['city'] = $city; |
377 | 373 | } |
378 | 374 | |
379 | 375 | // Zip. |
380 | - $zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
381 | - if ( $zip ) { |
|
376 | + $zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : ''; |
|
377 | + if ($zip) { |
|
382 | 378 | $donor_data['address']['zip'] = $zip; |
383 | 379 | } |
384 | 380 | |
385 | 381 | // State. |
386 | - $state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
387 | - if ( $state ) { |
|
382 | + $state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : ''; |
|
383 | + if ($state) { |
|
388 | 384 | $donor_data['address']['state'] = $state; |
389 | 385 | } |
390 | 386 | |
391 | 387 | // Country. |
392 | - $country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
393 | - if ( $country ) { |
|
388 | + $country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : ''; |
|
389 | + if ($country) { |
|
394 | 390 | $donor_data['address']['country'] = $country; |
395 | 391 | } |
396 | 392 | |
397 | 393 | $payment_meta['user_info'] = $donor_data; |
398 | 394 | |
399 | 395 | // Add filter |
400 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
396 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
401 | 397 | |
402 | 398 | // Set custom meta key into payment meta. |
403 | - if ( ! empty( $payment_meta['_give_payment_meta'] ) ) { |
|
404 | - $payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta ); |
|
399 | + if ( ! empty($payment_meta['_give_payment_meta'])) { |
|
400 | + $payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta); |
|
405 | 401 | } |
406 | 402 | |
407 | 403 | // Set cache. |
408 | - Give_Cache::set_db_query( $cache_key, $payment_meta ); |
|
404 | + Give_Cache::set_db_query($cache_key, $payment_meta); |
|
409 | 405 | } |
410 | 406 | |
411 | - if ( $single ) { |
|
407 | + if ($single) { |
|
412 | 408 | /** |
413 | 409 | * Filter the payment meta |
414 | 410 | * Add custom meta key to payment meta |
415 | 411 | * |
416 | 412 | * @since 2.0 |
417 | 413 | */ |
418 | - $new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key ); |
|
414 | + $new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key); |
|
419 | 415 | |
420 | 416 | $payment_meta = $new_payment_meta; |
421 | 417 | } |
@@ -423,7 +419,7 @@ discard block |
||
423 | 419 | return $payment_meta; |
424 | 420 | } |
425 | 421 | |
426 | -add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
422 | +add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
427 | 423 | |
428 | 424 | /** |
429 | 425 | * Add meta in payment that store page id and page url. |
@@ -435,19 +431,19 @@ discard block |
||
435 | 431 | * |
436 | 432 | * @param int $payment_id Payment id for which the meta value should be updated. |
437 | 433 | */ |
438 | -function give_payment_save_page_data( $payment_id ) { |
|
439 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
434 | +function give_payment_save_page_data($payment_id) { |
|
435 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
440 | 436 | |
441 | 437 | // Check $page_url is not empty. |
442 | - if ( $page_url ) { |
|
443 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
444 | - $page_id = url_to_postid( $page_url ); |
|
438 | + if ($page_url) { |
|
439 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
440 | + $page_id = url_to_postid($page_url); |
|
445 | 441 | // Check $page_id is not empty. |
446 | - if ( $page_id ) { |
|
447 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
442 | + if ($page_id) { |
|
443 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
448 | 444 | } |
449 | 445 | } |
450 | 446 | } |
451 | 447 | |
452 | 448 | // Fire when payment is save. |
453 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
454 | 449 | \ No newline at end of file |
450 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
455 | 451 | \ 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 | |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => __( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => __( 'PayPal', 'give' ), |
|
27 | + 'admin_label' => __('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => __('PayPal', 'give'), |
|
29 | 29 | ), |
30 | 30 | 'manual' => array( |
31 | - 'admin_label' => __( 'Test Donation', 'give' ), |
|
32 | - 'checkout_label' => __( 'Test Donation', 'give' ) |
|
31 | + 'admin_label' => __('Test Donation', 'give'), |
|
32 | + 'checkout_label' => __('Test Donation', 'give') |
|
33 | 33 | ), |
34 | 34 | ); |
35 | 35 | |
36 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
36 | + return apply_filters('give_payment_gateways', $gateways); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array $gateway_list All the available gateways |
48 | 48 | */ |
49 | -function give_get_enabled_payment_gateways( $form_id = 0 ) { |
|
49 | +function give_get_enabled_payment_gateways($form_id = 0) { |
|
50 | 50 | |
51 | 51 | $gateways = give_get_payment_gateways(); |
52 | 52 | |
53 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
53 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
54 | 54 | |
55 | 55 | $gateway_list = array(); |
56 | 56 | |
57 | - foreach ( $gateways as $key => $gateway ) { |
|
58 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
59 | - $gateway_list[ $key ] = $gateway; |
|
57 | + foreach ($gateways as $key => $gateway) { |
|
58 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
59 | + $gateway_list[$key] = $gateway; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Set order of payment gateway in list. |
64 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
64 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
65 | 65 | |
66 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id ); |
|
66 | + return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return boolean true if enabled, false otherwise |
77 | 77 | */ |
78 | -function give_is_gateway_active( $gateway ) { |
|
78 | +function give_is_gateway_active($gateway) { |
|
79 | 79 | $gateways = give_get_enabled_payment_gateways(); |
80 | 80 | |
81 | - $ret = array_key_exists( $gateway, $gateways ); |
|
81 | + $ret = array_key_exists($gateway, $gateways); |
|
82 | 82 | |
83 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
83 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string Gateway ID |
94 | 94 | */ |
95 | -function give_get_default_gateway( $form_id ) { |
|
95 | +function give_get_default_gateway($form_id) { |
|
96 | 96 | |
97 | - $enabled_gateways = array_keys( give_get_enabled_payment_gateways() ); |
|
97 | + $enabled_gateways = array_keys(give_get_enabled_payment_gateways()); |
|
98 | 98 | $default_gateway = give_get_option('default_gateway'); |
99 | - $default = ! empty( $default_gateway ) && give_is_gateway_active( $default_gateway ) ? $default_gateway : $enabled_gateways[0]; |
|
100 | - $form_default = give_get_meta( $form_id, '_give_default_gateway', true ); |
|
99 | + $default = ! empty($default_gateway) && give_is_gateway_active($default_gateway) ? $default_gateway : $enabled_gateways[0]; |
|
100 | + $form_default = give_get_meta($form_id, '_give_default_gateway', true); |
|
101 | 101 | |
102 | 102 | // Single Form settings varies compared to the Global default settings. |
103 | 103 | if ( |
104 | - ! empty( $form_default ) && |
|
104 | + ! empty($form_default) && |
|
105 | 105 | $form_id !== null && |
106 | 106 | $default !== $form_default && |
107 | 107 | 'global' !== $form_default && |
108 | - give_is_gateway_active( $form_default ) |
|
108 | + give_is_gateway_active($form_default) |
|
109 | 109 | ) { |
110 | 110 | $default = $form_default; |
111 | 111 | } |
112 | 112 | |
113 | - return apply_filters( 'give_default_gateway', $default ); |
|
113 | + return apply_filters('give_default_gateway', $default); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return string Gateway admin label |
124 | 124 | */ |
125 | -function give_get_gateway_admin_label( $gateway ) { |
|
125 | +function give_get_gateway_admin_label($gateway) { |
|
126 | 126 | $gateways = give_get_payment_gateways(); |
127 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
127 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
128 | 128 | |
129 | - if ( $gateway == 'manual' ) { |
|
130 | - $label = __( 'Test Donation', 'give' ); |
|
129 | + if ($gateway == 'manual') { |
|
130 | + $label = __('Test Donation', 'give'); |
|
131 | 131 | } |
132 | 132 | |
133 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
133 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string Checkout label for the gateway |
144 | 144 | */ |
145 | -function give_get_gateway_checkout_label( $gateway ) { |
|
145 | +function give_get_gateway_checkout_label($gateway) { |
|
146 | 146 | $gateways = give_get_payment_gateways(); |
147 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
147 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
148 | 148 | |
149 | - if ( $gateway == 'manual' ) { |
|
150 | - $label = __( 'Test Donation', 'give' ); |
|
149 | + if ($gateway == 'manual') { |
|
150 | + $label = __('Test Donation', 'give'); |
|
151 | 151 | } |
152 | 152 | |
153 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
153 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return array Options the gateway supports |
164 | 164 | */ |
165 | -function give_get_gateway_supports( $gateway ) { |
|
165 | +function give_get_gateway_supports($gateway) { |
|
166 | 166 | $gateways = give_get_enabled_payment_gateways(); |
167 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
167 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
168 | 168 | |
169 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
169 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return void |
181 | 181 | */ |
182 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
182 | +function give_send_to_gateway($gateway, $payment_data) { |
|
183 | 183 | |
184 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
184 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Fires while loading payment gateway via AJAX. |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @param array $payment_data All the payment data to be sent to the gateway. |
194 | 194 | */ |
195 | - do_action( "give_gateway_{$gateway}", $payment_data ); |
|
195 | + do_action("give_gateway_{$gateway}", $payment_data); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return string $enabled_gateway The slug of the gateway |
208 | 208 | */ |
209 | -function give_get_chosen_gateway( $form_id ) { |
|
209 | +function give_get_chosen_gateway($form_id) { |
|
210 | 210 | |
211 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
211 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
212 | 212 | |
213 | 213 | // Back to check if 'form-id' is present. |
214 | - if ( empty( $request_form_id ) ) { |
|
215 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
214 | + if (empty($request_form_id)) { |
|
215 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
216 | 216 | } |
217 | 217 | |
218 | - $request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
218 | + $request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
219 | 219 | $chosen = false; |
220 | 220 | |
221 | 221 | // If both 'payment-mode' and 'form-id' then set for only this form. |
222 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
222 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
223 | 223 | $chosen = $request_payment_mode; |
224 | - } elseif ( empty( $request_form_id ) && $request_payment_mode ) { |
|
224 | + } elseif (empty($request_form_id) && $request_payment_mode) { |
|
225 | 225 | // If no 'form-id' but there is 'payment-mode'. |
226 | 226 | $chosen = $request_payment_mode; |
227 | 227 | } |
228 | 228 | |
229 | 229 | // Get the enable gateway based of chosen var. |
230 | - if ( $chosen && give_is_gateway_active( $chosen ) ) { |
|
231 | - $enabled_gateway = urldecode( $chosen ); |
|
230 | + if ($chosen && give_is_gateway_active($chosen)) { |
|
231 | + $enabled_gateway = urldecode($chosen); |
|
232 | 232 | } else { |
233 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
233 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
234 | 234 | } |
235 | 235 | |
236 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
236 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
237 | 237 | |
238 | 238 | } |
239 | 239 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return int ID of the new log entry. |
254 | 254 | */ |
255 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
256 | - return Give()->logs->add( $title, $message, $parent, $type ); |
|
255 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
256 | + return Give()->logs->add($title, $message, $parent, $type); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return int ID of the new log entry |
272 | 272 | */ |
273 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
274 | - $title = empty( $title ) ? esc_html__( 'Payment Error', 'give' ) : $title; |
|
273 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
274 | + $title = empty($title) ? esc_html__('Payment Error', 'give') : $title; |
|
275 | 275 | |
276 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
276 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return int |
288 | 288 | */ |
289 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
289 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
290 | 290 | |
291 | 291 | $ret = 0; |
292 | 292 | $args = array( |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | 'fields' => 'ids', |
299 | 299 | ); |
300 | 300 | |
301 | - $payments = new WP_Query( $args ); |
|
301 | + $payments = new WP_Query($args); |
|
302 | 302 | |
303 | - if ( $payments ) { |
|
303 | + if ($payments) { |
|
304 | 304 | $ret = $payments->post_count; |
305 | 305 | } |
306 | 306 | |
@@ -317,27 +317,27 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array $gateways All the available gateways |
319 | 319 | */ |
320 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
320 | +function give_get_ordered_payment_gateways($gateways) { |
|
321 | 321 | |
322 | 322 | // Get gateways setting. |
323 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
323 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
324 | 324 | |
325 | 325 | // Return from here if we do not have gateways setting. |
326 | - if ( empty( $gateways_setting ) ) { |
|
326 | + if (empty($gateways_setting)) { |
|
327 | 327 | return $gateways; |
328 | 328 | } |
329 | 329 | |
330 | 330 | // Reverse array to order payment gateways. |
331 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
331 | + $gateways_setting = array_reverse($gateways_setting); |
|
332 | 332 | |
333 | 333 | // Reorder gateways array |
334 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
334 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
335 | 335 | |
336 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
337 | - unset( $gateways[ $gateway_key ] ); |
|
336 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
337 | + unset($gateways[$gateway_key]); |
|
338 | 338 | |
339 | - if ( ! empty( $new_gateway_value ) ) { |
|
340 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
339 | + if ( ! empty($new_gateway_value)) { |
|
340 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -348,5 +348,5 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @param array $gateways All the available gateways |
350 | 350 | */ |
351 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
351 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
352 | 352 | } |
353 | 353 | \ No newline at end of file |