@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | * Admin View: Import Core Settings |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if ( ! defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
10 | -if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
10 | +if ( ! current_user_can('manage_give_settings')) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @since 1.8.17 |
18 | 18 | */ |
19 | -do_action( 'give_tools_import_core_settings_main_before' ); |
|
19 | +do_action('give_tools_import_core_settings_main_before'); |
|
20 | 20 | ?> |
21 | 21 | <div id="poststuff"> |
22 | 22 | <div class="postbox"> |
23 | - <h1 class="give-importer-h1" align="center"><?php esc_html_e( 'Import Settings', 'give' ); ?></h1> |
|
23 | + <h1 class="give-importer-h1" align="center"><?php esc_html_e('Import Settings', 'give'); ?></h1> |
|
24 | 24 | <div class="inside give-tools-setting-page-import give-import-core-settings"> |
25 | 25 | <?php |
26 | 26 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @since 1.8.17 |
30 | 30 | */ |
31 | - do_action( 'give_tools_import_core_settings_form_before_start' ); |
|
31 | + do_action('give_tools_import_core_settings_form_before_start'); |
|
32 | 32 | ?> |
33 | 33 | <form method="post" id="give-import-core-settings-form" |
34 | 34 | class="give-import-form tools-setting-page-import tools-setting-page-import" |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.8.17 |
42 | 42 | */ |
43 | - do_action( 'give_tools_import_core_settings_form_start' ); |
|
43 | + do_action('give_tools_import_core_settings_form_start'); |
|
44 | 44 | ?> |
45 | 45 | |
46 | 46 | <?php |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @since 1.8.17 |
51 | 51 | */ |
52 | - do_action( 'give_tools_import_core_settings_form_end' ); |
|
52 | + do_action('give_tools_import_core_settings_form_end'); |
|
53 | 53 | ?> |
54 | 54 | </form> |
55 | 55 | <?php |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @since 1.8.17 |
60 | 60 | */ |
61 | - do_action( 'give_tools_import_core_settings_form_after_end' ); |
|
61 | + do_action('give_tools_import_core_settings_form_after_end'); |
|
62 | 62 | ?> |
63 | 63 | </div><!-- .inside --> |
64 | 64 | </div><!-- .postbox --> |
@@ -69,4 +69,4 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @since 1.8.17 |
71 | 71 | */ |
72 | -do_action( 'give_tools_import_core_settings_main_after' ); |
|
72 | +do_action('give_tools_import_core_settings_main_after'); |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_System_Info' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_System_Info')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_System_Info. |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | $this->id = 'system-info'; |
37 | - $this->label = esc_html__( 'System Info', 'give' ); |
|
37 | + $this->label = esc_html__('System Info', 'give'); |
|
38 | 38 | |
39 | 39 | parent::__construct(); |
40 | 40 | |
41 | 41 | // Do not use main form for this tab. |
42 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
43 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
44 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
42 | + if (give_get_current_setting_tab() === $this->id) { |
|
43 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
44 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function output() { |
55 | 55 | $GLOBALS['give_hide_save_button'] = true; |
56 | - include_once( 'views/html-admin-page-system-info.php' ); |
|
56 | + include_once('views/html-admin-page-system-info.php'); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
111 | 111 | if ( isset( $_POST['akismet_spam_protection'] ) |
112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
113 | - && ! give_check_akismet_key() |
|
112 | + && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
113 | + && ! give_check_akismet_key() |
|
114 | 114 | ) { |
115 | 115 | self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
116 | 116 | |
@@ -792,9 +792,9 @@ discard block |
||
792 | 792 | <td class="give-docs-link" colspan="2"> |
793 | 793 | <?php |
794 | 794 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
795 | - . '" target="_blank">' |
|
796 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
797 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
795 | + . '" target="_blank">' |
|
796 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
797 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
798 | 798 | ?> |
799 | 799 | </td> |
800 | 800 | </tr><?php |
@@ -465,9 +465,12 @@ discard block |
||
465 | 465 | <?php endforeach; ?> |
466 | 466 | <a href="#" data-id="<?php echo $value['id']; ?>" |
467 | 467 | class="give-repeat-setting-field button-secondary"><?php echo $value['repeat_btn_title']; ?></a> |
468 | - <?php else : ?> |
|
468 | + <?php else { |
|
469 | + : ?> |
|
469 | 470 | <input |
470 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
471 | + name="<?php echo esc_attr( $value['id'] ); |
|
472 | +} |
|
473 | +?>" |
|
471 | 474 | id="<?php echo esc_attr( $value['id'] ); ?>" |
472 | 475 | type="<?php echo esc_attr( $type ); ?>" |
473 | 476 | style="<?php echo esc_attr( $value['css'] ); ?>" |
@@ -533,7 +536,10 @@ discard block |
||
533 | 536 | </th> |
534 | 537 | <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
535 | 538 | <select |
536 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>" |
|
539 | + name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
540 | + echo '[]'; |
|
541 | +} |
|
542 | +?>" |
|
537 | 543 | id="<?php echo esc_attr( $value['id'] ); ?>" |
538 | 544 | style="<?php echo esc_attr( $value['css'] ); ?>" |
539 | 545 | class="<?php echo esc_attr( $value['class'] ); ?>" |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param array $settings Array of settings class object. |
74 | 74 | */ |
75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
76 | 76 | |
77 | 77 | return self::$settings; |
78 | 78 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return bool |
87 | 87 | */ |
88 | 88 | public static function verify_nonce() { |
89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
90 | 90 | return false; |
91 | 91 | } |
92 | 92 | |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | public static function save() { |
103 | 103 | $current_tab = give_get_current_setting_tab(); |
104 | 104 | |
105 | - if ( ! self::verify_nonce() ) { |
|
106 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
105 | + if ( ! self::verify_nonce()) { |
|
106 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
107 | 107 | die(); |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
111 | - if ( isset( $_POST['akismet_spam_protection'] ) |
|
112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
111 | + if (isset($_POST['akismet_spam_protection']) |
|
112 | + && give_is_setting_enabled($_POST['akismet_spam_protection']) |
|
113 | 113 | && ! give_check_akismet_key() |
114 | 114 | ) { |
115 | - self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
|
115 | + self::add_error('give-akismet-protection', __('Please properly configure Akismet to enable SPAM protection.', 'give')); |
|
116 | 116 | |
117 | 117 | return; |
118 | 118 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @since 1.8 |
128 | 128 | */ |
129 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
129 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
130 | 130 | |
131 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
131 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Trigger Action. |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @since 1.8 |
141 | 141 | */ |
142 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
142 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return void |
154 | 154 | */ |
155 | - public static function add_message( $code, $message ) { |
|
156 | - self::$messages[ $code ] = $message; |
|
155 | + public static function add_message($code, $message) { |
|
156 | + self::$messages[$code] = $message; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public static function add_error( $code, $message ) { |
|
170 | - self::$errors[ $code ] = $message; |
|
169 | + public static function add_error($code, $message) { |
|
170 | + self::$errors[$code] = $message; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | $notice_html = ''; |
181 | 181 | $classes = 'give-notice settings-error notice is-dismissible'; |
182 | 182 | |
183 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
184 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
183 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
184 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
185 | 185 | |
186 | - if ( 0 < count( self::$errors ) ) { |
|
187 | - foreach ( self::$errors as $code => $message ) { |
|
186 | + if (0 < count(self::$errors)) { |
|
187 | + foreach (self::$errors as $code => $message) { |
|
188 | 188 | $notice_html .= sprintf( |
189 | 189 | '<div id="setting-error-%1$s" class="%2$s error" style="display: none"><p><strong>%3$s</strong></p></div>', |
190 | 190 | $code, |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - if ( 0 < count( self::$messages ) ) { |
|
198 | - foreach ( self::$messages as $code => $message ) { |
|
197 | + if (0 < count(self::$messages)) { |
|
198 | + foreach (self::$messages as $code => $message) { |
|
199 | 199 | $notice_html .= sprintf( |
200 | 200 | '<div id="setting-error-%1$s" class="%2$s updated" style="display: none"><p><strong>%3$s</strong></p></div>', |
201 | 201 | $code, |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | self::$setting_filter_prefix = give_get_current_setting_page(); |
222 | 222 | |
223 | 223 | // Bailout: Exit if setting page is not defined. |
224 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
224 | + if (empty(self::$setting_filter_prefix)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @since 1.8 |
236 | 236 | */ |
237 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
237 | + do_action(self::$setting_filter_prefix.'_start'); |
|
238 | 238 | |
239 | 239 | $current_tab = give_get_current_setting_tab(); |
240 | 240 | |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | /* @var object $current_setting_obj */ |
245 | 245 | $current_setting_obj = new StdClass; |
246 | 246 | |
247 | - foreach ( $all_setting as $setting ) { |
|
247 | + foreach ($all_setting as $setting) { |
|
248 | 248 | if ( |
249 | - method_exists( $setting, 'get_id' ) && |
|
249 | + method_exists($setting, 'get_id') && |
|
250 | 250 | $current_tab === $setting->get_id() |
251 | 251 | ) { |
252 | 252 | $current_setting_obj = $setting; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | |
257 | 257 | // Save settings if data has been posted. |
258 | - if ( ! empty( $_POST ) ) { |
|
258 | + if ( ! empty($_POST)) { |
|
259 | 259 | self::save(); |
260 | 260 | } |
261 | 261 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @since 1.8 |
270 | 270 | */ |
271 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
271 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
272 | 272 | |
273 | 273 | include 'views/html-admin-settings.php'; |
274 | 274 | |
@@ -286,25 +286,25 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return string|bool |
288 | 288 | */ |
289 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
289 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
290 | 290 | // Bailout. |
291 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
291 | + if (empty($option_name) && empty($field_id)) { |
|
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
295 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
296 | 296 | // Get field value if any. |
297 | - $option_value = get_option( $option_name ); |
|
297 | + $option_value = get_option($option_name); |
|
298 | 298 | |
299 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
300 | - ? $option_value[ $field_id ] |
|
299 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
300 | + ? $option_value[$field_id] |
|
301 | 301 | : $default; |
302 | 302 | } else { |
303 | 303 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
304 | 304 | $option_name = ! $option_name ? $field_id : $option_name; |
305 | 305 | |
306 | 306 | // Get option value if any. |
307 | - $option_value = get_option( $option_name, $default ); |
|
307 | + $option_value = get_option($option_name, $default); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | return $option_value; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return void |
325 | 325 | */ |
326 | - public static function output_fields( $options, $option_name = '' ) { |
|
326 | + public static function output_fields($options, $option_name = '') { |
|
327 | 327 | $current_tab = give_get_current_setting_tab(); |
328 | 328 | |
329 | 329 | // Field Default values. |
@@ -335,62 +335,62 @@ discard block |
||
335 | 335 | 'desc' => '', |
336 | 336 | 'table_html' => true, |
337 | 337 | 'repeat' => false, |
338 | - 'repeat_btn_title' => __( 'Add Field', 'give' ), |
|
338 | + 'repeat_btn_title' => __('Add Field', 'give'), |
|
339 | 339 | ); |
340 | 340 | |
341 | - foreach ( $options as $value ) { |
|
342 | - if ( ! isset( $value['type'] ) ) { |
|
341 | + foreach ($options as $value) { |
|
342 | + if ( ! isset($value['type'])) { |
|
343 | 343 | continue; |
344 | 344 | } |
345 | 345 | |
346 | 346 | // Set title. |
347 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
347 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
348 | 348 | |
349 | 349 | // Set default setting. |
350 | - $value = wp_parse_args( $value, $defaults ); |
|
350 | + $value = wp_parse_args($value, $defaults); |
|
351 | 351 | |
352 | 352 | // Colorpicker field. |
353 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
354 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
353 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
354 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
355 | 355 | |
356 | 356 | |
357 | 357 | // Custom attribute handling. |
358 | 358 | $custom_attributes = array(); |
359 | 359 | |
360 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
361 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
362 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
360 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
361 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
362 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
366 | 366 | // Description handling. |
367 | - $description = self::get_field_description( $value ); |
|
367 | + $description = self::get_field_description($value); |
|
368 | 368 | |
369 | 369 | // Switch based on type. |
370 | - switch ( $value['type'] ) { |
|
370 | + switch ($value['type']) { |
|
371 | 371 | |
372 | 372 | // Section Titles |
373 | 373 | case 'title': |
374 | - if ( ! empty( $value['title'] ) || ! empty( $value['desc'] ) ) { |
|
374 | + if ( ! empty($value['title']) || ! empty($value['desc'])) { |
|
375 | 375 | ?> |
376 | 376 | <div class="give-setting-tab-header give-setting-tab-header-<?php echo $current_tab; ?>"> |
377 | - <?php if ( ! empty( $value['title'] ) ) : ?> |
|
378 | - <h2><?php echo self::get_field_title( $value ); ?></h2> |
|
377 | + <?php if ( ! empty($value['title'])) : ?> |
|
378 | + <h2><?php echo self::get_field_title($value); ?></h2> |
|
379 | 379 | <hr> |
380 | 380 | <?php endif; ?> |
381 | 381 | |
382 | - <?php if ( ! empty( $value['desc'] ) ) : ?> |
|
383 | - <?php echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); ?> |
|
382 | + <?php if ( ! empty($value['desc'])) : ?> |
|
383 | + <?php echo wpautop(wptexturize(wp_kses_post($value['desc']))); ?> |
|
384 | 384 | <?php endif; ?> |
385 | 385 | </div> |
386 | 386 | <?php |
387 | 387 | } |
388 | 388 | |
389 | - if ( $value['table_html'] ) { |
|
390 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
389 | + if ($value['table_html']) { |
|
390 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
391 | 391 | } |
392 | 392 | |
393 | - if ( ! empty( $value['id'] ) ) { |
|
393 | + if ( ! empty($value['id'])) { |
|
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Trigger Action. |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @since 1.8 |
401 | 401 | */ |
402 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
402 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | break; |
406 | 406 | |
407 | 407 | // Section Ends. |
408 | 408 | case 'sectionend': |
409 | - if ( ! empty( $value['id'] ) ) { |
|
409 | + if ( ! empty($value['id'])) { |
|
410 | 410 | |
411 | 411 | /** |
412 | 412 | * Trigger Action. |
@@ -415,14 +415,14 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @since 1.8 |
417 | 417 | */ |
418 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
418 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
419 | 419 | } |
420 | 420 | |
421 | - if ( $value['table_html'] ) { |
|
421 | + if ($value['table_html']) { |
|
422 | 422 | echo '</table>'; |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! empty( $value['id'] ) ) { |
|
425 | + if ( ! empty($value['id'])) { |
|
426 | 426 | |
427 | 427 | /** |
428 | 428 | * Trigger Action. |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @since 1.8 |
433 | 433 | */ |
434 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
434 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | break; |
@@ -439,51 +439,51 @@ discard block |
||
439 | 439 | // Standard text inputs and subtypes like 'number'. |
440 | 440 | case 'colorpicker': |
441 | 441 | case 'hidden' : |
442 | - $value['wrapper_class'] = empty( $value['wrapper_class'] ) ? 'give-hidden' : trim( $value['wrapper_class'] ) . ' give-hidden'; |
|
442 | + $value['wrapper_class'] = empty($value['wrapper_class']) ? 'give-hidden' : trim($value['wrapper_class']).' give-hidden'; |
|
443 | 443 | case 'text': |
444 | 444 | case 'email': |
445 | 445 | case 'number': |
446 | 446 | case 'password' : |
447 | 447 | $type = $value['type']; |
448 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
448 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
449 | 449 | |
450 | 450 | // Set default value for repeater field if not any value set yet. |
451 | - if ( $value['repeat'] && is_string( $option_value ) ) { |
|
452 | - $option_value = array( $value['default'] ); |
|
451 | + if ($value['repeat'] && is_string($option_value)) { |
|
452 | + $option_value = array($value['default']); |
|
453 | 453 | } |
454 | 454 | ?> |
455 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
455 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
456 | 456 | <th scope="row" class="titledesc"> |
457 | 457 | <label |
458 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
458 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
459 | 459 | </th> |
460 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
461 | - <?php if ( $value['repeat'] ) : ?> |
|
462 | - <?php foreach ( $option_value as $index => $field_value ) : ?> |
|
460 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
461 | + <?php if ($value['repeat']) : ?> |
|
462 | + <?php foreach ($option_value as $index => $field_value) : ?> |
|
463 | 463 | <p> |
464 | 464 | <input |
465 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
466 | - type="<?php echo esc_attr( $type ); ?>" |
|
467 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
468 | - value="<?php echo esc_attr( $field_value ); ?>" |
|
469 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?> <?php echo esc_attr( $value['id'] ); ?>" |
|
470 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
465 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
466 | + type="<?php echo esc_attr($type); ?>" |
|
467 | + style="<?php echo esc_attr($value['css']); ?>" |
|
468 | + value="<?php echo esc_attr($field_value); ?>" |
|
469 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?> <?php echo esc_attr($value['id']); ?>" |
|
470 | + <?php echo implode(' ', $custom_attributes); ?> |
|
471 | 471 | /> |
472 | 472 | <span class="give-remove-setting-field" |
473 | - title="<?php esc_html_e( 'Remove setting field', 'give' ); ?>">-</span> |
|
473 | + title="<?php esc_html_e('Remove setting field', 'give'); ?>">-</span> |
|
474 | 474 | </p> |
475 | 475 | <?php endforeach; ?> |
476 | 476 | <a href="#" data-id="<?php echo $value['id']; ?>" |
477 | 477 | class="give-repeat-setting-field button-secondary"><?php echo $value['repeat_btn_title']; ?></a> |
478 | 478 | <?php else : ?> |
479 | 479 | <input |
480 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
481 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
482 | - type="<?php echo esc_attr( $type ); ?>" |
|
483 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
484 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
485 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
486 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
480 | + name="<?php echo esc_attr($value['id']); ?>" |
|
481 | + id="<?php echo esc_attr($value['id']); ?>" |
|
482 | + type="<?php echo esc_attr($type); ?>" |
|
483 | + style="<?php echo esc_attr($value['css']); ?>" |
|
484 | + value="<?php echo esc_attr($option_value); ?>" |
|
485 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
486 | + <?php echo implode(' ', $custom_attributes); ?> |
|
487 | 487 | /> |
488 | 488 | <?php endif; ?> |
489 | 489 | <?php echo $description; ?> |
@@ -494,24 +494,24 @@ discard block |
||
494 | 494 | // Textarea. |
495 | 495 | case 'textarea': |
496 | 496 | |
497 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
497 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
498 | 498 | |
499 | 499 | ?> |
500 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
500 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
501 | 501 | <th scope="row" class="titledesc"> |
502 | 502 | <label |
503 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
503 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
504 | 504 | </th> |
505 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
505 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
506 | 506 | <textarea |
507 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
508 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
509 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
510 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
507 | + name="<?php echo esc_attr($value['id']); ?>" |
|
508 | + id="<?php echo esc_attr($value['id']); ?>" |
|
509 | + style="<?php echo esc_attr($value['css']); ?>" |
|
510 | + class="<?php echo esc_attr($value['class']); ?>" |
|
511 | 511 | rows="10" |
512 | 512 | cols="60" |
513 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
514 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
513 | + <?php echo implode(' ', $custom_attributes); ?> |
|
514 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
515 | 515 | <?php echo $description; ?> |
516 | 516 | </td> |
517 | 517 | </tr><?php |
@@ -520,47 +520,47 @@ discard block |
||
520 | 520 | // Select boxes. |
521 | 521 | case 'select' : |
522 | 522 | case 'multiselect' : |
523 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
523 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
524 | 524 | |
525 | 525 | /** |
526 | 526 | * insert page in option if missing. |
527 | 527 | * |
528 | 528 | * check success_page setting in general settings. |
529 | 529 | */ |
530 | - if( |
|
531 | - isset( $value['attributes' ] ) && |
|
532 | - false !== strpos( $value['class'], 'give-select-chosen' ) && |
|
533 | - in_array( 'data-search-type', array_keys( $value['attributes' ] ) ) && |
|
534 | - 'pages' == $value['attributes' ]['data-search-type'] && |
|
535 | - ! in_array( $option_value, array_keys( $value['options'] ) ) |
|
530 | + if ( |
|
531 | + isset($value['attributes']) && |
|
532 | + false !== strpos($value['class'], 'give-select-chosen') && |
|
533 | + in_array('data-search-type', array_keys($value['attributes'])) && |
|
534 | + 'pages' == $value['attributes']['data-search-type'] && |
|
535 | + ! in_array($option_value, array_keys($value['options'])) |
|
536 | 536 | ) { |
537 | - $value['options'][$option_value] = get_the_title( $option_value ); |
|
537 | + $value['options'][$option_value] = get_the_title($option_value); |
|
538 | 538 | } |
539 | 539 | ?> |
540 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
540 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
541 | 541 | <th scope="row" class="titledesc"> |
542 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
542 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
543 | 543 | </th> |
544 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
544 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
545 | 545 | <select |
546 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>" |
|
547 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
548 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
549 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
550 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
551 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
546 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') echo '[]'; ?>" |
|
547 | + id="<?php echo esc_attr($value['id']); ?>" |
|
548 | + style="<?php echo esc_attr($value['css']); ?>" |
|
549 | + class="<?php echo esc_attr($value['class']); ?>" |
|
550 | + <?php echo implode(' ', $custom_attributes); ?> |
|
551 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
552 | 552 | > |
553 | 553 | |
554 | 554 | <?php |
555 | - if ( ! empty( $value['options'] ) ) { |
|
556 | - foreach ( $value['options'] as $key => $val ) { |
|
555 | + if ( ! empty($value['options'])) { |
|
556 | + foreach ($value['options'] as $key => $val) { |
|
557 | 557 | ?> |
558 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
558 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
559 | 559 | |
560 | - if ( is_array( $option_value ) ) { |
|
561 | - selected( in_array( $key, $option_value ), true ); |
|
560 | + if (is_array($option_value)) { |
|
561 | + selected(in_array($key, $option_value), true); |
|
562 | 562 | } else { |
563 | - selected( $option_value, $key ); |
|
563 | + selected($option_value, $key); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | ?>><?php echo $val ?></option> |
@@ -576,29 +576,29 @@ discard block |
||
576 | 576 | |
577 | 577 | // Radio inputs. |
578 | 578 | case 'radio_inline' : |
579 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
579 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
580 | 580 | case 'radio' : |
581 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
581 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
582 | 582 | ?> |
583 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
583 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
584 | 584 | <th scope="row" class="titledesc"> |
585 | 585 | <label |
586 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
586 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
587 | 587 | </th> |
588 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
588 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
589 | 589 | <fieldset> |
590 | 590 | <ul> |
591 | 591 | <?php |
592 | - foreach ( $value['options'] as $key => $val ) { |
|
592 | + foreach ($value['options'] as $key => $val) { |
|
593 | 593 | ?> |
594 | 594 | <li> |
595 | 595 | <label><input |
596 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
596 | + name="<?php echo esc_attr($value['id']); ?>" |
|
597 | 597 | value="<?php echo $key; ?>" |
598 | 598 | type="radio" |
599 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
600 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
601 | - <?php checked( $key, $option_value ); ?> |
|
599 | + style="<?php echo esc_attr($value['css']); ?>" |
|
600 | + <?php echo implode(' ', $custom_attributes); ?> |
|
601 | + <?php checked($key, $option_value); ?> |
|
602 | 602 | /> <?php echo $val ?></label> |
603 | 603 | </li> |
604 | 604 | <?php |
@@ -612,22 +612,22 @@ discard block |
||
612 | 612 | |
613 | 613 | // Checkbox input. |
614 | 614 | case 'checkbox' : |
615 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
615 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
616 | 616 | ?> |
617 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
617 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
618 | 618 | <th scope="row" class="titledesc"> |
619 | 619 | <label |
620 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
620 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
621 | 621 | </th> |
622 | 622 | <td class="give-forminp"> |
623 | 623 | <input |
624 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
625 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
624 | + name="<?php echo esc_attr($value['id']); ?>" |
|
625 | + id="<?php echo esc_attr($value['id']); ?>" |
|
626 | 626 | type="checkbox" |
627 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
627 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
628 | 628 | value="1" |
629 | - <?php checked( $option_value, 'on' ); ?> |
|
630 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
629 | + <?php checked($option_value, 'on'); ?> |
|
630 | + <?php echo implode(' ', $custom_attributes); ?> |
|
631 | 631 | /> |
632 | 632 | <?php echo $description; ?> |
633 | 633 | </td> |
@@ -637,29 +637,29 @@ discard block |
||
637 | 637 | |
638 | 638 | // Multi Checkbox input. |
639 | 639 | case 'multicheck' : |
640 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
641 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
640 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
641 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
642 | 642 | ?> |
643 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
643 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
644 | 644 | <th scope="row" class="titledesc"> |
645 | 645 | <label |
646 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
646 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
647 | 647 | </th> |
648 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
648 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
649 | 649 | <fieldset> |
650 | 650 | <ul> |
651 | 651 | <?php |
652 | - foreach ( $value['options'] as $key => $val ) { |
|
652 | + foreach ($value['options'] as $key => $val) { |
|
653 | 653 | ?> |
654 | 654 | <li> |
655 | 655 | <label> |
656 | 656 | <input |
657 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
657 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
658 | 658 | value="<?php echo $key; ?>" |
659 | 659 | type="checkbox" |
660 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
661 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
662 | - <?php if ( in_array( $key, $option_value ) ) { |
|
660 | + style="<?php echo esc_attr($value['css']); ?>" |
|
661 | + <?php echo implode(' ', $custom_attributes); ?> |
|
662 | + <?php if (in_array($key, $option_value)) { |
|
663 | 663 | echo 'checked="checked"'; |
664 | 664 | } ?> |
665 | 665 | /> <?php echo $val ?> |
@@ -678,31 +678,31 @@ discard block |
||
678 | 678 | // File input field. |
679 | 679 | case 'file' : |
680 | 680 | case 'media' : |
681 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
682 | - $button_label = sprintf( __( 'Add or Upload %s', 'give' ), ( 'file' === $value['type'] ? __( 'File', 'give' ) : __( 'Image', 'give' ) ) ); |
|
683 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
684 | - |
|
685 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
686 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : ''; |
|
687 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
688 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
681 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
682 | + $button_label = sprintf(__('Add or Upload %s', 'give'), ('file' === $value['type'] ? __('File', 'give') : __('Image', 'give'))); |
|
683 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
684 | + |
|
685 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
686 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : ''; |
|
687 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
688 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
689 | 689 | ?> |
690 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
690 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
691 | 691 | <th scope="row" class="titledesc"> |
692 | 692 | <label |
693 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
693 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
694 | 694 | </th> |
695 | 695 | <td class="give-forminp"> |
696 | 696 | <div class="give-field-wrap"> |
697 | 697 | <label for="<?php echo $value['id'] ?>"> |
698 | 698 | <input |
699 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
700 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
699 | + name="<?php echo esc_attr($value['id']); ?>" |
|
700 | + id="<?php echo esc_attr($value['id']); ?>" |
|
701 | 701 | type="text" |
702 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
702 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
703 | 703 | value="<?php echo $option_value; ?>" |
704 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
705 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
704 | + style="<?php echo esc_attr($value['css']); ?>" |
|
705 | + <?php echo implode(' ', $custom_attributes); ?> |
|
706 | 706 | /> <input class="give-upload-button button" type="button" |
707 | 707 | data-fvalue="<?php echo $fvalue; ?>" |
708 | 708 | data-field-type="<?php echo $value['type']; ?>" |
@@ -723,18 +723,18 @@ discard block |
||
723 | 723 | // WordPress Editor. |
724 | 724 | case 'wysiwyg' : |
725 | 725 | // Get option value. |
726 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
726 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
727 | 727 | |
728 | 728 | // Get editor settings. |
729 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
729 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
730 | 730 | ?> |
731 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
731 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
732 | 732 | <th scope="row" class="titledesc"> |
733 | 733 | <label |
734 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
734 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
735 | 735 | </th> |
736 | 736 | <td class="give-forminp"> |
737 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
737 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
738 | 738 | <?php echo $description; ?> |
739 | 739 | </td> |
740 | 740 | </tr><?php |
@@ -742,15 +742,15 @@ discard block |
||
742 | 742 | |
743 | 743 | // Custom: Default gateways setting field. |
744 | 744 | case 'default_gateway' : |
745 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
745 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
746 | 746 | ?> |
747 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
747 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
748 | 748 | <th scope="row" class="titledesc"> |
749 | 749 | <label |
750 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
750 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
751 | 751 | </th> |
752 | 752 | <td class="give-forminp"> |
753 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
753 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
754 | 754 | <?php echo $description; ?> |
755 | 755 | </td> |
756 | 756 | </tr><?php |
@@ -759,13 +759,13 @@ discard block |
||
759 | 759 | // Custom: Email preview buttons field. |
760 | 760 | case 'email_preview_buttons' : |
761 | 761 | ?> |
762 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
762 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
763 | 763 | <th scope="row" class="titledesc"> |
764 | 764 | <label |
765 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
765 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
766 | 766 | </th> |
767 | 767 | <td class="give-forminp"> |
768 | - <?php give_email_preview_buttons_callback( $value ); ?> |
|
768 | + <?php give_email_preview_buttons_callback($value); ?> |
|
769 | 769 | <?php echo $description; ?> |
770 | 770 | </td> |
771 | 771 | </tr><?php |
@@ -779,23 +779,23 @@ discard block |
||
779 | 779 | |
780 | 780 | // Custom: Gateway API key. |
781 | 781 | case 'api_key' : |
782 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
783 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
782 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
783 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
784 | 784 | ?> |
785 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
785 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
786 | 786 | <th scope="row" class="titledesc"> |
787 | 787 | <label |
788 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
788 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
789 | 789 | </th> |
790 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
790 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
791 | 791 | <input |
792 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
793 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
794 | - type="<?php echo esc_attr( $type ); ?>" |
|
795 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
796 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
797 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
798 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
792 | + name="<?php echo esc_attr($value['id']); ?>" |
|
793 | + id="<?php echo esc_attr($value['id']); ?>" |
|
794 | + type="<?php echo esc_attr($type); ?>" |
|
795 | + style="<?php echo esc_attr($value['css']); ?>" |
|
796 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
797 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
798 | + <?php echo implode(' ', $custom_attributes); ?> |
|
799 | 799 | /> <?php echo $description; ?> |
800 | 800 | </td> |
801 | 801 | </tr><?php |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | * |
813 | 813 | * @since 1.0 |
814 | 814 | */ |
815 | - do_action( "give_logs_view_{$current_section}" ); |
|
815 | + do_action("give_logs_view_{$current_section}"); |
|
816 | 816 | |
817 | 817 | echo $description; |
818 | 818 | break; |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | // Custom: Data field. |
821 | 821 | case 'data' : |
822 | 822 | |
823 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
823 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
824 | 824 | |
825 | 825 | echo $description; |
826 | 826 | break; |
@@ -828,12 +828,12 @@ discard block |
||
828 | 828 | // Custom: Give Docs Link field type. |
829 | 829 | case 'give_docs_link' : |
830 | 830 | ?> |
831 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
831 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
832 | 832 | <td class="give-docs-link" colspan="2"> |
833 | 833 | <?php |
834 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
834 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
835 | 835 | . '" target="_blank">' |
836 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
836 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
837 | 837 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
838 | 838 | ?> |
839 | 839 | </td> |
@@ -844,8 +844,8 @@ discard block |
||
844 | 844 | // You can add or handle your custom field action. |
845 | 845 | default: |
846 | 846 | // Get option value. |
847 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
848 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
847 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
848 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
849 | 849 | break; |
850 | 850 | } |
851 | 851 | } |
@@ -861,15 +861,15 @@ discard block |
||
861 | 861 | * |
862 | 862 | * @return string The HTML description of the field. |
863 | 863 | */ |
864 | - public static function get_field_description( $value ) { |
|
864 | + public static function get_field_description($value) { |
|
865 | 865 | $description = ''; |
866 | 866 | |
867 | 867 | // Support for both 'description' and 'desc' args. |
868 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
869 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
868 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
869 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
870 | 870 | |
871 | - if ( ! empty( $value ) ) { |
|
872 | - $description = '<div class="give-field-description">' . wp_kses_post( $value ) . '</div>'; |
|
871 | + if ( ! empty($value)) { |
|
872 | + $description = '<div class="give-field-description">'.wp_kses_post($value).'</div>'; |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | return $description; |
@@ -886,11 +886,11 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return array The description and tip as a 2 element array |
888 | 888 | */ |
889 | - public static function get_field_title( $value ) { |
|
890 | - $title = esc_html( $value['title'] ); |
|
889 | + public static function get_field_title($value) { |
|
890 | + $title = esc_html($value['title']); |
|
891 | 891 | |
892 | 892 | // If html tag detected then allow them to print. |
893 | - if ( strip_tags( $title ) ) { |
|
893 | + if (strip_tags($title)) { |
|
894 | 894 | $title = $value['title']; |
895 | 895 | } |
896 | 896 | |
@@ -909,8 +909,8 @@ discard block |
||
909 | 909 | * |
910 | 910 | * @return bool |
911 | 911 | */ |
912 | - public static function save_fields( $options, $option_name = '' ) { |
|
913 | - if ( empty( $_POST ) ) { |
|
912 | + public static function save_fields($options, $option_name = '') { |
|
913 | + if (empty($_POST)) { |
|
914 | 914 | return false; |
915 | 915 | } |
916 | 916 | |
@@ -918,37 +918,37 @@ discard block |
||
918 | 918 | $update_options = array(); |
919 | 919 | |
920 | 920 | // Loop options and get values to save. |
921 | - foreach ( $options as $option ) { |
|
922 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
921 | + foreach ($options as $option) { |
|
922 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
923 | 923 | continue; |
924 | 924 | } |
925 | 925 | |
926 | 926 | // Get posted value. |
927 | - if ( strstr( $option['id'], '[' ) ) { |
|
928 | - parse_str( $option['id'], $option_name_array ); |
|
929 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
930 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
931 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
927 | + if (strstr($option['id'], '[')) { |
|
928 | + parse_str($option['id'], $option_name_array); |
|
929 | + $field_option_name = current(array_keys($option_name_array)); |
|
930 | + $setting_name = key($option_name_array[$field_option_name]); |
|
931 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
932 | 932 | } else { |
933 | 933 | $field_option_name = $option['id']; |
934 | 934 | $setting_name = ''; |
935 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
935 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | // Format the value based on option type. |
939 | - switch ( $option['type'] ) { |
|
939 | + switch ($option['type']) { |
|
940 | 940 | case 'checkbox' : |
941 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
941 | + $value = is_null($raw_value) ? '' : 'on'; |
|
942 | 942 | break; |
943 | 943 | case 'wysiwyg' : |
944 | 944 | case 'textarea' : |
945 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
945 | + $value = wp_kses_post(trim($raw_value)); |
|
946 | 946 | break; |
947 | 947 | case 'multiselect' : |
948 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
948 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
949 | 949 | break; |
950 | 950 | default : |
951 | - $value = give_clean( $raw_value ); |
|
951 | + $value = give_clean($raw_value); |
|
952 | 952 | break; |
953 | 953 | } |
954 | 954 | |
@@ -957,37 +957,37 @@ discard block |
||
957 | 957 | * |
958 | 958 | * @since 1.8 |
959 | 959 | */ |
960 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
960 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
961 | 961 | |
962 | 962 | /** |
963 | 963 | * Sanitize the value of an option by option name. |
964 | 964 | * |
965 | 965 | * @since 1.8 |
966 | 966 | */ |
967 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
967 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
968 | 968 | |
969 | - if ( is_null( $value ) ) { |
|
969 | + if (is_null($value)) { |
|
970 | 970 | continue; |
971 | 971 | } |
972 | 972 | |
973 | 973 | // Check if option is an array and handle that differently to single values. |
974 | - if ( $field_option_name && $setting_name ) { |
|
975 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
976 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
974 | + if ($field_option_name && $setting_name) { |
|
975 | + if ( ! isset($update_options[$field_option_name])) { |
|
976 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
977 | 977 | } |
978 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
979 | - $update_options[ $field_option_name ] = array(); |
|
978 | + if ( ! is_array($update_options[$field_option_name])) { |
|
979 | + $update_options[$field_option_name] = array(); |
|
980 | 980 | } |
981 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
981 | + $update_options[$field_option_name][$setting_name] = $value; |
|
982 | 982 | } else { |
983 | - $update_options[ $field_option_name ] = $value; |
|
983 | + $update_options[$field_option_name] = $value; |
|
984 | 984 | } |
985 | 985 | } |
986 | 986 | |
987 | 987 | // Save all options in our array or there own option name i.e. option id. |
988 | - if ( empty( $option_name ) ) { |
|
989 | - foreach ( $update_options as $name => $value ) { |
|
990 | - update_option( $name, $value ); |
|
988 | + if (empty($option_name)) { |
|
989 | + foreach ($update_options as $name => $value) { |
|
990 | + update_option($name, $value); |
|
991 | 991 | |
992 | 992 | /** |
993 | 993 | * Trigger action. |
@@ -996,13 +996,13 @@ discard block |
||
996 | 996 | * |
997 | 997 | * @since 1.8 |
998 | 998 | */ |
999 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
999 | + do_action("give_save_option_{$name}", $value, $name); |
|
1000 | 1000 | } |
1001 | 1001 | } else { |
1002 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
1003 | - $update_options = array_merge( $old_options, $update_options ); |
|
1002 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
1003 | + $update_options = array_merge($old_options, $update_options); |
|
1004 | 1004 | |
1005 | - update_option( $option_name, $update_options ); |
|
1005 | + update_option($option_name, $update_options); |
|
1006 | 1006 | |
1007 | 1007 | /** |
1008 | 1008 | * Trigger action. |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | * |
1012 | 1012 | * @since 1.8 |
1013 | 1013 | */ |
1014 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name, $old_options ); |
|
1014 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name, $old_options); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | return true; |
@@ -1040,21 +1040,21 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @return bool |
1042 | 1042 | */ |
1043 | - public static function is_setting_page( $tab = '', $section = '' ) { |
|
1043 | + public static function is_setting_page($tab = '', $section = '') { |
|
1044 | 1044 | $is_setting_page = false; |
1045 | 1045 | |
1046 | - if( ! is_admin() ) { |
|
1046 | + if ( ! is_admin()) { |
|
1047 | 1047 | return $is_setting_page; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | // Check fo setting tab. |
1051 | - if ( ! empty( $tab ) ) { |
|
1052 | - $is_setting_page = ( $tab === give_get_current_setting_tab() ); |
|
1051 | + if ( ! empty($tab)) { |
|
1052 | + $is_setting_page = ($tab === give_get_current_setting_tab()); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | // Check fo setting section. |
1056 | - if ( ! empty( $section ) ) { |
|
1057 | - $is_setting_page = ( $section === give_get_current_setting_section() ); |
|
1056 | + if ( ! empty($section)) { |
|
1057 | + $is_setting_page = ($section === give_get_current_setting_section()); |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | return $is_setting_page; |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
68 | - $donation_list_page_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
67 | + public function column_default($item, $column_name) { |
|
68 | + $donation_list_page_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
69 | 69 | |
70 | - switch ( $column_name ) { |
|
70 | + switch ($column_name) { |
|
71 | 71 | case 'complete_sales': |
72 | - $value = $item[ $column_name ] ? |
|
72 | + $value = $item[$column_name] ? |
|
73 | 73 | sprintf( |
74 | 74 | '<a href="%s">%s</a>', |
75 | 75 | add_query_arg( |
@@ -79,13 +79,12 @@ discard block |
||
79 | 79 | ), |
80 | 80 | $donation_list_page_url |
81 | 81 | ), |
82 | - $item[ $column_name ] |
|
83 | - ) : |
|
84 | - $item[ $column_name ]; |
|
82 | + $item[$column_name] |
|
83 | + ) : $item[$column_name]; |
|
85 | 84 | break; |
86 | 85 | |
87 | 86 | case 'pending_sales': |
88 | - $value = $item[ $column_name ] ? |
|
87 | + $value = $item[$column_name] ? |
|
89 | 88 | sprintf( |
90 | 89 | '<a href="%s">%s</a>', |
91 | 90 | add_query_arg( |
@@ -95,13 +94,12 @@ discard block |
||
95 | 94 | ), |
96 | 95 | $donation_list_page_url |
97 | 96 | ), |
98 | - $item[ $column_name ] |
|
99 | - ) : |
|
100 | - $item[ $column_name ]; |
|
97 | + $item[$column_name] |
|
98 | + ) : $item[$column_name]; |
|
101 | 99 | break; |
102 | 100 | |
103 | 101 | case 'total_sales': |
104 | - $value = $item[ $column_name ] ? |
|
102 | + $value = $item[$column_name] ? |
|
105 | 103 | sprintf( |
106 | 104 | '<a href="%s">%s</a>', |
107 | 105 | add_query_arg( |
@@ -110,14 +108,13 @@ discard block |
||
110 | 108 | ), |
111 | 109 | $donation_list_page_url |
112 | 110 | ), |
113 | - $item[ $column_name ] |
|
114 | - ) : |
|
115 | - $item[ $column_name ]; |
|
111 | + $item[$column_name] |
|
112 | + ) : $item[$column_name]; |
|
116 | 113 | |
117 | 114 | break; |
118 | 115 | |
119 | 116 | default: |
120 | - $value = $item[ $column_name ]; |
|
117 | + $value = $item[$column_name]; |
|
121 | 118 | } |
122 | 119 | |
123 | 120 | return $value; |
@@ -132,11 +129,11 @@ discard block |
||
132 | 129 | */ |
133 | 130 | public function get_columns() { |
134 | 131 | $columns = array( |
135 | - 'label' => esc_attr__( 'Gateway', 'give' ), |
|
136 | - 'complete_sales' => esc_attr__( 'Complete Payments', 'give' ), |
|
137 | - 'pending_sales' => esc_attr__( 'Pending / Failed Payments', 'give' ), |
|
138 | - 'total_sales' => esc_attr__( 'Total Payments', 'give' ), |
|
139 | - 'total_donations' => esc_attr__( 'Total Donated', 'give' ) |
|
132 | + 'label' => esc_attr__('Gateway', 'give'), |
|
133 | + 'complete_sales' => esc_attr__('Complete Payments', 'give'), |
|
134 | + 'pending_sales' => esc_attr__('Pending / Failed Payments', 'give'), |
|
135 | + 'total_sales' => esc_attr__('Total Payments', 'give'), |
|
136 | + 'total_donations' => esc_attr__('Total Donated', 'give') |
|
140 | 137 | ); |
141 | 138 | |
142 | 139 | return $columns; |
@@ -151,7 +148,7 @@ discard block |
||
151 | 148 | */ |
152 | 149 | public function get_sortable_columns() { |
153 | 150 | return array( |
154 | - 'total_donations' => array( 'total_donations', false ) |
|
151 | + 'total_donations' => array('total_donations', false) |
|
155 | 152 | ); |
156 | 153 | } |
157 | 154 | |
@@ -164,7 +161,7 @@ discard block |
||
164 | 161 | * @return int Current page number |
165 | 162 | */ |
166 | 163 | public function get_paged() { |
167 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
164 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
168 | 165 | } |
169 | 166 | |
170 | 167 | |
@@ -175,7 +172,7 @@ discard block |
||
175 | 172 | * @since 1.0 |
176 | 173 | * @return void |
177 | 174 | */ |
178 | - public function bulk_actions( $which = '' ) { |
|
175 | + public function bulk_actions($which = '') { |
|
179 | 176 | |
180 | 177 | } |
181 | 178 | |
@@ -187,27 +184,27 @@ discard block |
||
187 | 184 | * |
188 | 185 | * @param string $which |
189 | 186 | */ |
190 | - protected function display_tablenav( $which ) { |
|
187 | + protected function display_tablenav($which) { |
|
191 | 188 | |
192 | - if ( 'top' === $which ) { |
|
193 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
189 | + if ('top' === $which) { |
|
190 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
194 | 191 | } |
195 | 192 | ?> |
196 | - <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
193 | + <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
197 | 194 | |
198 | - <?php if ( 'top' === $which ) { ?> |
|
195 | + <?php if ('top' === $which) { ?> |
|
199 | 196 | <h2 class="alignleft reports-earnings-title screen-reader-text"> |
200 | - <?php _e( 'Donation Methods Report', 'give' ); ?> |
|
197 | + <?php _e('Donation Methods Report', 'give'); ?> |
|
201 | 198 | </h2> |
202 | 199 | <?php } ?> |
203 | 200 | |
204 | 201 | <div class="alignright tablenav-right"> |
205 | 202 | <div class="actions bulkactions"> |
206 | - <?php $this->bulk_actions( $which ); ?> |
|
203 | + <?php $this->bulk_actions($which); ?> |
|
207 | 204 | </div> |
208 | 205 | <?php |
209 | - $this->extra_tablenav( $which ); |
|
210 | - $this->pagination( $which ); |
|
206 | + $this->extra_tablenav($which); |
|
207 | + $this->pagination($which); |
|
211 | 208 | ?> |
212 | 209 | </div> |
213 | 210 | |
@@ -229,17 +226,17 @@ discard block |
||
229 | 226 | * |
230 | 227 | * @return int |
231 | 228 | */ |
232 | - public function give_sort_total_donations( $old_value, $new_value ) { |
|
229 | + public function give_sort_total_donations($old_value, $new_value) { |
|
233 | 230 | // If no sort, default to label. |
234 | - $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'label'; |
|
231 | + $orderby = ( ! empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'label'; |
|
235 | 232 | |
236 | 233 | //If no order, default to asc. |
237 | - $order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc'; |
|
234 | + $order = ( ! empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc'; |
|
238 | 235 | |
239 | 236 | //Determine sort order. |
240 | - $result = strcmp( $old_value[ $orderby ], $new_value[ $orderby ] ); |
|
237 | + $result = strcmp($old_value[$orderby], $new_value[$orderby]); |
|
241 | 238 | |
242 | - return ( $order === 'asc' ) ? $result : -$result; |
|
239 | + return ($order === 'asc') ? $result : -$result; |
|
243 | 240 | } |
244 | 241 | |
245 | 242 | |
@@ -256,10 +253,10 @@ discard block |
||
256 | 253 | $gateways = give_get_payment_gateways(); |
257 | 254 | $stats = new Give_Payment_Stats(); |
258 | 255 | |
259 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
256 | + foreach ($gateways as $gateway_id => $gateway) { |
|
260 | 257 | |
261 | - $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' ); |
|
262 | - $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) ); |
|
258 | + $complete_count = give_count_sales_by_gateway($gateway_id, 'publish'); |
|
259 | + $pending_count = give_count_sales_by_gateway($gateway_id, array('pending', 'failed')); |
|
263 | 260 | |
264 | 261 | $reports_data[] = array( |
265 | 262 | 'ID' => $gateway_id, |
@@ -267,7 +264,7 @@ discard block |
||
267 | 264 | 'complete_sales' => $complete_count, |
268 | 265 | 'pending_sales' => $pending_count, |
269 | 266 | 'total_sales' => $complete_count + $pending_count, |
270 | - 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, strtotime('04/13/2015' ), current_time('timestamp' ), $gateway_id ), array( 'sanitize' => false ) ) ), |
|
267 | + 'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, strtotime('04/13/2015'), current_time('timestamp'), $gateway_id), array('sanitize' => false))), |
|
271 | 268 | ); |
272 | 269 | } |
273 | 270 | |
@@ -288,11 +285,11 @@ discard block |
||
288 | 285 | $columns = $this->get_columns(); |
289 | 286 | $hidden = array(); // No hidden columns |
290 | 287 | $sortable = $this->get_sortable_columns(); |
291 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
288 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
292 | 289 | $this->items = $this->reports_data(); |
293 | 290 | |
294 | 291 | // Sort Array when we are sorting data in array. |
295 | - usort( $this->items, array( $this, 'give_sort_total_donations' ) ); |
|
292 | + usort($this->items, array($this, 'give_sort_total_donations')); |
|
296 | 293 | |
297 | 294 | } |
298 | 295 | } |
@@ -10,17 +10,17 @@ |
||
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 | ?> |
17 | 17 | <div class="wrap" id="poststuff"> |
18 | 18 | <div id="give-updates"> |
19 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates Complete', 'give' ); ?></h1> |
|
19 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates Complete', 'give'); ?></h1> |
|
20 | 20 | <hr class="wp-header-end"> |
21 | 21 | |
22 | 22 | <div class="give-update-panel-content"> |
23 | - <p><?php esc_html_e( 'Congratulations! You are running the latest versions of Give and its add-ons.', 'give' ); ?></p> |
|
23 | + <p><?php esc_html_e('Congratulations! You are running the latest versions of Give and its add-ons.', 'give'); ?></p> |
|
24 | 24 | </div> |
25 | 25 | |
26 | 26 | </div> |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | give_ignore_user_abort(); |
42 | 42 | |
43 | 43 | nocache_headers(); |
44 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
45 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
46 | - header( "Expires: 0" ); |
|
44 | + header('Content-Type: text/csv; charset=utf-8'); |
|
45 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
46 | + header("Expires: 0"); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | public function csv_cols() { |
58 | 58 | |
59 | 59 | $cols = array( |
60 | - 'date' => __( 'Date', 'give' ), |
|
61 | - 'donations' => __( 'Donations', 'give' ), |
|
60 | + 'date' => __('Date', 'give'), |
|
61 | + 'donations' => __('Donations', 'give'), |
|
62 | 62 | /* translators: %s: currency */ |
63 | - 'earnings' => sprintf( __( 'Income (%s)', 'give' ), give_currency_symbol('', true) ) |
|
63 | + 'earnings' => sprintf(__('Income (%s)', 'give'), give_currency_symbol('', true)) |
|
64 | 64 | ); |
65 | 65 | |
66 | 66 | return $cols; |
@@ -75,28 +75,28 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function get_data() { |
77 | 77 | |
78 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
79 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
80 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
81 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
78 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
79 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
80 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
81 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
82 | 82 | |
83 | 83 | $data = array(); |
84 | 84 | $year = $start_year; |
85 | 85 | $stats = new Give_Payment_Stats; |
86 | 86 | |
87 | - while ( $year <= $end_year ) { |
|
87 | + while ($year <= $end_year) { |
|
88 | 88 | |
89 | - if ( $year == $start_year && $year == $end_year ) { |
|
89 | + if ($year == $start_year && $year == $end_year) { |
|
90 | 90 | |
91 | 91 | $m1 = $start_month; |
92 | 92 | $m2 = $end_month; |
93 | 93 | |
94 | - } elseif ( $year == $start_year ) { |
|
94 | + } elseif ($year == $start_year) { |
|
95 | 95 | |
96 | 96 | $m1 = $start_month; |
97 | 97 | $m2 = 12; |
98 | 98 | |
99 | - } elseif ( $year == $end_year ) { |
|
99 | + } elseif ($year == $end_year) { |
|
100 | 100 | |
101 | 101 | $m1 = 1; |
102 | 102 | $m2 = $end_month; |
@@ -108,28 +108,28 @@ discard block |
||
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | - while ( $m1 <= $m2 ) { |
|
111 | + while ($m1 <= $m2) { |
|
112 | 112 | |
113 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
114 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
113 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
114 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
115 | 115 | |
116 | 116 | $data[] = array( |
117 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
118 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
119 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ), array( 'sanitize' => false ) ), |
|
117 | + 'date' => date_i18n('F Y', $date1), |
|
118 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
119 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2), array('sanitize' => false)), |
|
120 | 120 | ); |
121 | 121 | |
122 | - $m1 ++; |
|
122 | + $m1++; |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | - $year ++; |
|
127 | + $year++; |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
132 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
131 | + $data = apply_filters('give_export_get_data', $data); |
|
132 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
133 | 133 | |
134 | 134 | return $data; |
135 | 135 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.8 |
42 | 42 | * |
43 | - * @return bool |
|
43 | + * @return false|null |
|
44 | 44 | */ |
45 | 45 | function give_redirect_to_clean_url_admin_pages() { |
46 | 46 | // Give admin pages. |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | * @access public |
993 | 993 | * @since 2.0 |
994 | 994 | * |
995 | - * @return bool |
|
995 | + * @return false|null |
|
996 | 996 | */ |
997 | 997 | function give_update_donor_name_on_user_update( $user_id = 0 ) { |
998 | 998 | |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | * @param int $user_id User ID. |
1033 | 1033 | * @param WP_User|bool $old_user_data User data. |
1034 | 1034 | * |
1035 | - * @return bool |
|
1035 | + * @return false|null |
|
1036 | 1036 | */ |
1037 | 1037 | function give_update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) { |
1038 | 1038 |
@@ -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 | |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * @since 1.8 |
21 | 21 | */ |
22 | 22 | function give_load_wp_editor() { |
23 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
23 | + if ( ! isset($_POST['wp_editor'])) { |
|
24 | 24 | die(); |
25 | 25 | } |
26 | 26 | |
27 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
27 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
28 | 28 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
29 | 29 | |
30 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
30 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
31 | 31 | |
32 | 32 | die(); |
33 | 33 | } |
34 | 34 | |
35 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
35 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | ); |
53 | 53 | |
54 | 54 | // Get current page. |
55 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
55 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
56 | 56 | |
57 | 57 | // Bailout. |
58 | 58 | if ( |
59 | - empty( $current_page ) |
|
60 | - || empty( $_GET['_wp_http_referer'] ) |
|
61 | - || ! in_array( $current_page, $give_pages ) |
|
59 | + empty($current_page) |
|
60 | + || empty($_GET['_wp_http_referer']) |
|
61 | + || ! in_array($current_page, $give_pages) |
|
62 | 62 | ) { |
63 | 63 | return false; |
64 | 64 | } |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @since 1.8 |
70 | 70 | */ |
71 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
71 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
72 | 72 | |
73 | - if ( $redirect ) { |
|
73 | + if ($redirect) { |
|
74 | 74 | // Redirect. |
75 | 75 | wp_redirect( |
76 | 76 | remove_query_arg( |
77 | - array( '_wp_http_referer', '_wpnonce' ), |
|
78 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
77 | + array('_wp_http_referer', '_wpnonce'), |
|
78 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
85 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | /** |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function give_hide_outdated_php_notice() { |
98 | 98 | |
99 | - if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) { |
|
99 | + if ( ! isset($_POST['_give_hide_outdated_php_notices_shortly'])) { |
|
100 | 100 | give_die(); |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Transient key name. |
104 | 104 | $transient_key = '_give_hide_outdated_php_notices_shortly'; |
105 | 105 | |
106 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
106 | + if (Give_Cache::get($transient_key, true)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Hide notice for 24 hours. |
111 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
111 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
112 | 112 | |
113 | 113 | give_die(); |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | -add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' ); |
|
117 | +add_action('wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice'); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Register admin notices. |
@@ -123,27 +123,27 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function _give_register_admin_notices() { |
125 | 125 | // Bailout. |
126 | - if ( ! is_admin() ) { |
|
126 | + if ( ! is_admin()) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // Bulk action notices. |
131 | 131 | if ( |
132 | - isset( $_GET['action'] ) && |
|
133 | - ! empty( $_GET['action'] ) |
|
132 | + isset($_GET['action']) && |
|
133 | + ! empty($_GET['action']) |
|
134 | 134 | ) { |
135 | 135 | |
136 | 136 | // Add payment bulk notice. |
137 | 137 | if ( |
138 | - current_user_can( 'edit_give_payments' ) && |
|
139 | - isset( $_GET['payment'] ) && |
|
140 | - ! empty( $_GET['payment'] ) |
|
138 | + current_user_can('edit_give_payments') && |
|
139 | + isset($_GET['payment']) && |
|
140 | + ! empty($_GET['payment']) |
|
141 | 141 | ) { |
142 | - $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
142 | + $payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0; |
|
143 | 143 | |
144 | - switch ( $_GET['action'] ) { |
|
144 | + switch ($_GET['action']) { |
|
145 | 145 | case 'delete': |
146 | - Give()->notices->register_notice( array( |
|
146 | + Give()->notices->register_notice(array( |
|
147 | 147 | 'id' => 'bulk_action_delete', |
148 | 148 | 'type' => 'updated', |
149 | 149 | 'description' => sprintf( |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | ), |
156 | 156 | $payment_count ), |
157 | 157 | 'show' => true, |
158 | - ) ); |
|
158 | + )); |
|
159 | 159 | |
160 | 160 | break; |
161 | 161 | |
162 | 162 | case 'resend-receipt': |
163 | - Give()->notices->register_notice( array( |
|
163 | + Give()->notices->register_notice(array( |
|
164 | 164 | 'id' => 'bulk_action_resend_receipt', |
165 | 165 | 'type' => 'updated', |
166 | 166 | 'description' => sprintf( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $payment_count |
174 | 174 | ), |
175 | 175 | 'show' => true, |
176 | - ) ); |
|
176 | + )); |
|
177 | 177 | break; |
178 | 178 | |
179 | 179 | case 'set-status-publish' : |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | case 'set-status-cancelled' : |
186 | 186 | case 'set-status-abandoned' : |
187 | 187 | case 'set-status-preapproval' : |
188 | - Give()->notices->register_notice( array( |
|
188 | + Give()->notices->register_notice(array( |
|
189 | 189 | 'id' => 'bulk_action_status_change', |
190 | 190 | 'type' => 'updated', |
191 | 191 | 'description' => _n( |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | 'give' |
196 | 196 | ), |
197 | 197 | 'show' => true, |
198 | - ) ); |
|
198 | + )); |
|
199 | 199 | break; |
200 | 200 | }// End switch(). |
201 | 201 | }// End if(). |
@@ -203,239 +203,239 @@ discard block |
||
203 | 203 | |
204 | 204 | // Add give message notices. |
205 | 205 | $message_notices = give_get_admin_messages_key(); |
206 | - if ( ! empty( $message_notices ) ) { |
|
207 | - foreach ( $message_notices as $message_notice ) { |
|
206 | + if ( ! empty($message_notices)) { |
|
207 | + foreach ($message_notices as $message_notice) { |
|
208 | 208 | // Donation reports errors. |
209 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
210 | - switch ( $message_notice ) { |
|
209 | + if (current_user_can('view_give_reports')) { |
|
210 | + switch ($message_notice) { |
|
211 | 211 | case 'donation-deleted' : |
212 | - Give()->notices->register_notice( array( |
|
212 | + Give()->notices->register_notice(array( |
|
213 | 213 | 'id' => 'give-donation-deleted', |
214 | 214 | 'type' => 'updated', |
215 | - 'description' => __( 'The donation has been deleted.', 'give' ), |
|
215 | + 'description' => __('The donation has been deleted.', 'give'), |
|
216 | 216 | 'show' => true, |
217 | - ) ); |
|
217 | + )); |
|
218 | 218 | break; |
219 | 219 | case 'email-sent' : |
220 | - Give()->notices->register_notice( array( |
|
220 | + Give()->notices->register_notice(array( |
|
221 | 221 | 'id' => 'give-email-sent', |
222 | 222 | 'type' => 'updated', |
223 | - 'description' => __( 'The donation receipt has been resent.', 'give' ), |
|
223 | + 'description' => __('The donation receipt has been resent.', 'give'), |
|
224 | 224 | 'show' => true, |
225 | - ) ); |
|
225 | + )); |
|
226 | 226 | break; |
227 | 227 | case 'refreshed-reports' : |
228 | - Give()->notices->register_notice( array( |
|
228 | + Give()->notices->register_notice(array( |
|
229 | 229 | 'id' => 'give-refreshed-reports', |
230 | 230 | 'type' => 'updated', |
231 | - 'description' => __( 'The reports cache has been cleared.', 'give' ), |
|
231 | + 'description' => __('The reports cache has been cleared.', 'give'), |
|
232 | 232 | 'show' => true, |
233 | - ) ); |
|
233 | + )); |
|
234 | 234 | break; |
235 | 235 | case 'donation-note-deleted' : |
236 | - Give()->notices->register_notice( array( |
|
236 | + Give()->notices->register_notice(array( |
|
237 | 237 | 'id' => 'give-donation-note-deleted', |
238 | 238 | 'type' => 'updated', |
239 | - 'description' => __( 'The donation note has been deleted.', 'give' ), |
|
239 | + 'description' => __('The donation note has been deleted.', 'give'), |
|
240 | 240 | 'show' => true, |
241 | - ) ); |
|
241 | + )); |
|
242 | 242 | break; |
243 | 243 | }// End switch(). |
244 | 244 | }// End if(). |
245 | 245 | |
246 | 246 | // Give settings notices and errors. |
247 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
248 | - switch ( $message_notice ) { |
|
247 | + if (current_user_can('manage_give_settings')) { |
|
248 | + switch ($message_notice) { |
|
249 | 249 | case 'settings-imported' : |
250 | - Give()->notices->register_notice( array( |
|
250 | + Give()->notices->register_notice(array( |
|
251 | 251 | 'id' => 'give-settings-imported', |
252 | 252 | 'type' => 'updated', |
253 | - 'description' => __( 'The settings have been imported.', 'give' ), |
|
253 | + 'description' => __('The settings have been imported.', 'give'), |
|
254 | 254 | 'show' => true, |
255 | - ) ); |
|
255 | + )); |
|
256 | 256 | break; |
257 | 257 | case 'api-key-generated' : |
258 | - Give()->notices->register_notice( array( |
|
258 | + Give()->notices->register_notice(array( |
|
259 | 259 | 'id' => 'give-api-key-generated', |
260 | 260 | 'type' => 'updated', |
261 | - 'description' => __( 'API keys have been generated.', 'give' ), |
|
261 | + 'description' => __('API keys have been generated.', 'give'), |
|
262 | 262 | 'show' => true, |
263 | - ) ); |
|
263 | + )); |
|
264 | 264 | break; |
265 | 265 | case 'api-key-exists' : |
266 | - Give()->notices->register_notice( array( |
|
266 | + Give()->notices->register_notice(array( |
|
267 | 267 | 'id' => 'give-api-key-exists', |
268 | 268 | 'type' => 'updated', |
269 | - 'description' => __( 'The specified user already has API keys.', 'give' ), |
|
269 | + 'description' => __('The specified user already has API keys.', 'give'), |
|
270 | 270 | 'show' => true, |
271 | - ) ); |
|
271 | + )); |
|
272 | 272 | break; |
273 | 273 | case 'api-key-regenerated' : |
274 | - Give()->notices->register_notice( array( |
|
274 | + Give()->notices->register_notice(array( |
|
275 | 275 | 'id' => 'give-api-key-regenerated', |
276 | 276 | 'type' => 'updated', |
277 | - 'description' => __( 'API keys have been regenerated.', 'give' ), |
|
277 | + 'description' => __('API keys have been regenerated.', 'give'), |
|
278 | 278 | 'show' => true, |
279 | - ) ); |
|
279 | + )); |
|
280 | 280 | break; |
281 | 281 | case 'api-key-revoked' : |
282 | - Give()->notices->register_notice( array( |
|
282 | + Give()->notices->register_notice(array( |
|
283 | 283 | 'id' => 'give-api-key-revoked', |
284 | 284 | 'type' => 'updated', |
285 | - 'description' => __( 'API keys have been revoked.', 'give' ), |
|
285 | + 'description' => __('API keys have been revoked.', 'give'), |
|
286 | 286 | 'show' => true, |
287 | - ) ); |
|
287 | + )); |
|
288 | 288 | break; |
289 | 289 | case 'sent-test-email' : |
290 | - Give()->notices->register_notice( array( |
|
290 | + Give()->notices->register_notice(array( |
|
291 | 291 | 'id' => 'give-sent-test-email', |
292 | 292 | 'type' => 'updated', |
293 | - 'description' => __( 'The test email has been sent.', 'give' ), |
|
293 | + 'description' => __('The test email has been sent.', 'give'), |
|
294 | 294 | 'show' => true, |
295 | - ) ); |
|
295 | + )); |
|
296 | 296 | break; |
297 | 297 | case 'matched-success-failure-page': |
298 | - Give()->notices->register_notice( array( |
|
298 | + Give()->notices->register_notice(array( |
|
299 | 299 | 'id' => 'give-matched-success-failure-page', |
300 | 300 | 'type' => 'updated', |
301 | - 'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
301 | + 'description' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
302 | 302 | 'show' => true, |
303 | - ) ); |
|
303 | + )); |
|
304 | 304 | break; |
305 | 305 | }// End switch(). |
306 | 306 | }// End if(). |
307 | 307 | |
308 | 308 | // Payments errors. |
309 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
310 | - switch ( $message_notice ) { |
|
309 | + if (current_user_can('edit_give_payments')) { |
|
310 | + switch ($message_notice) { |
|
311 | 311 | case 'note-added' : |
312 | - Give()->notices->register_notice( array( |
|
312 | + Give()->notices->register_notice(array( |
|
313 | 313 | 'id' => 'give-note-added', |
314 | 314 | 'type' => 'updated', |
315 | - 'description' => __( 'The donation note has been added.', 'give' ), |
|
315 | + 'description' => __('The donation note has been added.', 'give'), |
|
316 | 316 | 'show' => true, |
317 | - ) ); |
|
317 | + )); |
|
318 | 318 | break; |
319 | 319 | case 'payment-updated' : |
320 | - Give()->notices->register_notice( array( |
|
320 | + Give()->notices->register_notice(array( |
|
321 | 321 | 'id' => 'give-payment-updated', |
322 | 322 | 'type' => 'updated', |
323 | - 'description' => __( 'The donation has been updated.', 'give' ), |
|
323 | + 'description' => __('The donation has been updated.', 'give'), |
|
324 | 324 | 'show' => true, |
325 | - ) ); |
|
325 | + )); |
|
326 | 326 | break; |
327 | 327 | }// End switch(). |
328 | 328 | }// End if(). |
329 | 329 | |
330 | 330 | // Donor Notices. |
331 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
332 | - switch ( $message_notice ) { |
|
331 | + if (current_user_can('edit_give_payments')) { |
|
332 | + switch ($message_notice) { |
|
333 | 333 | case 'donor-deleted' : |
334 | - Give()->notices->register_notice( array( |
|
334 | + Give()->notices->register_notice(array( |
|
335 | 335 | 'id' => 'give-donor-deleted', |
336 | 336 | 'type' => 'updated', |
337 | - 'description' => __( 'The selected donor(s) has been deleted.', 'give' ), |
|
337 | + 'description' => __('The selected donor(s) has been deleted.', 'give'), |
|
338 | 338 | 'show' => true, |
339 | - ) ); |
|
339 | + )); |
|
340 | 340 | break; |
341 | 341 | |
342 | 342 | case 'donor-donations-deleted' : |
343 | - Give()->notices->register_notice( array( |
|
343 | + Give()->notices->register_notice(array( |
|
344 | 344 | 'id' => 'give-donor-donations-deleted', |
345 | 345 | 'type' => 'updated', |
346 | - 'description' => __( 'The selected donor(s) and the associated donation(s) has been deleted.', 'give' ), |
|
346 | + 'description' => __('The selected donor(s) and the associated donation(s) has been deleted.', 'give'), |
|
347 | 347 | 'show' => true, |
348 | - ) ); |
|
348 | + )); |
|
349 | 349 | break; |
350 | 350 | |
351 | 351 | case 'confirm-delete-donor' : |
352 | - Give()->notices->register_notice( array( |
|
352 | + Give()->notices->register_notice(array( |
|
353 | 353 | 'id' => 'give-confirm-delete-donor', |
354 | 354 | 'type' => 'updated', |
355 | - 'description' => __( 'You must confirm to delete the selected donor(s).', 'give' ), |
|
355 | + 'description' => __('You must confirm to delete the selected donor(s).', 'give'), |
|
356 | 356 | 'show' => true, |
357 | - ) ); |
|
357 | + )); |
|
358 | 358 | break; |
359 | 359 | |
360 | 360 | case 'invalid-donor-id' : |
361 | - Give()->notices->register_notice( array( |
|
361 | + Give()->notices->register_notice(array( |
|
362 | 362 | 'id' => 'give-invalid-donor-id', |
363 | 363 | 'type' => 'updated', |
364 | - 'description' => __( 'Invalid Donor ID.', 'give' ), |
|
364 | + 'description' => __('Invalid Donor ID.', 'give'), |
|
365 | 365 | 'show' => true, |
366 | - ) ); |
|
366 | + )); |
|
367 | 367 | break; |
368 | 368 | |
369 | 369 | case 'donor-delete-failed' : |
370 | - Give()->notices->register_notice( array( |
|
370 | + Give()->notices->register_notice(array( |
|
371 | 371 | 'id' => 'give-donor-delete-failed', |
372 | 372 | 'type' => 'error', |
373 | - 'description' => __( 'Unable to delete selected donor(s).', 'give' ), |
|
373 | + 'description' => __('Unable to delete selected donor(s).', 'give'), |
|
374 | 374 | 'show' => true, |
375 | - ) ); |
|
375 | + )); |
|
376 | 376 | break; |
377 | 377 | |
378 | 378 | case 'email-added' : |
379 | - Give()->notices->register_notice( array( |
|
379 | + Give()->notices->register_notice(array( |
|
380 | 380 | 'id' => 'give-email-added', |
381 | 381 | 'type' => 'updated', |
382 | - 'description' => __( 'Donor email added.', 'give' ), |
|
382 | + 'description' => __('Donor email added.', 'give'), |
|
383 | 383 | 'show' => true, |
384 | - ) ); |
|
384 | + )); |
|
385 | 385 | break; |
386 | 386 | |
387 | 387 | case 'email-removed' : |
388 | - Give()->notices->register_notice( array( |
|
388 | + Give()->notices->register_notice(array( |
|
389 | 389 | 'id' => 'give-email-removed', |
390 | 390 | 'type' => 'updated', |
391 | - 'description' => __( 'Donor email removed.', 'give' ), |
|
391 | + 'description' => __('Donor email removed.', 'give'), |
|
392 | 392 | 'show' => true, |
393 | - ) ); |
|
393 | + )); |
|
394 | 394 | break; |
395 | 395 | |
396 | 396 | case 'email-remove-failed' : |
397 | - Give()->notices->register_notice( array( |
|
397 | + Give()->notices->register_notice(array( |
|
398 | 398 | 'id' => 'give-email-remove-failed', |
399 | 399 | 'type' => 'updated', |
400 | - 'description' => __( 'Failed to remove donor email.', 'give' ), |
|
400 | + 'description' => __('Failed to remove donor email.', 'give'), |
|
401 | 401 | 'show' => true, |
402 | - ) ); |
|
402 | + )); |
|
403 | 403 | break; |
404 | 404 | |
405 | 405 | case 'primary-email-updated' : |
406 | - Give()->notices->register_notice( array( |
|
406 | + Give()->notices->register_notice(array( |
|
407 | 407 | 'id' => 'give-primary-email-updated', |
408 | 408 | 'type' => 'updated', |
409 | - 'description' => __( 'Primary email updated for donor.', 'give' ), |
|
409 | + 'description' => __('Primary email updated for donor.', 'give'), |
|
410 | 410 | 'show' => true, |
411 | - ) ); |
|
411 | + )); |
|
412 | 412 | break; |
413 | 413 | |
414 | 414 | case 'primary-email-failed' : |
415 | - Give()->notices->register_notice( array( |
|
415 | + Give()->notices->register_notice(array( |
|
416 | 416 | 'id' => 'give-primary-email-failed', |
417 | 417 | 'type' => 'updated', |
418 | - 'description' => __( 'Failed to set primary email.', 'give' ), |
|
418 | + 'description' => __('Failed to set primary email.', 'give'), |
|
419 | 419 | 'show' => true, |
420 | - ) ); |
|
420 | + )); |
|
421 | 421 | break; |
422 | 422 | |
423 | 423 | case 'reconnect-user' : |
424 | - Give()->notices->register_notice( array( |
|
424 | + Give()->notices->register_notice(array( |
|
425 | 425 | 'id' => 'give-reconnect-user', |
426 | 426 | 'type' => 'updated', |
427 | - 'description' => __( 'User has been successfully connected with Donor.', 'give' ), |
|
427 | + 'description' => __('User has been successfully connected with Donor.', 'give'), |
|
428 | 428 | 'show' => true, |
429 | - ) ); |
|
429 | + )); |
|
430 | 430 | break; |
431 | 431 | |
432 | 432 | case 'profile-updated' : |
433 | - Give()->notices->register_notice( array( |
|
433 | + Give()->notices->register_notice(array( |
|
434 | 434 | 'id' => 'give-profile-updated', |
435 | 435 | 'type' => 'updated', |
436 | - 'description' => __( 'Donor information updated successfully.', 'give' ), |
|
436 | + 'description' => __('Donor information updated successfully.', 'give'), |
|
437 | 437 | 'show' => true, |
438 | - ) ); |
|
438 | + )); |
|
439 | 439 | break; |
440 | 440 | }// End switch(). |
441 | 441 | }// End if(). |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | -add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
|
446 | +add_action('admin_notices', '_give_register_admin_notices', - 1); |
|
447 | 447 | |
448 | 448 | |
449 | 449 | /** |
@@ -453,39 +453,38 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @return bool |
455 | 455 | */ |
456 | -function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
|
457 | - $is_test_mode = ! empty( $_POST['test_mode'] ) ? |
|
458 | - give_is_setting_enabled( $_POST['test_mode'] ) : |
|
459 | - give_is_test_mode(); |
|
456 | +function _give_show_test_mode_notice_in_admin_bar($wp_admin_bar) { |
|
457 | + $is_test_mode = ! empty($_POST['test_mode']) ? |
|
458 | + give_is_setting_enabled($_POST['test_mode']) : give_is_test_mode(); |
|
460 | 459 | |
461 | 460 | if ( |
462 | - ! current_user_can( 'view_give_reports' ) || |
|
461 | + ! current_user_can('view_give_reports') || |
|
463 | 462 | ! $is_test_mode |
464 | 463 | ) { |
465 | 464 | return false; |
466 | 465 | } |
467 | 466 | |
468 | 467 | // Add the main site admin menu item. |
469 | - $wp_admin_bar->add_menu( array( |
|
468 | + $wp_admin_bar->add_menu(array( |
|
470 | 469 | 'id' => 'give-test-notice', |
471 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
470 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
472 | 471 | 'parent' => 'top-secondary', |
473 | - 'title' => __( 'Give Test Mode Active', 'give' ), |
|
472 | + 'title' => __('Give Test Mode Active', 'give'), |
|
474 | 473 | 'meta' => array( |
475 | 474 | 'class' => 'give-test-mode-active', |
476 | 475 | ), |
477 | - ) ); |
|
476 | + )); |
|
478 | 477 | |
479 | 478 | return true; |
480 | 479 | } |
481 | 480 | |
482 | -add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |
|
481 | +add_action('admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1); |
|
483 | 482 | |
484 | 483 | /** |
485 | 484 | * Outputs the Give admin bar CSS. |
486 | 485 | */ |
487 | 486 | function _give_test_mode_notice_admin_bar_css() { |
488 | - if ( ! give_is_test_mode() ) { |
|
487 | + if ( ! give_is_test_mode()) { |
|
489 | 488 | return; |
490 | 489 | } |
491 | 490 | ?> |
@@ -503,7 +502,7 @@ discard block |
||
503 | 502 | <?php |
504 | 503 | } |
505 | 504 | |
506 | -add_action( 'admin_head', '_give_test_mode_notice_admin_bar_css' ); |
|
505 | +add_action('admin_head', '_give_test_mode_notice_admin_bar_css'); |
|
507 | 506 | |
508 | 507 | |
509 | 508 | /** |
@@ -513,12 +512,12 @@ discard block |
||
513 | 512 | */ |
514 | 513 | function give_import_page_link_callback() { |
515 | 514 | ?> |
516 | - <a href="<?php echo esc_url( give_import_page_url() ); ?>" |
|
517 | - class="page-import-action page-title-action"><?php _e( 'Import Donations', 'give' ); ?></a> |
|
515 | + <a href="<?php echo esc_url(give_import_page_url()); ?>" |
|
516 | + class="page-import-action page-title-action"><?php _e('Import Donations', 'give'); ?></a> |
|
518 | 517 | |
519 | 518 | <?php |
520 | 519 | // Check if view donation single page only. |
521 | - if ( ! empty( $_REQUEST['view'] ) && 'view-payment-details' === (string) give_clean( $_REQUEST['view'] ) && 'give-payment-history' === give_clean( $_REQUEST['page'] ) ) { |
|
520 | + if ( ! empty($_REQUEST['view']) && 'view-payment-details' === (string) give_clean($_REQUEST['view']) && 'give-payment-history' === give_clean($_REQUEST['page'])) { |
|
522 | 521 | ?> |
523 | 522 | <style type="text/css"> |
524 | 523 | .wrap #transaction-details-heading { |
@@ -529,7 +528,7 @@ discard block |
||
529 | 528 | } |
530 | 529 | } |
531 | 530 | |
532 | -add_action( 'give_payments_page_top', 'give_import_page_link_callback', 11 ); |
|
531 | +add_action('give_payments_page_top', 'give_import_page_link_callback', 11); |
|
533 | 532 | |
534 | 533 | /** |
535 | 534 | * Load donation import ajax callback |
@@ -545,9 +544,9 @@ discard block |
||
545 | 544 | Give_Cache::get_instance()->disable(); |
546 | 545 | |
547 | 546 | $import_setting = array(); |
548 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
547 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
549 | 548 | |
550 | - parse_str( $fields ); |
|
549 | + parse_str($fields); |
|
551 | 550 | |
552 | 551 | $import_setting['create_user'] = $create_user; |
553 | 552 | $import_setting['mode'] = $mode; |
@@ -557,67 +556,67 @@ discard block |
||
557 | 556 | $import_setting['dry_run'] = $dry_run; |
558 | 557 | |
559 | 558 | // Parent key id. |
560 | - $main_key = maybe_unserialize( $main_key ); |
|
561 | - |
|
562 | - $current = absint( $_REQUEST['current'] ); |
|
563 | - $total_ajax = absint( $_REQUEST['total_ajax'] ); |
|
564 | - $start = absint( $_REQUEST['start'] ); |
|
565 | - $end = absint( $_REQUEST['end'] ); |
|
566 | - $next = absint( $_REQUEST['next'] ); |
|
567 | - $total = absint( $_REQUEST['total'] ); |
|
568 | - $per_page = absint( $_REQUEST['per_page'] ); |
|
569 | - if ( empty( $delimiter ) ) { |
|
559 | + $main_key = maybe_unserialize($main_key); |
|
560 | + |
|
561 | + $current = absint($_REQUEST['current']); |
|
562 | + $total_ajax = absint($_REQUEST['total_ajax']); |
|
563 | + $start = absint($_REQUEST['start']); |
|
564 | + $end = absint($_REQUEST['end']); |
|
565 | + $next = absint($_REQUEST['next']); |
|
566 | + $total = absint($_REQUEST['total']); |
|
567 | + $per_page = absint($_REQUEST['per_page']); |
|
568 | + if (empty($delimiter)) { |
|
570 | 569 | $delimiter = ','; |
571 | 570 | } |
572 | 571 | |
573 | 572 | // Processing done here. |
574 | - $raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter ); |
|
575 | - $raw_key = maybe_unserialize( $mapto ); |
|
573 | + $raw_data = give_get_donation_data_from_csv($csv, $start, $end, $delimiter); |
|
574 | + $raw_key = maybe_unserialize($mapto); |
|
576 | 575 | $import_setting['raw_key'] = $raw_key; |
577 | 576 | |
578 | - if ( ! empty( $dry_run ) ) { |
|
579 | - $import_setting['csv_raw_data'] = give_get_donation_data_from_csv( $csv, 1, $end, $delimiter ); |
|
577 | + if ( ! empty($dry_run)) { |
|
578 | + $import_setting['csv_raw_data'] = give_get_donation_data_from_csv($csv, 1, $end, $delimiter); |
|
580 | 579 | |
581 | - $import_setting['donors_list'] = Give()->donors->get_donors( array( |
|
582 | - 'number' => - 1, |
|
583 | - 'fields' => array( 'id', 'user_id', 'email' ), |
|
584 | - ) ); |
|
580 | + $import_setting['donors_list'] = Give()->donors->get_donors(array( |
|
581 | + 'number' => -1, |
|
582 | + 'fields' => array('id', 'user_id', 'email'), |
|
583 | + )); |
|
585 | 584 | } |
586 | 585 | |
587 | 586 | // Prevent normal emails. |
588 | - remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
589 | - remove_action( 'give_insert_user', 'give_new_user_notification', 10 ); |
|
590 | - remove_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
587 | + remove_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
588 | + remove_action('give_insert_user', 'give_new_user_notification', 10); |
|
589 | + remove_action('give_insert_payment', 'give_payment_save_page_data'); |
|
591 | 590 | |
592 | 591 | $current_key = $start; |
593 | - foreach ( $raw_data as $row_data ) { |
|
592 | + foreach ($raw_data as $row_data) { |
|
594 | 593 | $import_setting['donation_key'] = $current_key; |
595 | - give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting ); |
|
596 | - $current_key ++; |
|
594 | + give_save_import_donation_to_db($raw_key, $row_data, $main_key, $import_setting); |
|
595 | + $current_key++; |
|
597 | 596 | } |
598 | 597 | |
599 | 598 | // Check if function exists or not. |
600 | - if ( function_exists( 'give_payment_save_page_data' ) ) { |
|
601 | - add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
599 | + if (function_exists('give_payment_save_page_data')) { |
|
600 | + add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
602 | 601 | } |
603 | - add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
604 | - add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 ); |
|
602 | + add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
603 | + add_action('give_complete_donation', 'give_trigger_donation_receipt', 999); |
|
605 | 604 | |
606 | - if ( $next == false ) { |
|
605 | + if ($next == false) { |
|
607 | 606 | $json_data = array( |
608 | 607 | 'success' => true, |
609 | - 'message' => __( 'All donation uploaded successfully!', 'give' ), |
|
608 | + 'message' => __('All donation uploaded successfully!', 'give'), |
|
610 | 609 | ); |
611 | 610 | } else { |
612 | 611 | $index_start = $start; |
613 | 612 | $index_end = $end; |
614 | 613 | $last = false; |
615 | 614 | $next = true; |
616 | - if ( $next ) { |
|
615 | + if ($next) { |
|
617 | 616 | $index_start = $index_start + $per_page; |
618 | - $index_end = $per_page + ( $index_start - 1 ); |
|
617 | + $index_end = $per_page + ($index_start - 1); |
|
619 | 618 | } |
620 | - if ( $index_end >= $total ) { |
|
619 | + if ($index_end >= $total) { |
|
621 | 620 | $index_end = $total; |
622 | 621 | $last = true; |
623 | 622 | } |
@@ -631,31 +630,31 @@ discard block |
||
631 | 630 | ); |
632 | 631 | } |
633 | 632 | |
634 | - $url = give_import_page_url( array( |
|
633 | + $url = give_import_page_url(array( |
|
635 | 634 | 'step' => '4', |
636 | 635 | 'importer-type' => 'import_donations', |
637 | 636 | 'csv' => $csv, |
638 | 637 | 'total' => $total, |
639 | 638 | 'delete_csv' => $import_setting['delete_csv'], |
640 | - 'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ), |
|
639 | + 'success' => (isset($json_data['success']) ? $json_data['success'] : ''), |
|
641 | 640 | 'dry_run' => $dry_run, |
642 | - ) ); |
|
641 | + )); |
|
643 | 642 | $json_data['url'] = $url; |
644 | 643 | |
645 | - $current ++; |
|
644 | + $current++; |
|
646 | 645 | $json_data['current'] = $current; |
647 | 646 | |
648 | - $percentage = ( 100 / ( $total_ajax + 1 ) ) * $current; |
|
647 | + $percentage = (100 / ($total_ajax + 1)) * $current; |
|
649 | 648 | $json_data['percentage'] = $percentage; |
650 | 649 | |
651 | 650 | // Enable Give cache |
652 | 651 | Give_Cache::get_instance()->enable(); |
653 | 652 | |
654 | - $json_data = apply_filters( 'give_import_ajax_responces', $json_data, $fields ); |
|
655 | - wp_die( json_encode( $json_data ) ); |
|
653 | + $json_data = apply_filters('give_import_ajax_responces', $json_data, $fields); |
|
654 | + wp_die(json_encode($json_data)); |
|
656 | 655 | } |
657 | 656 | |
658 | -add_action( 'wp_ajax_give_donation_import', 'give_donation_import_callback' ); |
|
657 | +add_action('wp_ajax_give_donation_import', 'give_donation_import_callback'); |
|
659 | 658 | |
660 | 659 | /** |
661 | 660 | * Load core settings import ajax callback |
@@ -667,8 +666,8 @@ discard block |
||
667 | 666 | */ |
668 | 667 | |
669 | 668 | function give_core_settings_import_callback() { |
670 | - $fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null; |
|
671 | - parse_str( $fields, $fields ); |
|
669 | + $fields = isset($_POST['fields']) ? $_POST['fields'] : null; |
|
670 | + parse_str($fields, $fields); |
|
672 | 671 | |
673 | 672 | $json_data['success'] = false; |
674 | 673 | |
@@ -683,22 +682,22 @@ discard block |
||
683 | 682 | * |
684 | 683 | * @return array $fields |
685 | 684 | */ |
686 | - $fields = (array) apply_filters( 'give_import_core_settings_fields', $fields ); |
|
685 | + $fields = (array) apply_filters('give_import_core_settings_fields', $fields); |
|
687 | 686 | |
688 | - $file_name = ( ! empty( $fields['file_name'] ) ? give_clean( $fields['file_name'] ) : false ); |
|
687 | + $file_name = ( ! empty($fields['file_name']) ? give_clean($fields['file_name']) : false); |
|
689 | 688 | |
690 | - if ( ! empty( $file_name ) ) { |
|
691 | - $type = ( ! empty( $fields['type'] ) ? give_clean( $fields['type'] ) : 'merge' ); |
|
689 | + if ( ! empty($file_name)) { |
|
690 | + $type = ( ! empty($fields['type']) ? give_clean($fields['type']) : 'merge'); |
|
692 | 691 | |
693 | 692 | // Get the json data from the file and then alter it in array format |
694 | - $json_string = give_get_core_settings_json( $file_name ); |
|
695 | - $json_to_array = json_decode( $json_string, true ); |
|
693 | + $json_string = give_get_core_settings_json($file_name); |
|
694 | + $json_to_array = json_decode($json_string, true); |
|
696 | 695 | |
697 | 696 | // get the current settign from the options table. |
698 | - $host_give_options = get_option( 'give_settings', array() ); |
|
697 | + $host_give_options = get_option('give_settings', array()); |
|
699 | 698 | |
700 | 699 | // Save old settins for backup. |
701 | - update_option( 'give_settings_old', $host_give_options ); |
|
700 | + update_option('give_settings_old', $host_give_options); |
|
702 | 701 | |
703 | 702 | /** |
704 | 703 | * Filter to Modify Core Settings that are being going to get import in options table as give settings. |
@@ -714,9 +713,9 @@ discard block |
||
714 | 713 | * |
715 | 714 | * @return array $json_to_array Setting that are being going to get imported |
716 | 715 | */ |
717 | - $json_to_array = (array) apply_filters( 'give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields ); |
|
716 | + $json_to_array = (array) apply_filters('give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields); |
|
718 | 717 | |
719 | - update_option( 'give_settings', $json_to_array ); |
|
718 | + update_option('give_settings', $json_to_array); |
|
720 | 719 | |
721 | 720 | $json_data['success'] = true; |
722 | 721 | } |
@@ -732,16 +731,16 @@ discard block |
||
732 | 731 | * |
733 | 732 | * @return array $url |
734 | 733 | */ |
735 | - $json_data['url'] = give_import_page_url( (array) apply_filters( 'give_import_core_settings_success_url', array( |
|
736 | - 'step' => ( empty( $json_data['success'] ) ? '1' : '3' ), |
|
734 | + $json_data['url'] = give_import_page_url((array) apply_filters('give_import_core_settings_success_url', array( |
|
735 | + 'step' => (empty($json_data['success']) ? '1' : '3'), |
|
737 | 736 | 'importer-type' => 'import_core_setting', |
738 | - 'success' => ( empty( $json_data['success'] ) ? '0' : '1' ), |
|
739 | - ) ) ); |
|
737 | + 'success' => (empty($json_data['success']) ? '0' : '1'), |
|
738 | + ))); |
|
740 | 739 | |
741 | - wp_send_json( $json_data ); |
|
740 | + wp_send_json($json_data); |
|
742 | 741 | } |
743 | 742 | |
744 | -add_action( 'wp_ajax_give_core_settings_import', 'give_core_settings_import_callback' ); |
|
743 | +add_action('wp_ajax_give_core_settings_import', 'give_core_settings_import_callback'); |
|
745 | 744 | |
746 | 745 | /** |
747 | 746 | * Initializes blank slate content if a list table is empty. |
@@ -753,7 +752,7 @@ discard block |
||
753 | 752 | $blank_slate->init(); |
754 | 753 | } |
755 | 754 | |
756 | -add_action( 'current_screen', 'give_blank_slate' ); |
|
755 | +add_action('current_screen', 'give_blank_slate'); |
|
757 | 756 | |
758 | 757 | /** |
759 | 758 | * Validate Fields of User Profile |
@@ -766,24 +765,24 @@ discard block |
||
766 | 765 | * |
767 | 766 | * @return mixed |
768 | 767 | */ |
769 | -function give_validate_user_profile( $errors, $update, $user ) { |
|
768 | +function give_validate_user_profile($errors, $update, $user) { |
|
770 | 769 | |
771 | - if ( ! empty( $_POST['action'] ) && ( 'adduser' === $_POST['action'] || 'createuser' === $_POST['action'] ) ) { |
|
770 | + if ( ! empty($_POST['action']) && ('adduser' === $_POST['action'] || 'createuser' === $_POST['action'])) { |
|
772 | 771 | return; |
773 | 772 | } |
774 | 773 | |
775 | - if ( ! empty( $user->ID ) ) { |
|
776 | - $donor = Give()->donors->get_donor_by( 'user_id', $user->ID ); |
|
774 | + if ( ! empty($user->ID)) { |
|
775 | + $donor = Give()->donors->get_donor_by('user_id', $user->ID); |
|
777 | 776 | |
778 | - if ( $donor ) { |
|
777 | + if ($donor) { |
|
779 | 778 | // If Donor is attached with User, then validate first name. |
780 | - if ( empty( $_POST['first_name'] ) ) { |
|
779 | + if (empty($_POST['first_name'])) { |
|
781 | 780 | $errors->add( |
782 | 781 | 'empty_first_name', |
783 | 782 | sprintf( |
784 | 783 | '<strong>%1$s:</strong> %2$s', |
785 | - __( 'ERROR', 'give' ), |
|
786 | - __( 'Please enter your first name.', 'give' ) |
|
784 | + __('ERROR', 'give'), |
|
785 | + __('Please enter your first name.', 'give') |
|
787 | 786 | ) |
788 | 787 | ); |
789 | 788 | } |
@@ -792,7 +791,7 @@ discard block |
||
792 | 791 | |
793 | 792 | } |
794 | 793 | |
795 | -add_action( 'user_profile_update_errors', 'give_validate_user_profile', 10, 3 ); |
|
794 | +add_action('user_profile_update_errors', 'give_validate_user_profile', 10, 3); |
|
796 | 795 | |
797 | 796 | /** |
798 | 797 | * Show Donor Information on User Profile Page. |
@@ -801,19 +800,19 @@ discard block |
||
801 | 800 | * |
802 | 801 | * @since 2.0 |
803 | 802 | */ |
804 | -function give_donor_information_profile_fields( $user ) { |
|
805 | - $donor = Give()->donors->get_donor_by( 'user_id', $user->ID ); |
|
803 | +function give_donor_information_profile_fields($user) { |
|
804 | + $donor = Give()->donors->get_donor_by('user_id', $user->ID); |
|
806 | 805 | |
807 | 806 | // Display Donor Information, only if donor is attached with User. |
808 | - if ( ! empty( $donor->user_id ) ) { |
|
807 | + if ( ! empty($donor->user_id)) { |
|
809 | 808 | ?> |
810 | 809 | <table class="form-table"> |
811 | 810 | <tbody> |
812 | 811 | <tr> |
813 | - <th scope="row"><?php _e( 'Donor', 'give' ); ?></th> |
|
812 | + <th scope="row"><?php _e('Donor', 'give'); ?></th> |
|
814 | 813 | <td> |
815 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
816 | - <?php _e( 'View Donor Information', 'give' ); ?> |
|
814 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
815 | + <?php _e('View Donor Information', 'give'); ?> |
|
817 | 816 | </a> |
818 | 817 | </td> |
819 | 818 | </tr> |
@@ -823,7 +822,7 @@ discard block |
||
823 | 822 | } |
824 | 823 | } |
825 | 824 | |
826 | -add_action( 'personal_options', 'give_donor_information_profile_fields' ); |
|
825 | +add_action('personal_options', 'give_donor_information_profile_fields'); |
|
827 | 826 | /** |
828 | 827 | * Get Array of WP User Roles. |
829 | 828 | * |
@@ -835,8 +834,8 @@ discard block |
||
835 | 834 | $user_roles = array(); |
836 | 835 | |
837 | 836 | // Loop through User Roles. |
838 | - foreach ( get_editable_roles() as $role_name => $role_info ) : |
|
839 | - $user_roles[ $role_name ] = $role_info['name']; |
|
837 | + foreach (get_editable_roles() as $role_name => $role_info) : |
|
838 | + $user_roles[$role_name] = $role_info['name']; |
|
840 | 839 | endforeach; |
841 | 840 | |
842 | 841 | return $user_roles; |
@@ -853,48 +852,46 @@ discard block |
||
853 | 852 | function __give_ajax_donor_manage_addresses() { |
854 | 853 | // Bailout. |
855 | 854 | if ( |
856 | - empty( $_POST['form'] ) || |
|
857 | - empty( $_POST['donorID'] ) |
|
855 | + empty($_POST['form']) || |
|
856 | + empty($_POST['donorID']) |
|
858 | 857 | ) { |
859 | - wp_send_json_error( array( |
|
858 | + wp_send_json_error(array( |
|
860 | 859 | 'error' => 1, |
861 | - ) ); |
|
860 | + )); |
|
862 | 861 | } |
863 | 862 | |
864 | - $post = give_clean( wp_parse_args( $_POST ) ); |
|
865 | - $donorID = absint( $post['donorID'] ); |
|
866 | - $form_data = give_clean( wp_parse_args( $post['form'] ) ); |
|
867 | - $is_multi_address_type = ( 'billing' === $form_data['address-id'] || false !== strpos( $form_data['address-id'], '_' ) ); |
|
868 | - $address_type = false !== strpos( $form_data['address-id'], '_' ) ? |
|
869 | - array_shift( explode( '_', $form_data['address-id'] ) ) : |
|
870 | - $form_data['address-id']; |
|
871 | - $address_id = false !== strpos( $form_data['address-id'], '_' ) ? |
|
872 | - array_pop( explode( '_', $form_data['address-id'] ) ) : |
|
873 | - null; |
|
863 | + $post = give_clean(wp_parse_args($_POST)); |
|
864 | + $donorID = absint($post['donorID']); |
|
865 | + $form_data = give_clean(wp_parse_args($post['form'])); |
|
866 | + $is_multi_address_type = ('billing' === $form_data['address-id'] || false !== strpos($form_data['address-id'], '_')); |
|
867 | + $address_type = false !== strpos($form_data['address-id'], '_') ? |
|
868 | + array_shift(explode('_', $form_data['address-id'])) : $form_data['address-id']; |
|
869 | + $address_id = false !== strpos($form_data['address-id'], '_') ? |
|
870 | + array_pop(explode('_', $form_data['address-id'])) : null; |
|
874 | 871 | $response_data = array( |
875 | 872 | 'action' => $form_data['address-action'], |
876 | 873 | 'id' => $form_data['address-id'], |
877 | 874 | ); |
878 | 875 | |
879 | 876 | // Security check. |
880 | - if ( ! wp_verify_nonce( $form_data['_wpnonce'], 'give-manage-donor-addresses' ) ) { |
|
881 | - wp_send_json_error( array( |
|
877 | + if ( ! wp_verify_nonce($form_data['_wpnonce'], 'give-manage-donor-addresses')) { |
|
878 | + wp_send_json_error(array( |
|
882 | 879 | 'error' => 1, |
883 | 880 | 'error_msg' => wp_sprintf( |
884 | 881 | '<div class="notice notice-error"><p>%s</p></div>', |
885 | - __( 'Error: Security issue.', 'give' ) |
|
882 | + __('Error: Security issue.', 'give') |
|
886 | 883 | ), |
887 | 884 | ) |
888 | 885 | ); |
889 | 886 | } |
890 | 887 | |
891 | - $donor = new Give_Donor( $donorID ); |
|
888 | + $donor = new Give_Donor($donorID); |
|
892 | 889 | |
893 | 890 | // Verify donor. |
894 | - if ( ! $donor->id ) { |
|
895 | - wp_send_json_error( array( |
|
891 | + if ( ! $donor->id) { |
|
892 | + wp_send_json_error(array( |
|
896 | 893 | 'error' => 3, |
897 | - ) ); |
|
894 | + )); |
|
898 | 895 | } |
899 | 896 | |
900 | 897 | // Unset all data except address. |
@@ -905,59 +902,57 @@ discard block |
||
905 | 902 | ); |
906 | 903 | |
907 | 904 | // Process action. |
908 | - switch ( $response_data['action'] ) { |
|
905 | + switch ($response_data['action']) { |
|
909 | 906 | |
910 | 907 | case 'add': |
911 | - if ( ! $donor->add_address( "{$address_type}[]", $form_data ) ) { |
|
912 | - wp_send_json_error( array( |
|
908 | + if ( ! $donor->add_address("{$address_type}[]", $form_data)) { |
|
909 | + wp_send_json_error(array( |
|
913 | 910 | 'error' => 1, |
914 | 911 | 'error_msg' => wp_sprintf( |
915 | 912 | '<div class="notice notice-error"><p>%s</p></div>', |
916 | - __( 'Error: Unable to save the address. Please check if address already exist.', 'give' ) |
|
913 | + __('Error: Unable to save the address. Please check if address already exist.', 'give') |
|
917 | 914 | ), |
918 | 915 | ) |
919 | 916 | ); |
920 | 917 | } |
921 | 918 | |
922 | - $total_addresses = count( $donor->address[ $address_type ] ); |
|
919 | + $total_addresses = count($donor->address[$address_type]); |
|
923 | 920 | |
924 | 921 | $address_index = $is_multi_address_type ? |
925 | - $total_addresses - 1 : |
|
926 | - $address_type; |
|
922 | + $total_addresses - 1 : $address_type; |
|
927 | 923 | |
928 | - $array_keys = array_keys( $donor->address[ $address_type ] ); |
|
924 | + $array_keys = array_keys($donor->address[$address_type]); |
|
929 | 925 | |
930 | 926 | $address_id = $is_multi_address_type ? |
931 | - end( $array_keys ) : |
|
932 | - $address_type; |
|
927 | + end($array_keys) : $address_type; |
|
933 | 928 | |
934 | 929 | $response_data['address_html'] = __give_get_format_address( |
935 | - end( $donor->address['billing'] ), |
|
930 | + end($donor->address['billing']), |
|
936 | 931 | array( |
937 | 932 | // We can add only billing address from donor screen. |
938 | 933 | 'type' => 'billing', |
939 | 934 | 'id' => $address_id, |
940 | - 'index' => ++ $address_index, |
|
935 | + 'index' => ++$address_index, |
|
941 | 936 | ) |
942 | 937 | ); |
943 | - $response_data['success_msg'] = wp_sprintf( |
|
938 | + $response_data['success_msg'] = wp_sprintf( |
|
944 | 939 | '<div class="notice updated"><p>%s</p></div>', |
945 | - __( 'Successfully added a new address to the donor.', 'give' ) |
|
940 | + __('Successfully added a new address to the donor.', 'give') |
|
946 | 941 | ); |
947 | 942 | |
948 | - if ( $is_multi_address_type ) { |
|
943 | + if ($is_multi_address_type) { |
|
949 | 944 | $response_data['id'] = "{$response_data['id']}_{$address_index}"; |
950 | 945 | } |
951 | 946 | |
952 | 947 | break; |
953 | 948 | |
954 | 949 | case 'remove': |
955 | - if ( ! $donor->remove_address( $response_data['id'] ) ) { |
|
956 | - wp_send_json_error( array( |
|
950 | + if ( ! $donor->remove_address($response_data['id'])) { |
|
951 | + wp_send_json_error(array( |
|
957 | 952 | 'error' => 2, |
958 | 953 | 'error_msg' => wp_sprintf( |
959 | 954 | '<div class="notice notice-error"><p>%s</p></div>', |
960 | - __( 'Error: Unable to delete address.', 'give' ) |
|
955 | + __('Error: Unable to delete address.', 'give') |
|
961 | 956 | ), |
962 | 957 | ) |
963 | 958 | ); |
@@ -965,18 +960,18 @@ discard block |
||
965 | 960 | |
966 | 961 | $response_data['success_msg'] = wp_sprintf( |
967 | 962 | '<div class="notice updated"><p>%s</p></div>', |
968 | - __( 'Successfully removed a address of donor.', 'give' ) |
|
963 | + __('Successfully removed a address of donor.', 'give') |
|
969 | 964 | ); |
970 | 965 | |
971 | 966 | break; |
972 | 967 | |
973 | 968 | case 'update': |
974 | - if ( ! $donor->update_address( $response_data['id'], $form_data ) ) { |
|
975 | - wp_send_json_error( array( |
|
969 | + if ( ! $donor->update_address($response_data['id'], $form_data)) { |
|
970 | + wp_send_json_error(array( |
|
976 | 971 | 'error' => 3, |
977 | 972 | 'error_msg' => wp_sprintf( |
978 | 973 | '<div class="notice notice-error"><p>%s</p></div>', |
979 | - __( 'Error: Unable to update address. Please check if address already exist.', 'give' ) |
|
974 | + __('Error: Unable to update address. Please check if address already exist.', 'give') |
|
980 | 975 | ), |
981 | 976 | ) |
982 | 977 | ); |
@@ -984,26 +979,25 @@ discard block |
||
984 | 979 | |
985 | 980 | $response_data['address_html'] = __give_get_format_address( |
986 | 981 | $is_multi_address_type ? |
987 | - $donor->address[ $address_type ][ $address_id ] : |
|
988 | - $donor->address[ $address_type ], |
|
982 | + $donor->address[$address_type][$address_id] : $donor->address[$address_type], |
|
989 | 983 | array( |
990 | 984 | 'type' => $address_type, |
991 | 985 | 'id' => $address_id, |
992 | 986 | 'index' => $address_id, |
993 | 987 | ) |
994 | 988 | ); |
995 | - $response_data['success_msg'] = wp_sprintf( |
|
989 | + $response_data['success_msg'] = wp_sprintf( |
|
996 | 990 | '<div class="notice updated"><p>%s</p></div>', |
997 | - __( 'Successfully updated a address of donor', 'give' ) |
|
991 | + __('Successfully updated a address of donor', 'give') |
|
998 | 992 | ); |
999 | 993 | |
1000 | 994 | break; |
1001 | 995 | }// End switch(). |
1002 | 996 | |
1003 | - wp_send_json_success( $response_data ); |
|
997 | + wp_send_json_success($response_data); |
|
1004 | 998 | } |
1005 | 999 | |
1006 | -add_action( 'wp_ajax_donor_manage_addresses', '__give_ajax_donor_manage_addresses' ); |
|
1000 | +add_action('wp_ajax_donor_manage_addresses', '__give_ajax_donor_manage_addresses'); |
|
1007 | 1001 | |
1008 | 1002 | /** |
1009 | 1003 | * Admin donor billing address label |
@@ -1014,13 +1008,13 @@ discard block |
||
1014 | 1008 | * |
1015 | 1009 | * @return string |
1016 | 1010 | */ |
1017 | -function __give_donor_billing_address_label( $address_label ) { |
|
1018 | - $address_label = __( 'Billing Address', 'give' ); |
|
1011 | +function __give_donor_billing_address_label($address_label) { |
|
1012 | + $address_label = __('Billing Address', 'give'); |
|
1019 | 1013 | |
1020 | 1014 | return $address_label; |
1021 | 1015 | } |
1022 | 1016 | |
1023 | -add_action( 'give_donor_billing_address_label', '__give_donor_billing_address_label' ); |
|
1017 | +add_action('give_donor_billing_address_label', '__give_donor_billing_address_label'); |
|
1024 | 1018 | |
1025 | 1019 | /** |
1026 | 1020 | * Admin donor personal address label |
@@ -1031,13 +1025,13 @@ discard block |
||
1031 | 1025 | * |
1032 | 1026 | * @return string |
1033 | 1027 | */ |
1034 | -function __give_donor_personal_address_label( $address_label ) { |
|
1035 | - $address_label = __( 'Personal Address', 'give' ); |
|
1028 | +function __give_donor_personal_address_label($address_label) { |
|
1029 | + $address_label = __('Personal Address', 'give'); |
|
1036 | 1030 | |
1037 | 1031 | return $address_label; |
1038 | 1032 | } |
1039 | 1033 | |
1040 | -add_action( 'give_donor_personal_address_label', '__give_donor_personal_address_label' ); |
|
1034 | +add_action('give_donor_personal_address_label', '__give_donor_personal_address_label'); |
|
1041 | 1035 | |
1042 | 1036 | /** |
1043 | 1037 | * Update Donor Information when User Profile is updated from admin. |
@@ -1050,34 +1044,34 @@ discard block |
||
1050 | 1044 | * |
1051 | 1045 | * @return bool |
1052 | 1046 | */ |
1053 | -function give_update_donor_name_on_user_update( $user_id = 0 ) { |
|
1047 | +function give_update_donor_name_on_user_update($user_id = 0) { |
|
1054 | 1048 | |
1055 | - if ( current_user_can( 'edit_user', $user_id ) ) { |
|
1049 | + if (current_user_can('edit_user', $user_id)) { |
|
1056 | 1050 | |
1057 | - $donor = new Give_Donor( $user_id, true ); |
|
1051 | + $donor = new Give_Donor($user_id, true); |
|
1058 | 1052 | |
1059 | 1053 | // Bailout, if donor doesn't exists. |
1060 | - if ( ! $donor ) { |
|
1054 | + if ( ! $donor) { |
|
1061 | 1055 | return false; |
1062 | 1056 | } |
1063 | 1057 | |
1064 | 1058 | // Get User First name and Last name. |
1065 | - $first_name = ( $_POST['first_name'] ) ? give_clean( $_POST['first_name'] ) : get_user_meta( $user_id, 'first_name', true ); |
|
1066 | - $last_name = ( $_POST['last_name'] ) ? give_clean( $_POST['last_name'] ) : get_user_meta( $user_id, 'last_name', true ); |
|
1067 | - $full_name = strip_tags( wp_unslash( trim( "{$first_name} {$last_name}" ) ) ); |
|
1059 | + $first_name = ($_POST['first_name']) ? give_clean($_POST['first_name']) : get_user_meta($user_id, 'first_name', true); |
|
1060 | + $last_name = ($_POST['last_name']) ? give_clean($_POST['last_name']) : get_user_meta($user_id, 'last_name', true); |
|
1061 | + $full_name = strip_tags(wp_unslash(trim("{$first_name} {$last_name}"))); |
|
1068 | 1062 | |
1069 | 1063 | // Assign User First name and Last name to Donor. |
1070 | - Give()->donors->update( $donor->id, array( |
|
1064 | + Give()->donors->update($donor->id, array( |
|
1071 | 1065 | 'name' => $full_name, |
1072 | - ) ); |
|
1073 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name ); |
|
1074 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name ); |
|
1066 | + )); |
|
1067 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name); |
|
1068 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name); |
|
1075 | 1069 | |
1076 | 1070 | } |
1077 | 1071 | } |
1078 | 1072 | |
1079 | -add_action( 'edit_user_profile_update', 'give_update_donor_name_on_user_update', 10 ); |
|
1080 | -add_action( 'personal_options_update', 'give_update_donor_name_on_user_update', 10 ); |
|
1073 | +add_action('edit_user_profile_update', 'give_update_donor_name_on_user_update', 10); |
|
1074 | +add_action('personal_options_update', 'give_update_donor_name_on_user_update', 10); |
|
1081 | 1075 | |
1082 | 1076 | |
1083 | 1077 | /** |
@@ -1092,31 +1086,31 @@ discard block |
||
1092 | 1086 | * |
1093 | 1087 | * @return bool |
1094 | 1088 | */ |
1095 | -function give_update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) { |
|
1089 | +function give_update_donor_email_on_user_update($user_id = 0, $old_user_data = false) { |
|
1096 | 1090 | |
1097 | - $donor = new Give_Donor( $user_id, true ); |
|
1091 | + $donor = new Give_Donor($user_id, true); |
|
1098 | 1092 | |
1099 | - if ( ! $donor ) { |
|
1093 | + if ( ! $donor) { |
|
1100 | 1094 | return false; |
1101 | 1095 | } |
1102 | 1096 | |
1103 | - $user = get_userdata( $user_id ); |
|
1097 | + $user = get_userdata($user_id); |
|
1104 | 1098 | |
1105 | - if ( ! empty( $user ) && $user->user_email !== $donor->email ) { |
|
1099 | + if ( ! empty($user) && $user->user_email !== $donor->email) { |
|
1106 | 1100 | |
1107 | - $success = Give()->donors->update( $donor->id, array( |
|
1101 | + $success = Give()->donors->update($donor->id, array( |
|
1108 | 1102 | 'email' => $user->user_email, |
1109 | - ) ); |
|
1103 | + )); |
|
1110 | 1104 | |
1111 | - if ( $success ) { |
|
1105 | + if ($success) { |
|
1112 | 1106 | // Update some payment meta if we need to |
1113 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
1107 | + $payments_array = explode(',', $donor->payment_ids); |
|
1114 | 1108 | |
1115 | - if ( ! empty( $payments_array ) ) { |
|
1109 | + if ( ! empty($payments_array)) { |
|
1116 | 1110 | |
1117 | - foreach ( $payments_array as $payment_id ) { |
|
1111 | + foreach ($payments_array as $payment_id) { |
|
1118 | 1112 | |
1119 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
1113 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
1120 | 1114 | |
1121 | 1115 | } |
1122 | 1116 | } |
@@ -1129,14 +1123,14 @@ discard block |
||
1129 | 1123 | * @param WP_User $user WordPress User object. |
1130 | 1124 | * @param Give_Donor $donor Give donor object. |
1131 | 1125 | */ |
1132 | - do_action( 'give_update_donor_email_on_user_update', $user, $donor ); |
|
1126 | + do_action('give_update_donor_email_on_user_update', $user, $donor); |
|
1133 | 1127 | |
1134 | 1128 | } |
1135 | 1129 | } |
1136 | 1130 | |
1137 | 1131 | } |
1138 | 1132 | |
1139 | -add_action( 'profile_update', 'give_update_donor_email_on_user_update', 10, 2 ); |
|
1133 | +add_action('profile_update', 'give_update_donor_email_on_user_update', 10, 2); |
|
1140 | 1134 | |
1141 | 1135 | |
1142 | 1136 | /** |
@@ -1145,15 +1139,15 @@ discard block |
||
1145 | 1139 | function give_cache_flush() { |
1146 | 1140 | $result = Give_Cache::flush_cache(); |
1147 | 1141 | |
1148 | - if ( $result ) { |
|
1149 | - wp_send_json_success( array( |
|
1150 | - 'message' => __( 'Cache flushed successfully.', 'give' ), |
|
1142 | + if ($result) { |
|
1143 | + wp_send_json_success(array( |
|
1144 | + 'message' => __('Cache flushed successfully.', 'give'), |
|
1151 | 1145 | )); |
1152 | 1146 | } else { |
1153 | - wp_send_json_error( array( |
|
1154 | - 'message' => __( 'An error occured while flushing the cache.', 'give' ), |
|
1147 | + wp_send_json_error(array( |
|
1148 | + 'message' => __('An error occured while flushing the cache.', 'give'), |
|
1155 | 1149 | )); |
1156 | 1150 | } |
1157 | 1151 | } |
1158 | 1152 | |
1159 | -add_action( 'wp_ajax_give_cache_flush', 'give_cache_flush', 10, 0 ); |
|
1153 | +add_action('wp_ajax_give_cache_flush', 'give_cache_flush', 10, 0); |
@@ -89,7 +89,7 @@ |
||
89 | 89 | * Connect and Reconnect Donor with User profile. |
90 | 90 | * @todo $address is unnecessary param because we are store address to user. |
91 | 91 | * |
92 | - * @param object $donor Donor Object. |
|
92 | + * @param Give_Donor $donor Donor Object. |
|
93 | 93 | * @param array $donor_data Donor Post Variables. |
94 | 94 | * @param array $address Address Information. |
95 | 95 | * |
@@ -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 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array The altered list of views. |
25 | 25 | */ |
26 | -function give_register_default_donor_views( $views ) { |
|
26 | +function give_register_default_donor_views($views) { |
|
27 | 27 | |
28 | 28 | $default_views = array( |
29 | 29 | 'overview' => 'give_donor_view', |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | 'notes' => 'give_donor_notes_view', |
32 | 32 | ); |
33 | 33 | |
34 | - return array_merge( $views, $default_views ); |
|
34 | + return array_merge($views, $default_views); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 ); |
|
38 | +add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register a tab for the single donor view. |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array The altered list of tabs |
48 | 48 | */ |
49 | -function give_register_default_donor_tabs( $tabs ) { |
|
49 | +function give_register_default_donor_tabs($tabs) { |
|
50 | 50 | |
51 | 51 | $default_tabs = array( |
52 | 52 | 'overview' => array( |
53 | 53 | 'dashicon' => 'dashicons-admin-users', |
54 | - 'title' => __( 'Donor Profile', 'give' ), |
|
54 | + 'title' => __('Donor Profile', 'give'), |
|
55 | 55 | ), |
56 | 56 | 'notes' => array( |
57 | 57 | 'dashicon' => 'dashicons-admin-comments', |
58 | - 'title' => __( 'Donor Notes', 'give' ), |
|
58 | + 'title' => __('Donor Notes', 'give'), |
|
59 | 59 | ), |
60 | 60 | ); |
61 | 61 | |
62 | - return array_merge( $tabs, $default_tabs ); |
|
62 | + return array_merge($tabs, $default_tabs); |
|
63 | 63 | } |
64 | 64 | |
65 | -add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 ); |
|
65 | +add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Register the Delete icon as late as possible so it's at the bottom. |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array The altered list of tabs, with 'delete' at the bottom. |
75 | 75 | */ |
76 | -function give_register_delete_donor_tab( $tabs ) { |
|
76 | +function give_register_delete_donor_tab($tabs) { |
|
77 | 77 | |
78 | 78 | $tabs['delete'] = array( |
79 | 79 | 'dashicon' => 'dashicons-trash', |
80 | - 'title' => __( 'Delete Donor', 'give' ), |
|
80 | + 'title' => __('Delete Donor', 'give'), |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | return $tabs; |
84 | 84 | } |
85 | 85 | |
86 | -add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 ); |
|
86 | +add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Connect and Reconnect Donor with User profile. |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return array |
99 | 99 | */ |
100 | -function give_connect_user_donor_profile( $donor, $donor_data, $address ) { |
|
100 | +function give_connect_user_donor_profile($donor, $donor_data, $address) { |
|
101 | 101 | |
102 | 102 | $donor_id = $donor->id; |
103 | 103 | $previous_user_id = $donor->user_id; |
@@ -111,31 +111,31 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @since 1.0 |
113 | 113 | */ |
114 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
114 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
115 | 115 | |
116 | 116 | $output = array(); |
117 | 117 | |
118 | - if ( $donor->update( $donor_data ) ) { |
|
118 | + if ($donor->update($donor_data)) { |
|
119 | 119 | |
120 | 120 | // Create and Update Donor First Name and Last Name in Meta Fields. |
121 | - $donor->update_meta( '_give_donor_first_name', $donor_data['first_name'] ); |
|
122 | - $donor->update_meta( '_give_donor_last_name', $donor_data['last_name'] ); |
|
121 | + $donor->update_meta('_give_donor_first_name', $donor_data['first_name']); |
|
122 | + $donor->update_meta('_give_donor_last_name', $donor_data['last_name']); |
|
123 | 123 | |
124 | 124 | // Fetch disconnected user id, if exists. |
125 | - $disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true ); |
|
125 | + $disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true); |
|
126 | 126 | |
127 | 127 | // Flag User and Donor Disconnection. |
128 | - delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' ); |
|
128 | + delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected'); |
|
129 | 129 | |
130 | 130 | // Check whether the disconnected user id and the reconnected user id are same or not. |
131 | 131 | // If both are same then delete user id store in donor meta. |
132 | - if( $donor_data['user_id'] === $disconnected_user_id ) { |
|
133 | - delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' ); |
|
134 | - $donor->delete_meta( '_give_disconnected_user_id' ); |
|
132 | + if ($donor_data['user_id'] === $disconnected_user_id) { |
|
133 | + delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id'); |
|
134 | + $donor->delete_meta('_give_disconnected_user_id'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $output['success'] = true; |
138 | - $donor_data = array_merge( $donor_data, $address ); |
|
138 | + $donor_data = array_merge($donor_data, $address); |
|
139 | 139 | $output['customer_info'] = $donor_data; |
140 | 140 | |
141 | 141 | } else { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @since 1.0 |
154 | 154 | */ |
155 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
155 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
156 | 156 | |
157 | 157 | |
158 | 158 | return $output; |
@@ -600,7 +600,7 @@ |
||
600 | 600 | * |
601 | 601 | * @param int $form_id |
602 | 602 | * |
603 | - * @return array|string |
|
603 | + * @return string |
|
604 | 604 | */ |
605 | 605 | public function get_preview_email_recipient( $form_id = null ) { |
606 | 606 | $recipients = $this->get_recipient( $form_id ); |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | -if ( ! class_exists( 'Give_Email_Notification' ) ) : |
|
19 | +if ( ! class_exists('Give_Email_Notification')) : |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Give_Email_Notification |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return Give_Email_Notification |
96 | 96 | */ |
97 | - public static function get_instance( $email_notification_id = '' ) { |
|
97 | + public static function get_instance($email_notification_id = '') { |
|
98 | 98 | $class = ''; |
99 | 99 | |
100 | - if ( ! empty( $email_notification_id ) ) { |
|
100 | + if ( ! empty($email_notification_id)) { |
|
101 | 101 | /* @var Give_Email_Notification $class */ |
102 | - foreach ( self::$singleton as $class ) { |
|
103 | - if ( $email_notification_id === $class->config['id'] ) { |
|
104 | - $class = get_class( $class ); |
|
102 | + foreach (self::$singleton as $class) { |
|
103 | + if ($email_notification_id === $class->config['id']) { |
|
104 | + $class = get_class($class); |
|
105 | 105 | break; |
106 | 106 | } |
107 | 107 | } |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | $class = get_called_class(); |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! empty( $class ) && ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) ) { |
|
113 | - self::$singleton[ $class ] = new $class(); |
|
112 | + if ( ! empty($class) && ( ! array_key_exists($class, self::$singleton) || is_null(self::$singleton[$class]))) { |
|
113 | + self::$singleton[$class] = new $class(); |
|
114 | 114 | } |
115 | 115 | |
116 | - return ( isset( self::$singleton[ $class ] ) ? self::$singleton[ $class ] : null ); |
|
116 | + return (isset(self::$singleton[$class]) ? self::$singleton[$class] : null); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -124,35 +124,35 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param array $config |
126 | 126 | */ |
127 | - public function load( $config ) { |
|
127 | + public function load($config) { |
|
128 | 128 | // Set notification configuration. |
129 | - $this->config = wp_parse_args( $config, $this->config ); |
|
129 | + $this->config = wp_parse_args($config, $this->config); |
|
130 | 130 | |
131 | 131 | // Set email preview header status. |
132 | 132 | $this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false; |
133 | 133 | |
134 | 134 | // Set email content type |
135 | - $this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array( |
|
135 | + $this->config['content_type'] = empty($this->config['content_type']) || ! in_array($this->config['content_type'], array( |
|
136 | 136 | 'text/html', |
137 | 137 | 'text/plain', |
138 | - ) ) |
|
138 | + )) |
|
139 | 139 | ? Give()->emails->get_content_type() |
140 | 140 | : $this->config['content_type']; |
141 | - $this->config['content_type'] = give_get_option( Give_Email_Setting_Field::get_prefix( $this ) . 'email_content_type', $this->config['content_type'] ); |
|
141 | + $this->config['content_type'] = give_get_option(Give_Email_Setting_Field::get_prefix($this).'email_content_type', $this->config['content_type']); |
|
142 | 142 | |
143 | 143 | // Set email template type. |
144 | - $this->config['email_template'] = empty( $this->config['email_template'] ) |
|
145 | - ? give_get_option( 'email_template' ) |
|
144 | + $this->config['email_template'] = empty($this->config['email_template']) |
|
145 | + ? give_get_option('email_template') |
|
146 | 146 | : $this->config['email_template']; |
147 | 147 | |
148 | 148 | // Set recipient group name. |
149 | - $this->config['recipient_group_name'] = empty( $this->config['recipient_group_name'] ) |
|
150 | - ? ( ! Give_Email_Notification_Util::has_recipient_field( $this ) ? __( 'Donor', 'give' ) : '' ) |
|
149 | + $this->config['recipient_group_name'] = empty($this->config['recipient_group_name']) |
|
150 | + ? ( ! Give_Email_Notification_Util::has_recipient_field($this) ? __('Donor', 'give') : '') |
|
151 | 151 | : $this->config['recipient_group_name']; |
152 | 152 | |
153 | 153 | // Non notification status editable notice. |
154 | - $this->config['notices']['non-notification-status-editable'] = empty( $this->config['notices']['non-notification-status-editable'] ) |
|
155 | - ? __( 'You can not edit notification status from here.', 'give' ) |
|
154 | + $this->config['notices']['non-notification-status-editable'] = empty($this->config['notices']['non-notification-status-editable']) |
|
155 | + ? __('You can not edit notification status from here.', 'give') |
|
156 | 156 | : $this->config['notices']['non-notification-status-editable']; |
157 | 157 | |
158 | 158 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param array Give_Email_Notification::config |
164 | 164 | * @param Give_Email_Notification $this |
165 | 165 | */ |
166 | - $this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this ); |
|
166 | + $this->config = apply_filters('give_email_api_notification_config', $this->config, $this); |
|
167 | 167 | |
168 | 168 | // Setup filters. |
169 | 169 | $this->setup_filters(); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | private function setup_filters() { |
180 | 180 | // Apply filter only for current email notification section. |
181 | - if ( give_get_current_setting_section() === $this->config['id'] ) { |
|
181 | + if (give_get_current_setting_section() === $this->config['id']) { |
|
182 | 182 | // Initialize email context for email notification. |
183 | 183 | $this->config['email_tag_context'] = apply_filters( |
184 | 184 | "give_{$this->config['id']}_email_tag_context", |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Setup setting fields. |
191 | - if( $this->config['show_on_emails_setting_page'] ) { |
|
192 | - add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 ); |
|
191 | + if ($this->config['show_on_emails_setting_page']) { |
|
192 | + add_filter('give_get_settings_emails', array($this, 'add_setting_fields'), 10, 2); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( $this->config['form_metabox_setting'] && ! empty( $this->config['form_metabox_id'] ) ) { |
|
195 | + if ($this->config['form_metabox_setting'] && ! empty($this->config['form_metabox_id'])) { |
|
196 | 196 | add_filter( |
197 | 197 | $this->config['form_metabox_id'], |
198 | - array( $this, 'add_metabox_setting_field' ), |
|
198 | + array($this, 'add_metabox_setting_field'), |
|
199 | 199 | 10, |
200 | 200 | 2 |
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
204 | - if( $this->config['has_recipient_field'] ) { |
|
204 | + if ($this->config['has_recipient_field']) { |
|
205 | 205 | add_action( |
206 | 206 | "give_save__give_{$this->config['id']}_recipient", |
207 | - array( $this, 'validate_form_recipient_field_value' ), |
|
207 | + array($this, 'validate_form_recipient_field_value'), |
|
208 | 208 | 10, |
209 | 209 | 3 |
210 | 210 | ); |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return array |
255 | 255 | */ |
256 | - public function add_section( $sections ) { |
|
257 | - $sections[ $this->config['id'] ] = $this->config['label']; |
|
256 | + public function add_section($sections) { |
|
257 | + $sections[$this->config['id']] = $this->config['label']; |
|
258 | 258 | |
259 | 259 | return $sections; |
260 | 260 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return bool |
270 | 270 | */ |
271 | - public function hide_section( $hide_section ) { |
|
271 | + public function hide_section($hide_section) { |
|
272 | 272 | $hide_section = true; |
273 | 273 | |
274 | 274 | return $hide_section; |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - public function add_setting_fields( $settings ) { |
|
288 | - if ( $this->config['id'] === give_get_current_setting_section() ) { |
|
287 | + public function add_setting_fields($settings) { |
|
288 | + if ($this->config['id'] === give_get_current_setting_section()) { |
|
289 | 289 | $settings = $this->get_setting_fields(); |
290 | 290 | } |
291 | 291 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return array |
305 | 305 | */ |
306 | - public function get_setting_fields( $form_id = null ) { |
|
307 | - return Give_Email_Setting_Field::get_setting_fields( $this, $form_id ); |
|
306 | + public function get_setting_fields($form_id = null) { |
|
307 | + return Give_Email_Setting_Field::get_setting_fields($this, $form_id); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return array |
321 | 321 | */ |
322 | - public function add_metabox_setting_field( $settings, $form_id ) { |
|
322 | + public function add_metabox_setting_field($settings, $form_id) { |
|
323 | 323 | |
324 | - if( Give_Email_Notification_Util::is_email_notification_active( $this ) ) { |
|
324 | + if (Give_Email_Notification_Util::is_email_notification_active($this)) { |
|
325 | 325 | $settings[] = array( |
326 | 326 | 'id' => $this->config['id'], |
327 | 327 | 'title' => $this->config['label'], |
328 | - 'fields' => $this->get_setting_fields( $form_id ), |
|
328 | + 'fields' => $this->get_setting_fields($form_id), |
|
329 | 329 | ); |
330 | 330 | } |
331 | 331 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @return array |
345 | 345 | */ |
346 | - public function get_extra_setting_fields( $form_id = null ) { |
|
346 | + public function get_extra_setting_fields($form_id = null) { |
|
347 | 347 | return array(); |
348 | 348 | } |
349 | 349 | |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return string|array |
362 | 362 | */ |
363 | - public function get_recipient( $form_id = null ) { |
|
364 | - if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) { |
|
363 | + public function get_recipient($form_id = null) { |
|
364 | + if (empty($this->recipient_email) && $this->config['has_recipient_field']) { |
|
365 | 365 | $this->recipient_email = Give_Email_Notification_Util::get_value( |
366 | 366 | $this, |
367 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'recipient', |
|
367 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'recipient', |
|
368 | 368 | $form_id |
369 | 369 | ); |
370 | 370 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @since 1.0 |
376 | 376 | * @deprecated 2.0 |
377 | 377 | */ |
378 | - $this->recipient_email = apply_filters( 'give_admin_notice_emails', $this->recipient_email, $this, $form_id ); |
|
378 | + $this->recipient_email = apply_filters('give_admin_notice_emails', $this->recipient_email, $this, $form_id); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return bool |
407 | 407 | */ |
408 | - public function get_notification_status( $form_id = null ) { |
|
409 | - $notification_status = empty( $form_id ) |
|
410 | - ? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] ) |
|
411 | - : give_get_meta( $form_id, Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'notification', true, 'global' ); |
|
408 | + public function get_notification_status($form_id = null) { |
|
409 | + $notification_status = empty($form_id) |
|
410 | + ? give_get_option("{$this->config['id']}_notification", $this->config['notification_status']) |
|
411 | + : give_get_meta($form_id, Give_Email_Setting_Field::get_prefix($this, $form_id).'notification', true, 'global'); |
|
412 | 412 | |
413 | 413 | /** |
414 | 414 | * Filter the notification status. |
@@ -433,11 +433,11 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return string |
435 | 435 | */ |
436 | - function get_email_subject( $form_id = null ) { |
|
436 | + function get_email_subject($form_id = null) { |
|
437 | 437 | $subject = wp_strip_all_tags( |
438 | 438 | Give_Email_Notification_Util::get_value( |
439 | 439 | $this, |
440 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
440 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
441 | 441 | $form_id, |
442 | 442 | $this->config['default_email_subject'] |
443 | 443 | ) |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return string |
468 | 468 | */ |
469 | - public function get_email_message( $form_id = null ) { |
|
469 | + public function get_email_message($form_id = null) { |
|
470 | 470 | $message = Give_Email_Notification_Util::get_value( |
471 | 471 | $this, |
472 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
472 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
473 | 473 | $form_id, |
474 | 474 | $this->config['default_email_message'] |
475 | 475 | ); |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return string |
498 | 498 | */ |
499 | - public function get_email_header( $form_id = null ) { |
|
499 | + public function get_email_header($form_id = null) { |
|
500 | 500 | $header = Give_Email_Notification_Util::get_value( |
501 | 501 | $this, |
502 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_header', |
|
502 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_header', |
|
503 | 503 | $form_id, |
504 | 504 | $this->config['default_email_header'] |
505 | 505 | ); |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public function get_email_content_type( $form_id ) { |
|
530 | + public function get_email_content_type($form_id) { |
|
531 | 531 | $content_type = Give_Email_Notification_Util::get_value( |
532 | 532 | $this, |
533 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_content_type', |
|
533 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_content_type', |
|
534 | 534 | $form_id, |
535 | 535 | $this->config['content_type'] |
536 | 536 | ); |
@@ -558,15 +558,14 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string |
560 | 560 | */ |
561 | - public function get_email_template( $form_id ) { |
|
562 | - $email_template = give_get_meta( $form_id, '_give_email_template', true ); |
|
561 | + public function get_email_template($form_id) { |
|
562 | + $email_template = give_get_meta($form_id, '_give_email_template', true); |
|
563 | 563 | $email_template = Give_Email_Notification_Util::get_value( |
564 | 564 | $this, |
565 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) .'email_template', |
|
565 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_template', |
|
566 | 566 | $form_id, |
567 | - ! empty( $email_template ) && Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ? |
|
568 | - $email_template : |
|
569 | - $this->config['email_template'] |
|
567 | + ! empty($email_template) && Give_Email_Notification_Util::can_use_form_email_options($this, $form_id) ? |
|
568 | + $email_template : $this->config['email_template'] |
|
570 | 569 | ); |
571 | 570 | |
572 | 571 | /** |
@@ -593,34 +592,34 @@ discard block |
||
593 | 592 | * |
594 | 593 | * @return array |
595 | 594 | */ |
596 | - public function get_allowed_email_tags( $formatted = false ) { |
|
595 | + public function get_allowed_email_tags($formatted = false) { |
|
597 | 596 | // Get all email tags. |
598 | 597 | $email_tags = Give()->email_tags->get_tags(); |
599 | 598 | |
600 | 599 | // Skip if all email template tags context setup exit. |
601 | - if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) { |
|
602 | - if ( is_array( $this->config['email_tag_context'] ) ) { |
|
603 | - foreach ( $email_tags as $index => $email_tag ) { |
|
604 | - if ( in_array( $email_tag['context'], $this->config['email_tag_context'] ) ) { |
|
600 | + if ($this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context']) { |
|
601 | + if (is_array($this->config['email_tag_context'])) { |
|
602 | + foreach ($email_tags as $index => $email_tag) { |
|
603 | + if (in_array($email_tag['context'], $this->config['email_tag_context'])) { |
|
605 | 604 | continue; |
606 | 605 | } |
607 | 606 | |
608 | - unset( $email_tags[ $index ] ); |
|
607 | + unset($email_tags[$index]); |
|
609 | 608 | } |
610 | 609 | } else { |
611 | - foreach ( $email_tags as $index => $email_tag ) { |
|
612 | - if ( $this->config['email_tag_context'] === $email_tag['context'] ) { |
|
610 | + foreach ($email_tags as $index => $email_tag) { |
|
611 | + if ($this->config['email_tag_context'] === $email_tag['context']) { |
|
613 | 612 | continue; |
614 | 613 | } |
615 | 614 | |
616 | - unset( $email_tags[ $index ] ); |
|
615 | + unset($email_tags[$index]); |
|
617 | 616 | } |
618 | 617 | } |
619 | 618 | } |
620 | 619 | |
621 | - if ( count( $email_tags ) && $formatted ) : ob_start() ?> |
|
620 | + if (count($email_tags) && $formatted) : ob_start() ?> |
|
622 | 621 | <ul class="give-email-tags-wrap"> |
623 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
622 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
624 | 623 | <li class="give_<?php echo $email_tag['tag']; ?>_tag"> |
625 | 624 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
626 | 625 | </li> |
@@ -643,8 +642,8 @@ discard block |
||
643 | 642 | * |
644 | 643 | * @return array|string |
645 | 644 | */ |
646 | - public function get_preview_email_recipient( $form_id = null ) { |
|
647 | - $recipients = $this->get_recipient( $form_id ); |
|
645 | + public function get_preview_email_recipient($form_id = null) { |
|
646 | + $recipients = $this->get_recipient($form_id); |
|
648 | 647 | |
649 | 648 | /** |
650 | 649 | * Filter the preview email recipients. |
@@ -654,7 +653,7 @@ discard block |
||
654 | 653 | * @param string|array $recipients List of recipients. |
655 | 654 | * @param Give_Email_Notification $this |
656 | 655 | */ |
657 | - $recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id ); |
|
656 | + $recipients = apply_filters('give_get_preview_email_recipient', $recipients, $this, $form_id); |
|
658 | 657 | |
659 | 658 | return $recipients; |
660 | 659 | } |
@@ -669,13 +668,13 @@ discard block |
||
669 | 668 | * |
670 | 669 | * @return array |
671 | 670 | */ |
672 | - public function get_email_attachments( $form_id = null ) { |
|
671 | + public function get_email_attachments($form_id = null) { |
|
673 | 672 | /** |
674 | 673 | * Filter the attachment. |
675 | 674 | * |
676 | 675 | * @since 2.0 |
677 | 676 | */ |
678 | - return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id ); |
|
677 | + return apply_filters("give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id); |
|
679 | 678 | } |
680 | 679 | |
681 | 680 | |
@@ -687,40 +686,40 @@ discard block |
||
687 | 686 | */ |
688 | 687 | public function send_preview_email() { |
689 | 688 | // Get form id |
690 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
689 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
691 | 690 | |
692 | 691 | // setup email data. |
693 | 692 | $this->setup_email_data(); |
694 | 693 | |
695 | 694 | $attachments = $this->get_email_attachments(); |
696 | - $message = $this->preview_email_template_tags( $this->get_email_message( $form_id ) ); |
|
697 | - $subject = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) ); |
|
698 | - $content_type = $this->get_email_content_type( $form_id ); |
|
695 | + $message = $this->preview_email_template_tags($this->get_email_message($form_id)); |
|
696 | + $subject = $this->preview_email_template_tags($this->get_email_subject($form_id)); |
|
697 | + $content_type = $this->get_email_content_type($form_id); |
|
699 | 698 | |
700 | 699 | // Setup email content type. |
701 | - Give()->emails->__set( 'content_type', $content_type ); |
|
702 | - Give()->emails->__set( 'html', true ); |
|
700 | + Give()->emails->__set('content_type', $content_type); |
|
701 | + Give()->emails->__set('html', true); |
|
703 | 702 | |
704 | 703 | // Setup email template |
705 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
704 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
706 | 705 | |
707 | 706 | // Set email header. |
708 | - Give()->emails->__set( 'heading', $this->preview_email_template_tags( $this->get_email_header( $form_id ) ) ); |
|
707 | + Give()->emails->__set('heading', $this->preview_email_template_tags($this->get_email_header($form_id))); |
|
709 | 708 | |
710 | 709 | // Format plain content type email. |
711 | - if ( 'text/plain' === $content_type ) { |
|
712 | - Give()->emails->__set( 'html', false ); |
|
713 | - Give()->emails->__set( 'template', 'none' ); |
|
714 | - $message = strip_tags( $message ); |
|
710 | + if ('text/plain' === $content_type) { |
|
711 | + Give()->emails->__set('html', false); |
|
712 | + Give()->emails->__set('template', 'none'); |
|
713 | + $message = strip_tags($message); |
|
715 | 714 | } |
716 | 715 | |
717 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
716 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
718 | 717 | Give()->emails->form_id = $form_id; |
719 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
720 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
718 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
719 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
721 | 720 | } |
722 | 721 | |
723 | - return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments ); |
|
722 | + return Give()->emails->send($this->get_preview_email_recipient($form_id), $subject, $message, $attachments); |
|
724 | 723 | } |
725 | 724 | |
726 | 725 | |
@@ -741,7 +740,7 @@ discard block |
||
741 | 740 | * |
742 | 741 | * @return bool |
743 | 742 | */ |
744 | - public function send_email_notification( $email_tag_args = array() ) { |
|
743 | + public function send_email_notification($email_tag_args = array()) { |
|
745 | 744 | // Add email content type email tags. |
746 | 745 | $email_tag_args['email_content_type'] = $this->config['content_type']; |
747 | 746 | |
@@ -750,16 +749,16 @@ discard block |
||
750 | 749 | * |
751 | 750 | * @since 2.0 |
752 | 751 | */ |
753 | - $email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this ); |
|
752 | + $email_tag_args = apply_filters("give_{$this->config['id']}_email_tag_args", $email_tag_args, $this); |
|
754 | 753 | |
755 | 754 | // Get form id. |
756 | - $form_id = ! empty( $email_tag_args['form_id'] ) |
|
757 | - ? absint( $email_tag_args['form_id'] ) |
|
758 | - : ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null ); |
|
755 | + $form_id = ! empty($email_tag_args['form_id']) |
|
756 | + ? absint($email_tag_args['form_id']) |
|
757 | + : ( ! empty($email_tag_args['payment_id']) ? give_get_payment_form_id($email_tag_args['payment_id']) : null); |
|
759 | 758 | |
760 | 759 | |
761 | 760 | // Do not send email if notification is disable. |
762 | - if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) { |
|
761 | + if ( ! Give_Email_Notification_Util::is_email_notification_active($this, $form_id)) { |
|
763 | 762 | return false; |
764 | 763 | } |
765 | 764 | |
@@ -768,44 +767,44 @@ discard block |
||
768 | 767 | * |
769 | 768 | * @since 2.0 |
770 | 769 | */ |
771 | - do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id ); |
|
770 | + do_action("give_{$this->config['id']}_email_send_before", $this, $form_id); |
|
772 | 771 | |
773 | 772 | $attachments = $this->get_email_attachments(); |
774 | - $message = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args ); |
|
775 | - $subject = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args ); |
|
776 | - $content_type = $this->get_email_content_type( $form_id ); |
|
773 | + $message = give_do_email_tags($this->get_email_message($form_id), $email_tag_args); |
|
774 | + $subject = give_do_email_tags($this->get_email_subject($form_id), $email_tag_args); |
|
775 | + $content_type = $this->get_email_content_type($form_id); |
|
777 | 776 | |
778 | 777 | // Setup email content type. |
779 | - Give()->emails->__set( 'content_type', $content_type ); |
|
780 | - Give()->emails->__set( 'html', true ); |
|
778 | + Give()->emails->__set('content_type', $content_type); |
|
779 | + Give()->emails->__set('html', true); |
|
781 | 780 | |
782 | 781 | // Set email template. |
783 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
782 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
784 | 783 | |
785 | 784 | // Set email header. |
786 | - Give()->emails->__set( 'heading', give_do_email_tags( $this->get_email_header( $form_id ), $email_tag_args ) ); |
|
785 | + Give()->emails->__set('heading', give_do_email_tags($this->get_email_header($form_id), $email_tag_args)); |
|
787 | 786 | |
788 | - if ( 'text/plain' === $content_type ) { |
|
789 | - Give()->emails->__set( 'html', false ); |
|
790 | - Give()->emails->__set( 'template', 'none' ); |
|
791 | - $message = strip_tags( $message ); |
|
787 | + if ('text/plain' === $content_type) { |
|
788 | + Give()->emails->__set('html', false); |
|
789 | + Give()->emails->__set('template', 'none'); |
|
790 | + $message = strip_tags($message); |
|
792 | 791 | } |
793 | 792 | |
794 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
793 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
795 | 794 | Give()->emails->form_id = $form_id; |
796 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
797 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
795 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
796 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
798 | 797 | } |
799 | 798 | |
800 | 799 | // Send email. |
801 | - $email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments ); |
|
800 | + $email_status = Give()->emails->send($this->get_recipient($form_id), $subject, $message, $attachments); |
|
802 | 801 | |
803 | 802 | /** |
804 | 803 | * Fire action after after email send. |
805 | 804 | * |
806 | 805 | * @since 2.0 |
807 | 806 | */ |
808 | - do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id ); |
|
807 | + do_action("give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id); |
|
809 | 808 | |
810 | 809 | return $email_status; |
811 | 810 | } |
@@ -820,67 +819,67 @@ discard block |
||
820 | 819 | * |
821 | 820 | * @return string |
822 | 821 | */ |
823 | - public function preview_email_template_tags( $message ) { |
|
822 | + public function preview_email_template_tags($message) { |
|
824 | 823 | // Set Payment. |
825 | - $payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' ); |
|
826 | - $payment = $payment_id ? new Give_Payment( $payment_id ) : new stdClass(); |
|
824 | + $payment_id = give_check_variable(give_clean($_GET), 'isset_empty', 0, 'preview_id'); |
|
825 | + $payment = $payment_id ? new Give_Payment($payment_id) : new stdClass(); |
|
827 | 826 | |
828 | 827 | // Set donor. |
829 | 828 | $user_id = $payment_id |
830 | 829 | ? $payment->user_id |
831 | - : give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' ); |
|
830 | + : give_check_variable(give_clean($_GET), 'isset_empty', 0, 'user_id'); |
|
832 | 831 | $user_id = $user_id ? $user_id : wp_get_current_user()->ID; |
833 | 832 | |
834 | 833 | // Set receipt. |
835 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
834 | + $receipt_id = strtolower(md5(uniqid())); |
|
836 | 835 | |
837 | - $receipt_link_url = esc_url( add_query_arg( array( |
|
836 | + $receipt_link_url = esc_url(add_query_arg(array( |
|
838 | 837 | 'payment_key' => $receipt_id, |
839 | - ), give_get_history_page_uri() ) ); |
|
838 | + ), give_get_history_page_uri())); |
|
840 | 839 | |
841 | 840 | $receipt_link = sprintf( |
842 | 841 | '<a href="%1$s">%2$s</a>', |
843 | 842 | $receipt_link_url, |
844 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
843 | + esc_html__('View the receipt in your browser »', 'give') |
|
845 | 844 | ); |
846 | 845 | |
847 | 846 | // Set default values for tags. |
848 | 847 | $this->config['preview_email_tags_values'] = wp_parse_args( |
849 | 848 | $this->config['preview_email_tags_values'], |
850 | 849 | array( |
851 | - 'name' => give_email_tag_first_name( array( |
|
850 | + 'name' => give_email_tag_first_name(array( |
|
852 | 851 | 'payment_id' => $payment_id, |
853 | 852 | 'user_id' => $user_id, |
854 | - ) ), |
|
855 | - 'fullname' => give_email_tag_fullname( array( |
|
853 | + )), |
|
854 | + 'fullname' => give_email_tag_fullname(array( |
|
856 | 855 | 'payment_id' => $payment_id, |
857 | 856 | 'user_id' => $user_id, |
858 | - ) ), |
|
859 | - 'username' => give_email_tag_username( array( |
|
857 | + )), |
|
858 | + 'username' => give_email_tag_username(array( |
|
860 | 859 | 'payment_id' => $payment_id, |
861 | 860 | 'user_id' => $user_id, |
862 | - ) ), |
|
863 | - 'user_email' => give_email_tag_user_email( array( |
|
861 | + )), |
|
862 | + 'user_email' => give_email_tag_user_email(array( |
|
864 | 863 | 'payment_id' => $payment_id, |
865 | 864 | 'user_id' => $user_id, |
866 | - ) ), |
|
867 | - 'payment_total' => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
868 | - 'amount' => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
869 | - 'price' => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
870 | - 'payment_method' => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ), |
|
865 | + )), |
|
866 | + 'payment_total' => $payment_id ? give_email_tag_payment_total(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
867 | + 'amount' => $payment_id ? give_email_tag_amount(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
868 | + 'price' => $payment_id ? give_email_tag_price(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
869 | + 'payment_method' => $payment_id ? give_email_tag_payment_method(array('payment_id' => $payment_id)) : __('PayPal', 'give'), |
|
871 | 870 | 'receipt_id' => $receipt_id, |
872 | - 'payment_id' => $payment_id ? $payment_id : rand( 2000, 2050 ), |
|
871 | + 'payment_id' => $payment_id ? $payment_id : rand(2000, 2050), |
|
873 | 872 | 'receipt_link_url' => $receipt_link_url, |
874 | 873 | 'receipt_link' => $receipt_link, |
875 | - 'date' => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ), |
|
876 | - 'donation' => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ), |
|
877 | - 'form_title' => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), |
|
878 | - 'sitename' => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ), |
|
874 | + 'date' => $payment_id ? date(give_date_format(), strtotime($payment->date)) : date(give_date_format(), current_time('timestamp')), |
|
875 | + 'donation' => $payment_id ? give_email_tag_donation(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title', 'give'), |
|
876 | + 'form_title' => $payment_id ? give_email_tag_form_title(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), |
|
877 | + 'sitename' => $payment_id ? give_email_tag_sitename(array('payment_id' => $payment_id)) : get_bloginfo('name'), |
|
879 | 878 | 'pdf_receipt' => sprintf( |
880 | 879 | '<a href="#">%s</a>', |
881 | - __( 'Download Receipt', 'give' ) |
|
880 | + __('Download Receipt', 'give') |
|
882 | 881 | ), |
883 | - 'billing_address' => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '', |
|
882 | + 'billing_address' => $payment_id ? give_email_tag_billing_address(array('payment_id' => $payment_id)) : '', |
|
884 | 883 | 'email_access_link' => sprintf( |
885 | 884 | '<a href="%1$s">%2$s</a>', |
886 | 885 | add_query_arg( |
@@ -889,20 +888,20 @@ discard block |
||
889 | 888 | ), |
890 | 889 | give_get_history_page_uri() |
891 | 890 | ), |
892 | - __( 'View your donation history »', 'give' ) |
|
891 | + __('View your donation history »', 'give') |
|
893 | 892 | ), |
894 | - 'reset_password_link' => $user_id ? give_email_tag_reset_password_link( array( 'user_id' => $user_id ), $payment_id ) : '', |
|
893 | + 'reset_password_link' => $user_id ? give_email_tag_reset_password_link(array('user_id' => $user_id), $payment_id) : '', |
|
895 | 894 | ) |
896 | 895 | ); |
897 | 896 | |
898 | 897 | // Decode tags. |
899 | - foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) { |
|
900 | - if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) { |
|
901 | - $message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message ); |
|
898 | + foreach ($this->config['preview_email_tags_values'] as $preview_tag => $value) { |
|
899 | + if (isset($this->config['preview_email_tags_values'][$preview_tag])) { |
|
900 | + $message = str_replace("{{$preview_tag}}", $this->config['preview_email_tags_values'][$preview_tag], $message); |
|
902 | 901 | } |
903 | 902 | } |
904 | 903 | |
905 | - return apply_filters( 'give_email_preview_template_tags', $message ); |
|
904 | + return apply_filters('give_email_preview_template_tags', $message); |
|
906 | 905 | } |
907 | 906 | |
908 | 907 | /** |
@@ -927,17 +926,17 @@ discard block |
||
927 | 926 | * @param $post_id |
928 | 927 | * |
929 | 928 | */ |
930 | - public function validate_form_recipient_field_value( $form_meta_key, $form_meta_value, $post_id ) { |
|
929 | + public function validate_form_recipient_field_value($form_meta_key, $form_meta_value, $post_id) { |
|
931 | 930 | // Get valid emails. |
932 | - $new_form_meta_value = array_filter( $form_meta_value, function ( $value ) { |
|
933 | - return ! empty( $value['email'] ) && is_email( $value['email'] ); |
|
931 | + $new_form_meta_value = array_filter($form_meta_value, function($value) { |
|
932 | + return ! empty($value['email']) && is_email($value['email']); |
|
934 | 933 | } ); |
935 | 934 | |
936 | 935 | // Remove duplicate emails from array. |
937 | 936 | $email_arr = array(); |
938 | - foreach ( $new_form_meta_value as $index => $email ) { |
|
939 | - if( in_array( $email['email'], $email_arr ) ) { |
|
940 | - unset( $new_form_meta_value[$index] ); |
|
937 | + foreach ($new_form_meta_value as $index => $email) { |
|
938 | + if (in_array($email['email'], $email_arr)) { |
|
939 | + unset($new_form_meta_value[$index]); |
|
941 | 940 | continue; |
942 | 941 | } |
943 | 942 | |
@@ -946,25 +945,25 @@ discard block |
||
946 | 945 | |
947 | 946 | $update = false; |
948 | 947 | |
949 | - if ( empty( $new_form_meta_value ) ) { |
|
948 | + if (empty($new_form_meta_value)) { |
|
950 | 949 | // Set default recipient. |
951 | 950 | $form_meta_value = array( |
952 | 951 | array( |
953 | - 'email' => get_bloginfo( 'admin_email' ) |
|
952 | + 'email' => get_bloginfo('admin_email') |
|
954 | 953 | ), |
955 | 954 | ); |
956 | 955 | |
957 | 956 | $update = true; |
958 | 957 | |
959 | - } elseif ( count( $new_form_meta_value ) !== count( $form_meta_value ) ) { |
|
958 | + } elseif (count($new_form_meta_value) !== count($form_meta_value)) { |
|
960 | 959 | // Filter recipient emails. |
961 | 960 | $form_meta_value = $new_form_meta_value; |
962 | 961 | |
963 | 962 | $update = true; |
964 | 963 | } |
965 | 964 | |
966 | - if( $update ) { |
|
967 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
965 | + if ($update) { |
|
966 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
968 | 967 | } |
969 | 968 | } |
970 | 969 | } |