@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return static |
54 | 54 | */ |
55 | 55 | public static function get_instance() { |
56 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
56 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
57 | 57 | self::$instance = new Give_Cache(); |
58 | 58 | } |
59 | 59 | |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setup() { |
70 | 70 | // Currently enable cache only for backend. |
71 | - self::$instance->is_cache = ( defined( 'GIVE_CACHE' ) ? GIVE_CACHE : give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) ) && is_admin(); |
|
71 | + self::$instance->is_cache = (defined('GIVE_CACHE') ? GIVE_CACHE : give_is_setting_enabled(give_get_option('cache', 'enabled'))) && is_admin(); |
|
72 | 72 | |
73 | 73 | // weekly delete all expired cache. |
74 | - Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) ); |
|
74 | + Give_Cron::add_weekly_event(array($this, 'delete_all_expired')); |
|
75 | 75 | |
76 | - add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) ); |
|
77 | - add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) ); |
|
78 | - add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 ); |
|
79 | - add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 ); |
|
76 | + add_action('save_post_give_forms', array($this, 'delete_form_related_cache')); |
|
77 | + add_action('save_post_give_payment', array($this, 'delete_payment_related_cache')); |
|
78 | + add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3); |
|
79 | + add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3); |
|
80 | 80 | |
81 | - add_action( 'give_save_settings_give_settings', array( $this, 'flush_cache' ) ); |
|
81 | + add_action('give_save_settings_give_settings', array($this, 'flush_cache')); |
|
82 | 82 | |
83 | - add_action( 'wp', array( __CLASS__, 'prevent_caching' ) ); |
|
84 | - add_action( 'admin_notices', array( $this, '__notices' ) ); |
|
83 | + add_action('wp', array(__CLASS__, 'prevent_caching')); |
|
84 | + add_action('admin_notices', array($this, '__notices')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @credit WooCommerce |
93 | 93 | */ |
94 | 94 | public static function prevent_caching() { |
95 | - if ( ! is_blog_installed() ) { |
|
95 | + if ( ! is_blog_installed()) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | - $page_ids = array_filter( array( |
|
100 | - give_get_option( 'success_page' ), |
|
101 | - give_get_option( 'failure_page' ), |
|
102 | - give_get_option( 'history_page' ), |
|
103 | - ) ); |
|
99 | + $page_ids = array_filter(array( |
|
100 | + give_get_option('success_page'), |
|
101 | + give_get_option('failure_page'), |
|
102 | + give_get_option('history_page'), |
|
103 | + )); |
|
104 | 104 | |
105 | 105 | if ( |
106 | - is_page( $page_ids ) |
|
107 | - || is_singular( 'give_forms' ) |
|
106 | + is_page($page_ids) |
|
107 | + || is_singular('give_forms') |
|
108 | 108 | ) { |
109 | 109 | self::set_nocache_constants(); |
110 | 110 | nocache_headers(); |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return mixed |
124 | 124 | */ |
125 | - public static function set_nocache_constants( $return = true ) { |
|
126 | - give_maybe_define_constant( 'DONOTCACHEPAGE', true ); |
|
127 | - give_maybe_define_constant( 'DONOTCACHEOBJECT', true ); |
|
128 | - give_maybe_define_constant( 'DONOTCACHEDB', true ); |
|
125 | + public static function set_nocache_constants($return = true) { |
|
126 | + give_maybe_define_constant('DONOTCACHEPAGE', true); |
|
127 | + give_maybe_define_constant('DONOTCACHEOBJECT', true); |
|
128 | + give_maybe_define_constant('DONOTCACHEDB', true); |
|
129 | 129 | |
130 | 130 | return $return; |
131 | 131 | } |
@@ -138,18 +138,18 @@ discard block |
||
138 | 138 | * @credit WooCommerce |
139 | 139 | */ |
140 | 140 | public function __notices() { |
141 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
141 | + if ( ! function_exists('w3tc_pgcache_flush') || ! function_exists('w3_instance')) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - $config = w3_instance( 'W3_Config' ); |
|
146 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
147 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
145 | + $config = w3_instance('W3_Config'); |
|
146 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
147 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
148 | 148 | |
149 | - if ( $enabled && ! in_array( 'give', $settings, true ) ) { |
|
149 | + if ($enabled && ! in_array('give', $settings, true)) { |
|
150 | 150 | ?> |
151 | 151 | <div class="error"> |
152 | - <p><?php echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give' ), '<code>give</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ) ); ?></p> |
|
152 | + <p><?php echo wp_kses_post(sprintf(__('In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give'), '<code>give</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache')))); ?></p> |
|
153 | 153 | </div> |
154 | 154 | <?php |
155 | 155 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public static function get_key( $action, $query_args = null, $is_prefix = true ) { |
|
169 | + public static function get_key($action, $query_args = null, $is_prefix = true) { |
|
170 | 170 | // Bailout. |
171 | - if ( empty( $action ) ) { |
|
172 | - return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) ); |
|
171 | + if (empty($action)) { |
|
172 | + return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give')); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // Set cache key. |
176 | 176 | $cache_key = $is_prefix ? "give_cache_{$action}" : $action; |
177 | 177 | |
178 | 178 | // Bailout. |
179 | - if ( ! empty( $query_args ) ) { |
|
180 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
179 | + if ( ! empty($query_args)) { |
|
180 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @since 2.0 |
187 | 187 | */ |
188 | - return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args ); |
|
188 | + return apply_filters('give_get_cache_key', $cache_key, $action, $query_args); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -199,26 +199,26 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return mixed |
201 | 201 | */ |
202 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
203 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
204 | - if ( ! $custom_key ) { |
|
205 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
202 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
203 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
204 | + if ( ! $custom_key) { |
|
205 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
206 | 206 | } |
207 | 207 | |
208 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
208 | + $cache_key = self::get_key($cache_key, $query_args); |
|
209 | 209 | } |
210 | 210 | |
211 | - $option = get_option( $cache_key ); |
|
211 | + $option = get_option($cache_key); |
|
212 | 212 | |
213 | 213 | // Backward compatibility (<1.8.7). |
214 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
214 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
215 | 215 | return $option; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Get current time. |
219 | - $current_time = current_time( 'timestamp', 1 ); |
|
219 | + $current_time = current_time('timestamp', 1); |
|
220 | 220 | |
221 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
221 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
222 | 222 | $option = $option['data']; |
223 | 223 | } else { |
224 | 224 | $option = false; |
@@ -240,23 +240,23 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return mixed |
242 | 242 | */ |
243 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
244 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
245 | - if ( ! $custom_key ) { |
|
246 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
243 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
244 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
245 | + if ( ! $custom_key) { |
|
246 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
247 | 247 | } |
248 | 248 | |
249 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
249 | + $cache_key = self::get_key($cache_key, $query_args); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | $option_value = array( |
253 | 253 | 'data' => $data, |
254 | - 'expiration' => ! is_null( $expiration ) |
|
255 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
254 | + 'expiration' => ! is_null($expiration) |
|
255 | + ? ($expiration + current_time('timestamp', 1)) |
|
256 | 256 | : null, |
257 | 257 | ); |
258 | 258 | |
259 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
259 | + $result = update_option($cache_key, $option_value, 'no'); |
|
260 | 260 | |
261 | 261 | return $result; |
262 | 262 | } |
@@ -272,27 +272,27 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return bool|WP_Error |
274 | 274 | */ |
275 | - public static function delete( $cache_keys ) { |
|
275 | + public static function delete($cache_keys) { |
|
276 | 276 | $result = true; |
277 | 277 | $invalid_keys = array(); |
278 | 278 | |
279 | - if ( ! empty( $cache_keys ) ) { |
|
280 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
279 | + if ( ! empty($cache_keys)) { |
|
280 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
281 | 281 | |
282 | - foreach ( $cache_keys as $cache_key ) { |
|
283 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
282 | + foreach ($cache_keys as $cache_key) { |
|
283 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
284 | 284 | $invalid_keys[] = $cache_key; |
285 | 285 | $result = false; |
286 | 286 | } |
287 | 287 | |
288 | - delete_option( $cache_key ); |
|
288 | + delete_option($cache_key); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | - if ( ! $result ) { |
|
292 | + if ( ! $result) { |
|
293 | 293 | $result = new WP_Error( |
294 | 294 | 'give_invalid_cache_key', |
295 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
295 | + __('Cache key format should be give_cache_*', 'give'), |
|
296 | 296 | $invalid_keys |
297 | 297 | ); |
298 | 298 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @return bool |
315 | 315 | */ |
316 | - public static function delete_all_expired( $force = false ) { |
|
316 | + public static function delete_all_expired($force = false) { |
|
317 | 317 | global $wpdb; |
318 | 318 | $options = $wpdb->get_results( |
319 | 319 | $wpdb->prepare( |
@@ -327,30 +327,30 @@ discard block |
||
327 | 327 | ); |
328 | 328 | |
329 | 329 | // Bailout. |
330 | - if ( empty( $options ) ) { |
|
330 | + if (empty($options)) { |
|
331 | 331 | return false; |
332 | 332 | } |
333 | 333 | |
334 | - $current_time = current_time( 'timestamp', 1 ); |
|
334 | + $current_time = current_time('timestamp', 1); |
|
335 | 335 | |
336 | 336 | // Delete log cache. |
337 | - foreach ( $options as $option ) { |
|
338 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
337 | + foreach ($options as $option) { |
|
338 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
339 | 339 | |
340 | 340 | if ( |
341 | 341 | ( |
342 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
343 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
344 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
345 | - || empty( $option['option_value']['expiration'] ) |
|
346 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
342 | + ! self::is_valid_cache_key($option['option_name']) |
|
343 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
344 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
345 | + || empty($option['option_value']['expiration']) |
|
346 | + || ($current_time < $option['option_value']['expiration']) |
|
347 | 347 | ) |
348 | 348 | && ! $force |
349 | 349 | ) { |
350 | 350 | continue; |
351 | 351 | } |
352 | 352 | |
353 | - self::delete( $option['option_name'] ); |
|
353 | + self::delete($option['option_name']); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -368,12 +368,12 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return array |
370 | 370 | */ |
371 | - public static function get_options_like( $option_name, $fields = false ) { |
|
371 | + public static function get_options_like($option_name, $fields = false) { |
|
372 | 372 | global $wpdb; |
373 | 373 | |
374 | 374 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
375 | 375 | |
376 | - if ( $fields ) { |
|
376 | + if ($fields) { |
|
377 | 377 | $options = $wpdb->get_results( |
378 | 378 | $wpdb->prepare( |
379 | 379 | "SELECT {$field_names } |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | ); |
398 | 398 | } |
399 | 399 | |
400 | - if ( ! empty( $options ) && $fields ) { |
|
401 | - foreach ( $options as $index => $option ) { |
|
402 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
403 | - $options[ $index ] = $option; |
|
400 | + if ( ! empty($options) && $fields) { |
|
401 | + foreach ($options as $index => $option) { |
|
402 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
403 | + $options[$index] = $option; |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * |
418 | 418 | * @return bool |
419 | 419 | */ |
420 | - public static function is_valid_cache_key( $cache_key ) { |
|
421 | - $is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
420 | + public static function is_valid_cache_key($cache_key) { |
|
421 | + $is_valid = (false !== strpos($cache_key, 'give_cache_')); |
|
422 | 422 | |
423 | 423 | |
424 | 424 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @since 2.0 |
428 | 428 | */ |
429 | - return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key ); |
|
429 | + return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -441,14 +441,14 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @return mixed |
443 | 443 | */ |
444 | - public static function get_group( $id, $group = '' ) { |
|
444 | + public static function get_group($id, $group = '') { |
|
445 | 445 | $cached_data = null; |
446 | 446 | |
447 | 447 | // Bailout. |
448 | - if ( self::$instance->is_cache && ! empty( $id ) ) { |
|
449 | - $group = self::$instance->filter_group_name( $group ); |
|
448 | + if (self::$instance->is_cache && ! empty($id)) { |
|
449 | + $group = self::$instance->filter_group_name($group); |
|
450 | 450 | |
451 | - $cached_data = wp_cache_get( $id, $group ); |
|
451 | + $cached_data = wp_cache_get($id, $group); |
|
452 | 452 | $cached_data = false !== $cached_data ? $cached_data : null; |
453 | 453 | } |
454 | 454 | |
@@ -468,17 +468,17 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return bool |
470 | 470 | */ |
471 | - public static function set_group( $id, $data, $group = '', $expire = 0 ) { |
|
471 | + public static function set_group($id, $data, $group = '', $expire = 0) { |
|
472 | 472 | $status = false; |
473 | 473 | |
474 | 474 | // Bailout. |
475 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
475 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
476 | 476 | return $status; |
477 | 477 | } |
478 | 478 | |
479 | - $group = self::$instance->filter_group_name( $group ); |
|
479 | + $group = self::$instance->filter_group_name($group); |
|
480 | 480 | |
481 | - $status = wp_cache_set( $id, $data, $group, $expire ); |
|
481 | + $status = wp_cache_set($id, $data, $group, $expire); |
|
482 | 482 | |
483 | 483 | return $status; |
484 | 484 | } |
@@ -494,15 +494,15 @@ discard block |
||
494 | 494 | * |
495 | 495 | * @return bool |
496 | 496 | */ |
497 | - public static function set_db_query( $id, $data ) { |
|
497 | + public static function set_db_query($id, $data) { |
|
498 | 498 | $status = false; |
499 | 499 | |
500 | 500 | // Bailout. |
501 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
501 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
502 | 502 | return $status; |
503 | 503 | } |
504 | 504 | |
505 | - return self::set_group( $id, $data, 'give-db-queries', 0 ); |
|
505 | + return self::set_group($id, $data, 'give-db-queries', 0); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @return mixed |
517 | 517 | */ |
518 | - public static function get_db_query( $id ) { |
|
519 | - return self::get_group( $id, 'give-db-queries' ); |
|
518 | + public static function get_db_query($id) { |
|
519 | + return self::get_group($id, 'give-db-queries'); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -531,20 +531,20 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @return bool |
533 | 533 | */ |
534 | - public static function delete_group( $ids, $group = '', $expire = 0 ) { |
|
534 | + public static function delete_group($ids, $group = '', $expire = 0) { |
|
535 | 535 | $status = false; |
536 | 536 | |
537 | 537 | // Bailout. |
538 | - if ( ! self::$instance->is_cache || empty( $ids ) ) { |
|
538 | + if ( ! self::$instance->is_cache || empty($ids)) { |
|
539 | 539 | return $status; |
540 | 540 | } |
541 | 541 | |
542 | - $group = self::$instance->filter_group_name( $group ); |
|
542 | + $group = self::$instance->filter_group_name($group); |
|
543 | 543 | |
544 | 544 | // Delete single or multiple cache items from cache. |
545 | - if ( ! is_array( $ids ) ) { |
|
546 | - $status = wp_cache_delete( $ids, $group, $expire ); |
|
547 | - self::$instance->get_incrementer( true ); |
|
545 | + if ( ! is_array($ids)) { |
|
546 | + $status = wp_cache_delete($ids, $group, $expire); |
|
547 | + self::$instance->get_incrementer(true); |
|
548 | 548 | |
549 | 549 | /** |
550 | 550 | * Fire action when cache deleted for specific id. |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | * @param string $group |
556 | 556 | * @param int $expire |
557 | 557 | */ |
558 | - do_action( "give_deleted_{$group}_cache", $ids, $group, $expire, $status ); |
|
558 | + do_action("give_deleted_{$group}_cache", $ids, $group, $expire, $status); |
|
559 | 559 | |
560 | 560 | } else { |
561 | - foreach ( $ids as $id ) { |
|
562 | - $status = wp_cache_delete( $id, $group, $expire ); |
|
563 | - self::$instance->get_incrementer( true ); |
|
561 | + foreach ($ids as $id) { |
|
562 | + $status = wp_cache_delete($id, $group, $expire); |
|
563 | + self::$instance->get_incrementer(true); |
|
564 | 564 | |
565 | 565 | /** |
566 | 566 | * Fire action when cache deleted for specific id . |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * @param string $group |
572 | 572 | * @param int $expire |
573 | 573 | */ |
574 | - do_action( "give_deleted_{$group}_cache", $id, $group, $expire, $status ); |
|
574 | + do_action("give_deleted_{$group}_cache", $id, $group, $expire, $status); |
|
575 | 575 | } |
576 | 576 | } |
577 | 577 | |
@@ -588,30 +588,30 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @param int $form_id |
590 | 590 | */ |
591 | - public function delete_form_related_cache( $form_id ) { |
|
591 | + public function delete_form_related_cache($form_id) { |
|
592 | 592 | // If this is just a revision, don't send the email. |
593 | - if ( wp_is_post_revision( $form_id ) ) { |
|
593 | + if (wp_is_post_revision($form_id)) { |
|
594 | 594 | return; |
595 | 595 | } |
596 | 596 | |
597 | 597 | $donation_query = new Give_Payments_Query( |
598 | 598 | array( |
599 | - 'number' => - 1, |
|
599 | + 'number' => -1, |
|
600 | 600 | 'give_forms' => $form_id, |
601 | 601 | ) |
602 | 602 | ); |
603 | 603 | |
604 | 604 | $donations = $donation_query->get_payments(); |
605 | 605 | |
606 | - if ( ! empty( $donations ) ) { |
|
606 | + if ( ! empty($donations)) { |
|
607 | 607 | /* @var Give_Payment $donation */ |
608 | - foreach ( $donations as $donation ) { |
|
609 | - wp_cache_delete( $donation->ID, $this->filter_group_name( 'give-donations' ) ); |
|
610 | - wp_cache_delete( $donation->donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
608 | + foreach ($donations as $donation) { |
|
609 | + wp_cache_delete($donation->ID, $this->filter_group_name('give-donations')); |
|
610 | + wp_cache_delete($donation->donor_id, $this->filter_group_name('give-donors')); |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
614 | - self::$instance->get_incrementer( true ); |
|
614 | + self::$instance->get_incrementer(true); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -623,22 +623,22 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @param int $donation_id |
625 | 625 | */ |
626 | - public function delete_payment_related_cache( $donation_id ) { |
|
626 | + public function delete_payment_related_cache($donation_id) { |
|
627 | 627 | // If this is just a revision, don't send the email. |
628 | - if ( wp_is_post_revision( $donation_id ) ) { |
|
628 | + if (wp_is_post_revision($donation_id)) { |
|
629 | 629 | return; |
630 | 630 | } |
631 | 631 | |
632 | 632 | /* @var Give_Payment $donation */ |
633 | - $donation = new Give_Payment( $donation_id ); |
|
633 | + $donation = new Give_Payment($donation_id); |
|
634 | 634 | |
635 | - if ( $donation && $donation->donor_id ) { |
|
636 | - wp_cache_delete( $donation->donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
635 | + if ($donation && $donation->donor_id) { |
|
636 | + wp_cache_delete($donation->donor_id, $this->filter_group_name('give-donors')); |
|
637 | 637 | } |
638 | 638 | |
639 | - wp_cache_delete( $donation->ID, $this->filter_group_name( 'give-donations' ) ); |
|
639 | + wp_cache_delete($donation->ID, $this->filter_group_name('give-donations')); |
|
640 | 640 | |
641 | - self::$instance->get_incrementer( true ); |
|
641 | + self::$instance->get_incrementer(true); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -652,17 +652,17 @@ discard block |
||
652 | 652 | * @param string $group |
653 | 653 | * @param int $expire |
654 | 654 | */ |
655 | - public function delete_donor_related_cache( $id, $group, $expire ) { |
|
656 | - $donor = new Give_Donor( $id ); |
|
657 | - $donation_ids = array_map( 'trim', (array) explode( ',', trim( $donor->payment_ids ) ) ); |
|
655 | + public function delete_donor_related_cache($id, $group, $expire) { |
|
656 | + $donor = new Give_Donor($id); |
|
657 | + $donation_ids = array_map('trim', (array) explode(',', trim($donor->payment_ids))); |
|
658 | 658 | |
659 | - if ( ! empty( $donation_ids ) ) { |
|
660 | - foreach ( $donation_ids as $donation ) { |
|
661 | - wp_cache_delete( $donation, $this->filter_group_name( 'give-donations' ) ); |
|
659 | + if ( ! empty($donation_ids)) { |
|
660 | + foreach ($donation_ids as $donation) { |
|
661 | + wp_cache_delete($donation, $this->filter_group_name('give-donations')); |
|
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
665 | - self::$instance->get_incrementer( true ); |
|
665 | + self::$instance->get_incrementer(true); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -676,15 +676,15 @@ discard block |
||
676 | 676 | * @param string $group |
677 | 677 | * @param int $expire |
678 | 678 | */ |
679 | - public function delete_donations_related_cache( $id, $group, $expire ) { |
|
679 | + public function delete_donations_related_cache($id, $group, $expire) { |
|
680 | 680 | /* @var Give_Payment $donation */ |
681 | - $donation = new Give_Payment( $id ); |
|
681 | + $donation = new Give_Payment($id); |
|
682 | 682 | |
683 | - if ( $donation && $donation->donor_id ) { |
|
684 | - wp_cache_delete( $donation->donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
683 | + if ($donation && $donation->donor_id) { |
|
684 | + wp_cache_delete($donation->donor_id, $this->filter_group_name('give-donors')); |
|
685 | 685 | } |
686 | 686 | |
687 | - self::$instance->get_incrementer( true ); |
|
687 | + self::$instance->get_incrementer(true); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -702,12 +702,12 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @return string |
704 | 704 | */ |
705 | - private function get_incrementer( $refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries' ) { |
|
706 | - $incrementer_value = wp_cache_get( $incrementer_key ); |
|
705 | + private function get_incrementer($refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries') { |
|
706 | + $incrementer_value = wp_cache_get($incrementer_key); |
|
707 | 707 | |
708 | - if ( false === $incrementer_value || true === $refresh ) { |
|
709 | - $incrementer_value = microtime( true ); |
|
710 | - wp_cache_set( $incrementer_key, $incrementer_value ); |
|
708 | + if (false === $incrementer_value || true === $refresh) { |
|
709 | + $incrementer_value = microtime(true); |
|
710 | + wp_cache_set($incrementer_key, $incrementer_value); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | return $incrementer_value; |
@@ -724,11 +724,11 @@ discard block |
||
724 | 724 | public function flush_cache() { |
725 | 725 | if ( |
726 | 726 | Give_Admin_Settings::is_saving_settings() && |
727 | - isset( $_POST['cache'] ) && |
|
728 | - give_is_setting_enabled( give_clean( $_POST['cache'] ) ) |
|
727 | + isset($_POST['cache']) && |
|
728 | + give_is_setting_enabled(give_clean($_POST['cache'])) |
|
729 | 729 | ) { |
730 | - $this->get_incrementer( true ); |
|
731 | - $this->get_incrementer( true, 'give-cache-incrementer' ); |
|
730 | + $this->get_incrementer(true); |
|
731 | + $this->get_incrementer(true, 'give-cache-incrementer'); |
|
732 | 732 | } |
733 | 733 | } |
734 | 734 | |
@@ -743,13 +743,13 @@ discard block |
||
743 | 743 | * |
744 | 744 | * @return mixed |
745 | 745 | */ |
746 | - private function filter_group_name( $group ) { |
|
747 | - $group = "{$group}_" . get_current_blog_id(); |
|
746 | + private function filter_group_name($group) { |
|
747 | + $group = "{$group}_".get_current_blog_id(); |
|
748 | 748 | |
749 | - if ( ! empty( $group ) ) { |
|
750 | - $incrementer = self::$instance->get_incrementer( false, 'give-cache-incrementer' ); |
|
749 | + if ( ! empty($group)) { |
|
750 | + $incrementer = self::$instance->get_incrementer(false, 'give-cache-incrementer'); |
|
751 | 751 | |
752 | - if ( 'give-db-queries' === $group ) { |
|
752 | + if ('give-db-queries' === $group) { |
|
753 | 753 | $incrementer = self::$instance->get_incrementer(); |
754 | 754 | } |
755 | 755 |
@@ -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,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | |
40 | 40 | global $wp; |
41 | 41 | |
42 | - if ( get_option( 'permalink_structure' ) ) { |
|
43 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
42 | + if (get_option('permalink_structure')) { |
|
43 | + $base = trailingslashit(home_url($wp->request)); |
|
44 | 44 | } else { |
45 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
46 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
45 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
46 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $scheme = is_ssl() ? 'https' : 'http'; |
50 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
50 | + $current_uri = set_url_scheme($base, $scheme); |
|
51 | 51 | |
52 | - if ( is_front_page() ) { |
|
53 | - $current_uri = home_url( '/' ); |
|
52 | + if (is_front_page()) { |
|
53 | + $current_uri = home_url('/'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param string $current_uri |
62 | 62 | */ |
63 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
63 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | */ |
83 | 83 | $gateways = give_get_enabled_payment_gateways(); |
84 | 84 | |
85 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
85 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
86 | 86 | $ret = true; |
87 | - } elseif ( count( $gateways ) == 1 ) { |
|
87 | + } elseif (count($gateways) == 1) { |
|
88 | 88 | $ret = false; |
89 | - } elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
89 | + } elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
90 | 90 | $ret = false; |
91 | 91 | } |
92 | 92 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param bool $ret |
99 | 99 | */ |
100 | - return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret ); |
|
100 | + return (bool) apply_filters('give_is_cc_verify_enabled', $ret); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -109,26 +109,26 @@ discard block |
||
109 | 109 | function give_get_timezone_id() { |
110 | 110 | |
111 | 111 | // if site timezone string exists, return it. |
112 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
112 | + if ($timezone = get_option('timezone_string')) { |
|
113 | 113 | return $timezone; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // get UTC offset, if it isn't set return UTC. |
117 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
117 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
118 | 118 | return 'UTC'; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // attempt to guess the timezone string from the UTC offset. |
122 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
122 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
123 | 123 | |
124 | 124 | // last try, guess timezone string manually. |
125 | - if ( $timezone === false ) { |
|
125 | + if ($timezone === false) { |
|
126 | 126 | |
127 | - $is_dst = date( 'I' ); |
|
127 | + $is_dst = date('I'); |
|
128 | 128 | |
129 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
130 | - foreach ( $abbr as $city ) { |
|
131 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
129 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
130 | + foreach ($abbr as $city) { |
|
131 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
132 | 132 | return $city['timezone_id']; |
133 | 133 | } |
134 | 134 | } |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | |
153 | 153 | $ip = '127.0.0.1'; |
154 | 154 | |
155 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
155 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
156 | 156 | // check ip from share internet |
157 | 157 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
158 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
158 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
159 | 159 | // to check ip is pass from proxy |
160 | 160 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
161 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
161 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
162 | 162 | $ip = $_SERVER['REMOTE_ADDR']; |
163 | 163 | } |
164 | 164 | |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @since 1.0 |
169 | 169 | */ |
170 | - $ip = apply_filters( 'give_get_ip', $ip ); |
|
170 | + $ip = apply_filters('give_get_ip', $ip); |
|
171 | 171 | |
172 | 172 | // Filter empty values. |
173 | - if( false !== strpos( $ip, ',' ) ) { |
|
174 | - $ip = give_clean( explode( ',', $ip ) ); |
|
175 | - $ip = array_filter( $ip ); |
|
176 | - $ip = implode( ',', $ip ); |
|
177 | - } else{ |
|
178 | - $ip = give_clean( $ip ); |
|
173 | + if (false !== strpos($ip, ',')) { |
|
174 | + $ip = give_clean(explode(',', $ip)); |
|
175 | + $ip = array_filter($ip); |
|
176 | + $ip = implode(',', $ip); |
|
177 | + } else { |
|
178 | + $ip = give_clean($ip); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $ip; |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @uses Give()->session->set() |
195 | 195 | */ |
196 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
197 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
198 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
196 | +function give_set_purchase_session($purchase_data = array()) { |
|
197 | + Give()->session->set('give_purchase', $purchase_data); |
|
198 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return mixed array | false |
210 | 210 | */ |
211 | 211 | function give_get_purchase_session() { |
212 | - return Give()->session->get( 'give_purchase' ); |
|
212 | + return Give()->session->get('give_purchase'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return array|string |
221 | 221 | */ |
222 | 222 | function give_get_receipt_session() { |
223 | - return Give()->session->get( 'receipt_access' ); |
|
223 | + return Give()->session->get('receipt_access'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @return array|string |
232 | 232 | */ |
233 | 233 | function give_get_history_session() { |
234 | - return (bool) Give()->session->get( 'history_access' ); |
|
234 | + return (bool) Give()->session->get('history_access'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @return string By default, the name of the form. Then the price level text if any is found. |
245 | 245 | */ |
246 | -function give_payment_gateway_item_title( $payment_data ) { |
|
246 | +function give_payment_gateway_item_title($payment_data) { |
|
247 | 247 | |
248 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
249 | - $item_name = isset( $payment_data['post_data']['give-form-title'] ) ? $payment_data['post_data']['give-form-title'] : ''; |
|
250 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
248 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
249 | + $item_name = isset($payment_data['post_data']['give-form-title']) ? $payment_data['post_data']['give-form-title'] : ''; |
|
250 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
251 | 251 | |
252 | 252 | |
253 | 253 | // Verify has variable prices. |
254 | - if ( give_has_variable_prices( $form_id ) && ! empty( $price_id ) ) { |
|
254 | + if (give_has_variable_prices($form_id) && ! empty($price_id)) { |
|
255 | 255 | |
256 | - $item_price_level_text = give_get_price_option_name( $form_id, $price_id, 0, false ); |
|
256 | + $item_price_level_text = give_get_price_option_name($form_id, $price_id, 0, false); |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Output donation level text if: |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | */ |
264 | 264 | if ( |
265 | 265 | 'custom' !== $price_id |
266 | - && ! empty( $item_price_level_text ) |
|
266 | + && ! empty($item_price_level_text) |
|
267 | 267 | ) { |
268 | 268 | // Matches a donation level - append level text. |
269 | - $item_name .= ' - ' . $item_price_level_text; |
|
269 | + $item_name .= ' - '.$item_price_level_text; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data ); |
|
284 | + return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -297,38 +297,38 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return string |
299 | 299 | */ |
300 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { |
|
300 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { |
|
301 | 301 | |
302 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; |
|
303 | - $price_id = isset( $donation_data['post_data']['give-price-id'] ) ? $donation_data['post_data']['give-price-id'] : ''; |
|
302 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; |
|
303 | + $price_id = isset($donation_data['post_data']['give-price-id']) ? $donation_data['post_data']['give-price-id'] : ''; |
|
304 | 304 | |
305 | 305 | // Form title. |
306 | - $summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) ); |
|
306 | + $summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give'))); |
|
307 | 307 | |
308 | 308 | // Form multilevel if applicable. |
309 | - if ( ! empty( $price_id ) && 'custom' !== $price_id ) { |
|
310 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); |
|
309 | + if ( ! empty($price_id) && 'custom' !== $price_id) { |
|
310 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | // Add Donor's name + email if requested. |
314 | - if ( $name_and_email ) { |
|
314 | + if ($name_and_email) { |
|
315 | 315 | |
316 | 316 | // First name |
317 | - if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { |
|
318 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; |
|
317 | + if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { |
|
318 | + $summary .= ' - '.$donation_data['user_info']['first_name']; |
|
319 | 319 | } |
320 | 320 | |
321 | - if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { |
|
322 | - $summary .= ' ' . $donation_data['user_info']['last_name']; |
|
321 | + if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { |
|
322 | + $summary .= ' '.$donation_data['user_info']['last_name']; |
|
323 | 323 | } |
324 | 324 | |
325 | - $summary .= ' (' . $donation_data['user_email'] . ')'; |
|
325 | + $summary .= ' ('.$donation_data['user_email'].')'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | // Cut the length |
329 | - $summary = substr( $summary, 0, $length ); |
|
329 | + $summary = substr($summary, 0, $length); |
|
330 | 330 | |
331 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); |
|
331 | + return apply_filters('give_payment_gateway_donation_summary', $summary); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -343,31 +343,31 @@ discard block |
||
343 | 343 | function give_get_host() { |
344 | 344 | $host = false; |
345 | 345 | |
346 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
346 | + if (defined('WPE_APIKEY')) { |
|
347 | 347 | $host = 'WP Engine'; |
348 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
348 | + } elseif (defined('PAGELYBIN')) { |
|
349 | 349 | $host = 'Pagely'; |
350 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
350 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
351 | 351 | $host = 'ICDSoft'; |
352 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
352 | + } elseif (DB_HOST == 'mysqlv5') { |
|
353 | 353 | $host = 'NetworkSolutions'; |
354 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
354 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
355 | 355 | $host = 'iPage'; |
356 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
356 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
357 | 357 | $host = 'IPower'; |
358 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
358 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
359 | 359 | $host = 'MediaTemple Grid'; |
360 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
360 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
361 | 361 | $host = 'pair Networks'; |
362 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
362 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
363 | 363 | $host = 'Rackspace Cloud'; |
364 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
364 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
365 | 365 | $host = 'SysFix.eu Power Hosting'; |
366 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
366 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
367 | 367 | $host = 'Flywheel'; |
368 | 368 | } else { |
369 | 369 | // Adding a general fallback for data gathering |
370 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
370 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | return $host; |
@@ -383,67 +383,67 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @return bool true if host matches, false if not |
385 | 385 | */ |
386 | -function give_is_host( $host = false ) { |
|
386 | +function give_is_host($host = false) { |
|
387 | 387 | |
388 | 388 | $return = false; |
389 | 389 | |
390 | - if ( $host ) { |
|
391 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
390 | + if ($host) { |
|
391 | + $host = str_replace(' ', '', strtolower($host)); |
|
392 | 392 | |
393 | - switch ( $host ) { |
|
393 | + switch ($host) { |
|
394 | 394 | case 'wpengine': |
395 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
395 | + if (defined('WPE_APIKEY')) { |
|
396 | 396 | $return = true; |
397 | 397 | } |
398 | 398 | break; |
399 | 399 | case 'pagely': |
400 | - if ( defined( 'PAGELYBIN' ) ) { |
|
400 | + if (defined('PAGELYBIN')) { |
|
401 | 401 | $return = true; |
402 | 402 | } |
403 | 403 | break; |
404 | 404 | case 'icdsoft': |
405 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
405 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
406 | 406 | $return = true; |
407 | 407 | } |
408 | 408 | break; |
409 | 409 | case 'networksolutions': |
410 | - if ( DB_HOST == 'mysqlv5' ) { |
|
410 | + if (DB_HOST == 'mysqlv5') { |
|
411 | 411 | $return = true; |
412 | 412 | } |
413 | 413 | break; |
414 | 414 | case 'ipage': |
415 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
415 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
416 | 416 | $return = true; |
417 | 417 | } |
418 | 418 | break; |
419 | 419 | case 'ipower': |
420 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
420 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
421 | 421 | $return = true; |
422 | 422 | } |
423 | 423 | break; |
424 | 424 | case 'mediatemplegrid': |
425 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
425 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
426 | 426 | $return = true; |
427 | 427 | } |
428 | 428 | break; |
429 | 429 | case 'pairnetworks': |
430 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
430 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
431 | 431 | $return = true; |
432 | 432 | } |
433 | 433 | break; |
434 | 434 | case 'rackspacecloud': |
435 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
435 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
436 | 436 | $return = true; |
437 | 437 | } |
438 | 438 | break; |
439 | 439 | case 'sysfix.eu': |
440 | 440 | case 'sysfix.eupowerhosting': |
441 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
441 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
442 | 442 | $return = true; |
443 | 443 | } |
444 | 444 | break; |
445 | 445 | case 'flywheel': |
446 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
446 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
447 | 447 | $return = true; |
448 | 448 | } |
449 | 449 | break; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param string $replacement Optional. The function that should have been called. |
477 | 477 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
478 | 478 | */ |
479 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
479 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
480 | 480 | |
481 | 481 | /** |
482 | 482 | * Fires while give deprecated function call occurs. |
@@ -489,19 +489,19 @@ discard block |
||
489 | 489 | * @param string $replacement Optional. The function that should have been called. |
490 | 490 | * @param string $version The plugin version that deprecated the function. |
491 | 491 | */ |
492 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
492 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
493 | 493 | |
494 | - $show_errors = current_user_can( 'manage_options' ); |
|
494 | + $show_errors = current_user_can('manage_options'); |
|
495 | 495 | |
496 | 496 | // Allow plugin to filter the output error trigger. |
497 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
498 | - if ( ! is_null( $replacement ) ) { |
|
499 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
500 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
497 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
498 | + if ( ! is_null($replacement)) { |
|
499 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
500 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
501 | 501 | // Alternatively we could dump this to a file. |
502 | 502 | } else { |
503 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
504 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
503 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
504 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
505 | 505 | // Alternatively we could dump this to a file. |
506 | 506 | } |
507 | 507 | } |
@@ -515,17 +515,17 @@ discard block |
||
515 | 515 | * @return string $post_id |
516 | 516 | */ |
517 | 517 | function give_get_admin_post_id() { |
518 | - $post_id = isset( $_REQUEST['post'] ) |
|
519 | - ? absint( $_REQUEST['post'] ) |
|
518 | + $post_id = isset($_REQUEST['post']) |
|
519 | + ? absint($_REQUEST['post']) |
|
520 | 520 | : null; |
521 | 521 | |
522 | - $post_id = ! empty( $post_id ) |
|
522 | + $post_id = ! empty($post_id) |
|
523 | 523 | ? $post_id |
524 | - : ( isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : null ); |
|
524 | + : (isset($_REQUEST['post_id']) ? absint($_REQUEST['post_id']) : null); |
|
525 | 525 | |
526 | - $post_id = ! empty( $post_id ) |
|
526 | + $post_id = ! empty($post_id) |
|
527 | 527 | ? $post_id |
528 | - : ( isset( $_REQUEST['post_ID'] ) ? absint( $_REQUEST['post_ID'] ) : null ); |
|
528 | + : (isset($_REQUEST['post_ID']) ? absint($_REQUEST['post_ID']) : null); |
|
529 | 529 | |
530 | 530 | return $post_id; |
531 | 531 | } |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * @return string Arg separator output |
538 | 538 | */ |
539 | 539 | function give_get_php_arg_separator_output() { |
540 | - return ini_get( 'arg_separator.output' ); |
|
540 | + return ini_get('arg_separator.output'); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
@@ -552,10 +552,10 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return string Short month name |
554 | 554 | */ |
555 | -function give_month_num_to_name( $n ) { |
|
556 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
555 | +function give_month_num_to_name($n) { |
|
556 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
557 | 557 | |
558 | - return date_i18n( 'M', $timestamp ); |
|
558 | + return date_i18n('M', $timestamp); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @return bool Whether or not function is disabled. |
570 | 570 | */ |
571 | -function give_is_func_disabled( $function ) { |
|
572 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
571 | +function give_is_func_disabled($function) { |
|
572 | + $disabled = explode(',', ini_get('disable_functions')); |
|
573 | 573 | |
574 | - return in_array( $function, $disabled ); |
|
574 | + return in_array($function, $disabled); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | function give_get_newsletter() { |
584 | 584 | ?> |
585 | 585 | |
586 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
586 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
587 | 587 | |
588 | 588 | <div class="give-newsletter-form-wrap"> |
589 | 589 | |
@@ -591,33 +591,33 @@ discard block |
||
591 | 591 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
592 | 592 | target="_blank" novalidate> |
593 | 593 | <div class="give-newsletter-confirmation"> |
594 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
594 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
595 | 595 | </div> |
596 | 596 | |
597 | 597 | <table class="form-table give-newsletter-form"> |
598 | 598 | <tr valign="middle"> |
599 | 599 | <td> |
600 | 600 | <label for="mce-EMAIL" |
601 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
601 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
602 | 602 | <input type="email" name="EMAIL" id="mce-EMAIL" |
603 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
603 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
604 | 604 | class="required email" value=""> |
605 | 605 | </td> |
606 | 606 | <td> |
607 | 607 | <label for="mce-FNAME" |
608 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
608 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
609 | 609 | <input type="text" name="FNAME" id="mce-FNAME" |
610 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
610 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
611 | 611 | </td> |
612 | 612 | <td> |
613 | 613 | <label for="mce-LNAME" |
614 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
614 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
615 | 615 | <input type="text" name="LNAME" id="mce-LNAME" |
616 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
616 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
617 | 617 | </td> |
618 | 618 | <td> |
619 | 619 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
620 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
620 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
621 | 621 | </td> |
622 | 622 | </tr> |
623 | 623 | </table> |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return string |
672 | 672 | */ |
673 | -function give_svg_icons( $icon ) { |
|
673 | +function give_svg_icons($icon) { |
|
674 | 674 | |
675 | 675 | // Store your SVGs in an associative array |
676 | 676 | $svgs = array( |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | ); |
683 | 683 | |
684 | 684 | // Return the chosen icon's SVG string |
685 | - return $svgs[ $icon ]; |
|
685 | + return $svgs[$icon]; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -694,15 +694,15 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @return mixed |
696 | 696 | */ |
697 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
698 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
699 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
697 | +function modify_nav_menu_meta_box_object($post_type) { |
|
698 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
699 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | return $post_type; |
703 | 703 | } |
704 | 704 | |
705 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
705 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
706 | 706 | |
707 | 707 | /** |
708 | 708 | * Show Donation Forms Post Type in Appearance > Menus by default on fresh install. |
@@ -721,35 +721,35 @@ discard block |
||
721 | 721 | // Proceed, if current screen is navigation menus. |
722 | 722 | if ( |
723 | 723 | 'nav-menus' === $screen->id && |
724 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) && |
|
725 | - ! get_user_option( 'give_is_donation_forms_menu_updated' ) |
|
724 | + give_is_setting_enabled(give_get_option('forms_singular')) && |
|
725 | + ! get_user_option('give_is_donation_forms_menu_updated') |
|
726 | 726 | ) { |
727 | 727 | |
728 | 728 | // Return false, if it fails to retrieve hidden meta box list and is not admin. |
729 | 729 | if ( |
730 | 730 | ! is_admin() || |
731 | - ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) |
|
731 | + ( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) |
|
732 | 732 | ) { |
733 | 733 | return false; |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. |
737 | - if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { |
|
737 | + if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { |
|
738 | 738 | return false; |
739 | 739 | } |
740 | 740 | |
741 | 741 | // Exclude 'Donation Form' value from hidden meta box's list. |
742 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); |
|
742 | + $hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); |
|
743 | 743 | |
744 | 744 | // Get current user ID. |
745 | 745 | $user = wp_get_current_user(); |
746 | 746 | |
747 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
748 | - update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true ); |
|
747 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
748 | + update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true); |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | |
752 | -add_action( 'current_screen', 'give_donation_metabox_menu' ); |
|
752 | +add_action('current_screen', 'give_donation_metabox_menu'); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Array_column backup usage |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * @license https://opensource.org/licenses/MIT MIT |
763 | 763 | */ |
764 | 764 | |
765 | -if ( ! function_exists( 'array_column' ) ) { |
|
765 | +if ( ! function_exists('array_column')) { |
|
766 | 766 | /** |
767 | 767 | * Returns the values from a single column of the input array, identified by |
768 | 768 | * the $columnKey. |
@@ -781,53 +781,53 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return array |
783 | 783 | */ |
784 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
784 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
785 | 785 | // Using func_get_args() in order to check for proper number of |
786 | 786 | // parameters and trigger errors exactly as the built-in array_column() |
787 | 787 | // does in PHP 5.5. |
788 | 788 | $argc = func_num_args(); |
789 | 789 | $params = func_get_args(); |
790 | 790 | |
791 | - if ( $argc < 2 ) { |
|
792 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
791 | + if ($argc < 2) { |
|
792 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
793 | 793 | |
794 | 794 | return null; |
795 | 795 | } |
796 | 796 | |
797 | - if ( ! is_array( $params[0] ) ) { |
|
798 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
797 | + if ( ! is_array($params[0])) { |
|
798 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
799 | 799 | |
800 | 800 | return null; |
801 | 801 | } |
802 | 802 | |
803 | - if ( ! is_int( $params[1] ) |
|
804 | - && ! is_float( $params[1] ) |
|
805 | - && ! is_string( $params[1] ) |
|
803 | + if ( ! is_int($params[1]) |
|
804 | + && ! is_float($params[1]) |
|
805 | + && ! is_string($params[1]) |
|
806 | 806 | && $params[1] !== null |
807 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
807 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
808 | 808 | ) { |
809 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
809 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
810 | 810 | |
811 | 811 | return false; |
812 | 812 | } |
813 | 813 | |
814 | - if ( isset( $params[2] ) |
|
815 | - && ! is_int( $params[2] ) |
|
816 | - && ! is_float( $params[2] ) |
|
817 | - && ! is_string( $params[2] ) |
|
818 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
814 | + if (isset($params[2]) |
|
815 | + && ! is_int($params[2]) |
|
816 | + && ! is_float($params[2]) |
|
817 | + && ! is_string($params[2]) |
|
818 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
819 | 819 | ) { |
820 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
820 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
821 | 821 | |
822 | 822 | return false; |
823 | 823 | } |
824 | 824 | |
825 | 825 | $paramsInput = $params[0]; |
826 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
826 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
827 | 827 | |
828 | 828 | $paramsIndexKey = null; |
829 | - if ( isset( $params[2] ) ) { |
|
830 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
829 | + if (isset($params[2])) { |
|
830 | + if (is_float($params[2]) || is_int($params[2])) { |
|
831 | 831 | $paramsIndexKey = (int) $params[2]; |
832 | 832 | } else { |
833 | 833 | $paramsIndexKey = (string) $params[2]; |
@@ -836,26 +836,26 @@ discard block |
||
836 | 836 | |
837 | 837 | $resultArray = array(); |
838 | 838 | |
839 | - foreach ( $paramsInput as $row ) { |
|
839 | + foreach ($paramsInput as $row) { |
|
840 | 840 | $key = $value = null; |
841 | 841 | $keySet = $valueSet = false; |
842 | 842 | |
843 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
843 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
844 | 844 | $keySet = true; |
845 | - $key = (string) $row[ $paramsIndexKey ]; |
|
845 | + $key = (string) $row[$paramsIndexKey]; |
|
846 | 846 | } |
847 | 847 | |
848 | - if ( $paramsColumnKey === null ) { |
|
848 | + if ($paramsColumnKey === null) { |
|
849 | 849 | $valueSet = true; |
850 | 850 | $value = $row; |
851 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
851 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
852 | 852 | $valueSet = true; |
853 | - $value = $row[ $paramsColumnKey ]; |
|
853 | + $value = $row[$paramsColumnKey]; |
|
854 | 854 | } |
855 | 855 | |
856 | - if ( $valueSet ) { |
|
857 | - if ( $keySet ) { |
|
858 | - $resultArray[ $key ] = $value; |
|
856 | + if ($valueSet) { |
|
857 | + if ($keySet) { |
|
858 | + $resultArray[$key] = $value; |
|
859 | 859 | } else { |
860 | 860 | $resultArray[] = $value; |
861 | 861 | } |
@@ -875,54 +875,54 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return bool Whether the receipt is visible or not. |
877 | 877 | */ |
878 | -function give_can_view_receipt( $payment_key = '' ) { |
|
878 | +function give_can_view_receipt($payment_key = '') { |
|
879 | 879 | |
880 | 880 | $return = false; |
881 | 881 | |
882 | - if ( empty( $payment_key ) ) { |
|
882 | + if (empty($payment_key)) { |
|
883 | 883 | return $return; |
884 | 884 | } |
885 | 885 | |
886 | 886 | global $give_receipt_args; |
887 | 887 | |
888 | - $give_receipt_args['id'] = give_get_donation_id_by_key( $payment_key ); |
|
888 | + $give_receipt_args['id'] = give_get_donation_id_by_key($payment_key); |
|
889 | 889 | |
890 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
890 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
891 | 891 | |
892 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
892 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
893 | 893 | |
894 | - if ( is_user_logged_in() ) { |
|
895 | - if ( $user_id === (int) get_current_user_id() ) { |
|
894 | + if (is_user_logged_in()) { |
|
895 | + if ($user_id === (int) get_current_user_id()) { |
|
896 | 896 | $return = true; |
897 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
897 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
898 | 898 | $return = true; |
899 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
899 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
900 | 900 | $return = true; |
901 | 901 | } |
902 | 902 | } |
903 | 903 | |
904 | 904 | // Check whether it is purchase session? |
905 | 905 | $purchase_session = give_get_purchase_session(); |
906 | - if ( ! empty( $purchase_session ) && ! is_user_logged_in() ) { |
|
907 | - if ( $purchase_session['purchase_key'] === $payment_meta['key'] ) { |
|
906 | + if ( ! empty($purchase_session) && ! is_user_logged_in()) { |
|
907 | + if ($purchase_session['purchase_key'] === $payment_meta['key']) { |
|
908 | 908 | $return = true; |
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
912 | 912 | // Check whether it is receipt access session? |
913 | 913 | $receipt_session = give_get_receipt_session(); |
914 | - if ( ! empty( $receipt_session ) && ! is_user_logged_in() ) { |
|
915 | - if ( $receipt_session === $payment_meta['key'] ) { |
|
914 | + if ( ! empty($receipt_session) && ! is_user_logged_in()) { |
|
915 | + if ($receipt_session === $payment_meta['key']) { |
|
916 | 916 | $return = true; |
917 | 917 | } |
918 | 918 | } |
919 | 919 | |
920 | 920 | // Check whether it is history access session? |
921 | - if ( true === give_get_history_session() ) { |
|
921 | + if (true === give_get_history_session()) { |
|
922 | 922 | $return = true; |
923 | 923 | } |
924 | 924 | |
925 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
925 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
926 | 926 | |
927 | 927 | } |
928 | 928 | |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | * |
932 | 932 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
933 | 933 | */ |
934 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
934 | +if ( ! function_exists('cal_days_in_month')) { |
|
935 | 935 | /** |
936 | 936 | * cal_days_in_month |
937 | 937 | * |
@@ -941,8 +941,8 @@ discard block |
||
941 | 941 | * |
942 | 942 | * @return bool|string |
943 | 943 | */ |
944 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
945 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
944 | + function cal_days_in_month($calendar, $month, $year) { |
|
945 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 | |
@@ -961,42 +961,42 @@ discard block |
||
961 | 961 | */ |
962 | 962 | function give_get_plugins() { |
963 | 963 | $plugins = get_plugins(); |
964 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
964 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
965 | 965 | |
966 | - if ( is_multisite() ) { |
|
967 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
968 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
966 | + if (is_multisite()) { |
|
967 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
968 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
969 | 969 | } |
970 | 970 | |
971 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
971 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
972 | 972 | // Is plugin active? |
973 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
974 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
973 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
974 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
975 | 975 | } else { |
976 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
976 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
977 | 977 | } |
978 | 978 | |
979 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
979 | + $dirname = strtolower(dirname($plugin_path)); |
|
980 | 980 | |
981 | 981 | // Is plugin a Give add-on by WordImpress? |
982 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
982 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
983 | 983 | // Plugin is a Give-addon. |
984 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
984 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
985 | 985 | |
986 | 986 | // Get license info from database. |
987 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
988 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
989 | - $license_active = get_option( $db_option ); |
|
987 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
988 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
989 | + $license_active = get_option($db_option); |
|
990 | 990 | |
991 | 991 | // Does a valid license exist? |
992 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
993 | - $plugins[ $plugin_path ]['License'] = true; |
|
992 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
993 | + $plugins[$plugin_path]['License'] = true; |
|
994 | 994 | } else { |
995 | - $plugins[ $plugin_path ]['License'] = false; |
|
995 | + $plugins[$plugin_path]['License'] = false; |
|
996 | 996 | } |
997 | 997 | } else { |
998 | 998 | // Plugin is not a Give add-on. |
999 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
999 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1013,16 +1013,16 @@ discard block |
||
1013 | 1013 | * |
1014 | 1014 | * @return bool |
1015 | 1015 | */ |
1016 | -function give_is_terms_enabled( $form_id ) { |
|
1017 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1016 | +function give_is_terms_enabled($form_id) { |
|
1017 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1018 | 1018 | |
1019 | 1019 | if ( |
1020 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1021 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1020 | + give_is_setting_enabled($form_option, 'global') |
|
1021 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1022 | 1022 | ) { |
1023 | 1023 | return true; |
1024 | 1024 | |
1025 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1025 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1026 | 1026 | return true; |
1027 | 1027 | |
1028 | 1028 | } else { |
@@ -1047,10 +1047,10 @@ discard block |
||
1047 | 1047 | * |
1048 | 1048 | * @return WP_Error|bool |
1049 | 1049 | */ |
1050 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
1050 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
1051 | 1051 | |
1052 | 1052 | // Delete all cache. |
1053 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
1053 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
1054 | 1054 | |
1055 | 1055 | /** |
1056 | 1056 | * Fire the action when donation stats delete. |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | * @param string|array $date_range |
1061 | 1061 | * @param array $args |
1062 | 1062 | */ |
1063 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
1063 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
1064 | 1064 | |
1065 | 1065 | return $status; |
1066 | 1066 | } |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | function give_is_add_new_form_page() { |
1075 | 1075 | $status = false; |
1076 | 1076 | |
1077 | - if ( false !== strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) { |
|
1077 | + if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) { |
|
1078 | 1078 | $status = true; |
1079 | 1079 | } |
1080 | 1080 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return mixed |
1099 | 1099 | */ |
1100 | -function give_get_meta( $id, $meta_key = '', $single = false, $default = false ) { |
|
1100 | +function give_get_meta($id, $meta_key = '', $single = false, $default = false) { |
|
1101 | 1101 | /** |
1102 | 1102 | * Filter the meta value |
1103 | 1103 | * |
@@ -1105,14 +1105,14 @@ discard block |
||
1105 | 1105 | */ |
1106 | 1106 | $meta_value = apply_filters( |
1107 | 1107 | 'give_get_meta', |
1108 | - get_post_meta( $id, $meta_key, $single ), |
|
1108 | + get_post_meta($id, $meta_key, $single), |
|
1109 | 1109 | $id, |
1110 | 1110 | $meta_key, |
1111 | 1111 | $default |
1112 | 1112 | ); |
1113 | 1113 | |
1114 | 1114 | if ( |
1115 | - ( empty( $meta_key ) || empty( $meta_value ) ) |
|
1115 | + (empty($meta_key) || empty($meta_value)) |
|
1116 | 1116 | && $default |
1117 | 1117 | ) { |
1118 | 1118 | $meta_value = $default; |
@@ -1133,15 +1133,15 @@ discard block |
||
1133 | 1133 | * |
1134 | 1134 | * @return mixed |
1135 | 1135 | */ |
1136 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1137 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); |
|
1136 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { |
|
1137 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); |
|
1138 | 1138 | |
1139 | 1139 | /** |
1140 | 1140 | * Filter the meta value update status |
1141 | 1141 | * |
1142 | 1142 | * @since 1.8.8 |
1143 | 1143 | */ |
1144 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); |
|
1144 | + return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1155,15 +1155,15 @@ discard block |
||
1155 | 1155 | * |
1156 | 1156 | * @return mixed |
1157 | 1157 | */ |
1158 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { |
|
1159 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); |
|
1158 | +function give_delete_meta($id, $meta_key, $meta_value = '') { |
|
1159 | + $status = delete_post_meta($id, $meta_key, $meta_value); |
|
1160 | 1160 | |
1161 | 1161 | /** |
1162 | 1162 | * Filter the meta value delete status |
1163 | 1163 | * |
1164 | 1164 | * @since 1.8.8 |
1165 | 1165 | */ |
1166 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); |
|
1166 | + return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1175,23 +1175,23 @@ discard block |
||
1175 | 1175 | * |
1176 | 1176 | * @return bool If the action has been added to the completed actions array |
1177 | 1177 | */ |
1178 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
1178 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
1179 | 1179 | // Bailout. |
1180 | - if ( empty( $upgrade_action ) ) { |
|
1180 | + if (empty($upgrade_action)) { |
|
1181 | 1181 | return false; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | // Fresh install? |
1185 | 1185 | // If fresh install then all upgrades will be consider as completed. |
1186 | - $is_fresh_install = ! get_option( 'give_version' ); |
|
1187 | - if ( $is_fresh_install ) { |
|
1186 | + $is_fresh_install = ! get_option('give_version'); |
|
1187 | + if ($is_fresh_install) { |
|
1188 | 1188 | return true; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | |
1192 | 1192 | $completed_upgrades = give_get_completed_upgrades(); |
1193 | 1193 | |
1194 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
1194 | + return in_array($upgrade_action, $completed_upgrades); |
|
1195 | 1195 | |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1203,8 +1203,8 @@ discard block |
||
1203 | 1203 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
1204 | 1204 | */ |
1205 | 1205 | function give_maybe_resume_upgrade() { |
1206 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
1207 | - if ( empty( $doing_upgrade ) ) { |
|
1206 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
1207 | + if (empty($doing_upgrade)) { |
|
1208 | 1208 | return false; |
1209 | 1209 | } |
1210 | 1210 | |
@@ -1220,9 +1220,9 @@ discard block |
||
1220 | 1220 | * |
1221 | 1221 | * @return bool If the function was successfully added |
1222 | 1222 | */ |
1223 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
1223 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
1224 | 1224 | |
1225 | - if ( empty( $upgrade_action ) ) { |
|
1225 | + if (empty($upgrade_action)) { |
|
1226 | 1226 | return false; |
1227 | 1227 | } |
1228 | 1228 | |
@@ -1230,16 +1230,16 @@ discard block |
||
1230 | 1230 | $completed_upgrades[] = $upgrade_action; |
1231 | 1231 | |
1232 | 1232 | // Remove any blanks, and only show uniques. |
1233 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
1233 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
1234 | 1234 | |
1235 | 1235 | /** |
1236 | 1236 | * Fire the action when any upgrade set to complete. |
1237 | 1237 | * |
1238 | 1238 | * @since 1.8.12 |
1239 | 1239 | */ |
1240 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); |
|
1240 | + do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); |
|
1241 | 1241 | |
1242 | - return update_option( 'give_completed_upgrades', $completed_upgrades, 'no' ); |
|
1242 | + return update_option('give_completed_upgrades', $completed_upgrades, 'no'); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | /** |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | * @return array The array of completed upgrades |
1250 | 1250 | */ |
1251 | 1251 | function give_get_completed_upgrades() { |
1252 | - return (array) get_option( 'give_completed_upgrades' ); |
|
1252 | + return (array) get_option('give_completed_upgrades'); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | /** |
@@ -1264,16 +1264,16 @@ discard block |
||
1264 | 1264 | * |
1265 | 1265 | * @return null|array |
1266 | 1266 | */ |
1267 | -function __give_v20_bc_table_details( $type ) { |
|
1267 | +function __give_v20_bc_table_details($type) { |
|
1268 | 1268 | global $wpdb; |
1269 | 1269 | $table = array(); |
1270 | 1270 | |
1271 | 1271 | // Bailout. |
1272 | - if ( empty( $type ) ) { |
|
1272 | + if (empty($type)) { |
|
1273 | 1273 | return null; |
1274 | 1274 | } |
1275 | 1275 | |
1276 | - switch ( $type ) { |
|
1276 | + switch ($type) { |
|
1277 | 1277 | case 'form': |
1278 | 1278 | $table['name'] = $wpdb->formmeta; |
1279 | 1279 | $table['column']['id'] = 'form_id'; |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | // Backward compatibility. |
1289 | - if ( ! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) ) { |
|
1289 | + if ( ! give_has_upgrade_completed('v20_move_metadata_into_new_table')) { |
|
1290 | 1290 | $table['name'] = $wpdb->postmeta; |
1291 | 1291 | $table['column']['id'] = 'post_id'; |
1292 | 1292 | } |
@@ -1302,12 +1302,12 @@ discard block |
||
1302 | 1302 | * |
1303 | 1303 | * @param WP_Query $query |
1304 | 1304 | */ |
1305 | -function give_remove_pages_from_search( $query ) { |
|
1305 | +function give_remove_pages_from_search($query) { |
|
1306 | 1306 | |
1307 | - if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { |
|
1307 | + if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { |
|
1308 | 1308 | |
1309 | - $transaction_failed = give_get_option( 'failure_page', 0 ); |
|
1310 | - $success_page = give_get_option( 'success_page', 0 ); |
|
1309 | + $transaction_failed = give_get_option('failure_page', 0); |
|
1310 | + $success_page = give_get_option('success_page', 0); |
|
1311 | 1311 | |
1312 | 1312 | $args = apply_filters( |
1313 | 1313 | 'give_remove_pages_from_search', array( |
@@ -1315,11 +1315,11 @@ discard block |
||
1315 | 1315 | $success_page, |
1316 | 1316 | ), $query |
1317 | 1317 | ); |
1318 | - $query->set( 'post__not_in', $args ); |
|
1318 | + $query->set('post__not_in', $args); |
|
1319 | 1319 | } |
1320 | 1320 | } |
1321 | 1321 | |
1322 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); |
|
1322 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); |
|
1323 | 1323 | |
1324 | 1324 | /** |
1325 | 1325 | * Inserts a new key/value before a key in the array. |
@@ -1335,14 +1335,14 @@ discard block |
||
1335 | 1335 | * |
1336 | 1336 | * @see array_insert_before() |
1337 | 1337 | */ |
1338 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { |
|
1339 | - if ( array_key_exists( $key, $array ) ) { |
|
1338 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { |
|
1339 | + if (array_key_exists($key, $array)) { |
|
1340 | 1340 | $new = array(); |
1341 | - foreach ( $array as $k => $value ) { |
|
1342 | - if ( $k === $key ) { |
|
1343 | - $new[ $new_key ] = $new_value; |
|
1341 | + foreach ($array as $k => $value) { |
|
1342 | + if ($k === $key) { |
|
1343 | + $new[$new_key] = $new_value; |
|
1344 | 1344 | } |
1345 | - $new[ $k ] = $value; |
|
1345 | + $new[$k] = $value; |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | return $new; |
@@ -1365,13 +1365,13 @@ discard block |
||
1365 | 1365 | * |
1366 | 1366 | * @see array_insert_before() |
1367 | 1367 | */ |
1368 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { |
|
1369 | - if ( array_key_exists( $key, $array ) ) { |
|
1368 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { |
|
1369 | + if (array_key_exists($key, $array)) { |
|
1370 | 1370 | $new = array(); |
1371 | - foreach ( $array as $k => $value ) { |
|
1372 | - $new[ $k ] = $value; |
|
1373 | - if ( $k === $key ) { |
|
1374 | - $new[ $new_key ] = $new_value; |
|
1371 | + foreach ($array as $k => $value) { |
|
1372 | + $new[$k] = $value; |
|
1373 | + if ($k === $key) { |
|
1374 | + $new[$new_key] = $new_value; |
|
1375 | 1375 | } |
1376 | 1376 | } |
1377 | 1377 | |
@@ -1398,21 +1398,21 @@ discard block |
||
1398 | 1398 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
1399 | 1399 | * `$list` will be preserved in the results. |
1400 | 1400 | */ |
1401 | -function give_list_pluck( $list, $field, $index_key = null ) { |
|
1401 | +function give_list_pluck($list, $field, $index_key = null) { |
|
1402 | 1402 | |
1403 | - if ( ! $index_key ) { |
|
1403 | + if ( ! $index_key) { |
|
1404 | 1404 | /** |
1405 | 1405 | * This is simple. Could at some point wrap array_column() |
1406 | 1406 | * if we knew we had an array of arrays. |
1407 | 1407 | */ |
1408 | - foreach ( $list as $key => $value ) { |
|
1409 | - if ( is_object( $value ) ) { |
|
1410 | - if ( isset( $value->$field ) ) { |
|
1411 | - $list[ $key ] = $value->$field; |
|
1408 | + foreach ($list as $key => $value) { |
|
1409 | + if (is_object($value)) { |
|
1410 | + if (isset($value->$field)) { |
|
1411 | + $list[$key] = $value->$field; |
|
1412 | 1412 | } |
1413 | 1413 | } else { |
1414 | - if ( isset( $value[ $field ] ) ) { |
|
1415 | - $list[ $key ] = $value[ $field ]; |
|
1414 | + if (isset($value[$field])) { |
|
1415 | + $list[$key] = $value[$field]; |
|
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | } |
@@ -1425,18 +1425,18 @@ discard block |
||
1425 | 1425 | * to the end of the stack. This is how array_column() behaves. |
1426 | 1426 | */ |
1427 | 1427 | $newlist = array(); |
1428 | - foreach ( $list as $value ) { |
|
1429 | - if ( is_object( $value ) ) { |
|
1430 | - if ( isset( $value->$index_key ) ) { |
|
1431 | - $newlist[ $value->$index_key ] = $value->$field; |
|
1428 | + foreach ($list as $value) { |
|
1429 | + if (is_object($value)) { |
|
1430 | + if (isset($value->$index_key)) { |
|
1431 | + $newlist[$value->$index_key] = $value->$field; |
|
1432 | 1432 | } else { |
1433 | 1433 | $newlist[] = $value->$field; |
1434 | 1434 | } |
1435 | 1435 | } else { |
1436 | - if ( isset( $value[ $index_key ] ) ) { |
|
1437 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
1436 | + if (isset($value[$index_key])) { |
|
1437 | + $newlist[$value[$index_key]] = $value[$field]; |
|
1438 | 1438 | } else { |
1439 | - $newlist[] = $value[ $field ]; |
|
1439 | + $newlist[] = $value[$field]; |
|
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | } |
@@ -1459,8 +1459,8 @@ discard block |
||
1459 | 1459 | * |
1460 | 1460 | * @return int|false Meta ID on success, false on failure. |
1461 | 1461 | */ |
1462 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { |
|
1463 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
1462 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { |
|
1463 | + return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | /** |
@@ -1478,8 +1478,8 @@ discard block |
||
1478 | 1478 | * |
1479 | 1479 | * @return bool True on success, false on failure. |
1480 | 1480 | */ |
1481 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { |
|
1482 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); |
|
1481 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { |
|
1482 | + return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | /** |
@@ -1494,8 +1494,8 @@ discard block |
||
1494 | 1494 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
1495 | 1495 | * is true. |
1496 | 1496 | */ |
1497 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { |
|
1498 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); |
|
1497 | +function get_donor_meta($donor_id, $key = '', $single = false) { |
|
1498 | + return get_metadata('give_customer', $donor_id, $key, $single); |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | /** |
@@ -1512,8 +1512,8 @@ discard block |
||
1512 | 1512 | * |
1513 | 1513 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
1514 | 1514 | */ |
1515 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1516 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
1515 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { |
|
1516 | + return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | |
@@ -1526,15 +1526,15 @@ discard block |
||
1526 | 1526 | * |
1527 | 1527 | * @return void |
1528 | 1528 | */ |
1529 | -function give_recount_form_income_donation( $form_id = 0 ) { |
|
1529 | +function give_recount_form_income_donation($form_id = 0) { |
|
1530 | 1530 | // Check if form id is not empty. |
1531 | - if ( ! empty( $form_id ) ) { |
|
1531 | + if ( ! empty($form_id)) { |
|
1532 | 1532 | /** |
1533 | 1533 | * Filter to modify payment status. |
1534 | 1534 | * |
1535 | 1535 | * @since 1.8.13 |
1536 | 1536 | */ |
1537 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
1537 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
1538 | 1538 | |
1539 | 1539 | /** |
1540 | 1540 | * Filter to modify args of payment query before recalculating the form total |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | 'give_recount_form_stats_args', array( |
1546 | 1546 | 'give_forms' => $form_id, |
1547 | 1547 | 'status' => $accepted_statuses, |
1548 | - 'posts_per_page' => - 1, |
|
1548 | + 'posts_per_page' => -1, |
|
1549 | 1549 | 'fields' => 'ids', |
1550 | 1550 | ) |
1551 | 1551 | ); |
@@ -1555,28 +1555,28 @@ discard block |
||
1555 | 1555 | 'earnings' => 0, |
1556 | 1556 | ); |
1557 | 1557 | |
1558 | - $payments = new Give_Payments_Query( $args ); |
|
1558 | + $payments = new Give_Payments_Query($args); |
|
1559 | 1559 | $payments = $payments->get_payments(); |
1560 | 1560 | |
1561 | - if ( $payments ) { |
|
1562 | - foreach ( $payments as $payment ) { |
|
1561 | + if ($payments) { |
|
1562 | + foreach ($payments as $payment) { |
|
1563 | 1563 | // Ensure acceptible status only |
1564 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
1564 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
1565 | 1565 | continue; |
1566 | 1566 | } |
1567 | 1567 | |
1568 | 1568 | // Ensure only payments for this form are counted |
1569 | - if ( $payment->form_id != $form_id ) { |
|
1569 | + if ($payment->form_id != $form_id) { |
|
1570 | 1570 | continue; |
1571 | 1571 | } |
1572 | 1572 | |
1573 | - $totals['sales'] ++; |
|
1573 | + $totals['sales']++; |
|
1574 | 1574 | $totals['earnings'] += $payment->total; |
1575 | 1575 | |
1576 | 1576 | } |
1577 | 1577 | } |
1578 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); |
|
1579 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
1578 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); |
|
1579 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
1580 | 1580 | }// End if(). |
1581 | 1581 | } |
1582 | 1582 | |
@@ -1590,18 +1590,18 @@ discard block |
||
1590 | 1590 | * |
1591 | 1591 | * @return string |
1592 | 1592 | */ |
1593 | -function give_get_attribute_str( $attributes ) { |
|
1593 | +function give_get_attribute_str($attributes) { |
|
1594 | 1594 | $attribute_str = ''; |
1595 | 1595 | |
1596 | - if ( empty( $attributes ) ) { |
|
1596 | + if (empty($attributes)) { |
|
1597 | 1597 | return $attribute_str; |
1598 | 1598 | } |
1599 | 1599 | |
1600 | - foreach ( $attributes as $tag => $value ) { |
|
1600 | + foreach ($attributes as $tag => $value) { |
|
1601 | 1601 | $attribute_str .= " {$tag}=\"{$value}\""; |
1602 | 1602 | } |
1603 | 1603 | |
1604 | - return trim( $attribute_str ); |
|
1604 | + return trim($attribute_str); |
|
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | /** |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | function give_get_wp_upload_dir() { |
1615 | 1615 | $wp_upload_dir = wp_upload_dir(); |
1616 | 1616 | |
1617 | - return ( ! empty( $wp_upload_dir['path'] ) ? $wp_upload_dir['path'] : false ); |
|
1617 | + return ( ! empty($wp_upload_dir['path']) ? $wp_upload_dir['path'] : false); |
|
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | /** |
@@ -1626,15 +1626,15 @@ discard block |
||
1626 | 1626 | * |
1627 | 1627 | * @return string|bool $file_contents File content |
1628 | 1628 | */ |
1629 | -function give_get_core_settings_json( $file_name ) { |
|
1629 | +function give_get_core_settings_json($file_name) { |
|
1630 | 1630 | $upload_dir = give_get_wp_upload_dir(); |
1631 | - $file_path = $upload_dir . '/' . $file_name; |
|
1631 | + $file_path = $upload_dir.'/'.$file_name; |
|
1632 | 1632 | |
1633 | - if ( is_wp_error( $file_path ) || empty( $file_path ) ) { |
|
1634 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) ); |
|
1633 | + if (is_wp_error($file_path) || empty($file_path)) { |
|
1634 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give')); |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | - $file_contents = file_get_contents( $file_path ); |
|
1637 | + $file_contents = file_get_contents($file_path); |
|
1638 | 1638 | |
1639 | 1639 | return $file_contents; |
1640 | 1640 | } |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | * @return int $country The two letter country code for the site's base country |
1648 | 1648 | */ |
1649 | 1649 | function give_get_limit_display_donations() { |
1650 | - return give_get_option( 'limit_display_donations', 1 ); |
|
1650 | + return give_get_option('limit_display_donations', 1); |
|
1651 | 1651 | } |
1652 | 1652 | |
1653 | 1653 | /** |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | * @since 1.8.17 |
1657 | 1657 | */ |
1658 | 1658 | function give_donation_history_table_end() { |
1659 | - $email = Give()->session->get( 'give_email' ); |
|
1659 | + $email = Give()->session->get('give_email'); |
|
1660 | 1660 | ?> |
1661 | 1661 | <tfoot> |
1662 | 1662 | <tr> |
@@ -1665,16 +1665,16 @@ discard block |
||
1665 | 1665 | <div class="give-security-column give-security-description-wrap"> |
1666 | 1666 | <?php |
1667 | 1667 | echo sprintf( |
1668 | - __( 'For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give' ), |
|
1668 | + __('For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give'), |
|
1669 | 1669 | |
1670 | 1670 | ); |
1671 | 1671 | ?> |
1672 | 1672 | </div> |
1673 | 1673 | <div class="give-security-column give-security-button-wrap"> |
1674 | 1674 | <a href="#" data-email="<?php echo $email; ?>" id="give-confirm-email-btn" class="give-confirm-email-btn give-btn"> |
1675 | - <?php _e( 'Confirm Email', 'give' ); ?> |
|
1675 | + <?php _e('Confirm Email', 'give'); ?> |
|
1676 | 1676 | </a> |
1677 | - <span><?php _e( 'Email Sent!', 'give' ); ?></span> |
|
1677 | + <span><?php _e('Email Sent!', 'give'); ?></span> |
|
1678 | 1678 | </div> |
1679 | 1679 | </div> |
1680 | 1680 | </td> |
@@ -1694,10 +1694,10 @@ discard block |
||
1694 | 1694 | * |
1695 | 1695 | * @return void |
1696 | 1696 | */ |
1697 | -function give_doing_it_wrong( $function, $message, $version ) { |
|
1698 | - $message .= "\nBacktrace:" . wp_debug_backtrace_summary(); |
|
1697 | +function give_doing_it_wrong($function, $message, $version) { |
|
1698 | + $message .= "\nBacktrace:".wp_debug_backtrace_summary(); |
|
1699 | 1699 | |
1700 | - _doing_it_wrong( $function, $message , $version ); |
|
1700 | + _doing_it_wrong($function, $message, $version); |
|
1701 | 1701 | } |
1702 | 1702 | |
1703 | 1703 | |
@@ -1706,11 +1706,11 @@ discard block |
||
1706 | 1706 | * |
1707 | 1707 | * @since 1.8.18 |
1708 | 1708 | */ |
1709 | -function give_ignore_user_abort(){ |
|
1710 | - ignore_user_abort( true ); |
|
1709 | +function give_ignore_user_abort() { |
|
1710 | + ignore_user_abort(true); |
|
1711 | 1711 | |
1712 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
1713 | - set_time_limit( 0 ); |
|
1712 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
1713 | + set_time_limit(0); |
|
1714 | 1714 | } |
1715 | 1715 | } |
1716 | 1716 | |
@@ -1724,28 +1724,28 @@ discard block |
||
1724 | 1724 | * |
1725 | 1725 | * @return int |
1726 | 1726 | */ |
1727 | -function give_get_total_post_type_count( $post_type = '', $args = array() ){ |
|
1727 | +function give_get_total_post_type_count($post_type = '', $args = array()) { |
|
1728 | 1728 | global $wpdb; |
1729 | 1729 | $where = ''; |
1730 | 1730 | |
1731 | - if( ! $post_type ) { |
|
1731 | + if ( ! $post_type) { |
|
1732 | 1732 | return 0; |
1733 | 1733 | } |
1734 | 1734 | |
1735 | 1735 | // Bulit where query |
1736 | - if( ! empty( $post_type ) ) { |
|
1737 | - $where.=' WHERE'; |
|
1736 | + if ( ! empty($post_type)) { |
|
1737 | + $where .= ' WHERE'; |
|
1738 | 1738 | |
1739 | - if( is_array( $post_type ) ) { |
|
1740 | - $where .= " post_type='" . implode( "' OR post_type='", $post_type ) . "'"; |
|
1741 | - }else{ |
|
1739 | + if (is_array($post_type)) { |
|
1740 | + $where .= " post_type='".implode("' OR post_type='", $post_type)."'"; |
|
1741 | + } else { |
|
1742 | 1742 | $where .= " post_type='{$post_type}'"; |
1743 | 1743 | } |
1744 | 1744 | } |
1745 | 1745 | |
1746 | 1746 | $result = $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts}{$where}"); |
1747 | 1747 | |
1748 | - return absint( $result ); |
|
1748 | + return absint($result); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | /** |
@@ -1757,8 +1757,8 @@ discard block |
||
1757 | 1757 | * |
1758 | 1758 | * @credit WooCommerce |
1759 | 1759 | */ |
1760 | -function give_maybe_define_constant( $name, $value ) { |
|
1761 | - if ( ! defined( $name ) ) { |
|
1762 | - define( $name, $value ); |
|
1760 | +function give_maybe_define_constant($name, $value) { |
|
1761 | + if ( ! defined($name)) { |
|
1762 | + define($name, $value); |
|
1763 | 1763 | } |
1764 | 1764 | } |
1765 | 1765 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @since 1.0 |
64 | 64 | */ |
65 | - public function __construct( $shortcode ) { |
|
65 | + public function __construct($shortcode) { |
|
66 | 66 | |
67 | 67 | $this->shortcode_tag = $shortcode; |
68 | 68 | |
69 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
69 | + add_action('admin_init', array($this, 'init')); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function init() { |
79 | 79 | |
80 | - if ( $this->shortcode_tag ) { |
|
80 | + if ($this->shortcode_tag) { |
|
81 | 81 | |
82 | - $this->self = get_class( $this ); |
|
82 | + $this->self = get_class($this); |
|
83 | 83 | |
84 | 84 | $this->errors = array(); |
85 | 85 | $this->required = array(); |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | $fields = $this->get_fields(); |
89 | 89 | |
90 | 90 | $defaults = array( |
91 | - 'btn_close' => esc_html__( 'Close', 'give' ), |
|
92 | - 'btn_okay' => esc_html__( 'Insert Shortcode', 'give' ), |
|
91 | + 'btn_close' => esc_html__('Close', 'give'), |
|
92 | + 'btn_okay' => esc_html__('Insert Shortcode', 'give'), |
|
93 | 93 | 'errors' => $this->errors, |
94 | 94 | 'fields' => $fields, |
95 | - 'label' => '[' . $this->shortcode_tag . ']', |
|
95 | + 'label' => '['.$this->shortcode_tag.']', |
|
96 | 96 | 'required' => $this->required, |
97 | - 'title' => esc_html__( 'Insert Shortcode', 'give' ), |
|
97 | + 'title' => esc_html__('Insert Shortcode', 'give'), |
|
98 | 98 | ); |
99 | 99 | |
100 | - if ( user_can_richedit() ) { |
|
100 | + if (user_can_richedit()) { |
|
101 | 101 | |
102 | - Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults ); |
|
102 | + Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults); |
|
103 | 103 | |
104 | 104 | } |
105 | 105 | } |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | - protected function generate_fields( $defined_fields ) { |
|
131 | + protected function generate_fields($defined_fields) { |
|
132 | 132 | |
133 | 133 | $fields = array(); |
134 | 134 | |
135 | - if ( is_array( $defined_fields ) ) { |
|
135 | + if (is_array($defined_fields)) { |
|
136 | 136 | |
137 | - foreach ( $defined_fields as $field ) { |
|
137 | + foreach ($defined_fields as $field) { |
|
138 | 138 | |
139 | 139 | $defaults = array( |
140 | 140 | 'label' => false, |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | 'type' => '', |
146 | 146 | ); |
147 | 147 | |
148 | - $field = wp_parse_args( (array) $field, $defaults ); |
|
149 | - $method = 'generate_' . strtolower( $field['type'] ); |
|
148 | + $field = wp_parse_args((array) $field, $defaults); |
|
149 | + $method = 'generate_'.strtolower($field['type']); |
|
150 | 150 | |
151 | - if ( method_exists( $this, $method ) ) { |
|
151 | + if (method_exists($this, $method)) { |
|
152 | 152 | |
153 | - $field = call_user_func( array( $this, $method ), $field ); |
|
153 | + $field = call_user_func(array($this, $method), $field); |
|
154 | 154 | |
155 | - if ( $field ) { |
|
155 | + if ($field) { |
|
156 | 156 | $fields[] = $field; |
157 | 157 | } |
158 | 158 | } |
@@ -172,23 +172,23 @@ discard block |
||
172 | 172 | protected function get_fields() { |
173 | 173 | |
174 | 174 | $defined_fields = $this->define_fields(); |
175 | - $generated_fields = $this->generate_fields( $defined_fields ); |
|
175 | + $generated_fields = $this->generate_fields($defined_fields); |
|
176 | 176 | |
177 | 177 | $errors = array(); |
178 | 178 | |
179 | - if ( ! empty( $this->errors ) ) { |
|
180 | - foreach ( $this->required as $name => $alert ) { |
|
179 | + if ( ! empty($this->errors)) { |
|
180 | + foreach ($this->required as $name => $alert) { |
|
181 | 181 | // Using WordPress function in place of array_column wp_list_pluck as it support older version as well. |
182 | - if ( false === array_search( $name, give_list_pluck( $generated_fields, 'name' ) ) ) { |
|
182 | + if (false === array_search($name, give_list_pluck($generated_fields, 'name'))) { |
|
183 | 183 | |
184 | - $errors[] = $this->errors[ $name ]; |
|
184 | + $errors[] = $this->errors[$name]; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | $this->errors = $errors; |
189 | 189 | } |
190 | 190 | |
191 | - if ( ! empty( $errors ) ) { |
|
191 | + if ( ! empty($errors)) { |
|
192 | 192 | |
193 | 193 | return $errors; |
194 | 194 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - protected function generate_container( $field ) { |
|
208 | + protected function generate_container($field) { |
|
209 | 209 | |
210 | - if ( array_key_exists( 'html', $field ) ) { |
|
210 | + if (array_key_exists('html', $field)) { |
|
211 | 211 | |
212 | 212 | return array( |
213 | 213 | 'type' => $field['type'], |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0 |
229 | 229 | */ |
230 | - protected function generate_listbox( $field ) { |
|
230 | + protected function generate_listbox($field) { |
|
231 | 231 | |
232 | - $listbox = shortcode_atts( array( |
|
232 | + $listbox = shortcode_atts(array( |
|
233 | 233 | 'label' => '', |
234 | 234 | 'minWidth' => '', |
235 | 235 | 'name' => false, |
@@ -237,27 +237,27 @@ discard block |
||
237 | 237 | 'type' => '', |
238 | 238 | 'value' => '', |
239 | 239 | 'classes' => '' |
240 | - ), $field ); |
|
240 | + ), $field); |
|
241 | 241 | |
242 | - if ( $this->validate( $field ) ) { |
|
242 | + if ($this->validate($field)) { |
|
243 | 243 | |
244 | 244 | $new_listbox = array(); |
245 | 245 | |
246 | - foreach ( $listbox as $key => $value ) { |
|
246 | + foreach ($listbox as $key => $value) { |
|
247 | 247 | |
248 | - if ( $key == 'value' && empty( $value ) ) { |
|
249 | - $new_listbox[ $key ] = $listbox['name']; |
|
250 | - } else if ( $value ) { |
|
251 | - $new_listbox[ $key ] = $value; |
|
248 | + if ($key == 'value' && empty($value)) { |
|
249 | + $new_listbox[$key] = $listbox['name']; |
|
250 | + } else if ($value) { |
|
251 | + $new_listbox[$key] = $value; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | // do not reindex array! |
256 | 256 | $field['options'] = array( |
257 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
257 | + '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')), |
|
258 | 258 | ) + $field['options']; |
259 | 259 | |
260 | - foreach ( $field['options'] as $value => $text ) { |
|
260 | + foreach ($field['options'] as $value => $text) { |
|
261 | 261 | $new_listbox['values'][] = array( |
262 | 262 | 'text' => $text, |
263 | 263 | 'value' => $value, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @since 1.0 |
281 | 281 | */ |
282 | - protected function generate_post( $field ) { |
|
282 | + protected function generate_post($field) { |
|
283 | 283 | |
284 | 284 | $args = array( |
285 | 285 | 'post_type' => 'post', |
@@ -289,26 +289,25 @@ discard block |
||
289 | 289 | 'posts_per_page' => 500, |
290 | 290 | ); |
291 | 291 | |
292 | - $args = wp_parse_args( (array) $field['query_args'], $args ); |
|
293 | - $posts = get_posts( $args ); |
|
292 | + $args = wp_parse_args((array) $field['query_args'], $args); |
|
293 | + $posts = get_posts($args); |
|
294 | 294 | $options = array(); |
295 | 295 | |
296 | - if ( ! empty( $posts ) ) { |
|
296 | + if ( ! empty($posts)) { |
|
297 | 297 | /* @var WP_Post $post */ |
298 | - foreach ( $posts as $post ) { |
|
299 | - $options[ absint( $post->ID ) ] = empty( $post->post_title ) ? |
|
300 | - sprintf( __( 'Untitled (#%s)', 'give' ), $post->ID ) : |
|
301 | - apply_filters( 'the_title', $post->post_title ); |
|
298 | + foreach ($posts as $post) { |
|
299 | + $options[absint($post->ID)] = empty($post->post_title) ? |
|
300 | + sprintf(__('Untitled (#%s)', 'give'), $post->ID) : apply_filters('the_title', $post->post_title); |
|
302 | 301 | } |
303 | 302 | |
304 | 303 | $field['type'] = 'listbox'; |
305 | 304 | $field['options'] = $options; |
306 | 305 | |
307 | - return $this->generate_listbox( $field ); |
|
306 | + return $this->generate_listbox($field); |
|
308 | 307 | } |
309 | 308 | |
310 | 309 | // perform validation here before returning false |
311 | - $this->validate( $field ); |
|
310 | + $this->validate($field); |
|
312 | 311 | |
313 | 312 | return false; |
314 | 313 | } |
@@ -322,9 +321,9 @@ discard block |
||
322 | 321 | * |
323 | 322 | * @since 1.0 |
324 | 323 | */ |
325 | - protected function generate_textbox( $field ) { |
|
324 | + protected function generate_textbox($field) { |
|
326 | 325 | |
327 | - $textbox = shortcode_atts( array( |
|
326 | + $textbox = shortcode_atts(array( |
|
328 | 327 | 'label' => '', |
329 | 328 | 'maxLength' => '', |
330 | 329 | 'minHeight' => '', |
@@ -335,10 +334,10 @@ discard block |
||
335 | 334 | 'type' => '', |
336 | 335 | 'value' => '', |
337 | 336 | 'classes' => '' |
338 | - ), $field ); |
|
337 | + ), $field); |
|
339 | 338 | |
340 | - if ( $this->validate( $field ) ) { |
|
341 | - return array_filter( $textbox, array( $this, 'return_textbox_value' ) ); |
|
339 | + if ($this->validate($field)) { |
|
340 | + return array_filter($textbox, array($this, 'return_textbox_value')); |
|
342 | 341 | } |
343 | 342 | |
344 | 343 | return false; |
@@ -351,7 +350,7 @@ discard block |
||
351 | 350 | * |
352 | 351 | * @return bool |
353 | 352 | */ |
354 | - function return_textbox_value( $value ) { |
|
353 | + function return_textbox_value($value) { |
|
355 | 354 | return $value !== ''; |
356 | 355 | } |
357 | 356 | |
@@ -367,9 +366,9 @@ discard block |
||
367 | 366 | * |
368 | 367 | * @since 1.0 |
369 | 368 | */ |
370 | - protected function validate( $field ) { |
|
369 | + protected function validate($field) { |
|
371 | 370 | |
372 | - extract( shortcode_atts( |
|
371 | + extract(shortcode_atts( |
|
373 | 372 | array( |
374 | 373 | 'name' => false, |
375 | 374 | 'required' => false, |
@@ -377,36 +376,36 @@ discard block |
||
377 | 376 | ), $field ) |
378 | 377 | ); |
379 | 378 | |
380 | - if ( $name ) { |
|
379 | + if ($name) { |
|
381 | 380 | |
382 | - if ( isset( $required['error'] ) ) { |
|
381 | + if (isset($required['error'])) { |
|
383 | 382 | |
384 | 383 | $error = array( |
385 | 384 | 'type' => 'container', |
386 | 385 | 'html' => $required['error'], |
387 | 386 | ); |
388 | 387 | |
389 | - $this->errors[ $name ] = $this->generate_container( $error ); |
|
388 | + $this->errors[$name] = $this->generate_container($error); |
|
390 | 389 | } |
391 | 390 | |
392 | - if ( ! ! $required || is_array( $required ) ) { |
|
391 | + if ( ! ! $required || is_array($required)) { |
|
393 | 392 | |
394 | - $alert = esc_html__( 'Some of the shortcode options are required.', 'give' ); |
|
393 | + $alert = esc_html__('Some of the shortcode options are required.', 'give'); |
|
395 | 394 | |
396 | - if ( isset( $required['alert'] ) ) { |
|
395 | + if (isset($required['alert'])) { |
|
397 | 396 | |
398 | 397 | $alert = $required['alert']; |
399 | 398 | |
400 | - } else if ( ! empty( $label ) ) { |
|
399 | + } else if ( ! empty($label)) { |
|
401 | 400 | |
402 | 401 | $alert = sprintf( |
403 | 402 | /* translators: %s: option label */ |
404 | - esc_html__( 'The "%s" option is required.', 'give' ), |
|
405 | - str_replace( ':', '', $label ) |
|
403 | + esc_html__('The "%s" option is required.', 'give'), |
|
404 | + str_replace(':', '', $label) |
|
406 | 405 | ); |
407 | 406 | } |
408 | 407 | |
409 | - $this->required[ $name ] = $alert; |
|
408 | + $this->required[$name] = $alert; |
|
410 | 409 | } |
411 | 410 | |
412 | 411 | return true; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
69 | + case version_compare($give_version, '1.8.17', '<') : |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | |
73 | - case version_compare( $give_version, '1.8.18', '<' ) : |
|
73 | + case version_compare($give_version, '1.8.18', '<') : |
|
74 | 74 | give_v1818_upgrades(); |
75 | 75 | $did_upgrade = true; |
76 | 76 | |
77 | - case version_compare( $give_version, '2.0', '<' ) : |
|
77 | + case version_compare($give_version, '2.0', '<') : |
|
78 | 78 | give_v20_upgrades(); |
79 | 79 | $did_upgrade = true; |
80 | 80 | |
81 | - case version_compare( $give_version, '2.0.1', '<' ) : |
|
81 | + case version_compare($give_version, '2.0.1', '<') : |
|
82 | 82 | // Do nothing on fresh install. |
83 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
83 | + if ( ! doing_action('give_upgrades')) { |
|
84 | 84 | give_v201_create_tables(); |
85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
86 | 86 | Give_Updates::$background_updater->dispatch(); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $did_upgrade = true; |
90 | 90 | |
91 | - case version_compare( $give_version, '2.0.2', '<' ) : |
|
91 | + case version_compare($give_version, '2.0.2', '<') : |
|
92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
94 | 94 | $v201_updates = array( |
@@ -98,35 +98,35 @@ discard block |
||
98 | 98 | 'v201_logs_upgrades', |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $v201_updates as $v201_update ) { |
|
102 | - if ( in_array( $v201_update, $completed_upgrades ) ) { |
|
103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades ) ] ); |
|
101 | + foreach ($v201_updates as $v201_update) { |
|
102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades); |
|
108 | 108 | |
109 | 109 | // Do nothing on fresh install. |
110 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
110 | + if ( ! doing_action('give_upgrades')) { |
|
111 | 111 | give_v201_create_tables(); |
112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
113 | 113 | Give_Updates::$background_updater->dispatch(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $did_upgrade = true; |
117 | 117 | |
118 | - case version_compare( $give_version, '2.0.3', '<' ) : |
|
118 | + case version_compare($give_version, '2.0.3', '<') : |
|
119 | 119 | give_v203_upgrades(); |
120 | 120 | $did_upgrade = true; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $did_upgrade ) { |
|
124 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
123 | + if ($did_upgrade) { |
|
124 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
129 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
128 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
129 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Display Upgrade Notices. |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | -function give_show_upgrade_notices( $give_updates ) { |
|
143 | +function give_show_upgrade_notices($give_updates) { |
|
144 | 144 | // v1.3.2 Upgrades |
145 | 145 | $give_updates->register( |
146 | 146 | array( |
@@ -206,32 +206,32 @@ discard block |
||
206 | 206 | ); |
207 | 207 | |
208 | 208 | // v1.8.17 Upgrades for donations. |
209 | - $give_updates->register( array( |
|
209 | + $give_updates->register(array( |
|
210 | 210 | 'id' => 'v1817_update_donation_iranian_currency_code', |
211 | 211 | 'version' => '1.8.17', |
212 | 212 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
213 | - ) ); |
|
213 | + )); |
|
214 | 214 | |
215 | 215 | // v1.8.17 Upgrades for cleanup of user roles. |
216 | - $give_updates->register( array( |
|
216 | + $give_updates->register(array( |
|
217 | 217 | 'id' => 'v1817_cleanup_user_roles', |
218 | 218 | 'version' => '1.8.17', |
219 | 219 | 'callback' => 'give_v1817_cleanup_user_roles', |
220 | - ) ); |
|
220 | + )); |
|
221 | 221 | |
222 | 222 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
223 | - $give_updates->register( array( |
|
223 | + $give_updates->register(array( |
|
224 | 224 | 'id' => 'v1818_assign_custom_amount_set_donation', |
225 | 225 | 'version' => '1.8.18', |
226 | 226 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
227 | - ) ); |
|
227 | + )); |
|
228 | 228 | |
229 | 229 | // v1.8.18 Cleanup the Give Worker Role Caps. |
230 | - $give_updates->register( array( |
|
230 | + $give_updates->register(array( |
|
231 | 231 | 'id' => 'v1818_give_worker_role_cleanup', |
232 | 232 | 'version' => '1.8.18', |
233 | 233 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
234 | - ) ); |
|
234 | + )); |
|
235 | 235 | |
236 | 236 | // v2.0.0 Upgrades |
237 | 237 | $give_updates->register( |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'id' => 'v20_move_metadata_into_new_table', |
286 | 286 | 'version' => '2.0.0', |
287 | 287 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
288 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
288 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
289 | 289 | ) |
290 | 290 | ); |
291 | 291 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | 'id' => 'v201_move_metadata_into_new_table', |
332 | 332 | 'version' => '2.0.1', |
333 | 333 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
334 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
334 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | ); |
347 | 347 | } |
348 | 348 | |
349 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
349 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Triggers all upgrade functions |
@@ -358,29 +358,29 @@ discard block |
||
358 | 358 | */ |
359 | 359 | function give_trigger_upgrades() { |
360 | 360 | |
361 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
362 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
361 | + if ( ! current_user_can('manage_give_settings')) { |
|
362 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
363 | 363 | 'response' => 403, |
364 | - ) ); |
|
364 | + )); |
|
365 | 365 | } |
366 | 366 | |
367 | - $give_version = get_option( 'give_version' ); |
|
367 | + $give_version = get_option('give_version'); |
|
368 | 368 | |
369 | - if ( ! $give_version ) { |
|
369 | + if ( ! $give_version) { |
|
370 | 370 | // 1.0 is the first version to use this option so we must add it. |
371 | 371 | $give_version = '1.0'; |
372 | - add_option( 'give_version', $give_version ); |
|
372 | + add_option('give_version', $give_version); |
|
373 | 373 | } |
374 | 374 | |
375 | - update_option( 'give_version', GIVE_VERSION ); |
|
376 | - delete_option( 'give_doing_upgrade' ); |
|
375 | + update_option('give_version', GIVE_VERSION); |
|
376 | + delete_option('give_doing_upgrade'); |
|
377 | 377 | |
378 | - if ( DOING_AJAX ) { |
|
379 | - die( 'complete' ); |
|
378 | + if (DOING_AJAX) { |
|
379 | + die('complete'); |
|
380 | 380 | } // End if(). |
381 | 381 | } |
382 | 382 | |
383 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
383 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
384 | 384 | |
385 | 385 | |
386 | 386 | /** |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | |
399 | 399 | // UPDATE DB METAKEYS. |
400 | 400 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
401 | - $query = $wpdb->query( $sql ); |
|
401 | + $query = $wpdb->query($sql); |
|
402 | 402 | |
403 | 403 | $give_updates->percentage = 100; |
404 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
404 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -425,24 +425,24 @@ discard block |
||
425 | 425 | $where .= "AND ( p.post_status = 'abandoned' )"; |
426 | 426 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
427 | 427 | |
428 | - $sql = $select . $join . $where; |
|
429 | - $found_payments = $wpdb->get_col( $sql ); |
|
428 | + $sql = $select.$join.$where; |
|
429 | + $found_payments = $wpdb->get_col($sql); |
|
430 | 430 | |
431 | - foreach ( $found_payments as $payment ) { |
|
431 | + foreach ($found_payments as $payment) { |
|
432 | 432 | |
433 | 433 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
434 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
434 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
435 | 435 | |
436 | 436 | // 1450124863 = 12/10/2015 20:42:25. |
437 | - if ( $modified_time >= 1450124863 ) { |
|
437 | + if ($modified_time >= 1450124863) { |
|
438 | 438 | |
439 | - give_update_payment_status( $payment, 'pending' ); |
|
439 | + give_update_payment_status($payment, 'pending'); |
|
440 | 440 | |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | $give_updates->percentage = 100; |
445 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
445 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -455,17 +455,17 @@ discard block |
||
455 | 455 | */ |
456 | 456 | function give_v152_cleanup_users() { |
457 | 457 | |
458 | - $give_version = get_option( 'give_version' ); |
|
458 | + $give_version = get_option('give_version'); |
|
459 | 459 | |
460 | - if ( ! $give_version ) { |
|
460 | + if ( ! $give_version) { |
|
461 | 461 | // 1.0 is the first version to use this option so we must add it. |
462 | 462 | $give_version = '1.0'; |
463 | 463 | } |
464 | 464 | |
465 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
465 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
466 | 466 | |
467 | 467 | // v1.5.2 Upgrades |
468 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
468 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
469 | 469 | |
470 | 470 | // Delete all caps with "ss". |
471 | 471 | // Also delete all unused "campaign" roles. |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | ); |
513 | 513 | |
514 | 514 | global $wp_roles; |
515 | - foreach ( $delete_caps as $cap ) { |
|
516 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
517 | - $wp_roles->remove_cap( $role, $cap ); |
|
515 | + foreach ($delete_caps as $cap) { |
|
516 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
517 | + $wp_roles->remove_cap($role, $cap); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -524,15 +524,15 @@ discard block |
||
524 | 524 | $roles->add_caps(); |
525 | 525 | |
526 | 526 | // The Update Ran. |
527 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
528 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
529 | - delete_option( 'give_doing_upgrade' ); |
|
527 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
528 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
529 | + delete_option('give_doing_upgrade'); |
|
530 | 530 | |
531 | 531 | }// End if(). |
532 | 532 | |
533 | 533 | } |
534 | 534 | |
535 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
535 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
536 | 536 | |
537 | 537 | /** |
538 | 538 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -575,53 +575,53 @@ discard block |
||
575 | 575 | |
576 | 576 | // Get addons license key. |
577 | 577 | $addons = array(); |
578 | - foreach ( $give_options as $key => $value ) { |
|
579 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
580 | - $addons[ $key ] = $value; |
|
578 | + foreach ($give_options as $key => $value) { |
|
579 | + if (false !== strpos($key, '_license_key')) { |
|
580 | + $addons[$key] = $value; |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Bailout: We do not have any addon license data to upgrade. |
585 | - if ( empty( $addons ) ) { |
|
585 | + if (empty($addons)) { |
|
586 | 586 | return false; |
587 | 587 | } |
588 | 588 | |
589 | - foreach ( $addons as $key => $addon_license ) { |
|
589 | + foreach ($addons as $key => $addon_license) { |
|
590 | 590 | |
591 | 591 | // Get addon shortname. |
592 | - $shortname = str_replace( '_license_key', '', $key ); |
|
592 | + $shortname = str_replace('_license_key', '', $key); |
|
593 | 593 | |
594 | 594 | // Addon license option name. |
595 | - $addon_license_option_name = $shortname . '_license_active'; |
|
595 | + $addon_license_option_name = $shortname.'_license_active'; |
|
596 | 596 | |
597 | 597 | // bailout if license is empty. |
598 | - if ( empty( $addon_license ) ) { |
|
599 | - delete_option( $addon_license_option_name ); |
|
598 | + if (empty($addon_license)) { |
|
599 | + delete_option($addon_license_option_name); |
|
600 | 600 | continue; |
601 | 601 | } |
602 | 602 | |
603 | 603 | // Get addon name. |
604 | 604 | $addon_name = array(); |
605 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
606 | - foreach ( $addon_name_parts as $name_part ) { |
|
605 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
606 | + foreach ($addon_name_parts as $name_part) { |
|
607 | 607 | |
608 | 608 | // Fix addon name |
609 | - switch ( $name_part ) { |
|
609 | + switch ($name_part) { |
|
610 | 610 | case 'authorizenet' : |
611 | 611 | $name_part = 'authorize.net'; |
612 | 612 | break; |
613 | 613 | } |
614 | 614 | |
615 | - $addon_name[] = ucfirst( $name_part ); |
|
615 | + $addon_name[] = ucfirst($name_part); |
|
616 | 616 | } |
617 | 617 | |
618 | - $addon_name = implode( ' ', $addon_name ); |
|
618 | + $addon_name = implode(' ', $addon_name); |
|
619 | 619 | |
620 | 620 | // Data to send to the API. |
621 | 621 | $api_params = array( |
622 | 622 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
623 | 623 | 'license' => $addon_license, |
624 | - 'item_name' => urlencode( $addon_name ), |
|
624 | + 'item_name' => urlencode($addon_name), |
|
625 | 625 | 'url' => home_url(), |
626 | 626 | ); |
627 | 627 | |
@@ -636,17 +636,17 @@ discard block |
||
636 | 636 | ); |
637 | 637 | |
638 | 638 | // Make sure there are no errors. |
639 | - if ( is_wp_error( $response ) ) { |
|
640 | - delete_option( $addon_license_option_name ); |
|
639 | + if (is_wp_error($response)) { |
|
640 | + delete_option($addon_license_option_name); |
|
641 | 641 | continue; |
642 | 642 | } |
643 | 643 | |
644 | 644 | // Tell WordPress to look for updates. |
645 | - set_site_transient( 'update_plugins', null ); |
|
645 | + set_site_transient('update_plugins', null); |
|
646 | 646 | |
647 | 647 | // Decode license data. |
648 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
649 | - update_option( $addon_license_option_name, $license_data ); |
|
648 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
649 | + update_option($addon_license_option_name, $license_data); |
|
650 | 650 | }// End foreach(). |
651 | 651 | } |
652 | 652 | |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | ); |
677 | 677 | |
678 | 678 | global $wp_roles; |
679 | - foreach ( $delete_caps as $cap ) { |
|
680 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
681 | - $wp_roles->remove_cap( $role, $cap ); |
|
679 | + foreach ($delete_caps as $cap) { |
|
680 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
681 | + $wp_roles->remove_cap($role, $cap); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | function give_v18_upgrades_core_setting() { |
713 | 713 | // Core settings which changes from checkbox to radio. |
714 | 714 | $core_setting_names = array_merge( |
715 | - array_keys( give_v18_renamed_core_settings() ), |
|
715 | + array_keys(give_v18_renamed_core_settings()), |
|
716 | 716 | array( |
717 | 717 | 'uninstall_on_delete', |
718 | 718 | 'scripts_footer', |
@@ -724,48 +724,48 @@ discard block |
||
724 | 724 | ); |
725 | 725 | |
726 | 726 | // Bailout: If not any setting define. |
727 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
727 | + if ($give_settings = get_option('give_settings')) { |
|
728 | 728 | |
729 | 729 | $setting_changed = false; |
730 | 730 | |
731 | 731 | // Loop: check each setting field. |
732 | - foreach ( $core_setting_names as $setting_name ) { |
|
732 | + foreach ($core_setting_names as $setting_name) { |
|
733 | 733 | // New setting name. |
734 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
734 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
735 | 735 | |
736 | 736 | // Continue: If setting already set. |
737 | 737 | if ( |
738 | - array_key_exists( $new_setting_name, $give_settings ) |
|
739 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
738 | + array_key_exists($new_setting_name, $give_settings) |
|
739 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
740 | 740 | ) { |
741 | 741 | continue; |
742 | 742 | } |
743 | 743 | |
744 | 744 | // Set checkbox value to radio value. |
745 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
745 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
746 | 746 | |
747 | 747 | // @see https://github.com/WordImpress/Give/issues/1063. |
748 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
748 | + if (false !== strpos($setting_name, 'disable_')) { |
|
749 | 749 | |
750 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
751 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
750 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
751 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
752 | 752 | |
753 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
753 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | // Tell bot to update core setting to db. |
757 | - if ( ! $setting_changed ) { |
|
757 | + if ( ! $setting_changed) { |
|
758 | 758 | $setting_changed = true; |
759 | 759 | } |
760 | 760 | } |
761 | 761 | |
762 | 762 | // Update setting only if they changed. |
763 | - if ( $setting_changed ) { |
|
764 | - update_option( 'give_settings', $give_settings ); |
|
763 | + if ($setting_changed) { |
|
764 | + update_option('give_settings', $give_settings); |
|
765 | 765 | } |
766 | 766 | }// End if(). |
767 | 767 | |
768 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
768 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | $give_updates = Give_Updates::get_instance(); |
780 | 780 | |
781 | 781 | // form query |
782 | - $forms = new WP_Query( array( |
|
782 | + $forms = new WP_Query(array( |
|
783 | 783 | 'paged' => $give_updates->step, |
784 | 784 | 'status' => 'any', |
785 | 785 | 'order' => 'ASC', |
@@ -788,41 +788,41 @@ discard block |
||
788 | 788 | ) |
789 | 789 | ); |
790 | 790 | |
791 | - if ( $forms->have_posts() ) { |
|
792 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
791 | + if ($forms->have_posts()) { |
|
792 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
793 | 793 | |
794 | - while ( $forms->have_posts() ) { |
|
794 | + while ($forms->have_posts()) { |
|
795 | 795 | $forms->the_post(); |
796 | 796 | |
797 | 797 | // Form content. |
798 | 798 | // Note in version 1.8 display content setting split into display content and content placement setting. |
799 | 799 | // You can delete _give_content_option in future. |
800 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
801 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
802 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
803 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
800 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
801 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
802 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
803 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
804 | 804 | |
805 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
806 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
805 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
806 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | // "Disable" Guest Donation. Checkbox. |
810 | 810 | // See: https://github.com/WordImpress/Give/issues/1470. |
811 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
812 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
813 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
811 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
812 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
813 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
814 | 814 | |
815 | 815 | // Offline Donations. |
816 | 816 | // See: https://github.com/WordImpress/Give/issues/1579. |
817 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
818 | - if ( 'no' === $offline_donation ) { |
|
817 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
818 | + if ('no' === $offline_donation) { |
|
819 | 819 | $offline_donation_newval = 'global'; |
820 | - } elseif ( 'yes' === $offline_donation ) { |
|
820 | + } elseif ('yes' === $offline_donation) { |
|
821 | 821 | $offline_donation_newval = 'enabled'; |
822 | 822 | } else { |
823 | 823 | $offline_donation_newval = 'disabled'; |
824 | 824 | } |
825 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
825 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
826 | 826 | |
827 | 827 | // Convert yes/no setting field to enabled/disabled. |
828 | 828 | $form_radio_settings = array( |
@@ -842,15 +842,15 @@ discard block |
||
842 | 842 | '_give_offline_donation_enable_billing_fields_single', |
843 | 843 | ); |
844 | 844 | |
845 | - foreach ( $form_radio_settings as $meta_key ) { |
|
845 | + foreach ($form_radio_settings as $meta_key) { |
|
846 | 846 | // Get value. |
847 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
847 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
848 | 848 | |
849 | 849 | // Convert meta value only if it is in yes/no/none. |
850 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
850 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
851 | 851 | |
852 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
853 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
852 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
853 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | }// End while(). |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | |
860 | 860 | } else { |
861 | 861 | // No more forms found, finish up. |
862 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
862 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | '%_transient_give_stats_%', |
927 | 927 | 'give_cache%', |
928 | 928 | '%_transient_give_add_ons_feed%', |
929 | - '%_transient__give_ajax_works' . |
|
929 | + '%_transient__give_ajax_works'. |
|
930 | 930 | '%_transient_give_total_api_keys%', |
931 | 931 | '%_transient_give_i18n_give_promo_hide%', |
932 | 932 | '%_transient_give_contributors%', |
@@ -953,24 +953,24 @@ discard block |
||
953 | 953 | ARRAY_A |
954 | 954 | ); |
955 | 955 | |
956 | - if ( ! empty( $user_apikey_options ) ) { |
|
957 | - foreach ( $user_apikey_options as $user ) { |
|
958 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
959 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
960 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
956 | + if ( ! empty($user_apikey_options)) { |
|
957 | + foreach ($user_apikey_options as $user) { |
|
958 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
959 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
960 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
964 | - if ( ! empty( $cached_options ) ) { |
|
965 | - foreach ( $cached_options as $option ) { |
|
966 | - switch ( true ) { |
|
967 | - case ( false !== strpos( $option, 'transient' ) ): |
|
968 | - $option = str_replace( '_transient_', '', $option ); |
|
969 | - delete_transient( $option ); |
|
964 | + if ( ! empty($cached_options)) { |
|
965 | + foreach ($cached_options as $option) { |
|
966 | + switch (true) { |
|
967 | + case (false !== strpos($option, 'transient')): |
|
968 | + $option = str_replace('_transient_', '', $option); |
|
969 | + delete_transient($option); |
|
970 | 970 | break; |
971 | 971 | |
972 | 972 | default: |
973 | - delete_option( $option ); |
|
973 | + delete_option($option); |
|
974 | 974 | } |
975 | 975 | } |
976 | 976 | } |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | global $wp_roles; |
989 | 989 | |
990 | 990 | // Get the role object. |
991 | - $give_worker = get_role( 'give_worker' ); |
|
991 | + $give_worker = get_role('give_worker'); |
|
992 | 992 | |
993 | 993 | // A list of capabilities to add for give workers. |
994 | 994 | $caps_to_add = array( |
@@ -996,9 +996,9 @@ discard block |
||
996 | 996 | 'edit_pages', |
997 | 997 | ); |
998 | 998 | |
999 | - foreach ( $caps_to_add as $cap ) { |
|
999 | + foreach ($caps_to_add as $cap) { |
|
1000 | 1000 | // Add the capability. |
1001 | - $give_worker->add_cap( $cap ); |
|
1001 | + $give_worker->add_cap($cap); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | $give_updates = Give_Updates::get_instance(); |
1016 | 1016 | |
1017 | 1017 | // form query. |
1018 | - $donation_forms = new WP_Query( array( |
|
1018 | + $donation_forms = new WP_Query(array( |
|
1019 | 1019 | 'paged' => $give_updates->step, |
1020 | 1020 | 'status' => 'any', |
1021 | 1021 | 'order' => 'ASC', |
@@ -1024,10 +1024,10 @@ discard block |
||
1024 | 1024 | ) |
1025 | 1025 | ); |
1026 | 1026 | |
1027 | - if ( $donation_forms->have_posts() ) { |
|
1028 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1027 | + if ($donation_forms->have_posts()) { |
|
1028 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1029 | 1029 | |
1030 | - while ( $donation_forms->have_posts() ) { |
|
1030 | + while ($donation_forms->have_posts()) { |
|
1031 | 1031 | $donation_forms->the_post(); |
1032 | 1032 | $form_id = get_the_ID(); |
1033 | 1033 | |
@@ -1035,41 +1035,41 @@ discard block |
||
1035 | 1035 | update_post_meta( |
1036 | 1036 | $form_id, |
1037 | 1037 | '_give_set_price', |
1038 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1038 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1039 | 1039 | ); |
1040 | 1040 | |
1041 | 1041 | // Remove formatting from _give_custom_amount_minimum. |
1042 | 1042 | update_post_meta( |
1043 | 1043 | $form_id, |
1044 | 1044 | '_give_custom_amount_minimum', |
1045 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1045 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1046 | 1046 | ); |
1047 | 1047 | |
1048 | 1048 | // Bailout. |
1049 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1049 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1050 | 1050 | continue; |
1051 | 1051 | } |
1052 | 1052 | |
1053 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1053 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1054 | 1054 | |
1055 | - if ( ! empty( $donation_levels ) ) { |
|
1055 | + if ( ! empty($donation_levels)) { |
|
1056 | 1056 | |
1057 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1058 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1059 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1057 | + foreach ($donation_levels as $index => $donation_level) { |
|
1058 | + if (isset($donation_level['_give_amount'])) { |
|
1059 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | |
1063 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1063 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1064 | 1064 | |
1065 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1065 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1066 | 1066 | |
1067 | - $min_amount = min( $donation_levels_amounts ); |
|
1068 | - $max_amount = max( $donation_levels_amounts ); |
|
1067 | + $min_amount = min($donation_levels_amounts); |
|
1068 | + $max_amount = max($donation_levels_amounts); |
|
1069 | 1069 | |
1070 | 1070 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1071 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1072 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1071 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1072 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | } |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | wp_reset_postdata(); |
1079 | 1079 | } else { |
1080 | 1080 | // The Update Ran. |
1081 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1081 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | */ |
1129 | 1129 | function give_v20_upgrades() { |
1130 | 1130 | // Update cache setting. |
1131 | - give_update_option( 'cache', 'enabled' ); |
|
1131 | + give_update_option('cache', 'enabled'); |
|
1132 | 1132 | |
1133 | 1133 | // Upgrade email settings. |
1134 | 1134 | give_v20_upgrades_email_setting(); |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | $all_setting = give_get_settings(); |
1148 | 1148 | |
1149 | 1149 | // Bailout on fresh install. |
1150 | - if ( empty( $all_setting ) ) { |
|
1150 | + if (empty($all_setting)) { |
|
1151 | 1151 | return; |
1152 | 1152 | } |
1153 | 1153 | |
@@ -1166,19 +1166,19 @@ discard block |
||
1166 | 1166 | 'admin_notices' => 'new-donation_notification', |
1167 | 1167 | ); |
1168 | 1168 | |
1169 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1169 | + foreach ($settings as $old_setting => $new_setting) { |
|
1170 | 1170 | // Do not update already modified |
1171 | - if ( ! is_array( $new_setting ) ) { |
|
1172 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1171 | + if ( ! is_array($new_setting)) { |
|
1172 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1173 | 1173 | continue; |
1174 | 1174 | } |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - switch ( $old_setting ) { |
|
1177 | + switch ($old_setting) { |
|
1178 | 1178 | case 'admin_notices': |
1179 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1179 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1180 | 1180 | |
1181 | - give_update_option( $new_setting, $notification_status ); |
|
1181 | + give_update_option($new_setting, $notification_status); |
|
1182 | 1182 | |
1183 | 1183 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1184 | 1184 | // give_delete_option( $old_setting ); |
@@ -1189,19 +1189,19 @@ discard block |
||
1189 | 1189 | case 'admin_notice_emails': |
1190 | 1190 | $recipients = give_get_admin_notice_emails(); |
1191 | 1191 | |
1192 | - foreach ( $new_setting as $setting ) { |
|
1192 | + foreach ($new_setting as $setting) { |
|
1193 | 1193 | // bailout if setting already exist. |
1194 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1194 | + if (array_key_exists($setting, $all_setting)) { |
|
1195 | 1195 | continue; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | - give_update_option( $setting, $recipients ); |
|
1198 | + give_update_option($setting, $recipients); |
|
1199 | 1199 | } |
1200 | 1200 | break; |
1201 | 1201 | |
1202 | 1202 | default: |
1203 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1204 | - give_delete_option( $old_setting ); |
|
1203 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1204 | + give_delete_option($old_setting); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1218,22 +1218,22 @@ discard block |
||
1218 | 1218 | $give_settings = give_get_settings(); |
1219 | 1219 | $give_setting_updated = false; |
1220 | 1220 | |
1221 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1221 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1222 | 1222 | $give_settings['number_decimals'] = 0; |
1223 | 1223 | $give_settings['decimal_separator'] = ''; |
1224 | 1224 | $give_setting_updated = true; |
1225 | 1225 | |
1226 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1226 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1227 | 1227 | $give_settings['number_decimals'] = 0; |
1228 | 1228 | $give_setting_updated = true; |
1229 | 1229 | |
1230 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1230 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1231 | 1231 | $give_settings['number_decimals'] = 5; |
1232 | 1232 | $give_setting_updated = true; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - if ( $give_setting_updated ) { |
|
1236 | - update_option( 'give_settings', $give_settings ); |
|
1235 | + if ($give_setting_updated) { |
|
1236 | + update_option('give_settings', $give_settings); |
|
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
@@ -1252,69 +1252,69 @@ discard block |
||
1252 | 1252 | $give_updates = Give_Updates::get_instance(); |
1253 | 1253 | |
1254 | 1254 | // form query. |
1255 | - $donation_forms = new WP_Query( array( |
|
1255 | + $donation_forms = new WP_Query(array( |
|
1256 | 1256 | 'paged' => $give_updates->step, |
1257 | 1257 | 'status' => 'any', |
1258 | 1258 | 'order' => 'ASC', |
1259 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1259 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1260 | 1260 | 'posts_per_page' => 20, |
1261 | 1261 | ) |
1262 | 1262 | ); |
1263 | - if ( $donation_forms->have_posts() ) { |
|
1264 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1263 | + if ($donation_forms->have_posts()) { |
|
1264 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1265 | 1265 | |
1266 | - while ( $donation_forms->have_posts() ) { |
|
1266 | + while ($donation_forms->have_posts()) { |
|
1267 | 1267 | $donation_forms->the_post(); |
1268 | 1268 | global $post; |
1269 | 1269 | |
1270 | - $meta = get_post_meta( $post->ID ); |
|
1270 | + $meta = get_post_meta($post->ID); |
|
1271 | 1271 | |
1272 | - switch ( $post->post_type ) { |
|
1272 | + switch ($post->post_type) { |
|
1273 | 1273 | case 'give_forms': |
1274 | 1274 | // _give_set_price. |
1275 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1276 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1275 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1276 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | // _give_custom_amount_minimum. |
1280 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1281 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1280 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1281 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | // _give_levels_minimum_amount. |
1285 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1286 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1285 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1286 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | // _give_levels_maximum_amount. |
1290 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1291 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1290 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1291 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | // _give_set_goal. |
1295 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1296 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1295 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1296 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | // _give_form_earnings. |
1300 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1301 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1300 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1301 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | // _give_custom_amount_minimum. |
1305 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1306 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1305 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1306 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1307 | 1307 | |
1308 | - foreach ( $donation_levels as $index => $level ) { |
|
1309 | - if ( empty( $level['_give_amount'] ) ) { |
|
1308 | + foreach ($donation_levels as $index => $level) { |
|
1309 | + if (empty($level['_give_amount'])) { |
|
1310 | 1310 | continue; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1313 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | $meta['_give_donation_levels'] = $donation_levels; |
1317 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1317 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | |
@@ -1322,8 +1322,8 @@ discard block |
||
1322 | 1322 | |
1323 | 1323 | case 'give_payment': |
1324 | 1324 | // _give_payment_total. |
1325 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1326 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1325 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1326 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1327 | 1327 | } |
1328 | 1328 | |
1329 | 1329 | break; |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | wp_reset_postdata(); |
1335 | 1335 | } else { |
1336 | 1336 | // The Update Ran. |
1337 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1337 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1338 | 1338 | } |
1339 | 1339 | } |
1340 | 1340 | |
@@ -1353,22 +1353,22 @@ discard block |
||
1353 | 1353 | $give_updates = Give_Updates::get_instance(); |
1354 | 1354 | |
1355 | 1355 | // form query. |
1356 | - $donors = Give()->donors->get_donors( array( |
|
1356 | + $donors = Give()->donors->get_donors(array( |
|
1357 | 1357 | 'number' => 20, |
1358 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1358 | + 'offset' => $give_updates->get_offset(20), |
|
1359 | 1359 | ) |
1360 | 1360 | ); |
1361 | 1361 | |
1362 | - if ( ! empty( $donors ) ) { |
|
1363 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1362 | + if ( ! empty($donors)) { |
|
1363 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1364 | 1364 | |
1365 | 1365 | /* @var Object $donor */ |
1366 | - foreach ( $donors as $donor ) { |
|
1367 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1366 | + foreach ($donors as $donor) { |
|
1367 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1368 | 1368 | } |
1369 | 1369 | } else { |
1370 | 1370 | // The Update Ran. |
1371 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1371 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1372 | 1372 | } |
1373 | 1373 | } |
1374 | 1374 | |
@@ -1382,25 +1382,25 @@ discard block |
||
1382 | 1382 | $give_updates = Give_Updates::get_instance(); |
1383 | 1383 | |
1384 | 1384 | // Fetch all the existing donors. |
1385 | - $donors = Give()->donors->get_donors( array( |
|
1385 | + $donors = Give()->donors->get_donors(array( |
|
1386 | 1386 | 'number' => 20, |
1387 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1387 | + 'offset' => $give_updates->get_offset(20), |
|
1388 | 1388 | ) |
1389 | 1389 | ); |
1390 | 1390 | |
1391 | - if ( ! empty( $donors ) ) { |
|
1392 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1391 | + if ( ! empty($donors)) { |
|
1392 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1393 | 1393 | |
1394 | 1394 | /* @var Object $donor */ |
1395 | - foreach ( $donors as $donor ) { |
|
1395 | + foreach ($donors as $donor) { |
|
1396 | 1396 | $user_id = $donor->user_id; |
1397 | 1397 | |
1398 | 1398 | // Proceed, if donor is attached with user. |
1399 | - if ( $user_id ) { |
|
1400 | - $user = get_userdata( $user_id ); |
|
1399 | + if ($user_id) { |
|
1400 | + $user = get_userdata($user_id); |
|
1401 | 1401 | |
1402 | 1402 | // Update user role, if user has subscriber role. |
1403 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1403 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1404 | 1404 | wp_update_user( |
1405 | 1405 | array( |
1406 | 1406 | 'ID' => $user_id, |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | } |
1413 | 1413 | } else { |
1414 | 1414 | // The Update Ran. |
1415 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1415 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | */ |
1425 | 1425 | function give_v1813_upgrades() { |
1426 | 1426 | // Update admin setting. |
1427 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1427 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1428 | 1428 | |
1429 | 1429 | // Update Give roles. |
1430 | 1430 | $roles = new Give_Roles(); |
@@ -1442,33 +1442,33 @@ discard block |
||
1442 | 1442 | $give_updates = Give_Updates::get_instance(); |
1443 | 1443 | |
1444 | 1444 | // form query. |
1445 | - $payments = new WP_Query( array( |
|
1445 | + $payments = new WP_Query(array( |
|
1446 | 1446 | 'paged' => $give_updates->step, |
1447 | 1447 | 'status' => 'any', |
1448 | 1448 | 'order' => 'ASC', |
1449 | - 'post_type' => array( 'give_payment' ), |
|
1449 | + 'post_type' => array('give_payment'), |
|
1450 | 1450 | 'posts_per_page' => 100, |
1451 | 1451 | ) |
1452 | 1452 | ); |
1453 | 1453 | |
1454 | - if ( $payments->have_posts() ) { |
|
1455 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1454 | + if ($payments->have_posts()) { |
|
1455 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1456 | 1456 | |
1457 | - while ( $payments->have_posts() ) { |
|
1457 | + while ($payments->have_posts()) { |
|
1458 | 1458 | $payments->the_post(); |
1459 | 1459 | |
1460 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1460 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1461 | 1461 | |
1462 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1462 | + if ('RIAL' === $payment_meta['currency']) { |
|
1463 | 1463 | $payment_meta['currency'] = 'IRR'; |
1464 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1464 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | } else { |
1470 | 1470 | // The Update Ran. |
1471 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1471 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1472 | 1472 | } |
1473 | 1473 | } |
1474 | 1474 | |
@@ -1481,9 +1481,9 @@ discard block |
||
1481 | 1481 | function give_v1817_upgrades() { |
1482 | 1482 | $give_settings = give_get_settings(); |
1483 | 1483 | |
1484 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1484 | + if ('RIAL' === $give_settings['currency']) { |
|
1485 | 1485 | $give_settings['currency'] = 'IRR'; |
1486 | - update_option( 'give_settings', $give_settings ); |
|
1486 | + update_option('give_settings', $give_settings); |
|
1487 | 1487 | } |
1488 | 1488 | } |
1489 | 1489 | |
@@ -1496,7 +1496,7 @@ discard block |
||
1496 | 1496 | |
1497 | 1497 | global $wp_roles; |
1498 | 1498 | |
1499 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1499 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1500 | 1500 | return; |
1501 | 1501 | } |
1502 | 1502 | |
@@ -1520,15 +1520,15 @@ discard block |
||
1520 | 1520 | ), |
1521 | 1521 | ); |
1522 | 1522 | |
1523 | - foreach ( $add_caps as $role => $caps ) { |
|
1524 | - foreach ( $caps as $cap ) { |
|
1525 | - $wp_roles->add_cap( $role, $cap ); |
|
1523 | + foreach ($add_caps as $role => $caps) { |
|
1524 | + foreach ($caps as $cap) { |
|
1525 | + $wp_roles->add_cap($role, $cap); |
|
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | |
1529 | - foreach ( $remove_caps as $role => $caps ) { |
|
1530 | - foreach ( $caps as $cap ) { |
|
1531 | - $wp_roles->remove_cap( $role, $cap ); |
|
1529 | + foreach ($remove_caps as $role => $caps) { |
|
1530 | + foreach ($caps as $cap) { |
|
1531 | + $wp_roles->remove_cap($role, $cap); |
|
1532 | 1532 | } |
1533 | 1533 | } |
1534 | 1534 | |
@@ -1552,7 +1552,7 @@ discard block |
||
1552 | 1552 | $roles->add_roles(); |
1553 | 1553 | $roles->add_caps(); |
1554 | 1554 | |
1555 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1555 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | /** |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | function give_v1818_upgrades() { |
1564 | 1564 | |
1565 | 1565 | // Remove email_access_installed from give_settings. |
1566 | - give_delete_option( 'email_access_installed' ); |
|
1566 | + give_delete_option('email_access_installed'); |
|
1567 | 1567 | } |
1568 | 1568 | |
1569 | 1569 | /** |
@@ -1576,23 +1576,23 @@ discard block |
||
1576 | 1576 | /* @var Give_Updates $give_updates */ |
1577 | 1577 | $give_updates = Give_Updates::get_instance(); |
1578 | 1578 | |
1579 | - $donations = new WP_Query( array( |
|
1579 | + $donations = new WP_Query(array( |
|
1580 | 1580 | 'paged' => $give_updates->step, |
1581 | 1581 | 'status' => 'any', |
1582 | 1582 | 'order' => 'ASC', |
1583 | - 'post_type' => array( 'give_payment' ), |
|
1583 | + 'post_type' => array('give_payment'), |
|
1584 | 1584 | 'posts_per_page' => 100, |
1585 | 1585 | ) |
1586 | 1586 | ); |
1587 | 1587 | |
1588 | - if ( $donations->have_posts() ) { |
|
1589 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1588 | + if ($donations->have_posts()) { |
|
1589 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1590 | 1590 | |
1591 | - while ( $donations->have_posts() ) { |
|
1591 | + while ($donations->have_posts()) { |
|
1592 | 1592 | $donations->the_post(); |
1593 | 1593 | |
1594 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1595 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1594 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1595 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1596 | 1596 | |
1597 | 1597 | // Update Donation meta with price_id set as custom, only if it is: |
1598 | 1598 | // 1. Donation Type = Set Donation. |
@@ -1601,19 +1601,19 @@ discard block |
||
1601 | 1601 | if ( |
1602 | 1602 | $form->ID && |
1603 | 1603 | $form->is_set_type_donation_form() && |
1604 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1605 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1604 | + ('custom' !== $donation_meta['price_id']) && |
|
1605 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1606 | 1606 | ) { |
1607 | 1607 | $donation_meta['price_id'] = 'custom'; |
1608 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1609 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1608 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1609 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1610 | 1610 | } |
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | wp_reset_postdata(); |
1614 | 1614 | } else { |
1615 | 1615 | // Update Ran Successfully. |
1616 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1616 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1617 | 1617 | } |
1618 | 1618 | } |
1619 | 1619 | |
@@ -1631,7 +1631,7 @@ discard block |
||
1631 | 1631 | |
1632 | 1632 | global $wp_roles; |
1633 | 1633 | |
1634 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1634 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1635 | 1635 | return; |
1636 | 1636 | } |
1637 | 1637 | |
@@ -1649,9 +1649,9 @@ discard block |
||
1649 | 1649 | ), |
1650 | 1650 | ); |
1651 | 1651 | |
1652 | - foreach ( $remove_caps as $role => $caps ) { |
|
1653 | - foreach ( $caps as $cap ) { |
|
1654 | - $wp_roles->remove_cap( $role, $cap ); |
|
1652 | + foreach ($remove_caps as $role => $caps) { |
|
1653 | + foreach ($caps as $cap) { |
|
1654 | + $wp_roles->remove_cap($role, $cap); |
|
1655 | 1655 | } |
1656 | 1656 | } |
1657 | 1657 | |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | $roles->add_roles(); |
1663 | 1663 | $roles->add_caps(); |
1664 | 1664 | |
1665 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1665 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | /** |
@@ -1676,7 +1676,7 @@ discard block |
||
1676 | 1676 | $give_updates = Give_Updates::get_instance(); |
1677 | 1677 | |
1678 | 1678 | // form query |
1679 | - $forms = new WP_Query( array( |
|
1679 | + $forms = new WP_Query(array( |
|
1680 | 1680 | 'paged' => $give_updates->step, |
1681 | 1681 | 'status' => 'any', |
1682 | 1682 | 'order' => 'ASC', |
@@ -1685,22 +1685,22 @@ discard block |
||
1685 | 1685 | ) |
1686 | 1686 | ); |
1687 | 1687 | |
1688 | - if ( $forms->have_posts() ) { |
|
1689 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1688 | + if ($forms->have_posts()) { |
|
1689 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1690 | 1690 | |
1691 | - while ( $forms->have_posts() ) { |
|
1691 | + while ($forms->have_posts()) { |
|
1692 | 1692 | $forms->the_post(); |
1693 | 1693 | global $post; |
1694 | 1694 | |
1695 | 1695 | // Update offline instruction email notification status. |
1696 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1697 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1696 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1697 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1698 | 1698 | 'enabled', |
1699 | 1699 | 'global', |
1700 | - ) ) |
|
1700 | + )) |
|
1701 | 1701 | ? $offline_instruction_notification_status |
1702 | 1702 | : 'global'; |
1703 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1703 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1704 | 1704 | |
1705 | 1705 | // Update offline instruction email message. |
1706 | 1706 | update_post_meta( |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | wp_reset_postdata(); |
1733 | 1733 | } else { |
1734 | 1734 | // No more forms found, finish up. |
1735 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1735 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1736 | 1736 | } |
1737 | 1737 | } |
1738 | 1738 | |
@@ -1749,7 +1749,7 @@ discard block |
||
1749 | 1749 | $give_updates = Give_Updates::get_instance(); |
1750 | 1750 | |
1751 | 1751 | // form query |
1752 | - $forms = new WP_Query( array( |
|
1752 | + $forms = new WP_Query(array( |
|
1753 | 1753 | 'paged' => $give_updates->step, |
1754 | 1754 | 'status' => 'any', |
1755 | 1755 | 'order' => 'ASC', |
@@ -1758,19 +1758,19 @@ discard block |
||
1758 | 1758 | ) |
1759 | 1759 | ); |
1760 | 1760 | |
1761 | - if ( $forms->have_posts() ) { |
|
1762 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1761 | + if ($forms->have_posts()) { |
|
1762 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1763 | 1763 | |
1764 | - while ( $forms->have_posts() ) { |
|
1764 | + while ($forms->have_posts()) { |
|
1765 | 1765 | $forms->the_post(); |
1766 | 1766 | global $post; |
1767 | 1767 | |
1768 | 1768 | // Split _give_payment_meta meta. |
1769 | 1769 | // @todo Remove _give_payment_meta after releases 2.0 |
1770 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1770 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1771 | 1771 | |
1772 | - if ( ! empty( $payment_meta ) ) { |
|
1773 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1772 | + if ( ! empty($payment_meta)) { |
|
1773 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | $deprecated_meta_keys = array( |
@@ -1779,9 +1779,9 @@ discard block |
||
1779 | 1779 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1780 | 1780 | ); |
1781 | 1781 | |
1782 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1782 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1783 | 1783 | // Do not add new meta key if already exist. |
1784 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
1784 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
1785 | 1785 | continue; |
1786 | 1786 | } |
1787 | 1787 | |
@@ -1790,25 +1790,25 @@ discard block |
||
1790 | 1790 | array( |
1791 | 1791 | 'post_id' => $post->ID, |
1792 | 1792 | 'meta_key' => $new_meta_key, |
1793 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
1793 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
1794 | 1794 | ) |
1795 | 1795 | ); |
1796 | 1796 | } |
1797 | 1797 | |
1798 | 1798 | // Bailout |
1799 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1799 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1800 | 1800 | /* @var Give_Donor $donor */ |
1801 | - $donor = new Give_Donor( $donor_id ); |
|
1801 | + $donor = new Give_Donor($donor_id); |
|
1802 | 1802 | |
1803 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1804 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1805 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1806 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1807 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1808 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1803 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1804 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1805 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1806 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1807 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1808 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1809 | 1809 | |
1810 | 1810 | // Save address. |
1811 | - $donor->add_address( 'billing[]', $address ); |
|
1811 | + $donor->add_address('billing[]', $address); |
|
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | }// End while(). |
@@ -1819,7 +1819,7 @@ discard block |
||
1819 | 1819 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1820 | 1820 | |
1821 | 1821 | // No more forms found, finish up. |
1822 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1822 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1823 | 1823 | } |
1824 | 1824 | } |
1825 | 1825 | |
@@ -1835,7 +1835,7 @@ discard block |
||
1835 | 1835 | $give_updates = Give_Updates::get_instance(); |
1836 | 1836 | |
1837 | 1837 | // form query |
1838 | - $forms = new WP_Query( array( |
|
1838 | + $forms = new WP_Query(array( |
|
1839 | 1839 | 'paged' => $give_updates->step, |
1840 | 1840 | 'order' => 'DESC', |
1841 | 1841 | 'post_type' => 'give_log', |
@@ -1844,20 +1844,20 @@ discard block |
||
1844 | 1844 | ) |
1845 | 1845 | ); |
1846 | 1846 | |
1847 | - if ( $forms->have_posts() ) { |
|
1848 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1847 | + if ($forms->have_posts()) { |
|
1848 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1849 | 1849 | |
1850 | - while ( $forms->have_posts() ) { |
|
1850 | + while ($forms->have_posts()) { |
|
1851 | 1851 | $forms->the_post(); |
1852 | 1852 | global $post; |
1853 | 1853 | |
1854 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1854 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1855 | 1855 | continue; |
1856 | 1856 | } |
1857 | 1857 | |
1858 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1859 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1860 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1858 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1859 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1860 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1861 | 1861 | |
1862 | 1862 | $log_data = array( |
1863 | 1863 | 'ID' => $post->ID, |
@@ -1870,29 +1870,29 @@ discard block |
||
1870 | 1870 | ); |
1871 | 1871 | $log_meta = array(); |
1872 | 1872 | |
1873 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1874 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1875 | - switch ( $meta_key ) { |
|
1873 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1874 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1875 | + switch ($meta_key) { |
|
1876 | 1876 | case '_give_log_payment_id': |
1877 | - $log_data['log_parent'] = current( $meta_value ); |
|
1877 | + $log_data['log_parent'] = current($meta_value); |
|
1878 | 1878 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1879 | 1879 | break; |
1880 | 1880 | |
1881 | 1881 | default: |
1882 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1882 | + $log_meta[$meta_key] = current($meta_value); |
|
1883 | 1883 | } |
1884 | 1884 | } |
1885 | 1885 | } |
1886 | 1886 | |
1887 | - if ( 'api_request' === $term_name ) { |
|
1887 | + if ('api_request' === $term_name) { |
|
1888 | 1888 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1889 | 1889 | } |
1890 | 1890 | |
1891 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1891 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1892 | 1892 | |
1893 | - if ( ! empty( $log_meta ) ) { |
|
1894 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1895 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1893 | + if ( ! empty($log_meta)) { |
|
1894 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1895 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1896 | 1896 | } |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1934,7 +1934,7 @@ discard block |
||
1934 | 1934 | Give()->logs->delete_cache(); |
1935 | 1935 | |
1936 | 1936 | // No more forms found, finish up. |
1937 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1937 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1938 | 1938 | } |
1939 | 1939 | } |
1940 | 1940 | |
@@ -1950,19 +1950,19 @@ discard block |
||
1950 | 1950 | $give_updates = Give_Updates::get_instance(); |
1951 | 1951 | |
1952 | 1952 | // form query |
1953 | - $payments = new WP_Query( array( |
|
1953 | + $payments = new WP_Query(array( |
|
1954 | 1954 | 'paged' => $give_updates->step, |
1955 | 1955 | 'status' => 'any', |
1956 | 1956 | 'order' => 'ASC', |
1957 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1957 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1958 | 1958 | 'posts_per_page' => 100, |
1959 | 1959 | ) |
1960 | 1960 | ); |
1961 | 1961 | |
1962 | - if ( $payments->have_posts() ) { |
|
1963 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
1962 | + if ($payments->have_posts()) { |
|
1963 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
1964 | 1964 | |
1965 | - while ( $payments->have_posts() ) { |
|
1965 | + while ($payments->have_posts()) { |
|
1966 | 1966 | $payments->the_post(); |
1967 | 1967 | global $post; |
1968 | 1968 | |
@@ -1974,19 +1974,19 @@ discard block |
||
1974 | 1974 | ARRAY_A |
1975 | 1975 | ); |
1976 | 1976 | |
1977 | - if ( ! empty( $meta_data ) ) { |
|
1978 | - foreach ( $meta_data as $index => $data ) { |
|
1977 | + if ( ! empty($meta_data)) { |
|
1978 | + foreach ($meta_data as $index => $data) { |
|
1979 | 1979 | // Check for duplicate meta values. |
1980 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
1980 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
1981 | 1981 | continue; |
1982 | 1982 | } |
1983 | 1983 | |
1984 | - switch ( $post->post_type ) { |
|
1984 | + switch ($post->post_type) { |
|
1985 | 1985 | case 'give_forms': |
1986 | 1986 | $data['form_id'] = $data['post_id']; |
1987 | - unset( $data['post_id'] ); |
|
1987 | + unset($data['post_id']); |
|
1988 | 1988 | |
1989 | - Give()->form_meta->insert( $data ); |
|
1989 | + Give()->form_meta->insert($data); |
|
1990 | 1990 | // @todo: delete form meta from post meta table after releases 2.0. |
1991 | 1991 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
1992 | 1992 | |
@@ -1994,9 +1994,9 @@ discard block |
||
1994 | 1994 | |
1995 | 1995 | case 'give_payment': |
1996 | 1996 | $data['payment_id'] = $data['post_id']; |
1997 | - unset( $data['post_id'] ); |
|
1997 | + unset($data['post_id']); |
|
1998 | 1998 | |
1999 | - Give()->payment_meta->insert( $data ); |
|
1999 | + Give()->payment_meta->insert($data); |
|
2000 | 2000 | |
2001 | 2001 | // @todo: delete donation meta from post meta table after releases 2.0. |
2002 | 2002 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2011,7 +2011,7 @@ discard block |
||
2011 | 2011 | wp_reset_postdata(); |
2012 | 2012 | } else { |
2013 | 2013 | // No more forms found, finish up. |
2014 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2014 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2015 | 2015 | } |
2016 | 2016 | |
2017 | 2017 | } |
@@ -2027,44 +2027,44 @@ discard block |
||
2027 | 2027 | /* @var Give_Updates $give_updates */ |
2028 | 2028 | $give_updates = Give_Updates::get_instance(); |
2029 | 2029 | |
2030 | - $donors = Give()->donors->get_donors( array( |
|
2030 | + $donors = Give()->donors->get_donors(array( |
|
2031 | 2031 | 'paged' => $give_updates->step, |
2032 | 2032 | 'number' => 100, |
2033 | - ) ); |
|
2033 | + )); |
|
2034 | 2034 | |
2035 | - if ( $donors ) { |
|
2036 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2035 | + if ($donors) { |
|
2036 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2037 | 2037 | // Loop through Donors |
2038 | - foreach ( $donors as $donor ) { |
|
2038 | + foreach ($donors as $donor) { |
|
2039 | 2039 | |
2040 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2041 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2042 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2040 | + $donor_name = explode(' ', $donor->name, 2); |
|
2041 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2042 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2043 | 2043 | |
2044 | 2044 | // If first name meta of donor is not created, then create it. |
2045 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2046 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2045 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2046 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2047 | 2047 | } |
2048 | 2048 | |
2049 | 2049 | // If last name meta of donor is not created, then create it. |
2050 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2051 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2050 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2051 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2052 | 2052 | } |
2053 | 2053 | |
2054 | 2054 | // If Donor is connected with WP User then update user meta. |
2055 | - if ( $donor->user_id ) { |
|
2056 | - if ( isset( $donor_name[0] ) ) { |
|
2057 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2055 | + if ($donor->user_id) { |
|
2056 | + if (isset($donor_name[0])) { |
|
2057 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2058 | 2058 | } |
2059 | - if ( isset( $donor_name[1] ) ) { |
|
2060 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2059 | + if (isset($donor_name[1])) { |
|
2060 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2061 | 2061 | } |
2062 | 2062 | } |
2063 | 2063 | } |
2064 | 2064 | |
2065 | 2065 | } else { |
2066 | 2066 | // The Update Ran. |
2067 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2067 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2068 | 2068 | } |
2069 | 2069 | |
2070 | 2070 | } |
@@ -2093,15 +2093,15 @@ discard block |
||
2093 | 2093 | |
2094 | 2094 | $users = $user_query->get_results(); |
2095 | 2095 | |
2096 | - if ( $users ) { |
|
2097 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2096 | + if ($users) { |
|
2097 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2098 | 2098 | |
2099 | 2099 | // Loop through Donors |
2100 | - foreach ( $users as $user ) { |
|
2100 | + foreach ($users as $user) { |
|
2101 | 2101 | /* @var Give_Donor $donor */ |
2102 | - $donor = new Give_Donor( $user->ID, true ); |
|
2102 | + $donor = new Give_Donor($user->ID, true); |
|
2103 | 2103 | |
2104 | - if ( ! $donor->id ) { |
|
2104 | + if ( ! $donor->id) { |
|
2105 | 2105 | continue; |
2106 | 2106 | } |
2107 | 2107 | |
@@ -2117,10 +2117,10 @@ discard block |
||
2117 | 2117 | ) |
2118 | 2118 | ); |
2119 | 2119 | |
2120 | - if ( ! empty( $address ) ) { |
|
2121 | - $address = maybe_unserialize( $address ); |
|
2122 | - $donor->add_address( 'personal', $address ); |
|
2123 | - $donor->add_address( 'billing[]', $address ); |
|
2120 | + if ( ! empty($address)) { |
|
2121 | + $address = maybe_unserialize($address); |
|
2122 | + $donor->add_address('personal', $address); |
|
2123 | + $donor->add_address('billing[]', $address); |
|
2124 | 2124 | |
2125 | 2125 | |
2126 | 2126 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2130,7 +2130,7 @@ discard block |
||
2130 | 2130 | |
2131 | 2131 | } else { |
2132 | 2132 | // The Update Ran. |
2133 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2133 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2134 | 2134 | } |
2135 | 2135 | |
2136 | 2136 | } |
@@ -2154,15 +2154,15 @@ discard block |
||
2154 | 2154 | ); |
2155 | 2155 | |
2156 | 2156 | // Alter customer table |
2157 | - foreach ( $tables as $old_table => $new_table ) { |
|
2157 | + foreach ($tables as $old_table => $new_table) { |
|
2158 | 2158 | if ( |
2159 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2160 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2159 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2160 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2161 | 2161 | ) { |
2162 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2162 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2163 | 2163 | |
2164 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2165 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2164 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2165 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2166 | 2166 | } |
2167 | 2167 | } |
2168 | 2168 | } |
@@ -2170,7 +2170,7 @@ discard block |
||
2170 | 2170 | $give_updates->percentage = 100; |
2171 | 2171 | |
2172 | 2172 | // No more forms found, finish up. |
2173 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2173 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2174 | 2174 | |
2175 | 2175 | // Re initiate donor classes. |
2176 | 2176 | Give()->donors = new Give_DB_Donors(); |
@@ -2188,19 +2188,19 @@ discard block |
||
2188 | 2188 | function give_v201_create_tables() { |
2189 | 2189 | global $wpdb; |
2190 | 2190 | |
2191 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2191 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2192 | 2192 | Give()->payment_meta->create_table(); |
2193 | 2193 | } |
2194 | 2194 | |
2195 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2195 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2196 | 2196 | Give()->form_meta->create_table(); |
2197 | 2197 | } |
2198 | 2198 | |
2199 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2199 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2200 | 2200 | Give()->logs->log_db->create_table(); |
2201 | 2201 | } |
2202 | 2202 | |
2203 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2203 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2204 | 2204 | Give()->logs->logmeta_db->create_table(); |
2205 | 2205 | } |
2206 | 2206 | } |
@@ -2225,31 +2225,31 @@ discard block |
||
2225 | 2225 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2226 | 2226 | ) |
2227 | 2227 | AND $wpdb->posts.post_type = 'give_payment' |
2228 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2228 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2229 | 2229 | ORDER BY $wpdb->posts.post_date ASC |
2230 | 2230 | LIMIT 100 |
2231 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2231 | + OFFSET ".$give_updates->get_offset(100) |
|
2232 | 2232 | ); |
2233 | 2233 | |
2234 | - if ( ! empty( $payments ) ) { |
|
2235 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2234 | + if ( ! empty($payments)) { |
|
2235 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2236 | 2236 | |
2237 | - foreach ( $payments as $payment_id ) { |
|
2238 | - $post = get_post( $payment_id ); |
|
2239 | - setup_postdata( $post ); |
|
2237 | + foreach ($payments as $payment_id) { |
|
2238 | + $post = get_post($payment_id); |
|
2239 | + setup_postdata($post); |
|
2240 | 2240 | |
2241 | 2241 | // Do not add new meta keys if already refactored. |
2242 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
2242 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
2243 | 2243 | continue; |
2244 | 2244 | } |
2245 | 2245 | |
2246 | 2246 | |
2247 | 2247 | // Split _give_payment_meta meta. |
2248 | 2248 | // @todo Remove _give_payment_meta after releases 2.0 |
2249 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2249 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2250 | 2250 | |
2251 | - if ( ! empty( $payment_meta ) ) { |
|
2252 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2251 | + if ( ! empty($payment_meta)) { |
|
2252 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2253 | 2253 | } |
2254 | 2254 | |
2255 | 2255 | $deprecated_meta_keys = array( |
@@ -2258,9 +2258,9 @@ discard block |
||
2258 | 2258 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2259 | 2259 | ); |
2260 | 2260 | |
2261 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2261 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2262 | 2262 | // Do not add new meta key if already exist. |
2263 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
2263 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
2264 | 2264 | continue; |
2265 | 2265 | } |
2266 | 2266 | |
@@ -2269,25 +2269,25 @@ discard block |
||
2269 | 2269 | array( |
2270 | 2270 | 'post_id' => $post->ID, |
2271 | 2271 | 'meta_key' => $new_meta_key, |
2272 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
2272 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
2273 | 2273 | ) |
2274 | 2274 | ); |
2275 | 2275 | } |
2276 | 2276 | |
2277 | 2277 | // Bailout |
2278 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2278 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2279 | 2279 | /* @var Give_Donor $donor */ |
2280 | - $donor = new Give_Donor( $donor_id ); |
|
2280 | + $donor = new Give_Donor($donor_id); |
|
2281 | 2281 | |
2282 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2283 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2284 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2285 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2286 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2287 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2282 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2283 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2284 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2285 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2286 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2287 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2288 | 2288 | |
2289 | 2289 | // Save address. |
2290 | - $donor->add_address( 'billing[]', $address ); |
|
2290 | + $donor->add_address('billing[]', $address); |
|
2291 | 2291 | } |
2292 | 2292 | |
2293 | 2293 | }// End while(). |
@@ -2298,7 +2298,7 @@ discard block |
||
2298 | 2298 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2299 | 2299 | |
2300 | 2300 | // No more forms found, finish up. |
2301 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2301 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2302 | 2302 | } |
2303 | 2303 | } |
2304 | 2304 | |
@@ -2318,21 +2318,21 @@ discard block |
||
2318 | 2318 | SELECT ID FROM $wpdb->posts |
2319 | 2319 | WHERE 1=1 |
2320 | 2320 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2321 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2321 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2322 | 2322 | ORDER BY $wpdb->posts.post_date ASC |
2323 | 2323 | LIMIT 100 |
2324 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2324 | + OFFSET ".$give_updates->get_offset(100) |
|
2325 | 2325 | ); |
2326 | 2326 | |
2327 | - if ( ! empty( $payments ) ) { |
|
2328 | - $give_updates->set_percentage( give_get_total_post_type_count( array( |
|
2327 | + if ( ! empty($payments)) { |
|
2328 | + $give_updates->set_percentage(give_get_total_post_type_count(array( |
|
2329 | 2329 | 'give_forms', |
2330 | 2330 | 'give_payment', |
2331 | - ) ), $give_updates->step * 100 ); |
|
2331 | + )), $give_updates->step * 100); |
|
2332 | 2332 | |
2333 | - foreach ( $payments as $payment_id ) { |
|
2334 | - $post = get_post( $payment_id ); |
|
2335 | - setup_postdata( $post ); |
|
2333 | + foreach ($payments as $payment_id) { |
|
2334 | + $post = get_post($payment_id); |
|
2335 | + setup_postdata($post); |
|
2336 | 2336 | |
2337 | 2337 | $meta_data = $wpdb->get_results( |
2338 | 2338 | $wpdb->prepare( |
@@ -2342,19 +2342,19 @@ discard block |
||
2342 | 2342 | ARRAY_A |
2343 | 2343 | ); |
2344 | 2344 | |
2345 | - if ( ! empty( $meta_data ) ) { |
|
2346 | - foreach ( $meta_data as $index => $data ) { |
|
2345 | + if ( ! empty($meta_data)) { |
|
2346 | + foreach ($meta_data as $index => $data) { |
|
2347 | 2347 | // Check for duplicate meta values. |
2348 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2348 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2349 | 2349 | continue; |
2350 | 2350 | } |
2351 | 2351 | |
2352 | - switch ( $post->post_type ) { |
|
2352 | + switch ($post->post_type) { |
|
2353 | 2353 | case 'give_forms': |
2354 | 2354 | $data['form_id'] = $data['post_id']; |
2355 | - unset( $data['post_id'] ); |
|
2355 | + unset($data['post_id']); |
|
2356 | 2356 | |
2357 | - Give()->form_meta->insert( $data ); |
|
2357 | + Give()->form_meta->insert($data); |
|
2358 | 2358 | // @todo: delete form meta from post meta table after releases 2.0. |
2359 | 2359 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2360 | 2360 | |
@@ -2362,9 +2362,9 @@ discard block |
||
2362 | 2362 | |
2363 | 2363 | case 'give_payment': |
2364 | 2364 | $data['payment_id'] = $data['post_id']; |
2365 | - unset( $data['post_id'] ); |
|
2365 | + unset($data['post_id']); |
|
2366 | 2366 | |
2367 | - Give()->payment_meta->insert( $data ); |
|
2367 | + Give()->payment_meta->insert($data); |
|
2368 | 2368 | |
2369 | 2369 | // @todo: delete donation meta from post meta table after releases 2.0. |
2370 | 2370 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2379,7 +2379,7 @@ discard block |
||
2379 | 2379 | wp_reset_postdata(); |
2380 | 2380 | } else { |
2381 | 2381 | // No more forms found, finish up. |
2382 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2382 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2383 | 2383 | } |
2384 | 2384 | |
2385 | 2385 | } |
@@ -2400,26 +2400,26 @@ discard block |
||
2400 | 2400 | SELECT ID FROM $wpdb->posts |
2401 | 2401 | WHERE 1=1 |
2402 | 2402 | AND $wpdb->posts.post_type = 'give_log' |
2403 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2403 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2404 | 2404 | ORDER BY $wpdb->posts.post_date ASC |
2405 | 2405 | LIMIT 100 |
2406 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2406 | + OFFSET ".$give_updates->get_offset(100) |
|
2407 | 2407 | ); |
2408 | 2408 | |
2409 | - if ( ! empty( $logs ) ) { |
|
2410 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2409 | + if ( ! empty($logs)) { |
|
2410 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2411 | 2411 | |
2412 | - foreach ( $logs as $log_id ) { |
|
2413 | - $post = get_post( $log_id ); |
|
2414 | - setup_postdata( $post ); |
|
2412 | + foreach ($logs as $log_id) { |
|
2413 | + $post = get_post($log_id); |
|
2414 | + setup_postdata($post); |
|
2415 | 2415 | |
2416 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2416 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2417 | 2417 | continue; |
2418 | 2418 | } |
2419 | 2419 | |
2420 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2421 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2422 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2420 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2421 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2422 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2423 | 2423 | |
2424 | 2424 | $log_data = array( |
2425 | 2425 | 'ID' => $post->ID, |
@@ -2432,29 +2432,29 @@ discard block |
||
2432 | 2432 | ); |
2433 | 2433 | $log_meta = array(); |
2434 | 2434 | |
2435 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2436 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2437 | - switch ( $meta_key ) { |
|
2435 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2436 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2437 | + switch ($meta_key) { |
|
2438 | 2438 | case '_give_log_payment_id': |
2439 | - $log_data['log_parent'] = current( $meta_value ); |
|
2439 | + $log_data['log_parent'] = current($meta_value); |
|
2440 | 2440 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2441 | 2441 | break; |
2442 | 2442 | |
2443 | 2443 | default: |
2444 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2444 | + $log_meta[$meta_key] = current($meta_value); |
|
2445 | 2445 | } |
2446 | 2446 | } |
2447 | 2447 | } |
2448 | 2448 | |
2449 | - if ( 'api_request' === $term_name ) { |
|
2449 | + if ('api_request' === $term_name) { |
|
2450 | 2450 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2451 | 2451 | } |
2452 | 2452 | |
2453 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2453 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2454 | 2454 | |
2455 | - if ( ! empty( $log_meta ) ) { |
|
2456 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2457 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2455 | + if ( ! empty($log_meta)) { |
|
2456 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2457 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2458 | 2458 | } |
2459 | 2459 | } |
2460 | 2460 | |
@@ -2467,7 +2467,7 @@ discard block |
||
2467 | 2467 | Give()->logs->delete_cache(); |
2468 | 2468 | |
2469 | 2469 | // No more forms found, finish up. |
2470 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2470 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2471 | 2471 | } |
2472 | 2472 | } |
2473 | 2473 | |
@@ -2482,51 +2482,51 @@ discard block |
||
2482 | 2482 | global $wpdb; |
2483 | 2483 | give_v201_create_tables(); |
2484 | 2484 | |
2485 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2486 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2487 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2485 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2486 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2487 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2488 | 2488 | $donor_data = array(); |
2489 | 2489 | |
2490 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2491 | - foreach ( $missing_donors as $donor_id ) { |
|
2490 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2491 | + foreach ($missing_donors as $donor_id) { |
|
2492 | 2492 | $donor_data[] = array( |
2493 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2494 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2493 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2494 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2495 | 2495 | |
2496 | 2496 | ); |
2497 | 2497 | } |
2498 | 2498 | } |
2499 | 2499 | |
2500 | - if ( ! empty( $donor_data ) ) { |
|
2500 | + if ( ! empty($donor_data)) { |
|
2501 | 2501 | $donor_table_name = Give()->donors->table_name; |
2502 | 2502 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2503 | 2503 | |
2504 | 2504 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2505 | 2505 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2506 | 2506 | |
2507 | - foreach ( $donor_data as $donor ) { |
|
2507 | + foreach ($donor_data as $donor) { |
|
2508 | 2508 | $donor['info'][0] = (array) $donor['info'][0]; |
2509 | 2509 | |
2510 | 2510 | // Prevent duplicate meta id issue. |
2511 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
2511 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2512 | 2512 | continue; |
2513 | 2513 | } |
2514 | 2514 | |
2515 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2515 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2516 | 2516 | |
2517 | - if ( ! empty( $donor['meta'] ) ) { |
|
2518 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2517 | + if ( ! empty($donor['meta'])) { |
|
2518 | + foreach ($donor['meta'] as $donor_meta) { |
|
2519 | 2519 | $donor_meta = (array) $donor_meta; |
2520 | 2520 | |
2521 | 2521 | // Prevent duplicate meta id issue. |
2522 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
2523 | - unset( $donor_meta['meta_id'] ); |
|
2522 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2523 | + unset($donor_meta['meta_id']); |
|
2524 | 2524 | } |
2525 | 2525 | |
2526 | 2526 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2527 | - unset( $donor_meta['customer_id'] ); |
|
2527 | + unset($donor_meta['customer_id']); |
|
2528 | 2528 | |
2529 | - Give()->donor_meta->insert( $donor_meta ); |
|
2529 | + Give()->donor_meta->insert($donor_meta); |
|
2530 | 2530 | } |
2531 | 2531 | } |
2532 | 2532 | |
@@ -2545,35 +2545,35 @@ discard block |
||
2545 | 2545 | ) |
2546 | 2546 | ); |
2547 | 2547 | |
2548 | - $donor = new Give_Donor( $donor_id ); |
|
2548 | + $donor = new Give_Donor($donor_id); |
|
2549 | 2549 | |
2550 | - if ( ! empty( $address ) ) { |
|
2551 | - $address = maybe_unserialize( $address ); |
|
2552 | - $donor->add_address( 'personal', $address ); |
|
2553 | - $donor->add_address( 'billing[]', $address ); |
|
2550 | + if ( ! empty($address)) { |
|
2551 | + $address = maybe_unserialize($address); |
|
2552 | + $donor->add_address('personal', $address); |
|
2553 | + $donor->add_address('billing[]', $address); |
|
2554 | 2554 | } |
2555 | 2555 | |
2556 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2557 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2558 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2556 | + $donor_name = explode(' ', $donor->name, 2); |
|
2557 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2558 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2559 | 2559 | |
2560 | 2560 | // If first name meta of donor is not created, then create it. |
2561 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2562 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2561 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2562 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2563 | 2563 | } |
2564 | 2564 | |
2565 | 2565 | // If last name meta of donor is not created, then create it. |
2566 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2567 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2566 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2567 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2568 | 2568 | } |
2569 | 2569 | |
2570 | 2570 | // If Donor is connected with WP User then update user meta. |
2571 | - if ( $donor->user_id ) { |
|
2572 | - if ( isset( $donor_name[0] ) ) { |
|
2573 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2571 | + if ($donor->user_id) { |
|
2572 | + if (isset($donor_name[0])) { |
|
2573 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2574 | 2574 | } |
2575 | - if ( isset( $donor_name[1] ) ) { |
|
2576 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2575 | + if (isset($donor_name[1])) { |
|
2576 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2577 | 2577 | } |
2578 | 2578 | } |
2579 | 2579 | } |
@@ -2584,7 +2584,7 @@ discard block |
||
2584 | 2584 | } |
2585 | 2585 | |
2586 | 2586 | Give_Updates::get_instance()->percentage = 100; |
2587 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
2587 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2588 | 2588 | } |
2589 | 2589 | |
2590 | 2590 | |
@@ -2597,14 +2597,14 @@ discard block |
||
2597 | 2597 | global $wpdb; |
2598 | 2598 | |
2599 | 2599 | // Do not auto load option. |
2600 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2600 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2601 | 2601 | |
2602 | 2602 | // Remove from cache. |
2603 | 2603 | $all_options = wp_load_alloptions(); |
2604 | 2604 | |
2605 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2606 | - unset( $all_options['give_completed_upgrades'] ); |
|
2607 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2605 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2606 | + unset($all_options['give_completed_upgrades']); |
|
2607 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2608 | 2608 | } |
2609 | 2609 | |
2610 | 2610 | } |
2611 | 2611 | \ No newline at end of file |
@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $args |
82 | 82 | */ |
83 | - public function register( $args ) { |
|
83 | + public function register($args) { |
|
84 | 84 | $args_default = array( |
85 | 85 | 'id' => '', |
86 | 86 | 'version' => '', |
87 | 87 | 'callback' => '', |
88 | 88 | ); |
89 | 89 | |
90 | - $args = wp_parse_args( $args, $args_default ); |
|
90 | + $args = wp_parse_args($args, $args_default); |
|
91 | 91 | |
92 | 92 | // You can only register database upgrade. |
93 | 93 | $args['type'] = 'database'; |
94 | 94 | |
95 | 95 | // Bailout. |
96 | 96 | if ( |
97 | - empty( $args['id'] ) || |
|
98 | - empty( $args['version'] ) || |
|
99 | - empty( $args['callback'] ) || |
|
100 | - ! is_callable( $args['callback'] ) |
|
97 | + empty($args['id']) || |
|
98 | + empty($args['version']) || |
|
99 | + empty($args['callback']) || |
|
100 | + ! is_callable($args['callback']) |
|
101 | 101 | ) { |
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Change depend param to array. |
106 | - if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) { |
|
107 | - $args['depend'] = array( $args['depend'] ); |
|
106 | + if (isset($args['depend']) && is_string($args['depend'])) { |
|
107 | + $args['depend'] = array($args['depend']); |
|
108 | 108 | } |
109 | 109 | |
110 | - $this->updates[ $args['type'] ][] = $args; |
|
110 | + $this->updates[$args['type']][] = $args; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return static |
119 | 119 | */ |
120 | 120 | static function get_instance() { |
121 | - if ( is_null( self::$instance ) ) { |
|
121 | + if (is_null(self::$instance)) { |
|
122 | 122 | self::$instance = new self(); |
123 | 123 | } |
124 | 124 | |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * Load file |
138 | 138 | */ |
139 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php'; |
|
140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
139 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php'; |
|
140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
141 | 141 | |
142 | 142 | self::$background_updater = new Give_Background_Updater(); |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Setup hooks. |
146 | 146 | */ |
147 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
148 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
149 | - add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) ); |
|
150 | - add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) ); |
|
151 | - add_action( 'admin_init', array( $this, '__redirect_admin' ) ); |
|
152 | - add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 ); |
|
153 | - add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 ); |
|
154 | - add_action( 'admin_notices', array( $this, '__show_notice' ) ); |
|
155 | - add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) ); |
|
156 | - |
|
157 | - if ( is_admin() ) { |
|
158 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
159 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
147 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
148 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
149 | + add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info')); |
|
150 | + add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating')); |
|
151 | + add_action('admin_init', array($this, '__redirect_admin')); |
|
152 | + add_action('admin_init', array($this, '__pause_db_update'), - 1); |
|
153 | + add_action('admin_init', array($this, '__restart_db_update'), - 1); |
|
154 | + add_action('admin_notices', array($this, '__show_notice')); |
|
155 | + add_action('give_restart_db_upgrade', array($this, '__health_background_update')); |
|
156 | + |
|
157 | + if (is_admin()) { |
|
158 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
159 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $addons = give_get_plugins(); |
171 | 171 | $plugin_updates = get_plugin_updates(); |
172 | 172 | |
173 | - foreach ( $addons as $key => $info ) { |
|
174 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
173 | + foreach ($addons as $key => $info) { |
|
174 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | |
178 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
178 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | */ |
189 | 189 | public function __register_upgrade() { |
190 | - if ( ! is_admin() ) { |
|
190 | + if ( ! is_admin()) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @since 1.8.12 |
198 | 198 | */ |
199 | - do_action( 'give_register_updates', $this ); |
|
199 | + do_action('give_register_updates', $this); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -209,23 +209,22 @@ discard block |
||
209 | 209 | global $menu; |
210 | 210 | |
211 | 211 | // Bailout. |
212 | - if ( empty( $menu ) || ! $this->get_total_update_count() ) { |
|
212 | + if (empty($menu) || ! $this->get_total_update_count()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
216 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
217 | 217 | |
218 | - foreach ( $menu as $index => $menu_item ) { |
|
219 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
218 | + foreach ($menu as $index => $menu_item) { |
|
219 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | - $menu[ $index ][0] = sprintf( |
|
223 | + $menu[$index][0] = sprintf( |
|
224 | 224 | '%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>', |
225 | - __( 'Donations', 'give' ), |
|
225 | + __('Donations', 'give'), |
|
226 | 226 | $is_update ? |
227 | - $this->get_db_update_processing_percentage() : |
|
228 | - $this->get_total_update_count(), |
|
227 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
229 | 228 | $is_update ? '%' : '' |
230 | 229 | ); |
231 | 230 | |
@@ -241,7 +240,7 @@ discard block |
||
241 | 240 | */ |
242 | 241 | public function __register_menu() { |
243 | 242 | // Bailout. |
244 | - if ( ! give_test_ajax_works() ) { |
|
243 | + if ( ! give_test_ajax_works()) { |
|
245 | 244 | return; |
246 | 245 | } |
247 | 246 | |
@@ -249,41 +248,40 @@ discard block |
||
249 | 248 | $this->__register_plugin_addon_updates(); |
250 | 249 | |
251 | 250 | // Bailout. |
252 | - if ( ! $this->get_total_update_count() ) { |
|
251 | + if ( ! $this->get_total_update_count()) { |
|
253 | 252 | // Show complete update message if still on update setting page. |
254 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
253 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
255 | 254 | // Upgrades |
256 | 255 | add_submenu_page( |
257 | 256 | 'edit.php?post_type=give_forms', |
258 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
259 | - __( 'Updates', 'give' ), |
|
257 | + esc_html__('Give Updates Complete', 'give'), |
|
258 | + __('Updates', 'give'), |
|
260 | 259 | 'manage_give_settings', |
261 | 260 | 'give-updates', |
262 | - array( $this, 'render_complete_page' ) |
|
261 | + array($this, 'render_complete_page') |
|
263 | 262 | ); |
264 | 263 | } |
265 | 264 | |
266 | 265 | return; |
267 | 266 | } |
268 | 267 | |
269 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
268 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
270 | 269 | |
271 | 270 | // Upgrades |
272 | 271 | add_submenu_page( |
273 | 272 | 'edit.php?post_type=give_forms', |
274 | - esc_html__( 'Give Updates', 'give' ), |
|
273 | + esc_html__('Give Updates', 'give'), |
|
275 | 274 | sprintf( |
276 | 275 | '%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>', |
277 | - __( 'Updates', 'give' ), |
|
278 | - isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '', |
|
276 | + __('Updates', 'give'), |
|
277 | + isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '', |
|
279 | 278 | $is_update ? |
280 | - $this->get_db_update_processing_percentage() : |
|
281 | - $this->get_total_update_count(), |
|
279 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
282 | 280 | $is_update ? '%' : '' |
283 | 281 | ), |
284 | 282 | 'manage_give_settings', |
285 | 283 | 'give-updates', |
286 | - array( $this, 'render_page' ) |
|
284 | + array($this, 'render_page') |
|
287 | 285 | ); |
288 | 286 | } |
289 | 287 | |
@@ -298,13 +296,13 @@ discard block |
||
298 | 296 | // Show db upgrade completed notice. |
299 | 297 | if ( |
300 | 298 | ! wp_doing_ajax() && |
301 | - current_user_can( 'manage_give_settings' ) && |
|
302 | - get_option( 'give_show_db_upgrade_complete_notice' ) && |
|
303 | - ! isset( $_GET['give-db-update-completed'] ) |
|
299 | + current_user_can('manage_give_settings') && |
|
300 | + get_option('give_show_db_upgrade_complete_notice') && |
|
301 | + ! isset($_GET['give-db-update-completed']) |
|
304 | 302 | ) { |
305 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
303 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
306 | 304 | |
307 | - wp_redirect( add_query_arg( array( 'give-db-update-completed' => 'give_db_upgrade_completed' ) ) ); |
|
305 | + wp_redirect(add_query_arg(array('give-db-update-completed' => 'give_db_upgrade_completed'))); |
|
308 | 306 | exit(); |
309 | 307 | } |
310 | 308 | } |
@@ -320,15 +318,15 @@ discard block |
||
320 | 318 | * |
321 | 319 | * @return bool |
322 | 320 | */ |
323 | - public function __pause_db_update( $force = false ) { |
|
321 | + public function __pause_db_update($force = false) { |
|
324 | 322 | // Bailout. |
325 | 323 | if ( |
326 | 324 | ! $force && |
327 | 325 | ( |
328 | 326 | wp_doing_ajax() || |
329 | - ! isset( $_GET['page'] ) || |
|
327 | + ! isset($_GET['page']) || |
|
330 | 328 | 'give-updates' !== $_GET['page'] || |
331 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
329 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
332 | 330 | self::$background_updater->is_paused_process() |
333 | 331 | ) |
334 | 332 | |
@@ -336,13 +334,13 @@ discard block |
||
336 | 334 | return false; |
337 | 335 | } |
338 | 336 | |
339 | - delete_option( 'give_upgrade_error' ); |
|
337 | + delete_option('give_upgrade_error'); |
|
340 | 338 | |
341 | - $this->__health_background_update( $this ); |
|
339 | + $this->__health_background_update($this); |
|
342 | 340 | $batch = self::$background_updater->get_all_batch(); |
343 | 341 | |
344 | 342 | // Bailout: if batch is empty |
345 | - if ( empty( $batch->data ) ) { |
|
343 | + if (empty($batch->data)) { |
|
346 | 344 | return false; |
347 | 345 | } |
348 | 346 | |
@@ -351,25 +349,25 @@ discard block |
||
351 | 349 | |
352 | 350 | // Do not stop background process immediately if task running. |
353 | 351 | // @see Give_Background_Updater::lock_process |
354 | - if ( ! $force && self::$background_updater->is_process_running() ) { |
|
355 | - update_option( 'give_pause_upgrade', 1 ); |
|
352 | + if ( ! $force && self::$background_updater->is_process_running()) { |
|
353 | + update_option('give_pause_upgrade', 1); |
|
356 | 354 | |
357 | 355 | return true; |
358 | 356 | } |
359 | 357 | |
360 | - update_option( 'give_paused_batches', $batch, 'no' ); |
|
361 | - delete_option( $batch->key ); |
|
362 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
363 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
358 | + update_option('give_paused_batches', $batch, 'no'); |
|
359 | + delete_option($batch->key); |
|
360 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
361 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
364 | 362 | |
365 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
363 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
366 | 364 | |
367 | 365 | /** |
368 | 366 | * Fire action when pause db updates |
369 | 367 | * |
370 | 368 | * @since 2.0.1 |
371 | 369 | */ |
372 | - do_action( 'give_pause_db_upgrade', $this ); |
|
370 | + do_action('give_pause_db_upgrade', $this); |
|
373 | 371 | |
374 | 372 | return true; |
375 | 373 | } |
@@ -386,31 +384,31 @@ discard block |
||
386 | 384 | // Bailout. |
387 | 385 | if ( |
388 | 386 | wp_doing_ajax() || |
389 | - ! isset( $_GET['page'] ) || |
|
387 | + ! isset($_GET['page']) || |
|
390 | 388 | 'give-updates' !== $_GET['page'] || |
391 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
389 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
392 | 390 | ! self::$background_updater->is_paused_process() |
393 | 391 | ) { |
394 | 392 | return false; |
395 | 393 | } |
396 | 394 | |
397 | 395 | Give_Background_Updater::flush_cache(); |
398 | - $batch = get_option( 'give_paused_batches' ); |
|
396 | + $batch = get_option('give_paused_batches'); |
|
399 | 397 | |
400 | - if ( ! empty( $batch ) ) { |
|
401 | - wp_cache_delete( $batch->key, 'options' ); |
|
402 | - update_option( $batch->key, $batch->data ); |
|
398 | + if ( ! empty($batch)) { |
|
399 | + wp_cache_delete($batch->key, 'options'); |
|
400 | + update_option($batch->key, $batch->data); |
|
403 | 401 | |
404 | - delete_option( 'give_paused_batches' ); |
|
402 | + delete_option('give_paused_batches'); |
|
405 | 403 | |
406 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
404 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
407 | 405 | |
408 | 406 | |
409 | 407 | /** Fire action when restart db updates |
410 | 408 | * |
411 | 409 | * @since 2.0.1 |
412 | 410 | */ |
413 | - do_action( 'give_restart_db_upgrade', $this ); |
|
411 | + do_action('give_restart_db_upgrade', $this); |
|
414 | 412 | |
415 | 413 | self::$background_updater->dispatch(); |
416 | 414 | } |
@@ -426,53 +424,53 @@ discard block |
||
426 | 424 | * |
427 | 425 | * @param Give_Updates $give_updates |
428 | 426 | */ |
429 | - public function __health_background_update( $give_updates ) { |
|
430 | - if ( ! $this->is_doing_updates() ) { |
|
427 | + public function __health_background_update($give_updates) { |
|
428 | + if ( ! $this->is_doing_updates()) { |
|
431 | 429 | return; |
432 | 430 | } |
433 | 431 | |
434 | 432 | Give_Background_Updater::flush_cache(); |
435 | 433 | |
436 | 434 | $batch = Give_Updates::$background_updater->get_all_batch(); |
437 | - $batch_data_count = count( $batch->data ); |
|
438 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
439 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
440 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
435 | + $batch_data_count = count($batch->data); |
|
436 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
437 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
438 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
441 | 439 | $log_data = ''; |
442 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
440 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
443 | 441 | |
444 | - if ( ! empty( $doing_upgrade_args ) ) { |
|
445 | - $log_data .= 'Doing update:' . "\n"; |
|
446 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
442 | + if ( ! empty($doing_upgrade_args)) { |
|
443 | + $log_data .= 'Doing update:'."\n"; |
|
444 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
447 | 445 | } |
448 | 446 | |
449 | 447 | /** |
450 | 448 | * Add remove upgrade from batch |
451 | 449 | */ |
452 | - if ( ! empty( $batch->data ) ) { |
|
450 | + if ( ! empty($batch->data)) { |
|
453 | 451 | |
454 | - foreach ( $batch->data as $index => $update ) { |
|
455 | - $log_data = print_r( $update, true ) . "\n"; |
|
452 | + foreach ($batch->data as $index => $update) { |
|
453 | + $log_data = print_r($update, true)."\n"; |
|
456 | 454 | |
457 | - if ( ! is_callable( $update['callback'] ) ) { |
|
458 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
459 | - unset( $batch->data[ $index ] ); |
|
460 | - } elseif ( give_has_upgrade_completed( $update['id'] ) ) { |
|
461 | - $log_data .= 'Removing already completed update: ' . "{$update['id']}\n"; |
|
462 | - unset( $batch->data[ $index ] ); |
|
455 | + if ( ! is_callable($update['callback'])) { |
|
456 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
457 | + unset($batch->data[$index]); |
|
458 | + } elseif (give_has_upgrade_completed($update['id'])) { |
|
459 | + $log_data .= 'Removing already completed update: '."{$update['id']}\n"; |
|
460 | + unset($batch->data[$index]); |
|
463 | 461 | } |
464 | 462 | |
465 | - if ( ! empty( $update['depend'] ) ) { |
|
463 | + if ( ! empty($update['depend'])) { |
|
466 | 464 | |
467 | - foreach ( $update['depend'] as $depend ) { |
|
468 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
469 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
465 | + foreach ($update['depend'] as $depend) { |
|
466 | + if (give_has_upgrade_completed($depend)) { |
|
467 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
470 | 468 | continue; |
471 | 469 | } |
472 | 470 | |
473 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
474 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
475 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
471 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
472 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
473 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
476 | 474 | } |
477 | 475 | } |
478 | 476 | } |
@@ -482,52 +480,52 @@ discard block |
||
482 | 480 | /** |
483 | 481 | * Add new upgrade to batch |
484 | 482 | */ |
485 | - if ( $new_updates = $this->get_updates( 'database', 'new' ) ) { |
|
486 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
483 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
484 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
487 | 485 | |
488 | - foreach ( $new_updates as $index => $new_update ) { |
|
489 | - if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
490 | - unset( $new_updates[ $index ] ); |
|
486 | + foreach ($new_updates as $index => $new_update) { |
|
487 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
488 | + unset($new_updates[$index]); |
|
491 | 489 | } |
492 | 490 | } |
493 | 491 | |
494 | - if ( ! empty( $new_updates ) ) { |
|
495 | - $log_data .= 'Adding new update: ' . "\n"; |
|
496 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
492 | + if ( ! empty($new_updates)) { |
|
493 | + $log_data .= 'Adding new update: '."\n"; |
|
494 | + $log_data .= print_r($new_updates, true)."\n"; |
|
497 | 495 | |
498 | - $batch->data = array_merge( (array) $batch->data, $new_updates ); |
|
499 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) ); |
|
496 | + $batch->data = array_merge((array) $batch->data, $new_updates); |
|
497 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates))); |
|
500 | 498 | } |
501 | 499 | } |
502 | 500 | |
503 | 501 | /** |
504 | 502 | * Fix batch |
505 | 503 | */ |
506 | - if ( empty( $batch->data ) ) { |
|
504 | + if (empty($batch->data)) { |
|
507 | 505 | // Complete batch if do not have any data to process. |
508 | - self::$background_updater->delete( $batch->key ); |
|
506 | + self::$background_updater->delete($batch->key); |
|
509 | 507 | |
510 | - if ( self::$background_updater->has_queue() ) { |
|
511 | - $this->__health_background_update( $this ); |
|
508 | + if (self::$background_updater->has_queue()) { |
|
509 | + $this->__health_background_update($this); |
|
512 | 510 | } else { |
513 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
514 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
511 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
512 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
515 | 513 | |
516 | 514 | self::$background_updater->complete(); |
517 | 515 | } |
518 | 516 | |
519 | - } elseif ( $batch_data_count !== count( $batch->data ) ) { |
|
517 | + } elseif ($batch_data_count !== count($batch->data)) { |
|
520 | 518 | |
521 | - $log_data .= 'Updating batch' . "\n"; |
|
522 | - $log_data .= print_r( $batch, true ); |
|
519 | + $log_data .= 'Updating batch'."\n"; |
|
520 | + $log_data .= print_r($batch, true); |
|
523 | 521 | |
524 | - if ( ! empty( $batch->key ) ) { |
|
525 | - wp_cache_delete( $batch->key, 'options' ); |
|
526 | - update_option( $batch->key, $batch->data ); |
|
522 | + if ( ! empty($batch->key)) { |
|
523 | + wp_cache_delete($batch->key, 'options'); |
|
524 | + update_option($batch->key, $batch->data); |
|
527 | 525 | } else { |
528 | 526 | |
529 | - foreach ( $batch->data as $data ) { |
|
530 | - Give_Updates::$background_updater->push_to_queue( $data ); |
|
527 | + foreach ($batch->data as $data) { |
|
528 | + Give_Updates::$background_updater->push_to_queue($data); |
|
531 | 529 | } |
532 | 530 | |
533 | 531 | Give_Updates::$background_updater->save(); |
@@ -538,25 +536,25 @@ discard block |
||
538 | 536 | /** |
539 | 537 | * Fix give_doing_upgrade option |
540 | 538 | */ |
541 | - $fresh_new_db_count = $this->get_total_new_db_update_count( true ); |
|
539 | + $fresh_new_db_count = $this->get_total_new_db_update_count(true); |
|
542 | 540 | |
543 | - update_option( 'give_db_update_count', $fresh_new_db_count ); |
|
541 | + update_option('give_db_update_count', $fresh_new_db_count); |
|
544 | 542 | |
545 | 543 | $doing_upgrade_args['update'] = 1; |
546 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count ); |
|
547 | - $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true ); |
|
544 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count); |
|
545 | + $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true); |
|
548 | 546 | |
549 | 547 | // Remove already completed update from info. |
550 | - if ( give_has_upgrade_completed( $doing_upgrade_args['update_info']['id'] ) ) { |
|
551 | - $doing_upgrade_args['update_info'] = current( array_values( $batch->data ) ); |
|
548 | + if (give_has_upgrade_completed($doing_upgrade_args['update_info']['id'])) { |
|
549 | + $doing_upgrade_args['update_info'] = current(array_values($batch->data)); |
|
552 | 550 | $doing_upgrade_args['step'] = 1; |
553 | 551 | } |
554 | 552 | |
555 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
553 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
556 | 554 | |
557 | - $log_data .= 'Updated doing update:' . "\n"; |
|
558 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
559 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
555 | + $log_data .= 'Updated doing update:'."\n"; |
|
556 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
557 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
560 | 558 | } |
561 | 559 | |
562 | 560 | |
@@ -568,66 +566,66 @@ discard block |
||
568 | 566 | */ |
569 | 567 | public function __show_notice() { |
570 | 568 | // Bailout. |
571 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
569 | + if ( ! current_user_can('manage_give_settings')) { |
|
572 | 570 | return; |
573 | 571 | } |
574 | 572 | |
575 | 573 | // Run DB updates. |
576 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
574 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
577 | 575 | $this->run_db_update(); |
578 | 576 | } |
579 | 577 | |
580 | 578 | |
581 | 579 | // Bailout. |
582 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
580 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
583 | 581 | return; |
584 | 582 | } |
585 | 583 | |
586 | 584 | // Show notice if upgrade paused. |
587 | - if ( self::$background_updater->is_paused_process() ) { |
|
585 | + if (self::$background_updater->is_paused_process()) { |
|
588 | 586 | ob_start(); |
589 | 587 | |
590 | - $upgrade_error = get_option( 'give_upgrade_error' ); |
|
591 | - if ( ! $upgrade_error ) : ?> |
|
592 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
593 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?> |
|
588 | + $upgrade_error = get_option('give_upgrade_error'); |
|
589 | + if ( ! $upgrade_error) : ?> |
|
590 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
591 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?> |
|
594 | 592 | <br> |
595 | 593 | <br> |
596 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
|
597 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
594 | + <a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn"> |
|
595 | + <?php _e('Restart the updater', 'give'); ?> |
|
598 | 596 | </a> |
599 | 597 | <script type="text/javascript"> |
600 | 598 | jQuery('.give-restart-updater-btn').click('click', function () { |
601 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
599 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
602 | 600 | }); |
603 | 601 | </script> |
604 | 602 | <?php else: ?> |
605 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
606 | - – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
603 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
604 | + – <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
607 | 605 | <?php |
608 | 606 | endif; |
609 | 607 | $desc_html = ob_get_clean(); |
610 | 608 | |
611 | - Give()->notices->register_notice( array( |
|
609 | + Give()->notices->register_notice(array( |
|
612 | 610 | 'id' => 'give_upgrade_db', |
613 | 611 | 'type' => 'error', |
614 | 612 | 'dismissible' => false, |
615 | 613 | 'description' => $desc_html, |
616 | - ) ); |
|
614 | + )); |
|
617 | 615 | } |
618 | 616 | |
619 | 617 | // Bailout if doing upgrades. |
620 | - if ( $this->is_doing_updates() ) { |
|
618 | + if ($this->is_doing_updates()) { |
|
621 | 619 | return; |
622 | 620 | } |
623 | 621 | |
624 | 622 | // Show notice if ajax is not working. |
625 | - if ( ! give_test_ajax_works() ) { |
|
623 | + if ( ! give_test_ajax_works()) { |
|
626 | 624 | Give()->notices->register_notice( |
627 | 625 | array( |
628 | 626 | 'id' => 'give_db_upgrade_ajax_inaccessible', |
629 | 627 | 'type' => 'error', |
630 | - 'description' => sprintf( '%1$s <a href="%2$s" target="_blank">%3$s</a>', __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), 'http://docs.givewp.com/admin-ajax-error', __( 'Read More', 'give' ) . ' »' ), |
|
628 | + 'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a>', __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), 'http://docs.givewp.com/admin-ajax-error', __('Read More', 'give').' »'), |
|
631 | 629 | 'show' => true, |
632 | 630 | ) |
633 | 631 | ); |
@@ -636,45 +634,45 @@ discard block |
||
636 | 634 | } |
637 | 635 | |
638 | 636 | // Show db upgrade completed notice. |
639 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
640 | - Give()->notices->register_notice( array( |
|
637 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
638 | + Give()->notices->register_notice(array( |
|
641 | 639 | 'id' => 'give_db_upgrade_completed', |
642 | 640 | 'type' => 'updated', |
643 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
641 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
644 | 642 | 'show' => true, |
645 | - ) ); |
|
643 | + )); |
|
646 | 644 | |
647 | 645 | // Start update. |
648 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
646 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
649 | 647 | $this->run_db_update(); |
650 | 648 | |
651 | 649 | // Show run the update notice. |
652 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
650 | + } elseif ($this->get_total_new_db_update_count()) { |
|
653 | 651 | ob_start(); |
654 | 652 | ?> |
655 | 653 | <p> |
656 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
657 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?> |
|
654 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
655 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?> |
|
658 | 656 | </p> |
659 | 657 | <p class="submit"> |
660 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now"> |
|
661 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
658 | + <a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now"> |
|
659 | + <?php _e('Run the updater', 'give'); ?> |
|
662 | 660 | </a> |
663 | 661 | </p> |
664 | 662 | <script type="text/javascript"> |
665 | 663 | jQuery('.give-run-update-now').click('click', function () { |
666 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
664 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
667 | 665 | }); |
668 | 666 | </script> |
669 | 667 | <?php |
670 | 668 | $desc_html = ob_get_clean(); |
671 | 669 | |
672 | - Give()->notices->register_notice( array( |
|
670 | + Give()->notices->register_notice(array( |
|
673 | 671 | 'id' => 'give_upgrade_db', |
674 | 672 | 'type' => 'updated', |
675 | 673 | 'dismissible' => false, |
676 | 674 | 'description' => $desc_html, |
677 | - ) ); |
|
675 | + )); |
|
678 | 676 | } |
679 | 677 | } |
680 | 678 | |
@@ -685,7 +683,7 @@ discard block |
||
685 | 683 | * @access public |
686 | 684 | */ |
687 | 685 | public function render_complete_page() { |
688 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
686 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
689 | 687 | } |
690 | 688 | |
691 | 689 | /** |
@@ -695,7 +693,7 @@ discard block |
||
695 | 693 | * @access public |
696 | 694 | */ |
697 | 695 | public function render_page() { |
698 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
696 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
699 | 697 | } |
700 | 698 | |
701 | 699 | /** |
@@ -706,26 +704,26 @@ discard block |
||
706 | 704 | */ |
707 | 705 | private function run_db_update() { |
708 | 706 | // Bailout. |
709 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
707 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
710 | 708 | return; |
711 | 709 | } |
712 | 710 | |
713 | - $updates = $this->get_updates( 'database', 'new' ); |
|
711 | + $updates = $this->get_updates('database', 'new'); |
|
714 | 712 | |
715 | - foreach ( $updates as $update ) { |
|
716 | - self::$background_updater->push_to_queue( $update ); |
|
713 | + foreach ($updates as $update) { |
|
714 | + self::$background_updater->push_to_queue($update); |
|
717 | 715 | } |
718 | 716 | |
719 | - add_option( 'give_db_update_count', count( $updates ), '', 'no' ); |
|
717 | + add_option('give_db_update_count', count($updates), '', 'no'); |
|
720 | 718 | |
721 | - add_option( 'give_doing_upgrade', array( |
|
719 | + add_option('give_doing_upgrade', array( |
|
722 | 720 | 'update_info' => $updates[0], |
723 | 721 | 'step' => 1, |
724 | 722 | 'update' => 1, |
725 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
723 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
726 | 724 | 'percentage' => 0, |
727 | 725 | 'total_percentage' => 0, |
728 | - ), '', 'no' ); |
|
726 | + ), '', 'no'); |
|
729 | 727 | |
730 | 728 | self::$background_updater->save()->dispatch(); |
731 | 729 | } |
@@ -739,14 +737,13 @@ discard block |
||
739 | 737 | */ |
740 | 738 | public function __flush_resume_updates() { |
741 | 739 | //delete_option( 'give_doing_upgrade' ); |
742 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
740 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
743 | 741 | |
744 | 742 | // Reset counter. |
745 | 743 | $this->step = $this->percentage = 0; |
746 | 744 | |
747 | - $this->update = ( $this->get_total_db_update_count() > $this->update ) ? |
|
748 | - ( $this->update + 1 ) : |
|
749 | - $this->update; |
|
745 | + $this->update = ($this->get_total_db_update_count() > $this->update) ? |
|
746 | + ($this->update + 1) : $this->update; |
|
750 | 747 | } |
751 | 748 | |
752 | 749 | |
@@ -761,7 +758,7 @@ discard block |
||
761 | 758 | public function __give_start_updating() { |
762 | 759 | // Check permission. |
763 | 760 | if ( |
764 | - ! current_user_can( 'manage_give_settings' ) || |
|
761 | + ! current_user_can('manage_give_settings') || |
|
765 | 762 | $this->is_doing_updates() |
766 | 763 | ) { |
767 | 764 | wp_send_json_error(); |
@@ -769,7 +766,7 @@ discard block |
||
769 | 766 | |
770 | 767 | // @todo: validate nonce |
771 | 768 | // @todo: set http method to post |
772 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
769 | + if (empty($_POST['run_db_update'])) { |
|
773 | 770 | wp_send_json_error(); |
774 | 771 | } |
775 | 772 | |
@@ -788,34 +785,34 @@ discard block |
||
788 | 785 | * @return string |
789 | 786 | */ |
790 | 787 | public function __give_db_updates_info() { |
791 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
788 | + $update_info = get_option('give_doing_upgrade'); |
|
792 | 789 | $response_type = ''; |
793 | 790 | |
794 | - if ( self::$background_updater->is_paused_process() ) { |
|
791 | + if (self::$background_updater->is_paused_process()) { |
|
795 | 792 | $update_info = array( |
796 | - 'message' => __( 'The updates have been paused.', 'give' ), |
|
797 | - 'heading' => __( '', 'give' ), |
|
793 | + 'message' => __('The updates have been paused.', 'give'), |
|
794 | + 'heading' => __('', 'give'), |
|
798 | 795 | 'percentage' => 0, |
799 | 796 | ); |
800 | 797 | |
801 | - if ( get_option( 'give_upgrade_error' ) ) { |
|
802 | - $update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); |
|
798 | + if (get_option('give_upgrade_error')) { |
|
799 | + $update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); |
|
803 | 800 | } |
804 | 801 | |
805 | 802 | $response_type = 'error'; |
806 | 803 | |
807 | - } elseif ( empty( $update_info ) ) { |
|
804 | + } elseif (empty($update_info)) { |
|
808 | 805 | $update_info = array( |
809 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
810 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
806 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
807 | + 'heading' => __('Updates Completed.', 'give'), |
|
811 | 808 | 'percentage' => 0, |
812 | 809 | ); |
813 | 810 | $response_type = 'success'; |
814 | 811 | |
815 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
812 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
816 | 813 | } |
817 | 814 | |
818 | - $this->send_ajax_response( $update_info, $response_type ); |
|
815 | + $this->send_ajax_response($update_info, $response_type); |
|
819 | 816 | } |
820 | 817 | |
821 | 818 | /** |
@@ -827,7 +824,7 @@ discard block |
||
827 | 824 | * @param $data |
828 | 825 | * @param string $type |
829 | 826 | */ |
830 | - public function send_ajax_response( $data, $type = '' ) { |
|
827 | + public function send_ajax_response($data, $type = '') { |
|
831 | 828 | $default = array( |
832 | 829 | 'message' => '', |
833 | 830 | 'heading' => '', |
@@ -837,24 +834,24 @@ discard block |
||
837 | 834 | ); |
838 | 835 | |
839 | 836 | // Set data. |
840 | - $data = wp_parse_args( $data, $default ); |
|
837 | + $data = wp_parse_args($data, $default); |
|
841 | 838 | |
842 | 839 | // Enable cache. |
843 | 840 | Give_Cache::enable(); |
844 | 841 | |
845 | - switch ( $type ) { |
|
842 | + switch ($type) { |
|
846 | 843 | case 'success': |
847 | - wp_send_json_success( $data ); |
|
844 | + wp_send_json_success($data); |
|
848 | 845 | break; |
849 | 846 | |
850 | 847 | case 'error': |
851 | - wp_send_json_error( $data ); |
|
848 | + wp_send_json_error($data); |
|
852 | 849 | break; |
853 | 850 | |
854 | 851 | default: |
855 | - wp_send_json( array( |
|
852 | + wp_send_json(array( |
|
856 | 853 | 'data' => $data, |
857 | - ) ); |
|
854 | + )); |
|
858 | 855 | break; |
859 | 856 | } |
860 | 857 | } |
@@ -868,12 +865,12 @@ discard block |
||
868 | 865 | * @param $total |
869 | 866 | * @param $current_total |
870 | 867 | */ |
871 | - public function set_percentage( $total, $current_total ) { |
|
868 | + public function set_percentage($total, $current_total) { |
|
872 | 869 | // Set percentage. |
873 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
870 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
874 | 871 | |
875 | 872 | // Verify percentage. |
876 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
873 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
877 | 874 | } |
878 | 875 | |
879 | 876 | /** |
@@ -886,22 +883,22 @@ discard block |
||
886 | 883 | * |
887 | 884 | * @return bool|null |
888 | 885 | */ |
889 | - public function is_parent_updates_completed( $update ) { |
|
886 | + public function is_parent_updates_completed($update) { |
|
890 | 887 | // Bailout. |
891 | - if ( empty( $update['depend'] ) ) { |
|
888 | + if (empty($update['depend'])) { |
|
892 | 889 | return true; |
893 | 890 | } |
894 | 891 | |
895 | 892 | // Check if dependency is valid or not. |
896 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
893 | + if ( ! $this->has_valid_dependency($update)) { |
|
897 | 894 | return null; |
898 | 895 | } |
899 | 896 | |
900 | 897 | $is_dependency_completed = true; |
901 | 898 | |
902 | - foreach ( $update['depend'] as $depend ) { |
|
899 | + foreach ($update['depend'] as $depend) { |
|
903 | 900 | |
904 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
901 | + if ( ! give_has_upgrade_completed($depend)) { |
|
905 | 902 | $is_dependency_completed = false; |
906 | 903 | break; |
907 | 904 | } |
@@ -918,7 +915,7 @@ discard block |
||
918 | 915 | * @return bool |
919 | 916 | */ |
920 | 917 | public function is_doing_updates() { |
921 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
918 | + return (bool) get_option('give_doing_upgrade'); |
|
922 | 919 | } |
923 | 920 | |
924 | 921 | |
@@ -932,7 +929,7 @@ discard block |
||
932 | 929 | * |
933 | 930 | * @return bool |
934 | 931 | */ |
935 | - public function has_valid_dependency( $update ) { |
|
932 | + public function has_valid_dependency($update) { |
|
936 | 933 | $is_valid_dependency = true; |
937 | 934 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
938 | 935 | // |
@@ -958,33 +955,33 @@ discard block |
||
958 | 955 | * |
959 | 956 | * @return array |
960 | 957 | */ |
961 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
958 | + public function get_updates($update_type = '', $status = 'all') { |
|
962 | 959 | // return all updates. |
963 | - if ( empty( $update_type ) ) { |
|
960 | + if (empty($update_type)) { |
|
964 | 961 | return $this->updates; |
965 | 962 | } |
966 | 963 | |
967 | 964 | // Get specific update. |
968 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
965 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
969 | 966 | |
970 | 967 | // Bailout. |
971 | - if ( empty( $updates ) ) { |
|
968 | + if (empty($updates)) { |
|
972 | 969 | return $updates; |
973 | 970 | } |
974 | 971 | |
975 | - switch ( $status ) { |
|
972 | + switch ($status) { |
|
976 | 973 | case 'new': |
977 | 974 | // Remove already completed updates. |
978 | - wp_cache_delete( 'give_completed_upgrades', 'options' ); |
|
975 | + wp_cache_delete('give_completed_upgrades', 'options'); |
|
979 | 976 | $completed_updates = give_get_completed_upgrades(); |
980 | 977 | |
981 | - if ( ! empty( $completed_updates ) ) { |
|
982 | - foreach ( $updates as $index => $update ) { |
|
983 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
984 | - unset( $updates[ $index ] ); |
|
978 | + if ( ! empty($completed_updates)) { |
|
979 | + foreach ($updates as $index => $update) { |
|
980 | + if (in_array($update['id'], $completed_updates)) { |
|
981 | + unset($updates[$index]); |
|
985 | 982 | } |
986 | 983 | } |
987 | - $updates = array_values( $updates ); |
|
984 | + $updates = array_values($updates); |
|
988 | 985 | } |
989 | 986 | |
990 | 987 | break; |
@@ -1001,7 +998,7 @@ discard block |
||
1001 | 998 | * @return int |
1002 | 999 | */ |
1003 | 1000 | public function get_total_plugin_update_count() { |
1004 | - return count( $this->get_updates( 'plugin' ) ); |
|
1001 | + return count($this->get_updates('plugin')); |
|
1005 | 1002 | } |
1006 | 1003 | |
1007 | 1004 | /** |
@@ -1016,7 +1013,7 @@ discard block |
||
1016 | 1013 | $db_update_count = $this->get_pending_db_update_count(); |
1017 | 1014 | $plugin_update_count = $this->get_total_plugin_update_count(); |
1018 | 1015 | |
1019 | - return ( $db_update_count + $plugin_update_count ); |
|
1016 | + return ($db_update_count + $plugin_update_count); |
|
1020 | 1017 | } |
1021 | 1018 | |
1022 | 1019 | /** |
@@ -1028,7 +1025,7 @@ discard block |
||
1028 | 1025 | * @return int |
1029 | 1026 | */ |
1030 | 1027 | public function get_pending_db_update_count() { |
1031 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
1028 | + return count($this->get_updates('database', 'new')); |
|
1032 | 1029 | } |
1033 | 1030 | |
1034 | 1031 | /** |
@@ -1040,7 +1037,7 @@ discard block |
||
1040 | 1037 | * @return int |
1041 | 1038 | */ |
1042 | 1039 | public function get_total_db_update_count() { |
1043 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
1040 | + return count($this->get_updates('database', 'all')); |
|
1044 | 1041 | } |
1045 | 1042 | |
1046 | 1043 | /** |
@@ -1053,10 +1050,9 @@ discard block |
||
1053 | 1050 | * |
1054 | 1051 | * @return int |
1055 | 1052 | */ |
1056 | - public function get_total_new_db_update_count( $refresh = false ) { |
|
1053 | + public function get_total_new_db_update_count($refresh = false) { |
|
1057 | 1054 | $update_count = $this->is_doing_updates() && ! $refresh ? |
1058 | - get_option( 'give_db_update_count' ) : |
|
1059 | - $this->get_pending_db_update_count(); |
|
1055 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
1060 | 1056 | |
1061 | 1057 | return $update_count; |
1062 | 1058 | } |
@@ -1071,11 +1067,11 @@ discard block |
||
1071 | 1067 | * |
1072 | 1068 | * @return int |
1073 | 1069 | */ |
1074 | - public function get_running_db_update( $refresh = false ) { |
|
1070 | + public function get_running_db_update($refresh = false) { |
|
1075 | 1071 | $current_update = 1; |
1076 | 1072 | |
1077 | - if ( $this->is_doing_updates() && ! $refresh ) { |
|
1078 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
1073 | + if ($this->is_doing_updates() && ! $refresh) { |
|
1074 | + $current_update = get_option('give_doing_upgrade'); |
|
1079 | 1075 | $current_update = $current_update['update']; |
1080 | 1076 | } |
1081 | 1077 | |
@@ -1092,25 +1088,23 @@ discard block |
||
1092 | 1088 | * |
1093 | 1089 | * @return float|int |
1094 | 1090 | */ |
1095 | - public function get_db_update_processing_percentage( $refresh = false ) { |
|
1091 | + public function get_db_update_processing_percentage($refresh = false) { |
|
1096 | 1092 | // Bailout. |
1097 | - if ( ! $this->get_total_new_db_update_count( $refresh ) ) { |
|
1093 | + if ( ! $this->get_total_new_db_update_count($refresh)) { |
|
1098 | 1094 | return 0; |
1099 | 1095 | } |
1100 | 1096 | |
1101 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
1102 | - $update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100; |
|
1103 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
1104 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
1097 | + $resume_update = get_option('give_doing_upgrade'); |
|
1098 | + $update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100; |
|
1099 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
1100 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
1105 | 1101 | |
1106 | 1102 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
1107 | 1103 | |
1108 | 1104 | return $this->is_doing_updates() ? |
1109 | - ( absint( $final_percentage ) ? |
|
1110 | - absint( $final_percentage ) : |
|
1111 | - round( $final_percentage, 2 ) |
|
1112 | - ) : |
|
1113 | - 0; |
|
1105 | + (absint($final_percentage) ? |
|
1106 | + absint($final_percentage) : round($final_percentage, 2) |
|
1107 | + ) : 0; |
|
1114 | 1108 | } |
1115 | 1109 | |
1116 | 1110 | |
@@ -1122,8 +1116,8 @@ discard block |
||
1122 | 1116 | * @return array |
1123 | 1117 | */ |
1124 | 1118 | public function get_update_ids() { |
1125 | - $all_updates = $this->get_updates( 'database', 'all' ); |
|
1126 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
1119 | + $all_updates = $this->get_updates('database', 'all'); |
|
1120 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
1127 | 1121 | |
1128 | 1122 | return $all_update_ids; |
1129 | 1123 | } |
@@ -1138,10 +1132,9 @@ discard block |
||
1138 | 1132 | * |
1139 | 1133 | * @return float|int |
1140 | 1134 | */ |
1141 | - public function get_offset( $process_item_count ) { |
|
1142 | - return ( 1 === $this->step ) ? |
|
1143 | - 0 : |
|
1144 | - ( $this->step - 1 ) * $process_item_count; |
|
1135 | + public function get_offset($process_item_count) { |
|
1136 | + return (1 === $this->step) ? |
|
1137 | + 0 : ($this->step - 1) * $process_item_count; |
|
1145 | 1138 | } |
1146 | 1139 | } |
1147 | 1140 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Exports |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if ( ! defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } ?> |
9 | 9 | |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @since 1.0 |
20 | 20 | */ |
21 | - do_action( 'give_tools_tab_export_content_top' ); |
|
21 | + do_action('give_tools_tab_export_content_top'); |
|
22 | 22 | ?> |
23 | 23 | |
24 | 24 | <table class="widefat export-options-table give-table striped"> |
25 | 25 | <thead> |
26 | 26 | <tr> |
27 | - <th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th> |
|
28 | - <th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th> |
|
27 | + <th scope="col"><?php esc_html_e('Export Type', 'give'); ?></th> |
|
28 | + <th scope="col"><?php esc_html_e('Export Options', 'give'); ?></th> |
|
29 | 29 | </tr> |
30 | 30 | </thead> |
31 | 31 | <tbody> |
@@ -38,42 +38,42 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @since 1.0 |
40 | 40 | */ |
41 | - do_action( 'give_tools_tab_export_table_top' ); |
|
41 | + do_action('give_tools_tab_export_table_top'); |
|
42 | 42 | ?> |
43 | 43 | <tr class="give-export-pdf-sales-earnings"> |
44 | 44 | <td scope="row" class="row-title"> |
45 | 45 | <h3> |
46 | - <span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span> |
|
46 | + <span><?php esc_html_e('Export PDF of Donations and Income', 'give'); ?></span> |
|
47 | 47 | </h3> |
48 | - <p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p> |
|
48 | + <p><?php esc_html_e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p> |
|
49 | 49 | </td> |
50 | 50 | <td> |
51 | - <a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>"> |
|
52 | - <?php esc_html_e( 'Generate PDF', 'give' ); ?> |
|
51 | + <a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?>"> |
|
52 | + <?php esc_html_e('Generate PDF', 'give'); ?> |
|
53 | 53 | </a> |
54 | 54 | </td> |
55 | 55 | </tr> |
56 | 56 | <tr class="give-export-sales-earnings"> |
57 | 57 | <td scope="row" class="row-title"> |
58 | 58 | <h3> |
59 | - <span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span> |
|
59 | + <span><?php esc_html_e('Export Income and Donation Stats', 'give'); ?></span> |
|
60 | 60 | </h3> |
61 | - <p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p> |
|
61 | + <p><?php esc_html_e('Download a CSV of income and donations over time.', 'give'); ?></p> |
|
62 | 62 | </td> |
63 | 63 | <td> |
64 | 64 | <form method="post"> |
65 | 65 | <?php |
66 | 66 | printf( |
67 | 67 | /* translators: 1: start date dropdown 2: end date dropdown */ |
68 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
69 | - Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ), |
|
70 | - Give()->html->year_dropdown( 'end_year' ) . ' ' . Give()->html->month_dropdown( 'end_month' ) |
|
68 | + esc_html__('%1$s to %2$s', 'give'), |
|
69 | + Give()->html->year_dropdown('start_year').' '.Give()->html->month_dropdown('start_month'), |
|
70 | + Give()->html->year_dropdown('end_year').' '.Give()->html->month_dropdown('end_month') |
|
71 | 71 | ); |
72 | 72 | ?> |
73 | 73 | <input type="hidden" name="give-action" |
74 | 74 | value="earnings_export"/> |
75 | 75 | <input type="submit" |
76 | - value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" |
|
76 | + value="<?php esc_attr_e('Generate CSV', 'give'); ?>" |
|
77 | 77 | class="button-secondary"/> |
78 | 78 | </form> |
79 | 79 | </td> |
@@ -81,37 +81,37 @@ discard block |
||
81 | 81 | <tr class="give-export-payment-history"> |
82 | 82 | <td scope="row" class="row-title"> |
83 | 83 | <h3> |
84 | - <span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span> |
|
84 | + <span><?php esc_html_e('Export Donation History', 'give'); ?></span> |
|
85 | 85 | </h3> |
86 | - <p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
|
86 | + <p><?php esc_html_e('Download a CSV of all donations recorded.', 'give'); ?></p> |
|
87 | 87 | </td> |
88 | 88 | <td> |
89 | 89 | <form id="give-export-payments" |
90 | 90 | class="give-export-form" method="post"> |
91 | 91 | <?php |
92 | - echo Give()->html->date_field( array( |
|
92 | + echo Give()->html->date_field(array( |
|
93 | 93 | 'id' => 'give-payment-export-start', |
94 | 94 | 'name' => 'start', |
95 | - 'placeholder' => esc_attr__( 'Start date', 'give' ), |
|
96 | - ) ); |
|
95 | + 'placeholder' => esc_attr__('Start date', 'give'), |
|
96 | + )); |
|
97 | 97 | |
98 | - echo Give()->html->date_field( array( |
|
98 | + echo Give()->html->date_field(array( |
|
99 | 99 | 'id' => 'give-payment-export-end', |
100 | 100 | 'name' => 'end', |
101 | - 'placeholder' => esc_attr__( 'End date', 'give' ), |
|
102 | - ) ); |
|
101 | + 'placeholder' => esc_attr__('End date', 'give'), |
|
102 | + )); |
|
103 | 103 | ?> |
104 | 104 | <select name="status"> |
105 | - <option value="any"><?php esc_html_e( 'All Statuses', 'give' ); ?></option> |
|
105 | + <option value="any"><?php esc_html_e('All Statuses', 'give'); ?></option> |
|
106 | 106 | <?php |
107 | 107 | $statuses = give_get_payment_statuses(); |
108 | - foreach ( $statuses as $status => $label ) { |
|
109 | - echo '<option value="' . $status . '">' . $label . '</option>'; |
|
108 | + foreach ($statuses as $status => $label) { |
|
109 | + echo '<option value="'.$status.'">'.$label.'</option>'; |
|
110 | 110 | } |
111 | 111 | ?> |
112 | 112 | </select> |
113 | 113 | <?php |
114 | - if ( give_is_setting_enabled( give_get_option( 'categories' ) ) ) { |
|
114 | + if (give_is_setting_enabled(give_get_option('categories'))) { |
|
115 | 115 | echo Give()->html->category_dropdown( |
116 | 116 | 'give_forms_categories[]', |
117 | 117 | 0, |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | 'multiple' => true, |
122 | 122 | 'selected' => array(), |
123 | 123 | 'show_option_all' => false, |
124 | - 'placeholder' => __( 'Choose one or more from categories', 'give' ), |
|
124 | + 'placeholder' => __('Choose one or more from categories', 'give'), |
|
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | } |
128 | 128 | |
129 | - if ( give_is_setting_enabled( give_get_option( 'tags' ) ) ) { |
|
129 | + if (give_is_setting_enabled(give_get_option('tags'))) { |
|
130 | 130 | echo Give()->html->tags_dropdown( |
131 | 131 | 'give_forms_tags[]', |
132 | 132 | 0, |
@@ -136,18 +136,18 @@ discard block |
||
136 | 136 | 'multiple' => true, |
137 | 137 | 'selected' => array(), |
138 | 138 | 'show_option_all' => false, |
139 | - 'placeholder' => __( 'Choose one or more from tags', 'give' ), |
|
139 | + 'placeholder' => __('Choose one or more from tags', 'give'), |
|
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | } |
143 | 143 | |
144 | - wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); |
|
144 | + wp_nonce_field('give_ajax_export', 'give_ajax_export'); |
|
145 | 145 | ?> |
146 | 146 | <input type="hidden" name="give-export-class" |
147 | 147 | value="Give_Batch_Payments_Export"/> |
148 | 148 | <span> |
149 | 149 | <input type="submit" |
150 | - value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" |
|
150 | + value="<?php esc_attr_e('Generate CSV', 'give'); ?>" |
|
151 | 151 | class="button-secondary"/> |
152 | 152 | <span class="spinner"></span> |
153 | 153 | </span> |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | <tr class="give-export-donors"> |
158 | 158 | <td scope="row" class="row-title"> |
159 | 159 | <h3> |
160 | - <span><?php esc_html_e( 'Export Donors in CSV', 'give' ); ?></span> |
|
160 | + <span><?php esc_html_e('Export Donors in CSV', 'give'); ?></span> |
|
161 | 161 | </h3> |
162 | - <p><?php esc_html_e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p> |
|
162 | + <p><?php esc_html_e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p> |
|
163 | 163 | </td> |
164 | 164 | <td> |
165 | 165 | <form method="post" id="give_donor_export" |
@@ -167,93 +167,93 @@ discard block |
||
167 | 167 | |
168 | 168 | <?php |
169 | 169 | // Start Date form field for donors |
170 | - echo Give()->html->date_field( array( |
|
170 | + echo Give()->html->date_field(array( |
|
171 | 171 | 'id' => 'give_donor_export_start_date', |
172 | 172 | 'name' => 'donor_export_start_date', |
173 | - 'placeholder' => esc_attr__( 'Start date', 'give' ), |
|
174 | - ) ); |
|
173 | + 'placeholder' => esc_attr__('Start date', 'give'), |
|
174 | + )); |
|
175 | 175 | |
176 | 176 | // End Date form field for donors |
177 | - echo Give()->html->date_field( array( |
|
177 | + echo Give()->html->date_field(array( |
|
178 | 178 | 'id' => 'give_donor_export_end_date', |
179 | 179 | 'name' => 'donor_export_end_date', |
180 | - 'placeholder' => esc_attr__( 'End date', 'give' ), |
|
181 | - ) ); |
|
180 | + 'placeholder' => esc_attr__('End date', 'give'), |
|
181 | + )); |
|
182 | 182 | |
183 | 183 | // Donation forms dropdown for donors export |
184 | - echo Give()->html->forms_dropdown( array( |
|
184 | + echo Give()->html->forms_dropdown(array( |
|
185 | 185 | 'name' => 'forms', |
186 | 186 | 'id' => 'give_donor_export_form', |
187 | 187 | 'chosen' => true, |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | ?> |
190 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
190 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
191 | 191 | |
192 | 192 | <div id="export-donor-options-wrap" |
193 | 193 | class="give-clearfix"> |
194 | - <p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p> |
|
194 | + <p><?php esc_html_e('Export Columns:', 'give'); ?></p> |
|
195 | 195 | <ul id="give-export-option-ul"> |
196 | 196 | <li> |
197 | 197 | <label for="give-export-fullname"> |
198 | 198 | <input type="checkbox" checked |
199 | 199 | name="give_export_option[full_name]" |
200 | - id="give-export-fullname"><?php esc_html_e( 'Name', 'give' ); ?> |
|
200 | + id="give-export-fullname"><?php esc_html_e('Name', 'give'); ?> |
|
201 | 201 | </label> |
202 | 202 | </li> |
203 | 203 | <li> |
204 | 204 | <label for="give-export-email"> |
205 | 205 | <input type="checkbox" checked |
206 | 206 | name="give_export_option[email]" |
207 | - id="give-export-email"><?php esc_html_e( 'Email', 'give' ); ?> |
|
207 | + id="give-export-email"><?php esc_html_e('Email', 'give'); ?> |
|
208 | 208 | </label> |
209 | 209 | </li> |
210 | 210 | <li> |
211 | 211 | <label for="give-export-address"> |
212 | 212 | <input type="checkbox" checked |
213 | 213 | name="give_export_option[address]" |
214 | - id="give-export-address"><?php esc_html_e( 'Address', 'give' ); ?> |
|
214 | + id="give-export-address"><?php esc_html_e('Address', 'give'); ?> |
|
215 | 215 | </label> |
216 | 216 | </li> |
217 | 217 | <li> |
218 | 218 | <label for="give-export-userid"> |
219 | 219 | <input type="checkbox" checked |
220 | 220 | name="give_export_option[userid]" |
221 | - id="give-export-userid"><?php esc_html_e( 'User ID', 'give' ); ?> |
|
221 | + id="give-export-userid"><?php esc_html_e('User ID', 'give'); ?> |
|
222 | 222 | </label> |
223 | 223 | </li> |
224 | 224 | <li> |
225 | 225 | <label for="give-export-donation-form"> |
226 | 226 | <input type="checkbox" checked |
227 | 227 | name="give_export_option[donation_form]" |
228 | - id="give-export-donation-form"><?php esc_html_e( 'Donation Form', 'give' ); ?> |
|
228 | + id="give-export-donation-form"><?php esc_html_e('Donation Form', 'give'); ?> |
|
229 | 229 | </label> |
230 | 230 | </li> |
231 | 231 | <li> |
232 | 232 | <label for="give-export-first-donation-date"> |
233 | 233 | <input type="checkbox" checked |
234 | 234 | name="give_export_option[date_first_donated]" |
235 | - id="give-export-first-donation-date"><?php esc_html_e( 'First Donation Date', 'give' ); ?> |
|
235 | + id="give-export-first-donation-date"><?php esc_html_e('First Donation Date', 'give'); ?> |
|
236 | 236 | </label> |
237 | 237 | </li> |
238 | 238 | <li> |
239 | 239 | <label for="give-export-donation-number"> |
240 | 240 | <input type="checkbox" checked |
241 | 241 | name="give_export_option[donations]" |
242 | - id="give-export-donation-number"><?php esc_html_e( 'Number of Donations', 'give' ); ?> |
|
242 | + id="give-export-donation-number"><?php esc_html_e('Number of Donations', 'give'); ?> |
|
243 | 243 | </label> |
244 | 244 | </li> |
245 | 245 | <li> |
246 | 246 | <label for="give-export-donation-sum"> |
247 | 247 | <input type="checkbox" checked |
248 | 248 | name="give_export_option[donation_sum]" |
249 | - id="give-export-donation-sum"><?php esc_html_e( 'Total Donated', 'give' ); ?> |
|
249 | + id="give-export-donation-sum"><?php esc_html_e('Total Donated', 'give'); ?> |
|
250 | 250 | </label> |
251 | 251 | </li> |
252 | 252 | </ul> |
253 | 253 | </div> |
254 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
254 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
255 | 255 | <input type="hidden" name="give-export-class" value="Give_Batch_Donors_Export"/> |
256 | - <input type="hidden" name="give_export_option[query_id]" value="<?php echo uniqid( 'give_' ); ?>"/> |
|
256 | + <input type="hidden" name="give_export_option[query_id]" value="<?php echo uniqid('give_'); ?>"/> |
|
257 | 257 | </form> |
258 | 258 | </td> |
259 | 259 | </tr> |
@@ -261,26 +261,26 @@ discard block |
||
261 | 261 | <tr class="give-export-core-settings"> |
262 | 262 | <td scope="row" class="row-title"> |
263 | 263 | <h3> |
264 | - <span><?php esc_html_e( 'Export Give Settings', 'give' ); ?></span> |
|
264 | + <span><?php esc_html_e('Export Give Settings', 'give'); ?></span> |
|
265 | 265 | </h3> |
266 | - <p><?php esc_html_e( 'Download an export of Give\'s settings and import it in a new WordPress installation.', 'give' ); ?></p> |
|
266 | + <p><?php esc_html_e('Download an export of Give\'s settings and import it in a new WordPress installation.', 'give'); ?></p> |
|
267 | 267 | </td> |
268 | 268 | <td> |
269 | 269 | <form method="post"> |
270 | - <p class="settings-excludes-title"><?php echo __( 'Checked options from the list will not be exported', 'give' ); ?></p> |
|
270 | + <p class="settings-excludes-title"><?php echo __('Checked options from the list will not be exported', 'give'); ?></p> |
|
271 | 271 | <ul class="settings-excludes-list"> |
272 | 272 | <?php |
273 | - $export_excludes = apply_filters( 'settings_export_excludes', array() ); |
|
273 | + $export_excludes = apply_filters('settings_export_excludes', array()); |
|
274 | 274 | |
275 | - if ( ! empty( $export_excludes ) ) { |
|
276 | - foreach ( $export_excludes as $option_key => $option_label ) { |
|
275 | + if ( ! empty($export_excludes)) { |
|
276 | + foreach ($export_excludes as $option_key => $option_label) { |
|
277 | 277 | ?> |
278 | 278 | <li> |
279 | 279 | <label for="settings_export_excludes[<?php echo $option_key?>]"> |
280 | 280 | <input |
281 | 281 | type="checkbox" checked |
282 | 282 | name="settings_export_excludes[<?php echo $option_key?>]" |
283 | - id="settings_export_excludes[<?php echo $option_key?>]"><?php echo esc_html( $option_label ); ?> |
|
283 | + id="settings_export_excludes[<?php echo $option_key?>]"><?php echo esc_html($option_label); ?> |
|
284 | 284 | </label> |
285 | 285 | </li> |
286 | 286 | <?php |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | ?> |
290 | 290 | </ul> |
291 | 291 | <input type="hidden" name="give-action" value="core_settings_export"/> |
292 | - <input type="submit" value="<?php esc_attr_e( 'Export JSON', 'give' ); ?>" class="button-secondary"/> |
|
292 | + <input type="submit" value="<?php esc_attr_e('Export JSON', 'give'); ?>" class="button-secondary"/> |
|
293 | 293 | </form> |
294 | 294 | </td> |
295 | 295 | </tr> |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @since 1.0 |
304 | 304 | */ |
305 | - do_action( 'give_tools_tab_export_table_bottom' ); |
|
305 | + do_action('give_tools_tab_export_table_bottom'); |
|
306 | 306 | ?> |
307 | 307 | </tbody> |
308 | 308 | </table> |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @since 1.0 |
315 | 315 | */ |
316 | - do_action( 'give_tools_tab_export_content_bottom' ); |
|
316 | + do_action('give_tools_tab_export_content_bottom'); |
|
317 | 317 | ?> |
318 | 318 | |
319 | 319 | </div> |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | give_ignore_user_abort(); |
43 | 43 | |
44 | 44 | nocache_headers(); |
45 | - header( 'Content-Type: application/json; charset=utf-8' ); |
|
46 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_core_settings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.json' ); |
|
47 | - header( 'Expires: 0' ); |
|
45 | + header('Content-Type: application/json; charset=utf-8'); |
|
46 | + header('Content-Disposition: attachment; filename='.apply_filters('give_core_settings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.json'); |
|
47 | + header('Expires: 0'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * @since 1.8.17 |
55 | 55 | */ |
56 | 56 | public function json_core_settings_export() { |
57 | - $settings_excludes = give_clean( $_POST['settings_export_excludes'] ); |
|
58 | - $give_settings = get_option( 'give_settings' ); |
|
57 | + $settings_excludes = give_clean($_POST['settings_export_excludes']); |
|
58 | + $give_settings = get_option('give_settings'); |
|
59 | 59 | |
60 | - if ( is_array( $settings_excludes ) && ! empty( $settings_excludes ) ) { |
|
61 | - foreach ( $settings_excludes as $key => $value ) { |
|
62 | - if ( give_is_setting_enabled( $value ) ) { |
|
63 | - unset( $give_settings[ $key ] ); |
|
60 | + if (is_array($settings_excludes) && ! empty($settings_excludes)) { |
|
61 | + foreach ($settings_excludes as $key => $value) { |
|
62 | + if (give_is_setting_enabled($value)) { |
|
63 | + unset($give_settings[$key]); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - echo wp_json_encode( $give_settings ); |
|
68 | + echo wp_json_encode($give_settings); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @since 1.8.17 |
76 | 76 | */ |
77 | 77 | public function export() { |
78 | - if ( ! $this->can_export() ) { |
|
79 | - wp_die( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
78 | + if ( ! $this->can_export()) { |
|
79 | + wp_die(__('You do not have permission to export data.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Set headers. |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', __( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', __('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats(); ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date_i18n( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date_i18n(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - __( 'Happy %s!', 'give' ), |
|
55 | - date_i18n( 'l', current_time( 'timestamp' ) ) |
|
54 | + __('Happy %s!', 'give'), |
|
55 | + date_i18n('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today, array( 'sanitize' => false ) ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today, array('sanitize' => false))); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-donations-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - __( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, array( 'decimal' => false, 'sanitize' => false ) ) |
|
68 | + __('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, array('decimal' => false, 'sanitize' => false)) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php _e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php _e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php _e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php _e('This Week', 'give'); ?></th> |
|
80 | + <th><?php _e('This Month', 'give'); ?></th> |
|
81 | + <th><?php _e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ), array( 'sanitize' => false ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'), array('sanitize' => false))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php _e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ), array( 'sanitize' => false ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'), array('sanitize' => false))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php _e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'), array('sanitize' => false))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php _e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php _e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year' ), array( 'sanitize' => false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year'), array('sanitize' => false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Year', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php _e('This Year', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,24 +123,24 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | 127 | |
128 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
128 | + $num_posts = wp_count_posts('give_forms'); |
|
129 | 129 | |
130 | - if ( $num_posts && $num_posts->publish ) { |
|
130 | + if ($num_posts && $num_posts->publish) { |
|
131 | 131 | |
132 | 132 | $text = sprintf( |
133 | 133 | /* translators: %s: number of posts published */ |
134 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
134 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
135 | 135 | $num_posts->publish |
136 | 136 | ); |
137 | 137 | |
138 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
138 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
139 | 139 | |
140 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
140 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
141 | 141 | $text = sprintf( |
142 | 142 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
143 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
143 | + admin_url('edit.php?post_type=give_forms'), |
|
144 | 144 | $text |
145 | 145 | ); |
146 | 146 | } else { |
@@ -156,4 +156,4 @@ discard block |
||
156 | 156 | return $items; |
157 | 157 | } |
158 | 158 | |
159 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
159 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.8.13 |
21 | 21 | */ |
22 | 22 | function give_import_donation_report() { |
23 | - return get_option( 'give_import_donation_report', array() ); |
|
23 | + return get_option('give_import_donation_report', array()); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8.13 |
31 | 31 | */ |
32 | -function give_import_donation_report_update( $value = array() ) { |
|
33 | - update_option( 'give_import_donation_report', $value ); |
|
32 | +function give_import_donation_report_update($value = array()) { |
|
33 | + update_option('give_import_donation_report', $value); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @since 1.8.13 |
41 | 41 | */ |
42 | 42 | function give_import_donation_report_reset() { |
43 | - update_option( 'give_import_donation_report', array() ); |
|
43 | + update_option('give_import_donation_report', array()); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
54 | 54 | */ |
55 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
55 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
56 | 56 | $new_form = false; |
57 | 57 | |
58 | 58 | // Get the import report |
@@ -61,62 +61,62 @@ discard block |
||
61 | 61 | $form = false; |
62 | 62 | $meta = array(); |
63 | 63 | |
64 | - if ( ! empty( $data['form_id'] ) ) { |
|
65 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
64 | + if ( ! empty($data['form_id'])) { |
|
65 | + $form = new Give_Donate_Form($data['form_id']); |
|
66 | 66 | // Add support to older php version. |
67 | 67 | $form_id = $form->get_ID(); |
68 | - if ( empty( $form_id ) ) { |
|
69 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
68 | + if (empty($form_id)) { |
|
69 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
70 | 70 | $form = false; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
75 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
74 | + if (false === $form && ! empty($data['form_title'])) { |
|
75 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
76 | 76 | |
77 | - if ( ! empty( $form->ID ) ) { |
|
77 | + if ( ! empty($form->ID)) { |
|
78 | 78 | |
79 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
79 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
80 | 80 | |
81 | - $form = new Give_Donate_Form( $form->ID ); |
|
81 | + $form = new Give_Donate_Form($form->ID); |
|
82 | 82 | } else { |
83 | 83 | $form = new Give_Donate_Form(); |
84 | 84 | $args = array( |
85 | 85 | 'post_title' => $data['form_title'], |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | ); |
88 | - $form = $form->create( $args ); |
|
89 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
88 | + $form = $form->create($args); |
|
89 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
90 | 90 | $new_form = true; |
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
95 | - $form = new Give_Donate_Form( $form->ID ); |
|
94 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
95 | + $form = new Give_Donate_Form($form->ID); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $form ) && $form->get_ID() && ! empty( $data['form_level'] ) ) { |
|
98 | + if ( ! empty($form) && $form->get_ID() && ! empty($data['form_level'])) { |
|
99 | 99 | |
100 | 100 | $price_option = 'set'; |
101 | - $form_level = strtolower( preg_replace('/\s+/', '', $data['form_level'] ) ); |
|
101 | + $form_level = strtolower(preg_replace('/\s+/', '', $data['form_level'])); |
|
102 | 102 | |
103 | - if ( 'custom' !== $form_level ) { |
|
103 | + if ('custom' !== $form_level) { |
|
104 | 104 | $prices = (array) $form->get_prices(); |
105 | 105 | $price_text = array(); |
106 | - foreach ( $prices as $key => $price ) { |
|
107 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
108 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? strtolower( preg_replace('/\s+/', '', $price['_give_text'] ) ) : '' ); |
|
106 | + foreach ($prices as $key => $price) { |
|
107 | + if (isset($price['_give_id']['level_id'])) { |
|
108 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? strtolower(preg_replace('/\s+/', '', $price['_give_text'])) : ''); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! in_array( $form_level, $price_text ) ) { |
|
112 | + if ( ! in_array($form_level, $price_text)) { |
|
113 | 113 | |
114 | 114 | // For generating unquiet level id. |
115 | 115 | $count = 1; |
116 | - $new_level = count( $prices ) + $count; |
|
117 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
118 | - $count ++; |
|
119 | - $new_level = count( $prices ) + $count; |
|
116 | + $new_level = count($prices) + $count; |
|
117 | + while (array_key_exists($new_level, $price_text)) { |
|
118 | + $count++; |
|
119 | + $new_level = count($prices) + $count; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $multi_level_donations = array( |
@@ -124,42 +124,42 @@ discard block |
||
124 | 124 | '_give_id' => array( |
125 | 125 | 'level_id' => $new_level, |
126 | 126 | ), |
127 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
127 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
128 | 128 | '_give_text' => $data['form_level'], |
129 | 129 | ), |
130 | 130 | ); |
131 | 131 | |
132 | - $price_text[ $new_level ] = strtolower( preg_replace('/\s+/', '', $data['form_level'] ) ); |
|
132 | + $price_text[$new_level] = strtolower(preg_replace('/\s+/', '', $data['form_level'])); |
|
133 | 133 | |
134 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
135 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
134 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
135 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
136 | 136 | |
137 | 137 | // Sort $prices by amount in ascending order. |
138 | - $prices = wp_list_sort( $prices, '_give_amount', 'ASC' ); |
|
138 | + $prices = wp_list_sort($prices, '_give_amount', 'ASC'); |
|
139 | 139 | } else { |
140 | 140 | $prices = $multi_level_donations; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Unset _give_default key from $prices. |
144 | - foreach ( $prices as $key => $price ) { |
|
145 | - if ( isset( $prices[ $key ]['_give_default'] ) ) { |
|
146 | - unset( $prices[ $key ]['_give_default'] ); |
|
144 | + foreach ($prices as $key => $price) { |
|
145 | + if (isset($prices[$key]['_give_default'])) { |
|
146 | + unset($prices[$key]['_give_default']); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Set the first $price of the $prices as default. |
151 | 151 | $prices[0]['_give_default'] = 'default'; |
152 | 152 | } |
153 | - $form->price_id = array_search( $form_level, $price_text ); |
|
153 | + $form->price_id = array_search($form_level, $price_text); |
|
154 | 154 | |
155 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
156 | - $min_amount = min( $donation_levels_amounts ); |
|
157 | - $max_amount = max( $donation_levels_amounts ); |
|
155 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
156 | + $min_amount = min($donation_levels_amounts); |
|
157 | + $max_amount = max($donation_levels_amounts); |
|
158 | 158 | |
159 | 159 | $meta = array( |
160 | 160 | '_give_levels_minimum_amount' => $min_amount, |
161 | 161 | '_give_levels_maximum_amount' => $max_amount, |
162 | - '_give_donation_levels' => array_values( $prices ), |
|
162 | + '_give_donation_levels' => array_values($prices), |
|
163 | 163 | ); |
164 | 164 | |
165 | 165 | $price_option = 'multi'; |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | $defaults = array( |
171 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
171 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
172 | 172 | ); |
173 | 173 | |
174 | 174 | // If new form is created. |
175 | - if ( ! empty( $new_form ) ) { |
|
175 | + if ( ! empty($new_form)) { |
|
176 | 176 | $new_form = array( |
177 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'Custom' ), |
|
177 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'Custom'), |
|
178 | 178 | '_give_logged_in_only' => 'enabled', |
179 | 179 | '_give_custom_amount' => 'enabled', |
180 | 180 | '_give_payment_import' => true, |
@@ -186,18 +186,18 @@ discard block |
||
186 | 186 | '_give_show_register_form' => 'both', |
187 | 187 | '_give_price_option' => $price_option, |
188 | 188 | ); |
189 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
189 | + $defaults = wp_parse_args($defaults, $new_form); |
|
190 | 190 | } |
191 | 191 | |
192 | - $meta = wp_parse_args( $meta, $defaults ); |
|
192 | + $meta = wp_parse_args($meta, $defaults); |
|
193 | 193 | |
194 | - foreach ( $meta as $key => $value ) { |
|
195 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
194 | + foreach ($meta as $key => $value) { |
|
195 | + give_update_meta($form->get_ID(), $key, $value); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | // update the report |
200 | - give_import_donation_report_update( $report ); |
|
200 | + give_import_donation_report_update($report); |
|
201 | 201 | |
202 | 202 | return $form; |
203 | 203 | } |
@@ -211,30 +211,30 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return bool|false|WP_User |
213 | 213 | */ |
214 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
214 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
215 | 215 | $report = give_import_donation_report(); |
216 | 216 | $donor_data = false; |
217 | 217 | $donor_id = false; |
218 | 218 | |
219 | 219 | // check if donor id is not empty |
220 | - if ( ! empty( $data['donor_id'] ) ) { |
|
221 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
222 | - if ( ! empty( $donor_data->id ) ) { |
|
223 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
220 | + if ( ! empty($data['donor_id'])) { |
|
221 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
222 | + if ( ! empty($donor_data->id)) { |
|
223 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
227 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
228 | 228 | $user_id = (int) $data['user_id']; |
229 | - $donor_data = new Give_Donor( $user_id, true ); |
|
229 | + $donor_data = new Give_Donor($user_id, true); |
|
230 | 230 | |
231 | 231 | |
232 | - if ( empty( $donor_data->id ) ) { |
|
233 | - $donor_data = get_user_by( 'id', $user_id ); |
|
234 | - if ( ! empty( $donor_data->ID ) ) { |
|
235 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
236 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
237 | - $name = $first_name . ' ' . $last_name; |
|
232 | + if (empty($donor_data->id)) { |
|
233 | + $donor_data = get_user_by('id', $user_id); |
|
234 | + if ( ! empty($donor_data->ID)) { |
|
235 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
236 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
237 | + $name = $first_name.' '.$last_name; |
|
238 | 238 | $user_email = $donor_data->user_email; |
239 | 239 | $donor_args = array( |
240 | 240 | 'name' => $name, |
@@ -243,45 +243,45 @@ discard block |
||
243 | 243 | ); |
244 | 244 | |
245 | 245 | $donor_data = new Give_Donor(); |
246 | - $donor_data->create( $donor_args ); |
|
246 | + $donor_data->create($donor_args); |
|
247 | 247 | |
248 | 248 | // Adding notes that donor is being imported from CSV. |
249 | 249 | $current_user = wp_get_current_user(); |
250 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
250 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
251 | 251 | |
252 | 252 | // Add is used to ensure duplicate emails are not added |
253 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
254 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
253 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
254 | + $donor_data->add_meta('additional_email', $data['email']); |
|
255 | 255 | } |
256 | 256 | |
257 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
257 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
258 | 258 | } |
259 | 259 | } else { |
260 | 260 | // Add is used to ensure duplicate emails are not added |
261 | - if ( $donor_data->email != $data['email'] ) { |
|
262 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
261 | + if ($donor_data->email != $data['email']) { |
|
262 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
263 | 263 | } |
264 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
264 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) ) { |
|
268 | + if (empty($donor_data->id) && ! empty($data['email'])) { |
|
269 | 269 | |
270 | - $donor_data = new Give_Donor( $data['email'] ); |
|
271 | - if ( empty( $donor_data->id ) ) { |
|
272 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
270 | + $donor_data = new Give_Donor($data['email']); |
|
271 | + if (empty($donor_data->id)) { |
|
272 | + $donor_data = get_user_by('email', $data['email']); |
|
273 | 273 | |
274 | - if ( empty( $donor_data->ID ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
275 | - $data['first_name'] = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $data['email'] ); |
|
276 | - $data['last_name'] = ( ! empty( $data['last_name'] ) ? $data['last_name'] : '' ); |
|
277 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
274 | + if (empty($donor_data->ID) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
275 | + $data['first_name'] = ( ! empty($data['first_name']) ? $data['first_name'] : $data['email']); |
|
276 | + $data['last_name'] = ( ! empty($data['last_name']) ? $data['last_name'] : ''); |
|
277 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
278 | 278 | $donor_args = array( |
279 | 279 | 'user_login' => $data['email'], |
280 | 280 | 'user_email' => $data['email'], |
281 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
281 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
282 | 282 | 'user_first' => $data['first_name'], |
283 | 283 | 'user_last' => $data['last_name'], |
284 | - 'user_pass' => wp_generate_password( 8, true ), |
|
284 | + 'user_pass' => wp_generate_password(8, true), |
|
285 | 285 | 'role' => $give_role, |
286 | 286 | ); |
287 | 287 | |
@@ -290,55 +290,55 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @since 1.8.13 |
292 | 292 | */ |
293 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
293 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
294 | 294 | |
295 | 295 | // This action was added to remove the login when using the give register function. |
296 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
297 | - $donor_id = give_register_and_login_new_user( $donor_args ); |
|
298 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
296 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
297 | + $donor_id = give_register_and_login_new_user($donor_args); |
|
298 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
299 | 299 | |
300 | - update_user_meta( $donor_id, '_give_payment_import', true ); |
|
301 | - $donor_data = new Give_Donor( $donor_id, true ); |
|
300 | + update_user_meta($donor_id, '_give_payment_import', true); |
|
301 | + $donor_data = new Give_Donor($donor_id, true); |
|
302 | 302 | } else { |
303 | - $donor_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
303 | + $donor_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
304 | 304 | } |
305 | 305 | |
306 | - if ( ! empty( $donor_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) { |
|
307 | - $donor_data = new Give_Donor( $donor_id, true ); |
|
306 | + if ( ! empty($donor_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user']))) { |
|
307 | + $donor_data = new Give_Donor($donor_id, true); |
|
308 | 308 | |
309 | - if ( empty( $donor_data->id ) ) { |
|
309 | + if (empty($donor_data->id)) { |
|
310 | 310 | |
311 | - if ( ! empty( $data['form_id'] ) ) { |
|
312 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
311 | + if ( ! empty($data['form_id'])) { |
|
312 | + $form = new Give_Donate_Form($data['form_id']); |
|
313 | 313 | } |
314 | 314 | |
315 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : esc_html__( 'New Form', 'give' ) ) ); |
|
315 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : esc_html__('New Form', 'give'))); |
|
316 | 316 | $donor_args = array( |
317 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
317 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
318 | 318 | 'email' => $data['email'], |
319 | 319 | ); |
320 | 320 | |
321 | - if ( ! empty( $donor_id ) ) { |
|
321 | + if ( ! empty($donor_id)) { |
|
322 | 322 | $donor_args['user_id'] = $donor_id; |
323 | 323 | } |
324 | 324 | |
325 | - $donor_data->create( $donor_args ); |
|
325 | + $donor_data->create($donor_args); |
|
326 | 326 | |
327 | 327 | // Adding notes that donor is being imported from CSV. |
328 | 328 | $current_user = wp_get_current_user(); |
329 | - $donor_data->add_note( esc_html( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
329 | + $donor_data->add_note(esc_html(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email))); |
|
330 | 330 | |
331 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
331 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
332 | 332 | } else { |
333 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
333 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } else { |
337 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
337 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | // update the report |
341 | - give_import_donation_report_update( $report ); |
|
341 | + give_import_donation_report_update($report); |
|
342 | 342 | |
343 | 343 | return $donor_data; |
344 | 344 | } |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return array |
358 | 358 | */ |
359 | - return (array) apply_filters( 'give_import_default_options', array( |
|
360 | - '' => __( 'Do not import', 'give' ), |
|
361 | - ) ); |
|
359 | + return (array) apply_filters('give_import_default_options', array( |
|
360 | + '' => __('Do not import', 'give'), |
|
361 | + )); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -374,62 +374,62 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @return array |
376 | 376 | */ |
377 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
378 | - 'id' => __( 'Donation ID', 'give' ), |
|
377 | + return (array) apply_filters('give_import_donations_options', array( |
|
378 | + 'id' => __('Donation ID', 'give'), |
|
379 | 379 | 'amount' => array( |
380 | - __( 'Donation Amount', 'give' ), |
|
381 | - __( 'Amount', 'give' ) |
|
380 | + __('Donation Amount', 'give'), |
|
381 | + __('Amount', 'give') |
|
382 | 382 | ), |
383 | 383 | 'post_date' => array( |
384 | - __( 'Donation Date', 'give' ), |
|
385 | - __( 'Date', 'give' ), |
|
384 | + __('Donation Date', 'give'), |
|
385 | + __('Date', 'give'), |
|
386 | 386 | ), |
387 | 387 | 'first_name' => array( |
388 | - __( 'Donor First Name', 'give' ), |
|
389 | - __( 'First Name', 'give' ), |
|
390 | - __( 'Name', 'give' ), |
|
388 | + __('Donor First Name', 'give'), |
|
389 | + __('First Name', 'give'), |
|
390 | + __('Name', 'give'), |
|
391 | 391 | ), |
392 | 392 | 'last_name' => array( |
393 | - __( 'Donor Last Name', 'give' ), |
|
394 | - __( 'Last Name', 'give' ), |
|
393 | + __('Donor Last Name', 'give'), |
|
394 | + __('Last Name', 'give'), |
|
395 | 395 | ), |
396 | 396 | 'line1' => array( |
397 | - __( 'Address 1', 'give' ), |
|
398 | - __( 'Address', 'give' ), |
|
397 | + __('Address 1', 'give'), |
|
398 | + __('Address', 'give'), |
|
399 | 399 | ), |
400 | - 'line2' => __( 'Address 2', 'give' ), |
|
401 | - 'city' => __( 'City', 'give' ), |
|
400 | + 'line2' => __('Address 2', 'give'), |
|
401 | + 'city' => __('City', 'give'), |
|
402 | 402 | 'state' => array( |
403 | - __( 'State', 'give' ), |
|
404 | - __( 'Province', 'give' ), |
|
405 | - __( 'County', 'give' ), |
|
406 | - __( 'Region', 'give' ), |
|
403 | + __('State', 'give'), |
|
404 | + __('Province', 'give'), |
|
405 | + __('County', 'give'), |
|
406 | + __('Region', 'give'), |
|
407 | 407 | ), |
408 | - 'country' => __( 'Country', 'give' ), |
|
408 | + 'country' => __('Country', 'give'), |
|
409 | 409 | 'zip' => array( |
410 | - __( 'Zip', 'give' ), |
|
411 | - __( 'Zip Code', 'give' ), |
|
412 | - __( 'Postal Code', 'give' ), |
|
410 | + __('Zip', 'give'), |
|
411 | + __('Zip Code', 'give'), |
|
412 | + __('Postal Code', 'give'), |
|
413 | 413 | ), |
414 | 414 | 'email' => array( |
415 | - __( 'Donor Email', 'give' ), |
|
416 | - __( 'Email', 'give' ) |
|
415 | + __('Donor Email', 'give'), |
|
416 | + __('Email', 'give') |
|
417 | 417 | ), |
418 | 418 | 'post_status' => array( |
419 | - __( 'Donation Status', 'give' ), |
|
420 | - __( 'Status', 'give' ), |
|
419 | + __('Donation Status', 'give'), |
|
420 | + __('Status', 'give'), |
|
421 | 421 | ), |
422 | 422 | 'gateway' => array( |
423 | - __( 'Payment Method', 'give' ), |
|
424 | - __( 'Method', 'give' ), |
|
423 | + __('Payment Method', 'give'), |
|
424 | + __('Method', 'give'), |
|
425 | 425 | ), |
426 | - 'notes' => __( 'Notes', 'give' ), |
|
426 | + 'notes' => __('Notes', 'give'), |
|
427 | 427 | 'mode' => array( |
428 | - __( 'Test Mode', 'give' ), |
|
429 | - __( 'Mode', 'give' ), |
|
428 | + __('Test Mode', 'give'), |
|
429 | + __('Mode', 'give'), |
|
430 | 430 | ), |
431 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
432 | - ) ); |
|
431 | + 'post_meta' => __('Import as Meta', 'give'), |
|
432 | + )); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -445,10 +445,10 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @return array |
447 | 447 | */ |
448 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
449 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
450 | - 'user_id' => __( 'User ID', 'give' ), |
|
451 | - ) ); |
|
448 | + return (array) apply_filters('give_import_donor_options', array( |
|
449 | + 'donor_id' => __('Donor ID', 'give'), |
|
450 | + 'user_id' => __('User ID', 'give'), |
|
451 | + )); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -464,23 +464,23 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @return array |
466 | 466 | */ |
467 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
467 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
468 | 468 | 'form_title' => array( |
469 | - __( 'Donation Form Title', 'give' ), |
|
470 | - __( 'Donation Form', 'give' ), |
|
471 | - __( 'Form Name', 'give' ), |
|
472 | - __( 'Title', 'give' ), |
|
469 | + __('Donation Form Title', 'give'), |
|
470 | + __('Donation Form', 'give'), |
|
471 | + __('Form Name', 'give'), |
|
472 | + __('Title', 'give'), |
|
473 | 473 | ), |
474 | 474 | 'form_id' => array( |
475 | - __( 'Donation Form ID', 'give' ), |
|
476 | - __( 'Form ID', 'give' ) |
|
475 | + __('Donation Form ID', 'give'), |
|
476 | + __('Form ID', 'give') |
|
477 | 477 | ), |
478 | 478 | 'form_level' => array( |
479 | - __( 'Donation Level', 'give' ), |
|
480 | - __( 'Level', 'give' ), |
|
479 | + __('Donation Level', 'give'), |
|
480 | + __('Level', 'give'), |
|
481 | 481 | ), |
482 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
483 | - ) ); |
|
482 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
483 | + )); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return array |
495 | 495 | */ |
496 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) { |
|
496 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') { |
|
497 | 497 | /** |
498 | 498 | * Filter to modify delimiter of Import. |
499 | 499 | * |
@@ -502,19 +502,19 @@ discard block |
||
502 | 502 | * |
503 | 503 | * Return string $delimiter. |
504 | 504 | */ |
505 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
505 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
506 | 506 | |
507 | 507 | $raw_data = array(); |
508 | - $file_dir = get_attached_file( $file_id ); |
|
508 | + $file_dir = get_attached_file($file_id); |
|
509 | 509 | $count = 0; |
510 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
511 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
512 | - if ( $count >= $start && $count <= $end ) { |
|
510 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
511 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
512 | + if ($count >= $start && $count <= $end) { |
|
513 | 513 | $raw_data[] = $row; |
514 | 514 | } |
515 | - $count ++; |
|
515 | + $count++; |
|
516 | 516 | } |
517 | - fclose( $handle ); |
|
517 | + fclose($handle); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | return $raw_data; |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return bool |
532 | 532 | */ |
533 | -function give_log_user_in_on_register_callback( $value ) { |
|
533 | +function give_log_user_in_on_register_callback($value) { |
|
534 | 534 | return false; |
535 | 535 | } |
536 | 536 | |
@@ -546,22 +546,22 @@ discard block |
||
546 | 546 | * |
547 | 547 | * @return bool |
548 | 548 | */ |
549 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
550 | - $data = array_combine( $raw_key, $row_data ); |
|
549 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
550 | + $data = array_combine($raw_key, $row_data); |
|
551 | 551 | $price_id = false; |
552 | 552 | $donor_id = 0; |
553 | - $import_setting['create_user'] = ( isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1 ); |
|
553 | + $import_setting['create_user'] = (isset($import_setting['create_user']) ? $import_setting['create_user'] : 1); |
|
554 | 554 | |
555 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
555 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
556 | 556 | |
557 | - $data['amount'] = give_maybe_sanitize_amount( $data['amount'] ); |
|
557 | + $data['amount'] = give_maybe_sanitize_amount($data['amount']); |
|
558 | 558 | |
559 | 559 | // Here come the login function. |
560 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
561 | - if ( ! empty( $donor_data->id ) ) { |
|
562 | - if ( ! empty( $donor_data->user_id ) ) { |
|
560 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
561 | + if ( ! empty($donor_data->id)) { |
|
562 | + if ( ! empty($donor_data->user_id)) { |
|
563 | 563 | $donor_id = $donor_data->user_id; |
564 | - } elseif ( ! empty( $data['user_id'] ) ) { |
|
564 | + } elseif ( ! empty($data['user_id'])) { |
|
565 | 565 | $donor_id = $data['user_id']; |
566 | 566 | } |
567 | 567 | } else { |
@@ -569,24 +569,24 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | // get form data or register a form data. |
572 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
573 | - if ( false == $form ) { |
|
572 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
573 | + if (false == $form) { |
|
574 | 574 | return false; |
575 | 575 | } else { |
576 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
576 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
580 | - $status = give_import_donation_get_status( $data ); |
|
580 | + $status = give_import_donation_get_status($data); |
|
581 | 581 | |
582 | 582 | |
583 | 583 | $address = array( |
584 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
585 | - 'line2' => ( ! empty( $data['line1'] ) ? give_clean( $data['line2'] ) : '' ), |
|
586 | - 'city' => ( ! empty( $data['line1'] ) ? give_clean( $data['city'] ) : '' ), |
|
587 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
588 | - 'state' => ( ! empty( $data['state'] ) ? give_clean( $data['state'] ) : '' ), |
|
589 | - 'country' => ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ), |
|
584 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
585 | + 'line2' => ( ! empty($data['line1']) ? give_clean($data['line2']) : ''), |
|
586 | + 'city' => ( ! empty($data['line1']) ? give_clean($data['city']) : ''), |
|
587 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
588 | + 'state' => ( ! empty($data['state']) ? give_clean($data['state']) : ''), |
|
589 | + 'country' => ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''), |
|
590 | 590 | ); |
591 | 591 | |
592 | 592 | //Create payment_data array |
@@ -597,72 +597,72 @@ discard block |
||
597 | 597 | 'currency' => give_get_currency(), |
598 | 598 | 'user_info' => array( |
599 | 599 | 'id' => $donor_id, |
600 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
601 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $donor_id ) && ( $first_name = get_user_meta( $donor_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
602 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $donor_id ) && ( $last_name = get_user_meta( $donor_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
600 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
601 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($donor_id) && ($first_name = get_user_meta($donor_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
602 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($donor_id) && ($last_name = get_user_meta($donor_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
603 | 603 | 'address' => $address, |
604 | 604 | ), |
605 | - 'gateway' => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
606 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : $form->get_name() ), |
|
605 | + 'gateway' => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
606 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : $form->get_name()), |
|
607 | 607 | 'give_form_id' => (string) $form->get_ID(), |
608 | 608 | 'give_price_id' => $price_id, |
609 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
609 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
610 | 610 | 'user_email' => $data['email'], |
611 | - 'post_date' => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ), |
|
612 | - 'mode' => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
611 | + 'post_date' => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')), |
|
612 | + 'mode' => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
613 | 613 | ); |
614 | 614 | |
615 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
615 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
616 | 616 | |
617 | 617 | // Get the report |
618 | 618 | $report = give_import_donation_report(); |
619 | 619 | |
620 | 620 | // Check for duplicate code. |
621 | - $donation_duplicate = give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ); |
|
622 | - if ( false !== $donation_duplicate ) { |
|
623 | - $report['donation_details'][ $import_setting['donation_key'] ]['duplicate'] = $donation_duplicate; |
|
624 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
621 | + $donation_duplicate = give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data); |
|
622 | + if (false !== $donation_duplicate) { |
|
623 | + $report['donation_details'][$import_setting['donation_key']]['duplicate'] = $donation_duplicate; |
|
624 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
625 | 625 | } else { |
626 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
627 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
628 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
629 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
630 | - $payment = give_insert_payment( $payment_data ); |
|
631 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
632 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
633 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
634 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
626 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
627 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
628 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
629 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
630 | + $payment = give_insert_payment($payment_data); |
|
631 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
632 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
633 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
634 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
635 | 635 | |
636 | - if ( $payment ) { |
|
636 | + if ($payment) { |
|
637 | 637 | |
638 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
638 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
639 | 639 | |
640 | - update_post_meta( $payment, '_give_payment_import', true ); |
|
640 | + update_post_meta($payment, '_give_payment_import', true); |
|
641 | 641 | |
642 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
643 | - update_post_meta( $payment, '_give_payment_import_id', $import_setting['csv'] ); |
|
642 | + if ( ! empty($import_setting['csv'])) { |
|
643 | + update_post_meta($payment, '_give_payment_import_id', $import_setting['csv']); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | // Insert Notes. |
647 | - if ( ! empty( $data['notes'] ) ) { |
|
648 | - give_insert_payment_note( $payment, $data['notes'] ); |
|
647 | + if ( ! empty($data['notes'])) { |
|
648 | + give_insert_payment_note($payment, $data['notes']); |
|
649 | 649 | } |
650 | 650 | |
651 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
652 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
653 | - foreach ( $meta_exists as $meta_exist ) { |
|
654 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
655 | - update_post_meta( $payment, $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
651 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
652 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
653 | + foreach ($meta_exists as $meta_exist) { |
|
654 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
655 | + update_post_meta($payment, $main_key[$meta_exist], $row_data[$meta_exist]); |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | } |
659 | 659 | } else { |
660 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
660 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | |
664 | 664 | // update the report |
665 | - give_import_donation_report_update( $report ); |
|
665 | + give_import_donation_report_update($report); |
|
666 | 666 | |
667 | 667 | return true; |
668 | 668 | } |
@@ -676,25 +676,25 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @return string $status Donation status. |
678 | 678 | */ |
679 | -function give_import_donation_get_status( $data ) { |
|
680 | - if ( empty( $data['post_status'] ) ) { |
|
679 | +function give_import_donation_get_status($data) { |
|
680 | + if (empty($data['post_status'])) { |
|
681 | 681 | return 'publish'; |
682 | 682 | } |
683 | 683 | |
684 | 684 | $status = 'publish'; |
685 | 685 | |
686 | - $donation_status = trim( $data['post_status'] ); |
|
687 | - $donation_status_key = strtolower( preg_replace( '/\s+/', '', $donation_status ) ); |
|
686 | + $donation_status = trim($data['post_status']); |
|
687 | + $donation_status_key = strtolower(preg_replace('/\s+/', '', $donation_status)); |
|
688 | 688 | |
689 | - foreach ( give_get_payment_statuses() as $key => $value ) { |
|
689 | + foreach (give_get_payment_statuses() as $key => $value) { |
|
690 | 690 | $match = false; |
691 | - if ( $key === $donation_status_key ) { |
|
691 | + if ($key === $donation_status_key) { |
|
692 | 692 | $match = true; |
693 | - } else if ( stristr( $donation_status, $value ) ) { |
|
693 | + } else if (stristr($donation_status, $value)) { |
|
694 | 694 | $match = true; |
695 | 695 | } |
696 | 696 | |
697 | - if ( ! empty( $match ) ) { |
|
697 | + if ( ! empty($match)) { |
|
698 | 698 | $status = $key; |
699 | 699 | break; |
700 | 700 | } |
@@ -714,12 +714,12 @@ discard block |
||
714 | 714 | * |
715 | 715 | * @return Give_Donor |
716 | 716 | */ |
717 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
717 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
718 | 718 | $old_donor = $donor; |
719 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
720 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
721 | - $donor = new Give_Donor( $donor_id ); |
|
722 | - if ( ! empty( $donor->id ) ) { |
|
719 | + if ( ! empty($payment_data['donor_id'])) { |
|
720 | + $donor_id = absint($payment_data['donor_id']); |
|
721 | + $donor = new Give_Donor($donor_id); |
|
722 | + if ( ! empty($donor->id)) { |
|
723 | 723 | return $donor; |
724 | 724 | } |
725 | 725 | } |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | * |
733 | 733 | * @since 1.8.13 |
734 | 734 | */ |
735 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
735 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
736 | 736 | // Update Give Customers purchase_count |
737 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
738 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
739 | - if ( ! empty( $donor_id ) ) { |
|
740 | - $donor = new Give_Donor( $donor_id ); |
|
737 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
738 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
739 | + if ( ! empty($donor_id)) { |
|
740 | + $donor = new Give_Donor($donor_id); |
|
741 | 741 | $donor->increase_purchase_count(); |
742 | 742 | } |
743 | 743 | } |
@@ -748,8 +748,8 @@ discard block |
||
748 | 748 | * |
749 | 749 | * @since 1.8.13 |
750 | 750 | */ |
751 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
752 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
751 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
752 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
753 | 753 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
754 | 754 | } |
755 | 755 | |
@@ -761,11 +761,11 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @since 1.8.13 |
763 | 763 | */ |
764 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
764 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
765 | 765 | $return = false; |
766 | - if ( ! empty( $data['post_date'] ) ) { |
|
767 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $data['post_date'] ); |
|
768 | - $post_date = explode( '-', $post_date ); |
|
766 | + if ( ! empty($data['post_date'])) { |
|
767 | + $post_date = mysql2date('Y-m-d-H-i-s', $data['post_date']); |
|
768 | + $post_date = explode('-', $post_date); |
|
769 | 769 | $args = array( |
770 | 770 | 'output' => 'post', |
771 | 771 | 'cache_results' => false, |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | 'meta_query' => array( |
787 | 787 | array( |
788 | 788 | 'key' => '_give_payment_total', |
789 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
789 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
790 | 790 | 'compare' => 'LIKE', |
791 | 791 | ), |
792 | 792 | array( |
@@ -808,9 +808,9 @@ discard block |
||
808 | 808 | ), |
809 | 809 | ); |
810 | 810 | |
811 | - $payments = new Give_Payments_Query( $args ); |
|
811 | + $payments = new Give_Payments_Query($args); |
|
812 | 812 | $donations = $payments->get_payments(); |
813 | - if ( ! empty( $donations ) ) { |
|
813 | + if ( ! empty($donations)) { |
|
814 | 814 | $return = $donations; |
815 | 815 | } |
816 | 816 | } |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | * |
821 | 821 | * @since 1.8.18 |
822 | 822 | */ |
823 | - return apply_filters( 'give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data ); |
|
823 | + return apply_filters('give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
@@ -832,9 +832,9 @@ discard block |
||
832 | 832 | * |
833 | 833 | * @return void |
834 | 834 | */ |
835 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
835 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
836 | 836 | $current_user = wp_get_current_user(); |
837 | - give_insert_payment_note( $payment_id, esc_html( wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ) ); |
|
837 | + give_insert_payment_note($payment_id, esc_html(wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email))); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -846,14 +846,14 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return string URL |
848 | 848 | */ |
849 | -function give_import_page_url( $parameter = array() ) { |
|
849 | +function give_import_page_url($parameter = array()) { |
|
850 | 850 | $defalut_query_arg = array( |
851 | 851 | 'post_type' => 'give_forms', |
852 | 852 | 'page' => 'give-tools', |
853 | 853 | 'tab' => 'import', |
854 | 854 | 'importer-type' => 'import_donations', |
855 | 855 | ); |
856 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
856 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
857 | 857 | |
858 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
858 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
859 | 859 | } |
860 | 860 | \ No newline at end of file |