@@ -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 | |
@@ -77,40 +77,40 @@ discard block |
||
77 | 77 | parent::__construct(); |
78 | 78 | |
79 | 79 | // Bailout. |
80 | - if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) { |
|
80 | + if (empty($this->supports) || ! $this->is_custom_meta_table_active()) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | - if ( in_array( 'add_post_metadata', $this->supports ) ) { |
|
85 | - add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 ); |
|
84 | + if (in_array('add_post_metadata', $this->supports)) { |
|
85 | + add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5); |
|
86 | 86 | } |
87 | 87 | |
88 | - if ( in_array( 'get_post_metadata', $this->supports ) ) { |
|
89 | - add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 0, 4 ); |
|
88 | + if (in_array('get_post_metadata', $this->supports)) { |
|
89 | + add_filter('get_post_metadata', array($this, '__get_meta'), 0, 4); |
|
90 | 90 | } |
91 | 91 | |
92 | - if ( in_array( 'update_post_metadata', $this->supports ) ) { |
|
93 | - add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 ); |
|
92 | + if (in_array('update_post_metadata', $this->supports)) { |
|
93 | + add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5); |
|
94 | 94 | } |
95 | 95 | |
96 | - if ( in_array( 'delete_post_metadata', $this->supports ) ) { |
|
97 | - add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 ); |
|
96 | + if (in_array('delete_post_metadata', $this->supports)) { |
|
97 | + add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5); |
|
98 | 98 | } |
99 | 99 | |
100 | - if ( in_array( 'posts_where', $this->supports ) ) { |
|
101 | - add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
100 | + if (in_array('posts_where', $this->supports)) { |
|
101 | + add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
102 | 102 | } |
103 | 103 | |
104 | - if ( in_array( 'posts_join', $this->supports ) ) { |
|
105 | - add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
104 | + if (in_array('posts_join', $this->supports)) { |
|
105 | + add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
106 | 106 | } |
107 | 107 | |
108 | - if ( in_array( 'posts_groupby', $this->supports ) ) { |
|
109 | - add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
108 | + if (in_array('posts_groupby', $this->supports)) { |
|
109 | + add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( in_array( 'posts_orderby', $this->supports ) ) { |
|
113 | - add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
112 | + if (in_array('posts_orderby', $this->supports)) { |
|
113 | + add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
129 | 129 | * is true. |
130 | 130 | */ |
131 | - public function get_meta( $id = 0, $meta_key = '', $single = false ) { |
|
132 | - $id = $this->sanitize_id( $id ); |
|
131 | + public function get_meta($id = 0, $meta_key = '', $single = false) { |
|
132 | + $id = $this->sanitize_id($id); |
|
133 | 133 | |
134 | 134 | // Bailout. |
135 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
135 | + if ( ! $this->is_valid_post_type($id)) { |
|
136 | 136 | return $this->check; |
137 | 137 | } |
138 | 138 | |
139 | - if ( $this->raw_result ) { |
|
140 | - if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) { |
|
139 | + if ($this->raw_result) { |
|
140 | + if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) { |
|
141 | 141 | $value = ''; |
142 | 142 | } |
143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->raw_result = false; |
146 | 146 | |
147 | 147 | } else { |
148 | - $value = get_metadata( $this->meta_type, $id, $meta_key, $single ); |
|
148 | + $value = get_metadata($this->meta_type, $id, $meta_key, $single); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $value; |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return int|bool False for failure. True for success. |
169 | 169 | */ |
170 | - public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
171 | - $id = $this->sanitize_id( $id ); |
|
170 | + public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
171 | + $id = $this->sanitize_id($id); |
|
172 | 172 | |
173 | 173 | // Bailout. |
174 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
174 | + if ( ! $this->is_valid_post_type($id)) { |
|
175 | 175 | return $this->check; |
176 | 176 | } |
177 | 177 | |
178 | - $meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
|
178 | + $meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique); |
|
179 | 179 | |
180 | - if ( $meta_id ) { |
|
181 | - $this->delete_cache( $id ); |
|
180 | + if ($meta_id) { |
|
181 | + $this->delete_cache($id); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return $meta_id; |
@@ -204,18 +204,18 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return int|bool False on failure, true if success. |
206 | 206 | */ |
207 | - public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
208 | - $id = $this->sanitize_id( $id ); |
|
207 | + public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
208 | + $id = $this->sanitize_id($id); |
|
209 | 209 | |
210 | 210 | // Bailout. |
211 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
211 | + if ( ! $this->is_valid_post_type($id)) { |
|
212 | 212 | return $this->check; |
213 | 213 | } |
214 | 214 | |
215 | - $meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
|
215 | + $meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value); |
|
216 | 216 | |
217 | - if ( $meta_id ) { |
|
218 | - $this->delete_cache( $id ); |
|
217 | + if ($meta_id) { |
|
218 | + $this->delete_cache($id); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return $meta_id; |
@@ -238,18 +238,18 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return bool False for failure. True for success. |
240 | 240 | */ |
241 | - public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
|
242 | - $id = $this->sanitize_id( $id ); |
|
241 | + public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') { |
|
242 | + $id = $this->sanitize_id($id); |
|
243 | 243 | |
244 | 244 | // Bailout. |
245 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
245 | + if ( ! $this->is_valid_post_type($id)) { |
|
246 | 246 | return $this->check; |
247 | 247 | } |
248 | 248 | |
249 | - $is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
|
249 | + $is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all); |
|
250 | 250 | |
251 | - if ( $is_meta_deleted ) { |
|
252 | - $this->delete_cache( $id ); |
|
251 | + if ($is_meta_deleted) { |
|
252 | + $this->delete_cache($id); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | return $is_meta_deleted; |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function __rename_meta_table_name_in_query( $clause, $wp_query ) { |
|
269 | + public function __rename_meta_table_name_in_query($clause, $wp_query) { |
|
270 | 270 | // Add new table to sql query. |
271 | - if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) { |
|
272 | - $clause = $this->__rename_meta_table_name( $clause, current_filter() ); |
|
271 | + if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) { |
|
272 | + $clause = $this->__rename_meta_table_name($clause, current_filter()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $clause; |
@@ -284,39 +284,39 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return mixed |
286 | 286 | */ |
287 | - public function __rename_meta_table_name( $clause, $filter ){ |
|
287 | + public function __rename_meta_table_name($clause, $filter) { |
|
288 | 288 | global $wpdb; |
289 | 289 | |
290 | - $clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause ); |
|
291 | - $clause = str_replace( $wpdb->postmeta, $this->table_name, $clause ); |
|
290 | + $clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause); |
|
291 | + $clause = str_replace($wpdb->postmeta, $this->table_name, $clause); |
|
292 | 292 | |
293 | - switch( $filter ) { |
|
293 | + switch ($filter) { |
|
294 | 294 | case 'posts_join': |
295 | - $joins = array( 'INNER JOIN', 'LEFT JOIN' ); |
|
295 | + $joins = array('INNER JOIN', 'LEFT JOIN'); |
|
296 | 296 | |
297 | - foreach ( $joins as $join ) { |
|
298 | - if( false !== strpos( $clause, $join ) ) { |
|
299 | - $clause = explode( $join, $clause ); |
|
297 | + foreach ($joins as $join) { |
|
298 | + if (false !== strpos($clause, $join)) { |
|
299 | + $clause = explode($join, $clause); |
|
300 | 300 | |
301 | - foreach ( $clause as $key => $clause_part ) { |
|
302 | - if( empty( $clause_part ) ) { |
|
301 | + foreach ($clause as $key => $clause_part) { |
|
302 | + if (empty($clause_part)) { |
|
303 | 303 | continue; |
304 | 304 | } |
305 | 305 | |
306 | - preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name ); |
|
306 | + preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name); |
|
307 | 307 | |
308 | - if( isset( $alias_table_name[1] ) ) { |
|
309 | - $clause[$key] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part ); |
|
308 | + if (isset($alias_table_name[1])) { |
|
309 | + $clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - $clause = implode( "{$join} ", $clause ); |
|
313 | + $clause = implode("{$join} ", $clause); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | break; |
317 | 317 | |
318 | 318 | case 'posts_where': |
319 | - $clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( "mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id" ), $clause ); |
|
319 | + $clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array("mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id"), $clause); |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | |
@@ -334,19 +334,19 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return bool |
336 | 336 | */ |
337 | - protected function is_post_type_query( $wp_query ) { |
|
337 | + protected function is_post_type_query($wp_query) { |
|
338 | 338 | $status = false; |
339 | 339 | |
340 | 340 | // Check if it is payment query. |
341 | - if ( ! empty( $wp_query->query['post_type'] ) ) { |
|
341 | + if ( ! empty($wp_query->query['post_type'])) { |
|
342 | 342 | if ( |
343 | - is_string( $wp_query->query['post_type'] ) && |
|
343 | + is_string($wp_query->query['post_type']) && |
|
344 | 344 | $this->post_type === $wp_query->query['post_type'] |
345 | 345 | ) { |
346 | 346 | $status = true; |
347 | 347 | } elseif ( |
348 | - is_array( $wp_query->query['post_type'] ) && |
|
349 | - in_array( $this->post_type, $wp_query->query['post_type'] ) |
|
348 | + is_array($wp_query->query['post_type']) && |
|
349 | + in_array($this->post_type, $wp_query->query['post_type']) |
|
350 | 350 | ) { |
351 | 351 | $status = true; |
352 | 352 | } |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return bool |
367 | 367 | */ |
368 | - protected function is_valid_post_type( $ID ) { |
|
369 | - return $ID && ( $this->post_type === get_post_type( $ID ) ); |
|
368 | + protected function is_valid_post_type($ID) { |
|
369 | + return $ID && ($this->post_type === get_post_type($ID)); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @return void |
394 | 394 | */ |
395 | - private function delete_cache( $id, $meta_type = '' ) { |
|
396 | - $meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type; |
|
395 | + private function delete_cache($id, $meta_type = '') { |
|
396 | + $meta_type = empty($meta_type) ? $this->meta_type : $meta_type; |
|
397 | 397 | |
398 | 398 | $group = array( |
399 | 399 | // 'form' => 'give-forms', |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | // 'log' => 'give-logs', |
404 | 404 | ); |
405 | 405 | |
406 | - if ( array_key_exists( $meta_type, $group ) ) { |
|
407 | - Give_Cache::delete_group( $id, $group[ $meta_type ] ); |
|
406 | + if (array_key_exists($meta_type, $group)) { |
|
407 | + Give_Cache::delete_group($id, $group[$meta_type]); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return mixed |
421 | 421 | */ |
422 | - public function __call( $name, $arguments ) { |
|
423 | - switch ( $name ) { |
|
422 | + public function __call($name, $arguments) { |
|
423 | + switch ($name) { |
|
424 | 424 | case '__add_meta': |
425 | 425 | $this->check = $arguments[0]; |
426 | 426 | $id = $arguments[1]; |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | $unique = $arguments[4]; |
430 | 430 | |
431 | 431 | // Bailout. |
432 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
432 | + if ( ! $this->is_valid_post_type($id)) { |
|
433 | 433 | return $this->check; |
434 | 434 | } |
435 | 435 | |
436 | - return $this->add_meta( $id, $meta_key, $meta_value, $unique ); |
|
436 | + return $this->add_meta($id, $meta_key, $meta_value, $unique); |
|
437 | 437 | |
438 | 438 | case '__get_meta': |
439 | 439 | $this->check = $arguments[0]; |
@@ -442,13 +442,13 @@ discard block |
||
442 | 442 | $single = $arguments[3]; |
443 | 443 | |
444 | 444 | // Bailout. |
445 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
445 | + if ( ! $this->is_valid_post_type($id)) { |
|
446 | 446 | return $this->check; |
447 | 447 | } |
448 | 448 | |
449 | 449 | $this->raw_result = true; |
450 | 450 | |
451 | - return $this->get_meta( $id, $meta_key, $single ); |
|
451 | + return $this->get_meta($id, $meta_key, $single); |
|
452 | 452 | |
453 | 453 | case '__update_meta': |
454 | 454 | $this->check = $arguments[0]; |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | $meta_value = $arguments[3]; |
458 | 458 | |
459 | 459 | // Bailout. |
460 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
460 | + if ( ! $this->is_valid_post_type($id)) { |
|
461 | 461 | return $this->check; |
462 | 462 | } |
463 | 463 | |
464 | - return $this->update_meta( $id, $meta_key, $meta_value ); |
|
464 | + return $this->update_meta($id, $meta_key, $meta_value); |
|
465 | 465 | |
466 | 466 | case '__delete_meta': |
467 | 467 | $this->check = $arguments[0]; |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | $delete_all = $arguments[3]; |
472 | 472 | |
473 | 473 | // Bailout. |
474 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
474 | + if ( ! $this->is_valid_post_type($id)) { |
|
475 | 475 | return $this->check; |
476 | 476 | } |
477 | 477 | |
478 | - return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all ); |
|
478 | + return $this->delete_meta($id, $meta_key, $meta_value, $delete_all); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | KEY meta_key (meta_key({$this->min_index_length})) |
501 | 501 | ) {$charset_collate};"; |
502 | 502 | |
503 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
504 | - dbDelta( $sql ); |
|
503 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
504 | + dbDelta($sql); |
|
505 | 505 | |
506 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
506 | + update_option($this->table_name.'_db_version', $this->version); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public function get_meta_type(){ |
|
518 | + public function get_meta_type() { |
|
519 | 519 | return $this->meta_type; |
520 | 520 | } |
521 | 521 | |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return bool False for failure. True for success. |
531 | 531 | */ |
532 | - public function delete_all_meta( $id = 0 ) { |
|
532 | + public function delete_all_meta($id = 0) { |
|
533 | 533 | global $wpdb; |
534 | - $status = $wpdb->delete( $this->table_name, array( "{$this->meta_type}_id" => $id ), array( '%d' ) ); |
|
534 | + $status = $wpdb->delete($this->table_name, array("{$this->meta_type}_id" => $id), array('%d')); |
|
535 | 535 | |
536 | - if ( $status ) { |
|
537 | - $this->delete_cache( $id, $this->meta_type ); |
|
536 | + if ($status) { |
|
537 | + $this->delete_cache($id, $this->meta_type); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | return $status; |
@@ -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,37 +23,37 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return mixed |
25 | 25 | */ |
26 | -function give_get_currency_formatting_settings( $id_or_currency_code = null ) { |
|
26 | +function give_get_currency_formatting_settings($id_or_currency_code = null) { |
|
27 | 27 | $give_options = give_get_settings(); |
28 | 28 | $setting = array(); |
29 | 29 | |
30 | - if ( ! empty( $id_or_currency_code ) ) { |
|
31 | - $currencies = give_get_currencies( 'all' ); |
|
30 | + if ( ! empty($id_or_currency_code)) { |
|
31 | + $currencies = give_get_currencies('all'); |
|
32 | 32 | |
33 | 33 | // Set default formatting setting only if currency not set as global currency. |
34 | 34 | if ( |
35 | - is_string( $id_or_currency_code ) && |
|
36 | - ! empty( $give_options['currency'] ) && |
|
35 | + is_string($id_or_currency_code) && |
|
36 | + ! empty($give_options['currency']) && |
|
37 | 37 | $id_or_currency_code !== $give_options['currency'] && |
38 | - array_key_exists( $id_or_currency_code, $currencies ) |
|
38 | + array_key_exists($id_or_currency_code, $currencies) |
|
39 | 39 | ) { |
40 | - $setting = $currencies[ $id_or_currency_code ]['setting']; |
|
41 | - } elseif ( is_numeric( $id_or_currency_code ) && 'give_payment' === get_post_type( $id_or_currency_code ) ) { |
|
42 | - $currency = give_get_meta( $id_or_currency_code, '_give_payment_currency', true ); |
|
40 | + $setting = $currencies[$id_or_currency_code]['setting']; |
|
41 | + } elseif (is_numeric($id_or_currency_code) && 'give_payment' === get_post_type($id_or_currency_code)) { |
|
42 | + $currency = give_get_meta($id_or_currency_code, '_give_payment_currency', true); |
|
43 | 43 | |
44 | 44 | if ( |
45 | - ! empty( $currency) && |
|
45 | + ! empty($currency) && |
|
46 | 46 | $give_options['currency'] !== $currency |
47 | 47 | ) { |
48 | - $setting = $currencies[ $currency ]['setting']; |
|
48 | + $setting = $currencies[$currency]['setting']; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - if ( empty( $setting ) ) { |
|
53 | + if (empty($setting)) { |
|
54 | 54 | // Set thousand separator. |
55 | - $thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ','; |
|
56 | - $thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator; |
|
55 | + $thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ','; |
|
56 | + $thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator; |
|
57 | 57 | |
58 | 58 | // Set decimal separator. |
59 | 59 | $default_decimal_separators = array( |
@@ -61,17 +61,16 @@ discard block |
||
61 | 61 | ',' => '.', |
62 | 62 | ); |
63 | 63 | |
64 | - $default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ? |
|
65 | - $default_decimal_separators[ $thousand_separator ] : |
|
66 | - '.'; |
|
64 | + $default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ? |
|
65 | + $default_decimal_separators[$thousand_separator] : '.'; |
|
67 | 66 | |
68 | - $decimal_separator = ! empty( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : $default_decimal_separator; |
|
67 | + $decimal_separator = ! empty($give_options['decimal_separator']) ? $give_options['decimal_separator'] : $default_decimal_separator; |
|
69 | 68 | |
70 | 69 | $setting = array( |
71 | - 'currency_position' => give_get_option( 'currency_position', 'before' ), |
|
70 | + 'currency_position' => give_get_option('currency_position', 'before'), |
|
72 | 71 | 'thousands_separator' => $thousand_separator, |
73 | 72 | 'decimal_separator' => $decimal_separator, |
74 | - 'number_decimals' => give_get_option( 'number_decimals', 0 ), |
|
73 | + 'number_decimals' => give_get_option('number_decimals', 0), |
|
75 | 74 | ); |
76 | 75 | } |
77 | 76 | |
@@ -80,7 +79,7 @@ discard block |
||
80 | 79 | * |
81 | 80 | * @since 1.8.15 |
82 | 81 | */ |
83 | - return apply_filters( 'give_get_currency_formatting_settings', $setting, $id_or_currency_code ); |
|
82 | + return apply_filters('give_get_currency_formatting_settings', $setting, $id_or_currency_code); |
|
84 | 83 | } |
85 | 84 | |
86 | 85 | /** |
@@ -92,16 +91,16 @@ discard block |
||
92 | 91 | * |
93 | 92 | * @return mixed |
94 | 93 | */ |
95 | -function give_get_price_decimals( $id_or_currency_code = null ) { |
|
94 | +function give_get_price_decimals($id_or_currency_code = null) { |
|
96 | 95 | // Set currency on basis of donation id. |
97 | - if ( empty( $id_or_currency_code ) ) { |
|
96 | + if (empty($id_or_currency_code)) { |
|
98 | 97 | $id_or_currency_code = give_get_currency(); |
99 | 98 | } |
100 | 99 | |
101 | 100 | $number_of_decimals = 0; |
102 | 101 | |
103 | - if ( ! give_is_zero_based_currency( $id_or_currency_code ) ) { |
|
104 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
102 | + if ( ! give_is_zero_based_currency($id_or_currency_code)) { |
|
103 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
105 | 104 | $number_of_decimals = $setting['number_decimals']; |
106 | 105 | } |
107 | 106 | |
@@ -110,7 +109,7 @@ discard block |
||
110 | 109 | * |
111 | 110 | * @since 1.6 |
112 | 111 | */ |
113 | - return apply_filters( 'give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code ); |
|
112 | + return apply_filters('give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code); |
|
114 | 113 | } |
115 | 114 | |
116 | 115 | /** |
@@ -122,15 +121,15 @@ discard block |
||
122 | 121 | * |
123 | 122 | * @return mixed |
124 | 123 | */ |
125 | -function give_get_price_thousand_separator( $id_or_currency_code = null ) { |
|
126 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
124 | +function give_get_price_thousand_separator($id_or_currency_code = null) { |
|
125 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
127 | 126 | |
128 | 127 | /** |
129 | 128 | * Filter the thousand separator |
130 | 129 | * |
131 | 130 | * @since 1.6 |
132 | 131 | */ |
133 | - return apply_filters( 'give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code ); |
|
132 | + return apply_filters('give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code); |
|
134 | 133 | } |
135 | 134 | |
136 | 135 | /** |
@@ -142,15 +141,15 @@ discard block |
||
142 | 141 | * |
143 | 142 | * @return mixed |
144 | 143 | */ |
145 | -function give_get_price_decimal_separator( $id_or_currency_code = null ) { |
|
146 | - $setting = give_get_currency_formatting_settings( $id_or_currency_code ); |
|
144 | +function give_get_price_decimal_separator($id_or_currency_code = null) { |
|
145 | + $setting = give_get_currency_formatting_settings($id_or_currency_code); |
|
147 | 146 | |
148 | 147 | /** |
149 | 148 | * Filter the thousand separator |
150 | 149 | * |
151 | 150 | * @since 1.6 |
152 | 151 | */ |
153 | - return apply_filters( 'give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code ); |
|
152 | + return apply_filters('give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code); |
|
154 | 153 | } |
155 | 154 | |
156 | 155 | |
@@ -163,8 +162,8 @@ discard block |
||
163 | 162 | * |
164 | 163 | * @return string $amount Newly sanitized amount |
165 | 164 | */ |
166 | -function give_sanitize_amount_for_db( $number ) { |
|
167 | - return give_maybe_sanitize_amount( $number, array( 'number_decimals' => 6 ) ); |
|
165 | +function give_sanitize_amount_for_db($number) { |
|
166 | + return give_maybe_sanitize_amount($number, array('number_decimals' => 6)); |
|
168 | 167 | } |
169 | 168 | |
170 | 169 | /** |
@@ -177,19 +176,19 @@ discard block |
||
177 | 176 | * |
178 | 177 | * @return string $amount Newly sanitized amount |
179 | 178 | */ |
180 | -function give_maybe_sanitize_amount( $number, $args = array() ) { |
|
179 | +function give_maybe_sanitize_amount($number, $args = array()) { |
|
181 | 180 | // Bailout. |
182 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
181 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
183 | 182 | return $number; |
184 | 183 | } |
185 | 184 | |
186 | 185 | $func_args = func_get_args(); |
187 | 186 | |
188 | 187 | // Backward compatibility. |
189 | - if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) { |
|
188 | + if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) { |
|
190 | 189 | $args = array( |
191 | 190 | 'number_decimals' => $func_args[1], |
192 | - 'trim_zeros' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
191 | + 'trim_zeros' => isset($func_args[2]) ? $func_args[2] : false, |
|
193 | 192 | ); |
194 | 193 | } |
195 | 194 | |
@@ -202,23 +201,22 @@ discard block |
||
202 | 201 | ) |
203 | 202 | ); |
204 | 203 | |
205 | - $thousand_separator = give_get_price_thousand_separator( $args['currency'] ); |
|
206 | - $decimal_separator = give_get_price_decimal_separator( $args['currency'] ); |
|
207 | - $number_decimals = is_bool( $args['number_decimals'] ) ? |
|
208 | - give_get_price_decimals() : |
|
209 | - $args['number_decimals']; |
|
204 | + $thousand_separator = give_get_price_thousand_separator($args['currency']); |
|
205 | + $decimal_separator = give_get_price_decimal_separator($args['currency']); |
|
206 | + $number_decimals = is_bool($args['number_decimals']) ? |
|
207 | + give_get_price_decimals() : $args['number_decimals']; |
|
210 | 208 | |
211 | 209 | // Explode number by . decimal separator. |
212 | - $number_parts = explode( '.', $number ); |
|
210 | + $number_parts = explode('.', $number); |
|
213 | 211 | |
214 | 212 | // Remove currency symbols from number if any. |
215 | - $number = trim( str_replace( give_currency_symbols( true ), '', $number ) ); |
|
213 | + $number = trim(str_replace(give_currency_symbols(true), '', $number)); |
|
216 | 214 | |
217 | 215 | if ( |
218 | 216 | // Non formatted number. |
219 | 217 | ( |
220 | - ( false === strpos( $number, $thousand_separator ) ) && |
|
221 | - ( false === strpos( $number, $decimal_separator ) ) |
|
218 | + (false === strpos($number, $thousand_separator)) && |
|
219 | + (false === strpos($number, $decimal_separator)) |
|
222 | 220 | ) || |
223 | 221 | |
224 | 222 | // Decimal formatted number. |
@@ -228,35 +226,35 @@ discard block |
||
228 | 226 | ( |
229 | 227 | $number_decimals && |
230 | 228 | '.' === $thousand_separator && |
231 | - false !== strpos( $number, $thousand_separator ) && |
|
232 | - false === strpos( $number, $decimal_separator ) && |
|
233 | - 2 === count( $number_parts ) && |
|
234 | - ( $number_decimals >= strlen( $number_parts[1] ) ) |
|
229 | + false !== strpos($number, $thousand_separator) && |
|
230 | + false === strpos($number, $decimal_separator) && |
|
231 | + 2 === count($number_parts) && |
|
232 | + ($number_decimals >= strlen($number_parts[1])) |
|
235 | 233 | ) |
236 | 234 | ) { |
237 | - return number_format( $number, $number_decimals, '.', '' ); |
|
235 | + return number_format($number, $number_decimals, '.', ''); |
|
238 | 236 | } |
239 | 237 | |
240 | 238 | // Handle thousand separator as '.' |
241 | 239 | // Handle sanitize database values. |
242 | - $is_db_sanitize_val = ( 2 === count( $number_parts ) && |
|
243 | - is_numeric( $number_parts[0] ) && |
|
244 | - is_numeric( $number_parts[1] ) && |
|
245 | - ( 6 === strlen( $number_parts[1] ) ) ); |
|
240 | + $is_db_sanitize_val = (2 === count($number_parts) && |
|
241 | + is_numeric($number_parts[0]) && |
|
242 | + is_numeric($number_parts[1]) && |
|
243 | + (6 === strlen($number_parts[1]))); |
|
246 | 244 | |
247 | - if ( $is_db_sanitize_val ) { |
|
245 | + if ($is_db_sanitize_val) { |
|
248 | 246 | // Sanitize database value. |
249 | - return number_format( $number, $number_decimals, '.', '' ); |
|
247 | + return number_format($number, $number_decimals, '.', ''); |
|
250 | 248 | |
251 | 249 | } elseif ( |
252 | 250 | '.' === $thousand_separator && |
253 | - false !== strpos( $number, $thousand_separator ) |
|
251 | + false !== strpos($number, $thousand_separator) |
|
254 | 252 | ) { |
255 | 253 | // Fix point thousand separator value. |
256 | - $number = str_replace( '.', '', $number ); |
|
254 | + $number = str_replace('.', '', $number); |
|
257 | 255 | } |
258 | 256 | |
259 | - return give_sanitize_amount( $number, $args ); |
|
257 | + return give_sanitize_amount($number, $args); |
|
260 | 258 | } |
261 | 259 | |
262 | 260 | /** |
@@ -273,10 +271,10 @@ discard block |
||
273 | 271 | * |
274 | 272 | * @return string $amount Newly sanitized amount |
275 | 273 | */ |
276 | -function give_sanitize_amount( $number, $args = array() ) { |
|
274 | +function give_sanitize_amount($number, $args = array()) { |
|
277 | 275 | |
278 | 276 | // Bailout. |
279 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
277 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
280 | 278 | return $number; |
281 | 279 | } |
282 | 280 | |
@@ -284,10 +282,10 @@ discard block |
||
284 | 282 | $func_args = func_get_args(); |
285 | 283 | |
286 | 284 | // Backward compatibility. |
287 | - if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) { |
|
285 | + if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) { |
|
288 | 286 | $args = array( |
289 | 287 | 'number_decimals' => $func_args[1], |
290 | - 'trim_zeros' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
288 | + 'trim_zeros' => isset($func_args[2]) ? $func_args[2] : false, |
|
291 | 289 | ); |
292 | 290 | } |
293 | 291 | |
@@ -303,58 +301,58 @@ discard block |
||
303 | 301 | // Remove slash from amount. |
304 | 302 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
305 | 303 | // To prevent notices and warning remove slash from amount/number. |
306 | - $number = wp_unslash( $number ); |
|
304 | + $number = wp_unslash($number); |
|
307 | 305 | |
308 | - $thousand_separator = give_get_price_thousand_separator( $args['currency'] ); |
|
306 | + $thousand_separator = give_get_price_thousand_separator($args['currency']); |
|
309 | 307 | |
310 | 308 | $locale = localeconv(); |
311 | 309 | $decimals = array( |
312 | - give_get_price_decimal_separator( $args['currency'] ), |
|
310 | + give_get_price_decimal_separator($args['currency']), |
|
313 | 311 | $locale['decimal_point'], |
314 | 312 | $locale['mon_decimal_point'], |
315 | 313 | ); |
316 | 314 | |
317 | 315 | // Remove locale from string |
318 | - if ( ! is_float( $number ) ) { |
|
319 | - $number = str_replace( $decimals, '.', $number ); |
|
316 | + if ( ! is_float($number)) { |
|
317 | + $number = str_replace($decimals, '.', $number); |
|
320 | 318 | } |
321 | 319 | |
322 | 320 | // Remove thousand amount formatting if amount has. |
323 | 321 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
324 | 322 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
325 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
326 | - $number = str_replace( $thousand_separator, '', $number ); |
|
327 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
328 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
323 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
324 | + $number = str_replace($thousand_separator, '', $number); |
|
325 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
326 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
329 | 327 | } |
330 | 328 | |
331 | 329 | // Remove non numeric entity before decimal separator. |
332 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
333 | - $default_dp = give_get_price_decimals( $args['currency'] ); |
|
330 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
331 | + $default_dp = give_get_price_decimals($args['currency']); |
|
334 | 332 | |
335 | 333 | // Reset negative amount to zero. |
336 | - if ( 0 > $number ) { |
|
337 | - $number = number_format( 0, $default_dp, '.' ); |
|
334 | + if (0 > $number) { |
|
335 | + $number = number_format(0, $default_dp, '.'); |
|
338 | 336 | } |
339 | 337 | |
340 | 338 | // If number does not have decimal then add number of decimals to it. |
341 | 339 | if ( |
342 | - false === strpos( $number, '.' ) |
|
343 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
340 | + false === strpos($number, '.') |
|
341 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
344 | 342 | ) { |
345 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
343 | + $number = number_format($number, $default_dp, '.', ''); |
|
346 | 344 | } |
347 | 345 | |
348 | 346 | // Format number by custom number of decimals. |
349 | - if ( false !== $args['number_decimals'] ) { |
|
350 | - $dp = intval( is_bool( $args['number_decimals'] ) ? $default_dp : $args['number_decimals'] ); |
|
351 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
352 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
347 | + if (false !== $args['number_decimals']) { |
|
348 | + $dp = intval(is_bool($args['number_decimals']) ? $default_dp : $args['number_decimals']); |
|
349 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
350 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
353 | 351 | } |
354 | 352 | |
355 | 353 | // Trim zeros. |
356 | - if ( $args['trim_zeros'] && strstr( $number, '.' ) ) { |
|
357 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
354 | + if ($args['trim_zeros'] && strstr($number, '.')) { |
|
355 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
358 | 356 | } |
359 | 357 | |
360 | 358 | /** |
@@ -362,7 +360,7 @@ discard block |
||
362 | 360 | * |
363 | 361 | * @since 1.0 |
364 | 362 | */ |
365 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
363 | + return apply_filters('give_sanitize_amount', $number); |
|
366 | 364 | } |
367 | 365 | |
368 | 366 | /** |
@@ -375,9 +373,9 @@ discard block |
||
375 | 373 | * |
376 | 374 | * @return string $amount Newly formatted amount or Price Not Available |
377 | 375 | */ |
378 | -function give_format_amount( $amount, $args = array() ) { |
|
376 | +function give_format_amount($amount, $args = array()) { |
|
379 | 377 | // Backward compatibility. |
380 | - if ( is_bool( $args ) ) { |
|
378 | + if (is_bool($args)) { |
|
381 | 379 | $args = array( |
382 | 380 | 'decimal' => $args, |
383 | 381 | ); |
@@ -390,60 +388,59 @@ discard block |
||
390 | 388 | 'currency' => '', |
391 | 389 | ); |
392 | 390 | |
393 | - $args = wp_parse_args( $args, $default_args ); |
|
391 | + $args = wp_parse_args($args, $default_args); |
|
394 | 392 | |
395 | 393 | // Set Currency based on donation id, if required. |
396 | - if ( $args['donation_id'] && empty( $args['currency'] ) ) { |
|
397 | - $args['currency'] = give_get_meta( $args['donation_id'], '_give_payment_currency', true ); |
|
394 | + if ($args['donation_id'] && empty($args['currency'])) { |
|
395 | + $args['currency'] = give_get_meta($args['donation_id'], '_give_payment_currency', true); |
|
398 | 396 | } |
399 | 397 | |
400 | 398 | $formatted = 0; |
401 | - $currency = ! empty( $args['currency'] ) ? $args['currency'] : give_get_currency( $args['donation_id'] ); |
|
402 | - $thousands_sep = give_get_price_thousand_separator( $currency ); |
|
403 | - $decimal_sep = give_get_price_decimal_separator( $currency ); |
|
404 | - $decimals = ! empty( $args['decimal'] ) ? give_get_price_decimals( $currency ) : 0; |
|
399 | + $currency = ! empty($args['currency']) ? $args['currency'] : give_get_currency($args['donation_id']); |
|
400 | + $thousands_sep = give_get_price_thousand_separator($currency); |
|
401 | + $decimal_sep = give_get_price_decimal_separator($currency); |
|
402 | + $decimals = ! empty($args['decimal']) ? give_get_price_decimals($currency) : 0; |
|
405 | 403 | |
406 | - if ( ! empty( $amount ) ) { |
|
404 | + if ( ! empty($amount)) { |
|
407 | 405 | // Sanitize amount before formatting. |
408 | - $amount = ! empty( $args['sanitize'] ) ? |
|
409 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $decimals, 'currency' => $currency ) ) : |
|
410 | - number_format( $amount, $decimals, '.', '' ); |
|
406 | + $amount = ! empty($args['sanitize']) ? |
|
407 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $decimals, 'currency' => $currency)) : number_format($amount, $decimals, '.', ''); |
|
411 | 408 | |
412 | - switch ( $currency ) { |
|
409 | + switch ($currency) { |
|
413 | 410 | case 'INR': |
414 | 411 | $decimal_amount = ''; |
415 | 412 | |
416 | 413 | // Extract decimals from amount |
417 | - if ( ( $pos = strpos( $amount, '.' ) ) !== false ) { |
|
418 | - if ( ! empty( $decimals ) ) { |
|
419 | - $decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 ); |
|
420 | - $amount = substr( $amount, 0, $pos ); |
|
421 | - |
|
422 | - if ( ! $decimal_amount ) { |
|
423 | - $decimal_amount = substr( "{$decimal_sep}0000000000", 0, ( $decimals + 1 ) ); |
|
424 | - } elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) { |
|
425 | - $decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) ); |
|
414 | + if (($pos = strpos($amount, '.')) !== false) { |
|
415 | + if ( ! empty($decimals)) { |
|
416 | + $decimal_amount = substr(round(substr($amount, $pos), $decimals), 1); |
|
417 | + $amount = substr($amount, 0, $pos); |
|
418 | + |
|
419 | + if ( ! $decimal_amount) { |
|
420 | + $decimal_amount = substr("{$decimal_sep}0000000000", 0, ($decimals + 1)); |
|
421 | + } elseif (($decimals + 1) > strlen($decimal_amount)) { |
|
422 | + $decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1)); |
|
426 | 423 | } |
427 | 424 | } else { |
428 | - $amount = number_format( $amount, $decimals, $decimal_sep, '' ); |
|
425 | + $amount = number_format($amount, $decimals, $decimal_sep, ''); |
|
429 | 426 | } |
430 | 427 | } |
431 | 428 | |
432 | 429 | // Extract last 3 from amount |
433 | - $result = substr( $amount, - 3 ); |
|
434 | - $amount = substr( $amount, 0, - 3 ); |
|
430 | + $result = substr($amount, - 3); |
|
431 | + $amount = substr($amount, 0, - 3); |
|
435 | 432 | |
436 | 433 | // Apply digits 2 by 2 |
437 | - while ( strlen( $amount ) > 0 ) { |
|
438 | - $result = substr( $amount, - 2 ) . $thousands_sep . $result; |
|
439 | - $amount = substr( $amount, 0, - 2 ); |
|
434 | + while (strlen($amount) > 0) { |
|
435 | + $result = substr($amount, - 2).$thousands_sep.$result; |
|
436 | + $amount = substr($amount, 0, - 2); |
|
440 | 437 | } |
441 | 438 | |
442 | - $formatted = $result . $decimal_amount; |
|
439 | + $formatted = $result.$decimal_amount; |
|
443 | 440 | break; |
444 | 441 | |
445 | 442 | default: |
446 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
443 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
447 | 444 | } |
448 | 445 | } |
449 | 446 | |
@@ -452,7 +449,7 @@ discard block |
||
452 | 449 | * |
453 | 450 | * @since 1.0 |
454 | 451 | */ |
455 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args ); |
|
452 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args); |
|
456 | 453 | } |
457 | 454 | |
458 | 455 | |
@@ -470,17 +467,17 @@ discard block |
||
470 | 467 | * |
471 | 468 | * @return string formatted amount number with large number names. |
472 | 469 | */ |
473 | -function give_human_format_large_amount( $amount, $args = array() ) { |
|
470 | +function give_human_format_large_amount($amount, $args = array()) { |
|
474 | 471 | // Sanitize amount. |
475 | - $sanitize_amount = give_maybe_sanitize_amount( $amount ); |
|
472 | + $sanitize_amount = give_maybe_sanitize_amount($amount); |
|
476 | 473 | |
477 | 474 | // Bailout. |
478 | - if ( ! floatval( $sanitize_amount ) ) { |
|
475 | + if ( ! floatval($sanitize_amount)) { |
|
479 | 476 | return '0'; |
480 | 477 | }; |
481 | 478 | |
482 | 479 | // Set default currency; |
483 | - if ( empty( $args['currency'] ) ) { |
|
480 | + if (empty($args['currency'])) { |
|
484 | 481 | $args['currency'] = give_get_currency(); |
485 | 482 | } |
486 | 483 | |
@@ -488,37 +485,37 @@ discard block |
||
488 | 485 | $thousands_sep = give_get_price_thousand_separator(); |
489 | 486 | |
490 | 487 | // Explode amount to calculate name of large numbers. |
491 | - $amount_array = explode( $thousands_sep, $amount ); |
|
488 | + $amount_array = explode($thousands_sep, $amount); |
|
492 | 489 | |
493 | 490 | // Calculate amount parts count. |
494 | - $amount_count_parts = count( $amount_array ); |
|
491 | + $amount_count_parts = count($amount_array); |
|
495 | 492 | |
496 | 493 | // Human format amount (default). |
497 | 494 | $human_format_amount = $amount; |
498 | 495 | |
499 | - switch ( $args['currency'] ) { |
|
496 | + switch ($args['currency']) { |
|
500 | 497 | case 'INR': |
501 | 498 | // Calculate large number formatted amount. |
502 | - if ( 4 < $amount_count_parts ) { |
|
503 | - $human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
504 | - } elseif ( 3 < $amount_count_parts ) { |
|
505 | - $human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) ); |
|
506 | - } elseif ( 2 < $amount_count_parts ) { |
|
507 | - $human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) ); |
|
499 | + if (4 < $amount_count_parts) { |
|
500 | + $human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
501 | + } elseif (3 < $amount_count_parts) { |
|
502 | + $human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2)); |
|
503 | + } elseif (2 < $amount_count_parts) { |
|
504 | + $human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2)); |
|
508 | 505 | } |
509 | 506 | break; |
510 | 507 | default: |
511 | 508 | // Calculate large number formatted amount. |
512 | - if ( 4 < $amount_count_parts ) { |
|
513 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
514 | - } elseif ( 3 < $amount_count_parts ) { |
|
515 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
516 | - } elseif ( 2 < $amount_count_parts ) { |
|
517 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
509 | + if (4 < $amount_count_parts) { |
|
510 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
511 | + } elseif (3 < $amount_count_parts) { |
|
512 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
513 | + } elseif (2 < $amount_count_parts) { |
|
514 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
518 | 515 | } |
519 | 516 | } |
520 | 517 | |
521 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
518 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
522 | 519 | } |
523 | 520 | |
524 | 521 | /** |
@@ -532,17 +529,16 @@ discard block |
||
532 | 529 | * |
533 | 530 | * @return string $amount Newly formatted amount or Price Not Available |
534 | 531 | */ |
535 | -function give_format_decimal( $amount, $dp = false, $sanitize = true ) { |
|
532 | +function give_format_decimal($amount, $dp = false, $sanitize = true) { |
|
536 | 533 | $decimal_separator = give_get_price_decimal_separator(); |
537 | 534 | $formatted_amount = $sanitize ? |
538 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $dp ) ) : |
|
539 | - number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
535 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $dp)) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
540 | 536 | |
541 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
542 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
537 | + if (false !== strpos($formatted_amount, '.')) { |
|
538 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
543 | 539 | } |
544 | 540 | |
545 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
541 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
546 | 542 | } |
547 | 543 | |
548 | 544 | /** |
@@ -554,7 +550,7 @@ discard block |
||
554 | 550 | * |
555 | 551 | * @return string Date format string |
556 | 552 | */ |
557 | -function give_date_format( $date_context = '' ) { |
|
553 | +function give_date_format($date_context = '') { |
|
558 | 554 | /** |
559 | 555 | * Filter the date context |
560 | 556 | * |
@@ -575,19 +571,19 @@ discard block |
||
575 | 571 | * |
576 | 572 | * } |
577 | 573 | */ |
578 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
574 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
579 | 575 | |
580 | 576 | // Set date format to default date format. |
581 | - $date_format = get_option( 'date_format' ); |
|
577 | + $date_format = get_option('date_format'); |
|
582 | 578 | |
583 | 579 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
584 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
585 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
586 | - ? $date_format_contexts[ $date_context ] |
|
580 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
581 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
582 | + ? $date_format_contexts[$date_context] |
|
587 | 583 | : $date_format; |
588 | 584 | } |
589 | 585 | |
590 | - return apply_filters( 'give_date_format', $date_format ); |
|
586 | + return apply_filters('give_date_format', $date_format); |
|
591 | 587 | } |
592 | 588 | |
593 | 589 | /** |
@@ -601,8 +597,8 @@ discard block |
||
601 | 597 | * |
602 | 598 | * @return string |
603 | 599 | */ |
604 | -function give_get_cache_key( $action, $query_args ) { |
|
605 | - return Give_Cache::get_key( $action, $query_args ); |
|
600 | +function give_get_cache_key($action, $query_args) { |
|
601 | + return Give_Cache::get_key($action, $query_args); |
|
606 | 602 | } |
607 | 603 | |
608 | 604 | /** |
@@ -615,11 +611,11 @@ discard block |
||
615 | 611 | * |
616 | 612 | * @return string|array |
617 | 613 | */ |
618 | -function give_clean( $var ) { |
|
619 | - if ( is_array( $var ) ) { |
|
620 | - return array_map( 'give_clean', $var ); |
|
614 | +function give_clean($var) { |
|
615 | + if (is_array($var)) { |
|
616 | + return array_map('give_clean', $var); |
|
621 | 617 | } else { |
622 | - return is_scalar( $var ) ? sanitize_text_field( wp_unslash( $var ) ) : $var; |
|
618 | + return is_scalar($var) ? sanitize_text_field(wp_unslash($var)) : $var; |
|
623 | 619 | } |
624 | 620 | } |
625 | 621 | |
@@ -632,10 +628,10 @@ discard block |
||
632 | 628 | * |
633 | 629 | * @return int |
634 | 630 | */ |
635 | -function give_let_to_num( $size ) { |
|
636 | - $l = substr( $size, - 1 ); |
|
637 | - $ret = substr( $size, 0, - 1 ); |
|
638 | - switch ( strtoupper( $l ) ) { |
|
631 | +function give_let_to_num($size) { |
|
632 | + $l = substr($size, - 1); |
|
633 | + $ret = substr($size, 0, - 1); |
|
634 | + switch (strtoupper($l)) { |
|
639 | 635 | case 'P': |
640 | 636 | $ret *= 1024; |
641 | 637 | case 'T': |
@@ -662,22 +658,22 @@ discard block |
||
662 | 658 | * |
663 | 659 | * @return bool |
664 | 660 | */ |
665 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
661 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
666 | 662 | |
667 | 663 | // Verify nonce. |
668 | - $verify_nonce = wp_verify_nonce( $nonce, $action ); |
|
664 | + $verify_nonce = wp_verify_nonce($nonce, $action); |
|
669 | 665 | |
670 | 666 | // On ajax request send nonce verification status. |
671 | - if ( wp_doing_ajax() ) { |
|
667 | + if (wp_doing_ajax()) { |
|
672 | 668 | return $verify_nonce; |
673 | 669 | } |
674 | 670 | |
675 | - if ( ! $verify_nonce ) { |
|
671 | + if ( ! $verify_nonce) { |
|
676 | 672 | $wp_die_args = wp_parse_args( |
677 | 673 | $wp_die_args, |
678 | 674 | array( |
679 | - 'message' => __( 'Nonce verification has failed.', 'give' ), |
|
680 | - 'title' => __( 'Error', 'give' ), |
|
675 | + 'message' => __('Nonce verification has failed.', 'give'), |
|
676 | + 'title' => __('Error', 'give'), |
|
681 | 677 | 'args' => array( |
682 | 678 | 'response' => 403, |
683 | 679 | ), |
@@ -704,16 +700,16 @@ discard block |
||
704 | 700 | * |
705 | 701 | * @return bool |
706 | 702 | */ |
707 | -function give_verify_donation_form_nonce( $nonce = '', $form_id ) { |
|
703 | +function give_verify_donation_form_nonce($nonce = '', $form_id) { |
|
708 | 704 | |
709 | 705 | // Form nonce action. |
710 | 706 | $nonce_action = "give_donation_form_nonce_{$form_id}"; |
711 | 707 | |
712 | 708 | // Nonce validation. |
713 | - $verify_nonce = give_validate_nonce( $nonce, $nonce_action ); |
|
709 | + $verify_nonce = give_validate_nonce($nonce, $nonce_action); |
|
714 | 710 | |
715 | - if ( ! $verify_nonce ) { |
|
716 | - give_set_error( 'donation_form_nonce', __( 'Nonce verification has failed.', 'give' ) ); |
|
711 | + if ( ! $verify_nonce) { |
|
712 | + give_set_error('donation_form_nonce', __('Nonce verification has failed.', 'give')); |
|
717 | 713 | } |
718 | 714 | |
719 | 715 | return $verify_nonce; |
@@ -733,43 +729,43 @@ discard block |
||
733 | 729 | * |
734 | 730 | * @return mixed |
735 | 731 | */ |
736 | -function give_check_variable( $variable, $conditional = '', $default = false, $array_key_name = '' ) { |
|
732 | +function give_check_variable($variable, $conditional = '', $default = false, $array_key_name = '') { |
|
737 | 733 | // Get value from array if array key non empty. |
738 | - if( empty( $array_key_name ) ) { |
|
739 | - switch ( $conditional ) { |
|
734 | + if (empty($array_key_name)) { |
|
735 | + switch ($conditional) { |
|
740 | 736 | case 'isset_empty': |
741 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
737 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
742 | 738 | break; |
743 | 739 | |
744 | 740 | case 'empty': |
745 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
741 | + $variable = ! empty($variable) ? $variable : $default; |
|
746 | 742 | break; |
747 | 743 | |
748 | 744 | case 'null': |
749 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
745 | + $variable = ! is_null($variable) ? $variable : $default; |
|
750 | 746 | break; |
751 | 747 | |
752 | 748 | default: |
753 | - $variable = isset( $variable ) ? $variable : $default; |
|
749 | + $variable = isset($variable) ? $variable : $default; |
|
754 | 750 | } |
755 | 751 | } else { |
756 | - $isset = array_key_exists( $array_key_name, $variable ); |
|
752 | + $isset = array_key_exists($array_key_name, $variable); |
|
757 | 753 | |
758 | - switch ( $conditional ) { |
|
754 | + switch ($conditional) { |
|
759 | 755 | case 'isset_empty': |
760 | - $variable = ( $isset && ! empty( $variable[ $array_key_name ] ) ) ? $variable[ $array_key_name ] : $default; |
|
756 | + $variable = ($isset && ! empty($variable[$array_key_name])) ? $variable[$array_key_name] : $default; |
|
761 | 757 | break; |
762 | 758 | |
763 | 759 | case 'empty': |
764 | - $variable = ! empty( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
760 | + $variable = ! empty($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
765 | 761 | break; |
766 | 762 | |
767 | 763 | case 'null': |
768 | - $variable = $isset && ! is_null( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
764 | + $variable = $isset && ! is_null($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
769 | 765 | break; |
770 | 766 | |
771 | 767 | default: |
772 | - $variable = $isset && isset( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
768 | + $variable = $isset && isset($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
773 | 769 | } |
774 | 770 | } |
775 | 771 |
@@ -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 | |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array $payments Payments retrieved from the database |
46 | 46 | */ |
47 | -function give_get_payments( $args = array() ) { |
|
47 | +function give_get_payments($args = array()) { |
|
48 | 48 | |
49 | 49 | // Fallback to post objects to ensure backwards compatibility. |
50 | - if ( ! isset( $args['output'] ) ) { |
|
50 | + if ( ! isset($args['output'])) { |
|
51 | 51 | $args['output'] = 'posts'; |
52 | 52 | } |
53 | 53 | |
54 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
55 | - $payments = new Give_Payments_Query( $args ); |
|
54 | + $args = apply_filters('give_get_payments_args', $args); |
|
55 | + $payments = new Give_Payments_Query($args); |
|
56 | 56 | |
57 | 57 | return $payments->get_payments(); |
58 | 58 | } |
@@ -67,19 +67,19 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return mixed |
69 | 69 | */ |
70 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
70 | +function give_get_payment_by($field = '', $value = '') { |
|
71 | 71 | |
72 | - if ( empty( $field ) || empty( $value ) ) { |
|
72 | + if (empty($field) || empty($value)) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | |
76 | - switch ( strtolower( $field ) ) { |
|
76 | + switch (strtolower($field)) { |
|
77 | 77 | |
78 | 78 | case 'id': |
79 | - $payment = new Give_Payment( $value ); |
|
79 | + $payment = new Give_Payment($value); |
|
80 | 80 | $id = $payment->ID; |
81 | 81 | |
82 | - if ( empty( $id ) ) { |
|
82 | + if (empty($id)) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | ) |
96 | 96 | ); |
97 | 97 | |
98 | - if ( $payment ) { |
|
99 | - $payment = new Give_Payment( $payment[0] ); |
|
98 | + if ($payment) { |
|
99 | + $payment = new Give_Payment($payment[0]); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | break; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | ) |
112 | 112 | ); |
113 | 113 | |
114 | - if ( $payment ) { |
|
115 | - $payment = new Give_Payment( $payment[0] ); |
|
114 | + if ($payment) { |
|
115 | + $payment = new Give_Payment($payment[0]); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | break; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | }// End switch(). |
123 | 123 | |
124 | - if ( $payment ) { |
|
124 | + if ($payment) { |
|
125 | 125 | return $payment; |
126 | 126 | } |
127 | 127 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
139 | 139 | */ |
140 | -function give_insert_payment( $payment_data = array() ) { |
|
140 | +function give_insert_payment($payment_data = array()) { |
|
141 | 141 | |
142 | - if ( empty( $payment_data ) ) { |
|
142 | + if (empty($payment_data)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
@@ -150,25 +150,25 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param array $payment_data Arguments passed. |
152 | 152 | */ |
153 | - $payment_data = apply_filters( 'give_pre_insert_payment', $payment_data ); |
|
153 | + $payment_data = apply_filters('give_pre_insert_payment', $payment_data); |
|
154 | 154 | |
155 | 155 | $payment = new Give_Payment(); |
156 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
157 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
158 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
159 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
160 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
156 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
157 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
158 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
159 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
160 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
161 | 161 | |
162 | 162 | // Set properties. |
163 | 163 | $payment->total = $payment_data['price']; |
164 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
165 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data ); |
|
164 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
165 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data); |
|
166 | 166 | $payment->user_info = $payment_data['user_info']; |
167 | 167 | $payment->gateway = $gateway; |
168 | 168 | $payment->form_title = $form_title; |
169 | 169 | $payment->form_id = $form_id; |
170 | 170 | $payment->price_id = $price_id; |
171 | - $payment->donor_id = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' ); |
|
171 | + $payment->donor_id = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : ''); |
|
172 | 172 | $payment->user_id = $payment_data['user_info']['id']; |
173 | 173 | $payment->email = $payment_data['user_email']; |
174 | 174 | $payment->first_name = $payment_data['user_info']['first_name']; |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | $payment->email = $payment_data['user_info']['email']; |
177 | 177 | $payment->ip = give_get_ip(); |
178 | 178 | $payment->key = $payment_data['purchase_key']; |
179 | - $payment->mode = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) ); |
|
180 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
179 | + $payment->mode = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live')); |
|
180 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
181 | 181 | |
182 | 182 | // Add the donation. |
183 | 183 | $args = array( |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | 'price_id' => $payment->price_id, |
186 | 186 | ); |
187 | 187 | |
188 | - $payment->add_donation( $payment->form_id, $args ); |
|
188 | + $payment->add_donation($payment->form_id, $args); |
|
189 | 189 | |
190 | 190 | // Set date if present. |
191 | - if ( isset( $payment_data['post_date'] ) ) { |
|
191 | + if (isset($payment_data['post_date'])) { |
|
192 | 192 | $payment->date = $payment_data['post_date']; |
193 | 193 | } |
194 | 194 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $payment->save(); |
197 | 197 | |
198 | 198 | // Setup donor id. |
199 | - if ( empty( $payment_data['user_info']['id'] ) ) { |
|
199 | + if (empty($payment_data['user_info']['id'])) { |
|
200 | 200 | $payment_data['user_info']['id'] = $payment->donor_id; |
201 | 201 | } |
202 | 202 | |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | * @param int $payment_id The payment ID. |
209 | 209 | * @param array $payment_data Arguments passed. |
210 | 210 | */ |
211 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
211 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
212 | 212 | |
213 | 213 | // Return payment ID upon success. |
214 | - if ( ! empty( $payment->ID ) ) { |
|
214 | + if ( ! empty($payment->ID)) { |
|
215 | 215 | return $payment->ID; |
216 | 216 | } |
217 | 217 | |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return bool|int |
229 | 229 | */ |
230 | -function give_create_payment( $payment_data ) { |
|
230 | +function give_create_payment($payment_data) { |
|
231 | 231 | |
232 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
233 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
232 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
233 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
234 | 234 | |
235 | 235 | // Collect payment data. |
236 | 236 | $insert_payment_data = array( |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | 'date' => $payment_data['date'], |
242 | 242 | 'user_email' => $payment_data['user_email'], |
243 | 243 | 'purchase_key' => $payment_data['purchase_key'], |
244 | - 'currency' => give_get_currency( $form_id, $payment_data ), |
|
244 | + 'currency' => give_get_currency($form_id, $payment_data), |
|
245 | 245 | 'user_info' => $payment_data['user_info'], |
246 | 246 | 'status' => 'pending', |
247 | 247 | 'gateway' => 'paypal', |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param array $insert_payment_data |
256 | 256 | */ |
257 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
257 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
258 | 258 | |
259 | 259 | // Record the pending payment. |
260 | - return give_insert_payment( $insert_payment_data ); |
|
260 | + return give_insert_payment($insert_payment_data); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return bool |
272 | 272 | */ |
273 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
273 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
274 | 274 | |
275 | 275 | $updated = false; |
276 | - $payment = new Give_Payment( $payment_id ); |
|
276 | + $payment = new Give_Payment($payment_id); |
|
277 | 277 | |
278 | - if ( $payment && $payment->ID > 0 ) { |
|
278 | + if ($payment && $payment->ID > 0) { |
|
279 | 279 | |
280 | 280 | $payment->status = $new_status; |
281 | 281 | $updated = $payment->save(); |
@@ -296,17 +296,17 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return void |
298 | 298 | */ |
299 | -function give_delete_donation( $payment_id = 0, $update_donor = true ) { |
|
300 | - $payment = new Give_Payment( $payment_id ); |
|
299 | +function give_delete_donation($payment_id = 0, $update_donor = true) { |
|
300 | + $payment = new Give_Payment($payment_id); |
|
301 | 301 | |
302 | 302 | // Bailout. |
303 | - if ( ! $payment->ID ) { |
|
303 | + if ( ! $payment->ID) { |
|
304 | 304 | return; |
305 | 305 | } |
306 | 306 | |
307 | - $amount = give_donation_amount( $payment_id ); |
|
307 | + $amount = give_donation_amount($payment_id); |
|
308 | 308 | $status = $payment->post_status; |
309 | - $donor = new Give_Donor( $payment->donor_id ); |
|
309 | + $donor = new Give_Donor($payment->donor_id); |
|
310 | 310 | |
311 | 311 | // Only undo donations that aren't these statuses. |
312 | 312 | $dont_undo_statuses = apply_filters( |
@@ -316,26 +316,26 @@ discard block |
||
316 | 316 | ) |
317 | 317 | ); |
318 | 318 | |
319 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
320 | - give_undo_donation( $payment_id ); |
|
319 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
320 | + give_undo_donation($payment_id); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | // Only undo donations that aren't these statuses. |
324 | - $status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) ); |
|
324 | + $status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish')); |
|
325 | 325 | |
326 | - if ( in_array( $status, $status_to_decrease_stats ) ) { |
|
326 | + if (in_array($status, $status_to_decrease_stats)) { |
|
327 | 327 | |
328 | 328 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
329 | - give_decrease_total_earnings( $amount ); |
|
329 | + give_decrease_total_earnings($amount); |
|
330 | 330 | |
331 | 331 | // @todo: Refresh only range related stat cache |
332 | 332 | give_delete_donation_stats(); |
333 | 333 | |
334 | - if ( $donor->id && $update_donor ) { |
|
334 | + if ($donor->id && $update_donor) { |
|
335 | 335 | |
336 | 336 | // Decrement the stats for the donor. |
337 | 337 | $donor->decrease_donation_count(); |
338 | - $donor->decrease_value( $amount ); |
|
338 | + $donor->decrease_value($amount); |
|
339 | 339 | |
340 | 340 | } |
341 | 341 | } |
@@ -347,20 +347,20 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @since 1.0 |
349 | 349 | */ |
350 | - do_action( 'give_payment_delete', $payment_id ); |
|
350 | + do_action('give_payment_delete', $payment_id); |
|
351 | 351 | |
352 | - if ( $donor->id && $update_donor ) { |
|
352 | + if ($donor->id && $update_donor) { |
|
353 | 353 | // Remove the payment ID from the donor. |
354 | - $donor->remove_payment( $payment_id ); |
|
354 | + $donor->remove_payment($payment_id); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | // Remove the payment. |
358 | - wp_delete_post( $payment_id, true ); |
|
358 | + wp_delete_post($payment_id, true); |
|
359 | 359 | |
360 | - Give()->payment_meta->delete_all_meta( $payment_id ); |
|
360 | + Give()->payment_meta->delete_all_meta($payment_id); |
|
361 | 361 | |
362 | 362 | // Remove related sale log entries. |
363 | - Give()->logs->delete_logs( $payment_id ); |
|
363 | + Give()->logs->delete_logs($payment_id); |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Fires after payment deleted. |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @since 1.0 |
371 | 371 | */ |
372 | - do_action( 'give_payment_deleted', $payment_id ); |
|
372 | + do_action('give_payment_deleted', $payment_id); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -384,20 +384,20 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return void |
386 | 386 | */ |
387 | -function give_undo_donation( $payment_id ) { |
|
387 | +function give_undo_donation($payment_id) { |
|
388 | 388 | |
389 | - $payment = new Give_Payment( $payment_id ); |
|
389 | + $payment = new Give_Payment($payment_id); |
|
390 | 390 | |
391 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
392 | - if ( true === $maybe_decrease_earnings ) { |
|
391 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
392 | + if (true === $maybe_decrease_earnings) { |
|
393 | 393 | // Decrease earnings. |
394 | - give_decrease_form_earnings( $payment->form_id, $payment->total, $payment_id ); |
|
394 | + give_decrease_form_earnings($payment->form_id, $payment->total, $payment_id); |
|
395 | 395 | } |
396 | 396 | |
397 | - $maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id ); |
|
398 | - if ( true === $maybe_decrease_donations ) { |
|
397 | + $maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id); |
|
398 | + if (true === $maybe_decrease_donations) { |
|
399 | 399 | // Decrease donation count. |
400 | - give_decrease_donation_count( $payment->form_id ); |
|
400 | + give_decrease_donation_count($payment->form_id); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | } |
@@ -414,21 +414,21 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return object $stats Contains the number of payments per payment status. |
416 | 416 | */ |
417 | -function give_count_payments( $args = array() ) { |
|
417 | +function give_count_payments($args = array()) { |
|
418 | 418 | // Backward compatibility. |
419 | - if ( ! empty( $args['start-date'] ) ) { |
|
419 | + if ( ! empty($args['start-date'])) { |
|
420 | 420 | $args['start_date'] = $args['start-date']; |
421 | - unset( $args['start-date'] ); |
|
421 | + unset($args['start-date']); |
|
422 | 422 | } |
423 | 423 | |
424 | - if ( ! empty( $args['end-date'] ) ) { |
|
424 | + if ( ! empty($args['end-date'])) { |
|
425 | 425 | $args['end_date'] = $args['end-date']; |
426 | - unset( $args['end-date'] ); |
|
426 | + unset($args['end-date']); |
|
427 | 427 | } |
428 | 428 | |
429 | - if ( ! empty( $args['form_id'] ) ) { |
|
429 | + if ( ! empty($args['form_id'])) { |
|
430 | 430 | $args['give_forms'] = $args['form_id']; |
431 | - unset( $args['form_id'] ); |
|
431 | + unset($args['form_id']); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | // Extract all donations |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $args['group_by'] = 'post_status'; |
437 | 437 | $args['count'] = 'true'; |
438 | 438 | |
439 | - $donations_obj = new Give_Payments_Query( $args ); |
|
439 | + $donations_obj = new Give_Payments_Query($args); |
|
440 | 440 | $donations_count = $donations_obj->get_payment_by_group(); |
441 | 441 | |
442 | 442 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @since 1.0 |
446 | 446 | */ |
447 | - return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj ); |
|
447 | + return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @return bool $exists True if payment exists, false otherwise. |
459 | 459 | */ |
460 | -function give_check_for_existing_payment( $payment_id ) { |
|
460 | +function give_check_for_existing_payment($payment_id) { |
|
461 | 461 | global $wpdb; |
462 | 462 | |
463 | 463 | return (bool) $wpdb->get_var( |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return bool|mixed True if payment status exists, false otherwise. |
487 | 487 | */ |
488 | -function give_get_payment_status( $payment_id, $return_label = false ) { |
|
488 | +function give_get_payment_status($payment_id, $return_label = false) { |
|
489 | 489 | |
490 | - if ( ! is_numeric( $payment_id ) ) { |
|
490 | + if ( ! is_numeric($payment_id)) { |
|
491 | 491 | if ( |
492 | 492 | $payment_id instanceof Give_Payment |
493 | 493 | || $payment_id instanceof WP_Post |
@@ -496,28 +496,28 @@ discard block |
||
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
499 | - if ( ! $payment_id > 0 ) { |
|
499 | + if ( ! $payment_id > 0) { |
|
500 | 500 | return false; |
501 | 501 | } |
502 | 502 | |
503 | - $payment_status = get_post_status( $payment_id ); |
|
503 | + $payment_status = get_post_status($payment_id); |
|
504 | 504 | |
505 | 505 | $statuses = give_get_payment_statuses(); |
506 | 506 | |
507 | - if ( empty( $payment_status ) || ! is_array( $statuses ) || empty( $statuses ) ) { |
|
507 | + if (empty($payment_status) || ! is_array($statuses) || empty($statuses)) { |
|
508 | 508 | return false; |
509 | 509 | } |
510 | 510 | |
511 | - if ( array_key_exists( $payment_status, $statuses ) ) { |
|
512 | - if ( true === $return_label ) { |
|
511 | + if (array_key_exists($payment_status, $statuses)) { |
|
512 | + if (true === $return_label) { |
|
513 | 513 | // Return translated status label. |
514 | - return $statuses[ $payment_status ]; |
|
514 | + return $statuses[$payment_status]; |
|
515 | 515 | } else { |
516 | 516 | // Account that our 'publish' status is labeled 'Complete' |
517 | 517 | $post_status = 'publish' === $payment_status ? 'Complete' : $payment_status; |
518 | 518 | |
519 | 519 | // Make sure we're matching cases, since they matter |
520 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
520 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
@@ -533,18 +533,18 @@ discard block |
||
533 | 533 | */ |
534 | 534 | function give_get_payment_statuses() { |
535 | 535 | $payment_statuses = array( |
536 | - 'pending' => __( 'Pending', 'give' ), |
|
537 | - 'publish' => __( 'Complete', 'give' ), |
|
538 | - 'refunded' => __( 'Refunded', 'give' ), |
|
539 | - 'failed' => __( 'Failed', 'give' ), |
|
540 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
541 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
542 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
543 | - 'processing' => __( 'Processing', 'give' ), |
|
544 | - 'revoked' => __( 'Revoked', 'give' ), |
|
536 | + 'pending' => __('Pending', 'give'), |
|
537 | + 'publish' => __('Complete', 'give'), |
|
538 | + 'refunded' => __('Refunded', 'give'), |
|
539 | + 'failed' => __('Failed', 'give'), |
|
540 | + 'cancelled' => __('Cancelled', 'give'), |
|
541 | + 'abandoned' => __('Abandoned', 'give'), |
|
542 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
543 | + 'processing' => __('Processing', 'give'), |
|
544 | + 'revoked' => __('Revoked', 'give'), |
|
545 | 545 | ); |
546 | 546 | |
547 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
547 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -557,10 +557,10 @@ discard block |
||
557 | 557 | * @return array $payment_status All the available payment statuses. |
558 | 558 | */ |
559 | 559 | function give_get_payment_status_keys() { |
560 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
561 | - asort( $statuses ); |
|
560 | + $statuses = array_keys(give_get_payment_statuses()); |
|
561 | + asort($statuses); |
|
562 | 562 | |
563 | - return array_values( $statuses ); |
|
563 | + return array_values($statuses); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -575,43 +575,43 @@ discard block |
||
575 | 575 | * |
576 | 576 | * @return int $earnings Earnings |
577 | 577 | */ |
578 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
578 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
579 | 579 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
580 | 580 | global $wpdb; |
581 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
581 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
582 | 582 | |
583 | 583 | $args = array( |
584 | 584 | 'post_type' => 'give_payment', |
585 | 585 | 'nopaging' => true, |
586 | 586 | 'year' => $year, |
587 | 587 | 'monthnum' => $month_num, |
588 | - 'post_status' => array( 'publish' ), |
|
588 | + 'post_status' => array('publish'), |
|
589 | 589 | 'fields' => 'ids', |
590 | 590 | 'update_post_term_cache' => false, |
591 | 591 | ); |
592 | - if ( ! empty( $day ) ) { |
|
592 | + if ( ! empty($day)) { |
|
593 | 593 | $args['day'] = $day; |
594 | 594 | } |
595 | 595 | |
596 | - if ( isset( $hour ) ) { |
|
596 | + if (isset($hour)) { |
|
597 | 597 | $args['hour'] = $hour; |
598 | 598 | } |
599 | 599 | |
600 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
601 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
600 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
601 | + $key = Give_Cache::get_key('give_stats', $args); |
|
602 | 602 | |
603 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
603 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
604 | 604 | $earnings = false; |
605 | 605 | } else { |
606 | - $earnings = Give_Cache::get( $key ); |
|
606 | + $earnings = Give_Cache::get($key); |
|
607 | 607 | } |
608 | 608 | |
609 | - if ( false === $earnings ) { |
|
610 | - $donations = get_posts( $args ); |
|
609 | + if (false === $earnings) { |
|
610 | + $donations = get_posts($args); |
|
611 | 611 | $earnings = 0; |
612 | - if ( $donations ) { |
|
613 | - $donations = implode( ',', $donations ); |
|
614 | - $earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" ); |
|
612 | + if ($donations) { |
|
613 | + $donations = implode(',', $donations); |
|
614 | + $earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})"); |
|
615 | 615 | |
616 | 616 | /** |
617 | 617 | * Filter The earnings by dates. |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | * @param array $donations Donations lists. |
623 | 623 | * @param array $args Donation query args. |
624 | 624 | */ |
625 | - $earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args ); |
|
625 | + $earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args); |
|
626 | 626 | } |
627 | 627 | // Cache the results for one hour. |
628 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
628 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
629 | 629 | } |
630 | 630 | |
631 | - return round( $earnings, 2 ); |
|
631 | + return round($earnings, 2); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | /** |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return int $count Sales |
645 | 645 | */ |
646 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
646 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
647 | 647 | |
648 | 648 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
649 | 649 | $args = array( |
@@ -651,14 +651,14 @@ discard block |
||
651 | 651 | 'nopaging' => true, |
652 | 652 | 'year' => $year, |
653 | 653 | 'fields' => 'ids', |
654 | - 'post_status' => array( 'publish' ), |
|
654 | + 'post_status' => array('publish'), |
|
655 | 655 | 'update_post_meta_cache' => false, |
656 | 656 | 'update_post_term_cache' => false, |
657 | 657 | ); |
658 | 658 | |
659 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
659 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
660 | 660 | |
661 | - if ( false === $show_free ) { |
|
661 | + if (false === $show_free) { |
|
662 | 662 | $args['meta_query'] = array( |
663 | 663 | array( |
664 | 664 | 'key' => '_give_payment_total', |
@@ -669,33 +669,33 @@ discard block |
||
669 | 669 | ); |
670 | 670 | } |
671 | 671 | |
672 | - if ( ! empty( $month_num ) ) { |
|
672 | + if ( ! empty($month_num)) { |
|
673 | 673 | $args['monthnum'] = $month_num; |
674 | 674 | } |
675 | 675 | |
676 | - if ( ! empty( $day ) ) { |
|
676 | + if ( ! empty($day)) { |
|
677 | 677 | $args['day'] = $day; |
678 | 678 | } |
679 | 679 | |
680 | - if ( isset( $hour ) ) { |
|
680 | + if (isset($hour)) { |
|
681 | 681 | $args['hour'] = $hour; |
682 | 682 | } |
683 | 683 | |
684 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
684 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
685 | 685 | |
686 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
686 | + $key = Give_Cache::get_key('give_stats', $args); |
|
687 | 687 | |
688 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
688 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
689 | 689 | $count = false; |
690 | 690 | } else { |
691 | - $count = Give_Cache::get( $key ); |
|
691 | + $count = Give_Cache::get($key); |
|
692 | 692 | } |
693 | 693 | |
694 | - if ( false === $count ) { |
|
695 | - $donations = new WP_Query( $args ); |
|
694 | + if (false === $count) { |
|
695 | + $donations = new WP_Query($args); |
|
696 | 696 | $count = (int) $donations->post_count; |
697 | 697 | // Cache the results for one hour. |
698 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
698 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | return $count; |
@@ -710,14 +710,14 @@ discard block |
||
710 | 710 | * |
711 | 711 | * @return bool $ret True if complete, false otherwise. |
712 | 712 | */ |
713 | -function give_is_payment_complete( $payment_id ) { |
|
713 | +function give_is_payment_complete($payment_id) { |
|
714 | 714 | $ret = false; |
715 | 715 | $payment_status = ''; |
716 | 716 | |
717 | - if ( $payment_id > 0 && 'give_payment' === get_post_type( $payment_id ) ) { |
|
718 | - $payment_status = get_post_status( $payment_id ); |
|
717 | + if ($payment_id > 0 && 'give_payment' === get_post_type($payment_id)) { |
|
718 | + $payment_status = get_post_status($payment_id); |
|
719 | 719 | |
720 | - if ( 'publish' === $payment_status ) { |
|
720 | + if ('publish' === $payment_status) { |
|
721 | 721 | $ret = true; |
722 | 722 | } |
723 | 723 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * |
728 | 728 | * @since 1.0 |
729 | 729 | */ |
730 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment_status ); |
|
730 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment_status); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -753,13 +753,13 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @return float $total Total earnings. |
755 | 755 | */ |
756 | -function give_get_total_earnings( $recalculate = false ) { |
|
756 | +function give_get_total_earnings($recalculate = false) { |
|
757 | 757 | |
758 | - $total = get_option( 'give_earnings_total', 0 ); |
|
759 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
758 | + $total = get_option('give_earnings_total', 0); |
|
759 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
760 | 760 | |
761 | 761 | // Calculate total earnings. |
762 | - if ( ! $total || $recalculate ) { |
|
762 | + if ( ! $total || $recalculate) { |
|
763 | 763 | global $wpdb; |
764 | 764 | |
765 | 765 | $total = (float) 0; |
@@ -767,38 +767,38 @@ discard block |
||
767 | 767 | $args = apply_filters( |
768 | 768 | 'give_get_total_earnings_args', array( |
769 | 769 | 'offset' => 0, |
770 | - 'number' => - 1, |
|
771 | - 'status' => array( 'publish' ), |
|
770 | + 'number' => -1, |
|
771 | + 'status' => array('publish'), |
|
772 | 772 | 'fields' => 'ids', |
773 | 773 | ) |
774 | 774 | ); |
775 | 775 | |
776 | - $payments = give_get_payments( $args ); |
|
777 | - if ( $payments ) { |
|
776 | + $payments = give_get_payments($args); |
|
777 | + if ($payments) { |
|
778 | 778 | |
779 | 779 | /** |
780 | 780 | * If performing a donation, we need to skip the very last payment in the database, |
781 | 781 | * since it calls give_increase_total_earnings() on completion, |
782 | 782 | * which results in duplicated earnings for the very first donation. |
783 | 783 | */ |
784 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
785 | - array_pop( $payments ); |
|
784 | + if (did_action('give_update_payment_status')) { |
|
785 | + array_pop($payments); |
|
786 | 786 | } |
787 | 787 | |
788 | - if ( ! empty( $payments ) ) { |
|
789 | - $payments = implode( ',', $payments ); |
|
790 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})" ); |
|
788 | + if ( ! empty($payments)) { |
|
789 | + $payments = implode(',', $payments); |
|
790 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})"); |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 | |
794 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
794 | + update_option('give_earnings_total', $total, 'no'); |
|
795 | 795 | } |
796 | 796 | |
797 | - if ( $total < 0 ) { |
|
797 | + if ($total < 0) { |
|
798 | 798 | $total = 0; // Don't ever show negative earnings. |
799 | 799 | } |
800 | 800 | |
801 | - return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total ); |
|
801 | + return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | /** |
@@ -810,10 +810,10 @@ discard block |
||
810 | 810 | * |
811 | 811 | * @return float $total Total earnings. |
812 | 812 | */ |
813 | -function give_increase_total_earnings( $amount = 0 ) { |
|
813 | +function give_increase_total_earnings($amount = 0) { |
|
814 | 814 | $total = give_get_total_earnings(); |
815 | 815 | $total += $amount; |
816 | - update_option( 'give_earnings_total', $total ); |
|
816 | + update_option('give_earnings_total', $total); |
|
817 | 817 | |
818 | 818 | return $total; |
819 | 819 | } |
@@ -827,13 +827,13 @@ discard block |
||
827 | 827 | * |
828 | 828 | * @return float $total Total earnings. |
829 | 829 | */ |
830 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
830 | +function give_decrease_total_earnings($amount = 0) { |
|
831 | 831 | $total = give_get_total_earnings(); |
832 | 832 | $total -= $amount; |
833 | - if ( $total < 0 ) { |
|
833 | + if ($total < 0) { |
|
834 | 834 | $total = 0; |
835 | 835 | } |
836 | - update_option( 'give_earnings_total', $total ); |
|
836 | + update_option('give_earnings_total', $total); |
|
837 | 837 | |
838 | 838 | return $total; |
839 | 839 | } |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @return mixed $meta Payment Meta. |
851 | 851 | */ |
852 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
853 | - return give_get_meta( $payment_id, $meta_key, $single ); |
|
852 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
853 | + return give_get_meta($payment_id, $meta_key, $single); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | * |
864 | 864 | * @return mixed Meta ID if successful, false if unsuccessful. |
865 | 865 | */ |
866 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
867 | - return give_update_meta( $payment_id, $meta_key, $meta_value ); |
|
866 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
867 | + return give_update_meta($payment_id, $meta_key, $meta_value); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -876,32 +876,32 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return array $user_info User Info Meta Values. |
878 | 878 | */ |
879 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
879 | +function give_get_payment_meta_user_info($payment_id) { |
|
880 | 880 | $donor_id = 0; |
881 | 881 | $donor_info = array( |
882 | - 'first_name' => give_get_meta( $payment_id, '_give_donor_billing_first_name', true ), |
|
883 | - 'last_name' => give_get_meta( $payment_id, '_give_donor_billing_last_name', true ), |
|
884 | - 'email' => give_get_meta( $payment_id, '_give_donor_billing_donor_email', true ), |
|
882 | + 'first_name' => give_get_meta($payment_id, '_give_donor_billing_first_name', true), |
|
883 | + 'last_name' => give_get_meta($payment_id, '_give_donor_billing_last_name', true), |
|
884 | + 'email' => give_get_meta($payment_id, '_give_donor_billing_donor_email', true), |
|
885 | 885 | ); |
886 | 886 | |
887 | - if ( empty( $donor_info['first_name'] ) ) { |
|
888 | - $donor_id = give_get_payment_donor_id( $payment_id ); |
|
889 | - $donor_info['first_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_first_name', true ); |
|
887 | + if (empty($donor_info['first_name'])) { |
|
888 | + $donor_id = give_get_payment_donor_id($payment_id); |
|
889 | + $donor_info['first_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_first_name', true); |
|
890 | 890 | } |
891 | 891 | |
892 | - if ( empty( $donor_info['last_name'] ) ) { |
|
893 | - $donor_id = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id ); |
|
894 | - $donor_info['last_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_last_name', true ); |
|
892 | + if (empty($donor_info['last_name'])) { |
|
893 | + $donor_id = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id); |
|
894 | + $donor_info['last_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_last_name', true); |
|
895 | 895 | } |
896 | 896 | |
897 | - if ( empty( $donor_info['email'] ) ) { |
|
898 | - $donor_id = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id ); |
|
899 | - $donor_info['email'] = Give()->donors->get_column_by( 'email', 'id', $donor_id ); |
|
897 | + if (empty($donor_info['email'])) { |
|
898 | + $donor_id = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id); |
|
899 | + $donor_info['email'] = Give()->donors->get_column_by('email', 'id', $donor_id); |
|
900 | 900 | } |
901 | 901 | |
902 | - $donor_info['address'] = give_get_donation_address( $payment_id ); |
|
903 | - $donor_info['id'] = give_get_payment_user_id( $payment_id ); |
|
904 | - $donor_info['donor_id'] = give_get_payment_donor_id( $payment_id ); |
|
902 | + $donor_info['address'] = give_get_donation_address($payment_id); |
|
903 | + $donor_info['id'] = give_get_payment_user_id($payment_id); |
|
904 | + $donor_info['donor_id'] = give_get_payment_donor_id($payment_id); |
|
905 | 905 | |
906 | 906 | return $donor_info; |
907 | 907 | } |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | * |
918 | 918 | * @return int $form_id Form ID. |
919 | 919 | */ |
920 | -function give_get_payment_form_id( $payment_id ) { |
|
921 | - return (int) give_get_meta( $payment_id, '_give_payment_form_id', true ); |
|
920 | +function give_get_payment_form_id($payment_id) { |
|
921 | + return (int) give_get_meta($payment_id, '_give_payment_form_id', true); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | /** |
@@ -930,11 +930,11 @@ discard block |
||
930 | 930 | * |
931 | 931 | * @return string $email User email. |
932 | 932 | */ |
933 | -function give_get_payment_user_email( $payment_id ) { |
|
934 | - $email = give_get_meta( $payment_id, '_give_payment_donor_email', true ); |
|
933 | +function give_get_payment_user_email($payment_id) { |
|
934 | + $email = give_get_meta($payment_id, '_give_payment_donor_email', true); |
|
935 | 935 | |
936 | - if ( empty( $email ) && ( $donor_id = give_get_payment_donor_id( $payment_id ) ) ) { |
|
937 | - $email = Give()->donors->get_column( 'email', $donor_id ); |
|
936 | + if (empty($email) && ($donor_id = give_get_payment_donor_id($payment_id))) { |
|
937 | + $email = Give()->donors->get_column('email', $donor_id); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | return $email; |
@@ -949,11 +949,11 @@ discard block |
||
949 | 949 | * |
950 | 950 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
951 | 951 | */ |
952 | -function give_is_guest_payment( $payment_id ) { |
|
953 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
954 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
952 | +function give_is_guest_payment($payment_id) { |
|
953 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
954 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
955 | 955 | |
956 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
956 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | * |
966 | 966 | * @return int $user_id User ID. |
967 | 967 | */ |
968 | -function give_get_payment_user_id( $payment_id ) { |
|
968 | +function give_get_payment_user_id($payment_id) { |
|
969 | 969 | global $wpdb; |
970 | 970 | $paymentmeta_table = Give()->payment_meta->table_name; |
971 | 971 | |
@@ -996,8 +996,8 @@ discard block |
||
996 | 996 | * |
997 | 997 | * @return int $payment->customer_id Donor ID. |
998 | 998 | */ |
999 | -function give_get_payment_donor_id( $payment_id ) { |
|
1000 | - return give_get_meta( $payment_id, '_give_payment_donor_id', true ); |
|
999 | +function give_get_payment_donor_id($payment_id) { |
|
1000 | + return give_get_meta($payment_id, '_give_payment_donor_id', true); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | /** |
@@ -1009,8 +1009,8 @@ discard block |
||
1009 | 1009 | * |
1010 | 1010 | * @return string |
1011 | 1011 | */ |
1012 | -function give_get_donation_donor_email( $payment_id ) { |
|
1013 | - return give_get_meta( $payment_id, '_give_payment_donor_email', true ); |
|
1012 | +function give_get_donation_donor_email($payment_id) { |
|
1013 | + return give_get_meta($payment_id, '_give_payment_donor_email', true); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | * |
1023 | 1023 | * @return string $ip User IP. |
1024 | 1024 | */ |
1025 | -function give_get_payment_user_ip( $payment_id ) { |
|
1026 | - return give_get_meta( $payment_id, '_give_payment_donor_ip', true ); |
|
1025 | +function give_get_payment_user_ip($payment_id) { |
|
1026 | + return give_get_meta($payment_id, '_give_payment_donor_ip', true); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | /** |
@@ -1035,8 +1035,8 @@ discard block |
||
1035 | 1035 | * |
1036 | 1036 | * @return string $date The date the payment was completed. |
1037 | 1037 | */ |
1038 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1039 | - return give_get_meta( $payment_id, '_give_completed_date', true ); |
|
1038 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1039 | + return give_get_meta($payment_id, '_give_completed_date', true); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | /** |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | * |
1049 | 1049 | * @return string $gateway Gateway. |
1050 | 1050 | */ |
1051 | -function give_get_payment_gateway( $payment_id ) { |
|
1052 | - return give_get_meta( $payment_id, '_give_payment_gateway', true ); |
|
1051 | +function give_get_payment_gateway($payment_id) { |
|
1052 | + return give_get_meta($payment_id, '_give_payment_gateway', true); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1062,10 +1062,9 @@ discard block |
||
1062 | 1062 | * |
1063 | 1063 | * @return bool |
1064 | 1064 | */ |
1065 | -function give_has_payment_gateway( $donation_id, $gateway_id ) { |
|
1065 | +function give_has_payment_gateway($donation_id, $gateway_id) { |
|
1066 | 1066 | $donation_gateway = $donation_id instanceof Give_Payment ? |
1067 | - $donation_id->gateway : |
|
1068 | - give_get_payment_gateway( $donation_id ); |
|
1067 | + $donation_id->gateway : give_get_payment_gateway($donation_id); |
|
1069 | 1068 | |
1070 | 1069 | return $gateway_id === $donation_gateway; |
1071 | 1070 | } |
@@ -1079,8 +1078,8 @@ discard block |
||
1079 | 1078 | * |
1080 | 1079 | * @return string $currency The currency code. |
1081 | 1080 | */ |
1082 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1083 | - return give_get_meta( $payment_id, '_give_payment_currency', true ); |
|
1081 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1082 | + return give_get_meta($payment_id, '_give_payment_currency', true); |
|
1084 | 1083 | } |
1085 | 1084 | |
1086 | 1085 | /** |
@@ -1092,10 +1091,10 @@ discard block |
||
1092 | 1091 | * |
1093 | 1092 | * @return string $currency The currency name. |
1094 | 1093 | */ |
1095 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1096 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1094 | +function give_get_payment_currency($payment_id = 0) { |
|
1095 | + $currency = give_get_payment_currency_code($payment_id); |
|
1097 | 1096 | |
1098 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1097 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1099 | 1098 | } |
1100 | 1099 | |
1101 | 1100 | /** |
@@ -1107,8 +1106,8 @@ discard block |
||
1107 | 1106 | * |
1108 | 1107 | * @return string $key Donation key. |
1109 | 1108 | */ |
1110 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1111 | - return give_get_meta( $payment_id, '_give_payment_purchase_key', true ); |
|
1109 | +function give_get_payment_key($payment_id = 0) { |
|
1110 | + return give_get_meta($payment_id, '_give_payment_purchase_key', true); |
|
1112 | 1111 | } |
1113 | 1112 | |
1114 | 1113 | /** |
@@ -1122,8 +1121,8 @@ discard block |
||
1122 | 1121 | * |
1123 | 1122 | * @return string $number Payment order number. |
1124 | 1123 | */ |
1125 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1126 | - return Give()->seq_donation_number->get_serial_code( $payment_id ); |
|
1124 | +function give_get_payment_number($payment_id = 0) { |
|
1125 | + return Give()->seq_donation_number->get_serial_code($payment_id); |
|
1127 | 1126 | } |
1128 | 1127 | |
1129 | 1128 | |
@@ -1141,17 +1140,17 @@ discard block |
||
1141 | 1140 | * |
1142 | 1141 | * @return string $amount Fully formatted donation amount. |
1143 | 1142 | */ |
1144 | -function give_donation_amount( $donation_id, $format_args = array() ) { |
|
1145 | - if ( ! $donation_id ) { |
|
1143 | +function give_donation_amount($donation_id, $format_args = array()) { |
|
1144 | + if ( ! $donation_id) { |
|
1146 | 1145 | return ''; |
1147 | - } elseif ( ! is_numeric( $donation_id ) && ( $donation_id instanceof Give_Payment ) ) { |
|
1146 | + } elseif ( ! is_numeric($donation_id) && ($donation_id instanceof Give_Payment)) { |
|
1148 | 1147 | $donation_id = $donation_id->ID; |
1149 | 1148 | } |
1150 | 1149 | |
1151 | - $amount = $formatted_amount = give_get_payment_total( $donation_id ); |
|
1152 | - $currency_code = give_get_payment_currency_code( $donation_id ); |
|
1150 | + $amount = $formatted_amount = give_get_payment_total($donation_id); |
|
1151 | + $currency_code = give_get_payment_currency_code($donation_id); |
|
1153 | 1152 | |
1154 | - if ( is_bool( $format_args ) ) { |
|
1153 | + if (is_bool($format_args)) { |
|
1155 | 1154 | $format_args = array( |
1156 | 1155 | 'currency' => (bool) $format_args, |
1157 | 1156 | 'amount' => (bool) $format_args, |
@@ -1174,27 +1173,25 @@ discard block |
||
1174 | 1173 | ) |
1175 | 1174 | ); |
1176 | 1175 | |
1177 | - if ( $format_args['amount'] || $format_args['currency'] ) { |
|
1176 | + if ($format_args['amount'] || $format_args['currency']) { |
|
1178 | 1177 | |
1179 | - if ( $format_args['amount'] ) { |
|
1178 | + if ($format_args['amount']) { |
|
1180 | 1179 | |
1181 | 1180 | $formatted_amount = give_format_amount( |
1182 | 1181 | $amount, |
1183 | - ! is_array( $format_args['amount'] ) ? |
|
1182 | + ! is_array($format_args['amount']) ? |
|
1184 | 1183 | array( |
1185 | 1184 | 'sanitize' => false, |
1186 | 1185 | 'currency' => $currency_code, |
1187 | - ) : |
|
1188 | - $format_args['amount'] |
|
1186 | + ) : $format_args['amount'] |
|
1189 | 1187 | ); |
1190 | 1188 | } |
1191 | 1189 | |
1192 | - if ( $format_args['currency'] ) { |
|
1190 | + if ($format_args['currency']) { |
|
1193 | 1191 | $formatted_amount = give_currency_filter( |
1194 | 1192 | $formatted_amount, |
1195 | - ! is_array( $format_args['currency'] ) ? |
|
1196 | - array( 'currency_code' => $currency_code ) : |
|
1197 | - $format_args['currency'] |
|
1193 | + ! is_array($format_args['currency']) ? |
|
1194 | + array('currency_code' => $currency_code) : $format_args['currency'] |
|
1198 | 1195 | ); |
1199 | 1196 | } |
1200 | 1197 | } |
@@ -1209,7 +1206,7 @@ discard block |
||
1209 | 1206 | * @param int $donation_id Donation ID. |
1210 | 1207 | * @param string $type Donation amount type. |
1211 | 1208 | */ |
1212 | - return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args ); |
|
1209 | + return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args); |
|
1213 | 1210 | } |
1214 | 1211 | |
1215 | 1212 | /** |
@@ -1226,10 +1223,10 @@ discard block |
||
1226 | 1223 | * |
1227 | 1224 | * @return array Fully formatted payment subtotal. |
1228 | 1225 | */ |
1229 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1230 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1226 | +function give_payment_subtotal($payment_id = 0) { |
|
1227 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1231 | 1228 | |
1232 | - return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) ); |
|
1229 | + return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id))); |
|
1233 | 1230 | } |
1234 | 1231 | |
1235 | 1232 | /** |
@@ -1243,8 +1240,8 @@ discard block |
||
1243 | 1240 | * |
1244 | 1241 | * @return float $subtotal Subtotal for payment (non formatted). |
1245 | 1242 | */ |
1246 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1247 | - $payment = new Give_Payment( $payment_id ); |
|
1243 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1244 | + $payment = new Give_Payment($payment_id); |
|
1248 | 1245 | |
1249 | 1246 | return $payment->subtotal; |
1250 | 1247 | } |
@@ -1258,12 +1255,12 @@ discard block |
||
1258 | 1255 | * |
1259 | 1256 | * @return string The donation ID. |
1260 | 1257 | */ |
1261 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1262 | - $transaction_id = give_get_meta( $payment_id, '_give_payment_transaction_id', true ); |
|
1258 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1259 | + $transaction_id = give_get_meta($payment_id, '_give_payment_transaction_id', true); |
|
1263 | 1260 | |
1264 | - if ( empty( $transaction_id ) ) { |
|
1265 | - $gateway = give_get_payment_gateway( $payment_id ); |
|
1266 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $payment_id ); |
|
1261 | + if (empty($transaction_id)) { |
|
1262 | + $gateway = give_get_payment_gateway($payment_id); |
|
1263 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $payment_id); |
|
1267 | 1264 | } |
1268 | 1265 | |
1269 | 1266 | return $transaction_id; |
@@ -1279,15 +1276,15 @@ discard block |
||
1279 | 1276 | * |
1280 | 1277 | * @return bool|mixed |
1281 | 1278 | */ |
1282 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1279 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1283 | 1280 | |
1284 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1281 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1285 | 1282 | return false; |
1286 | 1283 | } |
1287 | 1284 | |
1288 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1285 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1289 | 1286 | |
1290 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1287 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1291 | 1288 | } |
1292 | 1289 | |
1293 | 1290 | /** |
@@ -1300,10 +1297,10 @@ discard block |
||
1300 | 1297 | * |
1301 | 1298 | * @return int $purchase Donation ID. |
1302 | 1299 | */ |
1303 | -function give_get_donation_id_by_key( $key ) { |
|
1300 | +function give_get_donation_id_by_key($key) { |
|
1304 | 1301 | global $wpdb; |
1305 | 1302 | |
1306 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
1303 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
1307 | 1304 | |
1308 | 1305 | $purchase = $wpdb->get_var( |
1309 | 1306 | $wpdb->prepare( |
@@ -1319,7 +1316,7 @@ discard block |
||
1319 | 1316 | ) |
1320 | 1317 | ); |
1321 | 1318 | |
1322 | - if ( $purchase != null ) { |
|
1319 | + if ($purchase != null) { |
|
1323 | 1320 | return $purchase; |
1324 | 1321 | } |
1325 | 1322 | |
@@ -1337,13 +1334,13 @@ discard block |
||
1337 | 1334 | * |
1338 | 1335 | * @return int $purchase Donation ID. |
1339 | 1336 | */ |
1340 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1337 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1341 | 1338 | global $wpdb; |
1342 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
1339 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
1343 | 1340 | |
1344 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1341 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1345 | 1342 | |
1346 | - if ( $purchase != null ) { |
|
1343 | + if ($purchase != null) { |
|
1347 | 1344 | return $purchase; |
1348 | 1345 | } |
1349 | 1346 | |
@@ -1360,14 +1357,14 @@ discard block |
||
1360 | 1357 | * |
1361 | 1358 | * @return array $notes Donation Notes |
1362 | 1359 | */ |
1363 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1360 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1364 | 1361 | |
1365 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1362 | + if (empty($payment_id) && empty($search)) { |
|
1366 | 1363 | return false; |
1367 | 1364 | } |
1368 | 1365 | |
1369 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1370 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1366 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1367 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1371 | 1368 | |
1372 | 1369 | $notes = get_comments( |
1373 | 1370 | array( |
@@ -1377,8 +1374,8 @@ discard block |
||
1377 | 1374 | ) |
1378 | 1375 | ); |
1379 | 1376 | |
1380 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1381 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1377 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1378 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1382 | 1379 | |
1383 | 1380 | return $notes; |
1384 | 1381 | } |
@@ -1394,8 +1391,8 @@ discard block |
||
1394 | 1391 | * |
1395 | 1392 | * @return int The new note ID |
1396 | 1393 | */ |
1397 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1398 | - if ( empty( $payment_id ) ) { |
|
1394 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1395 | + if (empty($payment_id)) { |
|
1399 | 1396 | return false; |
1400 | 1397 | } |
1401 | 1398 | |
@@ -1407,7 +1404,7 @@ discard block |
||
1407 | 1404 | * |
1408 | 1405 | * @since 1.0 |
1409 | 1406 | */ |
1410 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1407 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1411 | 1408 | |
1412 | 1409 | $note_id = wp_insert_comment( |
1413 | 1410 | wp_filter_comment( |
@@ -1415,8 +1412,8 @@ discard block |
||
1415 | 1412 | 'comment_post_ID' => $payment_id, |
1416 | 1413 | 'comment_content' => $note, |
1417 | 1414 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1418 | - 'comment_date' => current_time( 'mysql' ), |
|
1419 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1415 | + 'comment_date' => current_time('mysql'), |
|
1416 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1420 | 1417 | 'comment_approved' => 1, |
1421 | 1418 | 'comment_parent' => 0, |
1422 | 1419 | 'comment_author' => '', |
@@ -1438,7 +1435,7 @@ discard block |
||
1438 | 1435 | * |
1439 | 1436 | * @since 1.0 |
1440 | 1437 | */ |
1441 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1438 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1442 | 1439 | |
1443 | 1440 | return $note_id; |
1444 | 1441 | } |
@@ -1453,8 +1450,8 @@ discard block |
||
1453 | 1450 | * |
1454 | 1451 | * @return bool True on success, false otherwise. |
1455 | 1452 | */ |
1456 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1457 | - if ( empty( $comment_id ) ) { |
|
1453 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1454 | + if (empty($comment_id)) { |
|
1458 | 1455 | return false; |
1459 | 1456 | } |
1460 | 1457 | |
@@ -1466,9 +1463,9 @@ discard block |
||
1466 | 1463 | * |
1467 | 1464 | * @since 1.0 |
1468 | 1465 | */ |
1469 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1466 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1470 | 1467 | |
1471 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1468 | + $ret = wp_delete_comment($comment_id, true); |
|
1472 | 1469 | |
1473 | 1470 | /** |
1474 | 1471 | * Fires after donation note deleted. |
@@ -1478,7 +1475,7 @@ discard block |
||
1478 | 1475 | * |
1479 | 1476 | * @since 1.0 |
1480 | 1477 | */ |
1481 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1478 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1482 | 1479 | |
1483 | 1480 | return $ret; |
1484 | 1481 | } |
@@ -1493,20 +1490,20 @@ discard block |
||
1493 | 1490 | * |
1494 | 1491 | * @return string |
1495 | 1492 | */ |
1496 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1493 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1497 | 1494 | |
1498 | - if ( is_numeric( $note ) ) { |
|
1499 | - $note = get_comment( $note ); |
|
1495 | + if (is_numeric($note)) { |
|
1496 | + $note = get_comment($note); |
|
1500 | 1497 | } |
1501 | 1498 | |
1502 | - if ( ! empty( $note->user_id ) ) { |
|
1503 | - $user = get_userdata( $note->user_id ); |
|
1499 | + if ( ! empty($note->user_id)) { |
|
1500 | + $user = get_userdata($note->user_id); |
|
1504 | 1501 | $user = $user->display_name; |
1505 | 1502 | } else { |
1506 | - $user = __( 'System', 'give' ); |
|
1503 | + $user = __('System', 'give'); |
|
1507 | 1504 | } |
1508 | 1505 | |
1509 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1506 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1510 | 1507 | |
1511 | 1508 | $delete_note_url = wp_nonce_url( |
1512 | 1509 | add_query_arg( |
@@ -1515,14 +1512,14 @@ discard block |
||
1515 | 1512 | 'note_id' => $note->comment_ID, |
1516 | 1513 | 'payment_id' => $payment_id, |
1517 | 1514 | ) |
1518 | - ), 'give_delete_payment_note_' . $note->comment_ID |
|
1515 | + ), 'give_delete_payment_note_'.$note->comment_ID |
|
1519 | 1516 | ); |
1520 | 1517 | |
1521 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1518 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1522 | 1519 | $note_html .= '<p>'; |
1523 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1520 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1524 | 1521 | $note_html .= $note->comment_content; |
1525 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>'; |
|
1522 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>'; |
|
1526 | 1523 | $note_html .= '</p>'; |
1527 | 1524 | $note_html .= '</div>'; |
1528 | 1525 | |
@@ -1540,18 +1537,18 @@ discard block |
||
1540 | 1537 | * |
1541 | 1538 | * @return void |
1542 | 1539 | */ |
1543 | -function give_hide_payment_notes( $query ) { |
|
1544 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1545 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1546 | - if ( ! is_array( $types ) ) { |
|
1547 | - $types = array( $types ); |
|
1540 | +function give_hide_payment_notes($query) { |
|
1541 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1542 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1543 | + if ( ! is_array($types)) { |
|
1544 | + $types = array($types); |
|
1548 | 1545 | } |
1549 | 1546 | $types[] = 'give_payment_note'; |
1550 | 1547 | $query->query_vars['type__not_in'] = $types; |
1551 | 1548 | } |
1552 | 1549 | } |
1553 | 1550 | |
1554 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1551 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1555 | 1552 | |
1556 | 1553 | /** |
1557 | 1554 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1563,15 +1560,15 @@ discard block |
||
1563 | 1560 | * |
1564 | 1561 | * @return array $clauses Updated comment clauses. |
1565 | 1562 | */ |
1566 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1567 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1563 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1564 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1568 | 1565 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1569 | 1566 | } |
1570 | 1567 | |
1571 | 1568 | return $clauses; |
1572 | 1569 | } |
1573 | 1570 | |
1574 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1571 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1575 | 1572 | |
1576 | 1573 | |
1577 | 1574 | /** |
@@ -1584,15 +1581,15 @@ discard block |
||
1584 | 1581 | * |
1585 | 1582 | * @return string $where |
1586 | 1583 | */ |
1587 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1584 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1588 | 1585 | global $wpdb; |
1589 | 1586 | |
1590 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1587 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1591 | 1588 | |
1592 | 1589 | return $where; |
1593 | 1590 | } |
1594 | 1591 | |
1595 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1592 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1596 | 1593 | |
1597 | 1594 | |
1598 | 1595 | /** |
@@ -1606,32 +1603,32 @@ discard block |
||
1606 | 1603 | * |
1607 | 1604 | * @return array|object Array of comment counts. |
1608 | 1605 | */ |
1609 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1606 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1610 | 1607 | global $wpdb, $pagenow; |
1611 | 1608 | |
1612 | - if ( 'index.php' != $pagenow ) { |
|
1609 | + if ('index.php' != $pagenow) { |
|
1613 | 1610 | return $stats; |
1614 | 1611 | } |
1615 | 1612 | |
1616 | 1613 | $post_id = (int) $post_id; |
1617 | 1614 | |
1618 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1615 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1619 | 1616 | return $stats; |
1620 | 1617 | } |
1621 | 1618 | |
1622 | - $stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' ); |
|
1619 | + $stats = Give_Cache::get_group("comments-{$post_id}", 'counts'); |
|
1623 | 1620 | |
1624 | - if ( ! is_null( $stats ) ) { |
|
1621 | + if ( ! is_null($stats)) { |
|
1625 | 1622 | return $stats; |
1626 | 1623 | } |
1627 | 1624 | |
1628 | 1625 | $where = 'WHERE comment_type != "give_payment_note"'; |
1629 | 1626 | |
1630 | - if ( $post_id > 0 ) { |
|
1631 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1627 | + if ($post_id > 0) { |
|
1628 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1632 | 1629 | } |
1633 | 1630 | |
1634 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1631 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1635 | 1632 | |
1636 | 1633 | $total = 0; |
1637 | 1634 | $approved = array( |
@@ -1641,30 +1638,30 @@ discard block |
||
1641 | 1638 | 'trash' => 'trash', |
1642 | 1639 | 'post-trashed' => 'post-trashed', |
1643 | 1640 | ); |
1644 | - foreach ( (array) $count as $row ) { |
|
1641 | + foreach ((array) $count as $row) { |
|
1645 | 1642 | // Don't count post-trashed toward totals. |
1646 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1643 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1647 | 1644 | $total += $row['num_comments']; |
1648 | 1645 | } |
1649 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1650 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1646 | + if (isset($approved[$row['comment_approved']])) { |
|
1647 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1651 | 1648 | } |
1652 | 1649 | } |
1653 | 1650 | |
1654 | 1651 | $stats['total_comments'] = $total; |
1655 | - foreach ( $approved as $key ) { |
|
1656 | - if ( empty( $stats[ $key ] ) ) { |
|
1657 | - $stats[ $key ] = 0; |
|
1652 | + foreach ($approved as $key) { |
|
1653 | + if (empty($stats[$key])) { |
|
1654 | + $stats[$key] = 0; |
|
1658 | 1655 | } |
1659 | 1656 | } |
1660 | 1657 | |
1661 | 1658 | $stats = (object) $stats; |
1662 | - Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' ); |
|
1659 | + Give_Cache::set_group("comments-{$post_id}", $stats, 'counts'); |
|
1663 | 1660 | |
1664 | 1661 | return $stats; |
1665 | 1662 | } |
1666 | 1663 | |
1667 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1664 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1668 | 1665 | |
1669 | 1666 | |
1670 | 1667 | /** |
@@ -1677,9 +1674,9 @@ discard block |
||
1677 | 1674 | * |
1678 | 1675 | * @return string $where Modified where clause. |
1679 | 1676 | */ |
1680 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1677 | +function give_filter_where_older_than_week($where = '') { |
|
1681 | 1678 | // Payments older than one week. |
1682 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1679 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1683 | 1680 | $where .= " AND post_date <= '{$start}'"; |
1684 | 1681 | |
1685 | 1682 | return $where; |
@@ -1699,13 +1696,13 @@ discard block |
||
1699 | 1696 | * |
1700 | 1697 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1701 | 1698 | */ |
1702 | -function give_get_donation_form_title( $donation_id, $args = array() ) { |
|
1699 | +function give_get_donation_form_title($donation_id, $args = array()) { |
|
1703 | 1700 | // Backward compatibility. |
1704 | - if ( ! is_numeric( $donation_id ) && $donation_id instanceof Give_Payment ) { |
|
1701 | + if ( ! is_numeric($donation_id) && $donation_id instanceof Give_Payment) { |
|
1705 | 1702 | $donation_id = $donation_id->ID; |
1706 | 1703 | } |
1707 | 1704 | |
1708 | - if ( ! $donation_id ) { |
|
1705 | + if ( ! $donation_id) { |
|
1709 | 1706 | return ''; |
1710 | 1707 | } |
1711 | 1708 | |
@@ -1714,11 +1711,11 @@ discard block |
||
1714 | 1711 | 'separator' => '', |
1715 | 1712 | ); |
1716 | 1713 | |
1717 | - $args = wp_parse_args( $args, $defaults ); |
|
1714 | + $args = wp_parse_args($args, $defaults); |
|
1718 | 1715 | |
1719 | - $form_id = give_get_payment_form_id( $donation_id ); |
|
1720 | - $price_id = give_get_meta( $donation_id, '_give_payment_price_id', true ); |
|
1721 | - $form_title = give_get_meta( $donation_id, '_give_payment_form_title', true ); |
|
1716 | + $form_id = give_get_payment_form_id($donation_id); |
|
1717 | + $price_id = give_get_meta($donation_id, '_give_payment_price_id', true); |
|
1718 | + $form_title = give_get_meta($donation_id, '_give_payment_form_title', true); |
|
1722 | 1719 | $only_level = $args['only_level']; |
1723 | 1720 | $separator = $args['separator']; |
1724 | 1721 | $level_label = ''; |
@@ -1734,38 +1731,38 @@ discard block |
||
1734 | 1731 | ), false |
1735 | 1732 | ); |
1736 | 1733 | |
1737 | - $form_title_html = Give_Cache::get_db_query( $cache_key ); |
|
1734 | + $form_title_html = Give_Cache::get_db_query($cache_key); |
|
1738 | 1735 | |
1739 | - if ( is_null( $form_title_html ) ) { |
|
1740 | - if ( true === $only_level ) { |
|
1736 | + if (is_null($form_title_html)) { |
|
1737 | + if (true === $only_level) { |
|
1741 | 1738 | $form_title = ''; |
1742 | 1739 | } |
1743 | 1740 | |
1744 | 1741 | $form_title_html = $form_title; |
1745 | 1742 | |
1746 | - if ( 'custom' === $price_id ) { |
|
1743 | + if ('custom' === $price_id) { |
|
1747 | 1744 | |
1748 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
1749 | - $level_label = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1745 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
1746 | + $level_label = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1750 | 1747 | |
1751 | 1748 | // Show custom amount level only in backend otherwise hide it. |
1752 | - if ( 'set' === give_get_meta( $form_id, '_give_price_option', true ) && ! is_admin() ) { |
|
1749 | + if ('set' === give_get_meta($form_id, '_give_price_option', true) && ! is_admin()) { |
|
1753 | 1750 | $level_label = ''; |
1754 | 1751 | } |
1755 | - } elseif ( give_has_variable_prices( $form_id ) ) { |
|
1756 | - $level_label = give_get_price_option_name( $form_id, $price_id, $donation_id, false ); |
|
1752 | + } elseif (give_has_variable_prices($form_id)) { |
|
1753 | + $level_label = give_get_price_option_name($form_id, $price_id, $donation_id, false); |
|
1757 | 1754 | } |
1758 | 1755 | |
1759 | 1756 | // Only add separator if there is a form title. |
1760 | 1757 | if ( |
1761 | - ! empty( $form_title_html ) && |
|
1762 | - ! empty( $level_label ) |
|
1758 | + ! empty($form_title_html) && |
|
1759 | + ! empty($level_label) |
|
1763 | 1760 | ) { |
1764 | 1761 | $form_title_html .= " {$separator} "; |
1765 | 1762 | } |
1766 | 1763 | |
1767 | 1764 | $form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>"; |
1768 | - Give_Cache::set_db_query( $cache_key, $form_title_html ); |
|
1765 | + Give_Cache::set_db_query($cache_key, $form_title_html); |
|
1769 | 1766 | } |
1770 | 1767 | |
1771 | 1768 | /** |
@@ -1774,7 +1771,7 @@ discard block |
||
1774 | 1771 | * @since 1.0 |
1775 | 1772 | * @todo: remove third param after 2.1.0 |
1776 | 1773 | */ |
1777 | - return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation_id, '' ); |
|
1774 | + return apply_filters('give_get_donation_form_title', $form_title_html, $donation_id, ''); |
|
1778 | 1775 | } |
1779 | 1776 | |
1780 | 1777 | /** |
@@ -1787,19 +1784,19 @@ discard block |
||
1787 | 1784 | * |
1788 | 1785 | * @return string $price_id |
1789 | 1786 | */ |
1790 | -function give_get_price_id( $form_id, $price ) { |
|
1787 | +function give_get_price_id($form_id, $price) { |
|
1791 | 1788 | $price_id = null; |
1792 | 1789 | |
1793 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1790 | + if (give_has_variable_prices($form_id)) { |
|
1794 | 1791 | |
1795 | - $levels = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
1792 | + $levels = give_get_meta($form_id, '_give_donation_levels', true); |
|
1796 | 1793 | |
1797 | - foreach ( $levels as $level ) { |
|
1794 | + foreach ($levels as $level) { |
|
1798 | 1795 | |
1799 | - $level_amount = give_maybe_sanitize_amount( $level['_give_amount'] ); |
|
1796 | + $level_amount = give_maybe_sanitize_amount($level['_give_amount']); |
|
1800 | 1797 | |
1801 | 1798 | // Check that this indeed the recurring price. |
1802 | - if ( $level_amount == $price ) { |
|
1799 | + if ($level_amount == $price) { |
|
1803 | 1800 | |
1804 | 1801 | $price_id = $level['_give_id']['level_id']; |
1805 | 1802 | break; |
@@ -1807,13 +1804,13 @@ discard block |
||
1807 | 1804 | } |
1808 | 1805 | } |
1809 | 1806 | |
1810 | - if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) { |
|
1807 | + if (is_null($price_id) && give_is_custom_price_mode($form_id)) { |
|
1811 | 1808 | $price_id = 'custom'; |
1812 | 1809 | } |
1813 | 1810 | } |
1814 | 1811 | |
1815 | 1812 | // Price ID must be numeric or string. |
1816 | - $price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id; |
|
1813 | + $price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id; |
|
1817 | 1814 | |
1818 | 1815 | /** |
1819 | 1816 | * Filter the price id |
@@ -1823,7 +1820,7 @@ discard block |
||
1823 | 1820 | * @param string $price_id |
1824 | 1821 | * @param int $form_id |
1825 | 1822 | */ |
1826 | - return apply_filters( 'give_get_price_id', $price_id, $form_id ); |
|
1823 | + return apply_filters('give_get_price_id', $price_id, $form_id); |
|
1827 | 1824 | } |
1828 | 1825 | |
1829 | 1826 | /** |
@@ -1839,10 +1836,10 @@ discard block |
||
1839 | 1836 | * |
1840 | 1837 | * @return string |
1841 | 1838 | */ |
1842 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1843 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1839 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1840 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1844 | 1841 | |
1845 | - if ( ! $echo ) { |
|
1842 | + if ( ! $echo) { |
|
1846 | 1843 | return $form_dropdown_html; |
1847 | 1844 | } |
1848 | 1845 | |
@@ -1859,17 +1856,17 @@ discard block |
||
1859 | 1856 | * |
1860 | 1857 | * @return string|bool |
1861 | 1858 | */ |
1862 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1859 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1863 | 1860 | |
1864 | 1861 | // Check for give form id. |
1865 | - if ( empty( $args['id'] ) ) { |
|
1862 | + if (empty($args['id'])) { |
|
1866 | 1863 | return false; |
1867 | 1864 | } |
1868 | 1865 | |
1869 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1866 | + $form = new Give_Donate_Form($args['id']); |
|
1870 | 1867 | |
1871 | 1868 | // Check if form has variable prices or not. |
1872 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1869 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1873 | 1870 | return false; |
1874 | 1871 | } |
1875 | 1872 | |
@@ -1877,13 +1874,13 @@ discard block |
||
1877 | 1874 | $variable_price_options = array(); |
1878 | 1875 | |
1879 | 1876 | // Check if multi donation form support custom donation or not. |
1880 | - if ( $form->is_custom_price_mode() ) { |
|
1881 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1877 | + if ($form->is_custom_price_mode()) { |
|
1878 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1882 | 1879 | } |
1883 | 1880 | |
1884 | 1881 | // Get variable price and ID from variable price array. |
1885 | - foreach ( $variable_prices as $variable_price ) { |
|
1886 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
1882 | + foreach ($variable_prices as $variable_price) { |
|
1883 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false))); |
|
1887 | 1884 | } |
1888 | 1885 | |
1889 | 1886 | // Update options. |
@@ -1894,9 +1891,9 @@ discard block |
||
1894 | 1891 | ); |
1895 | 1892 | |
1896 | 1893 | // Generate select html. |
1897 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1894 | + $form_dropdown_html = Give()->html->select($args); |
|
1898 | 1895 | |
1899 | - if ( ! $echo ) { |
|
1896 | + if ( ! $echo) { |
|
1900 | 1897 | return $form_dropdown_html; |
1901 | 1898 | } |
1902 | 1899 | |
@@ -1915,14 +1912,14 @@ discard block |
||
1915 | 1912 | * |
1916 | 1913 | * @return string |
1917 | 1914 | */ |
1918 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
1915 | +function give_get_payment_meta_price_id($payment_meta) { |
|
1919 | 1916 | |
1920 | - if ( isset( $payment_meta['give_price_id'] ) ) { |
|
1917 | + if (isset($payment_meta['give_price_id'])) { |
|
1921 | 1918 | $price_id = $payment_meta['give_price_id']; |
1922 | - } elseif ( isset( $payment_meta['price_id'] ) ) { |
|
1919 | + } elseif (isset($payment_meta['price_id'])) { |
|
1923 | 1920 | $price_id = $payment_meta['price_id']; |
1924 | 1921 | } else { |
1925 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
1922 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
1926 | 1923 | } |
1927 | 1924 | |
1928 | 1925 | /** |
@@ -1933,7 +1930,7 @@ discard block |
||
1933 | 1930 | * @param string $price_id |
1934 | 1931 | * @param array $payment_meta |
1935 | 1932 | */ |
1936 | - return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta ); |
|
1933 | + return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta); |
|
1937 | 1934 | |
1938 | 1935 | } |
1939 | 1936 | |
@@ -1947,10 +1944,10 @@ discard block |
||
1947 | 1944 | * |
1948 | 1945 | * @return float |
1949 | 1946 | */ |
1950 | -function give_get_payment_total( $payment_id = 0 ) { |
|
1947 | +function give_get_payment_total($payment_id = 0) { |
|
1951 | 1948 | return round( |
1952 | - floatval( give_get_meta( $payment_id, '_give_payment_total', true ) ), |
|
1953 | - give_get_price_decimals( $payment_id ) |
|
1949 | + floatval(give_get_meta($payment_id, '_give_payment_total', true)), |
|
1950 | + give_get_price_decimals($payment_id) |
|
1954 | 1951 | ); |
1955 | 1952 | } |
1956 | 1953 | |
@@ -1963,13 +1960,13 @@ discard block |
||
1963 | 1960 | * |
1964 | 1961 | * @return array |
1965 | 1962 | */ |
1966 | -function give_get_donation_address( $donation_id ) { |
|
1967 | - $address['line1'] = give_get_meta( $donation_id, '_give_donor_billing_address1', true, '' ); |
|
1968 | - $address['line2'] = give_get_meta( $donation_id, '_give_donor_billing_address2', true, '' ); |
|
1969 | - $address['city'] = give_get_meta( $donation_id, '_give_donor_billing_city', true, '' ); |
|
1970 | - $address['state'] = give_get_meta( $donation_id, '_give_donor_billing_state', true, '' ); |
|
1971 | - $address['zip'] = give_get_meta( $donation_id, '_give_donor_billing_zip', true, '' ); |
|
1972 | - $address['country'] = give_get_meta( $donation_id, '_give_donor_billing_country', true, '' ); |
|
1963 | +function give_get_donation_address($donation_id) { |
|
1964 | + $address['line1'] = give_get_meta($donation_id, '_give_donor_billing_address1', true, ''); |
|
1965 | + $address['line2'] = give_get_meta($donation_id, '_give_donor_billing_address2', true, ''); |
|
1966 | + $address['city'] = give_get_meta($donation_id, '_give_donor_billing_city', true, ''); |
|
1967 | + $address['state'] = give_get_meta($donation_id, '_give_donor_billing_state', true, ''); |
|
1968 | + $address['zip'] = give_get_meta($donation_id, '_give_donor_billing_zip', true, ''); |
|
1969 | + $address['country'] = give_get_meta($donation_id, '_give_donor_billing_country', true, ''); |
|
1973 | 1970 | |
1974 | 1971 | return $address; |
1975 | 1972 | } |
@@ -1984,7 +1981,7 @@ discard block |
||
1984 | 1981 | * |
1985 | 1982 | * @return bool |
1986 | 1983 | */ |
1987 | -function give_is_donation_completed( $donation_id ) { |
|
1984 | +function give_is_donation_completed($donation_id) { |
|
1988 | 1985 | global $wpdb; |
1989 | 1986 | |
1990 | 1987 | /** |
@@ -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 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /* @var WPDB $wpdb */ |
54 | 54 | global $wpdb; |
55 | 55 | |
56 | - $wpdb->donormeta = $this->table_name = $wpdb->prefix . 'give_donormeta'; |
|
56 | + $wpdb->donormeta = $this->table_name = $wpdb->prefix.'give_donormeta'; |
|
57 | 57 | $this->primary_key = 'meta_id'; |
58 | 58 | $this->version = '1.0'; |
59 | 59 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | global $wpdb; |
93 | 93 | |
94 | 94 | if ( |
95 | - ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) && |
|
96 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) ) |
|
95 | + ! give_has_upgrade_completed('v20_rename_donor_tables') && |
|
96 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta")) |
|
97 | 97 | ) { |
98 | 98 | $wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta"; |
99 | 99 | $this->meta_type = 'customer'; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return bool |
114 | 114 | */ |
115 | - protected function is_valid_post_type( $ID ) { |
|
115 | + protected function is_valid_post_type($ID) { |
|
116 | 116 | return $ID && true; |
117 | 117 | } |
118 | 118 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -26,31 +26,31 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_test_ajax_works() { |
28 | 28 | // Handle ajax. |
29 | - if ( doing_action( 'wp_ajax_nopriv_give_test_ajax' ) ) { |
|
30 | - wp_die( 0, 200 ); |
|
29 | + if (doing_action('wp_ajax_nopriv_give_test_ajax')) { |
|
30 | + wp_die(0, 200); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // Check if the Airplane Mode plugin is installed. |
34 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
34 | + if (class_exists('Airplane_Mode_Core')) { |
|
35 | 35 | |
36 | 36 | $airplane = Airplane_Mode_Core::getInstance(); |
37 | 37 | |
38 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
38 | + if (method_exists($airplane, 'enabled')) { |
|
39 | 39 | |
40 | - if ( $airplane->enabled() ) { |
|
40 | + if ($airplane->enabled()) { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } else { |
44 | 44 | |
45 | - if ( 'on' === $airplane->check_status() ) { |
|
45 | + if ('on' === $airplane->check_status()) { |
|
46 | 46 | return true; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - add_filter( 'block_local_requests', '__return_false' ); |
|
51 | + add_filter('block_local_requests', '__return_false'); |
|
52 | 52 | |
53 | - if ( Give_Cache::get( '_give_ajax_works', true ) ) { |
|
53 | + if (Give_Cache::get('_give_ajax_works', true)) { |
|
54 | 54 | return true; |
55 | 55 | } |
56 | 56 | |
@@ -62,41 +62,41 @@ discard block |
||
62 | 62 | ), |
63 | 63 | ); |
64 | 64 | |
65 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
65 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
66 | 66 | |
67 | 67 | $works = true; |
68 | 68 | |
69 | - if ( is_wp_error( $ajax ) ) { |
|
69 | + if (is_wp_error($ajax)) { |
|
70 | 70 | |
71 | 71 | $works = false; |
72 | 72 | |
73 | 73 | } else { |
74 | 74 | |
75 | - if ( empty( $ajax['response'] ) ) { |
|
75 | + if (empty($ajax['response'])) { |
|
76 | 76 | $works = false; |
77 | 77 | } |
78 | 78 | |
79 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
79 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
80 | 80 | $works = false; |
81 | 81 | } |
82 | 82 | |
83 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
83 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
84 | 84 | $works = false; |
85 | 85 | } |
86 | 86 | |
87 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
87 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
88 | 88 | $works = false; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - if ( $works ) { |
|
93 | - Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true ); |
|
92 | + if ($works) { |
|
93 | + Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true); |
|
94 | 94 | } |
95 | 95 | |
96 | - return apply_filters( 'give_test_ajax_works', $works ); |
|
96 | + return apply_filters('give_test_ajax_works', $works); |
|
97 | 97 | } |
98 | 98 | |
99 | -add_action( 'wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works' ); |
|
99 | +add_action('wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works'); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Get AJAX URL |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | -function give_get_ajax_url( $query = array() ) { |
|
111 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
110 | +function give_get_ajax_url($query = array()) { |
|
111 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
112 | 112 | |
113 | 113 | $current_url = give_get_current_page_url(); |
114 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
114 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
115 | 115 | |
116 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
117 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
116 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
117 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $query ) ) { |
|
121 | - $ajax_url = add_query_arg( $query, $ajax_url ); |
|
120 | + if ( ! empty($query)) { |
|
121 | + $ajax_url = add_query_arg($query, $ajax_url); |
|
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
124 | + return apply_filters('give_ajax_url', $ajax_url); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @since 1.7 |
139 | 139 | */ |
140 | - do_action( 'give_donation_form_login_fields' ); |
|
140 | + do_action('give_donation_form_login_fields'); |
|
141 | 141 | |
142 | 142 | give_die(); |
143 | 143 | } |
144 | 144 | |
145 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
145 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Load Checkout Fields |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | function give_load_checkout_fields() { |
155 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
155 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
156 | 156 | |
157 | 157 | ob_start(); |
158 | 158 | |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @since 1.7 |
163 | 163 | */ |
164 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
164 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
165 | 165 | |
166 | 166 | $fields = ob_get_clean(); |
167 | 167 | |
168 | - wp_send_json( array( |
|
169 | - 'fields' => wp_json_encode( $fields ), |
|
170 | - 'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ), |
|
171 | - ) ); |
|
168 | + wp_send_json(array( |
|
169 | + 'fields' => wp_json_encode($fields), |
|
170 | + 'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)), |
|
171 | + )); |
|
172 | 172 | } |
173 | 173 | |
174 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
175 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
174 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
175 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | function give_ajax_get_form_title() { |
185 | - if ( isset( $_POST['form_id'] ) ) { |
|
186 | - $title = get_the_title( $_POST['form_id'] ); |
|
187 | - if ( $title ) { |
|
185 | + if (isset($_POST['form_id'])) { |
|
186 | + $title = get_the_title($_POST['form_id']); |
|
187 | + if ($title) { |
|
188 | 188 | echo $title; |
189 | 189 | } else { |
190 | 190 | echo 'fail'; |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | give_die(); |
194 | 194 | } |
195 | 195 | |
196 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
197 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
196 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
197 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Retrieve a states drop down |
@@ -208,41 +208,41 @@ discard block |
||
208 | 208 | $show_field = true; |
209 | 209 | $states_require = true; |
210 | 210 | // Get the Country code from the $_POST. |
211 | - $country = sanitize_text_field( $_POST['country'] ); |
|
211 | + $country = sanitize_text_field($_POST['country']); |
|
212 | 212 | |
213 | 213 | // Get the field name from the $_POST. |
214 | - $field_name = sanitize_text_field( $_POST['field_name'] ); |
|
214 | + $field_name = sanitize_text_field($_POST['field_name']); |
|
215 | 215 | |
216 | - $label = __( 'State', 'give' ); |
|
216 | + $label = __('State', 'give'); |
|
217 | 217 | $states_label = give_get_states_label(); |
218 | 218 | |
219 | 219 | $default_state = ''; |
220 | - if ( $country === give_get_country() ) { |
|
220 | + if ($country === give_get_country()) { |
|
221 | 221 | $default_state = give_get_state(); |
222 | 222 | } |
223 | 223 | |
224 | 224 | // Check if $country code exists in the array key for states label. |
225 | - if ( array_key_exists( $country, $states_label ) ) { |
|
226 | - $label = $states_label[ $country ]; |
|
225 | + if (array_key_exists($country, $states_label)) { |
|
226 | + $label = $states_label[$country]; |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( empty( $country ) ) { |
|
229 | + if (empty($country)) { |
|
230 | 230 | $country = give_get_country(); |
231 | 231 | } |
232 | 232 | |
233 | - $states = give_get_states( $country ); |
|
234 | - if ( ! empty( $states ) ) { |
|
235 | - $args = array( |
|
233 | + $states = give_get_states($country); |
|
234 | + if ( ! empty($states)) { |
|
235 | + $args = array( |
|
236 | 236 | 'name' => $field_name, |
237 | 237 | 'id' => $field_name, |
238 | - 'class' => $field_name . ' give-select', |
|
238 | + 'class' => $field_name.' give-select', |
|
239 | 239 | 'options' => $states, |
240 | 240 | 'show_option_all' => false, |
241 | 241 | 'show_option_none' => false, |
242 | 242 | 'placeholder' => $label, |
243 | 243 | 'selected' => $default_state, |
244 | 244 | ); |
245 | - $data = Give()->html->select( $args ); |
|
245 | + $data = Give()->html->select($args); |
|
246 | 246 | $states_found = true; |
247 | 247 | } else { |
248 | 248 | $data = 'nostates'; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $no_states_country = give_no_states_country_list(); |
252 | 252 | |
253 | 253 | // Check if $country code exists in the array key. |
254 | - if ( array_key_exists( $country, $no_states_country ) ) { |
|
254 | + if (array_key_exists($country, $no_states_country)) { |
|
255 | 255 | $show_field = false; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $states_not_required_country_list = give_states_not_required_country_list(); |
260 | 260 | |
261 | 261 | // Check if $country code exists in the array key. |
262 | - if ( array_key_exists( $country, $states_not_required_country_list ) ) { |
|
262 | + if (array_key_exists($country, $states_not_required_country_list)) { |
|
263 | 263 | $states_require = false; |
264 | 264 | } |
265 | 265 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | 'data' => $data, |
273 | 273 | 'default_state' => $default_state, |
274 | 274 | ); |
275 | - wp_send_json( $response ); |
|
275 | + wp_send_json($response); |
|
276 | 276 | } |
277 | 277 | |
278 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
279 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
278 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
279 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Retrieve donation forms via AJAX for chosen dropdown search field. |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | function give_ajax_form_search() { |
289 | 289 | $results = array(); |
290 | - $search = esc_sql( sanitize_text_field( $_POST['s'] ) ); |
|
290 | + $search = esc_sql(sanitize_text_field($_POST['s'])); |
|
291 | 291 | |
292 | 292 | $args = array( |
293 | 293 | 'post_type' => 'give_forms', |
@@ -303,12 +303,12 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return array $args Query argument for WP_query |
305 | 305 | */ |
306 | - $args = (array) apply_filters( 'give_ajax_form_search_args', $args ); |
|
306 | + $args = (array) apply_filters('give_ajax_form_search_args', $args); |
|
307 | 307 | |
308 | 308 | // get all the donation form. |
309 | - $query = new WP_Query( $args ); |
|
310 | - if ( $query->have_posts() ) { |
|
311 | - while ( $query->have_posts() ) { |
|
309 | + $query = new WP_Query($args); |
|
310 | + if ($query->have_posts()) { |
|
311 | + while ($query->have_posts()) { |
|
312 | 312 | $query->the_post(); |
313 | 313 | global $post; |
314 | 314 | |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @return array $results Contain the Donation Form id |
331 | 331 | */ |
332 | - $results = (array) apply_filters( 'give_ajax_form_search_responce', $results ); |
|
332 | + $results = (array) apply_filters('give_ajax_form_search_responce', $results); |
|
333 | 333 | |
334 | - wp_send_json( $results ); |
|
334 | + wp_send_json($results); |
|
335 | 335 | } |
336 | 336 | |
337 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
338 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
337 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
338 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Search the donors database via Ajax |
@@ -347,28 +347,28 @@ discard block |
||
347 | 347 | function give_ajax_donor_search() { |
348 | 348 | global $wpdb; |
349 | 349 | |
350 | - $search = esc_sql( sanitize_text_field( $_POST['s'] ) ); |
|
350 | + $search = esc_sql(sanitize_text_field($_POST['s'])); |
|
351 | 351 | $results = array(); |
352 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
352 | + if ( ! current_user_can('view_give_reports')) { |
|
353 | 353 | $donors = array(); |
354 | 354 | } else { |
355 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
355 | + $donors = $wpdb->get_results("SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
356 | 356 | } |
357 | 357 | |
358 | - if ( $donors ) { |
|
359 | - foreach ( $donors as $donor ) { |
|
358 | + if ($donors) { |
|
359 | + foreach ($donors as $donor) { |
|
360 | 360 | |
361 | 361 | $results[] = array( |
362 | 362 | 'id' => $donor->id, |
363 | - 'name' => $donor->name . ' (' . $donor->email . ')', |
|
363 | + 'name' => $donor->name.' ('.$donor->email.')', |
|
364 | 364 | ); |
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | - wp_send_json( $results ); |
|
368 | + wp_send_json($results); |
|
369 | 369 | } |
370 | 370 | |
371 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
371 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
372 | 372 | |
373 | 373 | |
374 | 374 | /** |
@@ -381,37 +381,37 @@ discard block |
||
381 | 381 | function give_ajax_search_users() { |
382 | 382 | $results = array(); |
383 | 383 | |
384 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
384 | + if (current_user_can('manage_give_settings')) { |
|
385 | 385 | |
386 | - $search = esc_sql( sanitize_text_field( $_POST['s'] ) ); |
|
386 | + $search = esc_sql(sanitize_text_field($_POST['s'])); |
|
387 | 387 | |
388 | 388 | $get_users_args = array( |
389 | 389 | 'number' => 9999, |
390 | - 'search' => $search . '*', |
|
390 | + 'search' => $search.'*', |
|
391 | 391 | ); |
392 | 392 | |
393 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
393 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
394 | 394 | |
395 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search ); |
|
395 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search); |
|
396 | 396 | $results = array(); |
397 | 397 | |
398 | - if ( $found_users ) { |
|
398 | + if ($found_users) { |
|
399 | 399 | |
400 | - foreach ( $found_users as $user ) { |
|
400 | + foreach ($found_users as $user) { |
|
401 | 401 | |
402 | 402 | $results[] = array( |
403 | 403 | 'id' => $user->ID, |
404 | - 'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ), |
|
404 | + 'name' => esc_html($user->user_login.' ('.$user->user_email.')'), |
|
405 | 405 | ); |
406 | 406 | } |
407 | 407 | } |
408 | 408 | }// End if(). |
409 | 409 | |
410 | - wp_send_json( $results ); |
|
410 | + wp_send_json($results); |
|
411 | 411 | |
412 | 412 | } |
413 | 413 | |
414 | -add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' ); |
|
414 | +add_action('wp_ajax_give_user_search', 'give_ajax_search_users'); |
|
415 | 415 | |
416 | 416 | |
417 | 417 | /** |
@@ -427,14 +427,14 @@ discard block |
||
427 | 427 | $data = array(); |
428 | 428 | $args = array( |
429 | 429 | 'post_type' => 'page', |
430 | - 's' => give_clean( $_POST['s'] ), |
|
430 | + 's' => give_clean($_POST['s']), |
|
431 | 431 | ); |
432 | 432 | |
433 | - $query = new WP_Query( $args ); |
|
433 | + $query = new WP_Query($args); |
|
434 | 434 | |
435 | 435 | // Query posts by title. |
436 | - if ( $query->have_posts() ) { |
|
437 | - while ( $query->have_posts() ) { |
|
436 | + if ($query->have_posts()) { |
|
437 | + while ($query->have_posts()) { |
|
438 | 438 | $query->the_post(); |
439 | 439 | |
440 | 440 | $data[] = array( |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - wp_send_json( $data ); |
|
447 | + wp_send_json($data); |
|
448 | 448 | } |
449 | 449 | |
450 | -add_action( 'wp_ajax_give_pages_search', 'give_ajax_pages_search' ); |
|
450 | +add_action('wp_ajax_give_pages_search', 'give_ajax_pages_search'); |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * Retrieve Categories via AJAX for chosen dropdown search field. |
@@ -468,14 +468,14 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return array $args argument for get_terms |
470 | 470 | */ |
471 | - $args = (array) apply_filters( 'give_forms_categories_dropdown_args', array( |
|
471 | + $args = (array) apply_filters('give_forms_categories_dropdown_args', array( |
|
472 | 472 | 'number' => 30, |
473 | - 'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) ) |
|
474 | - ) ); |
|
473 | + 'name__like' => esc_sql(sanitize_text_field($_POST['s'])) |
|
474 | + )); |
|
475 | 475 | |
476 | - $categories = get_terms( 'give_forms_category', $args ); |
|
476 | + $categories = get_terms('give_forms_category', $args); |
|
477 | 477 | |
478 | - foreach ( $categories as $category ) { |
|
478 | + foreach ($categories as $category) { |
|
479 | 479 | $results[] = array( |
480 | 480 | 'id' => $category->term_id, |
481 | 481 | 'name' => $category->name, |
@@ -491,12 +491,12 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @return array $results Contain the categories id and name |
493 | 493 | */ |
494 | - $results = (array) apply_filters( 'give_forms_categories_dropdown_responce', $results ); |
|
494 | + $results = (array) apply_filters('give_forms_categories_dropdown_responce', $results); |
|
495 | 495 | |
496 | - wp_send_json( $results ); |
|
496 | + wp_send_json($results); |
|
497 | 497 | } |
498 | 498 | |
499 | -add_action( 'wp_ajax_give_categories_search', 'give_ajax_categories_search' ); |
|
499 | +add_action('wp_ajax_give_categories_search', 'give_ajax_categories_search'); |
|
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Retrieve Tags via AJAX for chosen dropdown search field. |
@@ -517,14 +517,14 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return array $args argument for get_terms |
519 | 519 | */ |
520 | - $args = (array) apply_filters( 'give_forms_tags_dropdown_args', array( |
|
520 | + $args = (array) apply_filters('give_forms_tags_dropdown_args', array( |
|
521 | 521 | 'number' => 30, |
522 | - 'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) ) |
|
523 | - ) ); |
|
522 | + 'name__like' => esc_sql(sanitize_text_field($_POST['s'])) |
|
523 | + )); |
|
524 | 524 | |
525 | - $categories = get_terms( 'give_forms_tag', $args ); |
|
525 | + $categories = get_terms('give_forms_tag', $args); |
|
526 | 526 | |
527 | - foreach ( $categories as $category ) { |
|
527 | + foreach ($categories as $category) { |
|
528 | 528 | $results[] = array( |
529 | 529 | 'id' => $category->term_id, |
530 | 530 | 'name' => $category->name, |
@@ -540,12 +540,12 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return array $results Contain the tags id and name |
542 | 542 | */ |
543 | - $results = (array) apply_filters( 'give_forms_tags_dropdown_responce', $results ); |
|
543 | + $results = (array) apply_filters('give_forms_tags_dropdown_responce', $results); |
|
544 | 544 | |
545 | - wp_send_json( $results ); |
|
545 | + wp_send_json($results); |
|
546 | 546 | } |
547 | 547 | |
548 | -add_action( 'wp_ajax_give_tags_search', 'give_ajax_tags_search' ); |
|
548 | +add_action('wp_ajax_give_tags_search', 'give_ajax_tags_search'); |
|
549 | 549 | |
550 | 550 | /** |
551 | 551 | * Check for Price Variations (Multi-level donation forms) |
@@ -556,32 +556,32 @@ discard block |
||
556 | 556 | */ |
557 | 557 | function give_check_for_form_price_variations() { |
558 | 558 | |
559 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
560 | - die( '-1' ); |
|
559 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
560 | + die('-1'); |
|
561 | 561 | } |
562 | 562 | |
563 | - $form_id = intval( $_POST['form_id'] ); |
|
564 | - $form = get_post( $form_id ); |
|
563 | + $form_id = intval($_POST['form_id']); |
|
564 | + $form = get_post($form_id); |
|
565 | 565 | |
566 | - if ( 'give_forms' !== $form->post_type ) { |
|
567 | - die( '-2' ); |
|
566 | + if ('give_forms' !== $form->post_type) { |
|
567 | + die('-2'); |
|
568 | 568 | } |
569 | 569 | |
570 | - if ( give_has_variable_prices( $form_id ) ) { |
|
571 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
570 | + if (give_has_variable_prices($form_id)) { |
|
571 | + $variable_prices = give_get_variable_prices($form_id); |
|
572 | 572 | |
573 | - if ( $variable_prices ) { |
|
573 | + if ($variable_prices) { |
|
574 | 574 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
575 | 575 | |
576 | - if ( isset( $_POST['all_prices'] ) ) { |
|
577 | - $ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
576 | + if (isset($_POST['all_prices'])) { |
|
577 | + $ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>'; |
|
578 | 578 | } |
579 | 579 | |
580 | - foreach ( $variable_prices as $key => $price ) { |
|
580 | + foreach ($variable_prices as $key => $price) { |
|
581 | 581 | |
582 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
582 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))); |
|
583 | 583 | |
584 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
584 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
585 | 585 | } |
586 | 586 | $ajax_response .= '</select>'; |
587 | 587 | echo $ajax_response; |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | give_die(); |
592 | 592 | } |
593 | 593 | |
594 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
594 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
595 | 595 | |
596 | 596 | |
597 | 597 | /** |
@@ -602,28 +602,28 @@ discard block |
||
602 | 602 | * @return void |
603 | 603 | */ |
604 | 604 | function give_check_for_form_price_variations_html() { |
605 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
605 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
606 | 606 | wp_die(); |
607 | 607 | } |
608 | 608 | |
609 | - $form_id = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false; |
|
610 | - $payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false; |
|
611 | - if ( empty( $form_id ) || empty( $payment_id ) ) { |
|
609 | + $form_id = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false; |
|
610 | + $payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false; |
|
611 | + if (empty($form_id) || empty($payment_id)) { |
|
612 | 612 | wp_die(); |
613 | 613 | } |
614 | 614 | |
615 | - $form = get_post( $form_id ); |
|
616 | - if ( ! empty( $form->post_type ) && 'give_forms' !== $form->post_type ) { |
|
615 | + $form = get_post($form_id); |
|
616 | + if ( ! empty($form->post_type) && 'give_forms' !== $form->post_type) { |
|
617 | 617 | wp_die(); |
618 | 618 | } |
619 | 619 | |
620 | - if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) { |
|
621 | - esc_html_e( 'n/a', 'give' ); |
|
620 | + if ( ! give_has_variable_prices($form_id) || ! $form_id) { |
|
621 | + esc_html_e('n/a', 'give'); |
|
622 | 622 | } else { |
623 | 623 | $prices_atts = array(); |
624 | - if ( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
625 | - foreach ( $variable_prices as $variable_price ) { |
|
626 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ); |
|
624 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
625 | + foreach ($variable_prices as $variable_price) { |
|
626 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false)); |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
@@ -634,12 +634,12 @@ discard block |
||
634 | 634 | 'chosen' => true, |
635 | 635 | 'show_option_all' => '', |
636 | 636 | 'show_option_none' => '', |
637 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
637 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
638 | 638 | ); |
639 | 639 | |
640 | - if ( $payment_id ) { |
|
640 | + if ($payment_id) { |
|
641 | 641 | // Payment object. |
642 | - $payment = new Give_Payment( $payment_id ); |
|
642 | + $payment = new Give_Payment($payment_id); |
|
643 | 643 | |
644 | 644 | // Payment meta. |
645 | 645 | $payment_meta = $payment->get_meta(); |
@@ -647,13 +647,13 @@ discard block |
||
647 | 647 | } |
648 | 648 | |
649 | 649 | // Render variable prices select tag html. |
650 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
650 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | give_die(); |
654 | 654 | } |
655 | 655 | |
656 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
656 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
|
657 | 657 | |
658 | 658 | /** |
659 | 659 | * Send Confirmation Email For Complete Donation History Access. |
@@ -665,30 +665,30 @@ discard block |
||
665 | 665 | function give_confirm_email_for_donation_access() { |
666 | 666 | |
667 | 667 | // Verify Security using Nonce. |
668 | - if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) { |
|
668 | + if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) { |
|
669 | 669 | return false; |
670 | 670 | } |
671 | 671 | |
672 | 672 | // Bail Out, if email is empty. |
673 | - if ( empty( $_POST['email'] ) ) { |
|
673 | + if (empty($_POST['email'])) { |
|
674 | 674 | return false; |
675 | 675 | } |
676 | 676 | |
677 | - $donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) ); |
|
678 | - if ( Give()->email_access->can_send_email( $donor->id ) ) { |
|
677 | + $donor = Give()->donors->get_donor_by('email', give_clean($_POST['email'])); |
|
678 | + if (Give()->email_access->can_send_email($donor->id)) { |
|
679 | 679 | $return = array(); |
680 | - $email_sent = Give()->email_access->send_email( $donor->id, $donor->email ); |
|
680 | + $email_sent = Give()->email_access->send_email($donor->id, $donor->email); |
|
681 | 681 | |
682 | - if ( ! $email_sent ) { |
|
682 | + if ( ! $email_sent) { |
|
683 | 683 | $return['status'] = 'error'; |
684 | 684 | $return['message'] = Give()->notices->print_frontend_notice( |
685 | - __( 'Unable to send email. Please try again.', 'give' ), |
|
685 | + __('Unable to send email. Please try again.', 'give'), |
|
686 | 686 | false, |
687 | 687 | 'error' |
688 | 688 | ); |
689 | 689 | } |
690 | 690 | |
691 | - $return['status'] = 'success'; |
|
691 | + $return['status'] = 'success'; |
|
692 | 692 | |
693 | 693 | /** |
694 | 694 | * Filter to modify access mail send notice |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * |
700 | 700 | * @return string $message Send notice message for email access. |
701 | 701 | */ |
702 | - $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) ); |
|
702 | + $message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give')); |
|
703 | 703 | |
704 | 704 | $return['message'] = Give()->notices->print_frontend_notice( |
705 | 705 | $message, |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | $message = (string) apply_filters( |
726 | 726 | 'give_email_access_requests_exceed_notice', |
727 | 727 | sprintf( |
728 | - __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
|
729 | - sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
|
728 | + __('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'), |
|
729 | + sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value) |
|
730 | 730 | ), |
731 | 731 | $value |
732 | 732 | ); |
@@ -738,8 +738,8 @@ discard block |
||
738 | 738 | ); |
739 | 739 | } |
740 | 740 | |
741 | - echo json_encode( $return ); |
|
741 | + echo json_encode($return); |
|
742 | 742 | give_die(); |
743 | 743 | } |
744 | 744 | |
745 | -add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' ); |
|
746 | 745 | \ No newline at end of file |
746 | +add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access'); |
|
747 | 747 | \ 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 | |
@@ -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( __CLASS__, 'flush_cache' ) ); |
|
81 | + add_action('give_save_settings_give_settings', array(__CLASS__, '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,28 +199,28 @@ 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( empty( $cache_key ) ) { |
|
205 | - return new WP_Error( 'give_empty_cache_key', __( 'Do not pass invalid empty cache key', 'give' ) ); |
|
206 | - }elseif ( ! $custom_key ) { |
|
207 | - 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 (empty($cache_key)) { |
|
205 | + return new WP_Error('give_empty_cache_key', __('Do not pass invalid empty cache key', 'give')); |
|
206 | + }elseif ( ! $custom_key) { |
|
207 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
208 | 208 | } |
209 | 209 | |
210 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
210 | + $cache_key = self::get_key($cache_key, $query_args); |
|
211 | 211 | } |
212 | 212 | |
213 | - $option = get_option( $cache_key ); |
|
213 | + $option = get_option($cache_key); |
|
214 | 214 | |
215 | 215 | // Backward compatibility (<1.8.7). |
216 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
216 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
217 | 217 | return $option; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Get current time. |
221 | - $current_time = current_time( 'timestamp', 1 ); |
|
221 | + $current_time = current_time('timestamp', 1); |
|
222 | 222 | |
223 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
223 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
224 | 224 | $option = $option['data']; |
225 | 225 | } else { |
226 | 226 | $option = false; |
@@ -242,23 +242,23 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return mixed |
244 | 244 | */ |
245 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
246 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
247 | - if ( ! $custom_key ) { |
|
248 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
245 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
246 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
247 | + if ( ! $custom_key) { |
|
248 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
249 | 249 | } |
250 | 250 | |
251 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
251 | + $cache_key = self::get_key($cache_key, $query_args); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | $option_value = array( |
255 | 255 | 'data' => $data, |
256 | - 'expiration' => ! is_null( $expiration ) |
|
257 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
256 | + 'expiration' => ! is_null($expiration) |
|
257 | + ? ($expiration + current_time('timestamp', 1)) |
|
258 | 258 | : null, |
259 | 259 | ); |
260 | 260 | |
261 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
261 | + $result = update_option($cache_key, $option_value, 'no'); |
|
262 | 262 | |
263 | 263 | return $result; |
264 | 264 | } |
@@ -274,27 +274,27 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return bool|WP_Error |
276 | 276 | */ |
277 | - public static function delete( $cache_keys ) { |
|
277 | + public static function delete($cache_keys) { |
|
278 | 278 | $result = true; |
279 | 279 | $invalid_keys = array(); |
280 | 280 | |
281 | - if ( ! empty( $cache_keys ) ) { |
|
282 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
281 | + if ( ! empty($cache_keys)) { |
|
282 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
283 | 283 | |
284 | - foreach ( $cache_keys as $cache_key ) { |
|
285 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
284 | + foreach ($cache_keys as $cache_key) { |
|
285 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
286 | 286 | $invalid_keys[] = $cache_key; |
287 | 287 | $result = false; |
288 | 288 | } |
289 | 289 | |
290 | - delete_option( $cache_key ); |
|
290 | + delete_option($cache_key); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | - if ( ! $result ) { |
|
294 | + if ( ! $result) { |
|
295 | 295 | $result = new WP_Error( |
296 | 296 | 'give_invalid_cache_key', |
297 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
297 | + __('Cache key format should be give_cache_*', 'give'), |
|
298 | 298 | $invalid_keys |
299 | 299 | ); |
300 | 300 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return bool |
317 | 317 | */ |
318 | - public static function delete_all_expired( $force = false ) { |
|
318 | + public static function delete_all_expired($force = false) { |
|
319 | 319 | global $wpdb; |
320 | 320 | $options = $wpdb->get_results( |
321 | 321 | $wpdb->prepare( |
@@ -329,30 +329,30 @@ discard block |
||
329 | 329 | ); |
330 | 330 | |
331 | 331 | // Bailout. |
332 | - if ( empty( $options ) ) { |
|
332 | + if (empty($options)) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | |
336 | - $current_time = current_time( 'timestamp', 1 ); |
|
336 | + $current_time = current_time('timestamp', 1); |
|
337 | 337 | |
338 | 338 | // Delete log cache. |
339 | - foreach ( $options as $option ) { |
|
340 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
339 | + foreach ($options as $option) { |
|
340 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
341 | 341 | |
342 | 342 | if ( |
343 | 343 | ( |
344 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
345 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
346 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
347 | - || empty( $option['option_value']['expiration'] ) |
|
348 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
344 | + ! self::is_valid_cache_key($option['option_name']) |
|
345 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
346 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
347 | + || empty($option['option_value']['expiration']) |
|
348 | + || ($current_time < $option['option_value']['expiration']) |
|
349 | 349 | ) |
350 | 350 | && ! $force |
351 | 351 | ) { |
352 | 352 | continue; |
353 | 353 | } |
354 | 354 | |
355 | - self::delete( $option['option_name'] ); |
|
355 | + self::delete($option['option_name']); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return array |
372 | 372 | */ |
373 | - public static function get_options_like( $option_name, $fields = false ) { |
|
373 | + public static function get_options_like($option_name, $fields = false) { |
|
374 | 374 | global $wpdb; |
375 | 375 | |
376 | 376 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
377 | 377 | |
378 | - if ( $fields ) { |
|
378 | + if ($fields) { |
|
379 | 379 | $options = $wpdb->get_results( |
380 | 380 | $wpdb->prepare( |
381 | 381 | "SELECT {$field_names } |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | ); |
400 | 400 | } |
401 | 401 | |
402 | - if ( ! empty( $options ) && $fields ) { |
|
403 | - foreach ( $options as $index => $option ) { |
|
404 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
405 | - $options[ $index ] = $option; |
|
402 | + if ( ! empty($options) && $fields) { |
|
403 | + foreach ($options as $index => $option) { |
|
404 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
405 | + $options[$index] = $option; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return bool |
421 | 421 | */ |
422 | - public static function is_valid_cache_key( $cache_key ) { |
|
423 | - $is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
422 | + public static function is_valid_cache_key($cache_key) { |
|
423 | + $is_valid = (false !== strpos($cache_key, 'give_cache_')); |
|
424 | 424 | |
425 | 425 | |
426 | 426 | /** |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @since 2.0 |
430 | 430 | */ |
431 | - return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key ); |
|
431 | + return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return mixed |
445 | 445 | */ |
446 | - public static function get_group( $id, $group = '' ) { |
|
446 | + public static function get_group($id, $group = '') { |
|
447 | 447 | $cached_data = null; |
448 | 448 | |
449 | 449 | // Bailout. |
450 | - if ( self::$instance->is_cache && ! empty( $id ) ) { |
|
451 | - $group = self::$instance->filter_group_name( $group ); |
|
450 | + if (self::$instance->is_cache && ! empty($id)) { |
|
451 | + $group = self::$instance->filter_group_name($group); |
|
452 | 452 | |
453 | - $cached_data = wp_cache_get( $id, $group ); |
|
453 | + $cached_data = wp_cache_get($id, $group); |
|
454 | 454 | $cached_data = false !== $cached_data ? $cached_data : null; |
455 | 455 | } |
456 | 456 | |
@@ -470,17 +470,17 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return bool |
472 | 472 | */ |
473 | - public static function set_group( $id, $data, $group = '', $expire = 0 ) { |
|
473 | + public static function set_group($id, $data, $group = '', $expire = 0) { |
|
474 | 474 | $status = false; |
475 | 475 | |
476 | 476 | // Bailout. |
477 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
477 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
478 | 478 | return $status; |
479 | 479 | } |
480 | 480 | |
481 | - $group = self::$instance->filter_group_name( $group ); |
|
481 | + $group = self::$instance->filter_group_name($group); |
|
482 | 482 | |
483 | - $status = wp_cache_set( $id, $data, $group, $expire ); |
|
483 | + $status = wp_cache_set($id, $data, $group, $expire); |
|
484 | 484 | |
485 | 485 | return $status; |
486 | 486 | } |
@@ -496,15 +496,15 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return bool |
498 | 498 | */ |
499 | - public static function set_db_query( $id, $data ) { |
|
499 | + public static function set_db_query($id, $data) { |
|
500 | 500 | $status = false; |
501 | 501 | |
502 | 502 | // Bailout. |
503 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
503 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
504 | 504 | return $status; |
505 | 505 | } |
506 | 506 | |
507 | - return self::set_group( $id, $data, 'give-db-queries', 0 ); |
|
507 | + return self::set_group($id, $data, 'give-db-queries', 0); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return mixed |
519 | 519 | */ |
520 | - public static function get_db_query( $id ) { |
|
521 | - return self::get_group( $id, 'give-db-queries' ); |
|
520 | + public static function get_db_query($id) { |
|
521 | + return self::get_group($id, 'give-db-queries'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -533,21 +533,21 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return bool |
535 | 535 | */ |
536 | - public static function delete_group( $ids, $group = '', $expire = 0 ) { |
|
536 | + public static function delete_group($ids, $group = '', $expire = 0) { |
|
537 | 537 | $status = false; |
538 | 538 | |
539 | 539 | // Bailout. |
540 | - if ( ! self::$instance->is_cache || empty( $ids ) ) { |
|
540 | + if ( ! self::$instance->is_cache || empty($ids)) { |
|
541 | 541 | return $status; |
542 | 542 | } |
543 | 543 | |
544 | 544 | $group_prefix = $group; |
545 | - $group = self::$instance->filter_group_name( $group ); |
|
545 | + $group = self::$instance->filter_group_name($group); |
|
546 | 546 | |
547 | 547 | // Delete single or multiple cache items from cache. |
548 | - if ( ! is_array( $ids ) ) { |
|
549 | - $status = wp_cache_delete( $ids, $group ); |
|
550 | - self::$instance->get_incrementer( true ); |
|
548 | + if ( ! is_array($ids)) { |
|
549 | + $status = wp_cache_delete($ids, $group); |
|
550 | + self::$instance->get_incrementer(true); |
|
551 | 551 | |
552 | 552 | /** |
553 | 553 | * Fire action when cache deleted for specific id. |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | * @param string $group |
559 | 559 | * @param int $expire |
560 | 560 | */ |
561 | - do_action( "give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status ); |
|
561 | + do_action("give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status); |
|
562 | 562 | |
563 | 563 | } else { |
564 | - foreach ( $ids as $id ) { |
|
565 | - $status = wp_cache_delete( $id, $group ); |
|
566 | - self::$instance->get_incrementer( true ); |
|
564 | + foreach ($ids as $id) { |
|
565 | + $status = wp_cache_delete($id, $group); |
|
566 | + self::$instance->get_incrementer(true); |
|
567 | 567 | |
568 | 568 | /** |
569 | 569 | * Fire action when cache deleted for specific id . |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * @param string $group |
575 | 575 | * @param int $expire |
576 | 576 | */ |
577 | - do_action( "give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status ); |
|
577 | + do_action("give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -591,15 +591,15 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @param int $form_id |
593 | 593 | */ |
594 | - public function delete_form_related_cache( $form_id ) { |
|
594 | + public function delete_form_related_cache($form_id) { |
|
595 | 595 | // If this is just a revision, don't send the email. |
596 | - if ( wp_is_post_revision( $form_id ) ) { |
|
596 | + if (wp_is_post_revision($form_id)) { |
|
597 | 597 | return; |
598 | 598 | } |
599 | 599 | |
600 | 600 | $donation_query = new Give_Payments_Query( |
601 | 601 | array( |
602 | - 'number' => - 1, |
|
602 | + 'number' => -1, |
|
603 | 603 | 'give_forms' => $form_id, |
604 | 604 | 'output' => '', |
605 | 605 | 'fields' => 'ids', |
@@ -608,15 +608,15 @@ discard block |
||
608 | 608 | |
609 | 609 | $donations = $donation_query->get_payments(); |
610 | 610 | |
611 | - if ( ! empty( $donations ) ) { |
|
611 | + if ( ! empty($donations)) { |
|
612 | 612 | /* @var Give_Payment $donation */ |
613 | - foreach ( $donations as $donation_id ) { |
|
614 | - wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) ); |
|
615 | - wp_cache_delete( give_get_payment_donor_id( $donation_id ), $this->filter_group_name( 'give-donors' ) ); |
|
613 | + foreach ($donations as $donation_id) { |
|
614 | + wp_cache_delete($donation_id, $this->filter_group_name('give-donations')); |
|
615 | + wp_cache_delete(give_get_payment_donor_id($donation_id), $this->filter_group_name('give-donors')); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
619 | - self::$instance->get_incrementer( true ); |
|
619 | + self::$instance->get_incrementer(true); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -628,19 +628,19 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @param int $donation_id |
630 | 630 | */ |
631 | - public function delete_payment_related_cache( $donation_id ) { |
|
631 | + public function delete_payment_related_cache($donation_id) { |
|
632 | 632 | // If this is just a revision, don't send the email. |
633 | - if ( wp_is_post_revision( $donation_id ) ) { |
|
633 | + if (wp_is_post_revision($donation_id)) { |
|
634 | 634 | return; |
635 | 635 | } |
636 | 636 | |
637 | - if ( $donation_id && ( $donor_id = give_get_payment_donor_id( $donation_id ) ) ) { |
|
638 | - wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
637 | + if ($donation_id && ($donor_id = give_get_payment_donor_id($donation_id))) { |
|
638 | + wp_cache_delete($donor_id, $this->filter_group_name('give-donors')); |
|
639 | 639 | } |
640 | 640 | |
641 | - wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) ); |
|
641 | + wp_cache_delete($donation_id, $this->filter_group_name('give-donations')); |
|
642 | 642 | |
643 | - self::$instance->get_incrementer( true ); |
|
643 | + self::$instance->get_incrementer(true); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
@@ -654,18 +654,18 @@ discard block |
||
654 | 654 | * @param string $group |
655 | 655 | * @param int $expire |
656 | 656 | */ |
657 | - public function delete_donor_related_cache( $id, $group, $expire ) { |
|
658 | - $donation_ids = Give()->donors->get_column( 'payment_ids', $id ); |
|
657 | + public function delete_donor_related_cache($id, $group, $expire) { |
|
658 | + $donation_ids = Give()->donors->get_column('payment_ids', $id); |
|
659 | 659 | |
660 | - if ( ! empty( $donation_ids ) ) { |
|
661 | - $donation_ids = array_map( 'trim', (array) explode( ',', trim( $donation_ids ) ) ); |
|
660 | + if ( ! empty($donation_ids)) { |
|
661 | + $donation_ids = array_map('trim', (array) explode(',', trim($donation_ids))); |
|
662 | 662 | |
663 | - foreach ( $donation_ids as $donation ) { |
|
664 | - wp_cache_delete( $donation, $this->filter_group_name( 'give-donations' ) ); |
|
663 | + foreach ($donation_ids as $donation) { |
|
664 | + wp_cache_delete($donation, $this->filter_group_name('give-donations')); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | - self::$instance->get_incrementer( true ); |
|
668 | + self::$instance->get_incrementer(true); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -679,12 +679,12 @@ discard block |
||
679 | 679 | * @param string $group |
680 | 680 | * @param int $expire |
681 | 681 | */ |
682 | - public function delete_donations_related_cache( $id, $group, $expire ) { |
|
683 | - if ( $id && ( $donor_id = give_get_payment_donor_id( $id ) ) ) { |
|
684 | - wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
682 | + public function delete_donations_related_cache($id, $group, $expire) { |
|
683 | + if ($id && ($donor_id = give_get_payment_donor_id($id))) { |
|
684 | + wp_cache_delete($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 | - public function get_incrementer( $refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries' ) { |
|
706 | - $incrementer_value = wp_cache_get( $incrementer_key ); |
|
705 | + public 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; |
@@ -723,21 +723,21 @@ discard block |
||
723 | 723 | */ |
724 | 724 | public static function flush_cache() { |
725 | 725 | if ( |
726 | - ( Give_Admin_Settings::is_saving_settings() |
|
727 | - && isset( $_POST['cache'] ) |
|
728 | - && give_is_setting_enabled( give_clean( $_POST['cache'] ) ) |
|
726 | + (Give_Admin_Settings::is_saving_settings() |
|
727 | + && isset($_POST['cache']) |
|
728 | + && give_is_setting_enabled(give_clean($_POST['cache'])) |
|
729 | 729 | ) |
730 | - || ( wp_doing_ajax() && 'give_cache_flush' === give_clean( $_GET['action'] ) ) |
|
730 | + || (wp_doing_ajax() && 'give_cache_flush' === give_clean($_GET['action'])) |
|
731 | 731 | ) { |
732 | - self::$instance->get_incrementer( true ); |
|
733 | - self::$instance->get_incrementer( true, 'give-cache-incrementer' ); |
|
732 | + self::$instance->get_incrementer(true); |
|
733 | + self::$instance->get_incrementer(true, 'give-cache-incrementer'); |
|
734 | 734 | |
735 | 735 | /** |
736 | 736 | * Fire the action when all cache deleted. |
737 | 737 | * |
738 | 738 | * @since 2.1.0 |
739 | 739 | */ |
740 | - do_action( 'give_fluched_cache' ); |
|
740 | + do_action('give_fluched_cache'); |
|
741 | 741 | |
742 | 742 | return true; |
743 | 743 | } |
@@ -756,23 +756,23 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @return mixed |
758 | 758 | */ |
759 | - private function filter_group_name( $group ) { |
|
759 | + private function filter_group_name($group) { |
|
760 | 760 | /** |
761 | 761 | * Filter the group name |
762 | 762 | * |
763 | 763 | * @since 2.1.0 |
764 | 764 | */ |
765 | - $filtered_group = apply_filters( 'give_cache_filter_group_name', '', $group ); |
|
765 | + $filtered_group = apply_filters('give_cache_filter_group_name', '', $group); |
|
766 | 766 | |
767 | - if ( empty( $filtered_group ) ) { |
|
767 | + if (empty($filtered_group)) { |
|
768 | 768 | |
769 | - switch ( $group ) { |
|
769 | + switch ($group) { |
|
770 | 770 | case 'give-db-queries': |
771 | 771 | $incrementer = self::$instance->get_incrementer(); |
772 | 772 | break; |
773 | 773 | |
774 | 774 | default: |
775 | - $incrementer = self::$instance->get_incrementer( false, 'give-cache-incrementer' ); |
|
775 | + $incrementer = self::$instance->get_incrementer(false, 'give-cache-incrementer'); |
|
776 | 776 | |
777 | 777 | } |
778 | 778 |
@@ -203,7 +203,7 @@ |
||
203 | 203 | if ( ! self::is_valid_cache_key( $cache_key ) ) { |
204 | 204 | if( empty( $cache_key ) ) { |
205 | 205 | return new WP_Error( 'give_empty_cache_key', __( 'Do not pass invalid empty cache key', 'give' ) ); |
206 | - }elseif ( ! $custom_key ) { |
|
206 | + } elseif ( ! $custom_key ) { |
|
207 | 207 | return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
208 | 208 | } |
209 | 209 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function donations_dropdown( $args = array() ) { |
|
38 | + public function donations_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'donations', |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => __( 'Select a donation', 'give' ), |
|
48 | + 'placeholder' => __('Select a donation', 'give'), |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | - $payments = new Give_Payments_Query( array( |
|
53 | + $payments = new Give_Payments_Query(array( |
|
54 | 54 | 'number' => $args['number'], |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | $payments = $payments->get_payments(); |
58 | 58 | |
59 | 59 | $options = array(); |
60 | 60 | |
61 | 61 | // Provide nice human readable options. |
62 | - if ( $payments ) { |
|
62 | + if ($payments) { |
|
63 | 63 | $options[0] = $args['placeholder']; |
64 | - foreach ( $payments as $payment ) { |
|
64 | + foreach ($payments as $payment) { |
|
65 | 65 | |
66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } else { |
70 | - $options[0] = __( 'No donations found.', 'give' ); |
|
70 | + $options[0] = __('No donations found.', 'give'); |
|
71 | 71 | } |
72 | 72 | |
73 | - $output = $this->select( array( |
|
73 | + $output = $this->select(array( |
|
74 | 74 | 'name' => $args['name'], |
75 | 75 | 'selected' => $args['selected'], |
76 | 76 | 'id' => $args['id'], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'select_atts' => $args['select_atts'], |
83 | 83 | 'show_option_all' => false, |
84 | 84 | 'show_option_none' => false, |
85 | - ) ); |
|
85 | + )); |
|
86 | 86 | |
87 | 87 | return $output; |
88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return string Give forms dropdown. |
101 | 101 | */ |
102 | - public function forms_dropdown( $args = array() ) { |
|
102 | + public function forms_dropdown($args = array()) { |
|
103 | 103 | |
104 | 104 | $defaults = array( |
105 | 105 | 'name' => 'forms', |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | 'selected' => 0, |
110 | 110 | 'chosen' => false, |
111 | 111 | 'number' => 30, |
112 | - 'placeholder' => esc_attr__( 'All Forms', 'give' ), |
|
112 | + 'placeholder' => esc_attr__('All Forms', 'give'), |
|
113 | 113 | 'data' => array( |
114 | 114 | 'search-type' => 'form', |
115 | 115 | ), |
116 | 116 | 'query_args' => array() |
117 | 117 | ); |
118 | 118 | |
119 | - $args = wp_parse_args( $args, $defaults ); |
|
119 | + $args = wp_parse_args($args, $defaults); |
|
120 | 120 | |
121 | 121 | $form_args = wp_parse_args( |
122 | 122 | $args['query_args'], |
@@ -128,37 +128,37 @@ discard block |
||
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | |
131 | - $cache_key = Give_Cache::get_key( 'give_forms', $form_args, false ); |
|
131 | + $cache_key = Give_Cache::get_key('give_forms', $form_args, false); |
|
132 | 132 | |
133 | 133 | // Get forms from cache. |
134 | - $forms = Give_Cache::get_db_query( $cache_key ); |
|
134 | + $forms = Give_Cache::get_db_query($cache_key); |
|
135 | 135 | |
136 | - if ( is_null( $forms ) ) { |
|
137 | - $forms = new WP_Query( $form_args ); |
|
136 | + if (is_null($forms)) { |
|
137 | + $forms = new WP_Query($form_args); |
|
138 | 138 | $forms = $forms->posts; |
139 | - Give_Cache::set_db_query( $cache_key, $forms ); |
|
139 | + Give_Cache::set_db_query($cache_key, $forms); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | $options = array(); |
143 | 143 | |
144 | 144 | // Ensure the selected. |
145 | - if ( false !== $args['selected'] && $args['selected'] !== 0 ) { |
|
146 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
145 | + if (false !== $args['selected'] && $args['selected'] !== 0) { |
|
146 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
147 | 147 | } |
148 | 148 | |
149 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
150 | - if ( ! empty( $forms ) ) { |
|
149 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
150 | + if ( ! empty($forms)) { |
|
151 | 151 | $options[0] = $args['placeholder']; |
152 | - foreach ( $forms as $form ) { |
|
153 | - $form_title = empty( $form->post_title ) |
|
154 | - ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) |
|
152 | + foreach ($forms as $form) { |
|
153 | + $form_title = empty($form->post_title) |
|
154 | + ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) |
|
155 | 155 | : $form->post_title; |
156 | 156 | |
157 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
157 | + $options[absint($form->ID)] = esc_html($form_title); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - $output = $this->select( array( |
|
161 | + $output = $this->select(array( |
|
162 | 162 | 'name' => $args['name'], |
163 | 163 | 'selected' => $args['selected'], |
164 | 164 | 'id' => $args['id'], |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | 'show_option_all' => false, |
171 | 171 | 'show_option_none' => false, |
172 | 172 | 'data' => $args['data'], |
173 | - ) ); |
|
173 | + )); |
|
174 | 174 | |
175 | 175 | return $output; |
176 | 176 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string Donors dropdown. |
189 | 189 | */ |
190 | - public function donor_dropdown( $args = array() ) { |
|
190 | + public function donor_dropdown($args = array()) { |
|
191 | 191 | |
192 | 192 | $defaults = array( |
193 | 193 | 'name' => 'donors', |
@@ -196,57 +196,57 @@ discard block |
||
196 | 196 | 'multiple' => false, |
197 | 197 | 'selected' => 0, |
198 | 198 | 'chosen' => true, |
199 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
199 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
200 | 200 | 'number' => 30, |
201 | 201 | 'data' => array( |
202 | 202 | 'search-type' => 'donor', |
203 | 203 | ), |
204 | 204 | ); |
205 | 205 | |
206 | - $args = wp_parse_args( $args, $defaults ); |
|
206 | + $args = wp_parse_args($args, $defaults); |
|
207 | 207 | |
208 | - $donors = Give()->donors->get_donors( array( |
|
208 | + $donors = Give()->donors->get_donors(array( |
|
209 | 209 | 'number' => $args['number'] |
210 | - ) ); |
|
210 | + )); |
|
211 | 211 | |
212 | 212 | $options = array(); |
213 | 213 | |
214 | - if ( $donors ) { |
|
215 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
216 | - foreach ( $donors as $donor ) { |
|
217 | - $options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
214 | + if ($donors) { |
|
215 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
216 | + foreach ($donors as $donor) { |
|
217 | + $options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')'); |
|
218 | 218 | } |
219 | 219 | } else { |
220 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
220 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( ! empty( $args['selected'] ) ) { |
|
223 | + if ( ! empty($args['selected'])) { |
|
224 | 224 | |
225 | 225 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
226 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
226 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
227 | 227 | |
228 | - $donor = new Give_Donor( $args['selected'] ); |
|
228 | + $donor = new Give_Donor($args['selected']); |
|
229 | 229 | |
230 | - if ( $donor ) { |
|
230 | + if ($donor) { |
|
231 | 231 | |
232 | - $options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
232 | + $options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')'); |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | - $output = $this->select( array( |
|
238 | + $output = $this->select(array( |
|
239 | 239 | 'name' => $args['name'], |
240 | 240 | 'selected' => $args['selected'], |
241 | 241 | 'id' => $args['id'], |
242 | - 'class' => $args['class'] . ' give-customer-select', |
|
242 | + 'class' => $args['class'].' give-customer-select', |
|
243 | 243 | 'options' => $options, |
244 | 244 | 'multiple' => $args['multiple'], |
245 | 245 | 'chosen' => $args['chosen'], |
246 | 246 | 'show_option_all' => false, |
247 | 247 | 'show_option_none' => false, |
248 | 248 | 'data' => $args['data'], |
249 | - ) ); |
|
249 | + )); |
|
250 | 250 | |
251 | 251 | return $output; |
252 | 252 | } |
@@ -265,22 +265,22 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return string Categories dropdown. |
267 | 267 | */ |
268 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
269 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
268 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
269 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
270 | 270 | |
271 | 271 | $options = array(); |
272 | 272 | |
273 | - foreach ( $categories as $category ) { |
|
274 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
273 | + foreach ($categories as $category) { |
|
274 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
275 | 275 | } |
276 | 276 | |
277 | - $output = $this->select( wp_parse_args( $args, array( |
|
277 | + $output = $this->select(wp_parse_args($args, array( |
|
278 | 278 | 'name' => $name, |
279 | 279 | 'selected' => $selected, |
280 | 280 | 'options' => $options, |
281 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
281 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
282 | 282 | 'show_option_none' => false, |
283 | - ) ) ); |
|
283 | + ))); |
|
284 | 284 | |
285 | 285 | return $output; |
286 | 286 | } |
@@ -299,22 +299,22 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return string Tags dropdown. |
301 | 301 | */ |
302 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
303 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
302 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
303 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
304 | 304 | |
305 | 305 | $options = array(); |
306 | 306 | |
307 | - foreach ( $tags as $tag ) { |
|
308 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
307 | + foreach ($tags as $tag) { |
|
308 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
309 | 309 | } |
310 | 310 | |
311 | - $output = $this->select( wp_parse_args( $args, array( |
|
311 | + $output = $this->select(wp_parse_args($args, array( |
|
312 | 312 | 'name' => $name, |
313 | 313 | 'selected' => $selected, |
314 | 314 | 'options' => $options, |
315 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
315 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
316 | 316 | 'show_option_none' => false, |
317 | - ) ) ); |
|
317 | + ))); |
|
318 | 318 | |
319 | 319 | return $output; |
320 | 320 | } |
@@ -334,25 +334,25 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return string Years dropdown. |
336 | 336 | */ |
337 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
338 | - $current = date( 'Y' ); |
|
339 | - $start_year = $current - absint( $years_before ); |
|
340 | - $end_year = $current + absint( $years_after ); |
|
341 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
337 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
338 | + $current = date('Y'); |
|
339 | + $start_year = $current - absint($years_before); |
|
340 | + $end_year = $current + absint($years_after); |
|
341 | + $selected = empty($selected) ? date('Y') : $selected; |
|
342 | 342 | $options = array(); |
343 | 343 | |
344 | - while ( $start_year <= $end_year ) { |
|
345 | - $options[ absint( $start_year ) ] = $start_year; |
|
346 | - $start_year ++; |
|
344 | + while ($start_year <= $end_year) { |
|
345 | + $options[absint($start_year)] = $start_year; |
|
346 | + $start_year++; |
|
347 | 347 | } |
348 | 348 | |
349 | - $output = $this->select( array( |
|
349 | + $output = $this->select(array( |
|
350 | 350 | 'name' => $name, |
351 | 351 | 'selected' => $selected, |
352 | 352 | 'options' => $options, |
353 | 353 | 'show_option_all' => false, |
354 | 354 | 'show_option_none' => false, |
355 | - ) ); |
|
355 | + )); |
|
356 | 356 | |
357 | 357 | return $output; |
358 | 358 | } |
@@ -370,23 +370,23 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return string Months dropdown. |
372 | 372 | */ |
373 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
373 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
374 | 374 | $month = 1; |
375 | 375 | $options = array(); |
376 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
376 | + $selected = empty($selected) ? date('n') : $selected; |
|
377 | 377 | |
378 | - while ( $month <= 12 ) { |
|
379 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
380 | - $month ++; |
|
378 | + while ($month <= 12) { |
|
379 | + $options[absint($month)] = give_month_num_to_name($month); |
|
380 | + $month++; |
|
381 | 381 | } |
382 | 382 | |
383 | - $output = $this->select( array( |
|
383 | + $output = $this->select(array( |
|
384 | 384 | 'name' => $name, |
385 | 385 | 'selected' => $selected, |
386 | 386 | 'options' => $options, |
387 | 387 | 'show_option_all' => false, |
388 | 388 | 'show_option_none' => false, |
389 | - ) ); |
|
389 | + )); |
|
390 | 390 | |
391 | 391 | return $output; |
392 | 392 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @return string The dropdown. |
405 | 405 | */ |
406 | - public function select( $args = array() ) { |
|
406 | + public function select($args = array()) { |
|
407 | 407 | $defaults = array( |
408 | 408 | 'options' => array(), |
409 | 409 | 'name' => null, |
@@ -414,74 +414,74 @@ discard block |
||
414 | 414 | 'placeholder' => null, |
415 | 415 | 'multiple' => false, |
416 | 416 | 'select_atts' => false, |
417 | - 'show_option_all' => __( 'All', 'give' ), |
|
418 | - 'show_option_none' => __( 'None', 'give' ), |
|
417 | + 'show_option_all' => __('All', 'give'), |
|
418 | + 'show_option_none' => __('None', 'give'), |
|
419 | 419 | 'data' => array(), |
420 | 420 | 'readonly' => false, |
421 | 421 | 'disabled' => false, |
422 | 422 | ); |
423 | 423 | |
424 | - $args = wp_parse_args( $args, $defaults ); |
|
424 | + $args = wp_parse_args($args, $defaults); |
|
425 | 425 | |
426 | 426 | $data_elements = ''; |
427 | - foreach ( $args['data'] as $key => $value ) { |
|
428 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
427 | + foreach ($args['data'] as $key => $value) { |
|
428 | + $data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"'; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | $multiple = ''; |
432 | - if ( $args['multiple'] ) { |
|
432 | + if ($args['multiple']) { |
|
433 | 433 | $multiple = 'MULTIPLE'; |
434 | 434 | } |
435 | 435 | |
436 | - if ( $args['chosen'] ) { |
|
436 | + if ($args['chosen']) { |
|
437 | 437 | $args['class'] .= ' give-select-chosen'; |
438 | 438 | } |
439 | 439 | |
440 | 440 | $placeholder = ''; |
441 | - if ( $args['placeholder'] ) { |
|
441 | + if ($args['placeholder']) { |
|
442 | 442 | $placeholder = $args['placeholder']; |
443 | 443 | } |
444 | 444 | |
445 | 445 | $output = sprintf( |
446 | 446 | '<select name="%1$s" id="%2$s" autocomplete="address-level4" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>', |
447 | - esc_attr( $args['name'] ), |
|
448 | - esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ), |
|
449 | - esc_attr( $args['class'] ), |
|
447 | + esc_attr($args['name']), |
|
448 | + esc_attr(sanitize_key(str_replace('-', '_', $args['id']))), |
|
449 | + esc_attr($args['class']), |
|
450 | 450 | $multiple, |
451 | 451 | $args['select_atts'], |
452 | 452 | $placeholder, |
453 | 453 | $data_elements |
454 | 454 | ); |
455 | 455 | |
456 | - if ( $args['show_option_all'] ) { |
|
457 | - if ( $args['multiple'] ) { |
|
458 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
456 | + if ($args['show_option_all']) { |
|
457 | + if ($args['multiple']) { |
|
458 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
459 | 459 | } else { |
460 | - $selected = selected( $args['selected'], 0, false ); |
|
460 | + $selected = selected($args['selected'], 0, false); |
|
461 | 461 | } |
462 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
462 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
463 | 463 | } |
464 | 464 | |
465 | - if ( ! empty( $args['options'] ) ) { |
|
465 | + if ( ! empty($args['options'])) { |
|
466 | 466 | |
467 | - if ( $args['show_option_none'] ) { |
|
468 | - if ( $args['multiple'] ) { |
|
469 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
467 | + if ($args['show_option_none']) { |
|
468 | + if ($args['multiple']) { |
|
469 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
470 | 470 | } else { |
471 | - $selected = selected( $args['selected'], - 1, false ); |
|
471 | + $selected = selected($args['selected'], - 1, false); |
|
472 | 472 | } |
473 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
473 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
474 | 474 | } |
475 | 475 | |
476 | - foreach ( $args['options'] as $key => $option ) { |
|
476 | + foreach ($args['options'] as $key => $option) { |
|
477 | 477 | |
478 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
479 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
478 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
479 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
480 | 480 | } else { |
481 | - $selected = selected( $args['selected'], $key, false ); |
|
481 | + $selected = selected($args['selected'], $key, false); |
|
482 | 482 | } |
483 | 483 | |
484 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
484 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return string The checkbox. |
504 | 504 | */ |
505 | - public function checkbox( $args = array() ) { |
|
505 | + public function checkbox($args = array()) { |
|
506 | 506 | $defaults = array( |
507 | 507 | 'name' => null, |
508 | 508 | 'current' => null, |
@@ -513,16 +513,16 @@ discard block |
||
513 | 513 | ), |
514 | 514 | ); |
515 | 515 | |
516 | - $args = wp_parse_args( $args, $defaults ); |
|
516 | + $args = wp_parse_args($args, $defaults); |
|
517 | 517 | |
518 | 518 | $options = ''; |
519 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
519 | + if ( ! empty($args['options']['disabled'])) { |
|
520 | 520 | $options .= ' disabled="disabled"'; |
521 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
521 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
522 | 522 | $options .= ' readonly'; |
523 | 523 | } |
524 | 524 | |
525 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
525 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
526 | 526 | |
527 | 527 | return $output; |
528 | 528 | } |
@@ -539,22 +539,22 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return string The text field. |
541 | 541 | */ |
542 | - public function text( $args = array() ) { |
|
542 | + public function text($args = array()) { |
|
543 | 543 | // Backwards compatibility. |
544 | - if ( func_num_args() > 1 ) { |
|
544 | + if (func_num_args() > 1) { |
|
545 | 545 | $args = func_get_args(); |
546 | 546 | |
547 | 547 | $name = $args[0]; |
548 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
549 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
550 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
548 | + $value = isset($args[1]) ? $args[1] : ''; |
|
549 | + $label = isset($args[2]) ? $args[2] : ''; |
|
550 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | $defaults = array( |
554 | - 'name' => isset( $name ) ? $name : 'text', |
|
555 | - 'value' => isset( $value ) ? $value : null, |
|
556 | - 'label' => isset( $label ) ? $label : null, |
|
557 | - 'desc' => isset( $desc ) ? $desc : null, |
|
554 | + 'name' => isset($name) ? $name : 'text', |
|
555 | + 'value' => isset($value) ? $value : null, |
|
556 | + 'label' => isset($label) ? $label : null, |
|
557 | + 'desc' => isset($desc) ? $desc : null, |
|
558 | 558 | 'placeholder' => '', |
559 | 559 | 'class' => 'regular-text', |
560 | 560 | 'disabled' => false, |
@@ -562,29 +562,29 @@ discard block |
||
562 | 562 | 'data' => false, |
563 | 563 | ); |
564 | 564 | |
565 | - $args = wp_parse_args( $args, $defaults ); |
|
565 | + $args = wp_parse_args($args, $defaults); |
|
566 | 566 | |
567 | 567 | $disabled = ''; |
568 | - if ( $args['disabled'] ) { |
|
568 | + if ($args['disabled']) { |
|
569 | 569 | $disabled = ' disabled="disabled"'; |
570 | 570 | } |
571 | 571 | |
572 | 572 | $data = ''; |
573 | - if ( ! empty( $args['data'] ) ) { |
|
574 | - foreach ( $args['data'] as $key => $value ) { |
|
575 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
573 | + if ( ! empty($args['data'])) { |
|
574 | + foreach ($args['data'] as $key => $value) { |
|
575 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
576 | 576 | } |
577 | 577 | } |
578 | 578 | |
579 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
579 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
580 | 580 | |
581 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
581 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
582 | 582 | |
583 | - if ( ! empty( $args['desc'] ) ) { |
|
584 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
583 | + if ( ! empty($args['desc'])) { |
|
584 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
585 | 585 | } |
586 | 586 | |
587 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
587 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
588 | 588 | |
589 | 589 | $output .= '</span>'; |
590 | 590 | |
@@ -603,15 +603,15 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @return string The date picker. |
605 | 605 | */ |
606 | - public function date_field( $args = array() ) { |
|
606 | + public function date_field($args = array()) { |
|
607 | 607 | |
608 | - if ( empty( $args['class'] ) ) { |
|
608 | + if (empty($args['class'])) { |
|
609 | 609 | $args['class'] = 'give_datepicker'; |
610 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
610 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
611 | 611 | $args['class'] .= ' give_datepicker'; |
612 | 612 | } |
613 | 613 | |
614 | - return $this->text( $args ); |
|
614 | + return $this->text($args); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * |
627 | 627 | * @return string The textarea. |
628 | 628 | */ |
629 | - public function textarea( $args = array() ) { |
|
629 | + public function textarea($args = array()) { |
|
630 | 630 | $defaults = array( |
631 | 631 | 'name' => 'textarea', |
632 | 632 | 'value' => null, |
@@ -636,21 +636,21 @@ discard block |
||
636 | 636 | 'disabled' => false, |
637 | 637 | ); |
638 | 638 | |
639 | - $args = wp_parse_args( $args, $defaults ); |
|
639 | + $args = wp_parse_args($args, $defaults); |
|
640 | 640 | |
641 | 641 | $disabled = ''; |
642 | - if ( $args['disabled'] ) { |
|
642 | + if ($args['disabled']) { |
|
643 | 643 | $disabled = ' disabled="disabled"'; |
644 | 644 | } |
645 | 645 | |
646 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
646 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
647 | 647 | |
648 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
648 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
649 | 649 | |
650 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
650 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
651 | 651 | |
652 | - if ( ! empty( $args['desc'] ) ) { |
|
653 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
652 | + if ( ! empty($args['desc'])) { |
|
653 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | $output .= '</span>'; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return string The text field with ajax search. |
672 | 672 | */ |
673 | - public function ajax_user_search( $args = array() ) { |
|
673 | + public function ajax_user_search($args = array()) { |
|
674 | 674 | |
675 | 675 | $defaults = array( |
676 | 676 | 'name' => 'users', |
@@ -681,13 +681,13 @@ discard block |
||
681 | 681 | 'chosen' => true, |
682 | 682 | 'number' => 30, |
683 | 683 | 'select_atts' => '', |
684 | - 'placeholder' => __( 'Select a user', 'give' ), |
|
684 | + 'placeholder' => __('Select a user', 'give'), |
|
685 | 685 | 'data' => array( |
686 | 686 | 'search-type' => 'user', |
687 | 687 | ), |
688 | 688 | ); |
689 | 689 | |
690 | - $args = wp_parse_args( $args, $defaults ); |
|
690 | + $args = wp_parse_args($args, $defaults); |
|
691 | 691 | |
692 | 692 | // Set initial args. |
693 | 693 | $get_users_args = array( |
@@ -696,31 +696,31 @@ discard block |
||
696 | 696 | |
697 | 697 | // Ensure selected user is not included in initial query. |
698 | 698 | // This is because sites with many users, it's not a guarantee the selected user will be returned. |
699 | - if ( ! empty( $args['selected'] ) ) { |
|
699 | + if ( ! empty($args['selected'])) { |
|
700 | 700 | $get_users_args['exclude'] = $args['selected']; |
701 | 701 | } |
702 | 702 | |
703 | 703 | // Initial users array. |
704 | - $users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); |
|
704 | + $users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args); |
|
705 | 705 | |
706 | 706 | // Now add the selected user to the $users array if the arg is present. |
707 | - if ( ! empty( $args['selected'] ) ) { |
|
708 | - $selected_user = apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );; |
|
709 | - $users = array_merge( $users, $selected_user ); |
|
707 | + if ( ! empty($args['selected'])) { |
|
708 | + $selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ; |
|
709 | + $users = array_merge($users, $selected_user); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | $options = array(); |
713 | 713 | |
714 | - if ( $users ) { |
|
714 | + if ($users) { |
|
715 | 715 | $options[0] = $args['placeholder']; |
716 | - foreach ( $users as $user ) { |
|
717 | - $options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); |
|
716 | + foreach ($users as $user) { |
|
717 | + $options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')'); |
|
718 | 718 | } |
719 | 719 | } else { |
720 | - $options[0] = __( 'No users found.', 'give' ); |
|
720 | + $options[0] = __('No users found.', 'give'); |
|
721 | 721 | } |
722 | 722 | |
723 | - $output = $this->select( array( |
|
723 | + $output = $this->select(array( |
|
724 | 724 | 'name' => $args['name'], |
725 | 725 | 'selected' => $args['selected'], |
726 | 726 | 'id' => $args['id'], |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | 'show_option_all' => false, |
734 | 734 | 'show_option_none' => false, |
735 | 735 | 'data' => $args['data'], |
736 | - ) ); |
|
736 | + )); |
|
737 | 737 | |
738 | 738 | return $output; |
739 | 739 |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Exit if accessed directly. |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | // Add give command. |
15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
16 | 16 | |
17 | 17 | |
18 | 18 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @subcommand logo |
78 | 78 | */ |
79 | - public function ascii( $args, $assoc_args ) { |
|
80 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/dist/images/give-ascii-logo.txt' ) ); |
|
79 | + public function ascii($args, $assoc_args) { |
|
80 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/dist/images/give-ascii-logo.txt')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -102,54 +102,54 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @subcommand details |
104 | 104 | */ |
105 | - public function details( $args, $assoc_args ) { |
|
105 | + public function details($args, $assoc_args) { |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Plugin Information |
109 | 109 | */ |
110 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
110 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * General Information. |
114 | 114 | */ |
115 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
115 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
116 | 116 | |
117 | - $success_page = give_get_option( 'success_page' ); |
|
118 | - $failure_page = give_get_option( 'failure_page' ); |
|
119 | - $history_page = give_get_option( 'history_page' ); |
|
117 | + $success_page = give_get_option('success_page'); |
|
118 | + $failure_page = give_get_option('failure_page'); |
|
119 | + $history_page = give_get_option('history_page'); |
|
120 | 120 | |
121 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
122 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
123 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
124 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
121 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
122 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
123 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
124 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Currency Information. |
128 | 128 | */ |
129 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
129 | + $default_gateway = give_get_option('default_gateway'); |
|
130 | 130 | |
131 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
131 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
132 | 132 | |
133 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
134 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
135 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
136 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
137 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
138 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
139 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
133 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
134 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
135 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
136 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
137 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
138 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
139 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
140 | 140 | |
141 | 141 | // Payment gateways Information. |
142 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
143 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
142 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
143 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
144 | 144 | |
145 | - if ( ! empty( $gateways ) ) { |
|
145 | + if ( ! empty($gateways)) { |
|
146 | 146 | self::$counter = 1; |
147 | - foreach ( $gateways as $gateway ) { |
|
148 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
149 | - self::$counter ++; |
|
147 | + foreach ($gateways as $gateway) { |
|
148 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
149 | + self::$counter++; |
|
150 | 150 | } |
151 | 151 | } else { |
152 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
152 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @subcommand forms |
183 | 183 | */ |
184 | - public function forms( $args, $assoc_args ) { |
|
184 | + public function forms($args, $assoc_args) { |
|
185 | 185 | global $wp_query; |
186 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
187 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
186 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
187 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
188 | 188 | $start = time(); |
189 | 189 | |
190 | 190 | // Cache previous number query var. |
191 | 191 | $is_set_number = $cache_per_page = false; |
192 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
192 | + if (isset($wp_query->query_vars['number'])) { |
|
193 | 193 | $cache_per_page = $wp_query->query_vars['number']; |
194 | 194 | $is_set_number = true; |
195 | 195 | } |
@@ -198,22 +198,22 @@ discard block |
||
198 | 198 | $wp_query->query_vars['number'] = $number; |
199 | 199 | |
200 | 200 | // Get forms. |
201 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
201 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
202 | 202 | |
203 | 203 | // Reset number query var. |
204 | - if ( $is_set_number ) { |
|
204 | + if ($is_set_number) { |
|
205 | 205 | $wp_query->query_vars['number'] = $cache_per_page; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Bailout. |
209 | - if ( array_key_exists( 'error', $forms ) ) { |
|
209 | + if (array_key_exists('error', $forms)) { |
|
210 | 210 | |
211 | - WP_CLI::warning( $forms['error'] ); |
|
211 | + WP_CLI::warning($forms['error']); |
|
212 | 212 | |
213 | 213 | return; |
214 | - } elseif ( empty( $forms['forms'] ) ) { |
|
214 | + } elseif (empty($forms['forms'])) { |
|
215 | 215 | |
216 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
216 | + WP_CLI::error(__('No forms found.', 'give')); |
|
217 | 217 | |
218 | 218 | return; |
219 | 219 | } |
@@ -221,25 +221,25 @@ discard block |
||
221 | 221 | // Param to check if form typeis already showed or not. |
222 | 222 | $is_show_form_type = false; |
223 | 223 | |
224 | - if ( 1 === count( $forms ) && $form_id ) { |
|
224 | + if (1 === count($forms) && $form_id) { |
|
225 | 225 | // Show single form. |
226 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
227 | - switch ( $key ) { |
|
226 | + foreach ($forms['forms'][0] as $key => $info) { |
|
227 | + switch ($key) { |
|
228 | 228 | case 'stats': |
229 | - $this->color_main_heading( ucfirst( $key ) ); |
|
229 | + $this->color_main_heading(ucfirst($key)); |
|
230 | 230 | |
231 | - foreach ( $info as $heading => $data ) { |
|
232 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
233 | - switch ( $heading ) { |
|
231 | + foreach ($info as $heading => $data) { |
|
232 | + $this->color_sub_heading(ucfirst($heading)); |
|
233 | + switch ($heading) { |
|
234 | 234 | default: |
235 | - foreach ( $data as $subheading => $subdata ) { |
|
235 | + foreach ($data as $subheading => $subdata) { |
|
236 | 236 | |
237 | - switch ( $subheading ) { |
|
237 | + switch ($subheading) { |
|
238 | 238 | case 'earnings': |
239 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
239 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
240 | 240 | break; |
241 | 241 | default: |
242 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
242 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
@@ -249,26 +249,26 @@ discard block |
||
249 | 249 | case 'pricing': |
250 | 250 | case 'info': |
251 | 251 | default: |
252 | - $this->color_main_heading( ucfirst( $key ) ); |
|
252 | + $this->color_main_heading(ucfirst($key)); |
|
253 | 253 | |
254 | 254 | // Show form type. |
255 | - if ( ! $is_show_form_type ) { |
|
256 | - $form = new Give_Donate_Form( $form_id ); |
|
255 | + if ( ! $is_show_form_type) { |
|
256 | + $form = new Give_Donate_Form($form_id); |
|
257 | 257 | $is_show_form_type = true; |
258 | 258 | |
259 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
259 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
260 | 260 | } |
261 | 261 | |
262 | - foreach ( $info as $heading => $data ) { |
|
262 | + foreach ($info as $heading => $data) { |
|
263 | 263 | |
264 | - switch ( $heading ) { |
|
264 | + switch ($heading) { |
|
265 | 265 | case 'id': |
266 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
266 | + WP_CLI::log($this->color_message($heading, $data)); |
|
267 | 267 | break; |
268 | 268 | |
269 | 269 | default: |
270 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
271 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
270 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
271 | + WP_CLI::log($this->color_message($heading, $data)); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | }// End switch(). |
@@ -279,37 +279,37 @@ discard block |
||
279 | 279 | $is_table_first_row_set = false; |
280 | 280 | $table_column_count = 0; |
281 | 281 | |
282 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
282 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
283 | 283 | |
284 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
284 | + foreach ($forms['forms'] as $index => $form_data) { |
|
285 | 285 | |
286 | 286 | // Default table data. |
287 | 287 | $table_first_row = array(); |
288 | 288 | $table_row = array(); |
289 | 289 | |
290 | - foreach ( $form_data['info'] as $key => $form ) { |
|
290 | + foreach ($form_data['info'] as $key => $form) { |
|
291 | 291 | |
292 | 292 | // Do not show thumbnail, content and link in table. |
293 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
293 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
294 | 294 | continue; |
295 | 295 | } |
296 | 296 | |
297 | - if ( ! $is_table_first_row_set ) { |
|
297 | + if ( ! $is_table_first_row_set) { |
|
298 | 298 | $table_first_row[] = $key; |
299 | 299 | } |
300 | 300 | |
301 | 301 | $table_row[] = $form; |
302 | 302 | |
303 | - if ( 'status' === $key ) { |
|
303 | + if ('status' === $key) { |
|
304 | 304 | // First array item will be an form id in our case. |
305 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
305 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
306 | 306 | |
307 | 307 | $table_row[] = $form->get_type(); |
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Set table first row. |
312 | - if ( ! $is_table_first_row_set ) { |
|
312 | + if ( ! $is_table_first_row_set) { |
|
313 | 313 | |
314 | 314 | // Add extra column to table. |
315 | 315 | $table_first_row[] = 'type'; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $table_data[] = $table_row; |
323 | 323 | }// End foreach(). |
324 | 324 | |
325 | - $this->display_table( $table_data ); |
|
325 | + $this->display_table($table_data); |
|
326 | 326 | }// End if(). |
327 | 327 | } |
328 | 328 | |
@@ -375,59 +375,59 @@ discard block |
||
375 | 375 | * |
376 | 376 | * @subcommand donors |
377 | 377 | */ |
378 | - public function donors( $args, $assoc_args ) { |
|
378 | + public function donors($args, $assoc_args) { |
|
379 | 379 | global $wp_query; |
380 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
381 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
382 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
383 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
384 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
385 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
386 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
380 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
381 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
382 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
383 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
384 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
385 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
386 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
387 | 387 | $start = time(); |
388 | 388 | |
389 | - if ( $create ) { |
|
390 | - if ( 80 < $create ) { |
|
391 | - WP_CLI::warning( 'Currently we can only generate maximum 80 donors.', 'give' ); |
|
389 | + if ($create) { |
|
390 | + if (80 < $create) { |
|
391 | + WP_CLI::warning('Currently we can only generate maximum 80 donors.', 'give'); |
|
392 | 392 | $create = 80; |
393 | 393 | } |
394 | 394 | |
395 | 395 | $number = 1; |
396 | 396 | |
397 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
398 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
397 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
398 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
399 | 399 | |
400 | 400 | return; |
401 | 401 | } |
402 | 402 | |
403 | 403 | // Create one or more donors. |
404 | - if ( ! $email ) { |
|
404 | + if ( ! $email) { |
|
405 | 405 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
406 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
406 | + $number = is_numeric($create) ? absint($create) : 1; |
|
407 | 407 | } |
408 | 408 | |
409 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
409 | + for ($i = 0; $i < $number; $i++) { |
|
410 | 410 | $name = $name ? $name : $this->get_random_name(); |
411 | - $email = $email ? $email : $this->get_random_email( $name ); |
|
411 | + $email = $email ? $email : $this->get_random_email($name); |
|
412 | 412 | |
413 | 413 | $args = array( |
414 | 414 | 'email' => $email, |
415 | 415 | 'name' => $name, |
416 | 416 | ); |
417 | 417 | |
418 | - $donor_id = Give()->donors->add( $args ); |
|
418 | + $donor_id = Give()->donors->add($args); |
|
419 | 419 | |
420 | - if ( $donor_id ) { |
|
421 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) ); |
|
420 | + if ($donor_id) { |
|
421 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id))); |
|
422 | 422 | } else { |
423 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
423 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | // Reset email and name to false so it is generated on the next loop (if creating donors). |
427 | 427 | $email = $name = false; |
428 | 428 | } |
429 | 429 | |
430 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
430 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
431 | 431 | |
432 | 432 | } else { |
433 | 433 | // Counter. |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | // Cache previous number query var. |
443 | 443 | $is_set_number = $cache_per_page = false; |
444 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
444 | + if (isset($wp_query->query_vars['number'])) { |
|
445 | 445 | $cache_per_page = $wp_query->query_vars['number']; |
446 | 446 | $is_set_number = true; |
447 | 447 | } |
@@ -450,24 +450,24 @@ discard block |
||
450 | 450 | $wp_query->query_vars['number'] = $number; |
451 | 451 | |
452 | 452 | // Get donors. |
453 | - if ( $form_id ) { |
|
453 | + if ($form_id) { |
|
454 | 454 | // @TODO: Allow user to get a list of donors by donation status. |
455 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
455 | + $donors = $this->get_donors_by_form_id($form_id); |
|
456 | 456 | } else { |
457 | - $donors = $this->api->get_donors( $search ); |
|
457 | + $donors = $this->api->get_donors($search); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // Reset number query var. |
461 | - if ( $is_set_number ) { |
|
461 | + if ($is_set_number) { |
|
462 | 462 | $wp_query->query_vars['number'] = $cache_per_page; |
463 | 463 | } |
464 | 464 | |
465 | - if ( isset( $donors['error'] ) ) { |
|
466 | - WP_CLI::error( $donors['error'] ); |
|
465 | + if (isset($donors['error'])) { |
|
466 | + WP_CLI::error($donors['error']); |
|
467 | 467 | } |
468 | 468 | |
469 | - if ( empty( $donors ) ) { |
|
470 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
469 | + if (empty($donors)) { |
|
470 | + WP_CLI::error(__('No donors found.', 'give')); |
|
471 | 471 | |
472 | 472 | return; |
473 | 473 | } |
@@ -475,24 +475,24 @@ discard block |
||
475 | 475 | $table_data = array(); |
476 | 476 | $is_table_first_row_set = false; |
477 | 477 | |
478 | - foreach ( $donors['donors'] as $donor_data ) { |
|
478 | + foreach ($donors['donors'] as $donor_data) { |
|
479 | 479 | // Set default table row data. |
480 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
481 | - $table_row = array( self::$counter ); |
|
480 | + $table_first_row = array(__('s_no', 'give')); |
|
481 | + $table_row = array(self::$counter); |
|
482 | 482 | |
483 | - foreach ( $donor_data as $key => $donor ) { |
|
484 | - switch ( $key ) { |
|
483 | + foreach ($donor_data as $key => $donor) { |
|
484 | + switch ($key) { |
|
485 | 485 | case 'stats': |
486 | - foreach ( $donor as $heading => $data ) { |
|
486 | + foreach ($donor as $heading => $data) { |
|
487 | 487 | |
488 | 488 | // Get first row. |
489 | - if ( ! $is_table_first_row_set ) { |
|
489 | + if ( ! $is_table_first_row_set) { |
|
490 | 490 | $table_first_row[] = $heading; |
491 | 491 | } |
492 | 492 | |
493 | - switch ( $heading ) { |
|
493 | + switch ($heading) { |
|
494 | 494 | case 'total_spent': |
495 | - $table_row[] = give_currency_filter( $data ); |
|
495 | + $table_row[] = give_currency_filter($data); |
|
496 | 496 | break; |
497 | 497 | |
498 | 498 | default: |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | |
504 | 504 | case 'info': |
505 | 505 | default: |
506 | - foreach ( $donor as $heading => $data ) { |
|
506 | + foreach ($donor as $heading => $data) { |
|
507 | 507 | |
508 | 508 | // Get first row. |
509 | - if ( ! $is_table_first_row_set ) { |
|
509 | + if ( ! $is_table_first_row_set) { |
|
510 | 510 | $table_first_row[] = $heading; |
511 | 511 | } |
512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | // Add first row data to table data. |
519 | - if ( ! $is_table_first_row_set ) { |
|
519 | + if ( ! $is_table_first_row_set) { |
|
520 | 520 | $table_data[] = $table_first_row; |
521 | 521 | $is_table_first_row_set = true; |
522 | 522 | } |
@@ -525,44 +525,44 @@ discard block |
||
525 | 525 | $table_data[] = $table_row; |
526 | 526 | |
527 | 527 | // Increase counter. |
528 | - self::$counter ++; |
|
528 | + self::$counter++; |
|
529 | 529 | }// End foreach(). |
530 | 530 | |
531 | - switch ( $format ) { |
|
531 | + switch ($format) { |
|
532 | 532 | case 'json': |
533 | 533 | $table_column_name = $table_data[0]; |
534 | - unset( $table_data[0] ); |
|
534 | + unset($table_data[0]); |
|
535 | 535 | |
536 | 536 | $new_table_data = array(); |
537 | - foreach ( $table_data as $index => $data ) { |
|
538 | - foreach ( $data as $key => $value ) { |
|
539 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
537 | + foreach ($table_data as $index => $data) { |
|
538 | + foreach ($data as $key => $value) { |
|
539 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
543 | + WP_CLI::log(json_encode($new_table_data)); |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'csv': |
547 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
548 | - $fp = fopen( $file_path, 'w' ); |
|
547 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
548 | + $fp = fopen($file_path, 'w'); |
|
549 | 549 | |
550 | - if ( is_writable( $file_path ) ) { |
|
551 | - foreach ( $table_data as $fields ) { |
|
552 | - fputcsv( $fp, $fields ); |
|
550 | + if (is_writable($file_path)) { |
|
551 | + foreach ($table_data as $fields) { |
|
552 | + fputcsv($fp, $fields); |
|
553 | 553 | } |
554 | 554 | |
555 | - fclose( $fp ); |
|
555 | + fclose($fp); |
|
556 | 556 | |
557 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
557 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
558 | 558 | } else { |
559 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
559 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | break; |
563 | 563 | |
564 | 564 | default: |
565 | - $this->display_table( $table_data ); |
|
565 | + $this->display_table($table_data); |
|
566 | 566 | }// End switch(). |
567 | 567 | }// End if(). |
568 | 568 | } |
@@ -592,13 +592,13 @@ discard block |
||
592 | 592 | * |
593 | 593 | * @subcommand donations |
594 | 594 | */ |
595 | - public function donations( $args, $assoc_args ) { |
|
595 | + public function donations($args, $assoc_args) { |
|
596 | 596 | global $wp_query; |
597 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
597 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
598 | 598 | |
599 | 599 | // Cache previous number query var. |
600 | 600 | $is_set_number = $cache_per_page = false; |
601 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
601 | + if (isset($wp_query->query_vars['number'])) { |
|
602 | 602 | $cache_per_page = $wp_query->query_vars['number']; |
603 | 603 | $is_set_number = true; |
604 | 604 | } |
@@ -610,46 +610,46 @@ discard block |
||
610 | 610 | $donations = $this->api->get_recent_donations(); |
611 | 611 | |
612 | 612 | // Reset number query var. |
613 | - if ( $is_set_number ) { |
|
613 | + if ($is_set_number) { |
|
614 | 614 | $wp_query->query_vars['number'] = $cache_per_page; |
615 | 615 | } |
616 | 616 | |
617 | - if ( empty( $donations ) ) { |
|
618 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
617 | + if (empty($donations)) { |
|
618 | + WP_CLI::error(__('No donations found.', 'give')); |
|
619 | 619 | |
620 | 620 | return; |
621 | 621 | } |
622 | 622 | |
623 | 623 | self::$counter = 1; |
624 | 624 | |
625 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
626 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
627 | - self::$counter ++; |
|
625 | + foreach ($donations['donations'] as $key => $donation) { |
|
626 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
627 | + self::$counter++; |
|
628 | 628 | |
629 | - foreach ( $donation as $column => $data ) { |
|
629 | + foreach ($donation as $column => $data) { |
|
630 | 630 | |
631 | - if ( is_array( $data ) ) { |
|
632 | - $this->color_sub_heading( $column ); |
|
633 | - foreach ( $data as $subcolumn => $subdata ) { |
|
631 | + if (is_array($data)) { |
|
632 | + $this->color_sub_heading($column); |
|
633 | + foreach ($data as $subcolumn => $subdata) { |
|
634 | 634 | |
635 | 635 | // Decode html codes. |
636 | - switch ( $subcolumn ) { |
|
636 | + switch ($subcolumn) { |
|
637 | 637 | case 'name': |
638 | - $subdata = html_entity_decode( $subdata ); |
|
638 | + $subdata = html_entity_decode($subdata); |
|
639 | 639 | break; |
640 | 640 | } |
641 | 641 | |
642 | 642 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
643 | - if ( is_array( $subdata ) ) { |
|
643 | + if (is_array($subdata)) { |
|
644 | 644 | continue; |
645 | 645 | } |
646 | 646 | |
647 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
647 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
648 | 648 | } |
649 | 649 | continue; |
650 | 650 | } |
651 | 651 | |
652 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
652 | + WP_CLI::log($this->color_message($column, $data)); |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | } |
@@ -689,27 +689,27 @@ discard block |
||
689 | 689 | * |
690 | 690 | * @return void |
691 | 691 | */ |
692 | - public function report( $args, $assoc_args ) { |
|
692 | + public function report($args, $assoc_args) { |
|
693 | 693 | $stats = new Give_Payment_Stats(); |
694 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
695 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
696 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
697 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
694 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
695 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
696 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
697 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
698 | 698 | |
699 | - if ( ! empty( $date ) ) { |
|
699 | + if ( ! empty($date)) { |
|
700 | 700 | $start_date = $date; |
701 | 701 | $end_date = false; |
702 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
702 | + } elseif (empty($date) && empty($start_date)) { |
|
703 | 703 | $start_date = 'this_month'; |
704 | 704 | $end_date = false; |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Get stats. |
708 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
709 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
708 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
709 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
710 | 710 | |
711 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings, array( 'decode_currency' => true ) ) ) ); |
|
712 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
711 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings, array('decode_currency' => true)))); |
|
712 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | |
@@ -736,27 +736,27 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @subcommand cache |
738 | 738 | */ |
739 | - public function cache( $args, $assoc_args ) { |
|
740 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
739 | + public function cache($args, $assoc_args) { |
|
740 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
741 | 741 | |
742 | 742 | // Bailout. |
743 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
744 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
743 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
744 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
745 | 745 | |
746 | 746 | return; |
747 | 747 | } |
748 | 748 | |
749 | - switch ( $action ) { |
|
749 | + switch ($action) { |
|
750 | 750 | case 'delete': |
751 | 751 | // Reset counter. |
752 | 752 | self::$counter = 1; |
753 | 753 | |
754 | - if ( $this->delete_stats_transients() ) { |
|
754 | + if ($this->delete_stats_transients()) { |
|
755 | 755 | // Report .eading. |
756 | - WP_CLI::success( 'Give cache deleted.' ); |
|
756 | + WP_CLI::success('Give cache deleted.'); |
|
757 | 757 | } else { |
758 | 758 | // Report .eading. |
759 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
759 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
760 | 760 | } |
761 | 761 | break; |
762 | 762 | } |
@@ -785,27 +785,27 @@ discard block |
||
785 | 785 | ARRAY_A |
786 | 786 | ); |
787 | 787 | |
788 | - if ( ! empty( $stat_option_names ) ) { |
|
788 | + if ( ! empty($stat_option_names)) { |
|
789 | 789 | |
790 | - foreach ( $stat_option_names as $option_name ) { |
|
790 | + foreach ($stat_option_names as $option_name) { |
|
791 | 791 | $error = false; |
792 | 792 | $option_name = $option_name['option_name']; |
793 | 793 | |
794 | - switch ( true ) { |
|
795 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
796 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
797 | - $error = delete_transient( $option_name ); |
|
794 | + switch (true) { |
|
795 | + case (false !== strpos($option_name, 'transient')): |
|
796 | + $option_name = str_replace('_transient_', '', $option_name); |
|
797 | + $error = delete_transient($option_name); |
|
798 | 798 | break; |
799 | 799 | |
800 | 800 | default: |
801 | - $error = delete_option( $option_name ); |
|
801 | + $error = delete_option($option_name); |
|
802 | 802 | } |
803 | 803 | |
804 | - if ( $error ) { |
|
805 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
806 | - self::$counter ++; |
|
804 | + if ($error) { |
|
805 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
806 | + self::$counter++; |
|
807 | 807 | } else { |
808 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
808 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 | |
@@ -826,13 +826,13 @@ discard block |
||
826 | 826 | * |
827 | 827 | * @return string |
828 | 828 | */ |
829 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
829 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
830 | 830 | // Add colon. |
831 | - if ( $colon ) { |
|
832 | - $heading = $heading . ': '; |
|
831 | + if ($colon) { |
|
832 | + $heading = $heading.': '; |
|
833 | 833 | } |
834 | 834 | |
835 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
835 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | * |
848 | 848 | * @return void |
849 | 849 | */ |
850 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
851 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
850 | + private function color_main_heading($heading, $color = 'g') { |
|
851 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | * |
862 | 862 | * @return void |
863 | 863 | */ |
864 | - private function color_sub_heading( $subheading ) { |
|
865 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
864 | + private function color_sub_heading($subheading) { |
|
865 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -876,17 +876,17 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return void |
878 | 878 | */ |
879 | - private function display_table( $data ) { |
|
879 | + private function display_table($data) { |
|
880 | 880 | $table = new \cli\Table(); |
881 | 881 | |
882 | 882 | // Set table header. |
883 | - $table->setHeaders( $data[0] ); |
|
883 | + $table->setHeaders($data[0]); |
|
884 | 884 | |
885 | 885 | // Remove table header. |
886 | - unset( $data[0] ); |
|
886 | + unset($data[0]); |
|
887 | 887 | |
888 | 888 | // Set table data. |
889 | - $table->setRows( $data ); |
|
889 | + $table->setRows($data); |
|
890 | 890 | |
891 | 891 | // Display table. |
892 | 892 | $table->display(); |
@@ -903,14 +903,14 @@ discard block |
||
903 | 903 | * @return array |
904 | 904 | */ |
905 | 905 | |
906 | - private function get_donors_by_form_id( $form_id ) { |
|
906 | + private function get_donors_by_form_id($form_id) { |
|
907 | 907 | $donors = array(); |
908 | 908 | |
909 | 909 | $donations = new Give_Payments_Query( |
910 | 910 | array( |
911 | - 'give_forms' => array( $form_id ), |
|
912 | - 'number' => - 1, |
|
913 | - 'status' => array( 'publish' ), |
|
911 | + 'give_forms' => array($form_id), |
|
912 | + 'number' => -1, |
|
913 | + 'status' => array('publish'), |
|
914 | 914 | ) |
915 | 915 | ); |
916 | 916 | |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $skip_donors = array(); |
919 | 919 | |
920 | 920 | /* @var Give_Payment|object $donation Payment object. */ |
921 | - foreach ( $donations as $donation ) { |
|
921 | + foreach ($donations as $donation) { |
|
922 | 922 | |
923 | - if ( in_array( $donation->customer_id, $skip_donors, true ) ) { |
|
923 | + if (in_array($donation->customer_id, $skip_donors, true)) { |
|
924 | 924 | continue; |
925 | 925 | } |
926 | 926 | |
927 | - if ( ! empty( $donors ) ) { |
|
928 | - $donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) ); |
|
927 | + if ( ! empty($donors)) { |
|
928 | + $donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id))); |
|
929 | 929 | } else { |
930 | - $donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) ); |
|
930 | + $donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id)); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | $skip_donors[] = $donation->customer_id; |
@@ -972,15 +972,15 @@ discard block |
||
972 | 972 | ); |
973 | 973 | |
974 | 974 | // Generate a random forename. |
975 | - $random_name = $names[ mt_rand( 0, sizeof( $names ) - 1 ) ]; |
|
975 | + $random_name = $names[mt_rand(0, sizeof($names) - 1)]; |
|
976 | 976 | |
977 | 977 | // Generate a random surname. |
978 | - $random_surname = $surnames[ mt_rand( 0, sizeof( $surnames ) - 1 ) ]; |
|
978 | + $random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)]; |
|
979 | 979 | |
980 | 980 | // Generate name. |
981 | 981 | $name = "{$random_name} {$random_surname}"; |
982 | 982 | |
983 | - if ( in_array( $name, $this->new_donor_names ) ) { |
|
983 | + if (in_array($name, $this->new_donor_names)) { |
|
984 | 984 | $name = $this->get_random_name(); |
985 | 985 | } |
986 | 986 | |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | * |
1000 | 1000 | * @return string |
1001 | 1001 | */ |
1002 | - private function get_random_email( $name ) { |
|
1003 | - return implode( '.', explode( ' ', strtolower( $name ) ) ) . '@test.com'; |
|
1002 | + private function get_random_email($name) { |
|
1003 | + return implode('.', explode(' ', strtolower($name))).'@test.com'; |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
@@ -1015,59 +1015,59 @@ discard block |
||
1015 | 1015 | * @when after_wp_load |
1016 | 1016 | * @subcommand test-mode |
1017 | 1017 | */ |
1018 | - public function test_mode( $args, $assoc ) { |
|
1018 | + public function test_mode($args, $assoc) { |
|
1019 | 1019 | |
1020 | 1020 | // Return if associative arguments are not specified. |
1021 | - if ( empty( $assoc ) ) { |
|
1022 | - WP_CLI::error( "--enable or --disable flag is missing." ); |
|
1021 | + if (empty($assoc)) { |
|
1022 | + WP_CLI::error("--enable or --disable flag is missing."); |
|
1023 | 1023 | return; |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - $enabled_gateways = give_get_option( 'gateways' ); |
|
1027 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
1026 | + $enabled_gateways = give_get_option('gateways'); |
|
1027 | + $default_gateway = give_get_option('default_gateway'); |
|
1028 | 1028 | |
1029 | 1029 | |
1030 | 1030 | // Enable Test Mode. |
1031 | - if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'enable' ) ) { |
|
1031 | + if (true === WP_CLI\Utils\get_flag_value($assoc, 'enable')) { |
|
1032 | 1032 | |
1033 | 1033 | // Set `Test Mode` to `enabled`. |
1034 | - give_update_option( 'test_mode', 'enabled' ); |
|
1034 | + give_update_option('test_mode', 'enabled'); |
|
1035 | 1035 | |
1036 | 1036 | |
1037 | 1037 | // Enable `Test Donation` gateway. |
1038 | 1038 | $enabled_gateways['manual'] = "1"; |
1039 | - give_update_option( 'gateways', $enabled_gateways ); |
|
1039 | + give_update_option('gateways', $enabled_gateways); |
|
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | // Set `Test Donation` as default gateway. |
1043 | - add_option( 'give_test_mode_default_gateway', $default_gateway ); |
|
1044 | - give_update_option( 'default_gateway', 'manual' ); |
|
1043 | + add_option('give_test_mode_default_gateway', $default_gateway); |
|
1044 | + give_update_option('default_gateway', 'manual'); |
|
1045 | 1045 | |
1046 | 1046 | |
1047 | 1047 | // Show success message on completion. |
1048 | - WP_CLI::success( 'Give Test mode enabled' ); |
|
1048 | + WP_CLI::success('Give Test mode enabled'); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | // Disable Test Mode. |
1052 | - if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'disable' ) ) { |
|
1052 | + if (true === WP_CLI\Utils\get_flag_value($assoc, 'disable')) { |
|
1053 | 1053 | |
1054 | 1054 | // Set `Test Mode` to `disabled`. |
1055 | - give_update_option( 'test_mode', 'disabled' ); |
|
1055 | + give_update_option('test_mode', 'disabled'); |
|
1056 | 1056 | |
1057 | 1057 | |
1058 | 1058 | // Disable `Test Donation` gateway. |
1059 | - unset( $enabled_gateways['manual'] ); |
|
1060 | - give_update_option( 'gateways', $enabled_gateways ); |
|
1059 | + unset($enabled_gateways['manual']); |
|
1060 | + give_update_option('gateways', $enabled_gateways); |
|
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 | // Backup `Default Gateway` setting for restore on test mode disable. |
1064 | - $default_gateway_backup = get_option( 'give_test_mode_default_gateway' ); |
|
1065 | - give_update_option( 'default_gateway', $default_gateway_backup ); |
|
1066 | - delete_option( 'give_test_mode_default_gateway' ); |
|
1064 | + $default_gateway_backup = get_option('give_test_mode_default_gateway'); |
|
1065 | + give_update_option('default_gateway', $default_gateway_backup); |
|
1066 | + delete_option('give_test_mode_default_gateway'); |
|
1067 | 1067 | |
1068 | 1068 | |
1069 | 1069 | // Show success message on completion. |
1070 | - WP_CLI::success( 'Give Test mode disabled' ); |
|
1070 | + WP_CLI::success('Give Test mode disabled'); |
|
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | |
@@ -1082,8 +1082,8 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @return boolean |
1084 | 1084 | */ |
1085 | - private function is_git_repo( $repo_path ) { |
|
1086 | - if ( is_dir( "{$repo_path}.git" ) ) { |
|
1085 | + private function is_git_repo($repo_path) { |
|
1086 | + if (is_dir("{$repo_path}.git")) { |
|
1087 | 1087 | return true; |
1088 | 1088 | } |
1089 | 1089 | |
@@ -1100,11 +1100,11 @@ discard block |
||
1100 | 1100 | * |
1101 | 1101 | * @return string |
1102 | 1102 | */ |
1103 | - private function get_git_current_branch( $repo_path ) { |
|
1103 | + private function get_git_current_branch($repo_path) { |
|
1104 | 1104 | |
1105 | - exec( "cd $repo_path && git branch | grep '\*'", $branch_names ); |
|
1105 | + exec("cd $repo_path && git branch | grep '\*'", $branch_names); |
|
1106 | 1106 | |
1107 | - $branch_name = trim( strtolower( str_replace( '* ', '', $branch_names[0] ) ) ); |
|
1107 | + $branch_name = trim(strtolower(str_replace('* ', '', $branch_names[0]))); |
|
1108 | 1108 | |
1109 | 1109 | return $branch_name; |
1110 | 1110 | } |
@@ -1134,59 +1134,59 @@ discard block |
||
1134 | 1134 | * |
1135 | 1135 | * @subcommand addon-update |
1136 | 1136 | */ |
1137 | - public function addon_update( $pos, $assoc ) { |
|
1137 | + public function addon_update($pos, $assoc) { |
|
1138 | 1138 | |
1139 | 1139 | /** |
1140 | 1140 | * Only 1 associative argument should be passed. |
1141 | 1141 | * It can be either `--name` or `--exclude` |
1142 | 1142 | */ |
1143 | - if ( count( $assoc ) > 1 ) { |
|
1144 | - WP_CLI::error( __( 'Too many associative arguments.', 'give' ) ); |
|
1143 | + if (count($assoc) > 1) { |
|
1144 | + WP_CLI::error(__('Too many associative arguments.', 'give')); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
1148 | 1148 | * Update a single Give addon. |
1149 | 1149 | */ |
1150 | - if ( false !== ( $addon_name = WP_CLI\Utils\get_flag_value( $assoc, 'name', false ) ) ) { |
|
1151 | - $give_addon_path = glob( WP_CONTENT_DIR . "/plugins/$addon_name/" , GLOB_ONLYDIR ); |
|
1150 | + if (false !== ($addon_name = WP_CLI\Utils\get_flag_value($assoc, 'name', false))) { |
|
1151 | + $give_addon_path = glob(WP_CONTENT_DIR."/plugins/$addon_name/", GLOB_ONLYDIR); |
|
1152 | 1152 | |
1153 | 1153 | /** |
1154 | 1154 | * Display error if the plugin (addon) name entered does |
1155 | 1155 | * not exist. |
1156 | 1156 | */ |
1157 | - if ( empty( $give_addon_path ) ) { |
|
1158 | - WP_CLI::error( sprintf( __( "The Give addon '%s' does not exist.", 'give' ), $addon_name ) ); |
|
1157 | + if (empty($give_addon_path)) { |
|
1158 | + WP_CLI::error(sprintf(__("The Give addon '%s' does not exist.", 'give'), $addon_name)); |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | /** |
1162 | 1162 | * If the directory does not contain a Git |
1163 | 1163 | * repository, then display error and halt. |
1164 | 1164 | */ |
1165 | - if ( ! $this->is_git_repo( $give_addon_path[0] ) ) { |
|
1166 | - WP_CLI::error( __( 'This is not a Git repo', 'give' ) ); |
|
1165 | + if ( ! $this->is_git_repo($give_addon_path[0])) { |
|
1166 | + WP_CLI::error(__('This is not a Git repo', 'give')); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
1170 | 1170 | * Get the current branch name. This branch will be updated next. |
1171 | 1171 | */ |
1172 | - $branch_name = $this->get_git_current_branch( $give_addon_path[0] ); |
|
1172 | + $branch_name = $this->get_git_current_branch($give_addon_path[0]); |
|
1173 | 1173 | |
1174 | 1174 | /** |
1175 | 1175 | * Take the latest pull of the current branch, i.e.; |
1176 | 1176 | * sync it with origin. |
1177 | 1177 | */ |
1178 | - passthru( "cd $give_addon_path[0] && git pull origin $branch_name", $return_var ); |
|
1178 | + passthru("cd $give_addon_path[0] && git pull origin $branch_name", $return_var); |
|
1179 | 1179 | |
1180 | 1180 | /** |
1181 | 1181 | * Show success/error messages depending on whether the |
1182 | 1182 | * current branch of the addon was updated or not. |
1183 | 1183 | */ |
1184 | - if ( 0 === $return_var ) { |
|
1185 | - WP_CLI::success( sprintf( __( "The Give addon '%s' is up-to-date with origin." ), $addon_name ) ); |
|
1184 | + if (0 === $return_var) { |
|
1185 | + WP_CLI::success(sprintf(__("The Give addon '%s' is up-to-date with origin."), $addon_name)); |
|
1186 | 1186 | |
1187 | 1187 | return; |
1188 | - } elseif ( 1 === $return_var ) { |
|
1189 | - WP_CLI::error( sprintf( __( "The Give addon '%s' was not updated." ), $addon_name ) ); |
|
1188 | + } elseif (1 === $return_var) { |
|
1189 | + WP_CLI::error(sprintf(__("The Give addon '%s' was not updated."), $addon_name)); |
|
1190 | 1190 | } |
1191 | 1191 | } |
1192 | 1192 | |
@@ -1194,34 +1194,34 @@ discard block |
||
1194 | 1194 | * Convert the comma-separated string of Give-addons in the |
1195 | 1195 | * excluded list into array. |
1196 | 1196 | */ |
1197 | - $addon_names = WP_CLI\Utils\get_flag_value( $assoc, 'exclude', array() ); |
|
1198 | - if ( ! empty( $addon_names ) ) { |
|
1199 | - $addon_names = array_map( 'trim', explode( ',', $addon_names ) ); |
|
1197 | + $addon_names = WP_CLI\Utils\get_flag_value($assoc, 'exclude', array()); |
|
1198 | + if ( ! empty($addon_names)) { |
|
1199 | + $addon_names = array_map('trim', explode(',', $addon_names)); |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | /** |
1203 | 1203 | * Get directory paths of all the addons including |
1204 | 1204 | * Give Core. |
1205 | 1205 | */ |
1206 | - $give_addon_directories = glob( WP_CONTENT_DIR . '/plugins/[gG]ive*/' , GLOB_ONLYDIR ); |
|
1206 | + $give_addon_directories = glob(WP_CONTENT_DIR.'/plugins/[gG]ive*/', GLOB_ONLYDIR); |
|
1207 | 1207 | |
1208 | - foreach ( $give_addon_directories as $repo ) { |
|
1208 | + foreach ($give_addon_directories as $repo) { |
|
1209 | 1209 | |
1210 | 1210 | /** |
1211 | 1211 | * Extract the plugin/addon folder name |
1212 | 1212 | * from the absolute path. |
1213 | 1213 | */ |
1214 | - $plugin_name = basename( $repo ); |
|
1214 | + $plugin_name = basename($repo); |
|
1215 | 1215 | |
1216 | 1216 | /** |
1217 | 1217 | * If the Give addon directory does not contain |
1218 | 1218 | * a Git repo, then continue. |
1219 | 1219 | */ |
1220 | - if ( ! $this->is_git_repo( $repo ) ) { |
|
1220 | + if ( ! $this->is_git_repo($repo)) { |
|
1221 | 1221 | WP_CLI::line( |
1222 | 1222 | sprintf( |
1223 | - __( "%s: '%s' does not contain git repo.", 'give' ), |
|
1224 | - WP_CLI::colorize( '%RError%n' ), |
|
1223 | + __("%s: '%s' does not contain git repo.", 'give'), |
|
1224 | + WP_CLI::colorize('%RError%n'), |
|
1225 | 1225 | $plugin_name |
1226 | 1226 | ) |
1227 | 1227 | ); |
@@ -1232,34 +1232,34 @@ discard block |
||
1232 | 1232 | /** |
1233 | 1233 | * Continue if the Give addon name is in the exlusion list. |
1234 | 1234 | */ |
1235 | - if ( in_array( $plugin_name, $addon_names, true ) ) { |
|
1235 | + if (in_array($plugin_name, $addon_names, true)) { |
|
1236 | 1236 | continue; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | /* Get the current branch name */ |
1240 | - $branch_name = $this->get_git_current_branch( $repo ); |
|
1240 | + $branch_name = $this->get_git_current_branch($repo); |
|
1241 | 1241 | |
1242 | 1242 | /** |
1243 | 1243 | * Show a colorized (CYAN) title for each addon/plugin |
1244 | 1244 | * before a pull. |
1245 | 1245 | */ |
1246 | - WP_CLI::line( WP_CLI::colorize( "> %CUpdating $plugin_name | $branch_name%n" ) ); |
|
1246 | + WP_CLI::line(WP_CLI::colorize("> %CUpdating $plugin_name | $branch_name%n")); |
|
1247 | 1247 | |
1248 | 1248 | /** |
1249 | 1249 | * Git pull from the current branch using |
1250 | 1250 | * remote `origin`. |
1251 | 1251 | */ |
1252 | - if ( ! empty( $branch_name ) ) { |
|
1253 | - passthru( "cd $repo && git pull origin $branch_name", $return_var ); |
|
1252 | + if ( ! empty($branch_name)) { |
|
1253 | + passthru("cd $repo && git pull origin $branch_name", $return_var); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | $items[] = array( |
1257 | 1257 | 'Give Addon' => $plugin_name, |
1258 | 1258 | 'Branch' => $branch_name, |
1259 | 1259 | 'Remote' => 'origin', |
1260 | - 'Status' => ( 0 === $return_var ) |
|
1261 | - ? __( 'Success', 'give' ) |
|
1262 | - : __( 'Failed', 'give' ), |
|
1260 | + 'Status' => (0 === $return_var) |
|
1261 | + ? __('Success', 'give') |
|
1262 | + : __('Failed', 'give'), |
|
1263 | 1263 | ); |
1264 | 1264 | |
1265 | 1265 | /** |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | 24 | |
25 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
25 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,33 +34,33 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function give_clear_seo_sitemap_cache_on_settings_change() { |
36 | 36 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
37 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
38 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
37 | + if ( ! function_exists('is_plugin_active')) { |
|
38 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | - if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
41 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
42 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
43 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
44 | 44 | ) { |
45 | 45 | |
46 | - $forms_singular_option = give_get_option( 'forms_singular' ); |
|
47 | - $forms_archive_option = give_get_option( 'forms_singular' ); |
|
46 | + $forms_singular_option = give_get_option('forms_singular'); |
|
47 | + $forms_archive_option = give_get_option('forms_singular'); |
|
48 | 48 | |
49 | 49 | // If there is change detected for Single Form View and Form Archives options then proceed. |
50 | 50 | if ( |
51 | - ( isset( $_POST['forms_singular'] ) && $_POST['forms_singular'] !== $forms_singular_option ) || |
|
52 | - ( isset( $_POST['forms_archives'] ) && $_POST['forms_archives'] !== $forms_archive_option ) |
|
51 | + (isset($_POST['forms_singular']) && $_POST['forms_singular'] !== $forms_singular_option) || |
|
52 | + (isset($_POST['forms_archives']) && $_POST['forms_archives'] !== $forms_archive_option) |
|
53 | 53 | ) { |
54 | 54 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
55 | 55 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
56 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
56 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
57 | 57 | WPSEO_Sitemaps_Cache::clear(); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
63 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * This is support for the plugin Elementor. This function |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Is the plugin: Elementor activated? |
80 | 80 | */ |
81 | - if ( is_plugin_active( 'elementor/elementor.php' ) ) { |
|
81 | + if (is_plugin_active('elementor/elementor.php')) { |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Check user is on the Elementor's editor page, then hide Give Shortcodes Button. |
85 | 85 | */ |
86 | - if ( isset( $_GET['action'] ) && 'elementor' === give_clean( $_GET['action'] ) ) { |
|
86 | + if (isset($_GET['action']) && 'elementor' === give_clean($_GET['action'])) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | } |
@@ -91,4 +91,4 @@ discard block |
||
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | |
94 | -add_filter( 'give_shortcode_button_condition', 'give_elementor_hide_shortcodes_button', 11 ); |
|
94 | +add_filter('give_shortcode_button_condition', 'give_elementor_hide_shortcodes_button', 11); |