@@ -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. |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'system-info'; |
46 | - $this->label = esc_html__( 'System Info', 'give' ); |
|
46 | + $this->label = esc_html__('System Info', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | |
51 | 51 | // Do not use main form for this tab. |
52 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
52 | + if (give_get_current_setting_tab() === $this->id) { |
|
53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return array |
66 | 66 | */ |
67 | - public function add_settings_page( $pages ) { |
|
68 | - $pages[ $this->id ] = $this->label; |
|
67 | + public function add_settings_page($pages) { |
|
68 | + $pages[$this->id] = $this->label; |
|
69 | 69 | |
70 | 70 | return $pages; |
71 | 71 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function output() { |
80 | 80 | $GLOBALS['give_hide_save_button'] = true; |
81 | - include_once( 'views/html-admin-page-system-info.php' ); |
|
81 | + include_once('views/html-admin-page-system-info.php'); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 |
@@ -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,8 +86,8 @@ discard block |
||
86 | 86 | public static function save() { |
87 | 87 | $current_tab = give_get_current_setting_tab(); |
88 | 88 | |
89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
90 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
90 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
91 | 91 | die(); |
92 | 92 | } |
93 | 93 | |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @since 1.8 |
102 | 102 | */ |
103 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
103 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
104 | 104 | |
105 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
105 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Trigger Action. |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.8 |
115 | 115 | */ |
116 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
116 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - public static function add_message( $code, $message ) { |
|
130 | - self::$messages[ $code ] = $message; |
|
129 | + public static function add_message($code, $message) { |
|
130 | + self::$messages[$code] = $message; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | - public static function add_error( $code, $message ) { |
|
144 | - self::$errors[ $code ] = $message; |
|
143 | + public static function add_error($code, $message) { |
|
144 | + self::$errors[$code] = $message; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | $notice_html = ''; |
155 | 155 | $classes = 'give-notice settings-error notice is-dismissible'; |
156 | 156 | |
157 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
158 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
157 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
158 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
159 | 159 | |
160 | - if ( 0 < count( self::$errors ) ) { |
|
161 | - foreach ( self::$errors as $code => $message ) { |
|
162 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
160 | + if (0 < count(self::$errors)) { |
|
161 | + foreach (self::$errors as $code => $message) { |
|
162 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - if ( 0 < count( self::$messages ) ) { |
|
167 | - foreach ( self::$messages as $code => $message ) { |
|
168 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
166 | + if (0 < count(self::$messages)) { |
|
167 | + foreach (self::$messages as $code => $message) { |
|
168 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | self::$setting_filter_prefix = give_get_current_setting_page(); |
186 | 186 | |
187 | 187 | // Bailout: Exit if setting page is not defined. |
188 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
188 | + if (empty(self::$setting_filter_prefix)) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @since 1.8 |
200 | 200 | */ |
201 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
201 | + do_action(self::$setting_filter_prefix.'_start'); |
|
202 | 202 | |
203 | 203 | $current_tab = give_get_current_setting_tab(); |
204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | self::get_settings_pages(); |
207 | 207 | |
208 | 208 | // Save settings if data has been posted. |
209 | - if ( ! empty( $_POST ) ) { |
|
209 | + if ( ! empty($_POST)) { |
|
210 | 210 | self::save(); |
211 | 211 | } |
212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @since 1.8 |
221 | 221 | */ |
222 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
222 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
223 | 223 | |
224 | 224 | include 'views/html-admin-settings.php'; |
225 | 225 | |
@@ -237,25 +237,25 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string|bool |
239 | 239 | */ |
240 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
240 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
241 | 241 | // Bailout. |
242 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
242 | + if (empty($option_name) && empty($field_id)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
246 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
247 | 247 | // Get field value if any. |
248 | - $option_value = get_option( $option_name ); |
|
248 | + $option_value = get_option($option_name); |
|
249 | 249 | |
250 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
251 | - ? $option_value[ $field_id ] |
|
250 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
251 | + ? $option_value[$field_id] |
|
252 | 252 | : $default; |
253 | 253 | } else { |
254 | 254 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
255 | 255 | $option_name = ! $option_name ? $field_id : $option_name; |
256 | 256 | |
257 | 257 | // Get option value if any. |
258 | - $option_value = get_option( $option_name, $default ); |
|
258 | + $option_value = get_option($option_name, $default); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $option_value; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return void |
275 | 275 | */ |
276 | - public static function output_fields( $options, $option_name = '' ) { |
|
276 | + public static function output_fields($options, $option_name = '') { |
|
277 | 277 | $current_tab = give_get_current_setting_tab(); |
278 | 278 | |
279 | 279 | // Field Default values. |
@@ -286,52 +286,52 @@ discard block |
||
286 | 286 | 'table_html' => true, |
287 | 287 | ); |
288 | 288 | |
289 | - foreach ( $options as $value ) { |
|
290 | - if ( ! isset( $value['type'] ) ) { |
|
289 | + foreach ($options as $value) { |
|
290 | + if ( ! isset($value['type'])) { |
|
291 | 291 | continue; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // Set title. |
295 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
295 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
296 | 296 | |
297 | 297 | // Set default setting. |
298 | - $value = wp_parse_args( $value, $defaults ); |
|
298 | + $value = wp_parse_args($value, $defaults); |
|
299 | 299 | |
300 | 300 | // Colorpicker field. |
301 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
302 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
301 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
302 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
303 | 303 | |
304 | 304 | |
305 | 305 | // Custom attribute handling. |
306 | 306 | $custom_attributes = array(); |
307 | 307 | |
308 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
309 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
310 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
308 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
309 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
310 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Description handling. |
315 | - $description = self::get_field_description( $value ); |
|
315 | + $description = self::get_field_description($value); |
|
316 | 316 | |
317 | 317 | // Switch based on type. |
318 | - switch ( $value['type'] ) { |
|
318 | + switch ($value['type']) { |
|
319 | 319 | |
320 | 320 | // Section Titles |
321 | 321 | case 'title': |
322 | - if ( ! empty( $value['title'] ) ) { |
|
323 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
322 | + if ( ! empty($value['title'])) { |
|
323 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $value['desc'] ) ) { |
|
327 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
326 | + if ( ! empty($value['desc'])) { |
|
327 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( $value['table_html'] ) { |
|
331 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
330 | + if ($value['table_html']) { |
|
331 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( ! empty( $value['id'] ) ) { |
|
334 | + if ( ! empty($value['id'])) { |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Trigger Action. |
@@ -340,14 +340,14 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @since 1.8 |
342 | 342 | */ |
343 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
343 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | break; |
347 | 347 | |
348 | 348 | // Section Ends. |
349 | 349 | case 'sectionend': |
350 | - if ( ! empty( $value['id'] ) ) { |
|
350 | + if ( ! empty($value['id'])) { |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Trigger Action. |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @since 1.8 |
358 | 358 | */ |
359 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
359 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( $value['table_html'] ) { |
|
362 | + if ($value['table_html']) { |
|
363 | 363 | echo '</table>'; |
364 | 364 | } |
365 | 365 | |
366 | - if ( ! empty( $value['id'] ) ) { |
|
366 | + if ( ! empty($value['id'])) { |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Trigger Action. |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @since 1.8 |
374 | 374 | */ |
375 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
375 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | break; |
@@ -385,22 +385,22 @@ discard block |
||
385 | 385 | case 'password' : |
386 | 386 | |
387 | 387 | $type = $value['type']; |
388 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
388 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
389 | 389 | |
390 | 390 | ?> |
391 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
391 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
392 | 392 | <th scope="row" class="titledesc"> |
393 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
393 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
394 | 394 | </th> |
395 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
395 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
396 | 396 | <input |
397 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
398 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
399 | - type="<?php echo esc_attr( $type ); ?>" |
|
400 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
401 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
402 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
403 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
397 | + name="<?php echo esc_attr($value['id']); ?>" |
|
398 | + id="<?php echo esc_attr($value['id']); ?>" |
|
399 | + type="<?php echo esc_attr($type); ?>" |
|
400 | + style="<?php echo esc_attr($value['css']); ?>" |
|
401 | + value="<?php echo esc_attr($option_value); ?>" |
|
402 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
403 | + <?php echo implode(' ', $custom_attributes); ?> |
|
404 | 404 | /> <?php echo $description; ?> |
405 | 405 | </td> |
406 | 406 | </tr><?php |
@@ -409,23 +409,23 @@ discard block |
||
409 | 409 | // Textarea. |
410 | 410 | case 'textarea': |
411 | 411 | |
412 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
412 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
413 | 413 | |
414 | 414 | ?> |
415 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
415 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
416 | 416 | <th scope="row" class="titledesc"> |
417 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
417 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
418 | 418 | </th> |
419 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
419 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
420 | 420 | <textarea |
421 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
422 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
423 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
424 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
421 | + name="<?php echo esc_attr($value['id']); ?>" |
|
422 | + id="<?php echo esc_attr($value['id']); ?>" |
|
423 | + style="<?php echo esc_attr($value['css']); ?>" |
|
424 | + class="<?php echo esc_attr($value['class']); ?>" |
|
425 | 425 | rows="10" |
426 | 426 | cols="60" |
427 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
428 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
427 | + <?php echo implode(' ', $custom_attributes); ?> |
|
428 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
429 | 429 | <?php echo $description; ?> |
430 | 430 | </td> |
431 | 431 | </tr><?php |
@@ -435,35 +435,35 @@ discard block |
||
435 | 435 | case 'select' : |
436 | 436 | case 'multiselect' : |
437 | 437 | |
438 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
438 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
439 | 439 | |
440 | 440 | ?> |
441 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
441 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
442 | 442 | <th scope="row" class="titledesc"> |
443 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
443 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
444 | 444 | </th> |
445 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
445 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
446 | 446 | <select |
447 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
447 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
448 | 448 | echo '[]'; |
449 | 449 | } ?>" |
450 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
451 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
452 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
453 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
454 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
450 | + id="<?php echo esc_attr($value['id']); ?>" |
|
451 | + style="<?php echo esc_attr($value['css']); ?>" |
|
452 | + class="<?php echo esc_attr($value['class']); ?>" |
|
453 | + <?php echo implode(' ', $custom_attributes); ?> |
|
454 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
455 | 455 | > |
456 | 456 | |
457 | 457 | <?php |
458 | - if ( ! empty( $value['options'] ) ) { |
|
459 | - foreach ( $value['options'] as $key => $val ) { |
|
458 | + if ( ! empty($value['options'])) { |
|
459 | + foreach ($value['options'] as $key => $val) { |
|
460 | 460 | ?> |
461 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
461 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
462 | 462 | |
463 | - if ( is_array( $option_value ) ) { |
|
464 | - selected( in_array( $key, $option_value ), true ); |
|
463 | + if (is_array($option_value)) { |
|
464 | + selected(in_array($key, $option_value), true); |
|
465 | 465 | } else { |
466 | - selected( $option_value, $key ); |
|
466 | + selected($option_value, $key); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | ?>><?php echo $val ?></option> |
@@ -479,28 +479,28 @@ discard block |
||
479 | 479 | |
480 | 480 | // Radio inputs. |
481 | 481 | case 'radio_inline' : |
482 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
482 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
483 | 483 | case 'radio' : |
484 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
484 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
485 | 485 | ?> |
486 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
486 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
487 | 487 | <th scope="row" class="titledesc"> |
488 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
488 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
489 | 489 | </th> |
490 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
490 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
491 | 491 | <fieldset> |
492 | 492 | <ul> |
493 | 493 | <?php |
494 | - foreach ( $value['options'] as $key => $val ) { |
|
494 | + foreach ($value['options'] as $key => $val) { |
|
495 | 495 | ?> |
496 | 496 | <li> |
497 | 497 | <label><input |
498 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
498 | + name="<?php echo esc_attr($value['id']); ?>" |
|
499 | 499 | value="<?php echo $key; ?>" |
500 | 500 | type="radio" |
501 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
502 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
503 | - <?php checked( $key, $option_value ); ?> |
|
501 | + style="<?php echo esc_attr($value['css']); ?>" |
|
502 | + <?php echo implode(' ', $custom_attributes); ?> |
|
503 | + <?php checked($key, $option_value); ?> |
|
504 | 504 | /> <?php echo $val ?></label> |
505 | 505 | </li> |
506 | 506 | <?php |
@@ -514,21 +514,21 @@ discard block |
||
514 | 514 | |
515 | 515 | // Checkbox input. |
516 | 516 | case 'checkbox' : |
517 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
517 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
518 | 518 | ?> |
519 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
519 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
520 | 520 | <th scope="row" class="titledesc"> |
521 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
521 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
522 | 522 | </th> |
523 | 523 | <td class="give-forminp"> |
524 | 524 | <input |
525 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
526 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
525 | + name="<?php echo esc_attr($value['id']); ?>" |
|
526 | + id="<?php echo esc_attr($value['id']); ?>" |
|
527 | 527 | type="checkbox" |
528 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
528 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
529 | 529 | value="1" |
530 | - <?php checked( $option_value, 'on' ); ?> |
|
531 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
530 | + <?php checked($option_value, 'on'); ?> |
|
531 | + <?php echo implode(' ', $custom_attributes); ?> |
|
532 | 532 | /> |
533 | 533 | <?php echo $description; ?> |
534 | 534 | </td> |
@@ -538,28 +538,28 @@ discard block |
||
538 | 538 | |
539 | 539 | // Multi Checkbox input. |
540 | 540 | case 'multicheck' : |
541 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
542 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
541 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
542 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
543 | 543 | ?> |
544 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
544 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
545 | 545 | <th scope="row" class="titledesc"> |
546 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
546 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
547 | 547 | </th> |
548 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
548 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
549 | 549 | <fieldset> |
550 | 550 | <ul> |
551 | 551 | <?php |
552 | - foreach ( $value['options'] as $key => $val ) { |
|
552 | + foreach ($value['options'] as $key => $val) { |
|
553 | 553 | ?> |
554 | 554 | <li> |
555 | 555 | <label> |
556 | 556 | <input |
557 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
557 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
558 | 558 | value="<?php echo $key; ?>" |
559 | 559 | type="checkbox" |
560 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
561 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
562 | - <?php if ( in_array( $key, $option_value ) ) { |
|
560 | + style="<?php echo esc_attr($value['css']); ?>" |
|
561 | + <?php echo implode(' ', $custom_attributes); ?> |
|
562 | + <?php if (in_array($key, $option_value)) { |
|
563 | 563 | echo 'checked="checked"'; |
564 | 564 | } ?> |
565 | 565 | /> <?php echo $val ?> |
@@ -578,35 +578,35 @@ discard block |
||
578 | 578 | // File input field. |
579 | 579 | case 'file' : |
580 | 580 | case 'media' : |
581 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
582 | - $button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $value['type'] ? 'File' : 'Image' ) ), 'give' ); |
|
583 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
584 | - |
|
585 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
586 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '#'; |
|
587 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
588 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
581 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
582 | + $button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $value['type'] ? 'File' : 'Image')), 'give'); |
|
583 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
584 | + |
|
585 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
586 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '#'; |
|
587 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
588 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
589 | 589 | ?> |
590 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
590 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
591 | 591 | <th scope="row" class="titledesc"> |
592 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
592 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
593 | 593 | </th> |
594 | 594 | <td class="give-forminp"> |
595 | 595 | <div class="give-field-wrap"> |
596 | 596 | <label for="<?php echo $value['id'] ?>"> |
597 | 597 | <input |
598 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
599 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
598 | + name="<?php echo esc_attr($value['id']); ?>" |
|
599 | + id="<?php echo esc_attr($value['id']); ?>" |
|
600 | 600 | type="text" |
601 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
601 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
602 | 602 | value="<?php echo $option_value; ?>" |
603 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
604 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
603 | + style="<?php echo esc_attr($value['css']); ?>" |
|
604 | + <?php echo implode(' ', $custom_attributes); ?> |
|
605 | 605 | /> <input class="give-upload-button button" type="button" data-fvalue="<?php echo $fvalue; ?>" data-field-type="<?php echo $value['type']; ?>" value="<?php echo $button_label; ?>"> |
606 | 606 | <?php echo $description ?> |
607 | 607 | <div class="give-image-thumb<?php echo ! $option_value || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
608 | 608 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
609 | - <img src="<?php echo $preview_image_src ; ?>" alt=""> |
|
609 | + <img src="<?php echo $preview_image_src; ?>" alt=""> |
|
610 | 610 | </div> |
611 | 611 | </label> |
612 | 612 | </div> |
@@ -618,17 +618,17 @@ discard block |
||
618 | 618 | // WordPress Editor. |
619 | 619 | case 'wysiwyg' : |
620 | 620 | // Get option value. |
621 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
621 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
622 | 622 | |
623 | 623 | // Get editor settings. |
624 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
624 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
625 | 625 | ?> |
626 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
626 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
627 | 627 | <th scope="row" class="titledesc"> |
628 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
628 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
629 | 629 | </th> |
630 | 630 | <td class="give-forminp"> |
631 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
631 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
632 | 632 | <?php echo $description; ?> |
633 | 633 | </td> |
634 | 634 | </tr><?php |
@@ -637,9 +637,9 @@ discard block |
||
637 | 637 | // Custom: System setting field. |
638 | 638 | case 'system_info' : |
639 | 639 | ?> |
640 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
640 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
641 | 641 | <th scope="row" class="titledesc"> |
642 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
642 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
643 | 643 | </th> |
644 | 644 | <td class="give-forminp"> |
645 | 645 | <?php give_system_info_callback(); ?> |
@@ -650,14 +650,14 @@ discard block |
||
650 | 650 | |
651 | 651 | // Custom: Default gateways setting field. |
652 | 652 | case 'default_gateway' : |
653 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
653 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
654 | 654 | ?> |
655 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
655 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
656 | 656 | <th scope="row" class="titledesc"> |
657 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
657 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
658 | 658 | </th> |
659 | 659 | <td class="give-forminp"> |
660 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
660 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
661 | 661 | <?php echo $description; ?> |
662 | 662 | </td> |
663 | 663 | </tr><?php |
@@ -665,14 +665,14 @@ discard block |
||
665 | 665 | |
666 | 666 | // Custom: Enable gateways setting field. |
667 | 667 | case 'enabled_gateways' : |
668 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
668 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
669 | 669 | ?> |
670 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
670 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
671 | 671 | <th scope="row" class="titledesc"> |
672 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
672 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
673 | 673 | </th> |
674 | 674 | <td class="give-forminp"> |
675 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
675 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
676 | 676 | <?php echo $description; ?> |
677 | 677 | </td> |
678 | 678 | </tr><?php |
@@ -681,9 +681,9 @@ discard block |
||
681 | 681 | // Custom: Email preview buttons field. |
682 | 682 | case 'email_preview_buttons' : |
683 | 683 | ?> |
684 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
684 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
685 | 685 | <th scope="row" class="titledesc"> |
686 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
686 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
687 | 687 | </th> |
688 | 688 | <td class="give-forminp"> |
689 | 689 | <?php give_email_preview_buttons_callback(); ?> |
@@ -700,22 +700,22 @@ discard block |
||
700 | 700 | |
701 | 701 | // Custom: Gateway API key. |
702 | 702 | case 'api_key' : |
703 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
704 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
703 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
704 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
705 | 705 | ?> |
706 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
706 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
707 | 707 | <th scope="row" class="titledesc"> |
708 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
708 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
709 | 709 | </th> |
710 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
710 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
711 | 711 | <input |
712 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
713 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
714 | - type="<?php echo esc_attr( $type ); ?>" |
|
715 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
716 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
717 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
718 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
712 | + name="<?php echo esc_attr($value['id']); ?>" |
|
713 | + id="<?php echo esc_attr($value['id']); ?>" |
|
714 | + type="<?php echo esc_attr($type); ?>" |
|
715 | + style="<?php echo esc_attr($value['css']); ?>" |
|
716 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
717 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
718 | + <?php echo implode(' ', $custom_attributes); ?> |
|
719 | 719 | /> <?php echo $description; ?> |
720 | 720 | </td> |
721 | 721 | </tr><?php |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * |
733 | 733 | * @since 1.0 |
734 | 734 | */ |
735 | - do_action( "give_logs_view_{$current_section}" ); |
|
735 | + do_action("give_logs_view_{$current_section}"); |
|
736 | 736 | |
737 | 737 | echo $description; |
738 | 738 | break; |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | // Custom: Data field. |
741 | 741 | case 'data' : |
742 | 742 | |
743 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
743 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
744 | 744 | |
745 | 745 | echo $description; |
746 | 746 | break; |
@@ -748,12 +748,12 @@ discard block |
||
748 | 748 | // Custom: Give Docs Link field type. |
749 | 749 | case 'give_docs_link' : |
750 | 750 | ?> |
751 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
751 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
752 | 752 | <td class="give-docs-link" colspan="2"> |
753 | 753 | <?php |
754 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
754 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
755 | 755 | . '" target="_blank">' |
756 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
756 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
757 | 757 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
758 | 758 | ?> |
759 | 759 | </td> |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | // You can add or handle your custom field action. |
765 | 765 | default: |
766 | 766 | // Get option value. |
767 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
768 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
767 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
768 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
769 | 769 | break; |
770 | 770 | } |
771 | 771 | } |
@@ -781,15 +781,15 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return string The HTML description of the field. |
783 | 783 | */ |
784 | - public static function get_field_description( $value ) { |
|
784 | + public static function get_field_description($value) { |
|
785 | 785 | $description = ''; |
786 | 786 | |
787 | 787 | // Support for both 'description' and 'desc' args. |
788 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
789 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
788 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
789 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
790 | 790 | |
791 | - if ( ! empty( $value ) ) { |
|
792 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
791 | + if ( ! empty($value)) { |
|
792 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | return $description; |
@@ -806,11 +806,11 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @return array The description and tip as a 2 element array |
808 | 808 | */ |
809 | - public static function get_field_title( $value ) { |
|
810 | - $title = esc_html( $value['title'] ); |
|
809 | + public static function get_field_title($value) { |
|
810 | + $title = esc_html($value['title']); |
|
811 | 811 | |
812 | 812 | // If html tag detected then allow them to print. |
813 | - if ( strip_tags( $title ) ) { |
|
813 | + if (strip_tags($title)) { |
|
814 | 814 | $title = $value['title']; |
815 | 815 | } |
816 | 816 | |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @return bool |
831 | 831 | */ |
832 | - public static function save_fields( $options, $option_name = '' ) { |
|
833 | - if ( empty( $_POST ) ) { |
|
832 | + public static function save_fields($options, $option_name = '') { |
|
833 | + if (empty($_POST)) { |
|
834 | 834 | return false; |
835 | 835 | } |
836 | 836 | |
@@ -838,37 +838,37 @@ discard block |
||
838 | 838 | $update_options = array(); |
839 | 839 | |
840 | 840 | // Loop options and get values to save. |
841 | - foreach ( $options as $option ) { |
|
842 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
841 | + foreach ($options as $option) { |
|
842 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
843 | 843 | continue; |
844 | 844 | } |
845 | 845 | |
846 | 846 | // Get posted value. |
847 | - if ( strstr( $option['id'], '[' ) ) { |
|
848 | - parse_str( $option['id'], $option_name_array ); |
|
849 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
850 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
851 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
847 | + if (strstr($option['id'], '[')) { |
|
848 | + parse_str($option['id'], $option_name_array); |
|
849 | + $field_option_name = current(array_keys($option_name_array)); |
|
850 | + $setting_name = key($option_name_array[$field_option_name]); |
|
851 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
852 | 852 | } else { |
853 | 853 | $field_option_name = $option['id']; |
854 | 854 | $setting_name = ''; |
855 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
855 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | // Format the value based on option type. |
859 | - switch ( $option['type'] ) { |
|
859 | + switch ($option['type']) { |
|
860 | 860 | case 'checkbox' : |
861 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
861 | + $value = is_null($raw_value) ? '' : 'on'; |
|
862 | 862 | break; |
863 | 863 | case 'wysiwyg' : |
864 | 864 | case 'textarea' : |
865 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
865 | + $value = wp_kses_post(trim($raw_value)); |
|
866 | 866 | break; |
867 | 867 | case 'multiselect' : |
868 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
868 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
869 | 869 | break; |
870 | 870 | default : |
871 | - $value = give_clean( $raw_value ); |
|
871 | + $value = give_clean($raw_value); |
|
872 | 872 | break; |
873 | 873 | } |
874 | 874 | |
@@ -877,37 +877,37 @@ discard block |
||
877 | 877 | * |
878 | 878 | * @since 1.8 |
879 | 879 | */ |
880 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
880 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
881 | 881 | |
882 | 882 | /** |
883 | 883 | * Sanitize the value of an option by option name. |
884 | 884 | * |
885 | 885 | * @since 1.8 |
886 | 886 | */ |
887 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
887 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
888 | 888 | |
889 | - if ( is_null( $value ) ) { |
|
889 | + if (is_null($value)) { |
|
890 | 890 | continue; |
891 | 891 | } |
892 | 892 | |
893 | 893 | // Check if option is an array and handle that differently to single values. |
894 | - if ( $field_option_name && $setting_name ) { |
|
895 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
896 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
894 | + if ($field_option_name && $setting_name) { |
|
895 | + if ( ! isset($update_options[$field_option_name])) { |
|
896 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
897 | 897 | } |
898 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
899 | - $update_options[ $field_option_name ] = array(); |
|
898 | + if ( ! is_array($update_options[$field_option_name])) { |
|
899 | + $update_options[$field_option_name] = array(); |
|
900 | 900 | } |
901 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
901 | + $update_options[$field_option_name][$setting_name] = $value; |
|
902 | 902 | } else { |
903 | - $update_options[ $field_option_name ] = $value; |
|
903 | + $update_options[$field_option_name] = $value; |
|
904 | 904 | } |
905 | 905 | } |
906 | 906 | |
907 | 907 | // Save all options in our array or there own option name i.e. option id. |
908 | - if ( empty( $option_name ) ) { |
|
909 | - foreach ( $update_options as $name => $value ) { |
|
910 | - update_option( $name, $value ); |
|
908 | + if (empty($option_name)) { |
|
909 | + foreach ($update_options as $name => $value) { |
|
910 | + update_option($name, $value); |
|
911 | 911 | |
912 | 912 | /** |
913 | 913 | * Trigger action. |
@@ -916,13 +916,13 @@ discard block |
||
916 | 916 | * |
917 | 917 | * @since 1.8 |
918 | 918 | */ |
919 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
919 | + do_action("give_save_option_{$name}", $value, $name); |
|
920 | 920 | } |
921 | 921 | } else { |
922 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
923 | - $update_options = array_merge( $old_options, $update_options ); |
|
922 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
923 | + $update_options = array_merge($old_options, $update_options); |
|
924 | 924 | |
925 | - update_option( $option_name, $update_options ); |
|
925 | + update_option($option_name, $update_options); |
|
926 | 926 | |
927 | 927 | /** |
928 | 928 | * Trigger action. |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | * |
932 | 932 | * @since 1.8 |
933 | 933 | */ |
934 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
934 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | return true; |
@@ -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 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
57 | 57 | */ |
58 | - public function __construct( $args = array() ) { |
|
58 | + public function __construct($args = array()) { |
|
59 | 59 | $defaults = array( |
60 | 60 | 'output' => 'payments', |
61 | - 'post_type' => array( 'give_payment' ), |
|
61 | + 'post_type' => array('give_payment'), |
|
62 | 62 | 'start_date' => false, |
63 | 63 | 'end_date' => false, |
64 | 64 | 'number' => 20, |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'give_forms' => null, |
80 | 80 | ); |
81 | 81 | |
82 | - $this->args = wp_parse_args( $args, $defaults ); |
|
82 | + $this->args = wp_parse_args($args, $defaults); |
|
83 | 83 | |
84 | 84 | $this->init(); |
85 | 85 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param $query_var |
94 | 94 | * @param $value |
95 | 95 | */ |
96 | - public function __set( $query_var, $value ) { |
|
97 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
98 | - $this->args[ $query_var ][] = $value; |
|
96 | + public function __set($query_var, $value) { |
|
97 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
98 | + $this->args[$query_var][] = $value; |
|
99 | 99 | } else { |
100 | - $this->args[ $query_var ] = $value; |
|
100 | + $this->args[$query_var] = $value; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param $query_var |
111 | 111 | */ |
112 | - public function __unset( $query_var ) { |
|
113 | - unset( $this->args[ $query_var ] ); |
|
112 | + public function __unset($query_var) { |
|
113 | + unset($this->args[$query_var]); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->children(); |
146 | 146 | $this->give_forms(); |
147 | 147 | |
148 | - add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 ); |
|
148 | + add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function unset_filters() { |
158 | 158 | $this->date_filter_post(); |
159 | - remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) ); |
|
159 | + remove_filter('posts_orderby', array($this, 'custom_orderby')); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -183,27 +183,27 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param Give_Payments_Query $this Payments query object. |
185 | 185 | */ |
186 | - do_action( 'give_pre_get_payments', $this ); |
|
186 | + do_action('give_pre_get_payments', $this); |
|
187 | 187 | |
188 | - $query = new WP_Query( $this->args ); |
|
188 | + $query = new WP_Query($this->args); |
|
189 | 189 | |
190 | 190 | $custom_output = array( |
191 | 191 | 'payments', |
192 | 192 | 'give_payments', |
193 | 193 | ); |
194 | 194 | |
195 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
195 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
196 | 196 | return $query->posts; |
197 | 197 | } |
198 | 198 | |
199 | - if ( $query->have_posts() ) { |
|
200 | - while ( $query->have_posts() ) { |
|
199 | + if ($query->have_posts()) { |
|
200 | + while ($query->have_posts()) { |
|
201 | 201 | $query->the_post(); |
202 | 202 | |
203 | 203 | $payment_id = get_post()->ID; |
204 | - $payment = new Give_Payment( $payment_id ); |
|
204 | + $payment = new Give_Payment($payment_id); |
|
205 | 205 | |
206 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
206 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | wp_reset_postdata(); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param Give_Payments_Query $this Payments query object. |
222 | 222 | */ |
223 | - do_action( 'give_post_get_payments', $this ); |
|
223 | + do_action('give_post_get_payments', $this); |
|
224 | 224 | |
225 | 225 | return $this->payments; |
226 | 226 | } |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | * @return void |
235 | 235 | */ |
236 | 236 | public function date_filter_pre() { |
237 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
237 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
241 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
242 | 242 | |
243 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
243 | + add_filter('posts_where', array($this, 'payments_where')); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | * @return void |
254 | 254 | */ |
255 | 255 | public function date_filter_post() { |
256 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
256 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
260 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * @return void |
270 | 270 | */ |
271 | 271 | public function status() { |
272 | - if ( ! isset ( $this->args['status'] ) ) { |
|
272 | + if ( ! isset ($this->args['status'])) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | - $this->__set( 'post_status', $this->args['status'] ); |
|
277 | - $this->__unset( 'status' ); |
|
276 | + $this->__set('post_status', $this->args['status']); |
|
277 | + $this->__unset('status'); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | * @return void |
287 | 287 | */ |
288 | 288 | public function page() { |
289 | - if ( ! isset ( $this->args['page'] ) ) { |
|
289 | + if ( ! isset ($this->args['page'])) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | - $this->__set( 'paged', $this->args['page'] ); |
|
294 | - $this->__unset( 'page' ); |
|
293 | + $this->__set('paged', $this->args['page']); |
|
294 | + $this->__unset('page'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -304,17 +304,17 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function per_page() { |
306 | 306 | |
307 | - if ( ! isset( $this->args['number'] ) ) { |
|
307 | + if ( ! isset($this->args['number'])) { |
|
308 | 308 | return; |
309 | 309 | } |
310 | 310 | |
311 | - if ( $this->args['number'] == - 1 ) { |
|
312 | - $this->__set( 'nopaging', true ); |
|
311 | + if ($this->args['number'] == - 1) { |
|
312 | + $this->__set('nopaging', true); |
|
313 | 313 | } else { |
314 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
314 | + $this->__set('posts_per_page', $this->args['number']); |
|
315 | 315 | } |
316 | 316 | |
317 | - $this->__unset( 'number' ); |
|
317 | + $this->__unset('number'); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | * @return void |
327 | 327 | */ |
328 | 328 | public function month() { |
329 | - if ( ! isset ( $this->args['month'] ) ) { |
|
329 | + if ( ! isset ($this->args['month'])) { |
|
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
334 | - $this->__unset( 'month' ); |
|
333 | + $this->__set('monthnum', $this->args['month']); |
|
334 | + $this->__unset('month'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
@@ -343,23 +343,23 @@ discard block |
||
343 | 343 | * @return void |
344 | 344 | */ |
345 | 345 | public function orderby() { |
346 | - switch ( $this->args['orderby'] ) { |
|
346 | + switch ($this->args['orderby']) { |
|
347 | 347 | case 'amount' : |
348 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
349 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
348 | + $this->__set('orderby', 'meta_value_num'); |
|
349 | + $this->__set('meta_key', '_give_payment_total'); |
|
350 | 350 | break; |
351 | 351 | |
352 | 352 | case 'status' : |
353 | - $this->__set( 'orderby', 'post_status' ); |
|
353 | + $this->__set('orderby', 'post_status'); |
|
354 | 354 | break; |
355 | 355 | |
356 | 356 | case 'donation_form' : |
357 | - $this->__set( 'orderby', 'meta_value' ); |
|
358 | - $this->__set( 'meta_key', '_give_payment_form_title' ); |
|
357 | + $this->__set('orderby', 'meta_value'); |
|
358 | + $this->__set('meta_key', '_give_payment_form_title'); |
|
359 | 359 | break; |
360 | 360 | |
361 | 361 | default : |
362 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
362 | + $this->__set('orderby', $this->args['orderby']); |
|
363 | 363 | break; |
364 | 364 | } |
365 | 365 | } |
@@ -376,17 +376,17 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @return mixed |
378 | 378 | */ |
379 | - public function custom_orderby( $order, $query ) { |
|
379 | + public function custom_orderby($order, $query) { |
|
380 | 380 | global $wpdb; |
381 | 381 | |
382 | - $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] ); |
|
383 | - if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) { |
|
382 | + $post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']); |
|
383 | + if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) { |
|
384 | 384 | return $order; |
385 | 385 | } |
386 | 386 | |
387 | - switch ( $query->query['orderby'] ) { |
|
387 | + switch ($query->query['orderby']) { |
|
388 | 388 | case 'post_status': |
389 | - $order = $wpdb->posts .'.post_status ' . strtoupper( $query->query['order'] ); |
|
389 | + $order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']); |
|
390 | 390 | break; |
391 | 391 | } |
392 | 392 | |
@@ -402,20 +402,20 @@ discard block |
||
402 | 402 | * @return void |
403 | 403 | */ |
404 | 404 | public function user() { |
405 | - if ( is_null( $this->args['user'] ) ) { |
|
405 | + if (is_null($this->args['user'])) { |
|
406 | 406 | return; |
407 | 407 | } |
408 | 408 | |
409 | - if ( is_numeric( $this->args['user'] ) ) { |
|
409 | + if (is_numeric($this->args['user'])) { |
|
410 | 410 | $user_key = '_give_payment_user_id'; |
411 | 411 | } else { |
412 | 412 | $user_key = '_give_payment_user_email'; |
413 | 413 | } |
414 | 414 | |
415 | - $this->__set( 'meta_query', array( |
|
415 | + $this->__set('meta_query', array( |
|
416 | 416 | 'key' => $user_key, |
417 | 417 | 'value' => $this->args['user'], |
418 | - ) ); |
|
418 | + )); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -426,14 +426,14 @@ discard block |
||
426 | 426 | * @return void |
427 | 427 | */ |
428 | 428 | public function donor() { |
429 | - if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) { |
|
429 | + if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) { |
|
430 | 430 | return; |
431 | 431 | } |
432 | 432 | |
433 | - $this->__set( 'meta_query', array( |
|
433 | + $this->__set('meta_query', array( |
|
434 | 434 | 'key' => '_give_payment_customer_id', |
435 | 435 | 'value' => (int) $this->args['donor'], |
436 | - ) ); |
|
436 | + )); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -446,33 +446,33 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function search() { |
448 | 448 | |
449 | - if ( ! isset( $this->args['s'] ) ) { |
|
449 | + if ( ! isset($this->args['s'])) { |
|
450 | 450 | return; |
451 | 451 | } |
452 | 452 | |
453 | - $search = trim( $this->args['s'] ); |
|
453 | + $search = trim($this->args['s']); |
|
454 | 454 | |
455 | - if ( empty( $search ) ) { |
|
455 | + if (empty($search)) { |
|
456 | 456 | return; |
457 | 457 | } |
458 | 458 | |
459 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
460 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
459 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
460 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
461 | 461 | |
462 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
462 | + if ( ! empty($this->args['search_in_notes'])) { |
|
463 | 463 | |
464 | - $notes = give_get_payment_notes( 0, $search ); |
|
464 | + $notes = give_get_payment_notes(0, $search); |
|
465 | 465 | |
466 | - if ( ! empty( $notes ) ) { |
|
466 | + if ( ! empty($notes)) { |
|
467 | 467 | |
468 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
468 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
469 | 469 | |
470 | - $this->__set( 'post__in', $payment_ids ); |
|
470 | + $this->__set('post__in', $payment_ids); |
|
471 | 471 | } |
472 | 472 | |
473 | - $this->__unset( 's' ); |
|
473 | + $this->__unset('s'); |
|
474 | 474 | |
475 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
475 | + } elseif ($is_email || strlen($search) == 32) { |
|
476 | 476 | |
477 | 477 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
478 | 478 | $search_meta = array( |
@@ -481,19 +481,19 @@ discard block |
||
481 | 481 | 'compare' => 'LIKE', |
482 | 482 | ); |
483 | 483 | |
484 | - $this->__set( 'meta_query', $search_meta ); |
|
485 | - $this->__unset( 's' ); |
|
484 | + $this->__set('meta_query', $search_meta); |
|
485 | + $this->__unset('s'); |
|
486 | 486 | |
487 | - } elseif ( $is_user ) { |
|
487 | + } elseif ($is_user) { |
|
488 | 488 | |
489 | 489 | $search_meta = array( |
490 | 490 | 'key' => '_give_payment_user_id', |
491 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ), |
|
491 | + 'value' => trim(str_replace('user:', '', strtolower($search))), |
|
492 | 492 | ); |
493 | 493 | |
494 | - $this->__set( 'meta_query', $search_meta ); |
|
494 | + $this->__set('meta_query', $search_meta); |
|
495 | 495 | |
496 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
496 | + if (give_get_option('enable_sequential')) { |
|
497 | 497 | |
498 | 498 | $search_meta = array( |
499 | 499 | 'key' => '_give_payment_number', |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | 'compare' => 'LIKE', |
502 | 502 | ); |
503 | 503 | |
504 | - $this->__set( 'meta_query', $search_meta ); |
|
504 | + $this->__set('meta_query', $search_meta); |
|
505 | 505 | |
506 | 506 | $this->args['meta_query']['relation'] = 'OR'; |
507 | 507 | |
508 | 508 | } |
509 | 509 | |
510 | - $this->__unset( 's' ); |
|
510 | + $this->__unset('s'); |
|
511 | 511 | |
512 | 512 | } elseif ( |
513 | - give_get_option( 'enable_sequential' ) && |
|
513 | + give_get_option('enable_sequential') && |
|
514 | 514 | ( |
515 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
516 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
515 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
516 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
517 | 517 | ) |
518 | 518 | ) { |
519 | 519 | |
@@ -523,29 +523,29 @@ discard block |
||
523 | 523 | 'compare' => 'LIKE', |
524 | 524 | ); |
525 | 525 | |
526 | - $this->__set( 'meta_query', $search_meta ); |
|
527 | - $this->__unset( 's' ); |
|
526 | + $this->__set('meta_query', $search_meta); |
|
527 | + $this->__unset('s'); |
|
528 | 528 | |
529 | - } elseif ( is_numeric( $search ) ) { |
|
529 | + } elseif (is_numeric($search)) { |
|
530 | 530 | |
531 | - $post = get_post( $search ); |
|
531 | + $post = get_post($search); |
|
532 | 532 | |
533 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
533 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
534 | 534 | |
535 | 535 | $arr = array(); |
536 | 536 | $arr[] = $search; |
537 | - $this->__set( 'post__in', $arr ); |
|
538 | - $this->__unset( 's' ); |
|
537 | + $this->__set('post__in', $arr); |
|
538 | + $this->__unset('s'); |
|
539 | 539 | } |
540 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
540 | + } elseif ('#' == substr($search, 0, 1)) { |
|
541 | 541 | |
542 | - $search = str_replace( '#:', '', $search ); |
|
543 | - $search = str_replace( '#', '', $search ); |
|
544 | - $this->__set( 'give_forms', $search ); |
|
545 | - $this->__unset( 's' ); |
|
542 | + $search = str_replace('#:', '', $search); |
|
543 | + $search = str_replace('#', '', $search); |
|
544 | + $this->__set('give_forms', $search); |
|
545 | + $this->__unset('s'); |
|
546 | 546 | |
547 | 547 | } else { |
548 | - $this->__set( 's', $search ); |
|
548 | + $this->__set('s', $search); |
|
549 | 549 | |
550 | 550 | } |
551 | 551 | |
@@ -560,16 +560,16 @@ discard block |
||
560 | 560 | * @return void |
561 | 561 | */ |
562 | 562 | public function mode() { |
563 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
564 | - $this->__unset( 'mode' ); |
|
563 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
564 | + $this->__unset('mode'); |
|
565 | 565 | |
566 | 566 | return; |
567 | 567 | } |
568 | 568 | |
569 | - $this->__set( 'meta_query', array( |
|
569 | + $this->__set('meta_query', array( |
|
570 | 570 | 'key' => '_give_payment_mode', |
571 | 571 | 'value' => $this->args['mode'], |
572 | - ) ); |
|
572 | + )); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -581,10 +581,10 @@ discard block |
||
581 | 581 | * @return void |
582 | 582 | */ |
583 | 583 | public function children() { |
584 | - if ( empty( $this->args['children'] ) ) { |
|
585 | - $this->__set( 'post_parent', 0 ); |
|
584 | + if (empty($this->args['children'])) { |
|
585 | + $this->__set('post_parent', 0); |
|
586 | 586 | } |
587 | - $this->__unset( 'children' ); |
|
587 | + $this->__unset('children'); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
@@ -597,25 +597,25 @@ discard block |
||
597 | 597 | */ |
598 | 598 | public function give_forms() { |
599 | 599 | |
600 | - if ( empty( $this->args['give_forms'] ) ) { |
|
600 | + if (empty($this->args['give_forms'])) { |
|
601 | 601 | return; |
602 | 602 | } |
603 | 603 | |
604 | 604 | $compare = '='; |
605 | 605 | |
606 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
606 | + if (is_array($this->args['give_forms'])) { |
|
607 | 607 | $compare = 'IN'; |
608 | 608 | } |
609 | 609 | |
610 | - $this->__set( 'meta_query', array( |
|
610 | + $this->__set('meta_query', array( |
|
611 | 611 | array( |
612 | 612 | 'key' => '_give_payment_form_id', |
613 | 613 | 'value' => $this->args['give_forms'], |
614 | 614 | 'compare' => $compare, |
615 | 615 | ), |
616 | - ) ); |
|
616 | + )); |
|
617 | 617 | |
618 | - $this->__unset( 'give_forms' ); |
|
618 | + $this->__unset('give_forms'); |
|
619 | 619 | |
620 | 620 | } |
621 | 621 |
@@ -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 | |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return bool $ret True if guest checkout is enabled, false otherwise |
29 | 29 | */ |
30 | -function give_no_guest_checkout( $form_id ) { |
|
30 | +function give_no_guest_checkout($form_id) { |
|
31 | 31 | |
32 | 32 | $backtrace = debug_backtrace(); |
33 | 33 | |
34 | - _give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace ); |
|
34 | + _give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace); |
|
35 | 35 | |
36 | - $ret = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
36 | + $ret = give_get_meta($form_id, '_give_logged_in_only', true); |
|
37 | 37 | |
38 | - return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) ); |
|
38 | + return (bool) apply_filters('give_no_guest_checkout', give_is_setting_enabled($ret)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | |
51 | 51 | $backtrace = debug_backtrace(); |
52 | 52 | |
53 | - _give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace ); |
|
53 | + _give_deprecated_function(__FUNCTION__, '1.8', null, $backtrace); |
|
54 | 54 | |
55 | 55 | $views = array( |
56 | - 'sales' => __( 'Donations', 'give' ), |
|
57 | - 'gateway_errors' => __( 'Payment Errors', 'give' ), |
|
58 | - 'api_requests' => __( 'API Requests', 'give' ), |
|
56 | + 'sales' => __('Donations', 'give'), |
|
57 | + 'gateway_errors' => __('Payment Errors', 'give'), |
|
58 | + 'api_requests' => __('API Requests', 'give'), |
|
59 | 59 | ); |
60 | 60 | |
61 | - $views = apply_filters( 'give_log_views', $views ); |
|
61 | + $views = apply_filters('give_log_views', $views); |
|
62 | 62 | |
63 | 63 | return $views; |
64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $backtrace = debug_backtrace(); |
75 | 75 | |
76 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace ); |
|
76 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace); |
|
77 | 77 | |
78 | 78 | // Call new renamed function. |
79 | 79 | give_donation_form_validate_agree_to_terms(); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $backtrace = debug_backtrace(); |
92 | 92 | |
93 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace ); |
|
93 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace); |
|
94 | 94 | |
95 | 95 | // Call new renamed function. |
96 | 96 | give_donation_form_validate_logged_in_user(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | $backtrace = debug_backtrace(); |
109 | 109 | |
110 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace ); |
|
110 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace); |
|
111 | 111 | |
112 | 112 | // Call new renamed function. |
113 | 113 | give_donation_form_validate_gateway(); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $backtrace = debug_backtrace(); |
126 | 126 | |
127 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace ); |
|
127 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace); |
|
128 | 128 | |
129 | 129 | // Call new renamed function. |
130 | 130 | give_donation_form_validate_fields(); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $backtrace = debug_backtrace(); |
143 | 143 | |
144 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace ); |
|
144 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace); |
|
145 | 145 | |
146 | 146 | // Call new renamed function. |
147 | 147 | give_donation_form_validate_cc(); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | $backtrace = debug_backtrace(); |
160 | 160 | |
161 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace ); |
|
161 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace); |
|
162 | 162 | |
163 | 163 | // Call new renamed function. |
164 | 164 | give_get_donation_cc_info(); |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * @param int $zip |
176 | 176 | * @param string $country_code |
177 | 177 | */ |
178 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
178 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
179 | 179 | |
180 | 180 | $backtrace = debug_backtrace(); |
181 | 181 | |
182 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace ); |
|
182 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace); |
|
183 | 183 | |
184 | 184 | // Call new renamed function. |
185 | - give_donation_form_validate_cc_zip( $zip, $country_code ); |
|
185 | + give_donation_form_validate_cc_zip($zip, $country_code); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $backtrace = debug_backtrace(); |
198 | 198 | |
199 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace ); |
|
199 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace); |
|
200 | 200 | |
201 | 201 | // Call new renamed function. |
202 | 202 | give_donation_form_validate_user_login(); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | $backtrace = debug_backtrace(); |
215 | 215 | |
216 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace ); |
|
216 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace); |
|
217 | 217 | |
218 | 218 | // Call new renamed function. |
219 | 219 | give_donation_form_validate_guest_user(); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | $backtrace = debug_backtrace(); |
232 | 232 | |
233 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace ); |
|
233 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace); |
|
234 | 234 | |
235 | 235 | // Call new renamed function. |
236 | 236 | give_donation_form_validate_new_user(); |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param array $valid_data |
248 | 248 | */ |
249 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
249 | +function give_get_purchase_form_user($valid_data = array()) { |
|
250 | 250 | |
251 | 251 | $backtrace = debug_backtrace(); |
252 | 252 | |
253 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace ); |
|
253 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace); |
|
254 | 254 | |
255 | 255 | // Call new renamed function. |
256 | - give_get_donation_form_user( $valid_data ); |
|
256 | + give_get_donation_form_user($valid_data); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return string |
271 | 271 | */ |
272 | -function give_checkout_button_purchase( $form_id ) { |
|
272 | +function give_checkout_button_purchase($form_id) { |
|
273 | 273 | $backtrace = debug_backtrace(); |
274 | 274 | |
275 | - _give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace ); |
|
275 | + _give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace); |
|
276 | 276 | |
277 | - return give_get_donation_form_submit_button( $form_id ); |
|
277 | + return give_get_donation_form_submit_button($form_id); |
|
278 | 278 | |
279 | 279 | } |
280 | 280 | |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return int $customer_id Customer ID. |
289 | 289 | */ |
290 | -function give_get_payment_customer_id( $payment_id ) { |
|
290 | +function give_get_payment_customer_id($payment_id) { |
|
291 | 291 | |
292 | 292 | $backtrace = debug_backtrace(); |
293 | 293 | |
294 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace ); |
|
294 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace); |
|
295 | 295 | |
296 | - return give_get_payment_donor_id( $payment_id ); |
|
296 | + return give_get_payment_donor_id($payment_id); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | $backtrace = debug_backtrace(); |
310 | 310 | |
311 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace ); |
|
311 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace); |
|
312 | 312 | |
313 | 313 | return give_get_total_donations(); |
314 | 314 | } |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return int The total number of donations |
328 | 328 | */ |
329 | -function give_count_purchases_of_customer( $user = null ) { |
|
329 | +function give_count_purchases_of_customer($user = null) { |
|
330 | 330 | |
331 | 331 | $backtrace = debug_backtrace(); |
332 | 332 | |
333 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace ); |
|
333 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace); |
|
334 | 334 | |
335 | - return give_count_donations_of_donor( $user ); |
|
335 | + return give_count_donations_of_donor($user); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return array |
350 | 350 | */ |
351 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
351 | +function give_get_purchase_stats_by_user($user = '') { |
|
352 | 352 | |
353 | 353 | $backtrace = debug_backtrace(); |
354 | 354 | |
355 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace ); |
|
355 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace); |
|
356 | 356 | |
357 | - return give_get_donation_stats_by_user( $user ); |
|
357 | + return give_get_donation_stats_by_user($user); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return bool|object List of all user donations |
374 | 374 | */ |
375 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
375 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
376 | 376 | |
377 | 377 | $backtrace = debug_backtrace(); |
378 | 378 | |
379 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace ); |
|
379 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace); |
|
380 | 380 | |
381 | - return give_get_users_donations( $user, $number, $pagination, $status ); |
|
381 | + return give_get_users_donations($user, $number, $pagination, $status); |
|
382 | 382 | |
383 | 383 | } |
384 | 384 | |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return bool True if has donated, false other wise. |
397 | 397 | */ |
398 | -function give_has_purchases( $user_id = null ) { |
|
398 | +function give_has_purchases($user_id = null) { |
|
399 | 399 | |
400 | 400 | $backtrace = debug_backtrace(); |
401 | 401 | |
402 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_has_donations', $backtrace ); |
|
402 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_has_donations', $backtrace); |
|
403 | 403 | |
404 | - return give_has_donations( $user_id ); |
|
404 | + return give_has_donations($user_id); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | function give_count_total_customers() { |
416 | 416 | $backtrace = debug_backtrace(); |
417 | 417 | |
418 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace ); |
|
418 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace); |
|
419 | 419 | |
420 | 420 | return give_count_total_donors(); |
421 | 421 | } |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return float The total amount the user has spent |
432 | 432 | */ |
433 | -function give_purchase_total_of_user( $user = null ) { |
|
433 | +function give_purchase_total_of_user($user = null) { |
|
434 | 434 | |
435 | 435 | $backtrace = debug_backtrace(); |
436 | 436 | |
437 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace ); |
|
437 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace); |
|
438 | 438 | |
439 | - return give_donation_total_of_user( $user ); |
|
439 | + return give_donation_total_of_user($user); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -450,13 +450,13 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return void |
452 | 452 | */ |
453 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
453 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
454 | 454 | |
455 | 455 | $backtrace = debug_backtrace(); |
456 | 456 | |
457 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace ); |
|
457 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace); |
|
458 | 458 | |
459 | - give_delete_donation( $payment_id, $update_customer ); |
|
459 | + give_delete_donation($payment_id, $update_customer); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
@@ -474,13 +474,13 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return void |
476 | 476 | */ |
477 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
477 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
478 | 478 | |
479 | 479 | $backtrace = debug_backtrace(); |
480 | 480 | |
481 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace ); |
|
481 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace); |
|
482 | 482 | |
483 | - give_undo_donation( $payment_id ); |
|
483 | + give_undo_donation($payment_id); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -493,12 +493,12 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return void |
495 | 495 | */ |
496 | -function give_trigger_purchase_delete( $data ) { |
|
496 | +function give_trigger_purchase_delete($data) { |
|
497 | 497 | $backtrace = debug_backtrace(); |
498 | 498 | |
499 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace ); |
|
499 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace); |
|
500 | 500 | |
501 | - give_trigger_donation_delete( $data ); |
|
501 | + give_trigger_donation_delete($data); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | * |
513 | 513 | * @return bool|int |
514 | 514 | */ |
515 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
515 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
516 | 516 | $backtrace = debug_backtrace(); |
517 | 517 | |
518 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace ); |
|
518 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace); |
|
519 | 519 | |
520 | - give_increase_donation_count( $form_id, $quantity ); |
|
520 | + give_increase_donation_count($form_id, $quantity); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return void |
538 | 538 | */ |
539 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
539 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
540 | 540 | $backtrace = debug_backtrace(); |
541 | 541 | |
542 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace ); |
|
542 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace); |
|
543 | 543 | |
544 | - give_record_donation_in_log( $give_form_id, $payment_id, $price_id, $sale_date ); |
|
544 | + give_record_donation_in_log($give_form_id, $payment_id, $price_id, $sale_date); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return void |
560 | 560 | */ |
561 | -function give_print_errors( $form_id ) { |
|
561 | +function give_print_errors($form_id) { |
|
562 | 562 | $backtrace = debug_backtrace(); |
563 | 563 | |
564 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace ); |
|
564 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace); |
|
565 | 565 | |
566 | - do_action( 'give_frontend_notices', $form_id ); |
|
566 | + do_action('give_frontend_notices', $form_id); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @return string $error |
581 | 581 | */ |
582 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
582 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
583 | 583 | $backtrace = debug_backtrace(); |
584 | 584 | |
585 | - _give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace ); |
|
585 | + _give_deprecated_function(__FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace); |
|
586 | 586 | |
587 | - Give()->notices->print_frontend_notice( $message, $echo, $error_id ); |
|
587 | + Give()->notices->print_frontend_notice($message, $echo, $error_id); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | * |
601 | 601 | * @return string |
602 | 602 | */ |
603 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
603 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
604 | 604 | |
605 | 605 | $backtrace = debug_backtrace(); |
606 | 606 | |
607 | - _give_deprecated_function( __FUNCTION__, '1.8.12', 'give_payment_gateway_donation_summary', $backtrace ); |
|
607 | + _give_deprecated_function(__FUNCTION__, '1.8.12', 'give_payment_gateway_donation_summary', $backtrace); |
|
608 | 608 | |
609 | 609 | give_payment_gateway_donation_summary($purchase_data, $email); |
610 | 610 |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * Return the calculated completion percentage. |
217 | 217 | * |
218 | 218 | * @since 1.8.12 |
219 | - * @return int |
|
219 | + * @return double |
|
220 | 220 | */ |
221 | 221 | public function get_percentage_complete() { |
222 | 222 | return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
@@ -353,6 +353,9 @@ discard block |
||
353 | 353 | return true; |
354 | 354 | } |
355 | 355 | |
356 | + /** |
|
357 | + * @param integer $page |
|
358 | + */ |
|
356 | 359 | public function get_delete_ids( $donation_ids, $page ) { |
357 | 360 | $index = $page --; |
358 | 361 | $count = count( $donation_ids ); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -109,32 +109,32 @@ discard block |
||
109 | 109 | $donor_ids = array(); |
110 | 110 | |
111 | 111 | // Check if the ajax request if running for the first time. |
112 | - if ( 1 === (int) $this->step ) { |
|
112 | + if (1 === (int) $this->step) { |
|
113 | 113 | // Delete all the donation ids. |
114 | - $this->delete_option( $this->donation_key ); |
|
114 | + $this->delete_option($this->donation_key); |
|
115 | 115 | // Delete all the donor ids. |
116 | - $this->delete_option( $this->donor_key ); |
|
116 | + $this->delete_option($this->donor_key); |
|
117 | 117 | |
118 | 118 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
119 | - $this->update_option( $this->step_key, 'count' ); |
|
119 | + $this->update_option($this->step_key, 'count'); |
|
120 | 120 | |
121 | 121 | // Delete tha page count of the step. |
122 | - $this->update_option( $this->step_on_key, '0' ); |
|
122 | + $this->update_option($this->step_on_key, '0'); |
|
123 | 123 | } else { |
124 | 124 | // Get the old donors list. |
125 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
125 | + $donor_ids = $this->get_option($this->donor_key); |
|
126 | 126 | |
127 | 127 | // Get the old donation list. |
128 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
128 | + $donation_ids = $this->get_option($this->donation_key); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
132 | 132 | $step = (int) $this->get_step(); |
133 | - if ( 1 === $step ) { |
|
133 | + if (1 === $step) { |
|
134 | 134 | /** |
135 | 135 | * Will add or update the donation and donor data by running wp query. |
136 | 136 | */ |
137 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
137 | + $this->count($step, $donation_ids, $donor_ids); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
146 | 146 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
147 | 147 | */ |
148 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
148 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
149 | 149 | |
150 | 150 | // Get the Page count by default it's zero. |
151 | 151 | $paged = (int) $this->get_step_page(); |
152 | 152 | // Incresed the page count by one. |
153 | - ++ $paged; |
|
153 | + ++$paged; |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Filter add to alter the argument before the wp quest run |
157 | 157 | */ |
158 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
158 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
159 | 159 | 'post_type' => 'give_payment', |
160 | 160 | 'post_status' => 'any', |
161 | 161 | 'posts_per_page' => $this->per_step, |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | // ONLY TEST MODE TRANSACTIONS!!! |
164 | 164 | 'meta_key' => '_give_payment_mode', |
165 | 165 | 'meta_value' => 'test' |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | |
168 | 168 | // Reset the post data. |
169 | 169 | wp_reset_postdata(); |
170 | 170 | // Getting the new donation. |
171 | - $donation_posts = new WP_Query( $args ); |
|
171 | + $donation_posts = new WP_Query($args); |
|
172 | 172 | |
173 | 173 | // The Loop. |
174 | - if ( $donation_posts->have_posts() ) { |
|
175 | - while ( $donation_posts->have_posts() ) { |
|
174 | + if ($donation_posts->have_posts()) { |
|
175 | + while ($donation_posts->have_posts()) { |
|
176 | 176 | $donation_posts->the_post(); |
177 | 177 | global $post; |
178 | 178 | // Add the donation id in side the array. |
@@ -191,23 +191,23 @@ discard block |
||
191 | 191 | $max_num_pages = (int) $donation_posts->max_num_pages; |
192 | 192 | |
193 | 193 | // Check current page is less then max number of page or not |
194 | - if ( $paged < $max_num_pages ) { |
|
194 | + if ($paged < $max_num_pages) { |
|
195 | 195 | // Update the curretn page virable for the next step |
196 | - $this->update_option( $this->step_on_key, $paged ); |
|
196 | + $this->update_option($this->step_on_key, $paged); |
|
197 | 197 | |
198 | 198 | // Calculating percentage. |
199 | 199 | $page_remain = $max_num_pages - $paged; |
200 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
200 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
201 | 201 | $this->step_completed = $paged; |
202 | 202 | } else { |
203 | - $donation_ids_count = count( $donor_ids ); |
|
204 | - $this->update_option( $this->step_key, 'donation' ); |
|
205 | - $this->update_option( $this->step_on_key, '0' ); |
|
203 | + $donation_ids_count = count($donor_ids); |
|
204 | + $this->update_option($this->step_key, 'donation'); |
|
205 | + $this->update_option($this->step_on_key, '0'); |
|
206 | 206 | } |
207 | 207 | |
208 | - $donor_ids = array_unique( $donor_ids ); |
|
209 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
210 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
208 | + $donor_ids = array_unique($donor_ids); |
|
209 | + $this->update_option($this->donor_key, $donor_ids); |
|
210 | + $this->update_option($this->donation_key, $donation_ids); |
|
211 | 211 | |
212 | 212 | wp_reset_postdata(); |
213 | 213 | } |
@@ -219,34 +219,34 @@ discard block |
||
219 | 219 | * @return int |
220 | 220 | */ |
221 | 221 | public function get_percentage_complete() { |
222 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
222 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | public function process_step() { |
226 | 226 | |
227 | - if ( ! $this->can_export() ) { |
|
228 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
227 | + if ( ! $this->can_export()) { |
|
228 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $had_data = $this->get_data(); |
232 | 232 | |
233 | - if ( $had_data ) { |
|
233 | + if ($had_data) { |
|
234 | 234 | $this->done = false; |
235 | 235 | |
236 | 236 | return true; |
237 | 237 | } else { |
238 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
239 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
238 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
239 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
240 | 240 | |
241 | - $this->delete_option( $this->donation_key ); |
|
241 | + $this->delete_option($this->donation_key); |
|
242 | 242 | |
243 | 243 | // Reset the sequential order numbers |
244 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
245 | - delete_option( 'give_last_payment_number' ); |
|
244 | + if (give_get_option('enable_sequential')) { |
|
245 | + delete_option('give_last_payment_number'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | $this->done = true; |
249 | - $this->message = __( 'Test donor and transactions successfully deleted.', 'give' ); |
|
249 | + $this->message = __('Test donor and transactions successfully deleted.', 'give'); |
|
250 | 250 | |
251 | 251 | return false; |
252 | 252 | } |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | public function get_data() { |
265 | 265 | |
266 | 266 | // Get the donation id's. |
267 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
267 | + $donation_ids = $this->get_option($this->donation_key); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Return false id not test donation is found. |
271 | 271 | */ |
272 | - if ( empty( $donation_ids ) ) { |
|
272 | + if (empty($donation_ids)) { |
|
273 | 273 | $this->is_empty = true; |
274 | 274 | $this->total_step = 1; |
275 | 275 | |
@@ -280,68 +280,68 @@ discard block |
||
280 | 280 | $step = (int) $this->get_step(); |
281 | 281 | |
282 | 282 | // get teh donor ids. |
283 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
283 | + $donor_ids = $this->get_option($this->donor_key); |
|
284 | 284 | |
285 | 285 | // In step to we delete all the donation in loop. |
286 | - if ( 2 === $step ) { |
|
286 | + if (2 === $step) { |
|
287 | 287 | $pass_to_donor = false; |
288 | 288 | $page = (int) $this->get_step_page(); |
289 | - $page ++; |
|
290 | - $count = count( $donation_ids ); |
|
289 | + $page++; |
|
290 | + $count = count($donation_ids); |
|
291 | 291 | |
292 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
292 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
293 | 293 | $this->step_completed = $page; |
294 | 294 | |
295 | 295 | |
296 | - if ( $count > $this->per_step ) { |
|
296 | + if ($count > $this->per_step) { |
|
297 | 297 | |
298 | - $this->update_option( $this->step_on_key, $page ); |
|
299 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
300 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
298 | + $this->update_option($this->step_on_key, $page); |
|
299 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
300 | + $current_page = (int) ceil($count / $this->per_step); |
|
301 | 301 | |
302 | - if ( $page === $current_page ) { |
|
302 | + if ($page === $current_page) { |
|
303 | 303 | $pass_to_donor = true; |
304 | 304 | } |
305 | 305 | } else { |
306 | 306 | $pass_to_donor = true; |
307 | 307 | } |
308 | 308 | |
309 | - if ( true === $pass_to_donor ) { |
|
310 | - $this->update_option( $this->step_key, 'donor' ); |
|
311 | - $this->update_option( $this->step_on_key, '0' ); |
|
309 | + if (true === $pass_to_donor) { |
|
310 | + $this->update_option($this->step_key, 'donor'); |
|
311 | + $this->update_option($this->step_on_key, '0'); |
|
312 | 312 | } |
313 | 313 | |
314 | - foreach ( $donation_ids as $item ) { |
|
315 | - wp_delete_post( $item, true ); |
|
314 | + foreach ($donation_ids as $item) { |
|
315 | + wp_delete_post($item, true); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
319 | 319 | |
320 | 320 | // Here we delete all the donor |
321 | - if ( 3 === $step ) { |
|
321 | + if (3 === $step) { |
|
322 | 322 | $page = (int) $this->get_step_page(); |
323 | - $count = count( $donor_ids ); |
|
323 | + $count = count($donor_ids); |
|
324 | 324 | |
325 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
326 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
325 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
326 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
327 | 327 | |
328 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
328 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
329 | 329 | 'post_type' => 'give_payment', |
330 | 330 | 'post_status' => 'any', |
331 | 331 | 'posts_per_page' => 1, |
332 | 332 | 'meta_key' => '_give_payment_mode', |
333 | 333 | 'meta_value' => 'live', |
334 | - 'author' => $donor_ids[ $page ] |
|
335 | - ) ); |
|
334 | + 'author' => $donor_ids[$page] |
|
335 | + )); |
|
336 | 336 | |
337 | - $donation_posts = get_posts( $args ); |
|
338 | - if ( empty( $donation_posts ) ) { |
|
339 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
337 | + $donation_posts = get_posts($args); |
|
338 | + if (empty($donation_posts)) { |
|
339 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
340 | 340 | } |
341 | 341 | |
342 | - $page ++; |
|
343 | - $this->update_option( $this->step_on_key, $page ); |
|
344 | - if ( $count === $page ) { |
|
342 | + $page++; |
|
343 | + $this->update_option($this->step_on_key, $page); |
|
344 | + if ($count === $page) { |
|
345 | 345 | $this->is_empty = false; |
346 | 346 | |
347 | 347 | return false; |
@@ -353,24 +353,24 @@ discard block |
||
353 | 353 | return true; |
354 | 354 | } |
355 | 355 | |
356 | - public function get_delete_ids( $donation_ids, $page ) { |
|
357 | - $index = $page --; |
|
358 | - $count = count( $donation_ids ); |
|
356 | + public function get_delete_ids($donation_ids, $page) { |
|
357 | + $index = $page--; |
|
358 | + $count = count($donation_ids); |
|
359 | 359 | $temp = 0; |
360 | 360 | $current_page = 0; |
361 | 361 | $post_delete = $this->per_step; |
362 | 362 | $page_donation_id = array(); |
363 | 363 | |
364 | - foreach ( $donation_ids as $item ) { |
|
365 | - $temp ++; |
|
366 | - $page_donation_id[ $current_page ][] = $item; |
|
367 | - if ( $temp === $post_delete ) { |
|
368 | - $current_page ++; |
|
364 | + foreach ($donation_ids as $item) { |
|
365 | + $temp++; |
|
366 | + $page_donation_id[$current_page][] = $item; |
|
367 | + if ($temp === $post_delete) { |
|
368 | + $current_page++; |
|
369 | 369 | $temp = 0; |
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | - return $page_donation_id[ $page ]; |
|
373 | + return $page_donation_id[$page]; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return mixed Returns the data from the database |
384 | 384 | */ |
385 | - public function get_option( $key, $defalut_value = false ) { |
|
386 | - return get_option( $key, $defalut_value ); |
|
385 | + public function get_option($key, $defalut_value = false) { |
|
386 | + return get_option($key, $defalut_value); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -396,8 +396,8 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return void |
398 | 398 | */ |
399 | - public function update_option( $key, $value ) { |
|
400 | - update_option( $key, $value, false ); |
|
399 | + public function update_option($key, $value) { |
|
400 | + update_option($key, $value, false); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return void |
411 | 411 | */ |
412 | - public function delete_option( $key ) { |
|
413 | - delete_option( $key ); |
|
412 | + public function delete_option($key) { |
|
413 | + delete_option($key); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | * @return int|string |
422 | 422 | */ |
423 | 423 | private function get_step() { |
424 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
425 | - if ( 'count' === $step_key ) { |
|
424 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
425 | + if ('count' === $step_key) { |
|
426 | 426 | return 1; |
427 | - } elseif ( 'donation' === $step_key ) { |
|
427 | + } elseif ('donation' === $step_key) { |
|
428 | 428 | return 2; |
429 | - } elseif ( 'donor' === $step_key ) { |
|
429 | + } elseif ('donor' === $step_key) { |
|
430 | 430 | return 3; |
431 | 431 | } else { |
432 | 432 | return $step_key; |
@@ -437,6 +437,6 @@ discard block |
||
437 | 437 | * Get the current $page value in the ajax. |
438 | 438 | */ |
439 | 439 | private function get_step_page() { |
440 | - return $this->get_option( $this->step_on_key, false ); |
|
440 | + return $this->get_option($this->step_on_key, false); |
|
441 | 441 | } |
442 | 442 | } |
@@ -340,7 +340,7 @@ |
||
340 | 340 | * @since 1.0 |
341 | 341 | * |
342 | 342 | * @param int|float|string $amount Formatted or sanitized price |
343 | - * @param int|bool $dp number of decimals |
|
343 | + * @param boolean $dp number of decimals |
|
344 | 344 | * @param bool $sanitize Whether or not sanitize number |
345 | 345 | * |
346 | 346 | * @return string $amount Newly formatted amount or Price Not Available |
@@ -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 | * @return mixed |
24 | 24 | */ |
25 | 25 | function give_get_price_decimals() { |
26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function give_get_price_thousand_separator() { |
37 | 37 | $give_options = give_get_settings(); |
38 | - $thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ','; |
|
39 | - $thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator; |
|
38 | + $thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ','; |
|
39 | + $thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator; |
|
40 | 40 | |
41 | 41 | return $thousand_separator; |
42 | 42 | } |
@@ -55,11 +55,10 @@ discard block |
||
55 | 55 | ); |
56 | 56 | |
57 | 57 | $thousand_separator = give_get_price_thousand_separator(); |
58 | - $default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ? |
|
59 | - $default_decimal_separators[$thousand_separator] : |
|
60 | - '.'; |
|
58 | + $default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ? |
|
59 | + $default_decimal_separators[$thousand_separator] : '.'; |
|
61 | 60 | |
62 | - $decimal_separator = give_get_option( 'decimal_separator', $default_decimal_separator ); |
|
61 | + $decimal_separator = give_get_option('decimal_separator', $default_decimal_separator); |
|
63 | 62 | |
64 | 63 | return $decimal_separator; |
65 | 64 | } |
@@ -74,8 +73,8 @@ discard block |
||
74 | 73 | * |
75 | 74 | * @return string $amount Newly sanitized amount |
76 | 75 | */ |
77 | -function give_sanitize_amount_for_db( $number ) { |
|
78 | - return give_sanitize_amount( $number, 6 ); |
|
76 | +function give_sanitize_amount_for_db($number) { |
|
77 | + return give_sanitize_amount($number, 6); |
|
79 | 78 | } |
80 | 79 | |
81 | 80 | /** |
@@ -89,33 +88,33 @@ discard block |
||
89 | 88 | * |
90 | 89 | * @return string $amount Newly sanitized amount |
91 | 90 | */ |
92 | -function give_maybe_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
91 | +function give_maybe_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
93 | 92 | $thousand_separator = give_get_price_thousand_separator(); |
94 | 93 | $decimal_separator = give_get_price_decimal_separator(); |
95 | 94 | |
96 | 95 | // Bailout. |
97 | - if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
96 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
98 | 97 | return $number; |
99 | 98 | }elseif ( |
100 | - ( false == strpos( $number, $thousand_separator ) ) && |
|
101 | - ( false === strpos( $number, $decimal_separator ) ) |
|
99 | + (false == strpos($number, $thousand_separator)) && |
|
100 | + (false === strpos($number, $decimal_separator)) |
|
102 | 101 | ) { |
103 | - return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
102 | + return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
104 | 103 | } |
105 | 104 | |
106 | 105 | // Handle thousand separator as '.' |
107 | - if ( '.' === $thousand_separator && false !== strpos( $number, $thousand_separator ) ){ |
|
108 | - $number_parts = explode( '.', $number ); |
|
106 | + if ('.' === $thousand_separator && false !== strpos($number, $thousand_separator)) { |
|
107 | + $number_parts = explode('.', $number); |
|
109 | 108 | |
110 | - if( 2 === count( $number_parts ) && ( 6 === strlen( $number_parts[1] ) ) ) { |
|
109 | + if (2 === count($number_parts) && (6 === strlen($number_parts[1]))) { |
|
111 | 110 | // Trim zero from database value. |
112 | 111 | $trim_zeros = true; |
113 | 112 | } else { |
114 | - $number = str_replace( '.', '', $number ); |
|
113 | + $number = str_replace('.', '', $number); |
|
115 | 114 | } |
116 | 115 | } |
117 | 116 | |
118 | - return give_sanitize_amount( $number, $dp, $trim_zeros ); |
|
117 | + return give_sanitize_amount($number, $dp, $trim_zeros); |
|
119 | 118 | } |
120 | 119 | |
121 | 120 | /** |
@@ -131,67 +130,67 @@ discard block |
||
131 | 130 | * |
132 | 131 | * @return string $amount Newly sanitized amount |
133 | 132 | */ |
134 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
133 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
135 | 134 | |
136 | 135 | // Bailout. |
137 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
136 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
138 | 137 | return $number; |
139 | 138 | } |
140 | 139 | |
141 | 140 | // Remove slash from amount. |
142 | 141 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
143 | 142 | // To prevent notices and warning remove slash from amount/number. |
144 | - $number = wp_unslash( $number ); |
|
143 | + $number = wp_unslash($number); |
|
145 | 144 | |
146 | 145 | $thousand_separator = give_get_price_thousand_separator(); |
147 | 146 | |
148 | 147 | $locale = localeconv(); |
149 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
148 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
150 | 149 | |
151 | 150 | // Remove locale from string |
152 | - if ( ! is_float( $number ) ) { |
|
153 | - $number = str_replace( $decimals, '.', $number ); |
|
151 | + if ( ! is_float($number)) { |
|
152 | + $number = str_replace($decimals, '.', $number); |
|
154 | 153 | } |
155 | 154 | |
156 | 155 | // Remove thousand amount formatting if amount has. |
157 | 156 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
158 | 157 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
159 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
160 | - $number = str_replace( $thousand_separator, '', $number ); |
|
161 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
162 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
158 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
159 | + $number = str_replace($thousand_separator, '', $number); |
|
160 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
161 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
163 | 162 | } |
164 | 163 | |
165 | 164 | // Remove non numeric entity before decimal separator. |
166 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
165 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
167 | 166 | $default_dp = give_get_price_decimals(); |
168 | 167 | |
169 | 168 | // Reset negative amount to zero. |
170 | - if ( 0 > $number ) { |
|
171 | - $number = number_format( 0, $default_dp, '.' ); |
|
169 | + if (0 > $number) { |
|
170 | + $number = number_format(0, $default_dp, '.'); |
|
172 | 171 | } |
173 | 172 | |
174 | 173 | // If number does not have decimal then add number of decimals to it. |
175 | 174 | if ( |
176 | - false === strpos( $number, '.' ) |
|
177 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
175 | + false === strpos($number, '.') |
|
176 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
178 | 177 | ) { |
179 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
178 | + $number = number_format($number, $default_dp, '.', ''); |
|
180 | 179 | } |
181 | 180 | |
182 | 181 | // Format number by custom number of decimals. |
183 | - if ( false !== $dp ) { |
|
184 | - $dp = intval( is_bool( $dp ) ? $default_dp : $dp ); |
|
185 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
186 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
182 | + if (false !== $dp) { |
|
183 | + $dp = intval(is_bool($dp) ? $default_dp : $dp); |
|
184 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
185 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
187 | 186 | } |
188 | 187 | |
189 | 188 | // Trim zeros. |
190 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
191 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
189 | + if ($trim_zeros && strstr($number, '.')) { |
|
190 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
192 | 191 | } |
193 | 192 | |
194 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
193 | + return apply_filters('give_sanitize_amount', $number); |
|
195 | 194 | } |
196 | 195 | |
197 | 196 | /** |
@@ -204,10 +203,10 @@ discard block |
||
204 | 203 | * |
205 | 204 | * @return string $amount Newly formatted amount or Price Not Available |
206 | 205 | */ |
207 | -function give_format_amount( $amount, $args = array() ) { |
|
206 | +function give_format_amount($amount, $args = array()) { |
|
208 | 207 | // Backward compatibility. |
209 | - if( is_bool( $args ) ) { |
|
210 | - $args = array( 'decimal' => $args ); |
|
208 | + if (is_bool($args)) { |
|
209 | + $args = array('decimal' => $args); |
|
211 | 210 | } |
212 | 211 | |
213 | 212 | $default_args = array( |
@@ -216,60 +215,59 @@ discard block |
||
216 | 215 | 'currency' => give_get_currency(), |
217 | 216 | ); |
218 | 217 | |
219 | - $args = wp_parse_args( $args, $default_args ); |
|
218 | + $args = wp_parse_args($args, $default_args); |
|
220 | 219 | |
221 | 220 | $formatted = 0; |
222 | 221 | $thousands_sep = give_get_price_thousand_separator(); |
223 | 222 | $decimal_sep = give_get_price_decimal_separator(); |
224 | - $decimals = ! empty( $args['decimal'] ) ? give_get_price_decimals() : 0; |
|
223 | + $decimals = ! empty($args['decimal']) ? give_get_price_decimals() : 0; |
|
225 | 224 | $currency = $args['currency']; |
226 | 225 | |
227 | - if ( ! empty( $amount ) ) { |
|
226 | + if ( ! empty($amount)) { |
|
228 | 227 | // Sanitize amount before formatting. |
229 | - $amount = ! empty( $args['sanitize'] ) ? |
|
230 | - give_maybe_sanitize_amount( $amount, $decimals ) : |
|
231 | - number_format( $amount, $decimals, '.', '' ); |
|
228 | + $amount = ! empty($args['sanitize']) ? |
|
229 | + give_maybe_sanitize_amount($amount, $decimals) : number_format($amount, $decimals, '.', ''); |
|
232 | 230 | |
233 | - switch ( $currency ) { |
|
231 | + switch ($currency) { |
|
234 | 232 | case 'INR': |
235 | 233 | $decimal_amount = ''; |
236 | 234 | |
237 | 235 | // Extract decimals from amount |
238 | - if ( ( $pos = strpos( $amount, '.' ) ) !== false ) { |
|
239 | - if ( ! empty( $decimals ) ) { |
|
240 | - $decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 ); |
|
241 | - $amount = substr( $amount, 0, $pos ); |
|
242 | - |
|
243 | - if ( ! $decimal_amount ) { |
|
244 | - $decimal_amount = substr( '.0000000000', 0, ( $decimals + 1 ) ); |
|
245 | - } elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) { |
|
246 | - $decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) ); |
|
236 | + if (($pos = strpos($amount, '.')) !== false) { |
|
237 | + if ( ! empty($decimals)) { |
|
238 | + $decimal_amount = substr(round(substr($amount, $pos), $decimals), 1); |
|
239 | + $amount = substr($amount, 0, $pos); |
|
240 | + |
|
241 | + if ( ! $decimal_amount) { |
|
242 | + $decimal_amount = substr('.0000000000', 0, ($decimals + 1)); |
|
243 | + } elseif (($decimals + 1) > strlen($decimal_amount)) { |
|
244 | + $decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1)); |
|
247 | 245 | } |
248 | 246 | |
249 | 247 | } else { |
250 | - $amount = number_format( $amount, $decimals, $decimal_sep, '' ); |
|
248 | + $amount = number_format($amount, $decimals, $decimal_sep, ''); |
|
251 | 249 | } |
252 | 250 | } |
253 | 251 | |
254 | 252 | // Extract last 3 from amount |
255 | - $result = substr( $amount, - 3 ); |
|
256 | - $amount = substr( $amount, 0, - 3 ); |
|
253 | + $result = substr($amount, - 3); |
|
254 | + $amount = substr($amount, 0, - 3); |
|
257 | 255 | |
258 | 256 | // Apply digits 2 by 2 |
259 | - while ( strlen( $amount ) > 0 ) { |
|
260 | - $result = substr( $amount, - 2 ) . $thousands_sep . $result; |
|
261 | - $amount = substr( $amount, 0, - 2 ); |
|
257 | + while (strlen($amount) > 0) { |
|
258 | + $result = substr($amount, - 2).$thousands_sep.$result; |
|
259 | + $amount = substr($amount, 0, - 2); |
|
262 | 260 | } |
263 | 261 | |
264 | - $formatted = $result . $decimal_amount; |
|
262 | + $formatted = $result.$decimal_amount; |
|
265 | 263 | break; |
266 | 264 | |
267 | 265 | default: |
268 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
266 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
269 | 267 | } |
270 | 268 | } |
271 | 269 | |
272 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args ); |
|
270 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args); |
|
273 | 271 | } |
274 | 272 | |
275 | 273 | |
@@ -287,51 +285,51 @@ discard block |
||
287 | 285 | * |
288 | 286 | * @return float|string formatted amount number with large number names. |
289 | 287 | */ |
290 | -function give_human_format_large_amount( $amount, $args = array() ) { |
|
288 | +function give_human_format_large_amount($amount, $args = array()) { |
|
291 | 289 | $default_args = array( |
292 | 290 | 'currency' => give_get_currency(), |
293 | 291 | ); |
294 | 292 | |
295 | - $args = wp_parse_args( $args, $default_args ); |
|
293 | + $args = wp_parse_args($args, $default_args); |
|
296 | 294 | |
297 | 295 | // Get thousand separator. |
298 | 296 | $thousands_sep = give_get_price_thousand_separator(); |
299 | 297 | |
300 | 298 | // Sanitize amount. |
301 | - $sanitize_amount = give_maybe_sanitize_amount( $amount ); |
|
299 | + $sanitize_amount = give_maybe_sanitize_amount($amount); |
|
302 | 300 | |
303 | 301 | // Explode amount to calculate name of large numbers. |
304 | - $amount_array = explode( $thousands_sep, $amount ); |
|
302 | + $amount_array = explode($thousands_sep, $amount); |
|
305 | 303 | |
306 | 304 | // Calculate amount parts count. |
307 | - $amount_count_parts = count( $amount_array ); |
|
305 | + $amount_count_parts = count($amount_array); |
|
308 | 306 | |
309 | 307 | // Human format amount (default). |
310 | 308 | $human_format_amount = $amount; |
311 | 309 | |
312 | - switch ( $args['currency'] ) { |
|
310 | + switch ($args['currency']) { |
|
313 | 311 | case 'INR': |
314 | 312 | // Calculate large number formatted amount. |
315 | - if ( 4 < $amount_count_parts ) { |
|
316 | - $human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
317 | - } elseif ( 3 < $amount_count_parts ) { |
|
318 | - $human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) ); |
|
319 | - } elseif ( 2 < $amount_count_parts ) { |
|
320 | - $human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) ); |
|
313 | + if (4 < $amount_count_parts) { |
|
314 | + $human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
315 | + } elseif (3 < $amount_count_parts) { |
|
316 | + $human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2)); |
|
317 | + } elseif (2 < $amount_count_parts) { |
|
318 | + $human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2)); |
|
321 | 319 | } |
322 | 320 | break; |
323 | 321 | default: |
324 | 322 | // Calculate large number formatted amount. |
325 | - if ( 4 < $amount_count_parts ) { |
|
326 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
327 | - } elseif ( 3 < $amount_count_parts ) { |
|
328 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
329 | - } elseif ( 2 < $amount_count_parts ) { |
|
330 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
323 | + if (4 < $amount_count_parts) { |
|
324 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
325 | + } elseif (3 < $amount_count_parts) { |
|
326 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
327 | + } elseif (2 < $amount_count_parts) { |
|
328 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
331 | 329 | } |
332 | 330 | } |
333 | 331 | |
334 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
332 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
335 | 333 | } |
336 | 334 | |
337 | 335 | /** |
@@ -345,17 +343,16 @@ discard block |
||
345 | 343 | * |
346 | 344 | * @return string $amount Newly formatted amount or Price Not Available |
347 | 345 | */ |
348 | -function give_format_decimal( $amount, $dp = false, $sanitize = true ) { |
|
346 | +function give_format_decimal($amount, $dp = false, $sanitize = true) { |
|
349 | 347 | $decimal_separator = give_get_price_decimal_separator(); |
350 | 348 | $formatted_amount = $sanitize ? |
351 | - give_maybe_sanitize_amount( $amount, $dp ) : |
|
352 | - number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
349 | + give_maybe_sanitize_amount($amount, $dp) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
353 | 350 | |
354 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
355 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
351 | + if (false !== strpos($formatted_amount, '.')) { |
|
352 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
356 | 353 | } |
357 | 354 | |
358 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
355 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
359 | 356 | } |
360 | 357 | |
361 | 358 | /** |
@@ -369,24 +366,24 @@ discard block |
||
369 | 366 | * |
370 | 367 | * @return mixed|string |
371 | 368 | */ |
372 | -function give_currency_filter( $price = '', $currency = '', $decode_currency = false ) { |
|
369 | +function give_currency_filter($price = '', $currency = '', $decode_currency = false) { |
|
373 | 370 | |
374 | - if ( empty( $currency ) || ! array_key_exists( (string) $currency, give_get_currencies() ) ) { |
|
371 | + if (empty($currency) || ! array_key_exists((string) $currency, give_get_currencies())) { |
|
375 | 372 | $currency = give_get_currency(); |
376 | 373 | } |
377 | 374 | |
378 | - $position = give_get_option( 'currency_position', 'before' ); |
|
375 | + $position = give_get_option('currency_position', 'before'); |
|
379 | 376 | |
380 | 377 | $negative = $price < 0; |
381 | 378 | |
382 | - if ( $negative ) { |
|
379 | + if ($negative) { |
|
383 | 380 | // Remove proceeding "-". |
384 | - $price = substr( $price, 1 ); |
|
381 | + $price = substr($price, 1); |
|
385 | 382 | } |
386 | 383 | |
387 | - $symbol = give_currency_symbol( $currency, $decode_currency ); |
|
384 | + $symbol = give_currency_symbol($currency, $decode_currency); |
|
388 | 385 | |
389 | - switch ( $currency ) : |
|
386 | + switch ($currency) : |
|
390 | 387 | case 'GBP' : |
391 | 388 | case 'BRL' : |
392 | 389 | case 'EUR' : |
@@ -415,13 +412,13 @@ discard block |
||
415 | 412 | case 'MAD' : |
416 | 413 | case 'KRW' : |
417 | 414 | case 'ZAR' : |
418 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
415 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
419 | 416 | break; |
420 | 417 | case 'NOK' : |
421 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
418 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
422 | 419 | break; |
423 | 420 | default : |
424 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
421 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
425 | 422 | break; |
426 | 423 | endswitch; |
427 | 424 | |
@@ -436,11 +433,11 @@ discard block |
||
436 | 433 | * and if currency is USD and currency position is after then |
437 | 434 | * filter name will be give_usd_currency_filter_after |
438 | 435 | */ |
439 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
436 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
440 | 437 | |
441 | - if ( $negative ) { |
|
438 | + if ($negative) { |
|
442 | 439 | // Prepend the minus sign before the currency sign. |
443 | - $formatted = '-' . $formatted; |
|
440 | + $formatted = '-'.$formatted; |
|
444 | 441 | } |
445 | 442 | |
446 | 443 | return $formatted; |
@@ -456,21 +453,21 @@ discard block |
||
456 | 453 | */ |
457 | 454 | function give_currency_decimal_filter() { |
458 | 455 | |
459 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
456 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
460 | 457 | |
461 | 458 | // Set default number of decimals. |
462 | 459 | $decimals = give_get_price_decimals(); |
463 | 460 | |
464 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
461 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
465 | 462 | |
466 | 463 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
467 | - if ( 1 <= func_num_args() ) { |
|
468 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
464 | + if (1 <= func_num_args()) { |
|
465 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
469 | 466 | } |
470 | 467 | |
471 | 468 | $currency = give_get_currency(); |
472 | 469 | |
473 | - switch ( $currency ) { |
|
470 | + switch ($currency) { |
|
474 | 471 | case 'RIAL' : |
475 | 472 | case 'JPY' : |
476 | 473 | case 'TWD' : |
@@ -480,11 +477,11 @@ discard block |
||
480 | 477 | break; |
481 | 478 | } |
482 | 479 | |
483 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
480 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
484 | 481 | } |
485 | 482 | |
486 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
487 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
483 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
484 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
488 | 485 | |
489 | 486 | |
490 | 487 | /** |
@@ -496,7 +493,7 @@ discard block |
||
496 | 493 | * |
497 | 494 | * @return string Date format string |
498 | 495 | */ |
499 | -function give_date_format( $date_context = '' ) { |
|
496 | +function give_date_format($date_context = '') { |
|
500 | 497 | /** |
501 | 498 | * Filter the date context |
502 | 499 | * |
@@ -517,19 +514,19 @@ discard block |
||
517 | 514 | * |
518 | 515 | * } |
519 | 516 | */ |
520 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
517 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
521 | 518 | |
522 | 519 | // Set date format to default date format. |
523 | - $date_format = get_option( 'date_format' ); |
|
520 | + $date_format = get_option('date_format'); |
|
524 | 521 | |
525 | 522 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
526 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
527 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
528 | - ? $date_format_contexts[ $date_context ] |
|
523 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
524 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
525 | + ? $date_format_contexts[$date_context] |
|
529 | 526 | : $date_format; |
530 | 527 | } |
531 | 528 | |
532 | - return apply_filters( 'give_date_format', $date_format ); |
|
529 | + return apply_filters('give_date_format', $date_format); |
|
533 | 530 | } |
534 | 531 | |
535 | 532 | /** |
@@ -543,8 +540,8 @@ discard block |
||
543 | 540 | * |
544 | 541 | * @return string |
545 | 542 | */ |
546 | -function give_get_cache_key( $action, $query_args ) { |
|
547 | - return Give_Cache::get_key( $action, $query_args ); |
|
543 | +function give_get_cache_key($action, $query_args) { |
|
544 | + return Give_Cache::get_key($action, $query_args); |
|
548 | 545 | } |
549 | 546 | |
550 | 547 | /** |
@@ -557,11 +554,11 @@ discard block |
||
557 | 554 | * |
558 | 555 | * @return string|array |
559 | 556 | */ |
560 | -function give_clean( $var ) { |
|
561 | - if ( is_array( $var ) ) { |
|
562 | - return array_map( 'give_clean', $var ); |
|
557 | +function give_clean($var) { |
|
558 | + if (is_array($var)) { |
|
559 | + return array_map('give_clean', $var); |
|
563 | 560 | } else { |
564 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
561 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
565 | 562 | } |
566 | 563 | } |
567 | 564 | |
@@ -574,10 +571,10 @@ discard block |
||
574 | 571 | * |
575 | 572 | * @return int |
576 | 573 | */ |
577 | -function give_let_to_num( $size ) { |
|
578 | - $l = substr( $size, - 1 ); |
|
579 | - $ret = substr( $size, 0, - 1 ); |
|
580 | - switch ( strtoupper( $l ) ) { |
|
574 | +function give_let_to_num($size) { |
|
575 | + $l = substr($size, - 1); |
|
576 | + $ret = substr($size, 0, - 1); |
|
577 | + switch (strtoupper($l)) { |
|
581 | 578 | case 'P': |
582 | 579 | $ret *= 1024; |
583 | 580 | case 'T': |
@@ -602,19 +599,19 @@ discard block |
||
602 | 599 | * @param int $action |
603 | 600 | * @param array $wp_die_args |
604 | 601 | */ |
605 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
602 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
606 | 603 | |
607 | 604 | $default_wp_die_args = array( |
608 | - 'message' => esc_html__( 'Nonce verification has failed.', 'give' ), |
|
609 | - 'title' => esc_html__( 'Error', 'give' ), |
|
605 | + 'message' => esc_html__('Nonce verification has failed.', 'give'), |
|
606 | + 'title' => esc_html__('Error', 'give'), |
|
610 | 607 | 'args' => array( |
611 | 608 | 'response' => 403, |
612 | 609 | ), |
613 | 610 | ); |
614 | 611 | |
615 | - $wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args ); |
|
612 | + $wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args); |
|
616 | 613 | |
617 | - if ( ! wp_verify_nonce( $nonce, $action ) ) { |
|
614 | + if ( ! wp_verify_nonce($nonce, $action)) { |
|
618 | 615 | wp_die( |
619 | 616 | $wp_die_args['message'], |
620 | 617 | $wp_die_args['title'], |
@@ -636,23 +633,23 @@ discard block |
||
636 | 633 | * |
637 | 634 | * @return mixed |
638 | 635 | */ |
639 | -function give_check_variable( $variable, $conditional = '', $default = false ) { |
|
636 | +function give_check_variable($variable, $conditional = '', $default = false) { |
|
640 | 637 | |
641 | - switch ( $conditional ) { |
|
638 | + switch ($conditional) { |
|
642 | 639 | case 'isset_empty': |
643 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
640 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
644 | 641 | break; |
645 | 642 | |
646 | 643 | case 'empty': |
647 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
644 | + $variable = ! empty($variable) ? $variable : $default; |
|
648 | 645 | break; |
649 | 646 | |
650 | 647 | case 'null': |
651 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
648 | + $variable = ! is_null($variable) ? $variable : $default; |
|
652 | 649 | break; |
653 | 650 | |
654 | 651 | default: |
655 | - $variable = isset( $variable ) ? $variable : $default; |
|
652 | + $variable = isset($variable) ? $variable : $default; |
|
656 | 653 | |
657 | 654 | } |
658 | 655 |
@@ -96,7 +96,7 @@ |
||
96 | 96 | // Bailout. |
97 | 97 | if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
98 | 98 | return $number; |
99 | - }elseif ( |
|
99 | + } elseif ( |
|
100 | 100 | ( false == strpos( $number, $thousand_separator ) ) && |
101 | 101 | ( false === strpos( $number, $decimal_separator ) ) |
102 | 102 | ) { |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * Used to redirect a user back to the donation form if there are errors present. |
157 | 157 | * |
158 | - * @param array $args |
|
158 | + * @param string $args |
|
159 | 159 | * |
160 | 160 | * @access public |
161 | 161 | * @since 1.0 |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @param int $form_id Give Form ID |
443 | 443 | * |
444 | - * @return int $earnings Earnings for a certain form |
|
444 | + * @return double $earnings Earnings for a certain form |
|
445 | 445 | */ |
446 | 446 | function give_get_form_earnings_stats( $form_id = 0 ) { |
447 | 447 | $give_form = new Give_Donate_Form( $form_id ); |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @param int $form_id ID number of the form to retrieve the minimum price for |
710 | 710 | * |
711 | - * @return mixed string|int Minimum price of the form |
|
711 | + * @return string string|int Minimum price of the form |
|
712 | 712 | */ |
713 | 713 | function give_get_form_minimum_price( $form_id = 0 ) { |
714 | 714 |
@@ -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,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | $form_id = 0; |
168 | 168 | |
169 | 169 | // Set the form_id. |
170 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
170 | + if (isset($_POST['give-form-id'])) { |
|
171 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Need a URL to continue. If none, redirect back to single form. |
175 | - if ( empty( $url ) ) { |
|
176 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
175 | + if (empty($url)) { |
|
176 | + wp_safe_redirect(get_permalink($form_id)); |
|
177 | 177 | give_die(); |
178 | 178 | } |
179 | 179 | |
@@ -182,41 +182,41 @@ discard block |
||
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Set the $level_id. |
185 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
186 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
185 | + if (isset($_POST['give-price-id'])) { |
|
186 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check for backward compatibility. |
190 | - if ( is_string( $args ) ) { |
|
191 | - $args = str_replace( '?', '', $args ); |
|
190 | + if (is_string($args)) { |
|
191 | + $args = str_replace('?', '', $args); |
|
192 | 192 | } |
193 | 193 | |
194 | - $args = wp_parse_args( $args, $defaults ); |
|
194 | + $args = wp_parse_args($args, $defaults); |
|
195 | 195 | |
196 | 196 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
197 | - $url_data = wp_parse_url( $url ); |
|
197 | + $url_data = wp_parse_url($url); |
|
198 | 198 | |
199 | 199 | // Check if an array to prevent notices before parsing. |
200 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
201 | - parse_str( $url_data['query'], $query ); |
|
200 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
201 | + parse_str($url_data['query'], $query); |
|
202 | 202 | |
203 | 203 | // Precaution: don't allow any CC info. |
204 | - unset( $query['card_number'] ); |
|
205 | - unset( $query['card_cvc'] ); |
|
204 | + unset($query['card_number']); |
|
205 | + unset($query['card_cvc']); |
|
206 | 206 | |
207 | 207 | } else { |
208 | 208 | // No $url_data so pass empty array. |
209 | 209 | $query = array(); |
210 | 210 | } |
211 | 211 | |
212 | - $new_query = array_merge( $args, $query ); |
|
213 | - $new_query_string = http_build_query( $new_query ); |
|
212 | + $new_query = array_merge($args, $query); |
|
213 | + $new_query_string = http_build_query($new_query); |
|
214 | 214 | |
215 | 215 | // Assemble URL parts. |
216 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
216 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
217 | 217 | |
218 | 218 | // Redirect them. |
219 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
219 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
220 | 220 | give_die(); |
221 | 221 | |
222 | 222 | } |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_get_success_page_url( $query_string = null ) { |
|
235 | +function give_get_success_page_url($query_string = null) { |
|
236 | 236 | |
237 | - $success_page = give_get_option( 'success_page', 0 ); |
|
238 | - $success_page = get_permalink( $success_page ); |
|
237 | + $success_page = give_get_option('success_page', 0); |
|
238 | + $success_page = get_permalink($success_page); |
|
239 | 239 | |
240 | - if ( $query_string ) { |
|
240 | + if ($query_string) { |
|
241 | 241 | $success_page .= $query_string; |
242 | 242 | } |
243 | 243 | |
244 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
244 | + return apply_filters('give_success_page_url', $success_page); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. |
256 | 256 | */ |
257 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
257 | +function give_get_failed_transaction_uri($extras = false) { |
|
258 | 258 | $give_options = give_get_settings(); |
259 | 259 | |
260 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
261 | - if ( $extras ) { |
|
260 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
261 | + if ($extras) { |
|
262 | 262 | $uri .= $extras; |
263 | 263 | } |
264 | 264 | |
265 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
265 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function give_is_failed_transaction_page() { |
275 | 275 | $give_options = give_get_settings(); |
276 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
276 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
277 | 277 | |
278 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
278 | + return apply_filters('give_is_failure_page', $ret); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | */ |
288 | 288 | function give_listen_for_failed_payments() { |
289 | 289 | |
290 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
290 | + $failed_page = give_get_option('failure_page', 0); |
|
291 | 291 | |
292 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
292 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
293 | 293 | |
294 | - $payment_id = absint( $_GET['payment-id'] ); |
|
295 | - give_update_payment_status( $payment_id, 'failed' ); |
|
294 | + $payment_id = absint($_GET['payment-id']); |
|
295 | + give_update_payment_status($payment_id, 'failed'); |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
301 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * Retrieve the Donation History page URI |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | function give_get_history_page_uri() { |
312 | 312 | $give_options = give_get_settings(); |
313 | 313 | |
314 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
314 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
315 | 315 | |
316 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
316 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | * @since 1.0 |
327 | 327 | * @return bool |
328 | 328 | */ |
329 | -function give_field_is_required( $field = '', $form_id ) { |
|
329 | +function give_field_is_required($field = '', $form_id) { |
|
330 | 330 | |
331 | - $required_fields = give_get_required_fields( $form_id ); |
|
331 | + $required_fields = give_get_required_fields($form_id); |
|
332 | 332 | |
333 | - return array_key_exists( $field, $required_fields ); |
|
333 | + return array_key_exists($field, $required_fields); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return void |
350 | 350 | */ |
351 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
351 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
352 | 352 | global $give_logs; |
353 | 353 | |
354 | 354 | $log_data = array( |
355 | 355 | 'post_parent' => $give_form_id, |
356 | 356 | 'log_type' => 'sale', |
357 | - 'post_date' => isset( $donation_date ) ? $donation_date : null, |
|
358 | - 'post_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
357 | + 'post_date' => isset($donation_date) ? $donation_date : null, |
|
358 | + 'post_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
359 | 359 | ); |
360 | 360 | |
361 | 361 | $log_meta = array( |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | 'price_id' => (int) $price_id, |
364 | 364 | ); |
365 | 365 | |
366 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
366 | + $give_logs->insert_log($log_data, $log_meta); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return bool|int |
379 | 379 | */ |
380 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
380 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { |
|
381 | 381 | $quantity = (int) $quantity; |
382 | - $form = new Give_Donate_Form( $form_id ); |
|
382 | + $form = new Give_Donate_Form($form_id); |
|
383 | 383 | |
384 | - return $form->increase_sales( $quantity ); |
|
384 | + return $form->increase_sales($quantity); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return bool|int |
396 | 396 | */ |
397 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
397 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
398 | 398 | $quantity = (int) $quantity; |
399 | - $form = new Give_Donate_Form( $form_id ); |
|
399 | + $form = new Give_Donate_Form($form_id); |
|
400 | 400 | |
401 | - return $form->decrease_sales( $quantity ); |
|
401 | + return $form->decrease_sales($quantity); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return bool|int |
413 | 413 | */ |
414 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
415 | - $form = new Give_Donate_Form( $give_form_id ); |
|
414 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
415 | + $form = new Give_Donate_Form($give_form_id); |
|
416 | 416 | |
417 | - return $form->increase_earnings( $amount ); |
|
417 | + return $form->increase_earnings($amount); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @return bool|int |
429 | 429 | */ |
430 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
431 | - $form = new Give_Donate_Form( $form_id ); |
|
430 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
431 | + $form = new Give_Donate_Form($form_id); |
|
432 | 432 | |
433 | - return $form->decrease_earnings( $amount ); |
|
433 | + return $form->decrease_earnings($amount); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return int $earnings Earnings for a certain form |
445 | 445 | */ |
446 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
447 | - $give_form = new Give_Donate_Form( $form_id ); |
|
446 | +function give_get_form_earnings_stats($form_id = 0) { |
|
447 | + $give_form = new Give_Donate_Form($form_id); |
|
448 | 448 | |
449 | 449 | return $give_form->earnings; |
450 | 450 | } |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @return int $sales Amount of sales for a certain form |
461 | 461 | */ |
462 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
463 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
462 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
463 | + $give_form = new Give_Donate_Form($give_form_id); |
|
464 | 464 | |
465 | 465 | return $give_form->sales; |
466 | 466 | } |
@@ -475,16 +475,16 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return float $sales Average monthly sales |
477 | 477 | */ |
478 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
479 | - $sales = give_get_form_sales_stats( $form_id ); |
|
480 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
478 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
479 | + $sales = give_get_form_sales_stats($form_id); |
|
480 | + $release_date = get_post_field('post_date', $form_id); |
|
481 | 481 | |
482 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
482 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
483 | 483 | |
484 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
484 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
485 | 485 | |
486 | - if ( $months > 0 ) { |
|
487 | - $sales = ( $sales / $months ); |
|
486 | + if ($months > 0) { |
|
487 | + $sales = ($sales / $months); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | return $sales; |
@@ -500,16 +500,16 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return float $earnings Average monthly earnings |
502 | 502 | */ |
503 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
504 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
505 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
503 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
504 | + $earnings = give_get_form_earnings_stats($form_id); |
|
505 | + $release_date = get_post_field('post_date', $form_id); |
|
506 | 506 | |
507 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
507 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
508 | 508 | |
509 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
509 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
510 | 510 | |
511 | - if ( $months > 0 ) { |
|
512 | - $earnings = ( $earnings / $months ); |
|
511 | + if ($months > 0) { |
|
512 | + $earnings = ($earnings / $months); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | return $earnings < 0 ? 0 : $earnings; |
@@ -529,23 +529,23 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string $price_name Name of the price option |
531 | 531 | */ |
532 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
532 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
533 | 533 | |
534 | - $prices = give_get_variable_prices( $form_id ); |
|
534 | + $prices = give_get_variable_prices($form_id); |
|
535 | 535 | $price_name = ''; |
536 | 536 | |
537 | - foreach ( $prices as $price ) { |
|
537 | + foreach ($prices as $price) { |
|
538 | 538 | |
539 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
539 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
540 | 540 | |
541 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
542 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ), '', true ); |
|
543 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
541 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
542 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)), '', true); |
|
543 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
548 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
548 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -558,23 +558,23 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string $range A fully formatted price range |
560 | 560 | */ |
561 | -function give_price_range( $form_id = 0 ) { |
|
562 | - $low = give_get_lowest_price_option( $form_id ); |
|
563 | - $high = give_get_highest_price_option( $form_id ); |
|
564 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
561 | +function give_price_range($form_id = 0) { |
|
562 | + $low = give_get_lowest_price_option($form_id); |
|
563 | + $high = give_get_highest_price_option($form_id); |
|
564 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
565 | 565 | |
566 | 566 | $range = sprintf( |
567 | 567 | '<span class="give_price_range_%1$s">%2$s</span> |
568 | 568 | <span class="give_price_range_sep"> – </span> |
569 | 569 | <span class="give_price_range_%3$s">%4$s</span>', |
570 | 570 | 'asc' === $order_type ? 'low' : 'high', |
571 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), |
|
571 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), |
|
572 | 572 | 'asc' === $order_type ? 'high' : 'low', |
573 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) |
|
573 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) |
|
574 | 574 | |
575 | 575 | ); |
576 | 576 | |
577 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
577 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -589,35 +589,35 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return int ID of the lowest price |
591 | 591 | */ |
592 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
592 | +function give_get_lowest_price_id($form_id = 0) { |
|
593 | 593 | |
594 | - if ( empty( $form_id ) ) { |
|
594 | + if (empty($form_id)) { |
|
595 | 595 | $form_id = get_the_ID(); |
596 | 596 | } |
597 | 597 | |
598 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
599 | - return give_get_form_price( $form_id ); |
|
598 | + if ( ! give_has_variable_prices($form_id)) { |
|
599 | + return give_get_form_price($form_id); |
|
600 | 600 | } |
601 | 601 | |
602 | - $prices = give_get_variable_prices( $form_id ); |
|
602 | + $prices = give_get_variable_prices($form_id); |
|
603 | 603 | |
604 | 604 | $min = $min_id = 0; |
605 | 605 | |
606 | - if ( ! empty( $prices ) ) { |
|
606 | + if ( ! empty($prices)) { |
|
607 | 607 | |
608 | - foreach ( $prices as $key => $price ) { |
|
608 | + foreach ($prices as $key => $price) { |
|
609 | 609 | |
610 | - if ( empty( $price['_give_amount'] ) ) { |
|
610 | + if (empty($price['_give_amount'])) { |
|
611 | 611 | continue; |
612 | 612 | } |
613 | 613 | |
614 | - if ( ! isset( $min ) ) { |
|
614 | + if ( ! isset($min)) { |
|
615 | 615 | $min = $price['_give_amount']; |
616 | 616 | } else { |
617 | - $min = min( $min, $price['_give_amount'] ); |
|
617 | + $min = min($min, $price['_give_amount']); |
|
618 | 618 | } |
619 | 619 | |
620 | - if ( $price['_give_amount'] == $min ) { |
|
620 | + if ($price['_give_amount'] == $min) { |
|
621 | 621 | $min_id = $price['_give_id']['level_id']; |
622 | 622 | } |
623 | 623 | } |
@@ -635,22 +635,22 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @return float Amount of the lowest price |
637 | 637 | */ |
638 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
639 | - if ( empty( $form_id ) ) { |
|
638 | +function give_get_lowest_price_option($form_id = 0) { |
|
639 | + if (empty($form_id)) { |
|
640 | 640 | $form_id = get_the_ID(); |
641 | 641 | } |
642 | 642 | |
643 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
644 | - return give_get_form_price( $form_id ); |
|
643 | + if ( ! give_has_variable_prices($form_id)) { |
|
644 | + return give_get_form_price($form_id); |
|
645 | 645 | } |
646 | 646 | |
647 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
647 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
648 | 648 | // Backward compatibility. |
649 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
650 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
649 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
650 | + $low = ! empty($prices) ? min($prices) : 0; |
|
651 | 651 | } |
652 | 652 | |
653 | - return give_maybe_sanitize_amount( $low ); |
|
653 | + return give_maybe_sanitize_amount($low); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
@@ -662,23 +662,23 @@ discard block |
||
662 | 662 | * |
663 | 663 | * @return float Amount of the highest price |
664 | 664 | */ |
665 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
665 | +function give_get_highest_price_option($form_id = 0) { |
|
666 | 666 | |
667 | - if ( empty( $form_id ) ) { |
|
667 | + if (empty($form_id)) { |
|
668 | 668 | $form_id = get_the_ID(); |
669 | 669 | } |
670 | 670 | |
671 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
672 | - return give_get_form_price( $form_id ); |
|
671 | + if ( ! give_has_variable_prices($form_id)) { |
|
672 | + return give_get_form_price($form_id); |
|
673 | 673 | } |
674 | 674 | |
675 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
675 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
676 | 676 | // Backward compatibility. |
677 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
678 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
677 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
678 | + $high = ! empty($prices) ? max($prices) : 0; |
|
679 | 679 | } |
680 | 680 | |
681 | - return give_maybe_sanitize_amount( $high ); |
|
681 | + return give_maybe_sanitize_amount($high); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -690,15 +690,15 @@ discard block |
||
690 | 690 | * |
691 | 691 | * @return mixed string|int Price of the form |
692 | 692 | */ |
693 | -function give_get_form_price( $form_id = 0 ) { |
|
693 | +function give_get_form_price($form_id = 0) { |
|
694 | 694 | |
695 | - if ( empty( $form_id ) ) { |
|
695 | + if (empty($form_id)) { |
|
696 | 696 | return false; |
697 | 697 | } |
698 | 698 | |
699 | - $form = new Give_Donate_Form( $form_id ); |
|
699 | + $form = new Give_Donate_Form($form_id); |
|
700 | 700 | |
701 | - return $form->__get( 'price' ); |
|
701 | + return $form->__get('price'); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -710,15 +710,15 @@ discard block |
||
710 | 710 | * |
711 | 711 | * @return mixed string|int Minimum price of the form |
712 | 712 | */ |
713 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
713 | +function give_get_form_minimum_price($form_id = 0) { |
|
714 | 714 | |
715 | - if ( empty( $form_id ) ) { |
|
715 | + if (empty($form_id)) { |
|
716 | 716 | return false; |
717 | 717 | } |
718 | 718 | |
719 | - $form = new Give_Donate_Form( $form_id ); |
|
719 | + $form = new Give_Donate_Form($form_id); |
|
720 | 720 | |
721 | - return $form->__get( 'minimum_price' ); |
|
721 | + return $form->__get('minimum_price'); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -733,48 +733,48 @@ discard block |
||
733 | 733 | * |
734 | 734 | * @return int $formatted_price |
735 | 735 | */ |
736 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
736 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
737 | 737 | $price = 0; |
738 | 738 | |
739 | - if ( empty( $form_id ) ) { |
|
739 | + if (empty($form_id)) { |
|
740 | 740 | $form_id = get_the_ID(); |
741 | 741 | } |
742 | 742 | |
743 | - if ( give_has_variable_prices( $form_id ) ) { |
|
743 | + if (give_has_variable_prices($form_id)) { |
|
744 | 744 | |
745 | - $prices = give_get_variable_prices( $form_id ); |
|
745 | + $prices = give_get_variable_prices($form_id); |
|
746 | 746 | |
747 | - if ( false !== $price_id ) { |
|
747 | + if (false !== $price_id) { |
|
748 | 748 | |
749 | 749 | // loop through multi-prices to see which is default |
750 | - foreach ( $prices as $price ) { |
|
750 | + foreach ($prices as $price) { |
|
751 | 751 | // this is the default price |
752 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
752 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
753 | 753 | $price = (float) $price['_give_amount']; |
754 | 754 | }; |
755 | 755 | } |
756 | 756 | } else { |
757 | 757 | |
758 | - $price = give_get_lowest_price_option( $form_id ); |
|
758 | + $price = give_get_lowest_price_option($form_id); |
|
759 | 759 | } |
760 | 760 | } else { |
761 | 761 | |
762 | - $price = give_get_form_price( $form_id ); |
|
762 | + $price = give_get_form_price($form_id); |
|
763 | 763 | } |
764 | 764 | |
765 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); |
|
766 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
767 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
765 | + $price = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); |
|
766 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
767 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
768 | 768 | |
769 | - if ( $echo ) { |
|
769 | + if ($echo) { |
|
770 | 770 | echo $formatted_price; |
771 | 771 | } else { |
772 | 772 | return $formatted_price; |
773 | 773 | } |
774 | 774 | } |
775 | 775 | |
776 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
777 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
776 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
777 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
778 | 778 | |
779 | 779 | |
780 | 780 | /** |
@@ -787,19 +787,19 @@ discard block |
||
787 | 787 | * |
788 | 788 | * @return float $amount Amount of the price option |
789 | 789 | */ |
790 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
791 | - $prices = give_get_variable_prices( $form_id ); |
|
790 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
791 | + $prices = give_get_variable_prices($form_id); |
|
792 | 792 | |
793 | 793 | $amount = 0.00; |
794 | 794 | |
795 | - foreach ( $prices as $price ) { |
|
796 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
797 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
795 | + foreach ($prices as $price) { |
|
796 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
797 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
798 | 798 | break; |
799 | 799 | }; |
800 | 800 | } |
801 | 801 | |
802 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); |
|
802 | + return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | /** |
@@ -811,13 +811,13 @@ discard block |
||
811 | 811 | * |
812 | 812 | * @return mixed string|int Goal of the form |
813 | 813 | */ |
814 | -function give_get_form_goal( $form_id = 0 ) { |
|
814 | +function give_get_form_goal($form_id = 0) { |
|
815 | 815 | |
816 | - if ( empty( $form_id ) ) { |
|
816 | + if (empty($form_id)) { |
|
817 | 817 | return false; |
818 | 818 | } |
819 | 819 | |
820 | - $form = new Give_Donate_Form( $form_id ); |
|
820 | + $form = new Give_Donate_Form($form_id); |
|
821 | 821 | |
822 | 822 | return $form->goal; |
823 | 823 | |
@@ -833,27 +833,27 @@ discard block |
||
833 | 833 | * |
834 | 834 | * @return string $formatted_goal |
835 | 835 | */ |
836 | -function give_goal( $form_id = 0, $echo = true ) { |
|
836 | +function give_goal($form_id = 0, $echo = true) { |
|
837 | 837 | |
838 | - if ( empty( $form_id ) ) { |
|
838 | + if (empty($form_id)) { |
|
839 | 839 | $form_id = get_the_ID(); |
840 | 840 | } |
841 | 841 | |
842 | - $goal = give_get_form_goal( $form_id ); |
|
842 | + $goal = give_get_form_goal($form_id); |
|
843 | 843 | |
844 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); |
|
845 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
846 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
844 | + $goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); |
|
845 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
846 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
847 | 847 | |
848 | - if ( $echo ) { |
|
848 | + if ($echo) { |
|
849 | 849 | echo $formatted_goal; |
850 | 850 | } else { |
851 | 851 | return $formatted_goal; |
852 | 852 | } |
853 | 853 | } |
854 | 854 | |
855 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
856 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
855 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
856 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
857 | 857 | |
858 | 858 | |
859 | 859 | /** |
@@ -865,15 +865,15 @@ discard block |
||
865 | 865 | * |
866 | 866 | * @return bool $ret Whether or not the logged_in_only setting is set |
867 | 867 | */ |
868 | -function give_logged_in_only( $form_id ) { |
|
868 | +function give_logged_in_only($form_id) { |
|
869 | 869 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
870 | 870 | // Otherwise it is member only donation form. |
871 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
872 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
871 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
872 | + $val = ! empty($val) ? $val : 'enabled'; |
|
873 | 873 | |
874 | - $ret = ! give_is_setting_enabled( $val ); |
|
874 | + $ret = ! give_is_setting_enabled($val); |
|
875 | 875 | |
876 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
876 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | |
@@ -886,11 +886,11 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return string |
888 | 888 | */ |
889 | -function give_show_login_register_option( $form_id ) { |
|
889 | +function give_show_login_register_option($form_id) { |
|
890 | 890 | |
891 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
891 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
892 | 892 | |
893 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
893 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
894 | 894 | |
895 | 895 | } |
896 | 896 | |
@@ -906,12 +906,12 @@ discard block |
||
906 | 906 | * |
907 | 907 | * @return array |
908 | 908 | */ |
909 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
909 | +function _give_get_prefill_form_field_values($form_id) { |
|
910 | 910 | $logged_in_donor_info = array(); |
911 | 911 | |
912 | - if ( is_user_logged_in() ) : |
|
913 | - $donor_data = get_userdata( get_current_user_id() ); |
|
914 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
912 | + if (is_user_logged_in()) : |
|
913 | + $donor_data = get_userdata(get_current_user_id()); |
|
914 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
915 | 915 | |
916 | 916 | $logged_in_donor_info = array( |
917 | 917 | // First name. |
@@ -924,42 +924,42 @@ discard block |
||
924 | 924 | 'give_email' => $donor_data->user_email, |
925 | 925 | |
926 | 926 | // Street address 1. |
927 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
927 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
928 | 928 | |
929 | 929 | // Street address 2. |
930 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
930 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
931 | 931 | |
932 | 932 | // Country. |
933 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
933 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
934 | 934 | |
935 | 935 | // State. |
936 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
936 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
937 | 937 | |
938 | 938 | // City. |
939 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
939 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
940 | 940 | |
941 | 941 | // Zipcode |
942 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ), |
|
942 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''), |
|
943 | 943 | ); |
944 | 944 | endif; |
945 | 945 | |
946 | 946 | // Bailout: Auto fill form field values only form form which donor is donating. |
947 | 947 | if ( |
948 | - empty( $_GET['form-id'] ) |
|
948 | + empty($_GET['form-id']) |
|
949 | 949 | || ! $form_id |
950 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
950 | + || ($form_id !== absint($_GET['form-id'])) |
|
951 | 951 | ) { |
952 | 952 | return $logged_in_donor_info; |
953 | 953 | } |
954 | 954 | |
955 | 955 | // Get purchase data. |
956 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
956 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
957 | 957 | |
958 | 958 | // Get donor info from form data. |
959 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
959 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
960 | 960 | ? array() |
961 | 961 | : $give_purchase_data['post_data']; |
962 | 962 | |
963 | 963 | // Output. |
964 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
964 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
965 | 965 | } |
@@ -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 | |
@@ -25,26 +25,26 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_load_scripts() { |
27 | 27 | |
28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
31 | 31 | |
32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
34 | 34 | |
35 | 35 | // Localize / PHP to AJAX vars. |
36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
39 | 39 | 'currency' => give_get_currency(), |
40 | - 'currency_sign' => give_currency_filter( '' ), |
|
40 | + 'currency_sign' => give_currency_filter(''), |
|
41 | 41 | 'currency_pos' => give_get_currency_position(), |
42 | 42 | 'thousands_separator' => give_get_price_thousand_separator(), |
43 | 43 | 'decimal_separator' => give_get_price_decimal_separator(), |
44 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
45 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
46 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
47 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
44 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
45 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
46 | + 'general_loading' => __('Loading...', 'give'), |
|
47 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
48 | 48 | 'number_decimals' => give_get_price_decimals(), |
49 | 49 | 'give_version' => GIVE_VERSION, |
50 | 50 | 'magnific_options' => apply_filters( |
@@ -58,81 +58,81 @@ discard block |
||
58 | 58 | 'give_form_translation_js', |
59 | 59 | array( |
60 | 60 | // Field name Validation message. |
61 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
62 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
63 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
64 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
65 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
66 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
67 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
61 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
62 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
63 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
64 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
65 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
66 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
67 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
68 | 68 | ) |
69 | 69 | ), |
70 | - ) ); |
|
70 | + )); |
|
71 | 71 | |
72 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
72 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
73 | 73 | 'ajaxurl' => give_get_ajax_url(), |
74 | - 'loading' => __( 'Loading', 'give' ), |
|
74 | + 'loading' => __('Loading', 'give'), |
|
75 | 75 | // General loading message. |
76 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
76 | + 'select_option' => __('Please select an option', 'give'), |
|
77 | 77 | // Variable pricing error with multi-donation option enabled. |
78 | - 'default_gateway' => give_get_default_gateway( null ), |
|
79 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
78 | + 'default_gateway' => give_get_default_gateway(null), |
|
79 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
80 | 80 | 'number_decimals' => give_get_price_decimals(), |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | 83 | // DEBUG is On. |
84 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
84 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
85 | 85 | |
86 | - if ( give_is_cc_verify_enabled() ) { |
|
87 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
88 | - wp_enqueue_script( 'give-cc-validator' ); |
|
86 | + if (give_is_cc_verify_enabled()) { |
|
87 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
88 | + wp_enqueue_script('give-cc-validator'); |
|
89 | 89 | } |
90 | 90 | |
91 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
92 | - wp_enqueue_script( 'give-float-labels' ); |
|
91 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
92 | + wp_enqueue_script('give-float-labels'); |
|
93 | 93 | |
94 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
95 | - wp_enqueue_script( 'give-blockui' ); |
|
94 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
95 | + wp_enqueue_script('give-blockui'); |
|
96 | 96 | |
97 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
98 | - wp_enqueue_script( 'give-qtip' ); |
|
97 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
98 | + wp_enqueue_script('give-qtip'); |
|
99 | 99 | |
100 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
101 | - wp_enqueue_script( 'give-accounting' ); |
|
100 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
101 | + wp_enqueue_script('give-accounting'); |
|
102 | 102 | |
103 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
104 | - wp_enqueue_script( 'give-magnific' ); |
|
103 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
104 | + wp_enqueue_script('give-magnific'); |
|
105 | 105 | |
106 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
107 | - wp_enqueue_script( 'give-checkout-global' ); |
|
106 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
107 | + wp_enqueue_script('give-checkout-global'); |
|
108 | 108 | |
109 | 109 | // General scripts. |
110 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
111 | - wp_enqueue_script( 'give-scripts' ); |
|
110 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
111 | + wp_enqueue_script('give-scripts'); |
|
112 | 112 | |
113 | 113 | // Load AJAX scripts, if enabled. |
114 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
115 | - wp_enqueue_script( 'give-ajax' ); |
|
114 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
115 | + wp_enqueue_script('give-ajax'); |
|
116 | 116 | |
117 | 117 | // Localize / Pass AJAX vars from PHP, |
118 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
119 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
118 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
119 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
120 | 120 | |
121 | 121 | } else { |
122 | 122 | |
123 | 123 | // DEBUG is OFF (one JS file to rule them all!). |
124 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
125 | - wp_enqueue_script( 'give' ); |
|
124 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
125 | + wp_enqueue_script('give'); |
|
126 | 126 | |
127 | 127 | // Localize / Pass AJAX vars from PHP. |
128 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
129 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
128 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
129 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
135 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * Register styles. |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function give_register_styles() { |
147 | 147 | |
148 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
148 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
153 | - wp_enqueue_style( 'give-styles' ); |
|
152 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
153 | + wp_enqueue_style('give-styles'); |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | |
157 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
157 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
158 | 158 | |
159 | 159 | |
160 | 160 | /** |
@@ -167,19 +167,19 @@ discard block |
||
167 | 167 | function give_get_stylesheet_uri() { |
168 | 168 | |
169 | 169 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
170 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
170 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
171 | 171 | |
172 | 172 | // LTR or RTL files. |
173 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
173 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
174 | 174 | |
175 | - $file = 'give' . $direction . $suffix . '.css'; |
|
175 | + $file = 'give'.$direction.$suffix.'.css'; |
|
176 | 176 | $templates_dir = give_get_theme_template_dir_name(); |
177 | 177 | |
178 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
179 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
180 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
181 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
182 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
178 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
179 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
180 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
181 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
182 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
183 | 183 | |
184 | 184 | $uri = false; |
185 | 185 | |
@@ -189,23 +189,23 @@ discard block |
||
189 | 189 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
190 | 190 | * This allows users to copy just give.css to their theme. |
191 | 191 | */ |
192 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
193 | - if ( ! empty( $nonmin ) ) { |
|
194 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
192 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
193 | + if ( ! empty($nonmin)) { |
|
194 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
195 | 195 | } else { |
196 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
196 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
197 | 197 | } |
198 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
199 | - if ( ! empty( $nonmin ) ) { |
|
200 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
198 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
199 | + if ( ! empty($nonmin)) { |
|
200 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
201 | 201 | } else { |
202 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
202 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
203 | 203 | } |
204 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
205 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
204 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
205 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
206 | 206 | } |
207 | 207 | |
208 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
208 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
@@ -222,79 +222,79 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return void |
224 | 224 | */ |
225 | -function give_load_admin_scripts( $hook ) { |
|
225 | +function give_load_admin_scripts($hook) { |
|
226 | 226 | |
227 | 227 | global $post, $post_type; |
228 | 228 | |
229 | 229 | $give_options = give_get_settings(); |
230 | 230 | |
231 | 231 | // Directories of assets. |
232 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
233 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
234 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
232 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
233 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
234 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
235 | 235 | |
236 | 236 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
237 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
237 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
238 | 238 | |
239 | 239 | // LTR or RTL files. |
240 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
240 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
241 | 241 | |
242 | 242 | // Global Admin. |
243 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
244 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
243 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
244 | + wp_enqueue_style('give-admin-bar-notification'); |
|
245 | 245 | |
246 | 246 | // Give Admin Only. |
247 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
247 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // CSS. |
252 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
253 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
254 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
255 | - wp_enqueue_style( 'give-admin' ); |
|
256 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
257 | - wp_enqueue_style( 'jquery-chosen' ); |
|
258 | - wp_enqueue_style( 'thickbox' ); |
|
259 | - wp_enqueue_style( 'wp-color-picker' ); |
|
252 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
253 | + wp_enqueue_style('jquery-ui-css'); |
|
254 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
255 | + wp_enqueue_style('give-admin'); |
|
256 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
257 | + wp_enqueue_style('jquery-chosen'); |
|
258 | + wp_enqueue_style('thickbox'); |
|
259 | + wp_enqueue_style('wp-color-picker'); |
|
260 | 260 | |
261 | 261 | |
262 | 262 | // JS. |
263 | - wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
264 | - wp_enqueue_script( 'give-selector-cache' ); |
|
263 | + wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
264 | + wp_enqueue_script('give-selector-cache'); |
|
265 | 265 | |
266 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
267 | - wp_enqueue_script( 'jquery-chosen' ); |
|
266 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
267 | + wp_enqueue_script('jquery-chosen'); |
|
268 | 268 | |
269 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
270 | - wp_enqueue_script( 'give-accounting' ); |
|
269 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
270 | + wp_enqueue_script('give-accounting'); |
|
271 | 271 | |
272 | - wp_enqueue_script( 'wp-color-picker' ); |
|
273 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
274 | - wp_enqueue_script( 'thickbox' ); |
|
272 | + wp_enqueue_script('wp-color-picker'); |
|
273 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
274 | + wp_enqueue_script('thickbox'); |
|
275 | 275 | |
276 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker' ), GIVE_VERSION, false ); |
|
277 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
276 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker'), GIVE_VERSION, false); |
|
277 | + wp_enqueue_script('give-admin-scripts'); |
|
278 | 278 | |
279 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
280 | - wp_enqueue_script( 'jquery-flot' ); |
|
279 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
280 | + wp_enqueue_script('jquery-flot'); |
|
281 | 281 | |
282 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
283 | - wp_enqueue_script( 'give-qtip' ); |
|
282 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
283 | + wp_enqueue_script('give-qtip'); |
|
284 | 284 | |
285 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
286 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
285 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
286 | + wp_enqueue_script('give-repeatable-fields'); |
|
287 | 287 | |
288 | 288 | // Forms CPT Script. |
289 | - if ( $post_type === 'give_forms' ) { |
|
290 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
291 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
289 | + if ($post_type === 'give_forms') { |
|
290 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
291 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // Settings Scripts. |
295 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
296 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
297 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
295 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
296 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
297 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | // Price Separators. |
@@ -302,76 +302,76 @@ discard block |
||
302 | 302 | $decimal_separator = give_get_price_decimal_separator(); |
303 | 303 | |
304 | 304 | // Localize strings & variables for JS. |
305 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
306 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
305 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
306 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
307 | 307 | 'give_version' => GIVE_VERSION, |
308 | 308 | 'thousands_separator' => $thousand_separator, |
309 | 309 | 'decimal_separator' => $decimal_separator, |
310 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
311 | - 'delete_payment' => __( 'Are you sure you want to delete this payment?', 'give' ), |
|
312 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
313 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
314 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
315 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
316 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
317 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
318 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
319 | - 'currency_sign' => give_currency_filter( '' ), |
|
320 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
321 | - 'currency_decimals' => give_currency_decimal_filter( give_get_price_decimals() ), |
|
322 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
323 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
324 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
325 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
326 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
310 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
311 | + 'delete_payment' => __('Are you sure you want to delete this payment?', 'give'), |
|
312 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
313 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
314 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
315 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
316 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
317 | + 'one_option' => __('Choose a form', 'give'), |
|
318 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
319 | + 'currency_sign' => give_currency_filter(''), |
|
320 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
321 | + 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), |
|
322 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
323 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
324 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
325 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
326 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
327 | 327 | /* translators : %s: Donation form options metabox */ |
328 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
329 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
330 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
331 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
332 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
333 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
334 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
328 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
329 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
330 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
331 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
332 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
333 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
334 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
335 | 335 | 'bulk_action' => array( |
336 | 336 | 'delete' => array( |
337 | - 'zero' => __( 'You must choose at least one or more payments to delete.', 'give' ), |
|
338 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
339 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
337 | + 'zero' => __('You must choose at least one or more payments to delete.', 'give'), |
|
338 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
339 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
340 | 340 | ), |
341 | 341 | 'resend-receipt' => array( |
342 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
343 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
344 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
342 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
343 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
344 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
345 | 345 | ), |
346 | 346 | 'set-to-status' => array( |
347 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
348 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
349 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
347 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
348 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
349 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
350 | 350 | ), |
351 | 351 | ), |
352 | 352 | 'metabox_fields' => array( |
353 | 353 | 'media' => array( |
354 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
354 | + 'button_title' => __('Choose Image', 'give'), |
|
355 | 355 | ), |
356 | 356 | 'file' => array( |
357 | - 'button_title' => __( 'Choose File', 'give' ), |
|
357 | + 'button_title' => __('Choose File', 'give'), |
|
358 | 358 | ) |
359 | 359 | ), |
360 | 360 | 'chosen' => array( |
361 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
362 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
361 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
362 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
363 | 363 | ), |
364 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ) |
|
365 | - ) ); |
|
364 | + 'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give') |
|
365 | + )); |
|
366 | 366 | |
367 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
367 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
368 | 368 | // call for new media manager. |
369 | 369 | wp_enqueue_media(); |
370 | 370 | } |
371 | 371 | |
372 | 372 | } |
373 | 373 | |
374 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
374 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * Admin Give Icon |
@@ -386,13 +386,13 @@ discard block |
||
386 | 386 | ?> |
387 | 387 | <style type="text/css" media="screen"> |
388 | 388 | |
389 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
389 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
390 | 390 | @font-face { |
391 | 391 | font-family: 'give-icomoon'; |
392 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
393 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
394 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
395 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
392 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
393 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
394 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
395 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
396 | 396 | font-weight: normal; |
397 | 397 | font-style: normal; |
398 | 398 | } |
@@ -411,4 +411,4 @@ discard block |
||
411 | 411 | <?php |
412 | 412 | } |
413 | 413 | |
414 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
414 | +add_action('admin_head', 'give_admin_icon'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | function give_test_ajax_works() { |
27 | 27 | |
28 | 28 | // Check if the Airplane Mode plugin is installed. |
29 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
29 | + if (class_exists('Airplane_Mode_Core')) { |
|
30 | 30 | |
31 | 31 | $airplane = Airplane_Mode_Core::getInstance(); |
32 | 32 | |
33 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
33 | + if (method_exists($airplane, 'enabled')) { |
|
34 | 34 | |
35 | - if ( $airplane->enabled() ) { |
|
35 | + if ($airplane->enabled()) { |
|
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | } else { |
39 | 39 | |
40 | - if ( 'on' === $airplane->check_status() ) { |
|
40 | + if ('on' === $airplane->check_status()) { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
46 | + add_filter('block_local_requests', '__return_false'); |
|
47 | 47 | |
48 | - if ( Give_Cache::get( '_give_ajax_works', true ) ) { |
|
48 | + if (Give_Cache::get('_give_ajax_works', true)) { |
|
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | ), |
58 | 58 | ); |
59 | 59 | |
60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
61 | 61 | |
62 | 62 | $works = true; |
63 | 63 | |
64 | - if ( is_wp_error( $ajax ) ) { |
|
64 | + if (is_wp_error($ajax)) { |
|
65 | 65 | |
66 | 66 | $works = false; |
67 | 67 | |
68 | 68 | } else { |
69 | 69 | |
70 | - if ( empty( $ajax['response'] ) ) { |
|
70 | + if (empty($ajax['response'])) { |
|
71 | 71 | $works = false; |
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
74 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
75 | 75 | $works = false; |
76 | 76 | } |
77 | 77 | |
78 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
78 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
79 | 79 | $works = false; |
80 | 80 | } |
81 | 81 | |
82 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
82 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
83 | 83 | $works = false; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - if ( $works ) { |
|
88 | - Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true ); |
|
87 | + if ($works) { |
|
88 | + Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $works; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | */ |
102 | 102 | function give_get_ajax_url() { |
103 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
103 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
104 | 104 | |
105 | 105 | $current_url = give_get_current_page_url(); |
106 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
106 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
107 | 107 | |
108 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
109 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
108 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
109 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
110 | 110 | } |
111 | 111 | |
112 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
112 | + return apply_filters('give_ajax_url', $ajax_url); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @since 1.7 |
127 | 127 | */ |
128 | - do_action( 'give_donation_form_login_fields' ); |
|
128 | + do_action('give_donation_form_login_fields'); |
|
129 | 129 | |
130 | 130 | give_die(); |
131 | 131 | } |
132 | 132 | |
133 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
133 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Load Checkout Fields |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return void |
141 | 141 | */ |
142 | 142 | function give_load_checkout_fields() { |
143 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
143 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
144 | 144 | |
145 | 145 | ob_start(); |
146 | 146 | |
@@ -149,18 +149,18 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @since 1.7 |
151 | 151 | */ |
152 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
152 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
153 | 153 | |
154 | 154 | $fields = ob_get_clean(); |
155 | 155 | |
156 | - wp_send_json( array( |
|
157 | - 'fields' => wp_json_encode( $fields ), |
|
158 | - 'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ), |
|
159 | - ) ); |
|
156 | + wp_send_json(array( |
|
157 | + 'fields' => wp_json_encode($fields), |
|
158 | + 'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)), |
|
159 | + )); |
|
160 | 160 | } |
161 | 161 | |
162 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
163 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
162 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
163 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * @return void |
171 | 171 | */ |
172 | 172 | function give_ajax_get_form_title() { |
173 | - if ( isset( $_POST['form_id'] ) ) { |
|
174 | - $title = get_the_title( $_POST['form_id'] ); |
|
175 | - if ( $title ) { |
|
173 | + if (isset($_POST['form_id'])) { |
|
174 | + $title = get_the_title($_POST['form_id']); |
|
175 | + if ($title) { |
|
176 | 176 | echo $title; |
177 | 177 | } else { |
178 | 178 | echo 'fail'; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | give_die(); |
182 | 182 | } |
183 | 183 | |
184 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
185 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
184 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
185 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Retrieve a states drop down |
@@ -196,35 +196,35 @@ discard block |
||
196 | 196 | $show_field = true; |
197 | 197 | $states_require = true; |
198 | 198 | // Get the Country code from the $_POST. |
199 | - $country = sanitize_text_field( $_POST['country'] ); |
|
199 | + $country = sanitize_text_field($_POST['country']); |
|
200 | 200 | |
201 | 201 | // Get the field name from the $_POST. |
202 | - $field_name = sanitize_text_field( $_POST['field_name'] ); |
|
202 | + $field_name = sanitize_text_field($_POST['field_name']); |
|
203 | 203 | |
204 | - $label = __( 'State', 'give' ); |
|
204 | + $label = __('State', 'give'); |
|
205 | 205 | $states_label = give_get_states_label(); |
206 | 206 | |
207 | 207 | // Check if $country code exists in the array key for states label. |
208 | - if ( array_key_exists( $country, $states_label ) ) { |
|
209 | - $label = $states_label[ $country ]; |
|
208 | + if (array_key_exists($country, $states_label)) { |
|
209 | + $label = $states_label[$country]; |
|
210 | 210 | } |
211 | 211 | |
212 | - if ( empty( $country ) ) { |
|
212 | + if (empty($country)) { |
|
213 | 213 | $country = give_get_country(); |
214 | 214 | } |
215 | 215 | |
216 | - $states = give_get_states( $country ); |
|
217 | - if ( ! empty( $states ) ) { |
|
216 | + $states = give_get_states($country); |
|
217 | + if ( ! empty($states)) { |
|
218 | 218 | $args = array( |
219 | 219 | 'name' => $field_name, |
220 | 220 | 'id' => $field_name, |
221 | - 'class' => $field_name . ' give-select', |
|
221 | + 'class' => $field_name.' give-select', |
|
222 | 222 | 'options' => $states, |
223 | 223 | 'show_option_all' => false, |
224 | 224 | 'show_option_none' => false, |
225 | 225 | 'placeholder' => $label, |
226 | 226 | ); |
227 | - $data = Give()->html->select( $args ); |
|
227 | + $data = Give()->html->select($args); |
|
228 | 228 | $states_found = true; |
229 | 229 | } else { |
230 | 230 | $data = 'nostates'; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $no_states_country = give_no_states_country_list(); |
234 | 234 | |
235 | 235 | // Check if $country code exists in the array key. |
236 | - if ( array_key_exists( $country, $no_states_country ) ) { |
|
236 | + if (array_key_exists($country, $no_states_country)) { |
|
237 | 237 | $show_field = false; |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $states_not_required_country_list = give_states_not_required_country_list(); |
242 | 242 | |
243 | 243 | // Check if $country code exists in the array key. |
244 | - if ( array_key_exists( $country, $states_not_required_country_list ) ) { |
|
244 | + if (array_key_exists($country, $states_not_required_country_list)) { |
|
245 | 245 | $states_require = false; |
246 | 246 | } |
247 | 247 | } |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | 'states_require' => $states_require, |
254 | 254 | 'data' => $data, |
255 | 255 | ); |
256 | - wp_send_json( $response ); |
|
256 | + wp_send_json($response); |
|
257 | 257 | } |
258 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
259 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
258 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
259 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Retrieve donation forms via AJAX for chosen dropdown search field. |
@@ -268,19 +268,19 @@ discard block |
||
268 | 268 | function give_ajax_form_search() { |
269 | 269 | global $wpdb; |
270 | 270 | |
271 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
272 | - $excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() ); |
|
271 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
272 | + $excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array()); |
|
273 | 273 | |
274 | 274 | $results = array(); |
275 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
276 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
275 | + if (current_user_can('edit_give_forms')) { |
|
276 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
277 | 277 | } else { |
278 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
278 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
279 | 279 | } |
280 | 280 | |
281 | - if ( $items ) { |
|
281 | + if ($items) { |
|
282 | 282 | |
283 | - foreach ( $items as $item ) { |
|
283 | + foreach ($items as $item) { |
|
284 | 284 | |
285 | 285 | $results[] = array( |
286 | 286 | 'id' => $item->ID, |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | |
292 | 292 | $items[] = array( |
293 | 293 | 'id' => 0, |
294 | - 'name' => __( 'No forms found.', 'give' ), |
|
294 | + 'name' => __('No forms found.', 'give'), |
|
295 | 295 | ); |
296 | 296 | |
297 | 297 | } |
298 | 298 | |
299 | - echo json_encode( $results ); |
|
299 | + echo json_encode($results); |
|
300 | 300 | |
301 | 301 | give_die(); |
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
305 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
304 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
305 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
306 | 306 | |
307 | 307 | /** |
308 | 308 | * Search the donors database via Ajax |
@@ -314,38 +314,38 @@ discard block |
||
314 | 314 | function give_ajax_donor_search() { |
315 | 315 | global $wpdb; |
316 | 316 | |
317 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
317 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
318 | 318 | $results = array(); |
319 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
319 | + if ( ! current_user_can('view_give_reports')) { |
|
320 | 320 | $donors = array(); |
321 | 321 | } else { |
322 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
322 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
323 | 323 | } |
324 | 324 | |
325 | - if ( $donors ) { |
|
325 | + if ($donors) { |
|
326 | 326 | |
327 | - foreach ( $donors as $donor ) { |
|
327 | + foreach ($donors as $donor) { |
|
328 | 328 | |
329 | 329 | $results[] = array( |
330 | 330 | 'id' => $donor->id, |
331 | - 'name' => $donor->name . ' (' . $donor->email . ')', |
|
331 | + 'name' => $donor->name.' ('.$donor->email.')', |
|
332 | 332 | ); |
333 | 333 | } |
334 | 334 | } else { |
335 | 335 | |
336 | 336 | $donors[] = array( |
337 | 337 | 'id' => 0, |
338 | - 'name' => __( 'No donors found.', 'give' ), |
|
338 | + 'name' => __('No donors found.', 'give'), |
|
339 | 339 | ); |
340 | 340 | |
341 | 341 | } |
342 | 342 | |
343 | - echo json_encode( $results ); |
|
343 | + echo json_encode($results); |
|
344 | 344 | |
345 | 345 | give_die(); |
346 | 346 | } |
347 | 347 | |
348 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
348 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
@@ -357,39 +357,39 @@ discard block |
||
357 | 357 | */ |
358 | 358 | function give_ajax_search_users() { |
359 | 359 | |
360 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
360 | + if (current_user_can('manage_give_settings')) { |
|
361 | 361 | |
362 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
362 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
363 | 363 | |
364 | 364 | $get_users_args = array( |
365 | 365 | 'number' => 9999, |
366 | - 'search' => $search . '*', |
|
366 | + 'search' => $search.'*', |
|
367 | 367 | ); |
368 | 368 | |
369 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
369 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
370 | 370 | |
371 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search ); |
|
371 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search); |
|
372 | 372 | $results = array(); |
373 | 373 | |
374 | - if ( $found_users ) { |
|
374 | + if ($found_users) { |
|
375 | 375 | |
376 | - foreach ( $found_users as $user ) { |
|
376 | + foreach ($found_users as $user) { |
|
377 | 377 | |
378 | 378 | $results[] = array( |
379 | 379 | 'id' => $user->ID, |
380 | - 'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ), |
|
380 | + 'name' => esc_html($user->user_login.' ('.$user->user_email.')'), |
|
381 | 381 | ); |
382 | 382 | } |
383 | 383 | } else { |
384 | 384 | |
385 | 385 | $results[] = array( |
386 | 386 | 'id' => 0, |
387 | - 'name' => __( 'No users found.', 'give' ), |
|
387 | + 'name' => __('No users found.', 'give'), |
|
388 | 388 | ); |
389 | 389 | |
390 | 390 | } |
391 | 391 | |
392 | - echo json_encode( $results ); |
|
392 | + echo json_encode($results); |
|
393 | 393 | |
394 | 394 | }// End if(). |
395 | 395 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | |
398 | 398 | } |
399 | 399 | |
400 | -add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' ); |
|
400 | +add_action('wp_ajax_give_user_search', 'give_ajax_search_users'); |
|
401 | 401 | |
402 | 402 | |
403 | 403 | /** |
@@ -409,32 +409,32 @@ discard block |
||
409 | 409 | */ |
410 | 410 | function give_check_for_form_price_variations() { |
411 | 411 | |
412 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
413 | - die( '-1' ); |
|
412 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
413 | + die('-1'); |
|
414 | 414 | } |
415 | 415 | |
416 | - $form_id = intval( $_POST['form_id'] ); |
|
417 | - $form = get_post( $form_id ); |
|
416 | + $form_id = intval($_POST['form_id']); |
|
417 | + $form = get_post($form_id); |
|
418 | 418 | |
419 | - if ( 'give_forms' != $form->post_type ) { |
|
420 | - die( '-2' ); |
|
419 | + if ('give_forms' != $form->post_type) { |
|
420 | + die('-2'); |
|
421 | 421 | } |
422 | 422 | |
423 | - if ( give_has_variable_prices( $form_id ) ) { |
|
424 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
423 | + if (give_has_variable_prices($form_id)) { |
|
424 | + $variable_prices = give_get_variable_prices($form_id); |
|
425 | 425 | |
426 | - if ( $variable_prices ) { |
|
426 | + if ($variable_prices) { |
|
427 | 427 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
428 | 428 | |
429 | - if ( isset( $_POST['all_prices'] ) ) { |
|
430 | - $ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
429 | + if (isset($_POST['all_prices'])) { |
|
430 | + $ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>'; |
|
431 | 431 | } |
432 | 432 | |
433 | - foreach ( $variable_prices as $key => $price ) { |
|
433 | + foreach ($variable_prices as $key => $price) { |
|
434 | 434 | |
435 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
435 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))); |
|
436 | 436 | |
437 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
437 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
438 | 438 | } |
439 | 439 | $ajax_response .= '</select>'; |
440 | 440 | echo $ajax_response; |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | give_die(); |
445 | 445 | } |
446 | 446 | |
447 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
447 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
448 | 448 | |
449 | 449 | |
450 | 450 | /** |
@@ -455,25 +455,25 @@ discard block |
||
455 | 455 | * @return void |
456 | 456 | */ |
457 | 457 | function give_check_for_form_price_variations_html() { |
458 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
458 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
459 | 459 | wp_die(); |
460 | 460 | } |
461 | 461 | |
462 | - $form_id = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0; |
|
463 | - $payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : 0; |
|
464 | - $form = get_post( $form_id ); |
|
462 | + $form_id = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : 0; |
|
463 | + $payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : 0; |
|
464 | + $form = get_post($form_id); |
|
465 | 465 | |
466 | - if ( 'give_forms' != $form->post_type ) { |
|
466 | + if ('give_forms' != $form->post_type) { |
|
467 | 467 | wp_die(); |
468 | 468 | } |
469 | 469 | |
470 | - if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) { |
|
471 | - esc_html_e( 'n/a', 'give' ); |
|
470 | + if ( ! give_has_variable_prices($form_id) || ! $form_id) { |
|
471 | + esc_html_e('n/a', 'give'); |
|
472 | 472 | } else { |
473 | 473 | $prices_atts = ''; |
474 | - if ( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
475 | - foreach ( $variable_prices as $variable_price ) { |
|
476 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ); |
|
474 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
475 | + foreach ($variable_prices as $variable_price) { |
|
476 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false)); |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | 'chosen' => true, |
485 | 485 | 'show_option_all' => '', |
486 | 486 | 'show_option_none' => '', |
487 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
487 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
488 | 488 | ); |
489 | 489 | |
490 | - if ( $payment_id ) { |
|
490 | + if ($payment_id) { |
|
491 | 491 | // Payment object. |
492 | - $payment = new Give_Payment( $payment_id ); |
|
492 | + $payment = new Give_Payment($payment_id); |
|
493 | 493 | |
494 | 494 | // Payment meta. |
495 | 495 | $payment_meta = $payment->get_meta(); |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | } |
498 | 498 | |
499 | 499 | // Render variable prices select tag html. |
500 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
500 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | give_die(); |
504 | 504 | } |
505 | 505 | |
506 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
506 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |