@@ -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' ), 10, 4 ); |
|
88 | + if (in_array('get_post_metadata', $this->supports)) { |
|
89 | + add_filter('get_post_metadata', array($this, '__get_meta'), 10, 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; |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give'), |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Add our payment instructions to the checkout |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return void |
41 | 41 | */ |
42 | -function give_offline_payment_cc_form( $form_id ) { |
|
42 | +function give_offline_payment_cc_form($form_id) { |
|
43 | 43 | // Get offline payment instruction. |
44 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
44 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
45 | 45 | |
46 | 46 | ob_start(); |
47 | 47 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param int $form_id Give form id. |
54 | 54 | */ |
55 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
55 | + do_action('give_before_offline_info_fields', $form_id); |
|
56 | 56 | ?> |
57 | 57 | <fieldset id="give_offline_payment_info"> |
58 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
58 | + <?php echo stripslashes($offline_instructions); ?> |
|
59 | 59 | </fieldset> |
60 | 60 | <?php |
61 | 61 | /** |
@@ -65,35 +65,35 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param int $form_id Give form id. |
67 | 67 | */ |
68 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
68 | + do_action('give_after_offline_info_fields', $form_id); |
|
69 | 69 | |
70 | 70 | echo ob_get_clean(); |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
73 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Give Offline Billing Field |
77 | 77 | * |
78 | 78 | * @param $form_id |
79 | 79 | */ |
80 | -function give_offline_billing_fields( $form_id ) { |
|
80 | +function give_offline_billing_fields($form_id) { |
|
81 | 81 | //Enable Default CC fields (billing info) |
82 | - $post_offline_cc_fields = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
83 | - $post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
82 | + $post_offline_cc_fields = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
83 | + $post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
84 | 84 | |
85 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
85 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
86 | 86 | |
87 | 87 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
88 | 88 | if ( |
89 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
90 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
89 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
90 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
91 | 91 | ) { |
92 | - give_default_cc_address_fields( $form_id ); |
|
92 | + give_default_cc_address_fields($form_id); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
96 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Process the payment |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return void |
106 | 106 | */ |
107 | -function give_offline_process_payment( $purchase_data ) { |
|
107 | +function give_offline_process_payment($purchase_data) { |
|
108 | 108 | |
109 | 109 | // Setup the payment details. |
110 | 110 | $payment_data = array( |
111 | 111 | 'price' => $purchase_data['price'], |
112 | 112 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
113 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
114 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
113 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
114 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
115 | 115 | 'date' => $purchase_data['date'], |
116 | 116 | 'user_email' => $purchase_data['user_email'], |
117 | 117 | 'purchase_key' => $purchase_data['purchase_key'], |
118 | - 'currency' => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ), |
|
118 | + 'currency' => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data), |
|
119 | 119 | 'user_info' => $purchase_data['user_info'], |
120 | 120 | 'status' => 'pending', |
121 | 121 | 'gateway' => 'offline', |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | |
124 | 124 | |
125 | 125 | // record the pending payment |
126 | - $payment = give_insert_payment( $payment_data ); |
|
126 | + $payment = give_insert_payment($payment_data); |
|
127 | 127 | |
128 | - if ( $payment ) { |
|
128 | + if ($payment) { |
|
129 | 129 | give_send_to_success_page(); |
130 | 130 | } else { |
131 | 131 | // if errors are present, send the user back to the donation form so they can be corrected |
132 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
132 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
137 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -147,59 +147,59 @@ discard block |
||
147 | 147 | * @since 1.0 |
148 | 148 | * @return void |
149 | 149 | */ |
150 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
150 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
151 | 151 | |
152 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
153 | - $post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
152 | + $payment_data = give_get_payment_meta($payment_id); |
|
153 | + $post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
154 | 154 | |
155 | 155 | //Customize email content depending on whether the single form has been customized |
156 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
156 | + $email_content = give_get_option('global_offline_donation_email'); |
|
157 | 157 | |
158 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
159 | - $email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
158 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
159 | + $email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
160 | 160 | } |
161 | 161 | |
162 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
162 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Filters the from name. |
166 | 166 | * |
167 | 167 | * @since 1.7 |
168 | 168 | */ |
169 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
169 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
170 | 170 | |
171 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
171 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Filters the from email. |
175 | 175 | * |
176 | 176 | * @since 1.7 |
177 | 177 | */ |
178 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
178 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
179 | 179 | |
180 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
180 | + $to_email = give_get_payment_user_email($payment_id); |
|
181 | 181 | |
182 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
183 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
184 | - $subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
182 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
183 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
184 | + $subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
185 | 185 | } |
186 | 186 | |
187 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
188 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
187 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
188 | + $subject = give_do_email_tags($subject, $payment_id); |
|
189 | 189 | |
190 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
191 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
190 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
191 | + $message = give_do_email_tags($email_content, $payment_id); |
|
192 | 192 | |
193 | 193 | $emails = Give()->emails; |
194 | 194 | |
195 | - $emails->__set( 'from_name', $from_name ); |
|
196 | - $emails->__set( 'from_email', $from_email ); |
|
197 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
195 | + $emails->__set('from_name', $from_name); |
|
196 | + $emails->__set('from_email', $from_email); |
|
197 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
198 | 198 | |
199 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
200 | - $emails->__set( 'headers', $headers ); |
|
199 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
200 | + $emails->__set('headers', $headers); |
|
201 | 201 | |
202 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
202 | + $emails->send($to_email, $subject, $message, $attachments); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
@@ -216,54 +216,54 @@ discard block |
||
216 | 216 | * @return void |
217 | 217 | * |
218 | 218 | */ |
219 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
219 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
220 | 220 | |
221 | 221 | /* Send an email notification to the admin */ |
222 | 222 | $admin_email = give_get_admin_notice_emails(); |
223 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
223 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
224 | 224 | |
225 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
226 | - $user_data = get_userdata( $user_info['id'] ); |
|
225 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
226 | + $user_data = get_userdata($user_info['id']); |
|
227 | 227 | $name = $user_data->display_name; |
228 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
229 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
228 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
229 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
230 | 230 | } else { |
231 | 231 | $name = $user_info['email']; |
232 | 232 | } |
233 | 233 | |
234 | - $amount = give_donation_amount( $payment_id ); |
|
234 | + $amount = give_donation_amount($payment_id); |
|
235 | 235 | |
236 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
236 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
237 | 237 | |
238 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
239 | - $admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n"; |
|
240 | - $admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
238 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
239 | + $admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n"; |
|
240 | + $admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
241 | 241 | |
242 | 242 | |
243 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
244 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
243 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
244 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
245 | 245 | |
246 | 246 | $admin_message .= sprintf( |
247 | 247 | '<a href="%1$s">%2$s</a>', |
248 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
249 | - __( 'View Donation Details »', 'give' ) |
|
250 | - ) . "\n\n"; |
|
248 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id), |
|
249 | + __('View Donation Details »', 'give') |
|
250 | + )."\n\n"; |
|
251 | 251 | |
252 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
253 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
252 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
253 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
254 | 254 | |
255 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
256 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
255 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
256 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
257 | 257 | |
258 | 258 | //Send Email |
259 | 259 | $emails = Give()->emails; |
260 | - $emails->__set( 'heading', __( 'New Offline Donation', 'give' ) ); |
|
260 | + $emails->__set('heading', __('New Offline Donation', 'give')); |
|
261 | 261 | |
262 | - if ( ! empty( $admin_headers ) ) { |
|
263 | - $emails->__set( 'headers', $admin_headers ); |
|
262 | + if ( ! empty($admin_headers)) { |
|
263 | + $emails->__set('headers', $admin_headers); |
|
264 | 264 | } |
265 | 265 | |
266 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
266 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
@@ -276,20 +276,20 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return array |
278 | 278 | */ |
279 | -function give_offline_add_settings( $settings ) { |
|
279 | +function give_offline_add_settings($settings) { |
|
280 | 280 | |
281 | 281 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
282 | - if ( in_array( 'offline', (array) give_get_option( 'gateways' ) ) ) { |
|
282 | + if (in_array('offline', (array) give_get_option('gateways'))) { |
|
283 | 283 | return $settings; |
284 | 284 | } |
285 | 285 | |
286 | 286 | //Vars |
287 | 287 | $prefix = '_give_'; |
288 | 288 | |
289 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
289 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
290 | 290 | |
291 | 291 | //this gateway isn't active |
292 | - if ( ! $is_gateway_active ) { |
|
292 | + if ( ! $is_gateway_active) { |
|
293 | 293 | //return settings and bounce |
294 | 294 | return $settings; |
295 | 295 | } |
@@ -298,34 +298,34 @@ discard block |
||
298 | 298 | $check_settings = array( |
299 | 299 | |
300 | 300 | array( |
301 | - 'name' => __( 'Offline Donations', 'give' ), |
|
302 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
303 | - 'id' => $prefix . 'customize_offline_donations', |
|
301 | + 'name' => __('Offline Donations', 'give'), |
|
302 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
303 | + 'id' => $prefix.'customize_offline_donations', |
|
304 | 304 | 'type' => 'radio_inline', |
305 | 305 | 'default' => 'global', |
306 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
307 | - 'global' => __( 'Global Option', 'give' ), |
|
308 | - 'enabled' => __( 'Customize', 'give' ), |
|
309 | - 'disabled' => __( 'Disable', 'give' ), |
|
306 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
307 | + 'global' => __('Global Option', 'give'), |
|
308 | + 'enabled' => __('Customize', 'give'), |
|
309 | + 'disabled' => __('Disable', 'give'), |
|
310 | 310 | ) |
311 | 311 | ), |
312 | 312 | ), |
313 | 313 | array( |
314 | - 'name' => __( 'Billing Fields', 'give' ), |
|
315 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
316 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
314 | + 'name' => __('Billing Fields', 'give'), |
|
315 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
316 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
317 | 317 | 'row_classes' => 'give-subfield give-hidden', |
318 | 318 | 'type' => 'radio_inline', |
319 | 319 | 'default' => 'disabled', |
320 | 320 | 'options' => array( |
321 | - 'enabled' => __( 'Enabled', 'give' ), |
|
322 | - 'disabled' => __( 'Disabled', 'give' ), |
|
321 | + 'enabled' => __('Enabled', 'give'), |
|
322 | + 'disabled' => __('Disabled', 'give'), |
|
323 | 323 | ), |
324 | 324 | ), |
325 | 325 | array( |
326 | - 'id' => $prefix . 'offline_checkout_notes', |
|
327 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
328 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
326 | + 'id' => $prefix.'offline_checkout_notes', |
|
327 | + 'name' => __('Donation Instructions', 'give'), |
|
328 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
329 | 329 | 'default' => give_get_default_offline_donation_content(), |
330 | 330 | 'type' => 'wysiwyg', |
331 | 331 | 'row_classes' => 'give-subfield give-hidden', |
@@ -337,14 +337,14 @@ discard block |
||
337 | 337 | 'name' => 'offline_docs', |
338 | 338 | 'type' => 'docs_link', |
339 | 339 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
340 | - 'title' => __( 'Offline Donations', 'give' ), |
|
340 | + 'title' => __('Offline Donations', 'give'), |
|
341 | 341 | ), |
342 | 342 | ); |
343 | 343 | |
344 | - return array_merge( $settings, $check_settings ); |
|
344 | + return array_merge($settings, $check_settings); |
|
345 | 345 | } |
346 | 346 | |
347 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
347 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
348 | 348 | |
349 | 349 | |
350 | 350 | /** |
@@ -356,32 +356,32 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function give_get_default_offline_donation_content() { |
358 | 358 | |
359 | - $sitename = get_bloginfo( 'sitename' ); |
|
359 | + $sitename = get_bloginfo('sitename'); |
|
360 | 360 | |
361 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
361 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
362 | 362 | $default_text .= '<ol>'; |
363 | 363 | $default_text .= '<li>'; |
364 | 364 | $default_text .= sprintf( |
365 | 365 | /* translators: %s: site name */ |
366 | - __( 'Make a check payable to "%s"', 'give' ), |
|
366 | + __('Make a check payable to "%s"', 'give'), |
|
367 | 367 | $sitename |
368 | 368 | ); |
369 | 369 | $default_text .= '</li>'; |
370 | 370 | $default_text .= '<li>'; |
371 | 371 | $default_text .= sprintf( |
372 | 372 | /* translators: %s: site name */ |
373 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
373 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
374 | 374 | $sitename |
375 | 375 | ); |
376 | 376 | $default_text .= '</li>'; |
377 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
377 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
378 | 378 | $default_text .= '</ol>'; |
379 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
379 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
380 | 380 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
381 | 381 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
382 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
382 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
383 | 383 | |
384 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
384 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
385 | 385 | |
386 | 386 | } |
387 | 387 | |
@@ -394,34 +394,34 @@ discard block |
||
394 | 394 | */ |
395 | 395 | function give_get_default_offline_donation_email_content() { |
396 | 396 | |
397 | - $sitename = get_bloginfo( 'sitename' ); |
|
398 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
399 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
397 | + $sitename = get_bloginfo('sitename'); |
|
398 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
399 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
400 | 400 | $default_text .= '<ol>'; |
401 | 401 | $default_text .= '<li>'; |
402 | 402 | $default_text .= sprintf( |
403 | 403 | /* translators: %s: site name */ |
404 | - __( 'Make a check payable to "%s"', 'give' ), |
|
404 | + __('Make a check payable to "%s"', 'give'), |
|
405 | 405 | $sitename |
406 | 406 | ); |
407 | 407 | $default_text .= '</li>'; |
408 | 408 | $default_text .= '<li>'; |
409 | 409 | $default_text .= sprintf( |
410 | 410 | /* translators: %s: site name */ |
411 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
411 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
412 | 412 | $sitename |
413 | 413 | ); |
414 | 414 | $default_text .= '</li>'; |
415 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
415 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
416 | 416 | $default_text .= '</ol>'; |
417 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
417 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
418 | 418 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
419 | 419 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
420 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
421 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
422 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
420 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
421 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
422 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
423 | 423 | |
424 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
424 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
425 | 425 | |
426 | 426 | } |
427 | 427 | |
@@ -435,33 +435,33 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return string |
437 | 437 | */ |
438 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
438 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
439 | 439 | // Bailout. |
440 | - if ( ! $form_id ) { |
|
440 | + if ( ! $form_id) { |
|
441 | 441 | return ''; |
442 | 442 | } |
443 | 443 | |
444 | - $post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
445 | - $post_offline_instructions = give_get_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
446 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
444 | + $post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
445 | + $post_offline_instructions = give_get_meta($form_id, '_give_offline_checkout_notes', true); |
|
446 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
447 | 447 | $offline_instructions = $global_offline_instruction; |
448 | 448 | |
449 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
449 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
450 | 450 | $offline_instructions = $post_offline_instructions; |
451 | 451 | } |
452 | 452 | |
453 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
453 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
454 | 454 | |
455 | 455 | /* translators: %s: form settings url */ |
456 | - $offline_instructions = ! empty( $offline_instructions ) |
|
456 | + $offline_instructions = ! empty($offline_instructions) |
|
457 | 457 | ? $offline_instructions |
458 | 458 | : sprintf( |
459 | - __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), |
|
459 | + __('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), |
|
460 | 460 | $settings_url |
461 | 461 | ); |
462 | 462 | |
463 | 463 | $formmated_offline_instructions = $wpautop |
464 | - ? wpautop( do_shortcode( $offline_instructions ) ) |
|
464 | + ? wpautop(do_shortcode($offline_instructions)) |
|
465 | 465 | : $offline_instructions; |
466 | 466 | |
467 | 467 | /** |
@@ -492,21 +492,21 @@ discard block |
||
492 | 492 | * |
493 | 493 | * @return array |
494 | 494 | */ |
495 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
495 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
496 | 496 | if ( |
497 | 497 | // Show offline payment gateway if enable for new donation form. |
498 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
498 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
499 | 499 | && $form_id |
500 | - && ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( 'enabled', 'global' ) ) |
|
500 | + && ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array('enabled', 'global')) |
|
501 | 501 | ) { |
502 | - unset( $gateway_list['offline'] ); |
|
502 | + unset($gateway_list['offline']); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | // Output. |
506 | 506 | return $gateway_list; |
507 | 507 | } |
508 | 508 | |
509 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
509 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
510 | 510 | |
511 | 511 | /** |
512 | 512 | * Set default gateway to global default payment gateway |
@@ -520,13 +520,13 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @return void |
522 | 522 | */ |
523 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
523 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
524 | 524 | if ( |
525 | - ! give_is_setting_enabled( $meta_value, array( 'global', 'enabled' ) ) |
|
526 | - && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) |
|
525 | + ! give_is_setting_enabled($meta_value, array('global', 'enabled')) |
|
526 | + && ('offline' === give_get_meta($postid, '_give_default_gateway', true)) |
|
527 | 527 | ) { |
528 | - give_update_meta( $postid, '_give_default_gateway', 'global' ); |
|
528 | + give_update_meta($postid, '_give_default_gateway', 'global'); |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
532 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -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,24 +201,23 @@ 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 | - false === strpos( $number, $thousand_separator ) |
|
220 | - && false === strpos( $number, $decimal_separator ) |
|
217 | + false === strpos($number, $thousand_separator) |
|
218 | + && false === strpos($number, $decimal_separator) |
|
221 | 219 | ) { |
222 | - return number_format( $number, $number_decimals, '.', '' ); |
|
220 | + return number_format($number, $number_decimals, '.', ''); |
|
223 | 221 | } elseif ( |
224 | 222 | // Decimal formatted number. |
225 | 223 | // If number of decimal place set to non zero and |
@@ -227,34 +225,34 @@ discard block |
||
227 | 225 | // then number will be consider as decimal formatted which means number is already sanitized. |
228 | 226 | $number_decimals |
229 | 227 | && '.' === $thousand_separator |
230 | - && false !== strpos( $number, $thousand_separator ) |
|
231 | - && false === strpos( $number, $decimal_separator ) |
|
232 | - && 2 === count( $number_parts ) |
|
233 | - && ( $number_decimals >= strlen( $number_parts[1] ) ) |
|
234 | - ){ |
|
235 | - return number_format( $number, $number_decimals, '.', '' ); |
|
228 | + && false !== strpos($number, $thousand_separator) |
|
229 | + && false === strpos($number, $decimal_separator) |
|
230 | + && 2 === count($number_parts) |
|
231 | + && ($number_decimals >= strlen($number_parts[1])) |
|
232 | + ) { |
|
233 | + return number_format($number, $number_decimals, '.', ''); |
|
236 | 234 | } |
237 | 235 | |
238 | 236 | // Handle thousand separator as '.' |
239 | 237 | // Handle sanitize database values. |
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] ) ) ); |
|
238 | + $is_db_sanitize_val = (2 === count($number_parts) && |
|
239 | + is_numeric($number_parts[0]) && |
|
240 | + is_numeric($number_parts[1]) && |
|
241 | + (6 === strlen($number_parts[1]))); |
|
244 | 242 | |
245 | - if ( $is_db_sanitize_val ) { |
|
243 | + if ($is_db_sanitize_val) { |
|
246 | 244 | // Sanitize database value. |
247 | - return number_format( $number, $number_decimals, '.', '' ); |
|
245 | + return number_format($number, $number_decimals, '.', ''); |
|
248 | 246 | |
249 | 247 | } elseif ( |
250 | 248 | '.' === $thousand_separator && |
251 | - false !== strpos( $number, $thousand_separator ) |
|
249 | + false !== strpos($number, $thousand_separator) |
|
252 | 250 | ) { |
253 | 251 | // Fix point thousand separator value. |
254 | - $number = str_replace( '.', '', $number ); |
|
252 | + $number = str_replace('.', '', $number); |
|
255 | 253 | } |
256 | 254 | |
257 | - return give_sanitize_amount( $number, $args ); |
|
255 | + return give_sanitize_amount($number, $args); |
|
258 | 256 | } |
259 | 257 | |
260 | 258 | /** |
@@ -271,10 +269,10 @@ discard block |
||
271 | 269 | * |
272 | 270 | * @return string $amount Newly sanitized amount |
273 | 271 | */ |
274 | -function give_sanitize_amount( $number, $args = array() ) { |
|
272 | +function give_sanitize_amount($number, $args = array()) { |
|
275 | 273 | |
276 | 274 | // Bailout. |
277 | - if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) { |
|
275 | + if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) { |
|
278 | 276 | return $number; |
279 | 277 | } |
280 | 278 | |
@@ -282,10 +280,10 @@ discard block |
||
282 | 280 | $func_args = func_get_args(); |
283 | 281 | |
284 | 282 | // Backward compatibility. |
285 | - if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) { |
|
283 | + if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) { |
|
286 | 284 | $args = array( |
287 | 285 | 'number_decimals' => $func_args[1], |
288 | - 'trim_zeros' => isset( $func_args[2] ) ? $func_args[2] : false, |
|
286 | + 'trim_zeros' => isset($func_args[2]) ? $func_args[2] : false, |
|
289 | 287 | ); |
290 | 288 | } |
291 | 289 | |
@@ -301,58 +299,58 @@ discard block |
||
301 | 299 | // Remove slash from amount. |
302 | 300 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
303 | 301 | // To prevent notices and warning remove slash from amount/number. |
304 | - $number = wp_unslash( $number ); |
|
302 | + $number = wp_unslash($number); |
|
305 | 303 | |
306 | - $thousand_separator = give_get_price_thousand_separator( $args['currency'] ); |
|
304 | + $thousand_separator = give_get_price_thousand_separator($args['currency']); |
|
307 | 305 | |
308 | 306 | $locale = localeconv(); |
309 | 307 | $decimals = array( |
310 | - give_get_price_decimal_separator( $args['currency'] ), |
|
308 | + give_get_price_decimal_separator($args['currency']), |
|
311 | 309 | $locale['decimal_point'], |
312 | 310 | $locale['mon_decimal_point'], |
313 | 311 | ); |
314 | 312 | |
315 | 313 | // Remove locale from string |
316 | - if ( ! is_float( $number ) ) { |
|
317 | - $number = str_replace( $decimals, '.', $number ); |
|
314 | + if ( ! is_float($number)) { |
|
315 | + $number = str_replace($decimals, '.', $number); |
|
318 | 316 | } |
319 | 317 | |
320 | 318 | // Remove thousand amount formatting if amount has. |
321 | 319 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
322 | 320 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
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 ); |
|
321 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
322 | + $number = str_replace($thousand_separator, '', $number); |
|
323 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
324 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
327 | 325 | } |
328 | 326 | |
329 | 327 | // Remove non numeric entity before decimal separator. |
330 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
331 | - $default_dp = give_get_price_decimals( $args['currency'] ); |
|
328 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
329 | + $default_dp = give_get_price_decimals($args['currency']); |
|
332 | 330 | |
333 | 331 | // Reset negative amount to zero. |
334 | - if ( 0 > $number ) { |
|
335 | - $number = number_format( 0, $default_dp, '.' ); |
|
332 | + if (0 > $number) { |
|
333 | + $number = number_format(0, $default_dp, '.'); |
|
336 | 334 | } |
337 | 335 | |
338 | 336 | // If number does not have decimal then add number of decimals to it. |
339 | 337 | if ( |
340 | - false === strpos( $number, '.' ) |
|
341 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
338 | + false === strpos($number, '.') |
|
339 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
342 | 340 | ) { |
343 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
341 | + $number = number_format($number, $default_dp, '.', ''); |
|
344 | 342 | } |
345 | 343 | |
346 | 344 | // Format number by custom number of decimals. |
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, '.', '' ); |
|
345 | + if (false !== $args['number_decimals']) { |
|
346 | + $dp = intval(is_bool($args['number_decimals']) ? $default_dp : $args['number_decimals']); |
|
347 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
348 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
351 | 349 | } |
352 | 350 | |
353 | 351 | // Trim zeros. |
354 | - if ( $args['trim_zeros'] && strstr( $number, '.' ) ) { |
|
355 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
352 | + if ($args['trim_zeros'] && strstr($number, '.')) { |
|
353 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
356 | 354 | } |
357 | 355 | |
358 | 356 | /** |
@@ -360,7 +358,7 @@ discard block |
||
360 | 358 | * |
361 | 359 | * @since 1.0 |
362 | 360 | */ |
363 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
361 | + return apply_filters('give_sanitize_amount', $number); |
|
364 | 362 | } |
365 | 363 | |
366 | 364 | /** |
@@ -373,9 +371,9 @@ discard block |
||
373 | 371 | * |
374 | 372 | * @return string $amount Newly formatted amount or Price Not Available |
375 | 373 | */ |
376 | -function give_format_amount( $amount, $args = array() ) { |
|
374 | +function give_format_amount($amount, $args = array()) { |
|
377 | 375 | // Backward compatibility. |
378 | - if ( is_bool( $args ) ) { |
|
376 | + if (is_bool($args)) { |
|
379 | 377 | $args = array( |
380 | 378 | 'decimal' => $args, |
381 | 379 | ); |
@@ -388,60 +386,59 @@ discard block |
||
388 | 386 | 'currency' => '', |
389 | 387 | ); |
390 | 388 | |
391 | - $args = wp_parse_args( $args, $default_args ); |
|
389 | + $args = wp_parse_args($args, $default_args); |
|
392 | 390 | |
393 | 391 | // Set Currency based on donation id, if required. |
394 | - if ( $args['donation_id'] && empty( $args['currency'] ) ) { |
|
395 | - $args['currency'] = give_get_meta( $args['donation_id'], '_give_payment_currency', true ); |
|
392 | + if ($args['donation_id'] && empty($args['currency'])) { |
|
393 | + $args['currency'] = give_get_meta($args['donation_id'], '_give_payment_currency', true); |
|
396 | 394 | } |
397 | 395 | |
398 | 396 | $formatted = 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; |
|
397 | + $currency = ! empty($args['currency']) ? $args['currency'] : give_get_currency($args['donation_id']); |
|
398 | + $thousands_sep = give_get_price_thousand_separator($currency); |
|
399 | + $decimal_sep = give_get_price_decimal_separator($currency); |
|
400 | + $decimals = ! empty($args['decimal']) ? give_get_price_decimals($currency) : 0; |
|
403 | 401 | |
404 | - if ( ! empty( $amount ) ) { |
|
402 | + if ( ! empty($amount)) { |
|
405 | 403 | // Sanitize amount before formatting. |
406 | - $amount = ! empty( $args['sanitize'] ) ? |
|
407 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $decimals, 'currency' => $currency ) ) : |
|
408 | - number_format( $amount, $decimals, '.', '' ); |
|
404 | + $amount = ! empty($args['sanitize']) ? |
|
405 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $decimals, 'currency' => $currency)) : number_format($amount, $decimals, '.', ''); |
|
409 | 406 | |
410 | - switch ( $currency ) { |
|
407 | + switch ($currency) { |
|
411 | 408 | case 'INR': |
412 | 409 | $decimal_amount = ''; |
413 | 410 | |
414 | 411 | // Extract decimals from amount |
415 | - if ( ( $pos = strpos( $amount, '.' ) ) !== false ) { |
|
416 | - if ( ! empty( $decimals ) ) { |
|
417 | - $decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 ); |
|
418 | - $amount = substr( $amount, 0, $pos ); |
|
419 | - |
|
420 | - if ( ! $decimal_amount ) { |
|
421 | - $decimal_amount = substr( "{$decimal_sep}0000000000", 0, ( $decimals + 1 ) ); |
|
422 | - } elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) { |
|
423 | - $decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) ); |
|
412 | + if (($pos = strpos($amount, '.')) !== false) { |
|
413 | + if ( ! empty($decimals)) { |
|
414 | + $decimal_amount = substr(round(substr($amount, $pos), $decimals), 1); |
|
415 | + $amount = substr($amount, 0, $pos); |
|
416 | + |
|
417 | + if ( ! $decimal_amount) { |
|
418 | + $decimal_amount = substr("{$decimal_sep}0000000000", 0, ($decimals + 1)); |
|
419 | + } elseif (($decimals + 1) > strlen($decimal_amount)) { |
|
420 | + $decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1)); |
|
424 | 421 | } |
425 | 422 | } else { |
426 | - $amount = number_format( $amount, $decimals, $decimal_sep, '' ); |
|
423 | + $amount = number_format($amount, $decimals, $decimal_sep, ''); |
|
427 | 424 | } |
428 | 425 | } |
429 | 426 | |
430 | 427 | // Extract last 3 from amount |
431 | - $result = substr( $amount, - 3 ); |
|
432 | - $amount = substr( $amount, 0, - 3 ); |
|
428 | + $result = substr($amount, - 3); |
|
429 | + $amount = substr($amount, 0, - 3); |
|
433 | 430 | |
434 | 431 | // Apply digits 2 by 2 |
435 | - while ( strlen( $amount ) > 0 ) { |
|
436 | - $result = substr( $amount, - 2 ) . $thousands_sep . $result; |
|
437 | - $amount = substr( $amount, 0, - 2 ); |
|
432 | + while (strlen($amount) > 0) { |
|
433 | + $result = substr($amount, - 2).$thousands_sep.$result; |
|
434 | + $amount = substr($amount, 0, - 2); |
|
438 | 435 | } |
439 | 436 | |
440 | - $formatted = $result . $decimal_amount; |
|
437 | + $formatted = $result.$decimal_amount; |
|
441 | 438 | break; |
442 | 439 | |
443 | 440 | default: |
444 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
441 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
445 | 442 | } |
446 | 443 | } |
447 | 444 | |
@@ -450,7 +447,7 @@ discard block |
||
450 | 447 | * |
451 | 448 | * @since 1.0 |
452 | 449 | */ |
453 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args ); |
|
450 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args); |
|
454 | 451 | } |
455 | 452 | |
456 | 453 | |
@@ -468,17 +465,17 @@ discard block |
||
468 | 465 | * |
469 | 466 | * @return string formatted amount number with large number names. |
470 | 467 | */ |
471 | -function give_human_format_large_amount( $amount, $args = array() ) { |
|
468 | +function give_human_format_large_amount($amount, $args = array()) { |
|
472 | 469 | // Sanitize amount. |
473 | - $sanitize_amount = give_maybe_sanitize_amount( $amount ); |
|
470 | + $sanitize_amount = give_maybe_sanitize_amount($amount); |
|
474 | 471 | |
475 | 472 | // Bailout. |
476 | - if ( ! floatval( $sanitize_amount ) ) { |
|
473 | + if ( ! floatval($sanitize_amount)) { |
|
477 | 474 | return '0'; |
478 | 475 | }; |
479 | 476 | |
480 | 477 | // Set default currency; |
481 | - if ( empty( $args['currency'] ) ) { |
|
478 | + if (empty($args['currency'])) { |
|
482 | 479 | $args['currency'] = give_get_currency(); |
483 | 480 | } |
484 | 481 | |
@@ -486,37 +483,37 @@ discard block |
||
486 | 483 | $thousands_sep = give_get_price_thousand_separator(); |
487 | 484 | |
488 | 485 | // Explode amount to calculate name of large numbers. |
489 | - $amount_array = explode( $thousands_sep, $amount ); |
|
486 | + $amount_array = explode($thousands_sep, $amount); |
|
490 | 487 | |
491 | 488 | // Calculate amount parts count. |
492 | - $amount_count_parts = count( $amount_array ); |
|
489 | + $amount_count_parts = count($amount_array); |
|
493 | 490 | |
494 | 491 | // Human format amount (default). |
495 | 492 | $human_format_amount = $amount; |
496 | 493 | |
497 | - switch ( $args['currency'] ) { |
|
494 | + switch ($args['currency']) { |
|
498 | 495 | case 'INR': |
499 | 496 | // Calculate large number formatted amount. |
500 | - if ( 4 < $amount_count_parts ) { |
|
501 | - $human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
502 | - } elseif ( 3 < $amount_count_parts ) { |
|
503 | - $human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) ); |
|
504 | - } elseif ( 2 < $amount_count_parts ) { |
|
505 | - $human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) ); |
|
497 | + if (4 < $amount_count_parts) { |
|
498 | + $human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
499 | + } elseif (3 < $amount_count_parts) { |
|
500 | + $human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2)); |
|
501 | + } elseif (2 < $amount_count_parts) { |
|
502 | + $human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2)); |
|
506 | 503 | } |
507 | 504 | break; |
508 | 505 | default: |
509 | 506 | // Calculate large number formatted amount. |
510 | - if ( 4 < $amount_count_parts ) { |
|
511 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
512 | - } elseif ( 3 < $amount_count_parts ) { |
|
513 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
514 | - } elseif ( 2 < $amount_count_parts ) { |
|
515 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
507 | + if (4 < $amount_count_parts) { |
|
508 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
509 | + } elseif (3 < $amount_count_parts) { |
|
510 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
511 | + } elseif (2 < $amount_count_parts) { |
|
512 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
516 | 513 | } |
517 | 514 | } |
518 | 515 | |
519 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
516 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
520 | 517 | } |
521 | 518 | |
522 | 519 | /** |
@@ -530,17 +527,16 @@ discard block |
||
530 | 527 | * |
531 | 528 | * @return string $amount Newly formatted amount or Price Not Available |
532 | 529 | */ |
533 | -function give_format_decimal( $amount, $dp = false, $sanitize = true ) { |
|
530 | +function give_format_decimal($amount, $dp = false, $sanitize = true) { |
|
534 | 531 | $decimal_separator = give_get_price_decimal_separator(); |
535 | 532 | $formatted_amount = $sanitize ? |
536 | - give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $dp ) ) : |
|
537 | - number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' ); |
|
533 | + give_maybe_sanitize_amount($amount, array('number_decimals' => $dp)) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', ''); |
|
538 | 534 | |
539 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
540 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
535 | + if (false !== strpos($formatted_amount, '.')) { |
|
536 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
541 | 537 | } |
542 | 538 | |
543 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
539 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
544 | 540 | } |
545 | 541 | |
546 | 542 | /** |
@@ -552,7 +548,7 @@ discard block |
||
552 | 548 | * |
553 | 549 | * @return string Date format string |
554 | 550 | */ |
555 | -function give_date_format( $date_context = '' ) { |
|
551 | +function give_date_format($date_context = '') { |
|
556 | 552 | /** |
557 | 553 | * Filter the date context |
558 | 554 | * |
@@ -573,19 +569,19 @@ discard block |
||
573 | 569 | * |
574 | 570 | * } |
575 | 571 | */ |
576 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
572 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
577 | 573 | |
578 | 574 | // Set date format to default date format. |
579 | - $date_format = get_option( 'date_format' ); |
|
575 | + $date_format = get_option('date_format'); |
|
580 | 576 | |
581 | 577 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
582 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
583 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
584 | - ? $date_format_contexts[ $date_context ] |
|
578 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
579 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
580 | + ? $date_format_contexts[$date_context] |
|
585 | 581 | : $date_format; |
586 | 582 | } |
587 | 583 | |
588 | - return apply_filters( 'give_date_format', $date_format ); |
|
584 | + return apply_filters('give_date_format', $date_format); |
|
589 | 585 | } |
590 | 586 | |
591 | 587 | /** |
@@ -599,8 +595,8 @@ discard block |
||
599 | 595 | * |
600 | 596 | * @return string |
601 | 597 | */ |
602 | -function give_get_cache_key( $action, $query_args ) { |
|
603 | - return Give_Cache::get_key( $action, $query_args ); |
|
598 | +function give_get_cache_key($action, $query_args) { |
|
599 | + return Give_Cache::get_key($action, $query_args); |
|
604 | 600 | } |
605 | 601 | |
606 | 602 | /** |
@@ -613,11 +609,11 @@ discard block |
||
613 | 609 | * |
614 | 610 | * @return string|array |
615 | 611 | */ |
616 | -function give_clean( $var ) { |
|
617 | - if ( is_array( $var ) ) { |
|
618 | - return array_map( 'give_clean', $var ); |
|
612 | +function give_clean($var) { |
|
613 | + if (is_array($var)) { |
|
614 | + return array_map('give_clean', $var); |
|
619 | 615 | } else { |
620 | - return is_scalar( $var ) ? sanitize_text_field( wp_unslash( $var ) ) : $var; |
|
616 | + return is_scalar($var) ? sanitize_text_field(wp_unslash($var)) : $var; |
|
621 | 617 | } |
622 | 618 | } |
623 | 619 | |
@@ -630,10 +626,10 @@ discard block |
||
630 | 626 | * |
631 | 627 | * @return int |
632 | 628 | */ |
633 | -function give_let_to_num( $size ) { |
|
634 | - $l = substr( $size, - 1 ); |
|
635 | - $ret = substr( $size, 0, - 1 ); |
|
636 | - switch ( strtoupper( $l ) ) { |
|
629 | +function give_let_to_num($size) { |
|
630 | + $l = substr($size, - 1); |
|
631 | + $ret = substr($size, 0, - 1); |
|
632 | + switch (strtoupper($l)) { |
|
637 | 633 | case 'P': |
638 | 634 | $ret *= 1024; |
639 | 635 | case 'T': |
@@ -660,22 +656,22 @@ discard block |
||
660 | 656 | * |
661 | 657 | * @return bool |
662 | 658 | */ |
663 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
659 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
664 | 660 | |
665 | 661 | // Verify nonce. |
666 | - $verify_nonce = wp_verify_nonce( $nonce, $action ); |
|
662 | + $verify_nonce = wp_verify_nonce($nonce, $action); |
|
667 | 663 | |
668 | 664 | // On ajax request send nonce verification status. |
669 | - if ( wp_doing_ajax() ) { |
|
665 | + if (wp_doing_ajax()) { |
|
670 | 666 | return $verify_nonce; |
671 | 667 | } |
672 | 668 | |
673 | - if ( ! $verify_nonce ) { |
|
669 | + if ( ! $verify_nonce) { |
|
674 | 670 | $wp_die_args = wp_parse_args( |
675 | 671 | $wp_die_args, |
676 | 672 | array( |
677 | - 'message' => __( 'Nonce verification has failed.', 'give' ), |
|
678 | - 'title' => __( 'Error', 'give' ), |
|
673 | + 'message' => __('Nonce verification has failed.', 'give'), |
|
674 | + 'title' => __('Error', 'give'), |
|
679 | 675 | 'args' => array( |
680 | 676 | 'response' => 403, |
681 | 677 | ), |
@@ -702,16 +698,16 @@ discard block |
||
702 | 698 | * |
703 | 699 | * @return bool |
704 | 700 | */ |
705 | -function give_verify_donation_form_nonce( $nonce = '', $form_id ) { |
|
701 | +function give_verify_donation_form_nonce($nonce = '', $form_id) { |
|
706 | 702 | |
707 | 703 | // Form nonce action. |
708 | 704 | $nonce_action = "give_donation_form_nonce_{$form_id}"; |
709 | 705 | |
710 | 706 | // Nonce validation. |
711 | - $verify_nonce = give_validate_nonce( $nonce, $nonce_action ); |
|
707 | + $verify_nonce = give_validate_nonce($nonce, $nonce_action); |
|
712 | 708 | |
713 | - if ( ! $verify_nonce ) { |
|
714 | - give_set_error( 'donation_form_nonce', __( 'Nonce verification has failed.', 'give' ) ); |
|
709 | + if ( ! $verify_nonce) { |
|
710 | + give_set_error('donation_form_nonce', __('Nonce verification has failed.', 'give')); |
|
715 | 711 | } |
716 | 712 | |
717 | 713 | return $verify_nonce; |
@@ -731,43 +727,43 @@ discard block |
||
731 | 727 | * |
732 | 728 | * @return mixed |
733 | 729 | */ |
734 | -function give_check_variable( $variable, $conditional = '', $default = false, $array_key_name = '' ) { |
|
730 | +function give_check_variable($variable, $conditional = '', $default = false, $array_key_name = '') { |
|
735 | 731 | // Get value from array if array key non empty. |
736 | - if( empty( $array_key_name ) ) { |
|
737 | - switch ( $conditional ) { |
|
732 | + if (empty($array_key_name)) { |
|
733 | + switch ($conditional) { |
|
738 | 734 | case 'isset_empty': |
739 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
735 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
740 | 736 | break; |
741 | 737 | |
742 | 738 | case 'empty': |
743 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
739 | + $variable = ! empty($variable) ? $variable : $default; |
|
744 | 740 | break; |
745 | 741 | |
746 | 742 | case 'null': |
747 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
743 | + $variable = ! is_null($variable) ? $variable : $default; |
|
748 | 744 | break; |
749 | 745 | |
750 | 746 | default: |
751 | - $variable = isset( $variable ) ? $variable : $default; |
|
747 | + $variable = isset($variable) ? $variable : $default; |
|
752 | 748 | } |
753 | 749 | } else { |
754 | - $isset = array_key_exists( $array_key_name, $variable ); |
|
750 | + $isset = array_key_exists($array_key_name, $variable); |
|
755 | 751 | |
756 | - switch ( $conditional ) { |
|
752 | + switch ($conditional) { |
|
757 | 753 | case 'isset_empty': |
758 | - $variable = ( $isset && ! empty( $variable[ $array_key_name ] ) ) ? $variable[ $array_key_name ] : $default; |
|
754 | + $variable = ($isset && ! empty($variable[$array_key_name])) ? $variable[$array_key_name] : $default; |
|
759 | 755 | break; |
760 | 756 | |
761 | 757 | case 'empty': |
762 | - $variable = ! empty( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
758 | + $variable = ! empty($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
763 | 759 | break; |
764 | 760 | |
765 | 761 | case 'null': |
766 | - $variable = $isset && ! is_null( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
762 | + $variable = $isset && ! is_null($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
767 | 763 | break; |
768 | 764 | |
769 | 765 | default: |
770 | - $variable = $isset && isset( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default; |
|
766 | + $variable = $isset && isset($variable[$array_key_name]) ? $variable[$array_key_name] : $default; |
|
771 | 767 | } |
772 | 768 | } |
773 | 769 |
@@ -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,9 +35,9 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
39 | - add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10, 1 ); |
|
40 | - add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard' ), 10 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | + add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10, 1); |
|
40 | + add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return void |
52 | 52 | */ |
53 | 53 | public function add_roles() { |
54 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
54 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
55 | 55 | 'read' => true, |
56 | 56 | 'edit_posts' => true, |
57 | 57 | 'delete_posts' => true, |
@@ -80,25 +80,25 @@ discard block |
||
80 | 80 | 'publish_posts' => true, |
81 | 81 | 'read_private_pages' => true, |
82 | 82 | 'read_private_posts' => true, |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
85 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
86 | 86 | 'read' => true, |
87 | 87 | 'edit_posts' => false, |
88 | 88 | 'delete_posts' => false, |
89 | - ) ); |
|
89 | + )); |
|
90 | 90 | |
91 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
91 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
92 | 92 | 'read' => true, |
93 | 93 | 'edit_posts' => true, |
94 | 94 | 'edit_pages' => true, |
95 | 95 | 'upload_files' => true, |
96 | 96 | 'delete_posts' => false, |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | |
99 | - add_role( 'give_donor', __( 'Give Donor', 'give' ), array( |
|
99 | + add_role('give_donor', __('Give Donor', 'give'), array( |
|
100 | 100 | 'read' => true, |
101 | - ) ); |
|
101 | + )); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -117,54 +117,54 @@ discard block |
||
117 | 117 | public function add_caps() { |
118 | 118 | global $wp_roles; |
119 | 119 | |
120 | - if ( class_exists( 'WP_Roles' ) ) { |
|
121 | - if ( ! isset( $wp_roles ) ) { |
|
120 | + if (class_exists('WP_Roles')) { |
|
121 | + if ( ! isset($wp_roles)) { |
|
122 | 122 | $wp_roles = new WP_Roles(); |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if ( is_object( $wp_roles ) ) { |
|
127 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
129 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
130 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
131 | - $wp_roles->add_cap( 'give_manager', 'view_give_payments' ); |
|
126 | + if (is_object($wp_roles)) { |
|
127 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
128 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
129 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
130 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
131 | + $wp_roles->add_cap('give_manager', 'view_give_payments'); |
|
132 | 132 | |
133 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
134 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
135 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
136 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
137 | - $wp_roles->add_cap( 'administrator', 'view_give_payments' ); |
|
133 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
134 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
135 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
136 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
137 | + $wp_roles->add_cap('administrator', 'view_give_payments'); |
|
138 | 138 | |
139 | 139 | // Add the main post type capabilities. |
140 | 140 | $capabilities = $this->get_core_caps(); |
141 | - foreach ( $capabilities as $cap_group ) { |
|
142 | - foreach ( $cap_group as $cap ) { |
|
143 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
144 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
141 | + foreach ($capabilities as $cap_group) { |
|
142 | + foreach ($cap_group as $cap) { |
|
143 | + $wp_roles->add_cap('administrator', $cap); |
|
144 | + $wp_roles->add_cap('give_manager', $cap); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Add Capabilities to Give Workers User Role. |
149 | - $wp_roles->add_cap( 'give_worker', 'edit_give_payments' ); |
|
150 | - $wp_roles->add_cap( 'give_worker', 'delete_give_forms' ); |
|
151 | - $wp_roles->add_cap( 'give_worker', 'delete_others_give_forms' ); |
|
152 | - $wp_roles->add_cap( 'give_worker', 'delete_private_give_forms' ); |
|
153 | - $wp_roles->add_cap( 'give_worker', 'delete_published_give_forms' ); |
|
154 | - $wp_roles->add_cap( 'give_worker', 'edit_give_forms' ); |
|
155 | - $wp_roles->add_cap( 'give_worker', 'edit_others_give_forms' ); |
|
156 | - $wp_roles->add_cap( 'give_worker', 'edit_private_give_forms' ); |
|
157 | - $wp_roles->add_cap( 'give_worker', 'edit_published_give_forms' ); |
|
158 | - $wp_roles->add_cap( 'give_worker', 'publish_give_forms' ); |
|
159 | - $wp_roles->add_cap( 'give_worker', 'read_private_give_forms' ); |
|
149 | + $wp_roles->add_cap('give_worker', 'edit_give_payments'); |
|
150 | + $wp_roles->add_cap('give_worker', 'delete_give_forms'); |
|
151 | + $wp_roles->add_cap('give_worker', 'delete_others_give_forms'); |
|
152 | + $wp_roles->add_cap('give_worker', 'delete_private_give_forms'); |
|
153 | + $wp_roles->add_cap('give_worker', 'delete_published_give_forms'); |
|
154 | + $wp_roles->add_cap('give_worker', 'edit_give_forms'); |
|
155 | + $wp_roles->add_cap('give_worker', 'edit_others_give_forms'); |
|
156 | + $wp_roles->add_cap('give_worker', 'edit_private_give_forms'); |
|
157 | + $wp_roles->add_cap('give_worker', 'edit_published_give_forms'); |
|
158 | + $wp_roles->add_cap('give_worker', 'publish_give_forms'); |
|
159 | + $wp_roles->add_cap('give_worker', 'read_private_give_forms'); |
|
160 | 160 | |
161 | 161 | // Add Capabilities to Give Accountant User Role. |
162 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
163 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
164 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
165 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
166 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
167 | - $wp_roles->add_cap( 'give_accountant', 'view_give_payments' ); |
|
162 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
163 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
164 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
165 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
166 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
167 | + $wp_roles->add_cap('give_accountant', 'view_give_payments'); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | public function get_core_caps() { |
183 | 183 | $capabilities = array(); |
184 | 184 | |
185 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
185 | + $capability_types = array('give_form', 'give_payment'); |
|
186 | 186 | |
187 | - foreach ( $capability_types as $capability_type ) { |
|
188 | - $capabilities[ $capability_type ] = array( |
|
187 | + foreach ($capability_types as $capability_type) { |
|
188 | + $capabilities[$capability_type] = array( |
|
189 | 189 | // Post type. |
190 | 190 | "edit_{$capability_type}", |
191 | 191 | "read_{$capability_type}", |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return array $caps Meta capabilities. |
233 | 233 | */ |
234 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
234 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
235 | 235 | |
236 | - switch ( $cap ) { |
|
236 | + switch ($cap) { |
|
237 | 237 | |
238 | 238 | case 'view_give_form_stats' : |
239 | 239 | |
240 | - if ( empty( $args[0] ) ) { |
|
240 | + if (empty($args[0])) { |
|
241 | 241 | break; |
242 | 242 | } |
243 | 243 | |
244 | - $form = get_post( $args[0] ); |
|
245 | - if ( empty( $form ) ) { |
|
244 | + $form = get_post($args[0]); |
|
245 | + if (empty($form)) { |
|
246 | 246 | break; |
247 | 247 | } |
248 | 248 | |
249 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
249 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
250 | 250 | $caps = array(); |
251 | 251 | } |
252 | 252 | |
@@ -273,57 +273,57 @@ discard block |
||
273 | 273 | |
274 | 274 | global $wp_roles; |
275 | 275 | |
276 | - if ( class_exists( 'WP_Roles' ) ) { |
|
277 | - if ( ! isset( $wp_roles ) ) { |
|
276 | + if (class_exists('WP_Roles')) { |
|
277 | + if ( ! isset($wp_roles)) { |
|
278 | 278 | $wp_roles = new WP_Roles(); |
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | - if ( is_object( $wp_roles ) ) { |
|
282 | + if (is_object($wp_roles)) { |
|
283 | 283 | // Give Manager Capabilities. |
284 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
285 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
286 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
287 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
284 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
285 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
286 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
287 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
288 | 288 | |
289 | 289 | // Site Administrator Capabilities. |
290 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
291 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
292 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
293 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
294 | - $wp_roles->remove_cap( 'administrator', 'view_give_payments' ); |
|
290 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
291 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
292 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
293 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
294 | + $wp_roles->remove_cap('administrator', 'view_give_payments'); |
|
295 | 295 | |
296 | 296 | // Remove the Main Post Type Capabilities. |
297 | 297 | $capabilities = $this->get_core_caps(); |
298 | 298 | |
299 | - foreach ( $capabilities as $cap_group ) { |
|
300 | - foreach ( $cap_group as $cap ) { |
|
301 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
302 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
299 | + foreach ($capabilities as $cap_group) { |
|
300 | + foreach ($cap_group as $cap) { |
|
301 | + $wp_roles->remove_cap('give_manager', $cap); |
|
302 | + $wp_roles->remove_cap('administrator', $cap); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | 307 | // Remove capabilities from the Give Worker role. |
308 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_payments' ); |
|
309 | - $wp_roles->remove_cap( 'give_worker', 'delete_give_forms' ); |
|
310 | - $wp_roles->remove_cap( 'give_worker', 'delete_others_give_forms' ); |
|
311 | - $wp_roles->remove_cap( 'give_worker', 'delete_private_give_forms' ); |
|
312 | - $wp_roles->remove_cap( 'give_worker', 'delete_published_give_forms' ); |
|
313 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_forms' ); |
|
314 | - $wp_roles->remove_cap( 'give_worker', 'edit_others_give_forms' ); |
|
315 | - $wp_roles->remove_cap( 'give_worker', 'edit_private_give_forms' ); |
|
316 | - $wp_roles->remove_cap( 'give_worker', 'edit_published_give_forms' ); |
|
317 | - $wp_roles->remove_cap( 'give_worker', 'publish_give_forms' ); |
|
318 | - $wp_roles->remove_cap( 'give_worker', 'read_private_give_forms' ); |
|
308 | + $wp_roles->remove_cap('give_worker', 'edit_give_payments'); |
|
309 | + $wp_roles->remove_cap('give_worker', 'delete_give_forms'); |
|
310 | + $wp_roles->remove_cap('give_worker', 'delete_others_give_forms'); |
|
311 | + $wp_roles->remove_cap('give_worker', 'delete_private_give_forms'); |
|
312 | + $wp_roles->remove_cap('give_worker', 'delete_published_give_forms'); |
|
313 | + $wp_roles->remove_cap('give_worker', 'edit_give_forms'); |
|
314 | + $wp_roles->remove_cap('give_worker', 'edit_others_give_forms'); |
|
315 | + $wp_roles->remove_cap('give_worker', 'edit_private_give_forms'); |
|
316 | + $wp_roles->remove_cap('give_worker', 'edit_published_give_forms'); |
|
317 | + $wp_roles->remove_cap('give_worker', 'publish_give_forms'); |
|
318 | + $wp_roles->remove_cap('give_worker', 'read_private_give_forms'); |
|
319 | 319 | |
320 | 320 | // Remove Capabilities from Give Accountant User Role. |
321 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
322 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
323 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
324 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
325 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' ); |
|
326 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_payments' ); |
|
321 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
322 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
323 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
324 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
325 | + $wp_roles->remove_cap('give_accountant', 'edit_give_payments'); |
|
326 | + $wp_roles->remove_cap('give_accountant', 'view_give_payments'); |
|
327 | 327 | |
328 | 328 | } |
329 | 329 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $current_user = wp_get_current_user(); |
347 | 347 | |
348 | 348 | // If user with "Give Accountant" user role is logged-in . |
349 | - if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) { |
|
349 | + if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) { |
|
350 | 350 | |
351 | 351 | // Return false, means no prevention. |
352 | 352 | return false; |
@@ -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 | |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function __construct() { |
104 | 104 | |
105 | - if ( 'none' === $this->get_template() ) { |
|
105 | + if ('none' === $this->get_template()) { |
|
106 | 106 | $this->html = false; |
107 | 107 | } |
108 | 108 | |
109 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
110 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
109 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
110 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param $key |
120 | 120 | * @param $value |
121 | 121 | */ |
122 | - public function __set( $key, $value ) { |
|
122 | + public function __set($key, $value) { |
|
123 | 123 | $this->$key = $value; |
124 | 124 | } |
125 | 125 | |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | 131 | public function get_from_name() { |
132 | - if ( ! $this->from_name ) { |
|
133 | - $this->from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
132 | + if ( ! $this->from_name) { |
|
133 | + $this->from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
134 | 134 | } |
135 | 135 | |
136 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
136 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @since 1.0 |
143 | 143 | */ |
144 | 144 | public function get_from_address() { |
145 | - if ( ! $this->from_address ) { |
|
146 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
145 | + if ( ! $this->from_address) { |
|
146 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
147 | 147 | } |
148 | 148 | |
149 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
149 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | 157 | public function get_content_type() { |
158 | - if ( ! $this->content_type ) { |
|
158 | + if ( ! $this->content_type) { |
|
159 | 159 | $this->content_type = $this->html |
160 | - ? apply_filters( 'give_email_default_content_type', 'text/html', $this ) |
|
160 | + ? apply_filters('give_email_default_content_type', 'text/html', $this) |
|
161 | 161 | : 'text/plain'; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
164 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | * @since 1.0 |
171 | 171 | */ |
172 | 172 | public function get_headers() { |
173 | - if ( ! $this->headers ) { |
|
173 | + if ( ! $this->headers) { |
|
174 | 174 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
175 | 175 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
176 | 176 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
177 | 177 | } |
178 | 178 | |
179 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
179 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function get_templates() { |
188 | 188 | $templates = array( |
189 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
190 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
189 | + 'default' => esc_html__('Default Template', 'give'), |
|
190 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
191 | 191 | ); |
192 | 192 | |
193 | - return apply_filters( 'give_email_templates', $templates ); |
|
193 | + return apply_filters('give_email_templates', $templates); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @since 1.0 |
200 | 200 | */ |
201 | 201 | public function get_template() { |
202 | - if ( ! $this->template ) { |
|
203 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
202 | + if ( ! $this->template) { |
|
203 | + $this->template = give_get_option('email_template', 'default'); |
|
204 | 204 | } |
205 | 205 | |
206 | - return apply_filters( 'give_email_template', $this->template ); |
|
206 | + return apply_filters('give_email_template', $this->template); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @since 1.0 |
213 | 213 | */ |
214 | 214 | public function get_heading() { |
215 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
215 | + return apply_filters('give_email_heading', $this->heading); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return mixed |
224 | 224 | */ |
225 | - public function parse_tags( $content ) { |
|
225 | + public function parse_tags($content) { |
|
226 | 226 | return $content; |
227 | 227 | } |
228 | 228 | |
@@ -235,34 +235,34 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public function build_email( $message ) { |
|
238 | + public function build_email($message) { |
|
239 | 239 | |
240 | - if ( false === $this->html ) { |
|
240 | + if (false === $this->html) { |
|
241 | 241 | |
242 | 242 | // Added Replacement check to simply behaviour of anchor tags. |
243 | 243 | $pattern = '/<a.+?href\=(?:["|\'])(.+?)(?:["|\']).*?>(.+?)<\/a>/i'; |
244 | 244 | $message = preg_replace_callback( |
245 | 245 | $pattern, |
246 | - function ( $return ) { |
|
247 | - if ( $return[1] !== $return[2] ) { |
|
246 | + function($return) { |
|
247 | + if ($return[1] !== $return[2]) { |
|
248 | 248 | return "{$return[2]} ( {$return[1]} )"; |
249 | 249 | } |
250 | 250 | |
251 | - return trailingslashit( $return[1] ); |
|
251 | + return trailingslashit($return[1]); |
|
252 | 252 | }, |
253 | 253 | $message |
254 | 254 | ); |
255 | 255 | |
256 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
256 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
257 | 257 | } |
258 | 258 | |
259 | - $message = $this->text_to_html( $message ); |
|
259 | + $message = $this->text_to_html($message); |
|
260 | 260 | |
261 | 261 | $template = $this->get_template(); |
262 | 262 | |
263 | 263 | ob_start(); |
264 | 264 | |
265 | - give_get_template_part( 'emails/header', $template, true ); |
|
265 | + give_get_template_part('emails/header', $template, true); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Fires in the email head. |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @param Give_Emails $this The email object. |
273 | 273 | */ |
274 | - do_action( 'give_email_header', $this ); |
|
274 | + do_action('give_email_header', $this); |
|
275 | 275 | |
276 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
276 | + if (has_action('give_email_template_'.$template)) { |
|
277 | 277 | /** |
278 | 278 | * Fires in a specific email template. |
279 | 279 | * |
280 | 280 | * @since 1.0 |
281 | 281 | */ |
282 | - do_action( "give_email_template_{$template}" ); |
|
282 | + do_action("give_email_template_{$template}"); |
|
283 | 283 | } else { |
284 | - give_get_template_part( 'emails/body', $template, true ); |
|
284 | + give_get_template_part('emails/body', $template, true); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @param Give_Emails $this The email object. |
293 | 293 | */ |
294 | - do_action( 'give_email_body', $this ); |
|
294 | + do_action('give_email_body', $this); |
|
295 | 295 | |
296 | - give_get_template_part( 'emails/footer', $template, true ); |
|
296 | + give_get_template_part('emails/footer', $template, true); |
|
297 | 297 | |
298 | 298 | /** |
299 | 299 | * Fires in the email footer. |
@@ -302,26 +302,26 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @param Give_Emails $this The email object. |
304 | 304 | */ |
305 | - do_action( 'give_email_footer', $this ); |
|
305 | + do_action('give_email_footer', $this); |
|
306 | 306 | |
307 | 307 | $body = ob_get_clean(); |
308 | 308 | |
309 | 309 | // Email tag. |
310 | - $message = str_replace( '{email}', $message, $body ); |
|
310 | + $message = str_replace('{email}', $message, $body); |
|
311 | 311 | |
312 | - $header_img = Give_Email_Notification_Util::get_email_logo( $this->form_id ); |
|
312 | + $header_img = Give_Email_Notification_Util::get_email_logo($this->form_id); |
|
313 | 313 | |
314 | - if ( ! empty( $header_img ) ) { |
|
314 | + if ( ! empty($header_img)) { |
|
315 | 315 | $header_img = sprintf( |
316 | 316 | '<div id="template_header_image"><p style="margin-top:0;"><img style="max-width:450px;" src="%1$s" alt="%2$s" /></p></div>', |
317 | - esc_url( $header_img ), |
|
318 | - get_bloginfo( 'name' ) |
|
317 | + esc_url($header_img), |
|
318 | + get_bloginfo('name') |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | |
322 | - $message = str_replace( '{email_logo}', $header_img, $message ); |
|
322 | + $message = str_replace('{email_logo}', $header_img, $message); |
|
323 | 323 | |
324 | - return apply_filters( 'give_email_message', $message, $this ); |
|
324 | + return apply_filters('give_email_message', $message, $this); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return bool |
336 | 336 | */ |
337 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
337 | + public function send($to, $subject, $message, $attachments = '') { |
|
338 | 338 | |
339 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
340 | - give_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
339 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
340 | + give_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
341 | 341 | |
342 | 342 | return false; |
343 | 343 | } |
@@ -349,16 +349,16 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @param Give_Emails $this The email object. |
351 | 351 | */ |
352 | - do_action( 'give_email_send_before', $this ); |
|
352 | + do_action('give_email_send_before', $this); |
|
353 | 353 | |
354 | - $subject = $this->parse_tags( $subject ); |
|
355 | - $message = $this->parse_tags( $message ); |
|
354 | + $subject = $this->parse_tags($subject); |
|
355 | + $message = $this->parse_tags($message); |
|
356 | 356 | |
357 | - $message = $this->build_email( $message ); |
|
357 | + $message = $this->build_email($message); |
|
358 | 358 | |
359 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
359 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
360 | 360 | |
361 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
361 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Fires after sending an email. |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @param Give_Emails $this The email object. |
369 | 369 | */ |
370 | - do_action( 'give_email_send_after', $this ); |
|
370 | + do_action('give_email_send_after', $this); |
|
371 | 371 | |
372 | 372 | return $sent; |
373 | 373 | |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | * @since 1.0 |
380 | 380 | */ |
381 | 381 | public function send_before() { |
382 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
383 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
384 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
382 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
383 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
384 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -390,9 +390,9 @@ discard block |
||
390 | 390 | * @since 1.0 |
391 | 391 | */ |
392 | 392 | public function send_after() { |
393 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
394 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
395 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
393 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
394 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
395 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
396 | 396 | |
397 | 397 | // Reset email related params. |
398 | 398 | $this->heading = ''; |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @since 1.0 |
408 | 408 | */ |
409 | - public function text_to_html( $message ) { |
|
409 | + public function text_to_html($message) { |
|
410 | 410 | |
411 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
412 | - $message = wpautop( $message ); |
|
411 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
412 | + $message = wpautop($message); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | return $message; |
@@ -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,35 +23,35 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string Donation form. |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | static $count = 1; |
30 | 30 | |
31 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
31 | + $form_id = is_object($post) ? $post->ID : 0; |
|
32 | 32 | |
33 | - if ( isset( $args['id'] ) ) { |
|
33 | + if (isset($args['id'])) { |
|
34 | 34 | $form_id = $args['id']; |
35 | 35 | } |
36 | 36 | |
37 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
37 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
38 | 38 | 'form_id' => $form_id, |
39 | - ) ); |
|
39 | + )); |
|
40 | 40 | |
41 | - $args = wp_parse_args( $args, $defaults ); |
|
41 | + $args = wp_parse_args($args, $defaults); |
|
42 | 42 | |
43 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
43 | + $form = new Give_Donate_Form($args['form_id']); |
|
44 | 44 | |
45 | 45 | // Bail out, if no form ID. |
46 | - if ( empty( $form->ID ) ) { |
|
46 | + if (empty($form->ID)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $args['id_prefix'] = "{$form_id}-{$count}"; |
51 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
51 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
52 | 52 | |
53 | 53 | $form_action = add_query_arg( |
54 | - apply_filters( 'give_form_action_args', array( |
|
54 | + apply_filters('give_form_action_args', array( |
|
55 | 55 | 'payment-mode' => $payment_mode, |
56 | 56 | ) |
57 | 57 | ), |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | |
61 | 61 | // Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
62 | 62 | if ( |
63 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
64 | - || ( 'trash' === $form->post_status ) |
|
63 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
64 | + || ('trash' === $form->post_status) |
|
65 | 65 | ) { |
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
69 | 69 | // Get the form wrap CSS classes. |
70 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
70 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
71 | 71 | |
72 | 72 | // Get the <form> tag wrap CSS classes. |
73 | - $form_classes = $form->get_form_classes( $args ); |
|
73 | + $form_classes = $form->get_form_classes($args); |
|
74 | 74 | |
75 | 75 | ob_start(); |
76 | 76 | |
@@ -82,21 +82,21 @@ discard block |
||
82 | 82 | * @param int $form_id The form ID. |
83 | 83 | * @param array $args An array of form arguments. |
84 | 84 | */ |
85 | - do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
|
85 | + do_action('give_pre_form_output', $form->ID, $args, $form); |
|
86 | 86 | |
87 | 87 | ?> |
88 | 88 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
89 | 89 | <?php |
90 | - if ( $form->is_close_donation_form() ) { |
|
90 | + if ($form->is_close_donation_form()) { |
|
91 | 91 | |
92 | - $form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ) : ''; |
|
92 | + $form_title = ! is_singular('give_forms') ? apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>') : ''; |
|
93 | 93 | |
94 | 94 | // Get Goal thank you message. |
95 | - $goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
96 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
95 | + $goal_achieved_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
96 | + $goal_achieved_message = ! empty($goal_achieved_message) ? $form_title.apply_filters('the_content', $goal_achieved_message) : ''; |
|
97 | 97 | |
98 | 98 | // Print thank you message. |
99 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
99 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID, $form); |
|
100 | 100 | |
101 | 101 | } else { |
102 | 102 | /** |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * 1. if show_title params set to true |
105 | 105 | * 2. if admin set form display_style to button |
106 | 106 | */ |
107 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
107 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
108 | 108 | if ( |
109 | 109 | ( |
110 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
111 | - || ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) ) |
|
110 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
111 | + || ('button' === get_post_meta($form_id, '_give_payment_display', true)) |
|
112 | 112 | ) |
113 | - && ! doing_action( 'give_single_form_summary' ) |
|
113 | + && ! doing_action('give_single_form_summary') |
|
114 | 114 | ) { |
115 | 115 | echo $form_title; |
116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * @param array $args An array of form arguments. |
125 | 125 | * @param Give_Donate_Form $form Form object. |
126 | 126 | */ |
127 | - do_action( 'give_pre_form', $form->ID, $args, $form ); |
|
127 | + do_action('give_pre_form', $form->ID, $args, $form); |
|
128 | 128 | |
129 | 129 | // Set form html tags. |
130 | 130 | $form_html_tags = array( |
131 | 131 | 'id' => "give-form-{$args['id_prefix']}", |
132 | 132 | 'class' => $form_classes, |
133 | - 'action' => esc_url_raw( $form_action ), |
|
133 | + 'action' => esc_url_raw($form_action), |
|
134 | 134 | 'data-id' => $args['id_prefix'], |
135 | 135 | ); |
136 | 136 | |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param array $form_html_tags Array of form html tags. |
143 | 143 | * @param Give_Donate_Form $form Form object. |
144 | 144 | */ |
145 | - $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
|
145 | + $form_html_tags = apply_filters('give_form_html_tags', (array) $form_html_tags, $form); |
|
146 | 146 | ?> |
147 | - <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
147 | + <form <?php echo give_get_attribute_str($form_html_tags); ?> method="post"> |
|
148 | 148 | <!-- The following field is for robots only, invisible to humans: --> |
149 | 149 | <span class="give-hidden" style="display: none !important;"> |
150 | 150 | <label for="give-form-honeypot-<?php echo $form_id; ?>"></label> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param array $args An array of form arguments. |
163 | 163 | * @param Give_Donate_Form $form Form object. |
164 | 164 | */ |
165 | - do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
|
165 | + do_action('give_donation_form_top', $form->ID, $args, $form); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Fires while outputting donation form, for payment gateway fields. |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param array $args An array of form arguments. |
174 | 174 | * @param Give_Donate_Form $form Form object. |
175 | 175 | */ |
176 | - do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
|
176 | + do_action('give_payment_mode_select', $form->ID, $args, $form); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Fires while outputting donation form, after all other fields. |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param array $args An array of form arguments. |
185 | 185 | * @param Give_Donate_Form $form Form object. |
186 | 186 | */ |
187 | - do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
|
187 | + do_action('give_donation_form_bottom', $form->ID, $args, $form); |
|
188 | 188 | |
189 | 189 | ?> |
190 | 190 | </form> |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | * @param array $args An array of form arguments. |
200 | 200 | * @param Give_Donate_Form $form Form object. |
201 | 201 | */ |
202 | - do_action( 'give_post_form', $form->ID, $args, $form ); |
|
202 | + do_action('give_post_form', $form->ID, $args, $form); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | ?> |
206 | 206 | |
207 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
207 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
208 | 208 | <?php |
209 | 209 | |
210 | 210 | /** |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * @param int $form_id The form ID. |
216 | 216 | * @param array $args An array of form arguments. |
217 | 217 | */ |
218 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
218 | + do_action('give_post_form_output', $form->ID, $args); |
|
219 | 219 | |
220 | 220 | $final_output = ob_get_clean(); |
221 | - $count ++; |
|
221 | + $count++; |
|
222 | 222 | |
223 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
223 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string |
239 | 239 | */ |
240 | -function give_show_purchase_form( $form_id, $args ) { |
|
240 | +function give_show_purchase_form($form_id, $args) { |
|
241 | 241 | |
242 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
242 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
243 | 243 | |
244 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
244 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
245 | 245 | $form_id = $_POST['give_form_id']; |
246 | 246 | } |
247 | 247 | |
@@ -250,33 +250,33 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @since 1.7 |
252 | 252 | */ |
253 | - do_action( 'give_payment_fields_top', $form_id ); |
|
253 | + do_action('give_payment_fields_top', $form_id); |
|
254 | 254 | |
255 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
255 | + if (give_can_checkout() && isset($form_id)) { |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Fires while displaying donation form, before registration login. |
259 | 259 | * |
260 | 260 | * @since 1.7 |
261 | 261 | */ |
262 | - do_action( 'give_donation_form_before_register_login', $form_id, $args ); |
|
262 | + do_action('give_donation_form_before_register_login', $form_id, $args); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Fire when register/login form fields render. |
266 | 266 | * |
267 | 267 | * @since 1.7 |
268 | 268 | */ |
269 | - do_action( 'give_donation_form_register_login_fields', $form_id, $args ); |
|
269 | + do_action('give_donation_form_register_login_fields', $form_id, $args); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Fire when credit card form fields render. |
273 | 273 | * |
274 | 274 | * @since 1.7 |
275 | 275 | */ |
276 | - do_action( 'give_donation_form_before_cc_form', $form_id, $args ); |
|
276 | + do_action('give_donation_form_before_cc_form', $form_id, $args); |
|
277 | 277 | |
278 | 278 | // Load the credit card form and allow gateways to load their own if they wish. |
279 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
279 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
280 | 280 | /** |
281 | 281 | * Fires while displaying donation form, credit card form fields for a given gateway. |
282 | 282 | * |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param int $form_id The form ID. |
286 | 286 | */ |
287 | - do_action( "give_{$payment_mode}_cc_form", $form_id, $args ); |
|
287 | + do_action("give_{$payment_mode}_cc_form", $form_id, $args); |
|
288 | 288 | } else { |
289 | 289 | /** |
290 | 290 | * Fires while displaying donation form, credit card form fields. |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param int $form_id The form ID. |
295 | 295 | */ |
296 | - do_action( 'give_cc_form', $form_id, $args ); |
|
296 | + do_action('give_cc_form', $form_id, $args); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.7 |
303 | 303 | */ |
304 | - do_action( 'give_donation_form_after_cc_form', $form_id, $args ); |
|
304 | + do_action('give_donation_form_after_cc_form', $form_id, $args); |
|
305 | 305 | |
306 | 306 | } else { |
307 | 307 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @since 1.7 |
311 | 311 | */ |
312 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
312 | + do_action('give_donation_form_no_access', $form_id); |
|
313 | 313 | |
314 | 314 | } |
315 | 315 | |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @since 1.7 |
320 | 320 | */ |
321 | - do_action( 'give_payment_fields_bottom', $form_id, $args ); |
|
321 | + do_action('give_payment_fields_bottom', $form_id, $args); |
|
322 | 322 | } |
323 | 323 | |
324 | -add_action( 'give_donation_form', 'give_show_purchase_form', 10, 2 ); |
|
324 | +add_action('give_donation_form', 'give_show_purchase_form', 10, 2); |
|
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Give Show Login/Register Form Fields. |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return void |
334 | 334 | */ |
335 | -function give_show_register_login_fields( $form_id ) { |
|
335 | +function give_show_register_login_fields($form_id) { |
|
336 | 336 | |
337 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
337 | + $show_register_form = give_show_login_register_option($form_id); |
|
338 | 338 | |
339 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
339 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
340 | 340 | ?> |
341 | 341 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
342 | 342 | <?php |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @since 1.7 |
347 | 347 | */ |
348 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
348 | + do_action('give_donation_form_register_fields', $form_id); |
|
349 | 349 | ?> |
350 | 350 | </div> |
351 | 351 | <?php |
352 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
352 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
353 | 353 | ?> |
354 | 354 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
355 | 355 | <?php |
@@ -358,23 +358,23 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.7 |
360 | 360 | */ |
361 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
361 | + do_action('give_donation_form_login_fields', $form_id); |
|
362 | 362 | ?> |
363 | 363 | </div> |
364 | 364 | <?php |
365 | 365 | endif; |
366 | 366 | |
367 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
367 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
368 | 368 | /** |
369 | 369 | * Fire when user info render. |
370 | 370 | * |
371 | 371 | * @since 1.7 |
372 | 372 | */ |
373 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
373 | + do_action('give_donation_form_after_user_info', $form_id); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
377 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Donation Amount Field. |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return void |
391 | 391 | */ |
392 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
392 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
393 | 393 | |
394 | 394 | $give_options = give_get_settings(); |
395 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
396 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
397 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
398 | - $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
|
399 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
400 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
|
401 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
395 | + $variable_pricing = give_has_variable_prices($form_id); |
|
396 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
397 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
398 | + $symbol = give_currency_symbol(give_get_currency($form_id, $args)); |
|
399 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
400 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false, 'currency' => give_get_currency($form_id))); |
|
401 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
402 | 402 | |
403 | 403 | /** |
404 | 404 | * Fires while displaying donation form, before donation level fields. |
@@ -408,20 +408,20 @@ discard block |
||
408 | 408 | * @param int $form_id The form ID. |
409 | 409 | * @param array $args An array of form arguments. |
410 | 410 | */ |
411 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
411 | + do_action('give_before_donation_levels', $form_id, $args); |
|
412 | 412 | |
413 | 413 | //Set Price, No Custom Amount Allowed means hidden price field |
414 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
414 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
415 | 415 | ?> |
416 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
416 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
417 | 417 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
418 | 418 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
419 | 419 | <div class="set-price give-donation-amount form-row-wide"> |
420 | - <?php if ( $currency_position == 'before' ) { |
|
420 | + <?php if ($currency_position == 'before') { |
|
421 | 421 | echo $currency_output; |
422 | 422 | } ?> |
423 | 423 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
424 | - <?php if ( $currency_position == 'after' ) { |
|
424 | + <?php if ($currency_position == 'after') { |
|
425 | 425 | echo $currency_output; |
426 | 426 | } ?> |
427 | 427 | </div> |
@@ -431,13 +431,13 @@ discard block |
||
431 | 431 | ?> |
432 | 432 | <div class="give-total-wrap"> |
433 | 433 | <div class="give-donation-amount form-row-wide"> |
434 | - <?php if ( $currency_position == 'before' ) { |
|
434 | + <?php if ($currency_position == 'before') { |
|
435 | 435 | echo $currency_output; |
436 | 436 | } ?> |
437 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
437 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
438 | 438 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
439 | 439 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
440 | - <?php if ( $currency_position == 'after' ) { |
|
440 | + <?php if ($currency_position == 'after') { |
|
441 | 441 | echo $currency_output; |
442 | 442 | } ?> |
443 | 443 | </div> |
@@ -452,16 +452,16 @@ discard block |
||
452 | 452 | * @param int $form_id The form ID. |
453 | 453 | * @param array $args An array of form arguments. |
454 | 454 | */ |
455 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
455 | + do_action('give_after_donation_amount', $form_id, $args); |
|
456 | 456 | |
457 | 457 | //Custom Amount Text |
458 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
458 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
459 | 459 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
460 | 460 | <?php } |
461 | 461 | |
462 | 462 | //Output Variable Pricing Levels. |
463 | - if ( $variable_pricing ) { |
|
464 | - give_output_levels( $form_id ); |
|
463 | + if ($variable_pricing) { |
|
464 | + give_output_levels($form_id); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -472,10 +472,10 @@ discard block |
||
472 | 472 | * @param int $form_id The form ID. |
473 | 473 | * @param array $args An array of form arguments. |
474 | 474 | */ |
475 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
475 | + do_action('give_after_donation_levels', $form_id, $args); |
|
476 | 476 | } |
477 | 477 | |
478 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
478 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -486,48 +486,48 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @return string Donation levels. |
488 | 488 | */ |
489 | -function give_output_levels( $form_id ) { |
|
489 | +function give_output_levels($form_id) { |
|
490 | 490 | |
491 | 491 | //Get variable pricing. |
492 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
493 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
494 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
495 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
492 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
493 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
494 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
495 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
496 | 496 | |
497 | - if ( empty( $custom_amount_text ) ) { |
|
498 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
497 | + if (empty($custom_amount_text)) { |
|
498 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | $output = ''; |
502 | 502 | |
503 | - switch ( $display_style ) { |
|
503 | + switch ($display_style) { |
|
504 | 504 | case 'buttons': |
505 | 505 | |
506 | 506 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
507 | 507 | |
508 | - foreach ( $prices as $price ) { |
|
509 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
510 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
508 | + foreach ($prices as $price) { |
|
509 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
510 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
511 | 511 | |
512 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
512 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
513 | 513 | 'sanitize' => false, |
514 | - 'currency' => give_get_currency( $form_id ), |
|
515 | - ) ); |
|
514 | + 'currency' => give_get_currency($form_id), |
|
515 | + )); |
|
516 | 516 | |
517 | 517 | $output .= sprintf( |
518 | 518 | '<li><button type="button" data-price-id="%1$s" class="%2$s" value="%3$s" data-default="%4$s">%5$s</button></li>', |
519 | 519 | $price['_give_id']['level_id'], |
520 | 520 | $level_classes, |
521 | 521 | $formatted_amount, |
522 | - array_key_exists( '_give_default', $price ) ? 1 : 0, |
|
522 | + array_key_exists('_give_default', $price) ? 1 : 0, |
|
523 | 523 | $level_text |
524 | 524 | ); |
525 | 525 | } |
526 | 526 | |
527 | 527 | //Custom Amount. |
528 | 528 | if ( |
529 | - give_is_setting_enabled( $custom_amount ) |
|
530 | - && ! empty( $custom_amount_text ) |
|
529 | + give_is_setting_enabled($custom_amount) |
|
530 | + && ! empty($custom_amount_text) |
|
531 | 531 | ) { |
532 | 532 | |
533 | 533 | $output .= sprintf( |
@@ -544,30 +544,30 @@ discard block |
||
544 | 544 | |
545 | 545 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
546 | 546 | |
547 | - foreach ( $prices as $price ) { |
|
548 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
549 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
547 | + foreach ($prices as $price) { |
|
548 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
549 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
550 | 550 | |
551 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
551 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
552 | 552 | 'sanitize' => false, |
553 | - 'currency' => give_get_currency( $form_id ), |
|
554 | - ) ); |
|
553 | + 'currency' => give_get_currency($form_id), |
|
554 | + )); |
|
555 | 555 | |
556 | 556 | $output .= sprintf( |
557 | 557 | '<li><input type="radio" data-price-id="%1$s" class="%2$s" value="%3$s" name="give-radio-donation-level" id="give-radio-level-%1$s" %4$s data-default="%5$s"><label for="give-radio-level-%1$s">%6$s</label></li>', |
558 | 558 | $price['_give_id']['level_id'], |
559 | 559 | $level_classes, |
560 | 560 | $formatted_amount, |
561 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ), |
|
562 | - array_key_exists( '_give_default', $price ) ? 1 : 0, |
|
561 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : ''), |
|
562 | + array_key_exists('_give_default', $price) ? 1 : 0, |
|
563 | 563 | $level_text |
564 | 564 | ); |
565 | 565 | } |
566 | 566 | |
567 | 567 | //Custom Amount. |
568 | 568 | if ( |
569 | - give_is_setting_enabled( $custom_amount ) |
|
570 | - && ! empty( $custom_amount_text ) |
|
569 | + give_is_setting_enabled($custom_amount) |
|
570 | + && ! empty($custom_amount_text) |
|
571 | 571 | ) { |
572 | 572 | $output .= sprintf( |
573 | 573 | '<li><input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom"><label for="give-radio-level-custom">%1$s</label></li>', |
@@ -581,32 +581,32 @@ discard block |
||
581 | 581 | |
582 | 582 | case 'dropdown': |
583 | 583 | |
584 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
585 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
584 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
585 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
586 | 586 | |
587 | 587 | //first loop through prices. |
588 | - foreach ( $prices as $price ) { |
|
589 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
590 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
588 | + foreach ($prices as $price) { |
|
589 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
590 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
591 | 591 | |
592 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
592 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
593 | 593 | 'sanitize' => false, |
594 | - 'currency' => give_get_currency( $form_id ), |
|
595 | - ) ); |
|
594 | + 'currency' => give_get_currency($form_id), |
|
595 | + )); |
|
596 | 596 | |
597 | 597 | $output .= sprintf( |
598 | 598 | '<option data-price-id="%1$s" class="%2$s" value="%3$s" %4$s data-default="%5$s">%6$s</option>', |
599 | 599 | $price['_give_id']['level_id'], |
600 | 600 | $level_classes, |
601 | 601 | $formatted_amount, |
602 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ), |
|
603 | - array_key_exists( '_give_default', $price ) ? 1 : 0, |
|
602 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : ''), |
|
603 | + array_key_exists('_give_default', $price) ? 1 : 0, |
|
604 | 604 | $level_text |
605 | 605 | ); |
606 | 606 | } |
607 | 607 | |
608 | 608 | //Custom Amount. |
609 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
609 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
610 | 610 | $output .= sprintf( |
611 | 611 | '<option data-price-id="custom" class="give-donation-level-custom" value="custom">%1$s</option>', |
612 | 612 | $custom_amount_text |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | break; |
619 | 619 | } |
620 | 620 | |
621 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
621 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -633,27 +633,27 @@ discard block |
||
633 | 633 | * |
634 | 634 | * @return string Checkout button. |
635 | 635 | */ |
636 | -function give_display_checkout_button( $form_id, $args ) { |
|
636 | +function give_display_checkout_button($form_id, $args) { |
|
637 | 637 | |
638 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
638 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
639 | 639 | ? $args['display_style'] |
640 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
640 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
641 | 641 | |
642 | - if ( 'button' === $display_option ) { |
|
642 | + if ('button' === $display_option) { |
|
643 | 643 | $display_option = 'modal'; |
644 | - } elseif ( $display_option === 'onpage' ) { |
|
644 | + } elseif ($display_option === 'onpage') { |
|
645 | 645 | return ''; |
646 | 646 | } |
647 | 647 | |
648 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
649 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
648 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
649 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
650 | 650 | |
651 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
651 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
652 | 652 | |
653 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
653 | + echo apply_filters('give_display_checkout_button', $output); |
|
654 | 654 | } |
655 | 655 | |
656 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
656 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
657 | 657 | |
658 | 658 | /** |
659 | 659 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -666,79 +666,79 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return void |
668 | 668 | */ |
669 | -function give_user_info_fields( $form_id ) { |
|
669 | +function give_user_info_fields($form_id) { |
|
670 | 670 | // Get user info. |
671 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
671 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
672 | 672 | |
673 | 673 | /** |
674 | 674 | * Fire before user personal information fields |
675 | 675 | * |
676 | 676 | * @since 1.7 |
677 | 677 | */ |
678 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
678 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
679 | 679 | ?> |
680 | 680 | <fieldset id="give_checkout_user_info"> |
681 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
681 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend> |
|
682 | 682 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
683 | 683 | <label class="give-label" for="give-first"> |
684 | - <?php _e( 'First Name', 'give' ); ?> |
|
685 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
684 | + <?php _e('First Name', 'give'); ?> |
|
685 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
686 | 686 | <span class="give-required-indicator">*</span> |
687 | 687 | <?php endif ?> |
688 | - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?> |
|
688 | + <?php echo Give()->tooltips->render_help(__('We will use this to personalize your account experience.', 'give')); ?> |
|
689 | 689 | </label> |
690 | 690 | <input |
691 | 691 | class="give-input required" |
692 | 692 | type="text" |
693 | 693 | name="give_first" |
694 | 694 | autocomplete="given-name" |
695 | - placeholder="<?php _e( 'First Name', 'give' ); ?>" |
|
695 | + placeholder="<?php _e('First Name', 'give'); ?>" |
|
696 | 696 | id="give-first" |
697 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
698 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
697 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
698 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
699 | 699 | /> |
700 | 700 | </p> |
701 | 701 | |
702 | 702 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
703 | 703 | <label class="give-label" for="give-last"> |
704 | - <?php _e( 'Last Name', 'give' ); ?> |
|
705 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
704 | + <?php _e('Last Name', 'give'); ?> |
|
705 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
706 | 706 | <span class="give-required-indicator">*</span> |
707 | 707 | <?php endif ?> |
708 | - <?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?> |
|
708 | + <?php echo Give()->tooltips->render_help(__('We will use this as well to personalize your account experience.', 'give')); ?> |
|
709 | 709 | </label> |
710 | 710 | |
711 | 711 | <input |
712 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
712 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
713 | 713 | type="text" |
714 | 714 | name="give_last" |
715 | 715 | autocomplete="family-name" |
716 | 716 | id="give-last" |
717 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>" |
|
718 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
719 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
717 | + placeholder="<?php _e('Last Name', 'give'); ?>" |
|
718 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
719 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
720 | 720 | /> |
721 | 721 | </p> |
722 | 722 | |
723 | - <?php if ( give_is_company_field_enabled( $form_id ) ) : ?> |
|
724 | - <?php $give_company = give_field_is_required( 'give_company_name', $form_id ); ?> |
|
723 | + <?php if (give_is_company_field_enabled($form_id)) : ?> |
|
724 | + <?php $give_company = give_field_is_required('give_company_name', $form_id); ?> |
|
725 | 725 | <p id="give-company-wrap" class="form-row form-row-wide"> |
726 | 726 | <label class="give-label" for="give-company"> |
727 | - <?php _e( 'Company Name', 'give' ); ?> |
|
728 | - <?php if ( $give_company ) : ?> |
|
727 | + <?php _e('Company Name', 'give'); ?> |
|
728 | + <?php if ($give_company) : ?> |
|
729 | 729 | <span class="give-required-indicator">*</span> |
730 | 730 | <?php endif; ?> |
731 | - <?php echo Give()->tooltips->render_help( __( 'Donate on behalf of Company', 'give' ) ); ?> |
|
731 | + <?php echo Give()->tooltips->render_help(__('Donate on behalf of Company', 'give')); ?> |
|
732 | 732 | </label> |
733 | 733 | |
734 | 734 | <input |
735 | - class="give-input<?php echo( $give_company ? ' required' : '' ); ?>" |
|
735 | + class="give-input<?php echo($give_company ? ' required' : ''); ?>" |
|
736 | 736 | type="text" |
737 | 737 | name="give_company_name" |
738 | - placeholder="<?php _e( 'Company Name', 'give' ); ?>" |
|
738 | + placeholder="<?php _e('Company Name', 'give'); ?>" |
|
739 | 739 | id="give-company" |
740 | - value="<?php echo isset( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : ''; ?>" |
|
741 | - <?php echo( $give_company ? ' required aria-required="true" ' : '' ); ?> |
|
740 | + value="<?php echo isset($give_user_info['company_name']) ? $give_user_info['company_name'] : ''; ?>" |
|
741 | + <?php echo($give_company ? ' required aria-required="true" ' : ''); ?> |
|
742 | 742 | /> |
743 | 743 | |
744 | 744 | </p> |
@@ -750,15 +750,15 @@ discard block |
||
750 | 750 | * |
751 | 751 | * @since 1.7 |
752 | 752 | */ |
753 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
753 | + do_action('give_donation_form_before_email', $form_id); |
|
754 | 754 | ?> |
755 | 755 | <p id="give-email-wrap" class="form-row form-row-wide"> |
756 | 756 | <label class="give-label" for="give-email"> |
757 | - <?php _e( 'Email Address', 'give' ); ?> |
|
758 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
757 | + <?php _e('Email Address', 'give'); ?> |
|
758 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
759 | 759 | <span class="give-required-indicator">*</span> |
760 | 760 | <?php } ?> |
761 | - <?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?> |
|
761 | + <?php echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?> |
|
762 | 762 | </label> |
763 | 763 | |
764 | 764 | <input |
@@ -766,10 +766,10 @@ discard block |
||
766 | 766 | type="email" |
767 | 767 | name="give_email" |
768 | 768 | autocomplete="email" |
769 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>" |
|
769 | + placeholder="<?php _e('Email Address', 'give'); ?>" |
|
770 | 770 | id="give-email" |
771 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
772 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
771 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
772 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
773 | 773 | /> |
774 | 774 | |
775 | 775 | </p> |
@@ -779,14 +779,14 @@ discard block |
||
779 | 779 | * |
780 | 780 | * @since 1.7 |
781 | 781 | */ |
782 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
782 | + do_action('give_donation_form_after_email', $form_id); |
|
783 | 783 | |
784 | 784 | /** |
785 | 785 | * Fire after personal email field |
786 | 786 | * |
787 | 787 | * @since 1.7 |
788 | 788 | */ |
789 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
789 | + do_action('give_donation_form_user_info', $form_id); |
|
790 | 790 | ?> |
791 | 791 | </fieldset> |
792 | 792 | <?php |
@@ -795,11 +795,11 @@ discard block |
||
795 | 795 | * |
796 | 796 | * @since 1.7 |
797 | 797 | */ |
798 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
798 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
799 | 799 | } |
800 | 800 | |
801 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
802 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
801 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
802 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
803 | 803 | |
804 | 804 | /** |
805 | 805 | * Renders the credit card info form. |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | * |
811 | 811 | * @return void |
812 | 812 | */ |
813 | -function give_get_cc_form( $form_id ) { |
|
813 | +function give_get_cc_form($form_id) { |
|
814 | 814 | |
815 | 815 | ob_start(); |
816 | 816 | |
@@ -821,50 +821,50 @@ discard block |
||
821 | 821 | * |
822 | 822 | * @param int $form_id The form ID. |
823 | 823 | */ |
824 | - do_action( 'give_before_cc_fields', $form_id ); |
|
824 | + do_action('give_before_cc_fields', $form_id); |
|
825 | 825 | ?> |
826 | 826 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
827 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
828 | - <?php if ( is_ssl() ) : ?> |
|
827 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
828 | + <?php if (is_ssl()) : ?> |
|
829 | 829 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
830 | 830 | <span class="give-icon padlock"></span> |
831 | - <span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
831 | + <span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
832 | 832 | </div> |
833 | 833 | <?php endif; ?> |
834 | 834 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
835 | 835 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
836 | - <?php _e( 'Card Number', 'give' ); ?> |
|
836 | + <?php _e('Card Number', 'give'); ?> |
|
837 | 837 | <span class="give-required-indicator">*</span> |
838 | - <?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?> |
|
838 | + <?php echo Give()->tooltips->render_help(__('The (typically) 16 digits on the front of your credit card.', 'give')); ?> |
|
839 | 839 | <span class="card-type"></span> |
840 | 840 | </label> |
841 | 841 | |
842 | 842 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
843 | - class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" |
|
843 | + class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" |
|
844 | 844 | required aria-required="true"/> |
845 | 845 | </p> |
846 | 846 | |
847 | 847 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
848 | 848 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
849 | - <?php _e( 'CVC', 'give' ); ?> |
|
849 | + <?php _e('CVC', 'give'); ?> |
|
850 | 850 | <span class="give-required-indicator">*</span> |
851 | - <?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?> |
|
851 | + <?php echo Give()->tooltips->render_help(__('The 3 digit (back) or 4 digit (front) value on your card.', 'give')); ?> |
|
852 | 852 | </label> |
853 | 853 | |
854 | 854 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
855 | - class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" |
|
855 | + class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" |
|
856 | 856 | required aria-required="true"/> |
857 | 857 | </p> |
858 | 858 | |
859 | 859 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
860 | 860 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
861 | - <?php _e( 'Name on the Card', 'give' ); ?> |
|
861 | + <?php _e('Name on the Card', 'give'); ?> |
|
862 | 862 | <span class="give-required-indicator">*</span> |
863 | - <?php echo Give()->tooltips->render_help( __( 'The name printed on the front of your credit card.', 'give' ) ); ?> |
|
863 | + <?php echo Give()->tooltips->render_help(__('The name printed on the front of your credit card.', 'give')); ?> |
|
864 | 864 | </label> |
865 | 865 | |
866 | 866 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
867 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
867 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
868 | 868 | required aria-required="true"/> |
869 | 869 | </p> |
870 | 870 | <?php |
@@ -875,19 +875,19 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @param int $form_id The form ID. |
877 | 877 | */ |
878 | - do_action( 'give_before_cc_expiration' ); |
|
878 | + do_action('give_before_cc_expiration'); |
|
879 | 879 | ?> |
880 | 880 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
881 | 881 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
882 | - <?php _e( 'Expiration', 'give' ); ?> |
|
882 | + <?php _e('Expiration', 'give'); ?> |
|
883 | 883 | <span class="give-required-indicator">*</span> |
884 | - <?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?> |
|
884 | + <?php echo Give()->tooltips->render_help(__('The date your credit card expires, typically on the front of the card.', 'give')); ?> |
|
885 | 885 | </label> |
886 | 886 | |
887 | 887 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
888 | 888 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
889 | 889 | |
890 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true"/> |
|
890 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true"/> |
|
891 | 891 | </p> |
892 | 892 | <?php |
893 | 893 | /** |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * |
898 | 898 | * @param int $form_id The form ID. |
899 | 899 | */ |
900 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
900 | + do_action('give_after_cc_expiration', $form_id); |
|
901 | 901 | ?> |
902 | 902 | </fieldset> |
903 | 903 | <?php |
@@ -908,12 +908,12 @@ discard block |
||
908 | 908 | * |
909 | 909 | * @param int $form_id The form ID. |
910 | 910 | */ |
911 | - do_action( 'give_after_cc_fields', $form_id ); |
|
911 | + do_action('give_after_cc_fields', $form_id); |
|
912 | 912 | |
913 | 913 | echo ob_get_clean(); |
914 | 914 | } |
915 | 915 | |
916 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
916 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
917 | 917 | |
918 | 918 | /** |
919 | 919 | * Outputs the default credit card address fields. |
@@ -924,20 +924,20 @@ discard block |
||
924 | 924 | * |
925 | 925 | * @return void |
926 | 926 | */ |
927 | -function give_default_cc_address_fields( $form_id ) { |
|
927 | +function give_default_cc_address_fields($form_id) { |
|
928 | 928 | // Get user info. |
929 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
929 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
930 | 930 | |
931 | 931 | $logged_in = is_user_logged_in(); |
932 | 932 | |
933 | - if ( $logged_in ) { |
|
934 | - $user_address = give_get_donor_address( get_current_user_id() ); |
|
933 | + if ($logged_in) { |
|
934 | + $user_address = give_get_donor_address(get_current_user_id()); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | ob_start(); |
938 | 938 | ?> |
939 | 939 | <fieldset id="give_cc_address" class="cc-address"> |
940 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
940 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
941 | 941 | <?php |
942 | 942 | /** |
943 | 943 | * Fires while rendering credit card billing form, before address fields. |
@@ -946,36 +946,36 @@ discard block |
||
946 | 946 | * |
947 | 947 | * @param int $form_id The form ID. |
948 | 948 | */ |
949 | - do_action( 'give_cc_billing_top' ); |
|
949 | + do_action('give_cc_billing_top'); |
|
950 | 950 | |
951 | 951 | // For Country. |
952 | 952 | $selected_country = give_get_country(); |
953 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
953 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
954 | 954 | $selected_country = $give_user_info['billing_country']; |
955 | 955 | } |
956 | 956 | $countries = give_get_country_list(); |
957 | 957 | |
958 | 958 | // For state |
959 | 959 | $selected_state = ''; |
960 | - if ( $selected_country === give_get_country() ) { |
|
960 | + if ($selected_country === give_get_country()) { |
|
961 | 961 | // Get defalut selected state by admin. |
962 | 962 | $selected_state = give_get_state(); |
963 | 963 | } |
964 | 964 | // Get the last payment made by user states. |
965 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
965 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
966 | 966 | $selected_state = $give_user_info['card_state']; |
967 | 967 | } |
968 | 968 | // Get the country code |
969 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
969 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
970 | 970 | $selected_country = $give_user_info['billing_country']; |
971 | 971 | } |
972 | - $label = __( 'State', 'give' ); |
|
972 | + $label = __('State', 'give'); |
|
973 | 973 | $states_label = give_get_states_label(); |
974 | 974 | // Check if $country code exists in the array key for states label. |
975 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
976 | - $label = $states_label[ $selected_country ]; |
|
975 | + if (array_key_exists($selected_country, $states_label)) { |
|
976 | + $label = $states_label[$selected_country]; |
|
977 | 977 | } |
978 | - $states = give_get_states( $selected_country ); |
|
978 | + $states = give_get_states($selected_country); |
|
979 | 979 | // Get the country list that do not have any states init. |
980 | 980 | $no_states_country = give_no_states_country_list(); |
981 | 981 | // Get the country list that does not require states. |
@@ -983,24 +983,24 @@ discard block |
||
983 | 983 | ?> |
984 | 984 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
985 | 985 | <label for="billing_country" class="give-label"> |
986 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
987 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
986 | + <?php esc_html_e('Country', 'give'); ?> |
|
987 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
988 | 988 | <span class="give-required-indicator">*</span> |
989 | 989 | <?php endif; ?> |
990 | 990 | <span class="give-tooltip give-icon give-icon-question" |
991 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
991 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
992 | 992 | </label> |
993 | 993 | |
994 | 994 | <select |
995 | 995 | name="billing_country" |
996 | 996 | autocomplete="country-name" |
997 | 997 | id="billing_country" |
998 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
999 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
998 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
999 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1000 | 1000 | > |
1001 | 1001 | <?php |
1002 | - foreach ( $countries as $country_code => $country ) { |
|
1003 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
1002 | + foreach ($countries as $country_code => $country) { |
|
1003 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
1004 | 1004 | } |
1005 | 1005 | ?> |
1006 | 1006 | </select> |
@@ -1008,12 +1008,12 @@ discard block |
||
1008 | 1008 | |
1009 | 1009 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
1010 | 1010 | <label for="card_address" class="give-label"> |
1011 | - <?php _e( 'Address 1', 'give' ); ?> |
|
1011 | + <?php _e('Address 1', 'give'); ?> |
|
1012 | 1012 | <?php |
1013 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
1013 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
1014 | 1014 | <span class="give-required-indicator">*</span> |
1015 | 1015 | <?php endif; ?> |
1016 | - <?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?> |
|
1016 | + <?php echo Give()->tooltips->render_help(__('The primary billing address for your credit card.', 'give')); ?> |
|
1017 | 1017 | </label> |
1018 | 1018 | |
1019 | 1019 | <input |
@@ -1021,20 +1021,20 @@ discard block |
||
1021 | 1021 | id="card_address" |
1022 | 1022 | name="card_address" |
1023 | 1023 | autocomplete="address-line1" |
1024 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
1025 | - placeholder="<?php _e( 'Address line 1', 'give' ); ?>" |
|
1026 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
1027 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1024 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
1025 | + placeholder="<?php _e('Address line 1', 'give'); ?>" |
|
1026 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
1027 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1028 | 1028 | /> |
1029 | 1029 | </p> |
1030 | 1030 | |
1031 | 1031 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
1032 | 1032 | <label for="card_address_2" class="give-label"> |
1033 | - <?php _e( 'Address 2', 'give' ); ?> |
|
1034 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
1033 | + <?php _e('Address 2', 'give'); ?> |
|
1034 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
1035 | 1035 | <span class="give-required-indicator">*</span> |
1036 | 1036 | <?php endif; ?> |
1037 | - <?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?> |
|
1037 | + <?php echo Give()->tooltips->render_help(__('(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give')); ?> |
|
1038 | 1038 | </label> |
1039 | 1039 | |
1040 | 1040 | <input |
@@ -1042,56 +1042,56 @@ discard block |
||
1042 | 1042 | id="card_address_2" |
1043 | 1043 | name="card_address_2" |
1044 | 1044 | autocomplete="address-line2" |
1045 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
1046 | - placeholder="<?php _e( 'Address line 2', 'give' ); ?>" |
|
1047 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
1048 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1045 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
1046 | + placeholder="<?php _e('Address line 2', 'give'); ?>" |
|
1047 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
1048 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1049 | 1049 | /> |
1050 | 1050 | </p> |
1051 | 1051 | |
1052 | 1052 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
1053 | 1053 | <label for="card_city" class="give-label"> |
1054 | - <?php _e( 'City', 'give' ); ?> |
|
1055 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
1054 | + <?php _e('City', 'give'); ?> |
|
1055 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
1056 | 1056 | <span class="give-required-indicator">*</span> |
1057 | 1057 | <?php endif; ?> |
1058 | - <?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?> |
|
1058 | + <?php echo Give()->tooltips->render_help(__('The city for your billing address.', 'give')); ?> |
|
1059 | 1059 | </label> |
1060 | 1060 | <input |
1061 | 1061 | type="text" |
1062 | 1062 | id="card_city" |
1063 | 1063 | name="card_city" |
1064 | 1064 | autocomplete="address-level3" |
1065 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
1066 | - placeholder="<?php _e( 'City', 'give' ); ?>" |
|
1067 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
1068 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1065 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
1066 | + placeholder="<?php _e('City', 'give'); ?>" |
|
1067 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
1068 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1069 | 1069 | /> |
1070 | 1070 | </p> |
1071 | 1071 | |
1072 | 1072 | <p id="give-card-state-wrap" |
1073 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
1073 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
1074 | 1074 | <label for="card_state" class="give-label"> |
1075 | 1075 | <span class="state-label-text"><?php echo $label; ?></span> |
1076 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
1076 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
1077 | 1077 | ?> |
1078 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
1078 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
1079 | 1079 | <?php endif; ?> |
1080 | 1080 | <span class="give-tooltip give-icon give-icon-question" |
1081 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
1081 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
1082 | 1082 | </label> |
1083 | 1083 | <?php |
1084 | 1084 | |
1085 | - if ( ! empty( $states ) ) : ?> |
|
1085 | + if ( ! empty($states)) : ?> |
|
1086 | 1086 | <select |
1087 | 1087 | name="card_state" |
1088 | 1088 | autocomplete="address-level4" |
1089 | 1089 | id="card_state" |
1090 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
1091 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
1090 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
1091 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
1092 | 1092 | <?php |
1093 | - foreach ( $states as $state_code => $state ) { |
|
1094 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1093 | + foreach ($states as $state_code => $state) { |
|
1094 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
1095 | 1095 | } |
1096 | 1096 | ?> |
1097 | 1097 | </select> |
@@ -1103,11 +1103,11 @@ discard block |
||
1103 | 1103 | |
1104 | 1104 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
1105 | 1105 | <label for="card_zip" class="give-label"> |
1106 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
1107 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
1106 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
1107 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
1108 | 1108 | <span class="give-required-indicator">*</span> |
1109 | 1109 | <?php endif; ?> |
1110 | - <?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?> |
|
1110 | + <?php echo Give()->tooltips->render_help(__('The ZIP Code or postal code for your billing address.', 'give')); ?> |
|
1111 | 1111 | </label> |
1112 | 1112 | |
1113 | 1113 | <input |
@@ -1116,10 +1116,10 @@ discard block |
||
1116 | 1116 | id="card_zip" |
1117 | 1117 | name="card_zip" |
1118 | 1118 | autocomplete="postal-code" |
1119 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
1120 | - placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" |
|
1121 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
1122 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1119 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
1120 | + placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" |
|
1121 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
1122 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1123 | 1123 | /> |
1124 | 1124 | </p> |
1125 | 1125 | <?php |
@@ -1130,14 +1130,14 @@ discard block |
||
1130 | 1130 | * |
1131 | 1131 | * @param int $form_id The form ID. |
1132 | 1132 | */ |
1133 | - do_action( 'give_cc_billing_bottom' ); |
|
1133 | + do_action('give_cc_billing_bottom'); |
|
1134 | 1134 | ?> |
1135 | 1135 | </fieldset> |
1136 | 1136 | <?php |
1137 | 1137 | echo ob_get_clean(); |
1138 | 1138 | } |
1139 | 1139 | |
1140 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
1140 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
1141 | 1141 | |
1142 | 1142 | |
1143 | 1143 | /** |
@@ -1150,15 +1150,15 @@ discard block |
||
1150 | 1150 | * |
1151 | 1151 | * @return string |
1152 | 1152 | */ |
1153 | -function give_get_register_fields( $form_id ) { |
|
1153 | +function give_get_register_fields($form_id) { |
|
1154 | 1154 | |
1155 | 1155 | global $user_ID; |
1156 | 1156 | |
1157 | - if ( is_user_logged_in() ) { |
|
1158 | - $user_data = get_userdata( $user_ID ); |
|
1157 | + if (is_user_logged_in()) { |
|
1158 | + $user_data = get_userdata($user_ID); |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1161 | + $show_register_form = give_show_login_register_option($form_id); |
|
1162 | 1162 | |
1163 | 1163 | ob_start(); ?> |
1164 | 1164 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | * |
1172 | 1172 | * @param int $form_id The form ID. |
1173 | 1173 | */ |
1174 | - do_action( 'give_register_fields_before', $form_id ); |
|
1174 | + do_action('give_register_fields_before', $form_id); |
|
1175 | 1175 | ?> |
1176 | 1176 | |
1177 | 1177 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
@@ -1183,24 +1183,24 @@ discard block |
||
1183 | 1183 | * |
1184 | 1184 | * @param int $form_id The form ID. |
1185 | 1185 | */ |
1186 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
1186 | + do_action('give_register_account_fields_before', $form_id); |
|
1187 | 1187 | |
1188 | - $class = ( 'registration' === $show_register_form) ? 'form-row-wide' : 'form-row-first'; |
|
1188 | + $class = ('registration' === $show_register_form) ? 'form-row-wide' : 'form-row-first'; |
|
1189 | 1189 | ?> |
1190 | - <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row <?php echo esc_attr( $class ); ?> form-row-responsive"> |
|
1190 | + <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row <?php echo esc_attr($class); ?> form-row-responsive"> |
|
1191 | 1191 | <label for="give-create-account-<?php echo $form_id; ?>"> |
1192 | 1192 | <?php |
1193 | 1193 | // Add attributes to checkbox, if Guest Checkout is disabled. |
1194 | - $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
1195 | - $id = 'give-create-account-' . $form_id; |
|
1196 | - if ( ! give_is_setting_enabled( $is_guest_checkout ) ) { |
|
1194 | + $is_guest_checkout = give_get_meta($form_id, '_give_logged_in_only', true); |
|
1195 | + $id = 'give-create-account-'.$form_id; |
|
1196 | + if ( ! give_is_setting_enabled($is_guest_checkout)) { |
|
1197 | 1197 | echo Give()->tooltips->render( |
1198 | 1198 | array( |
1199 | 1199 | 'tag_content' => sprintf( |
1200 | 1200 | '<input type="checkbox" name="give_create_account" value="on" id="%s" class="give-input give-disabled" checked />', |
1201 | 1201 | $id |
1202 | 1202 | ), |
1203 | - 'label' => __( 'Registration is required to donate.', 'give' ), |
|
1203 | + 'label' => __('Registration is required to donate.', 'give'), |
|
1204 | 1204 | ) ); |
1205 | 1205 | } else { |
1206 | 1206 | ?> |
@@ -1208,17 +1208,17 @@ discard block |
||
1208 | 1208 | <?php |
1209 | 1209 | } |
1210 | 1210 | ?> |
1211 | - <?php _e( 'Create an account', 'give' ); ?> |
|
1212 | - <?php echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) ); ?> |
|
1213 | - <?php wp_nonce_field( 'give_form_create_user_nonce', 'give-form-user-register-hash', false, true );?> |
|
1211 | + <?php _e('Create an account', 'give'); ?> |
|
1212 | + <?php echo Give()->tooltips->render_help(__('Create an account on the site to see and manage donation history.', 'give')); ?> |
|
1213 | + <?php wp_nonce_field('give_form_create_user_nonce', 'give-form-user-register-hash', false, true); ?> |
|
1214 | 1214 | </label> |
1215 | 1215 | </div> |
1216 | 1216 | |
1217 | - <?php if ( 'both' === $show_register_form ) { ?> |
|
1217 | + <?php if ('both' === $show_register_form) { ?> |
|
1218 | 1218 | <div class="give-login-account-wrap form-row form-row-last form-row-responsive"> |
1219 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
1220 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
1221 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
1219 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
1220 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
1221 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
1222 | 1222 | </p> |
1223 | 1223 | <p class="give-loading-text"> |
1224 | 1224 | <span class="give-loading-animation"></span> |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | * |
1235 | 1235 | * @param int $form_id The form ID. |
1236 | 1236 | */ |
1237 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
1237 | + do_action('give_register_account_fields_after', $form_id); |
|
1238 | 1238 | ?> |
1239 | 1239 | </fieldset> |
1240 | 1240 | |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | * |
1247 | 1247 | * @param int $form_id The form ID. |
1248 | 1248 | */ |
1249 | - do_action( 'give_register_fields_after', $form_id ); |
|
1249 | + do_action('give_register_fields_after', $form_id); |
|
1250 | 1250 | ?> |
1251 | 1251 | |
1252 | 1252 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | * |
1258 | 1258 | * @since 1.7 |
1259 | 1259 | */ |
1260 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
1260 | + do_action('give_donation_form_user_info', $form_id); |
|
1261 | 1261 | ?> |
1262 | 1262 | |
1263 | 1263 | </fieldset> |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | echo ob_get_clean(); |
1266 | 1266 | } |
1267 | 1267 | |
1268 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
1268 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
1269 | 1269 | |
1270 | 1270 | /** |
1271 | 1271 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1278,28 +1278,28 @@ discard block |
||
1278 | 1278 | * |
1279 | 1279 | * @return string |
1280 | 1280 | */ |
1281 | -function give_get_login_fields( $form_id ) { |
|
1281 | +function give_get_login_fields($form_id) { |
|
1282 | 1282 | |
1283 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
1284 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1283 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
1284 | + $show_register_form = give_show_login_register_option($form_id); |
|
1285 | 1285 | |
1286 | 1286 | ob_start(); |
1287 | 1287 | ?> |
1288 | 1288 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
1289 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
1290 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1291 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
1289 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give')); |
|
1290 | + if ( ! give_logged_in_only($form_id)) { |
|
1291 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
1292 | 1292 | } ?> |
1293 | 1293 | </legend> |
1294 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1294 | + <?php if ($show_register_form == 'both') { ?> |
|
1295 | 1295 | <p class="give-new-account-link"> |
1296 | - <?php _e( 'Don\'t have an account?', 'give' ); ?> |
|
1297 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
1296 | + <?php _e('Don\'t have an account?', 'give'); ?> |
|
1297 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
1298 | 1298 | data-action="give_checkout_register"> |
1299 | - <?php if ( give_logged_in_only( $form_id ) ) { |
|
1300 | - _e( 'Register as a part of your donation »', 'give' ); |
|
1299 | + <?php if (give_logged_in_only($form_id)) { |
|
1300 | + _e('Register as a part of your donation »', 'give'); |
|
1301 | 1301 | } else { |
1302 | - _e( 'Register or donate as a guest »', 'give' ); |
|
1302 | + _e('Register or donate as a guest »', 'give'); |
|
1303 | 1303 | } ?> |
1304 | 1304 | </a> |
1305 | 1305 | </p> |
@@ -1315,49 +1315,49 @@ discard block |
||
1315 | 1315 | * |
1316 | 1316 | * @param int $form_id The form ID. |
1317 | 1317 | */ |
1318 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
1318 | + do_action('give_checkout_login_fields_before', $form_id); |
|
1319 | 1319 | ?> |
1320 | 1320 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1321 | 1321 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
1322 | - <?php _e( 'Username', 'give' ); ?> |
|
1323 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1322 | + <?php _e('Username', 'give'); ?> |
|
1323 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1324 | 1324 | <span class="give-required-indicator">*</span> |
1325 | 1325 | <?php } ?> |
1326 | 1326 | </label> |
1327 | 1327 | |
1328 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
1328 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
1329 | 1329 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
1330 | - placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1330 | + placeholder="<?php _e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1331 | 1331 | </div> |
1332 | 1332 | |
1333 | 1333 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1334 | 1334 | class="give_login_password form-row form-row-last form-row-responsive"> |
1335 | 1335 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
1336 | - <?php _e( 'Password', 'give' ); ?> |
|
1337 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1336 | + <?php _e('Password', 'give'); ?> |
|
1337 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1338 | 1338 | <span class="give-required-indicator">*</span> |
1339 | 1339 | <?php } ?> |
1340 | 1340 | </label> |
1341 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
1341 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
1342 | 1342 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
1343 | - placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1343 | + placeholder="<?php _e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1344 | 1344 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1345 | 1345 | </div> |
1346 | 1346 | |
1347 | 1347 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
1348 | 1348 | <span class="give-forgot-password "> |
1349 | 1349 | <a href="<?php echo wp_lostpassword_url() ?>" |
1350 | - target="_blank"><?php _e( 'Reset Password', 'give' ) ?></a> |
|
1350 | + target="_blank"><?php _e('Reset Password', 'give') ?></a> |
|
1351 | 1351 | </span> |
1352 | 1352 | </div> |
1353 | 1353 | |
1354 | 1354 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
1355 | 1355 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
1356 | - value="<?php _e( 'Login', 'give' ); ?>"/> |
|
1357 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
1356 | + value="<?php _e('Login', 'give'); ?>"/> |
|
1357 | + <?php if ($show_register_form !== 'login') { ?> |
|
1358 | 1358 | <input type="button" data-action="give_cancel_login" |
1359 | 1359 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
1360 | - value="<?php _e( 'Cancel', 'give' ); ?>"/> |
|
1360 | + value="<?php _e('Cancel', 'give'); ?>"/> |
|
1361 | 1361 | <?php } ?> |
1362 | 1362 | <span class="give-loading-animation"></span> |
1363 | 1363 | </div> |
@@ -1369,14 +1369,14 @@ discard block |
||
1369 | 1369 | * |
1370 | 1370 | * @param int $form_id The form ID. |
1371 | 1371 | */ |
1372 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
1372 | + do_action('give_checkout_login_fields_after', $form_id); |
|
1373 | 1373 | ?> |
1374 | 1374 | </fieldset><!--end #give-login-fields--> |
1375 | 1375 | <?php |
1376 | 1376 | echo ob_get_clean(); |
1377 | 1377 | } |
1378 | 1378 | |
1379 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
1379 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
1380 | 1380 | |
1381 | 1381 | /** |
1382 | 1382 | * Payment Mode Select. |
@@ -1392,10 +1392,10 @@ discard block |
||
1392 | 1392 | * |
1393 | 1393 | * @return void |
1394 | 1394 | */ |
1395 | -function give_payment_mode_select( $form_id, $args ) { |
|
1395 | +function give_payment_mode_select($form_id, $args) { |
|
1396 | 1396 | |
1397 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
1398 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
1397 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
1398 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
1399 | 1399 | |
1400 | 1400 | /** |
1401 | 1401 | * Fires while selecting payment gateways, before the fields. |
@@ -1404,10 +1404,10 @@ discard block |
||
1404 | 1404 | * |
1405 | 1405 | * @param int $form_id The form ID. |
1406 | 1406 | */ |
1407 | - do_action( 'give_payment_mode_top', $form_id ); |
|
1407 | + do_action('give_payment_mode_top', $form_id); |
|
1408 | 1408 | ?> |
1409 | 1409 | |
1410 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
1410 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
1411 | 1411 | echo 'style="display: none;"'; |
1412 | 1412 | } ?>> |
1413 | 1413 | <?php |
@@ -1418,10 +1418,10 @@ discard block |
||
1418 | 1418 | * |
1419 | 1419 | * @param int $form_id The form ID. |
1420 | 1420 | */ |
1421 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
1421 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
1422 | 1422 | ?> |
1423 | 1423 | <legend |
1424 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
1424 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
1425 | 1425 | <span class="give-loading-text"><span |
1426 | 1426 | class="give-loading-animation"></span> |
1427 | 1427 | </span> |
@@ -1434,37 +1434,36 @@ discard block |
||
1434 | 1434 | * |
1435 | 1435 | * @since 1.7 |
1436 | 1436 | */ |
1437 | - do_action( 'give_payment_mode_before_gateways' ) |
|
1437 | + do_action('give_payment_mode_before_gateways') |
|
1438 | 1438 | ?> |
1439 | 1439 | <ul id="give-gateway-radio-list"> |
1440 | 1440 | <?php |
1441 | 1441 | /** |
1442 | 1442 | * Loop through the active payment gateways. |
1443 | 1443 | */ |
1444 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
1444 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
1445 | 1445 | $give_settings = give_get_settings(); |
1446 | - $gateways_label = array_key_exists( 'gateways_label', $give_settings ) ? |
|
1447 | - $give_settings['gateways_label'] : |
|
1448 | - array(); |
|
1446 | + $gateways_label = array_key_exists('gateways_label', $give_settings) ? |
|
1447 | + $give_settings['gateways_label'] : array(); |
|
1449 | 1448 | |
1450 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
1449 | + foreach ($gateways as $gateway_id => $gateway) : |
|
1451 | 1450 | //Determine the default gateway. |
1452 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
1451 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
1453 | 1452 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
1454 | 1453 | <li<?php echo $checked_class ?>> |
1455 | 1454 | <input type="radio" name="payment-mode" class="give-gateway" |
1456 | - id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
1457 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
1455 | + id="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
1456 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
1458 | 1457 | |
1459 | 1458 | <?php |
1460 | 1459 | $label = $gateway['checkout_label']; |
1461 | - if ( ! empty( $gateways_label[ $gateway_id ] ) ) { |
|
1462 | - $label = $gateways_label[ $gateway_id ]; |
|
1460 | + if ( ! empty($gateways_label[$gateway_id])) { |
|
1461 | + $label = $gateways_label[$gateway_id]; |
|
1463 | 1462 | } |
1464 | 1463 | ?> |
1465 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
1464 | + <label for="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
1466 | 1465 | class="give-gateway-option" |
1467 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $label ); ?></label> |
|
1466 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($label); ?></label> |
|
1468 | 1467 | </li> |
1469 | 1468 | <?php |
1470 | 1469 | endforeach; |
@@ -1476,7 +1475,7 @@ discard block |
||
1476 | 1475 | * |
1477 | 1476 | * @since 1.7 |
1478 | 1477 | */ |
1479 | - do_action( 'give_payment_mode_after_gateways' ); |
|
1478 | + do_action('give_payment_mode_after_gateways'); |
|
1480 | 1479 | ?> |
1481 | 1480 | </div> |
1482 | 1481 | <?php |
@@ -1487,7 +1486,7 @@ discard block |
||
1487 | 1486 | * |
1488 | 1487 | * @param int $form_id The form ID. |
1489 | 1488 | */ |
1490 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
1489 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
1491 | 1490 | ?> |
1492 | 1491 | </fieldset> |
1493 | 1492 | |
@@ -1499,7 +1498,7 @@ discard block |
||
1499 | 1498 | * |
1500 | 1499 | * @param int $form_id The form ID. |
1501 | 1500 | */ |
1502 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
1501 | + do_action('give_payment_mode_bottom', $form_id); |
|
1503 | 1502 | ?> |
1504 | 1503 | |
1505 | 1504 | <div id="give_purchase_form_wrap"> |
@@ -1510,7 +1509,7 @@ discard block |
||
1510 | 1509 | * |
1511 | 1510 | * @since 1.7 |
1512 | 1511 | */ |
1513 | - do_action( 'give_donation_form', $form_id, $args ); |
|
1512 | + do_action('give_donation_form', $form_id, $args); |
|
1514 | 1513 | ?> |
1515 | 1514 | |
1516 | 1515 | </div> |
@@ -1521,10 +1520,10 @@ discard block |
||
1521 | 1520 | * |
1522 | 1521 | * @since 1.7 |
1523 | 1522 | */ |
1524 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
1523 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
1525 | 1524 | } |
1526 | 1525 | |
1527 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select', 10, 2 ); |
|
1526 | +add_action('give_payment_mode_select', 'give_payment_mode_select', 10, 2); |
|
1528 | 1527 | |
1529 | 1528 | /** |
1530 | 1529 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1537,22 +1536,22 @@ discard block |
||
1537 | 1536 | * |
1538 | 1537 | * @return bool |
1539 | 1538 | */ |
1540 | -function give_terms_agreement( $form_id ) { |
|
1541 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1539 | +function give_terms_agreement($form_id) { |
|
1540 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1542 | 1541 | |
1543 | 1542 | // Bailout if per form and global term and conditions is not setup. |
1544 | 1543 | if ( |
1545 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1546 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1544 | + give_is_setting_enabled($form_option, 'global') |
|
1545 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1547 | 1546 | ) { |
1548 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
1549 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
1550 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
1547 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
1548 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
1549 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
1551 | 1550 | |
1552 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1553 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
1554 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
1555 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
1551 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1552 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
1553 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
1554 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
1556 | 1555 | |
1557 | 1556 | } else { |
1558 | 1557 | return false; |
@@ -1560,9 +1559,9 @@ discard block |
||
1560 | 1559 | |
1561 | 1560 | |
1562 | 1561 | // Bailout: Check if term and conditions text is empty or not. |
1563 | - if ( empty( $terms ) ) { |
|
1564 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
1565 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
1562 | + if (empty($terms)) { |
|
1563 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
1564 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
1566 | 1565 | } |
1567 | 1566 | |
1568 | 1567 | return false; |
@@ -1573,11 +1572,11 @@ discard block |
||
1573 | 1572 | * |
1574 | 1573 | * @since 2.1.5 |
1575 | 1574 | */ |
1576 | - $terms = apply_filters( 'give_the_term_content', wpautop( do_shortcode( $terms ) ), $terms, $form_id ); |
|
1575 | + $terms = apply_filters('give_the_term_content', wpautop(do_shortcode($terms)), $terms, $form_id); |
|
1577 | 1576 | |
1578 | 1577 | ?> |
1579 | 1578 | <fieldset id="give_terms_agreement"> |
1580 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
1579 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
1581 | 1580 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
1582 | 1581 | <?php |
1583 | 1582 | /** |
@@ -1585,7 +1584,7 @@ discard block |
||
1585 | 1584 | * |
1586 | 1585 | * @since 1.0 |
1587 | 1586 | */ |
1588 | - do_action( 'give_before_terms' ); |
|
1587 | + do_action('give_before_terms'); |
|
1589 | 1588 | |
1590 | 1589 | echo $terms; |
1591 | 1590 | /** |
@@ -1593,14 +1592,14 @@ discard block |
||
1593 | 1592 | * |
1594 | 1593 | * @since 1.0 |
1595 | 1594 | */ |
1596 | - do_action( 'give_after_terms' ); |
|
1595 | + do_action('give_after_terms'); |
|
1597 | 1596 | ?> |
1598 | 1597 | </div> |
1599 | 1598 | <div id="give_show_terms"> |
1600 | 1599 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1601 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1600 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1602 | 1601 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1603 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1602 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1604 | 1603 | </div> |
1605 | 1604 | |
1606 | 1605 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1611,7 +1610,7 @@ discard block |
||
1611 | 1610 | <?php |
1612 | 1611 | } |
1613 | 1612 | |
1614 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
1613 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
1615 | 1614 | |
1616 | 1615 | /** |
1617 | 1616 | * Checkout Final Total. |
@@ -1624,15 +1623,14 @@ discard block |
||
1624 | 1623 | * |
1625 | 1624 | * @return void |
1626 | 1625 | */ |
1627 | -function give_checkout_final_total( $form_id ) { |
|
1626 | +function give_checkout_final_total($form_id) { |
|
1628 | 1627 | |
1629 | - $total = isset( $_POST['give_total'] ) ? |
|
1630 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
1631 | - give_get_default_form_amount( $form_id ); |
|
1628 | + $total = isset($_POST['give_total']) ? |
|
1629 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
1632 | 1630 | |
1633 | 1631 | |
1634 | 1632 | // Only proceed if give_total available. |
1635 | - if ( empty( $total ) ) { |
|
1633 | + if (empty($total)) { |
|
1636 | 1634 | return; |
1637 | 1635 | } |
1638 | 1636 | ?> |
@@ -1643,19 +1641,19 @@ discard block |
||
1643 | 1641 | * |
1644 | 1642 | * @since 2.0.5 |
1645 | 1643 | */ |
1646 | - do_action( 'give_donation_final_total_label_before', $form_id ); |
|
1644 | + do_action('give_donation_final_total_label_before', $form_id); |
|
1647 | 1645 | ?> |
1648 | 1646 | <span class="give-donation-total-label"> |
1649 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
1647 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
1650 | 1648 | </span> |
1651 | 1649 | <span class="give-final-total-amount" |
1652 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
1650 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
1653 | 1651 | <?php |
1654 | 1652 | |
1655 | - echo give_currency_filter( give_format_amount( $total, array( |
|
1653 | + echo give_currency_filter(give_format_amount($total, array( |
|
1656 | 1654 | 'sanitize' => false, |
1657 | - 'currency' => give_get_currency( $form_id ), |
|
1658 | - ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ); ?> |
|
1655 | + 'currency' => give_get_currency($form_id), |
|
1656 | + )), array('currency_code' => give_get_currency($form_id))); ?> |
|
1659 | 1657 | </span> |
1660 | 1658 | <?php |
1661 | 1659 | /** |
@@ -1663,13 +1661,13 @@ discard block |
||
1663 | 1661 | * |
1664 | 1662 | * @since 2.0.5 |
1665 | 1663 | */ |
1666 | - do_action( 'give_donation_final_total_label_after', $form_id ); |
|
1664 | + do_action('give_donation_final_total_label_after', $form_id); |
|
1667 | 1665 | ?> |
1668 | 1666 | </p> |
1669 | 1667 | <?php |
1670 | 1668 | } |
1671 | 1669 | |
1672 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1670 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
1673 | 1671 | |
1674 | 1672 | /** |
1675 | 1673 | * Renders the Checkout Submit section. |
@@ -1681,7 +1679,7 @@ discard block |
||
1681 | 1679 | * |
1682 | 1680 | * @return void |
1683 | 1681 | */ |
1684 | -function give_checkout_submit( $form_id, $args ) { |
|
1682 | +function give_checkout_submit($form_id, $args) { |
|
1685 | 1683 | ?> |
1686 | 1684 | <fieldset id="give_purchase_submit" class="give-donation-submit"> |
1687 | 1685 | <?php |
@@ -1690,24 +1688,24 @@ discard block |
||
1690 | 1688 | * |
1691 | 1689 | * @since 1.7 |
1692 | 1690 | */ |
1693 | - do_action( 'give_donation_form_before_submit', $form_id, $args ); |
|
1691 | + do_action('give_donation_form_before_submit', $form_id, $args); |
|
1694 | 1692 | |
1695 | - give_checkout_hidden_fields( $form_id ); |
|
1693 | + give_checkout_hidden_fields($form_id); |
|
1696 | 1694 | |
1697 | - echo give_get_donation_form_submit_button( $form_id ); |
|
1695 | + echo give_get_donation_form_submit_button($form_id); |
|
1698 | 1696 | |
1699 | 1697 | /** |
1700 | 1698 | * Fire after donation form submit. |
1701 | 1699 | * |
1702 | 1700 | * @since 1.7 |
1703 | 1701 | */ |
1704 | - do_action( 'give_donation_form_after_submit', $form_id, $args ); |
|
1702 | + do_action('give_donation_form_after_submit', $form_id, $args); |
|
1705 | 1703 | ?> |
1706 | 1704 | </fieldset> |
1707 | 1705 | <?php |
1708 | 1706 | } |
1709 | 1707 | |
1710 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2 ); |
|
1708 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2); |
|
1711 | 1709 | |
1712 | 1710 | /** |
1713 | 1711 | * Give Donation form submit button. |
@@ -1718,10 +1716,10 @@ discard block |
||
1718 | 1716 | * |
1719 | 1717 | * @return string |
1720 | 1718 | */ |
1721 | -function give_get_donation_form_submit_button( $form_id ) { |
|
1719 | +function give_get_donation_form_submit_button($form_id) { |
|
1722 | 1720 | |
1723 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
1724 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1721 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
1722 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1725 | 1723 | ob_start(); |
1726 | 1724 | ?> |
1727 | 1725 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1730,7 +1728,7 @@ discard block |
||
1730 | 1728 | <span class="give-loading-animation"></span> |
1731 | 1729 | </div> |
1732 | 1730 | <?php |
1733 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
1731 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
1734 | 1732 | } |
1735 | 1733 | |
1736 | 1734 | /** |
@@ -1745,22 +1743,22 @@ discard block |
||
1745 | 1743 | * |
1746 | 1744 | * @return mixed |
1747 | 1745 | */ |
1748 | -function give_show_goal_progress( $form_id, $args = array() ) { |
|
1746 | +function give_show_goal_progress($form_id, $args = array()) { |
|
1749 | 1747 | |
1750 | 1748 | ob_start(); |
1751 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1749 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1752 | 1750 | |
1753 | 1751 | /** |
1754 | 1752 | * Filter progress bar output |
1755 | 1753 | * |
1756 | 1754 | * @since 2.0 |
1757 | 1755 | */ |
1758 | - echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); |
|
1756 | + echo apply_filters('give_goal_output', ob_get_clean(), $form_id, $args); |
|
1759 | 1757 | |
1760 | 1758 | return true; |
1761 | 1759 | } |
1762 | 1760 | |
1763 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1761 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1764 | 1762 | |
1765 | 1763 | /** |
1766 | 1764 | * Show Give Totals Progress. |
@@ -1772,22 +1770,22 @@ discard block |
||
1772 | 1770 | * |
1773 | 1771 | * @return mixed |
1774 | 1772 | */ |
1775 | -function give_show_goal_totals_progress( $total, $total_goal ) { |
|
1773 | +function give_show_goal_totals_progress($total, $total_goal) { |
|
1776 | 1774 | |
1777 | 1775 | // Bail out if total goal is set as an array. |
1778 | - if ( isset( $total_goal ) && is_array( $total_goal ) ) { |
|
1776 | + if (isset($total_goal) && is_array($total_goal)) { |
|
1779 | 1777 | return false; |
1780 | 1778 | } |
1781 | 1779 | |
1782 | 1780 | ob_start(); |
1783 | - give_get_template( 'shortcode-totals-progress', array( 'total' => $total, 'total_goal' => $total_goal ) ); |
|
1781 | + give_get_template('shortcode-totals-progress', array('total' => $total, 'total_goal' => $total_goal)); |
|
1784 | 1782 | |
1785 | - echo apply_filters( 'give_total_progress_output', ob_get_clean() ); |
|
1783 | + echo apply_filters('give_total_progress_output', ob_get_clean()); |
|
1786 | 1784 | |
1787 | 1785 | return true; |
1788 | 1786 | } |
1789 | 1787 | |
1790 | -add_action( 'give_pre_form', 'give_show_goal_totals_progress', 10, 2 ); |
|
1788 | +add_action('give_pre_form', 'give_show_goal_totals_progress', 10, 2); |
|
1791 | 1789 | |
1792 | 1790 | /** |
1793 | 1791 | * Get form content position. |
@@ -1799,10 +1797,10 @@ discard block |
||
1799 | 1797 | * |
1800 | 1798 | * @return mixed|string |
1801 | 1799 | */ |
1802 | -function give_get_form_content_placement( $form_id, $args ) { |
|
1800 | +function give_get_form_content_placement($form_id, $args) { |
|
1803 | 1801 | $show_content = ''; |
1804 | 1802 | |
1805 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
1803 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
1806 | 1804 | // Content positions. |
1807 | 1805 | $content_placement = array( |
1808 | 1806 | 'above' => 'give_pre_form', |
@@ -1810,18 +1808,18 @@ discard block |
||
1810 | 1808 | ); |
1811 | 1809 | |
1812 | 1810 | // Check if content position already decoded. |
1813 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
1811 | + if (in_array($args['show_content'], $content_placement)) { |
|
1814 | 1812 | return $args['show_content']; |
1815 | 1813 | } |
1816 | 1814 | |
1817 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
1815 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
1818 | 1816 | |
1819 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
1820 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
1817 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
1818 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
1821 | 1819 | |
1822 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
1820 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
1823 | 1821 | // Backward compatibility for _give_content_option for v18. |
1824 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
1822 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
1825 | 1823 | } |
1826 | 1824 | |
1827 | 1825 | return $show_content; |
@@ -1837,20 +1835,20 @@ discard block |
||
1837 | 1835 | * |
1838 | 1836 | * @return void|bool |
1839 | 1837 | */ |
1840 | -function give_form_content( $form_id, $args ) { |
|
1838 | +function give_form_content($form_id, $args) { |
|
1841 | 1839 | |
1842 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1840 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1843 | 1841 | |
1844 | 1842 | // Bailout. |
1845 | - if ( empty( $show_content ) ) { |
|
1843 | + if (empty($show_content)) { |
|
1846 | 1844 | return false; |
1847 | 1845 | } |
1848 | 1846 | |
1849 | 1847 | // Add action according to value. |
1850 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1848 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1851 | 1849 | } |
1852 | 1850 | |
1853 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1851 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1854 | 1852 | |
1855 | 1853 | /** |
1856 | 1854 | * Renders Post Form Content. |
@@ -1864,14 +1862,14 @@ discard block |
||
1864 | 1862 | * |
1865 | 1863 | * @return void |
1866 | 1864 | */ |
1867 | -function give_form_display_content( $form_id, $args ) { |
|
1868 | - $content = give_get_meta( $form_id, '_give_form_content', true ); |
|
1869 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1870 | - |
|
1871 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
1872 | - $content = apply_filters( 'the_content', $content ); |
|
1873 | - } else{ |
|
1874 | - $content = wpautop( do_shortcode( $content ) ); |
|
1865 | +function give_form_display_content($form_id, $args) { |
|
1866 | + $content = give_get_meta($form_id, '_give_form_content', true); |
|
1867 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1868 | + |
|
1869 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
1870 | + $content = apply_filters('the_content', $content); |
|
1871 | + } else { |
|
1872 | + $content = wpautop(do_shortcode($content)); |
|
1875 | 1873 | } |
1876 | 1874 | |
1877 | 1875 | $output = sprintf( |
@@ -1890,11 +1888,11 @@ discard block |
||
1890 | 1888 | * @param int $form_id |
1891 | 1889 | * @param array $args |
1892 | 1890 | */ |
1893 | - echo apply_filters( 'give_form_content_output', $output, $form_id, $args ); |
|
1891 | + echo apply_filters('give_form_content_output', $output, $form_id, $args); |
|
1894 | 1892 | |
1895 | 1893 | // remove action to prevent content output on addition forms on page. |
1896 | 1894 | // @see: https://github.com/WordImpress/Give/issues/634. |
1897 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1895 | + remove_action($show_content, 'give_form_display_content'); |
|
1898 | 1896 | } |
1899 | 1897 | |
1900 | 1898 | /** |
@@ -1906,7 +1904,7 @@ discard block |
||
1906 | 1904 | * |
1907 | 1905 | * @return void |
1908 | 1906 | */ |
1909 | -function give_checkout_hidden_fields( $form_id ) { |
|
1907 | +function give_checkout_hidden_fields($form_id) { |
|
1910 | 1908 | |
1911 | 1909 | /** |
1912 | 1910 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1915,13 +1913,13 @@ discard block |
||
1915 | 1913 | * |
1916 | 1914 | * @param int $form_id The form ID. |
1917 | 1915 | */ |
1918 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1916 | + do_action('give_hidden_fields_before', $form_id); |
|
1919 | 1917 | |
1920 | - if ( is_user_logged_in() ) { ?> |
|
1918 | + if (is_user_logged_in()) { ?> |
|
1921 | 1919 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1922 | 1920 | <?php } ?> |
1923 | 1921 | <input type="hidden" name="give_action" value="purchase"/> |
1924 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1922 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1925 | 1923 | <?php |
1926 | 1924 | /** |
1927 | 1925 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1930,7 +1928,7 @@ discard block |
||
1930 | 1928 | * |
1931 | 1929 | * @param int $form_id The form ID. |
1932 | 1930 | */ |
1933 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1931 | + do_action('give_hidden_fields_after', $form_id); |
|
1934 | 1932 | |
1935 | 1933 | } |
1936 | 1934 | |
@@ -1945,20 +1943,20 @@ discard block |
||
1945 | 1943 | * |
1946 | 1944 | * @return string $content Filtered content. |
1947 | 1945 | */ |
1948 | -function give_filter_success_page_content( $content ) { |
|
1946 | +function give_filter_success_page_content($content) { |
|
1949 | 1947 | |
1950 | 1948 | $give_options = give_get_settings(); |
1951 | 1949 | |
1952 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1953 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1954 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1950 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1951 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1952 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1955 | 1953 | } |
1956 | 1954 | } |
1957 | 1955 | |
1958 | 1956 | return $content; |
1959 | 1957 | } |
1960 | 1958 | |
1961 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1959 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1962 | 1960 | |
1963 | 1961 | /** |
1964 | 1962 | * Test Mode Frontend Warning. |
@@ -1969,12 +1967,12 @@ discard block |
||
1969 | 1967 | */ |
1970 | 1968 | function give_test_mode_frontend_warning() { |
1971 | 1969 | |
1972 | - if ( give_is_test_mode() ) { |
|
1973 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
1970 | + if (give_is_test_mode()) { |
|
1971 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
1974 | 1972 | } |
1975 | 1973 | } |
1976 | 1974 | |
1977 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1975 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1978 | 1976 | |
1979 | 1977 | /** |
1980 | 1978 | * Members-only Form. |
@@ -1988,21 +1986,21 @@ discard block |
||
1988 | 1986 | * |
1989 | 1987 | * @return string |
1990 | 1988 | */ |
1991 | -function give_members_only_form( $final_output, $args ) { |
|
1989 | +function give_members_only_form($final_output, $args) { |
|
1992 | 1990 | |
1993 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1991 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1994 | 1992 | |
1995 | 1993 | //Sanity Check: Must have form_id & not be logged in. |
1996 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1994 | + if (empty($form_id) || is_user_logged_in()) { |
|
1997 | 1995 | return $final_output; |
1998 | 1996 | } |
1999 | 1997 | |
2000 | 1998 | //Logged in only and Register / Login set to none. |
2001 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1999 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
2002 | 2000 | |
2003 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
2001 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
2004 | 2002 | |
2005 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
2003 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
2006 | 2004 | |
2007 | 2005 | } |
2008 | 2006 | |
@@ -2010,7 +2008,7 @@ discard block |
||
2010 | 2008 | |
2011 | 2009 | } |
2012 | 2010 | |
2013 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
2011 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
2014 | 2012 | |
2015 | 2013 | |
2016 | 2014 | /** |
@@ -2022,45 +2020,45 @@ discard block |
||
2022 | 2020 | * @param array $args |
2023 | 2021 | * @param Give_Donate_Form $form |
2024 | 2022 | */ |
2025 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
|
2026 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
2023 | +function __give_form_add_donation_hidden_field($form_id, $args, $form) { |
|
2024 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
2027 | 2025 | ?> |
2028 | 2026 | <input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/> |
2029 | - <input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/> |
|
2030 | - <input type="hidden" name="give-form-title" value="<?php echo esc_html( $form->post_title ); ?>"/> |
|
2031 | - <input type="hidden" name="give-current-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
2032 | - <input type="hidden" name="give-form-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
2027 | + <input type="hidden" name="give-form-id" value="<?php echo intval($form_id); ?>"/> |
|
2028 | + <input type="hidden" name="give-form-title" value="<?php echo esc_html($form->post_title); ?>"/> |
|
2029 | + <input type="hidden" name="give-current-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
2030 | + <input type="hidden" name="give-form-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
2033 | 2031 | <?php |
2034 | 2032 | // Get the custom option amount. |
2035 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
2033 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
2036 | 2034 | |
2037 | 2035 | // If custom amount enabled. |
2038 | - if ( give_is_setting_enabled( $custom_amount ) ) { |
|
2036 | + if (give_is_setting_enabled($custom_amount)) { |
|
2039 | 2037 | ?> |
2040 | 2038 | <input type="hidden" name="give-form-minimum" |
2041 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/> |
|
2039 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_minimum_price($form_id)); ?>"/> |
|
2042 | 2040 | <input type="hidden" name="give-form-maximum" |
2043 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/> |
|
2041 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_maximum_price($form_id)); ?>"/> |
|
2044 | 2042 | <?php |
2045 | 2043 | } |
2046 | 2044 | |
2047 | 2045 | // WP nonce field. |
2048 | 2046 | echo str_replace( |
2049 | 2047 | '/>', |
2050 | - 'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>', |
|
2051 | - give_get_nonce_field( "give_donation_form_nonce_{$form_id}", 'give-form-hash', false ) |
|
2048 | + 'data-time="'.time().'" data-nonce-life="'.give_get_nonce_life().'"/>', |
|
2049 | + give_get_nonce_field("give_donation_form_nonce_{$form_id}", 'give-form-hash', false) |
|
2052 | 2050 | ); |
2053 | 2051 | |
2054 | 2052 | // Price ID hidden field for variable (multi-level) donation forms. |
2055 | - if ( give_has_variable_prices( $form_id ) ) { |
|
2053 | + if (give_has_variable_prices($form_id)) { |
|
2056 | 2054 | |
2057 | 2055 | // Get default selected price ID. |
2058 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
2056 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
2059 | 2057 | $price_id = 0; |
2060 | 2058 | |
2061 | 2059 | // Loop through prices. |
2062 | - foreach ( $prices as $price ) { |
|
2063 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
2060 | + foreach ($prices as $price) { |
|
2061 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
2064 | 2062 | $price_id = $price['_give_id']['level_id']; |
2065 | 2063 | }; |
2066 | 2064 | } |
@@ -2073,7 +2071,7 @@ discard block |
||
2073 | 2071 | } |
2074 | 2072 | } |
2075 | 2073 | |
2076 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
|
2074 | +add_action('give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3); |
|
2077 | 2075 | |
2078 | 2076 | /** |
2079 | 2077 | * Add currency settings on donation form. |
@@ -2085,20 +2083,20 @@ discard block |
||
2085 | 2083 | * |
2086 | 2084 | * @return array |
2087 | 2085 | */ |
2088 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { |
|
2089 | - $form_currency = give_get_currency( $form->ID ); |
|
2090 | - $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
|
2086 | +function __give_form_add_currency_settings($form_html_tags, $form) { |
|
2087 | + $form_currency = give_get_currency($form->ID); |
|
2088 | + $currency_settings = give_get_currency_formatting_settings($form_currency); |
|
2091 | 2089 | |
2092 | 2090 | // Check if currency exist. |
2093 | - if ( empty( $currency_settings ) ) { |
|
2091 | + if (empty($currency_settings)) { |
|
2094 | 2092 | return $form_html_tags; |
2095 | 2093 | } |
2096 | 2094 | |
2097 | - $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
|
2095 | + $form_html_tags['data-currency_symbol'] = give_currency_symbol($form_currency); |
|
2098 | 2096 | $form_html_tags['data-currency_code'] = $form_currency; |
2099 | 2097 | |
2100 | - if ( ! empty( $currency_settings ) ) { |
|
2101 | - foreach ( $currency_settings as $key => $value ) { |
|
2098 | + if ( ! empty($currency_settings)) { |
|
2099 | + foreach ($currency_settings as $key => $value) { |
|
2102 | 2100 | $form_html_tags["data-{$key}"] = $value; |
2103 | 2101 | } |
2104 | 2102 | } |
@@ -2106,7 +2104,7 @@ discard block |
||
2106 | 2104 | return $form_html_tags; |
2107 | 2105 | } |
2108 | 2106 | |
2109 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
|
2107 | +add_filter('give_form_html_tags', '__give_form_add_currency_settings', 0, 2); |
|
2110 | 2108 | |
2111 | 2109 | /** |
2112 | 2110 | * Adds classes to progress bar container. |
@@ -2117,7 +2115,7 @@ discard block |
||
2117 | 2115 | * |
2118 | 2116 | * @return string |
2119 | 2117 | */ |
2120 | -function add_give_goal_progress_class( $class_goal ) { |
|
2118 | +function add_give_goal_progress_class($class_goal) { |
|
2121 | 2119 | $class_goal = 'progress progress-striped active'; |
2122 | 2120 | |
2123 | 2121 | return $class_goal; |
@@ -2132,7 +2130,7 @@ discard block |
||
2132 | 2130 | * |
2133 | 2131 | * @return string |
2134 | 2132 | */ |
2135 | -function add_give_goal_progress_bar_class( $class_bar ) { |
|
2133 | +function add_give_goal_progress_bar_class($class_bar) { |
|
2136 | 2134 | $class_bar = 'bar'; |
2137 | 2135 | |
2138 | 2136 | return $class_bar; |
@@ -2149,12 +2147,12 @@ discard block |
||
2149 | 2147 | * |
2150 | 2148 | * @return array |
2151 | 2149 | */ |
2152 | -function add_class_for_form_grid( $class, $id, $args ) { |
|
2150 | +function add_class_for_form_grid($class, $id, $args) { |
|
2153 | 2151 | $class[] = 'give-form-grid-wrap'; |
2154 | 2152 | |
2155 | - foreach ( $class as $index => $item ) { |
|
2156 | - if( false !== strpos( $item, 'give-display-' ) ) { |
|
2157 | - unset( $class[$index] ); |
|
2153 | + foreach ($class as $index => $item) { |
|
2154 | + if (false !== strpos($item, 'give-display-')) { |
|
2155 | + unset($class[$index]); |
|
2158 | 2156 | } |
2159 | 2157 | } |
2160 | 2158 | |
@@ -2170,7 +2168,7 @@ discard block |
||
2170 | 2168 | * |
2171 | 2169 | * @since 2.1 |
2172 | 2170 | */ |
2173 | -function give_is_form_grid_page_hidden_field( $id, $args, $form ) { |
|
2171 | +function give_is_form_grid_page_hidden_field($id, $args, $form) { |
|
2174 | 2172 | echo '<input type="hidden" name="is-form-grid" value="true" />'; |
2175 | 2173 | } |
2176 | 2174 | |
@@ -2185,28 +2183,28 @@ discard block |
||
2185 | 2183 | * @since 2.1 |
2186 | 2184 | * @return string |
2187 | 2185 | */ |
2188 | -function give_redirect_and_popup_form( $redirect, $args ) { |
|
2186 | +function give_redirect_and_popup_form($redirect, $args) { |
|
2189 | 2187 | |
2190 | 2188 | // Check the page has Form Grid. |
2191 | - $is_form_grid = isset( $_POST['is-form-grid'] ) ? give_clean( $_POST['is-form-grid'] ) : ''; |
|
2189 | + $is_form_grid = isset($_POST['is-form-grid']) ? give_clean($_POST['is-form-grid']) : ''; |
|
2192 | 2190 | |
2193 | - if ( 'true' === $is_form_grid ) { |
|
2191 | + if ('true' === $is_form_grid) { |
|
2194 | 2192 | |
2195 | - $payment_mode = give_clean( $_POST['payment-mode'] ); |
|
2193 | + $payment_mode = give_clean($_POST['payment-mode']); |
|
2196 | 2194 | $form_id = $args['form-id']; |
2197 | 2195 | |
2198 | 2196 | // Get the URL without Query parameters. |
2199 | - $redirect = strtok( $redirect, '?' ); |
|
2197 | + $redirect = strtok($redirect, '?'); |
|
2200 | 2198 | |
2201 | 2199 | // Add query parameters 'form-id' and 'payment-mode'. |
2202 | - $redirect = add_query_arg( array( |
|
2200 | + $redirect = add_query_arg(array( |
|
2203 | 2201 | 'form-id' => $form_id, |
2204 | 2202 | 'payment-mode' => $payment_mode, |
2205 | - ), $redirect ); |
|
2203 | + ), $redirect); |
|
2206 | 2204 | } |
2207 | 2205 | |
2208 | 2206 | // Return the modified URL. |
2209 | 2207 | return $redirect; |
2210 | 2208 | } |
2211 | 2209 | |
2212 | -add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 ); |
|
2210 | +add_filter('give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2); |
@@ -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 | |
@@ -18,56 +18,55 @@ discard block |
||
18 | 18 | ?> |
19 | 19 | <div class="wrap" id="poststuff"> |
20 | 20 | <div id="give-updates"> |
21 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1> |
|
21 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1> |
|
22 | 22 | <hr class="wp-header-end"> |
23 | 23 | |
24 | 24 | <?php $db_updates = $give_updates->get_pending_db_update_count(); ?> |
25 | - <?php if ( ! empty( $db_updates ) ) : ?> |
|
25 | + <?php if ( ! empty($db_updates)) : ?> |
|
26 | 26 | <?php |
27 | 27 | $is_doing_updates = $give_updates->is_doing_updates(); |
28 | - $db_update_url = add_query_arg( array( 'type' => 'database', ) ); |
|
29 | - $resume_updates = get_option( 'give_doing_upgrade' ); |
|
30 | - $width = ! empty( $resume_updates ) ? $resume_updates['percentage'] : 0; |
|
28 | + $db_update_url = add_query_arg(array('type' => 'database',)); |
|
29 | + $resume_updates = get_option('give_doing_upgrade'); |
|
30 | + $width = ! empty($resume_updates) ? $resume_updates['percentage'] : 0; |
|
31 | 31 | ?> |
32 | 32 | <div class="give-update-panel-content"> |
33 | - <p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p> |
|
33 | + <p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p> |
|
34 | 34 | </div> |
35 | 35 | |
36 | - <div id="give-db-updates" data-resume-update="<?php echo absint( $give_updates->is_doing_updates() ); ?>"> |
|
36 | + <div id="give-db-updates" data-resume-update="<?php echo absint($give_updates->is_doing_updates()); ?>"> |
|
37 | 37 | <div class="postbox-container"> |
38 | 38 | <div class="postbox"> |
39 | - <h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2> |
|
39 | + <h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2> |
|
40 | 40 | <div class="inside"> |
41 | 41 | <div class="panel-content"> |
42 | 42 | <p class="give-update-button"> |
43 | - <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
43 | + <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
44 | 44 | <?php echo sprintf( |
45 | - __( '%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give' ), |
|
45 | + __('%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give'), |
|
46 | 46 | $is_doing_updates ? |
47 | - __( 'Give is currently updating the database in the background.', 'give' ) : |
|
48 | - __( 'Give needs to update the database.', 'give' ), |
|
47 | + __('Give is currently updating the database in the background.', 'give') : __('Give needs to update the database.', 'give'), |
|
49 | 48 | $db_update_url, |
50 | - ( $is_doing_updates ? 'give-hidden' : '' ), |
|
51 | - __( 'Update now', 'give' ) |
|
49 | + ($is_doing_updates ? 'give-hidden' : ''), |
|
50 | + __('Update now', 'give') |
|
52 | 51 | ); |
53 | 52 | ?> |
54 | 53 | </span> |
55 | - <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
56 | - <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
|
57 | - <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
54 | + <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
55 | + <?php if (get_option('give_upgrade_error')) : ?> |
|
56 | + <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
58 | 57 | <?php else : ?> |
59 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
58 | + <?php _e('The updates have been paused.', 'give'); ?> |
|
60 | 59 | |
61 | 60 | <?php endif; ?> |
62 | 61 | </span> |
63 | 62 | |
64 | - <?php if ( Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
65 | - <?php $is_disabled = isset( $_GET['give-restart-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
66 | - <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>><?php _e( 'Restart Upgrades', 'give' ); ?></button> |
|
67 | - <?php elseif( $give_updates->is_doing_updates() ): ?> |
|
68 | - <?php $is_disabled = isset( $_GET['give-pause-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
69 | - <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>> |
|
70 | - <?php _e( 'Pause Upgrades', 'give' ); ?> |
|
63 | + <?php if (Give_Updates::$background_updater->is_paused_process()) : ?> |
|
64 | + <?php $is_disabled = isset($_GET['give-restart-db-upgrades']) ? ' disabled' : ''; ?> |
|
65 | + <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>><?php _e('Restart Upgrades', 'give'); ?></button> |
|
66 | + <?php elseif ($give_updates->is_doing_updates()): ?> |
|
67 | + <?php $is_disabled = isset($_GET['give-pause-db-upgrades']) ? ' disabled' : ''; ?> |
|
68 | + <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>> |
|
69 | + <?php _e('Pause Upgrades', 'give'); ?> |
|
71 | 70 | </button> |
72 | 71 | <?php endif; ?> |
73 | 72 | </p> |
@@ -77,7 +76,7 @@ discard block |
||
77 | 76 | <strong> |
78 | 77 | <?php |
79 | 78 | echo sprintf( |
80 | - __( 'Update %s of %s', 'give' ), |
|
79 | + __('Update %s of %s', 'give'), |
|
81 | 80 | $give_updates->get_running_db_update(), |
82 | 81 | $give_updates->get_total_new_db_update_count() |
83 | 82 | ); |
@@ -85,10 +84,10 @@ discard block |
||
85 | 84 | </strong> |
86 | 85 | </p> |
87 | 86 | <div class="progress-content"> |
88 | - <?php if ( $is_doing_updates ) : ?> |
|
87 | + <?php if ($is_doing_updates) : ?> |
|
89 | 88 | <div class="notice-wrap give-clearfix"> |
90 | 89 | |
91 | - <?php if ( ! Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
90 | + <?php if ( ! Give_Updates::$background_updater->is_paused_process()) : ?> |
|
92 | 91 | <span class="spinner is-active"></span> |
93 | 92 | <?php endif; ?> |
94 | 93 | |
@@ -100,7 +99,7 @@ discard block |
||
100 | 99 | </div> |
101 | 100 | </div> |
102 | 101 | |
103 | - <?php if ( ! $is_doing_updates ) : ?> |
|
102 | + <?php if ( ! $is_doing_updates) : ?> |
|
104 | 103 | <div class="give-run-database-update"></div> |
105 | 104 | <?php endif; ?> |
106 | 105 | </div> |
@@ -108,18 +107,18 @@ discard block |
||
108 | 107 | </div><!-- .postbox --> |
109 | 108 | </div> <!-- .post-container --> |
110 | 109 | </div> |
111 | - <?php else: include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php';?> |
|
110 | + <?php else: include GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; ?> |
|
112 | 111 | <?php endif; ?> |
113 | 112 | |
114 | 113 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
115 | - <?php if ( ! empty( $plugin_updates ) ) : ?> |
|
116 | - <?php $plugin_update_url = add_query_arg( array( |
|
114 | + <?php if ( ! empty($plugin_updates)) : ?> |
|
115 | + <?php $plugin_update_url = add_query_arg(array( |
|
117 | 116 | 'plugin_status' => 'give', |
118 | - ), admin_url( '/plugins.php' ) ); ?> |
|
117 | + ), admin_url('/plugins.php')); ?> |
|
119 | 118 | <div id="give-plugin-updates"> |
120 | 119 | <div class="postbox-container"> |
121 | 120 | <div class="postbox"> |
122 | - <h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2> |
|
121 | + <h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2> |
|
123 | 122 | <div class="inside"> |
124 | 123 | <div class="panel-content"> |
125 | 124 | <p> |
@@ -55,8 +55,11 @@ discard block |
||
55 | 55 | <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
56 | 56 | <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
57 | 57 | <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
58 | - <?php else : ?> |
|
59 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
58 | + <?php else { |
|
59 | + : ?> |
|
60 | + <?php _e( 'The updates have been paused.', 'give' ); |
|
61 | +} |
|
62 | +?> |
|
60 | 63 | |
61 | 64 | <?php endif; ?> |
62 | 65 | </span> |
@@ -108,7 +111,10 @@ discard block |
||
108 | 111 | </div><!-- .postbox --> |
109 | 112 | </div> <!-- .post-container --> |
110 | 113 | </div> |
111 | - <?php else: include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php';?> |
|
114 | + <?php else { |
|
115 | + : include GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/db-upgrades-complete-metabox.php'; |
|
116 | +} |
|
117 | +?> |
|
112 | 118 | <?php endif; ?> |
113 | 119 | |
114 | 120 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* @var Give_Updates $give_updates */ |
3 | -$plugins = $give_updates->get_updates( 'plugin' ); |
|
4 | -if ( empty( $plugins ) ) { |
|
3 | +$plugins = $give_updates->get_updates('plugin'); |
|
4 | +if (empty($plugins)) { |
|
5 | 5 | return; |
6 | 6 | } |
7 | 7 | |
8 | 8 | ob_start(); |
9 | -foreach ( $plugins as $plugin_data ) { |
|
10 | - if ( 'active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type'] ) { |
|
9 | +foreach ($plugins as $plugin_data) { |
|
10 | + if ('active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type']) { |
|
11 | 11 | continue; |
12 | 12 | } |
13 | 13 | |
@@ -15,45 +15,45 @@ discard block |
||
15 | 15 | $author_name = $plugin_data['Author']; |
16 | 16 | |
17 | 17 | // Link the plugin name to the plugin URL if available. |
18 | - if ( ! empty( $plugin_data['PluginURI'] ) ) { |
|
18 | + if ( ! empty($plugin_data['PluginURI'])) { |
|
19 | 19 | $plugin_name = sprintf( |
20 | 20 | '<a href="%s" title="%s">%s</a> (%s)', |
21 | - esc_url( $plugin_data['PluginURI'] ), |
|
22 | - esc_attr__( 'Visit plugin homepage', 'give' ), |
|
21 | + esc_url($plugin_data['PluginURI']), |
|
22 | + esc_attr__('Visit plugin homepage', 'give'), |
|
23 | 23 | $plugin_name, |
24 | - esc_html( $plugin_data['Version'] ) |
|
24 | + esc_html($plugin_data['Version']) |
|
25 | 25 | ); |
26 | 26 | } |
27 | 27 | |
28 | 28 | // Link the author name to the author URL if available. |
29 | - if ( ! empty( $plugin_data['AuthorURI'] ) ) { |
|
29 | + if ( ! empty($plugin_data['AuthorURI'])) { |
|
30 | 30 | $author_name = sprintf( |
31 | 31 | '<a href="%s" title="%s">%s</a>', |
32 | - esc_url( $plugin_data['AuthorURI'] ), |
|
33 | - esc_attr__( 'Visit author homepage', 'give' ), |
|
32 | + esc_url($plugin_data['AuthorURI']), |
|
33 | + esc_attr__('Visit author homepage', 'give'), |
|
34 | 34 | $author_name |
35 | 35 | ); |
36 | 36 | } |
37 | 37 | ?> |
38 | 38 | <tr> |
39 | - <td><?php echo wp_kses( $plugin_name, wp_kses_allowed_html( 'post' ) ); ?></td> |
|
39 | + <td><?php echo wp_kses($plugin_name, wp_kses_allowed_html('post')); ?></td> |
|
40 | 40 | <td> |
41 | 41 | <?php |
42 | 42 | echo true === $plugin_data['License'] |
43 | 43 | ? sprintf( |
44 | 44 | '<span class="dashicons dashicons-yes"></span>%s', |
45 | - __( 'Licensed', 'give' ) |
|
45 | + __('Licensed', 'give') |
|
46 | 46 | ) |
47 | 47 | : sprintf( |
48 | 48 | '<span data-tooltip="%s"><span class="dashicons dashicons-no-alt"></span>%s</span>', |
49 | - __( 'Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give' ), |
|
50 | - __( 'Unlicensed', 'give' ) |
|
49 | + __('Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give'), |
|
50 | + __('Unlicensed', 'give') |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | echo sprintf( |
54 | 54 | ' – %s – %s', |
55 | - sprintf( _x( 'by %s', 'by author', 'give' ), wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ), |
|
56 | - sprintf( __( '(Latest Version: %s)' ), $plugin_data['update']->new_version ) |
|
55 | + sprintf(_x('by %s', 'by author', 'give'), wp_kses($author_name, wp_kses_allowed_html('post'))), |
|
56 | + sprintf(__('(Latest Version: %s)'), $plugin_data['update']->new_version) |
|
57 | 57 | ); |
58 | 58 | ?> |
59 | 59 | </td> |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
69 | + case version_compare($give_version, '1.8.17', '<') : |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | |
73 | - case version_compare( $give_version, '1.8.18', '<' ) : |
|
73 | + case version_compare($give_version, '1.8.18', '<') : |
|
74 | 74 | give_v1818_upgrades(); |
75 | 75 | $did_upgrade = true; |
76 | 76 | |
77 | - case version_compare( $give_version, '2.0', '<' ) : |
|
77 | + case version_compare($give_version, '2.0', '<') : |
|
78 | 78 | give_v20_upgrades(); |
79 | 79 | $did_upgrade = true; |
80 | 80 | |
81 | - case version_compare( $give_version, '2.0.1', '<' ) : |
|
81 | + case version_compare($give_version, '2.0.1', '<') : |
|
82 | 82 | // Do nothing on fresh install. |
83 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
83 | + if ( ! doing_action('give_upgrades')) { |
|
84 | 84 | give_v201_create_tables(); |
85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
86 | 86 | Give_Updates::$background_updater->dispatch(); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $did_upgrade = true; |
90 | 90 | |
91 | - case version_compare( $give_version, '2.0.2', '<' ) : |
|
91 | + case version_compare($give_version, '2.0.2', '<') : |
|
92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
94 | 94 | $v201_updates = array( |
@@ -98,35 +98,35 @@ discard block |
||
98 | 98 | 'v201_logs_upgrades', |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $v201_updates as $v201_update ) { |
|
102 | - if ( in_array( $v201_update, $completed_upgrades ) ) { |
|
103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades ) ] ); |
|
101 | + foreach ($v201_updates as $v201_update) { |
|
102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
107 | + update_option('give_completed_upgrades', $completed_upgrades); |
|
108 | 108 | |
109 | 109 | // Do nothing on fresh install. |
110 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
110 | + if ( ! doing_action('give_upgrades')) { |
|
111 | 111 | give_v201_create_tables(); |
112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
113 | 113 | Give_Updates::$background_updater->dispatch(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $did_upgrade = true; |
117 | 117 | |
118 | - case version_compare( $give_version, '2.0.3', '<' ) : |
|
118 | + case version_compare($give_version, '2.0.3', '<') : |
|
119 | 119 | give_v203_upgrades(); |
120 | 120 | $did_upgrade = true; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $did_upgrade ) { |
|
124 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
123 | + if ($did_upgrade) { |
|
124 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
129 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
128 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
129 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Display Upgrade Notices. |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | -function give_show_upgrade_notices( $give_updates ) { |
|
143 | +function give_show_upgrade_notices($give_updates) { |
|
144 | 144 | // v1.3.2 Upgrades |
145 | 145 | $give_updates->register( |
146 | 146 | array( |
@@ -206,32 +206,32 @@ discard block |
||
206 | 206 | ); |
207 | 207 | |
208 | 208 | // v1.8.17 Upgrades for donations. |
209 | - $give_updates->register( array( |
|
209 | + $give_updates->register(array( |
|
210 | 210 | 'id' => 'v1817_update_donation_iranian_currency_code', |
211 | 211 | 'version' => '1.8.17', |
212 | 212 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
213 | - ) ); |
|
213 | + )); |
|
214 | 214 | |
215 | 215 | // v1.8.17 Upgrades for cleanup of user roles. |
216 | - $give_updates->register( array( |
|
216 | + $give_updates->register(array( |
|
217 | 217 | 'id' => 'v1817_cleanup_user_roles', |
218 | 218 | 'version' => '1.8.17', |
219 | 219 | 'callback' => 'give_v1817_cleanup_user_roles', |
220 | - ) ); |
|
220 | + )); |
|
221 | 221 | |
222 | 222 | // v1.8.18 Upgrades for assigning custom amount to existing set donations. |
223 | - $give_updates->register( array( |
|
223 | + $give_updates->register(array( |
|
224 | 224 | 'id' => 'v1818_assign_custom_amount_set_donation', |
225 | 225 | 'version' => '1.8.18', |
226 | 226 | 'callback' => 'give_v1818_assign_custom_amount_set_donation', |
227 | - ) ); |
|
227 | + )); |
|
228 | 228 | |
229 | 229 | // v1.8.18 Cleanup the Give Worker Role Caps. |
230 | - $give_updates->register( array( |
|
230 | + $give_updates->register(array( |
|
231 | 231 | 'id' => 'v1818_give_worker_role_cleanup', |
232 | 232 | 'version' => '1.8.18', |
233 | 233 | 'callback' => 'give_v1818_give_worker_role_cleanup', |
234 | - ) ); |
|
234 | + )); |
|
235 | 235 | |
236 | 236 | // v2.0.0 Upgrades |
237 | 237 | $give_updates->register( |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'id' => 'v20_move_metadata_into_new_table', |
286 | 286 | 'version' => '2.0.0', |
287 | 287 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
288 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
288 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
289 | 289 | ) |
290 | 290 | ); |
291 | 291 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | 'id' => 'v201_move_metadata_into_new_table', |
332 | 332 | 'version' => '2.0.1', |
333 | 333 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
334 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
334 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | 'id' => 'v213_delete_donation_meta', |
360 | 360 | 'version' => '2.1.3', |
361 | 361 | 'callback' => 'give_v213_delete_donation_meta_callback', |
362 | - 'depends' => array( 'v201_move_metadata_into_new_table' ) |
|
362 | + 'depends' => array('v201_move_metadata_into_new_table') |
|
363 | 363 | ) |
364 | 364 | ); |
365 | 365 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | |
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
377 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Triggers all upgrade functions |
@@ -386,29 +386,29 @@ discard block |
||
386 | 386 | */ |
387 | 387 | function give_trigger_upgrades() { |
388 | 388 | |
389 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
390 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
389 | + if ( ! current_user_can('manage_give_settings')) { |
|
390 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
391 | 391 | 'response' => 403, |
392 | - ) ); |
|
392 | + )); |
|
393 | 393 | } |
394 | 394 | |
395 | - $give_version = get_option( 'give_version' ); |
|
395 | + $give_version = get_option('give_version'); |
|
396 | 396 | |
397 | - if ( ! $give_version ) { |
|
397 | + if ( ! $give_version) { |
|
398 | 398 | // 1.0 is the first version to use this option so we must add it. |
399 | 399 | $give_version = '1.0'; |
400 | - add_option( 'give_version', $give_version ); |
|
400 | + add_option('give_version', $give_version); |
|
401 | 401 | } |
402 | 402 | |
403 | - update_option( 'give_version', GIVE_VERSION ); |
|
404 | - delete_option( 'give_doing_upgrade' ); |
|
403 | + update_option('give_version', GIVE_VERSION); |
|
404 | + delete_option('give_doing_upgrade'); |
|
405 | 405 | |
406 | - if ( DOING_AJAX ) { |
|
407 | - die( 'complete' ); |
|
406 | + if (DOING_AJAX) { |
|
407 | + die('complete'); |
|
408 | 408 | } // End if(). |
409 | 409 | } |
410 | 410 | |
411 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
411 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
412 | 412 | |
413 | 413 | |
414 | 414 | /** |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | |
427 | 427 | // UPDATE DB METAKEYS. |
428 | 428 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
429 | - $query = $wpdb->query( $sql ); |
|
429 | + $query = $wpdb->query($sql); |
|
430 | 430 | |
431 | 431 | $give_updates->percentage = 100; |
432 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
432 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -453,24 +453,24 @@ discard block |
||
453 | 453 | $where .= "AND ( p.post_status = 'abandoned' )"; |
454 | 454 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
455 | 455 | |
456 | - $sql = $select . $join . $where; |
|
457 | - $found_payments = $wpdb->get_col( $sql ); |
|
456 | + $sql = $select.$join.$where; |
|
457 | + $found_payments = $wpdb->get_col($sql); |
|
458 | 458 | |
459 | - foreach ( $found_payments as $payment ) { |
|
459 | + foreach ($found_payments as $payment) { |
|
460 | 460 | |
461 | 461 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
462 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
462 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
463 | 463 | |
464 | 464 | // 1450124863 = 12/10/2015 20:42:25. |
465 | - if ( $modified_time >= 1450124863 ) { |
|
465 | + if ($modified_time >= 1450124863) { |
|
466 | 466 | |
467 | - give_update_payment_status( $payment, 'pending' ); |
|
467 | + give_update_payment_status($payment, 'pending'); |
|
468 | 468 | |
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
472 | 472 | $give_updates->percentage = 100; |
473 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
473 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -483,17 +483,17 @@ discard block |
||
483 | 483 | */ |
484 | 484 | function give_v152_cleanup_users() { |
485 | 485 | |
486 | - $give_version = get_option( 'give_version' ); |
|
486 | + $give_version = get_option('give_version'); |
|
487 | 487 | |
488 | - if ( ! $give_version ) { |
|
488 | + if ( ! $give_version) { |
|
489 | 489 | // 1.0 is the first version to use this option so we must add it. |
490 | 490 | $give_version = '1.0'; |
491 | 491 | } |
492 | 492 | |
493 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
493 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
494 | 494 | |
495 | 495 | // v1.5.2 Upgrades |
496 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
496 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
497 | 497 | |
498 | 498 | // Delete all caps with "ss". |
499 | 499 | // Also delete all unused "campaign" roles. |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | ); |
541 | 541 | |
542 | 542 | global $wp_roles; |
543 | - foreach ( $delete_caps as $cap ) { |
|
544 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
545 | - $wp_roles->remove_cap( $role, $cap ); |
|
543 | + foreach ($delete_caps as $cap) { |
|
544 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
545 | + $wp_roles->remove_cap($role, $cap); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
@@ -552,15 +552,15 @@ discard block |
||
552 | 552 | $roles->add_caps(); |
553 | 553 | |
554 | 554 | // The Update Ran. |
555 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
556 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
557 | - delete_option( 'give_doing_upgrade' ); |
|
555 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
556 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
557 | + delete_option('give_doing_upgrade'); |
|
558 | 558 | |
559 | 559 | }// End if(). |
560 | 560 | |
561 | 561 | } |
562 | 562 | |
563 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
563 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
564 | 564 | |
565 | 565 | /** |
566 | 566 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -603,53 +603,53 @@ discard block |
||
603 | 603 | |
604 | 604 | // Get addons license key. |
605 | 605 | $addons = array(); |
606 | - foreach ( $give_options as $key => $value ) { |
|
607 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
608 | - $addons[ $key ] = $value; |
|
606 | + foreach ($give_options as $key => $value) { |
|
607 | + if (false !== strpos($key, '_license_key')) { |
|
608 | + $addons[$key] = $value; |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
612 | 612 | // Bailout: We do not have any addon license data to upgrade. |
613 | - if ( empty( $addons ) ) { |
|
613 | + if (empty($addons)) { |
|
614 | 614 | return false; |
615 | 615 | } |
616 | 616 | |
617 | - foreach ( $addons as $key => $addon_license ) { |
|
617 | + foreach ($addons as $key => $addon_license) { |
|
618 | 618 | |
619 | 619 | // Get addon shortname. |
620 | - $shortname = str_replace( '_license_key', '', $key ); |
|
620 | + $shortname = str_replace('_license_key', '', $key); |
|
621 | 621 | |
622 | 622 | // Addon license option name. |
623 | - $addon_license_option_name = $shortname . '_license_active'; |
|
623 | + $addon_license_option_name = $shortname.'_license_active'; |
|
624 | 624 | |
625 | 625 | // bailout if license is empty. |
626 | - if ( empty( $addon_license ) ) { |
|
627 | - delete_option( $addon_license_option_name ); |
|
626 | + if (empty($addon_license)) { |
|
627 | + delete_option($addon_license_option_name); |
|
628 | 628 | continue; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // Get addon name. |
632 | 632 | $addon_name = array(); |
633 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
634 | - foreach ( $addon_name_parts as $name_part ) { |
|
633 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
634 | + foreach ($addon_name_parts as $name_part) { |
|
635 | 635 | |
636 | 636 | // Fix addon name |
637 | - switch ( $name_part ) { |
|
637 | + switch ($name_part) { |
|
638 | 638 | case 'authorizenet' : |
639 | 639 | $name_part = 'authorize.net'; |
640 | 640 | break; |
641 | 641 | } |
642 | 642 | |
643 | - $addon_name[] = ucfirst( $name_part ); |
|
643 | + $addon_name[] = ucfirst($name_part); |
|
644 | 644 | } |
645 | 645 | |
646 | - $addon_name = implode( ' ', $addon_name ); |
|
646 | + $addon_name = implode(' ', $addon_name); |
|
647 | 647 | |
648 | 648 | // Data to send to the API. |
649 | 649 | $api_params = array( |
650 | 650 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
651 | 651 | 'license' => $addon_license, |
652 | - 'item_name' => urlencode( $addon_name ), |
|
652 | + 'item_name' => urlencode($addon_name), |
|
653 | 653 | 'url' => home_url(), |
654 | 654 | ); |
655 | 655 | |
@@ -664,17 +664,17 @@ discard block |
||
664 | 664 | ); |
665 | 665 | |
666 | 666 | // Make sure there are no errors. |
667 | - if ( is_wp_error( $response ) ) { |
|
668 | - delete_option( $addon_license_option_name ); |
|
667 | + if (is_wp_error($response)) { |
|
668 | + delete_option($addon_license_option_name); |
|
669 | 669 | continue; |
670 | 670 | } |
671 | 671 | |
672 | 672 | // Tell WordPress to look for updates. |
673 | - set_site_transient( 'update_plugins', null ); |
|
673 | + set_site_transient('update_plugins', null); |
|
674 | 674 | |
675 | 675 | // Decode license data. |
676 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
677 | - update_option( $addon_license_option_name, $license_data ); |
|
676 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
677 | + update_option($addon_license_option_name, $license_data); |
|
678 | 678 | }// End foreach(). |
679 | 679 | } |
680 | 680 | |
@@ -704,9 +704,9 @@ discard block |
||
704 | 704 | ); |
705 | 705 | |
706 | 706 | global $wp_roles; |
707 | - foreach ( $delete_caps as $cap ) { |
|
708 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
709 | - $wp_roles->remove_cap( $role, $cap ); |
|
707 | + foreach ($delete_caps as $cap) { |
|
708 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
709 | + $wp_roles->remove_cap($role, $cap); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | function give_v18_upgrades_core_setting() { |
741 | 741 | // Core settings which changes from checkbox to radio. |
742 | 742 | $core_setting_names = array_merge( |
743 | - array_keys( give_v18_renamed_core_settings() ), |
|
743 | + array_keys(give_v18_renamed_core_settings()), |
|
744 | 744 | array( |
745 | 745 | 'uninstall_on_delete', |
746 | 746 | 'scripts_footer', |
@@ -752,48 +752,48 @@ discard block |
||
752 | 752 | ); |
753 | 753 | |
754 | 754 | // Bailout: If not any setting define. |
755 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
755 | + if ($give_settings = get_option('give_settings')) { |
|
756 | 756 | |
757 | 757 | $setting_changed = false; |
758 | 758 | |
759 | 759 | // Loop: check each setting field. |
760 | - foreach ( $core_setting_names as $setting_name ) { |
|
760 | + foreach ($core_setting_names as $setting_name) { |
|
761 | 761 | // New setting name. |
762 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
762 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
763 | 763 | |
764 | 764 | // Continue: If setting already set. |
765 | 765 | if ( |
766 | - array_key_exists( $new_setting_name, $give_settings ) |
|
767 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
766 | + array_key_exists($new_setting_name, $give_settings) |
|
767 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
768 | 768 | ) { |
769 | 769 | continue; |
770 | 770 | } |
771 | 771 | |
772 | 772 | // Set checkbox value to radio value. |
773 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
773 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
774 | 774 | |
775 | 775 | // @see https://github.com/WordImpress/Give/issues/1063. |
776 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
776 | + if (false !== strpos($setting_name, 'disable_')) { |
|
777 | 777 | |
778 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
779 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
778 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
779 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
780 | 780 | |
781 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
781 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | // Tell bot to update core setting to db. |
785 | - if ( ! $setting_changed ) { |
|
785 | + if ( ! $setting_changed) { |
|
786 | 786 | $setting_changed = true; |
787 | 787 | } |
788 | 788 | } |
789 | 789 | |
790 | 790 | // Update setting only if they changed. |
791 | - if ( $setting_changed ) { |
|
792 | - update_option( 'give_settings', $give_settings ); |
|
791 | + if ($setting_changed) { |
|
792 | + update_option('give_settings', $give_settings); |
|
793 | 793 | } |
794 | 794 | }// End if(). |
795 | 795 | |
796 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
796 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | /** |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | $give_updates = Give_Updates::get_instance(); |
808 | 808 | |
809 | 809 | // form query |
810 | - $forms = new WP_Query( array( |
|
810 | + $forms = new WP_Query(array( |
|
811 | 811 | 'paged' => $give_updates->step, |
812 | 812 | 'status' => 'any', |
813 | 813 | 'order' => 'ASC', |
@@ -816,41 +816,41 @@ discard block |
||
816 | 816 | ) |
817 | 817 | ); |
818 | 818 | |
819 | - if ( $forms->have_posts() ) { |
|
820 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
819 | + if ($forms->have_posts()) { |
|
820 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
821 | 821 | |
822 | - while ( $forms->have_posts() ) { |
|
822 | + while ($forms->have_posts()) { |
|
823 | 823 | $forms->the_post(); |
824 | 824 | |
825 | 825 | // Form content. |
826 | 826 | // Note in version 1.8 display content setting split into display content and content placement setting. |
827 | 827 | // You can delete _give_content_option in future. |
828 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
829 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
830 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
831 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
828 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
829 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
830 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
831 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
832 | 832 | |
833 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
834 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
833 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
834 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | // "Disable" Guest Donation. Checkbox. |
838 | 838 | // See: https://github.com/WordImpress/Give/issues/1470. |
839 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
840 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
841 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
839 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
840 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
841 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
842 | 842 | |
843 | 843 | // Offline Donations. |
844 | 844 | // See: https://github.com/WordImpress/Give/issues/1579. |
845 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
846 | - if ( 'no' === $offline_donation ) { |
|
845 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
846 | + if ('no' === $offline_donation) { |
|
847 | 847 | $offline_donation_newval = 'global'; |
848 | - } elseif ( 'yes' === $offline_donation ) { |
|
848 | + } elseif ('yes' === $offline_donation) { |
|
849 | 849 | $offline_donation_newval = 'enabled'; |
850 | 850 | } else { |
851 | 851 | $offline_donation_newval = 'disabled'; |
852 | 852 | } |
853 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
853 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
854 | 854 | |
855 | 855 | // Convert yes/no setting field to enabled/disabled. |
856 | 856 | $form_radio_settings = array( |
@@ -870,15 +870,15 @@ discard block |
||
870 | 870 | '_give_offline_donation_enable_billing_fields_single', |
871 | 871 | ); |
872 | 872 | |
873 | - foreach ( $form_radio_settings as $meta_key ) { |
|
873 | + foreach ($form_radio_settings as $meta_key) { |
|
874 | 874 | // Get value. |
875 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
875 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
876 | 876 | |
877 | 877 | // Convert meta value only if it is in yes/no/none. |
878 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
878 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
879 | 879 | |
880 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
881 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
880 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
881 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
882 | 882 | } |
883 | 883 | } |
884 | 884 | }// End while(). |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | |
888 | 888 | } else { |
889 | 889 | // No more forms found, finish up. |
890 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
890 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | '%_transient_give_stats_%', |
955 | 955 | 'give_cache%', |
956 | 956 | '%_transient_give_add_ons_feed%', |
957 | - '%_transient__give_ajax_works' . |
|
957 | + '%_transient__give_ajax_works'. |
|
958 | 958 | '%_transient_give_total_api_keys%', |
959 | 959 | '%_transient_give_i18n_give_promo_hide%', |
960 | 960 | '%_transient_give_contributors%', |
@@ -981,24 +981,24 @@ discard block |
||
981 | 981 | ARRAY_A |
982 | 982 | ); |
983 | 983 | |
984 | - if ( ! empty( $user_apikey_options ) ) { |
|
985 | - foreach ( $user_apikey_options as $user ) { |
|
986 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
987 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
988 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
984 | + if ( ! empty($user_apikey_options)) { |
|
985 | + foreach ($user_apikey_options as $user) { |
|
986 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
987 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
988 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
989 | 989 | } |
990 | 990 | } |
991 | 991 | |
992 | - if ( ! empty( $cached_options ) ) { |
|
993 | - foreach ( $cached_options as $option ) { |
|
994 | - switch ( true ) { |
|
995 | - case ( false !== strpos( $option, 'transient' ) ): |
|
996 | - $option = str_replace( '_transient_', '', $option ); |
|
997 | - delete_transient( $option ); |
|
992 | + if ( ! empty($cached_options)) { |
|
993 | + foreach ($cached_options as $option) { |
|
994 | + switch (true) { |
|
995 | + case (false !== strpos($option, 'transient')): |
|
996 | + $option = str_replace('_transient_', '', $option); |
|
997 | + delete_transient($option); |
|
998 | 998 | break; |
999 | 999 | |
1000 | 1000 | default: |
1001 | - delete_option( $option ); |
|
1001 | + delete_option($option); |
|
1002 | 1002 | } |
1003 | 1003 | } |
1004 | 1004 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | global $wp_roles; |
1017 | 1017 | |
1018 | 1018 | // Get the role object. |
1019 | - $give_worker = get_role( 'give_worker' ); |
|
1019 | + $give_worker = get_role('give_worker'); |
|
1020 | 1020 | |
1021 | 1021 | // A list of capabilities to add for give workers. |
1022 | 1022 | $caps_to_add = array( |
@@ -1024,9 +1024,9 @@ discard block |
||
1024 | 1024 | 'edit_pages', |
1025 | 1025 | ); |
1026 | 1026 | |
1027 | - foreach ( $caps_to_add as $cap ) { |
|
1027 | + foreach ($caps_to_add as $cap) { |
|
1028 | 1028 | // Add the capability. |
1029 | - $give_worker->add_cap( $cap ); |
|
1029 | + $give_worker->add_cap($cap); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | } |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | $give_updates = Give_Updates::get_instance(); |
1044 | 1044 | |
1045 | 1045 | // form query. |
1046 | - $donation_forms = new WP_Query( array( |
|
1046 | + $donation_forms = new WP_Query(array( |
|
1047 | 1047 | 'paged' => $give_updates->step, |
1048 | 1048 | 'status' => 'any', |
1049 | 1049 | 'order' => 'ASC', |
@@ -1052,10 +1052,10 @@ discard block |
||
1052 | 1052 | ) |
1053 | 1053 | ); |
1054 | 1054 | |
1055 | - if ( $donation_forms->have_posts() ) { |
|
1056 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1055 | + if ($donation_forms->have_posts()) { |
|
1056 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1057 | 1057 | |
1058 | - while ( $donation_forms->have_posts() ) { |
|
1058 | + while ($donation_forms->have_posts()) { |
|
1059 | 1059 | $donation_forms->the_post(); |
1060 | 1060 | $form_id = get_the_ID(); |
1061 | 1061 | |
@@ -1063,41 +1063,41 @@ discard block |
||
1063 | 1063 | update_post_meta( |
1064 | 1064 | $form_id, |
1065 | 1065 | '_give_set_price', |
1066 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
1066 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
1067 | 1067 | ); |
1068 | 1068 | |
1069 | 1069 | // Remove formatting from _give_custom_amount_minimum. |
1070 | 1070 | update_post_meta( |
1071 | 1071 | $form_id, |
1072 | 1072 | '_give_custom_amount_minimum', |
1073 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1073 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1074 | 1074 | ); |
1075 | 1075 | |
1076 | 1076 | // Bailout. |
1077 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1077 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1078 | 1078 | continue; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1081 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1082 | 1082 | |
1083 | - if ( ! empty( $donation_levels ) ) { |
|
1083 | + if ( ! empty($donation_levels)) { |
|
1084 | 1084 | |
1085 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1086 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
1087 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1085 | + foreach ($donation_levels as $index => $donation_level) { |
|
1086 | + if (isset($donation_level['_give_amount'])) { |
|
1087 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1088 | 1088 | } |
1089 | 1089 | } |
1090 | 1090 | |
1091 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1091 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1092 | 1092 | |
1093 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1093 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1094 | 1094 | |
1095 | - $min_amount = min( $donation_levels_amounts ); |
|
1096 | - $max_amount = max( $donation_levels_amounts ); |
|
1095 | + $min_amount = min($donation_levels_amounts); |
|
1096 | + $max_amount = max($donation_levels_amounts); |
|
1097 | 1097 | |
1098 | 1098 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1099 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1100 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1099 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1100 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | wp_reset_postdata(); |
1107 | 1107 | } else { |
1108 | 1108 | // The Update Ran. |
1109 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1109 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | function give_v20_upgrades() { |
1158 | 1158 | // Update cache setting. |
1159 | - give_update_option( 'cache', 'enabled' ); |
|
1159 | + give_update_option('cache', 'enabled'); |
|
1160 | 1160 | |
1161 | 1161 | // Upgrade email settings. |
1162 | 1162 | give_v20_upgrades_email_setting(); |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | $all_setting = give_get_settings(); |
1176 | 1176 | |
1177 | 1177 | // Bailout on fresh install. |
1178 | - if ( empty( $all_setting ) ) { |
|
1178 | + if (empty($all_setting)) { |
|
1179 | 1179 | return; |
1180 | 1180 | } |
1181 | 1181 | |
@@ -1194,19 +1194,19 @@ discard block |
||
1194 | 1194 | 'admin_notices' => 'new-donation_notification', |
1195 | 1195 | ); |
1196 | 1196 | |
1197 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
1197 | + foreach ($settings as $old_setting => $new_setting) { |
|
1198 | 1198 | // Do not update already modified |
1199 | - if ( ! is_array( $new_setting ) ) { |
|
1200 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
1199 | + if ( ! is_array($new_setting)) { |
|
1200 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
1201 | 1201 | continue; |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | 1204 | |
1205 | - switch ( $old_setting ) { |
|
1205 | + switch ($old_setting) { |
|
1206 | 1206 | case 'admin_notices': |
1207 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
1207 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
1208 | 1208 | |
1209 | - give_update_option( $new_setting, $notification_status ); |
|
1209 | + give_update_option($new_setting, $notification_status); |
|
1210 | 1210 | |
1211 | 1211 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
1212 | 1212 | // give_delete_option( $old_setting ); |
@@ -1217,19 +1217,19 @@ discard block |
||
1217 | 1217 | case 'admin_notice_emails': |
1218 | 1218 | $recipients = give_get_admin_notice_emails(); |
1219 | 1219 | |
1220 | - foreach ( $new_setting as $setting ) { |
|
1220 | + foreach ($new_setting as $setting) { |
|
1221 | 1221 | // bailout if setting already exist. |
1222 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
1222 | + if (array_key_exists($setting, $all_setting)) { |
|
1223 | 1223 | continue; |
1224 | 1224 | } |
1225 | 1225 | |
1226 | - give_update_option( $setting, $recipients ); |
|
1226 | + give_update_option($setting, $recipients); |
|
1227 | 1227 | } |
1228 | 1228 | break; |
1229 | 1229 | |
1230 | 1230 | default: |
1231 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
1232 | - give_delete_option( $old_setting ); |
|
1231 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
1232 | + give_delete_option($old_setting); |
|
1233 | 1233 | } |
1234 | 1234 | } |
1235 | 1235 | } |
@@ -1246,22 +1246,22 @@ discard block |
||
1246 | 1246 | $give_settings = give_get_settings(); |
1247 | 1247 | $give_setting_updated = false; |
1248 | 1248 | |
1249 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
1249 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
1250 | 1250 | $give_settings['number_decimals'] = 0; |
1251 | 1251 | $give_settings['decimal_separator'] = ''; |
1252 | 1252 | $give_setting_updated = true; |
1253 | 1253 | |
1254 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
1254 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
1255 | 1255 | $give_settings['number_decimals'] = 0; |
1256 | 1256 | $give_setting_updated = true; |
1257 | 1257 | |
1258 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
1258 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
1259 | 1259 | $give_settings['number_decimals'] = 5; |
1260 | 1260 | $give_setting_updated = true; |
1261 | 1261 | } |
1262 | 1262 | |
1263 | - if ( $give_setting_updated ) { |
|
1264 | - update_option( 'give_settings', $give_settings ); |
|
1263 | + if ($give_setting_updated) { |
|
1264 | + update_option('give_settings', $give_settings); |
|
1265 | 1265 | } |
1266 | 1266 | } |
1267 | 1267 | |
@@ -1280,69 +1280,69 @@ discard block |
||
1280 | 1280 | $give_updates = Give_Updates::get_instance(); |
1281 | 1281 | |
1282 | 1282 | // form query. |
1283 | - $donation_forms = new WP_Query( array( |
|
1283 | + $donation_forms = new WP_Query(array( |
|
1284 | 1284 | 'paged' => $give_updates->step, |
1285 | 1285 | 'status' => 'any', |
1286 | 1286 | 'order' => 'ASC', |
1287 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1287 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1288 | 1288 | 'posts_per_page' => 20, |
1289 | 1289 | ) |
1290 | 1290 | ); |
1291 | - if ( $donation_forms->have_posts() ) { |
|
1292 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1291 | + if ($donation_forms->have_posts()) { |
|
1292 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1293 | 1293 | |
1294 | - while ( $donation_forms->have_posts() ) { |
|
1294 | + while ($donation_forms->have_posts()) { |
|
1295 | 1295 | $donation_forms->the_post(); |
1296 | 1296 | global $post; |
1297 | 1297 | |
1298 | - $meta = get_post_meta( $post->ID ); |
|
1298 | + $meta = get_post_meta($post->ID); |
|
1299 | 1299 | |
1300 | - switch ( $post->post_type ) { |
|
1300 | + switch ($post->post_type) { |
|
1301 | 1301 | case 'give_forms': |
1302 | 1302 | // _give_set_price. |
1303 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1304 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1303 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1304 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | // _give_custom_amount_minimum. |
1308 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1309 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1308 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1309 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | // _give_levels_minimum_amount. |
1313 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1314 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1313 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1314 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | // _give_levels_maximum_amount. |
1318 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1319 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1318 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1319 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | // _give_set_goal. |
1323 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1324 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1323 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1324 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1325 | 1325 | } |
1326 | 1326 | |
1327 | 1327 | // _give_form_earnings. |
1328 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1329 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1328 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1329 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | // _give_custom_amount_minimum. |
1333 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1334 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1333 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1334 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1335 | 1335 | |
1336 | - foreach ( $donation_levels as $index => $level ) { |
|
1337 | - if ( empty( $level['_give_amount'] ) ) { |
|
1336 | + foreach ($donation_levels as $index => $level) { |
|
1337 | + if (empty($level['_give_amount'])) { |
|
1338 | 1338 | continue; |
1339 | 1339 | } |
1340 | 1340 | |
1341 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1341 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1342 | 1342 | } |
1343 | 1343 | |
1344 | 1344 | $meta['_give_donation_levels'] = $donation_levels; |
1345 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1345 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | |
@@ -1350,8 +1350,8 @@ discard block |
||
1350 | 1350 | |
1351 | 1351 | case 'give_payment': |
1352 | 1352 | // _give_payment_total. |
1353 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1354 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1353 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1354 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | break; |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | wp_reset_postdata(); |
1363 | 1363 | } else { |
1364 | 1364 | // The Update Ran. |
1365 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1365 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1366 | 1366 | } |
1367 | 1367 | } |
1368 | 1368 | |
@@ -1381,22 +1381,22 @@ discard block |
||
1381 | 1381 | $give_updates = Give_Updates::get_instance(); |
1382 | 1382 | |
1383 | 1383 | // form query. |
1384 | - $donors = Give()->donors->get_donors( array( |
|
1384 | + $donors = Give()->donors->get_donors(array( |
|
1385 | 1385 | 'number' => 20, |
1386 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1386 | + 'offset' => $give_updates->get_offset(20), |
|
1387 | 1387 | ) |
1388 | 1388 | ); |
1389 | 1389 | |
1390 | - if ( ! empty( $donors ) ) { |
|
1391 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1390 | + if ( ! empty($donors)) { |
|
1391 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1392 | 1392 | |
1393 | 1393 | /* @var Object $donor */ |
1394 | - foreach ( $donors as $donor ) { |
|
1395 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1394 | + foreach ($donors as $donor) { |
|
1395 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1396 | 1396 | } |
1397 | 1397 | } else { |
1398 | 1398 | // The Update Ran. |
1399 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1399 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1400 | 1400 | } |
1401 | 1401 | } |
1402 | 1402 | |
@@ -1410,25 +1410,25 @@ discard block |
||
1410 | 1410 | $give_updates = Give_Updates::get_instance(); |
1411 | 1411 | |
1412 | 1412 | // Fetch all the existing donors. |
1413 | - $donors = Give()->donors->get_donors( array( |
|
1413 | + $donors = Give()->donors->get_donors(array( |
|
1414 | 1414 | 'number' => 20, |
1415 | - 'offset' => $give_updates->get_offset( 20 ), |
|
1415 | + 'offset' => $give_updates->get_offset(20), |
|
1416 | 1416 | ) |
1417 | 1417 | ); |
1418 | 1418 | |
1419 | - if ( ! empty( $donors ) ) { |
|
1420 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
1419 | + if ( ! empty($donors)) { |
|
1420 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
1421 | 1421 | |
1422 | 1422 | /* @var Object $donor */ |
1423 | - foreach ( $donors as $donor ) { |
|
1423 | + foreach ($donors as $donor) { |
|
1424 | 1424 | $user_id = $donor->user_id; |
1425 | 1425 | |
1426 | 1426 | // Proceed, if donor is attached with user. |
1427 | - if ( $user_id ) { |
|
1428 | - $user = get_userdata( $user_id ); |
|
1427 | + if ($user_id) { |
|
1428 | + $user = get_userdata($user_id); |
|
1429 | 1429 | |
1430 | 1430 | // Update user role, if user has subscriber role. |
1431 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1431 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1432 | 1432 | wp_update_user( |
1433 | 1433 | array( |
1434 | 1434 | 'ID' => $user_id, |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | } |
1441 | 1441 | } else { |
1442 | 1442 | // The Update Ran. |
1443 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1443 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1444 | 1444 | } |
1445 | 1445 | } |
1446 | 1446 | |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | */ |
1453 | 1453 | function give_v1813_upgrades() { |
1454 | 1454 | // Update admin setting. |
1455 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1455 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1456 | 1456 | |
1457 | 1457 | // Update Give roles. |
1458 | 1458 | $roles = new Give_Roles(); |
@@ -1470,33 +1470,33 @@ discard block |
||
1470 | 1470 | $give_updates = Give_Updates::get_instance(); |
1471 | 1471 | |
1472 | 1472 | // form query. |
1473 | - $payments = new WP_Query( array( |
|
1473 | + $payments = new WP_Query(array( |
|
1474 | 1474 | 'paged' => $give_updates->step, |
1475 | 1475 | 'status' => 'any', |
1476 | 1476 | 'order' => 'ASC', |
1477 | - 'post_type' => array( 'give_payment' ), |
|
1477 | + 'post_type' => array('give_payment'), |
|
1478 | 1478 | 'posts_per_page' => 100, |
1479 | 1479 | ) |
1480 | 1480 | ); |
1481 | 1481 | |
1482 | - if ( $payments->have_posts() ) { |
|
1483 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
1482 | + if ($payments->have_posts()) { |
|
1483 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
1484 | 1484 | |
1485 | - while ( $payments->have_posts() ) { |
|
1485 | + while ($payments->have_posts()) { |
|
1486 | 1486 | $payments->the_post(); |
1487 | 1487 | |
1488 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1488 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1489 | 1489 | |
1490 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1490 | + if ('RIAL' === $payment_meta['currency']) { |
|
1491 | 1491 | $payment_meta['currency'] = 'IRR'; |
1492 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1492 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | } else { |
1498 | 1498 | // The Update Ran. |
1499 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1499 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1500 | 1500 | } |
1501 | 1501 | } |
1502 | 1502 | |
@@ -1509,9 +1509,9 @@ discard block |
||
1509 | 1509 | function give_v1817_upgrades() { |
1510 | 1510 | $give_settings = give_get_settings(); |
1511 | 1511 | |
1512 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1512 | + if ('RIAL' === $give_settings['currency']) { |
|
1513 | 1513 | $give_settings['currency'] = 'IRR'; |
1514 | - update_option( 'give_settings', $give_settings ); |
|
1514 | + update_option('give_settings', $give_settings); |
|
1515 | 1515 | } |
1516 | 1516 | } |
1517 | 1517 | |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | |
1525 | 1525 | global $wp_roles; |
1526 | 1526 | |
1527 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1527 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1528 | 1528 | return; |
1529 | 1529 | } |
1530 | 1530 | |
@@ -1548,15 +1548,15 @@ discard block |
||
1548 | 1548 | ), |
1549 | 1549 | ); |
1550 | 1550 | |
1551 | - foreach ( $add_caps as $role => $caps ) { |
|
1552 | - foreach ( $caps as $cap ) { |
|
1553 | - $wp_roles->add_cap( $role, $cap ); |
|
1551 | + foreach ($add_caps as $role => $caps) { |
|
1552 | + foreach ($caps as $cap) { |
|
1553 | + $wp_roles->add_cap($role, $cap); |
|
1554 | 1554 | } |
1555 | 1555 | } |
1556 | 1556 | |
1557 | - foreach ( $remove_caps as $role => $caps ) { |
|
1558 | - foreach ( $caps as $cap ) { |
|
1559 | - $wp_roles->remove_cap( $role, $cap ); |
|
1557 | + foreach ($remove_caps as $role => $caps) { |
|
1558 | + foreach ($caps as $cap) { |
|
1559 | + $wp_roles->remove_cap($role, $cap); |
|
1560 | 1560 | } |
1561 | 1561 | } |
1562 | 1562 | |
@@ -1580,7 +1580,7 @@ discard block |
||
1580 | 1580 | $roles->add_roles(); |
1581 | 1581 | $roles->add_caps(); |
1582 | 1582 | |
1583 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1583 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1584 | 1584 | } |
1585 | 1585 | |
1586 | 1586 | /** |
@@ -1591,7 +1591,7 @@ discard block |
||
1591 | 1591 | function give_v1818_upgrades() { |
1592 | 1592 | |
1593 | 1593 | // Remove email_access_installed from give_settings. |
1594 | - give_delete_option( 'email_access_installed' ); |
|
1594 | + give_delete_option('email_access_installed'); |
|
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | /** |
@@ -1604,23 +1604,23 @@ discard block |
||
1604 | 1604 | /* @var Give_Updates $give_updates */ |
1605 | 1605 | $give_updates = Give_Updates::get_instance(); |
1606 | 1606 | |
1607 | - $donations = new WP_Query( array( |
|
1607 | + $donations = new WP_Query(array( |
|
1608 | 1608 | 'paged' => $give_updates->step, |
1609 | 1609 | 'status' => 'any', |
1610 | 1610 | 'order' => 'ASC', |
1611 | - 'post_type' => array( 'give_payment' ), |
|
1611 | + 'post_type' => array('give_payment'), |
|
1612 | 1612 | 'posts_per_page' => 100, |
1613 | 1613 | ) |
1614 | 1614 | ); |
1615 | 1615 | |
1616 | - if ( $donations->have_posts() ) { |
|
1617 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
1616 | + if ($donations->have_posts()) { |
|
1617 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
1618 | 1618 | |
1619 | - while ( $donations->have_posts() ) { |
|
1619 | + while ($donations->have_posts()) { |
|
1620 | 1620 | $donations->the_post(); |
1621 | 1621 | |
1622 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
1623 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
1622 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
1623 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
1624 | 1624 | |
1625 | 1625 | // Update Donation meta with price_id set as custom, only if it is: |
1626 | 1626 | // 1. Donation Type = Set Donation. |
@@ -1629,19 +1629,19 @@ discard block |
||
1629 | 1629 | if ( |
1630 | 1630 | $form->ID && |
1631 | 1631 | $form->is_set_type_donation_form() && |
1632 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
1633 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
1632 | + ('custom' !== $donation_meta['price_id']) && |
|
1633 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
1634 | 1634 | ) { |
1635 | 1635 | $donation_meta['price_id'] = 'custom'; |
1636 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
1637 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
1636 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
1637 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
1638 | 1638 | } |
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | wp_reset_postdata(); |
1642 | 1642 | } else { |
1643 | 1643 | // Update Ran Successfully. |
1644 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
1644 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
1645 | 1645 | } |
1646 | 1646 | } |
1647 | 1647 | |
@@ -1659,7 +1659,7 @@ discard block |
||
1659 | 1659 | |
1660 | 1660 | global $wp_roles; |
1661 | 1661 | |
1662 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1662 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1663 | 1663 | return; |
1664 | 1664 | } |
1665 | 1665 | |
@@ -1677,9 +1677,9 @@ discard block |
||
1677 | 1677 | ), |
1678 | 1678 | ); |
1679 | 1679 | |
1680 | - foreach ( $remove_caps as $role => $caps ) { |
|
1681 | - foreach ( $caps as $cap ) { |
|
1682 | - $wp_roles->remove_cap( $role, $cap ); |
|
1680 | + foreach ($remove_caps as $role => $caps) { |
|
1681 | + foreach ($caps as $cap) { |
|
1682 | + $wp_roles->remove_cap($role, $cap); |
|
1683 | 1683 | } |
1684 | 1684 | } |
1685 | 1685 | |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | $roles->add_roles(); |
1691 | 1691 | $roles->add_caps(); |
1692 | 1692 | |
1693 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
1693 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | /** |
@@ -1704,7 +1704,7 @@ discard block |
||
1704 | 1704 | $give_updates = Give_Updates::get_instance(); |
1705 | 1705 | |
1706 | 1706 | // form query |
1707 | - $forms = new WP_Query( array( |
|
1707 | + $forms = new WP_Query(array( |
|
1708 | 1708 | 'paged' => $give_updates->step, |
1709 | 1709 | 'status' => 'any', |
1710 | 1710 | 'order' => 'ASC', |
@@ -1713,22 +1713,22 @@ discard block |
||
1713 | 1713 | ) |
1714 | 1714 | ); |
1715 | 1715 | |
1716 | - if ( $forms->have_posts() ) { |
|
1717 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1716 | + if ($forms->have_posts()) { |
|
1717 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1718 | 1718 | |
1719 | - while ( $forms->have_posts() ) { |
|
1719 | + while ($forms->have_posts()) { |
|
1720 | 1720 | $forms->the_post(); |
1721 | 1721 | global $post; |
1722 | 1722 | |
1723 | 1723 | // Update offline instruction email notification status. |
1724 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
1725 | - $offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array( |
|
1724 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
1725 | + $offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array( |
|
1726 | 1726 | 'enabled', |
1727 | 1727 | 'global', |
1728 | - ) ) |
|
1728 | + )) |
|
1729 | 1729 | ? $offline_instruction_notification_status |
1730 | 1730 | : 'global'; |
1731 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
1731 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
1732 | 1732 | |
1733 | 1733 | // Update offline instruction email message. |
1734 | 1734 | update_post_meta( |
@@ -1760,7 +1760,7 @@ discard block |
||
1760 | 1760 | wp_reset_postdata(); |
1761 | 1761 | } else { |
1762 | 1762 | // No more forms found, finish up. |
1763 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
1763 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
1764 | 1764 | } |
1765 | 1765 | } |
1766 | 1766 | |
@@ -1777,7 +1777,7 @@ discard block |
||
1777 | 1777 | $give_updates = Give_Updates::get_instance(); |
1778 | 1778 | |
1779 | 1779 | // form query |
1780 | - $forms = new WP_Query( array( |
|
1780 | + $forms = new WP_Query(array( |
|
1781 | 1781 | 'paged' => $give_updates->step, |
1782 | 1782 | 'status' => 'any', |
1783 | 1783 | 'order' => 'ASC', |
@@ -1786,19 +1786,19 @@ discard block |
||
1786 | 1786 | ) |
1787 | 1787 | ); |
1788 | 1788 | |
1789 | - if ( $forms->have_posts() ) { |
|
1790 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
1789 | + if ($forms->have_posts()) { |
|
1790 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
1791 | 1791 | |
1792 | - while ( $forms->have_posts() ) { |
|
1792 | + while ($forms->have_posts()) { |
|
1793 | 1793 | $forms->the_post(); |
1794 | 1794 | global $post; |
1795 | 1795 | |
1796 | 1796 | // Split _give_payment_meta meta. |
1797 | 1797 | // @todo Remove _give_payment_meta after releases 2.0 |
1798 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
1798 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
1799 | 1799 | |
1800 | - if ( ! empty( $payment_meta ) ) { |
|
1801 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
1800 | + if ( ! empty($payment_meta)) { |
|
1801 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
1802 | 1802 | } |
1803 | 1803 | |
1804 | 1804 | $deprecated_meta_keys = array( |
@@ -1807,9 +1807,9 @@ discard block |
||
1807 | 1807 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
1808 | 1808 | ); |
1809 | 1809 | |
1810 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
1810 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
1811 | 1811 | // Do not add new meta key if already exist. |
1812 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
1812 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
1813 | 1813 | continue; |
1814 | 1814 | } |
1815 | 1815 | |
@@ -1818,25 +1818,25 @@ discard block |
||
1818 | 1818 | array( |
1819 | 1819 | 'post_id' => $post->ID, |
1820 | 1820 | 'meta_key' => $new_meta_key, |
1821 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
1821 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
1822 | 1822 | ) |
1823 | 1823 | ); |
1824 | 1824 | } |
1825 | 1825 | |
1826 | 1826 | // Bailout |
1827 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
1827 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
1828 | 1828 | /* @var Give_Donor $donor */ |
1829 | - $donor = new Give_Donor( $donor_id ); |
|
1829 | + $donor = new Give_Donor($donor_id); |
|
1830 | 1830 | |
1831 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
1832 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
1833 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
1834 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
1835 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
1836 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
1831 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
1832 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
1833 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
1834 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
1835 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
1836 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
1837 | 1837 | |
1838 | 1838 | // Save address. |
1839 | - $donor->add_address( 'billing[]', $address ); |
|
1839 | + $donor->add_address('billing[]', $address); |
|
1840 | 1840 | } |
1841 | 1841 | |
1842 | 1842 | }// End while(). |
@@ -1847,7 +1847,7 @@ discard block |
||
1847 | 1847 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
1848 | 1848 | |
1849 | 1849 | // No more forms found, finish up. |
1850 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
1850 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
1851 | 1851 | } |
1852 | 1852 | } |
1853 | 1853 | |
@@ -1863,7 +1863,7 @@ discard block |
||
1863 | 1863 | $give_updates = Give_Updates::get_instance(); |
1864 | 1864 | |
1865 | 1865 | // form query |
1866 | - $forms = new WP_Query( array( |
|
1866 | + $forms = new WP_Query(array( |
|
1867 | 1867 | 'paged' => $give_updates->step, |
1868 | 1868 | 'order' => 'DESC', |
1869 | 1869 | 'post_type' => 'give_log', |
@@ -1872,20 +1872,20 @@ discard block |
||
1872 | 1872 | ) |
1873 | 1873 | ); |
1874 | 1874 | |
1875 | - if ( $forms->have_posts() ) { |
|
1876 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
1875 | + if ($forms->have_posts()) { |
|
1876 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
1877 | 1877 | |
1878 | - while ( $forms->have_posts() ) { |
|
1878 | + while ($forms->have_posts()) { |
|
1879 | 1879 | $forms->the_post(); |
1880 | 1880 | global $post; |
1881 | 1881 | |
1882 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
1882 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
1883 | 1883 | continue; |
1884 | 1884 | } |
1885 | 1885 | |
1886 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
1887 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
1888 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
1886 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
1887 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
1888 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
1889 | 1889 | |
1890 | 1890 | $log_data = array( |
1891 | 1891 | 'ID' => $post->ID, |
@@ -1898,29 +1898,29 @@ discard block |
||
1898 | 1898 | ); |
1899 | 1899 | $log_meta = array(); |
1900 | 1900 | |
1901 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
1902 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
1903 | - switch ( $meta_key ) { |
|
1901 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
1902 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
1903 | + switch ($meta_key) { |
|
1904 | 1904 | case '_give_log_payment_id': |
1905 | - $log_data['log_parent'] = current( $meta_value ); |
|
1905 | + $log_data['log_parent'] = current($meta_value); |
|
1906 | 1906 | $log_meta['_give_log_form_id'] = $post->post_parent; |
1907 | 1907 | break; |
1908 | 1908 | |
1909 | 1909 | default: |
1910 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
1910 | + $log_meta[$meta_key] = current($meta_value); |
|
1911 | 1911 | } |
1912 | 1912 | } |
1913 | 1913 | } |
1914 | 1914 | |
1915 | - if ( 'api_request' === $term_name ) { |
|
1915 | + if ('api_request' === $term_name) { |
|
1916 | 1916 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
1917 | 1917 | } |
1918 | 1918 | |
1919 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
1919 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
1920 | 1920 | |
1921 | - if ( ! empty( $log_meta ) ) { |
|
1922 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
1923 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
1921 | + if ( ! empty($log_meta)) { |
|
1922 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
1923 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
1924 | 1924 | } |
1925 | 1925 | } |
1926 | 1926 | |
@@ -1962,7 +1962,7 @@ discard block |
||
1962 | 1962 | Give()->logs->delete_cache(); |
1963 | 1963 | |
1964 | 1964 | // No more forms found, finish up. |
1965 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
1965 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
1966 | 1966 | } |
1967 | 1967 | } |
1968 | 1968 | |
@@ -1978,19 +1978,19 @@ discard block |
||
1978 | 1978 | $give_updates = Give_Updates::get_instance(); |
1979 | 1979 | |
1980 | 1980 | // form query |
1981 | - $payments = new WP_Query( array( |
|
1981 | + $payments = new WP_Query(array( |
|
1982 | 1982 | 'paged' => $give_updates->step, |
1983 | 1983 | 'status' => 'any', |
1984 | 1984 | 'order' => 'ASC', |
1985 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1985 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1986 | 1986 | 'posts_per_page' => 100, |
1987 | 1987 | ) |
1988 | 1988 | ); |
1989 | 1989 | |
1990 | - if ( $payments->have_posts() ) { |
|
1991 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
1990 | + if ($payments->have_posts()) { |
|
1991 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
1992 | 1992 | |
1993 | - while ( $payments->have_posts() ) { |
|
1993 | + while ($payments->have_posts()) { |
|
1994 | 1994 | $payments->the_post(); |
1995 | 1995 | global $post; |
1996 | 1996 | |
@@ -2002,19 +2002,19 @@ discard block |
||
2002 | 2002 | ARRAY_A |
2003 | 2003 | ); |
2004 | 2004 | |
2005 | - if ( ! empty( $meta_data ) ) { |
|
2006 | - foreach ( $meta_data as $index => $data ) { |
|
2005 | + if ( ! empty($meta_data)) { |
|
2006 | + foreach ($meta_data as $index => $data) { |
|
2007 | 2007 | // Check for duplicate meta values. |
2008 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2008 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2009 | 2009 | continue; |
2010 | 2010 | } |
2011 | 2011 | |
2012 | - switch ( $post->post_type ) { |
|
2012 | + switch ($post->post_type) { |
|
2013 | 2013 | case 'give_forms': |
2014 | 2014 | $data['form_id'] = $data['post_id']; |
2015 | - unset( $data['post_id'] ); |
|
2015 | + unset($data['post_id']); |
|
2016 | 2016 | |
2017 | - Give()->form_meta->insert( $data ); |
|
2017 | + Give()->form_meta->insert($data); |
|
2018 | 2018 | // @todo: delete form meta from post meta table after releases 2.0. |
2019 | 2019 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2020 | 2020 | |
@@ -2022,9 +2022,9 @@ discard block |
||
2022 | 2022 | |
2023 | 2023 | case 'give_payment': |
2024 | 2024 | $data['payment_id'] = $data['post_id']; |
2025 | - unset( $data['post_id'] ); |
|
2025 | + unset($data['post_id']); |
|
2026 | 2026 | |
2027 | - Give()->payment_meta->insert( $data ); |
|
2027 | + Give()->payment_meta->insert($data); |
|
2028 | 2028 | |
2029 | 2029 | // @todo: delete donation meta from post meta table after releases 2.0. |
2030 | 2030 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2039,7 +2039,7 @@ discard block |
||
2039 | 2039 | wp_reset_postdata(); |
2040 | 2040 | } else { |
2041 | 2041 | // No more forms found, finish up. |
2042 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
2042 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
2043 | 2043 | } |
2044 | 2044 | |
2045 | 2045 | } |
@@ -2055,44 +2055,44 @@ discard block |
||
2055 | 2055 | /* @var Give_Updates $give_updates */ |
2056 | 2056 | $give_updates = Give_Updates::get_instance(); |
2057 | 2057 | |
2058 | - $donors = Give()->donors->get_donors( array( |
|
2058 | + $donors = Give()->donors->get_donors(array( |
|
2059 | 2059 | 'paged' => $give_updates->step, |
2060 | 2060 | 'number' => 100, |
2061 | - ) ); |
|
2061 | + )); |
|
2062 | 2062 | |
2063 | - if ( $donors ) { |
|
2064 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
2063 | + if ($donors) { |
|
2064 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
2065 | 2065 | // Loop through Donors |
2066 | - foreach ( $donors as $donor ) { |
|
2066 | + foreach ($donors as $donor) { |
|
2067 | 2067 | |
2068 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2069 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2070 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2068 | + $donor_name = explode(' ', $donor->name, 2); |
|
2069 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2070 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2071 | 2071 | |
2072 | 2072 | // If first name meta of donor is not created, then create it. |
2073 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2074 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2073 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2074 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2075 | 2075 | } |
2076 | 2076 | |
2077 | 2077 | // If last name meta of donor is not created, then create it. |
2078 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2079 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2078 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2079 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2080 | 2080 | } |
2081 | 2081 | |
2082 | 2082 | // If Donor is connected with WP User then update user meta. |
2083 | - if ( $donor->user_id ) { |
|
2084 | - if ( isset( $donor_name[0] ) ) { |
|
2085 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2083 | + if ($donor->user_id) { |
|
2084 | + if (isset($donor_name[0])) { |
|
2085 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2086 | 2086 | } |
2087 | - if ( isset( $donor_name[1] ) ) { |
|
2088 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2087 | + if (isset($donor_name[1])) { |
|
2088 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2089 | 2089 | } |
2090 | 2090 | } |
2091 | 2091 | } |
2092 | 2092 | |
2093 | 2093 | } else { |
2094 | 2094 | // The Update Ran. |
2095 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
2095 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
2096 | 2096 | } |
2097 | 2097 | |
2098 | 2098 | } |
@@ -2121,15 +2121,15 @@ discard block |
||
2121 | 2121 | |
2122 | 2122 | $users = $user_query->get_results(); |
2123 | 2123 | |
2124 | - if ( $users ) { |
|
2125 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
2124 | + if ($users) { |
|
2125 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
2126 | 2126 | |
2127 | 2127 | // Loop through Donors |
2128 | - foreach ( $users as $user ) { |
|
2128 | + foreach ($users as $user) { |
|
2129 | 2129 | /* @var Give_Donor $donor */ |
2130 | - $donor = new Give_Donor( $user->ID, true ); |
|
2130 | + $donor = new Give_Donor($user->ID, true); |
|
2131 | 2131 | |
2132 | - if ( ! $donor->id ) { |
|
2132 | + if ( ! $donor->id) { |
|
2133 | 2133 | continue; |
2134 | 2134 | } |
2135 | 2135 | |
@@ -2145,10 +2145,10 @@ discard block |
||
2145 | 2145 | ) |
2146 | 2146 | ); |
2147 | 2147 | |
2148 | - if ( ! empty( $address ) ) { |
|
2149 | - $address = maybe_unserialize( $address ); |
|
2150 | - $donor->add_address( 'personal', $address ); |
|
2151 | - $donor->add_address( 'billing[]', $address ); |
|
2148 | + if ( ! empty($address)) { |
|
2149 | + $address = maybe_unserialize($address); |
|
2150 | + $donor->add_address('personal', $address); |
|
2151 | + $donor->add_address('billing[]', $address); |
|
2152 | 2152 | |
2153 | 2153 | |
2154 | 2154 | // @todo: delete _give_user_address from user meta after releases 2.0. |
@@ -2158,7 +2158,7 @@ discard block |
||
2158 | 2158 | |
2159 | 2159 | } else { |
2160 | 2160 | // The Update Ran. |
2161 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
2161 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
2162 | 2162 | } |
2163 | 2163 | |
2164 | 2164 | } |
@@ -2182,15 +2182,15 @@ discard block |
||
2182 | 2182 | ); |
2183 | 2183 | |
2184 | 2184 | // Alter customer table |
2185 | - foreach ( $tables as $old_table => $new_table ) { |
|
2185 | + foreach ($tables as $old_table => $new_table) { |
|
2186 | 2186 | if ( |
2187 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) && |
|
2188 | - ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) ) |
|
2187 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) && |
|
2188 | + ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table)) |
|
2189 | 2189 | ) { |
2190 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
2190 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
2191 | 2191 | |
2192 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
2193 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
2192 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
2193 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
2194 | 2194 | } |
2195 | 2195 | } |
2196 | 2196 | } |
@@ -2198,7 +2198,7 @@ discard block |
||
2198 | 2198 | $give_updates->percentage = 100; |
2199 | 2199 | |
2200 | 2200 | // No more forms found, finish up. |
2201 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
2201 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
2202 | 2202 | |
2203 | 2203 | // Re initiate donor classes. |
2204 | 2204 | Give()->donors = new Give_DB_Donors(); |
@@ -2216,19 +2216,19 @@ discard block |
||
2216 | 2216 | function give_v201_create_tables() { |
2217 | 2217 | global $wpdb; |
2218 | 2218 | |
2219 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
2219 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) { |
|
2220 | 2220 | Give()->payment_meta->create_table(); |
2221 | 2221 | } |
2222 | 2222 | |
2223 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
2223 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) { |
|
2224 | 2224 | Give()->form_meta->create_table(); |
2225 | 2225 | } |
2226 | 2226 | |
2227 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) { |
|
2227 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) { |
|
2228 | 2228 | Give()->logs->log_db->create_table(); |
2229 | 2229 | } |
2230 | 2230 | |
2231 | - if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
2231 | + if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) { |
|
2232 | 2232 | Give()->logs->logmeta_db->create_table(); |
2233 | 2233 | } |
2234 | 2234 | } |
@@ -2253,31 +2253,31 @@ discard block |
||
2253 | 2253 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
2254 | 2254 | ) |
2255 | 2255 | AND $wpdb->posts.post_type = 'give_payment' |
2256 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2256 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2257 | 2257 | ORDER BY $wpdb->posts.post_date ASC |
2258 | 2258 | LIMIT 100 |
2259 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2259 | + OFFSET ".$give_updates->get_offset(100) |
|
2260 | 2260 | ); |
2261 | 2261 | |
2262 | - if ( ! empty( $payments ) ) { |
|
2263 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
2262 | + if ( ! empty($payments)) { |
|
2263 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
2264 | 2264 | |
2265 | - foreach ( $payments as $payment_id ) { |
|
2266 | - $post = get_post( $payment_id ); |
|
2267 | - setup_postdata( $post ); |
|
2265 | + foreach ($payments as $payment_id) { |
|
2266 | + $post = get_post($payment_id); |
|
2267 | + setup_postdata($post); |
|
2268 | 2268 | |
2269 | 2269 | // Do not add new meta keys if already refactored. |
2270 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
2270 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
2271 | 2271 | continue; |
2272 | 2272 | } |
2273 | 2273 | |
2274 | 2274 | |
2275 | 2275 | // Split _give_payment_meta meta. |
2276 | 2276 | // @todo Remove _give_payment_meta after releases 2.0 |
2277 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
2277 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
2278 | 2278 | |
2279 | - if ( ! empty( $payment_meta ) ) { |
|
2280 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
2279 | + if ( ! empty($payment_meta)) { |
|
2280 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
2281 | 2281 | } |
2282 | 2282 | |
2283 | 2283 | $deprecated_meta_keys = array( |
@@ -2286,9 +2286,9 @@ discard block |
||
2286 | 2286 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
2287 | 2287 | ); |
2288 | 2288 | |
2289 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
2289 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
2290 | 2290 | // Do not add new meta key if already exist. |
2291 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
2291 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
2292 | 2292 | continue; |
2293 | 2293 | } |
2294 | 2294 | |
@@ -2297,25 +2297,25 @@ discard block |
||
2297 | 2297 | array( |
2298 | 2298 | 'post_id' => $post->ID, |
2299 | 2299 | 'meta_key' => $new_meta_key, |
2300 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
2300 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
2301 | 2301 | ) |
2302 | 2302 | ); |
2303 | 2303 | } |
2304 | 2304 | |
2305 | 2305 | // Bailout |
2306 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
2306 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
2307 | 2307 | /* @var Give_Donor $donor */ |
2308 | - $donor = new Give_Donor( $donor_id ); |
|
2308 | + $donor = new Give_Donor($donor_id); |
|
2309 | 2309 | |
2310 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
2311 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
2312 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
2313 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
2314 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
2315 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
2310 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
2311 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
2312 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
2313 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
2314 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
2315 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
2316 | 2316 | |
2317 | 2317 | // Save address. |
2318 | - $donor->add_address( 'billing[]', $address ); |
|
2318 | + $donor->add_address('billing[]', $address); |
|
2319 | 2319 | } |
2320 | 2320 | |
2321 | 2321 | }// End while(). |
@@ -2326,7 +2326,7 @@ discard block |
||
2326 | 2326 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
2327 | 2327 | |
2328 | 2328 | // No more forms found, finish up. |
2329 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
2329 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
2330 | 2330 | } |
2331 | 2331 | } |
2332 | 2332 | |
@@ -2346,21 +2346,21 @@ discard block |
||
2346 | 2346 | SELECT ID FROM $wpdb->posts |
2347 | 2347 | WHERE 1=1 |
2348 | 2348 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
2349 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2349 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2350 | 2350 | ORDER BY $wpdb->posts.post_date ASC |
2351 | 2351 | LIMIT 100 |
2352 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2352 | + OFFSET ".$give_updates->get_offset(100) |
|
2353 | 2353 | ); |
2354 | 2354 | |
2355 | - if ( ! empty( $payments ) ) { |
|
2356 | - $give_updates->set_percentage( give_get_total_post_type_count( array( |
|
2355 | + if ( ! empty($payments)) { |
|
2356 | + $give_updates->set_percentage(give_get_total_post_type_count(array( |
|
2357 | 2357 | 'give_forms', |
2358 | 2358 | 'give_payment', |
2359 | - ) ), $give_updates->step * 100 ); |
|
2359 | + )), $give_updates->step * 100); |
|
2360 | 2360 | |
2361 | - foreach ( $payments as $payment_id ) { |
|
2362 | - $post = get_post( $payment_id ); |
|
2363 | - setup_postdata( $post ); |
|
2361 | + foreach ($payments as $payment_id) { |
|
2362 | + $post = get_post($payment_id); |
|
2363 | + setup_postdata($post); |
|
2364 | 2364 | |
2365 | 2365 | $meta_data = $wpdb->get_results( |
2366 | 2366 | $wpdb->prepare( |
@@ -2370,19 +2370,19 @@ discard block |
||
2370 | 2370 | ARRAY_A |
2371 | 2371 | ); |
2372 | 2372 | |
2373 | - if ( ! empty( $meta_data ) ) { |
|
2374 | - foreach ( $meta_data as $index => $data ) { |
|
2373 | + if ( ! empty($meta_data)) { |
|
2374 | + foreach ($meta_data as $index => $data) { |
|
2375 | 2375 | // Check for duplicate meta values. |
2376 | - if ( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) { |
|
2376 | + if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) { |
|
2377 | 2377 | continue; |
2378 | 2378 | } |
2379 | 2379 | |
2380 | - switch ( $post->post_type ) { |
|
2380 | + switch ($post->post_type) { |
|
2381 | 2381 | case 'give_forms': |
2382 | 2382 | $data['form_id'] = $data['post_id']; |
2383 | - unset( $data['post_id'] ); |
|
2383 | + unset($data['post_id']); |
|
2384 | 2384 | |
2385 | - Give()->form_meta->insert( $data ); |
|
2385 | + Give()->form_meta->insert($data); |
|
2386 | 2386 | // @todo: delete form meta from post meta table after releases 2.0. |
2387 | 2387 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
2388 | 2388 | |
@@ -2390,9 +2390,9 @@ discard block |
||
2390 | 2390 | |
2391 | 2391 | case 'give_payment': |
2392 | 2392 | $data['payment_id'] = $data['post_id']; |
2393 | - unset( $data['post_id'] ); |
|
2393 | + unset($data['post_id']); |
|
2394 | 2394 | |
2395 | - Give()->payment_meta->insert( $data ); |
|
2395 | + Give()->payment_meta->insert($data); |
|
2396 | 2396 | |
2397 | 2397 | // @todo: delete donation meta from post meta table after releases 2.0. |
2398 | 2398 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2407,7 +2407,7 @@ discard block |
||
2407 | 2407 | wp_reset_postdata(); |
2408 | 2408 | } else { |
2409 | 2409 | // No more forms found, finish up. |
2410 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
2410 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
2411 | 2411 | } |
2412 | 2412 | |
2413 | 2413 | } |
@@ -2428,26 +2428,26 @@ discard block |
||
2428 | 2428 | SELECT ID FROM $wpdb->posts |
2429 | 2429 | WHERE 1=1 |
2430 | 2430 | AND $wpdb->posts.post_type = 'give_log' |
2431 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
2431 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
2432 | 2432 | ORDER BY $wpdb->posts.post_date ASC |
2433 | 2433 | LIMIT 100 |
2434 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
2434 | + OFFSET ".$give_updates->get_offset(100) |
|
2435 | 2435 | ); |
2436 | 2436 | |
2437 | - if ( ! empty( $logs ) ) { |
|
2438 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
2437 | + if ( ! empty($logs)) { |
|
2438 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
2439 | 2439 | |
2440 | - foreach ( $logs as $log_id ) { |
|
2441 | - $post = get_post( $log_id ); |
|
2442 | - setup_postdata( $post ); |
|
2440 | + foreach ($logs as $log_id) { |
|
2441 | + $post = get_post($log_id); |
|
2442 | + setup_postdata($post); |
|
2443 | 2443 | |
2444 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
2444 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
2445 | 2445 | continue; |
2446 | 2446 | } |
2447 | 2447 | |
2448 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
2449 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
2450 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
2448 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
2449 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
2450 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
2451 | 2451 | |
2452 | 2452 | $log_data = array( |
2453 | 2453 | 'ID' => $post->ID, |
@@ -2460,29 +2460,29 @@ discard block |
||
2460 | 2460 | ); |
2461 | 2461 | $log_meta = array(); |
2462 | 2462 | |
2463 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
2464 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
2465 | - switch ( $meta_key ) { |
|
2463 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
2464 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
2465 | + switch ($meta_key) { |
|
2466 | 2466 | case '_give_log_payment_id': |
2467 | - $log_data['log_parent'] = current( $meta_value ); |
|
2467 | + $log_data['log_parent'] = current($meta_value); |
|
2468 | 2468 | $log_meta['_give_log_form_id'] = $post->post_parent; |
2469 | 2469 | break; |
2470 | 2470 | |
2471 | 2471 | default: |
2472 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
2472 | + $log_meta[$meta_key] = current($meta_value); |
|
2473 | 2473 | } |
2474 | 2474 | } |
2475 | 2475 | } |
2476 | 2476 | |
2477 | - if ( 'api_request' === $term_name ) { |
|
2477 | + if ('api_request' === $term_name) { |
|
2478 | 2478 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
2479 | 2479 | } |
2480 | 2480 | |
2481 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
2481 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
2482 | 2482 | |
2483 | - if ( ! empty( $log_meta ) ) { |
|
2484 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
2485 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
2483 | + if ( ! empty($log_meta)) { |
|
2484 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
2485 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
2486 | 2486 | } |
2487 | 2487 | } |
2488 | 2488 | |
@@ -2495,7 +2495,7 @@ discard block |
||
2495 | 2495 | Give()->logs->delete_cache(); |
2496 | 2496 | |
2497 | 2497 | // No more forms found, finish up. |
2498 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
2498 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
2499 | 2499 | } |
2500 | 2500 | } |
2501 | 2501 | |
@@ -2510,51 +2510,51 @@ discard block |
||
2510 | 2510 | global $wpdb; |
2511 | 2511 | give_v201_create_tables(); |
2512 | 2512 | |
2513 | - if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) { |
|
2514 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
2515 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
2513 | + if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) { |
|
2514 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
2515 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
2516 | 2516 | $donor_data = array(); |
2517 | 2517 | |
2518 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
2519 | - foreach ( $missing_donors as $donor_id ) { |
|
2518 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
2519 | + foreach ($missing_donors as $donor_id) { |
|
2520 | 2520 | $donor_data[] = array( |
2521 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
2522 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
2521 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
2522 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
2523 | 2523 | |
2524 | 2524 | ); |
2525 | 2525 | } |
2526 | 2526 | } |
2527 | 2527 | |
2528 | - if ( ! empty( $donor_data ) ) { |
|
2528 | + if ( ! empty($donor_data)) { |
|
2529 | 2529 | $donor_table_name = Give()->donors->table_name; |
2530 | 2530 | $donor_meta_table_name = Give()->donor_meta->table_name; |
2531 | 2531 | |
2532 | 2532 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
2533 | 2533 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
2534 | 2534 | |
2535 | - foreach ( $donor_data as $donor ) { |
|
2535 | + foreach ($donor_data as $donor) { |
|
2536 | 2536 | $donor['info'][0] = (array) $donor['info'][0]; |
2537 | 2537 | |
2538 | 2538 | // Prevent duplicate meta id issue. |
2539 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
2539 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
2540 | 2540 | continue; |
2541 | 2541 | } |
2542 | 2542 | |
2543 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
2543 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
2544 | 2544 | |
2545 | - if ( ! empty( $donor['meta'] ) ) { |
|
2546 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
2545 | + if ( ! empty($donor['meta'])) { |
|
2546 | + foreach ($donor['meta'] as $donor_meta) { |
|
2547 | 2547 | $donor_meta = (array) $donor_meta; |
2548 | 2548 | |
2549 | 2549 | // Prevent duplicate meta id issue. |
2550 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
2551 | - unset( $donor_meta['meta_id'] ); |
|
2550 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
2551 | + unset($donor_meta['meta_id']); |
|
2552 | 2552 | } |
2553 | 2553 | |
2554 | 2554 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
2555 | - unset( $donor_meta['customer_id'] ); |
|
2555 | + unset($donor_meta['customer_id']); |
|
2556 | 2556 | |
2557 | - Give()->donor_meta->insert( $donor_meta ); |
|
2557 | + Give()->donor_meta->insert($donor_meta); |
|
2558 | 2558 | } |
2559 | 2559 | } |
2560 | 2560 | |
@@ -2573,35 +2573,35 @@ discard block |
||
2573 | 2573 | ) |
2574 | 2574 | ); |
2575 | 2575 | |
2576 | - $donor = new Give_Donor( $donor_id ); |
|
2576 | + $donor = new Give_Donor($donor_id); |
|
2577 | 2577 | |
2578 | - if ( ! empty( $address ) ) { |
|
2579 | - $address = maybe_unserialize( $address ); |
|
2580 | - $donor->add_address( 'personal', $address ); |
|
2581 | - $donor->add_address( 'billing[]', $address ); |
|
2578 | + if ( ! empty($address)) { |
|
2579 | + $address = maybe_unserialize($address); |
|
2580 | + $donor->add_address('personal', $address); |
|
2581 | + $donor->add_address('billing[]', $address); |
|
2582 | 2582 | } |
2583 | 2583 | |
2584 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
2585 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
2586 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
2584 | + $donor_name = explode(' ', $donor->name, 2); |
|
2585 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
2586 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
2587 | 2587 | |
2588 | 2588 | // If first name meta of donor is not created, then create it. |
2589 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
2590 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
2589 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
2590 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
2591 | 2591 | } |
2592 | 2592 | |
2593 | 2593 | // If last name meta of donor is not created, then create it. |
2594 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
2595 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
2594 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
2595 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
2596 | 2596 | } |
2597 | 2597 | |
2598 | 2598 | // If Donor is connected with WP User then update user meta. |
2599 | - if ( $donor->user_id ) { |
|
2600 | - if ( isset( $donor_name[0] ) ) { |
|
2601 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
2599 | + if ($donor->user_id) { |
|
2600 | + if (isset($donor_name[0])) { |
|
2601 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
2602 | 2602 | } |
2603 | - if ( isset( $donor_name[1] ) ) { |
|
2604 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
2603 | + if (isset($donor_name[1])) { |
|
2604 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
2605 | 2605 | } |
2606 | 2606 | } |
2607 | 2607 | } |
@@ -2612,7 +2612,7 @@ discard block |
||
2612 | 2612 | } |
2613 | 2613 | |
2614 | 2614 | Give_Updates::get_instance()->percentage = 100; |
2615 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
2615 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
2616 | 2616 | } |
2617 | 2617 | |
2618 | 2618 | |
@@ -2625,14 +2625,14 @@ discard block |
||
2625 | 2625 | global $wpdb; |
2626 | 2626 | |
2627 | 2627 | // Do not auto load option. |
2628 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
2628 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
2629 | 2629 | |
2630 | 2630 | // Remove from cache. |
2631 | 2631 | $all_options = wp_load_alloptions(); |
2632 | 2632 | |
2633 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
2634 | - unset( $all_options['give_completed_upgrades'] ); |
|
2635 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
2633 | + if (isset($all_options['give_completed_upgrades'])) { |
|
2634 | + unset($all_options['give_completed_upgrades']); |
|
2635 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
2636 | 2636 | } |
2637 | 2637 | |
2638 | 2638 | } |
@@ -2647,7 +2647,7 @@ discard block |
||
2647 | 2647 | $give_updates = Give_Updates::get_instance(); |
2648 | 2648 | |
2649 | 2649 | // form query. |
2650 | - $donation_forms = new WP_Query( array( |
|
2650 | + $donation_forms = new WP_Query(array( |
|
2651 | 2651 | 'paged' => $give_updates->step, |
2652 | 2652 | 'status' => 'any', |
2653 | 2653 | 'order' => 'ASC', |
@@ -2656,16 +2656,16 @@ discard block |
||
2656 | 2656 | ) |
2657 | 2657 | ); |
2658 | 2658 | |
2659 | - if ( $donation_forms->have_posts() ) { |
|
2660 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
2659 | + if ($donation_forms->have_posts()) { |
|
2660 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
2661 | 2661 | |
2662 | - while ( $donation_forms->have_posts() ) { |
|
2662 | + while ($donation_forms->have_posts()) { |
|
2663 | 2663 | $donation_forms->the_post(); |
2664 | 2664 | $form_id = get_the_ID(); |
2665 | 2665 | |
2666 | - $form_closed_status = give_get_meta( $form_id, '_give_form_status', true ); |
|
2667 | - if ( empty( $form_closed_status ) ) { |
|
2668 | - give_set_form_closed_status( $form_id ); |
|
2666 | + $form_closed_status = give_get_meta($form_id, '_give_form_status', true); |
|
2667 | + if (empty($form_closed_status)) { |
|
2668 | + give_set_form_closed_status($form_id); |
|
2669 | 2669 | } |
2670 | 2670 | } |
2671 | 2671 | |
@@ -2675,7 +2675,7 @@ discard block |
||
2675 | 2675 | } else { |
2676 | 2676 | |
2677 | 2677 | // The Update Ran. |
2678 | - give_set_upgrade_complete( 'v210_verify_form_status_upgrades' ); |
|
2678 | + give_set_upgrade_complete('v210_verify_form_status_upgrades'); |
|
2679 | 2679 | } |
2680 | 2680 | |
2681 | 2681 | } |
@@ -2695,22 +2695,22 @@ discard block |
||
2695 | 2695 | SELECT DISTINCT payment_id |
2696 | 2696 | FROM {$donation_meta_table} |
2697 | 2697 | LIMIT 20 |
2698 | - OFFSET {$give_updates->get_offset( 20 )} |
|
2698 | + OFFSET {$give_updates->get_offset(20)} |
|
2699 | 2699 | " |
2700 | 2700 | ); |
2701 | 2701 | |
2702 | - if ( ! empty( $donations ) ) { |
|
2703 | - foreach ( $donations as $donation ) { |
|
2704 | - $donation_obj = get_post( $donation ); |
|
2702 | + if ( ! empty($donations)) { |
|
2703 | + foreach ($donations as $donation) { |
|
2704 | + $donation_obj = get_post($donation); |
|
2705 | 2705 | |
2706 | - if ( ! $donation_obj instanceof WP_Post ) { |
|
2707 | - Give()->payment_meta->delete_all_meta( $donation ); |
|
2706 | + if ( ! $donation_obj instanceof WP_Post) { |
|
2707 | + Give()->payment_meta->delete_all_meta($donation); |
|
2708 | 2708 | } |
2709 | 2709 | } |
2710 | 2710 | } else { |
2711 | 2711 | |
2712 | 2712 | // The Update Ran. |
2713 | - give_set_upgrade_complete( 'v213_delete_donation_meta' ); |
|
2713 | + give_set_upgrade_complete('v213_delete_donation_meta'); |
|
2714 | 2714 | } |
2715 | 2715 | |
2716 | 2716 | } |
@@ -2722,8 +2722,8 @@ discard block |
||
2722 | 2722 | */ |
2723 | 2723 | function give_v215_update_donor_user_roles_callback() { |
2724 | 2724 | |
2725 | - $role = get_role( 'give_manager' ); |
|
2726 | - $role->add_cap( 'view_give_payments' ); |
|
2725 | + $role = get_role('give_manager'); |
|
2726 | + $role->add_cap('view_give_payments'); |
|
2727 | 2727 | |
2728 | - give_set_upgrade_complete( 'v215_update_donor_user_roles' ); |
|
2728 | + give_set_upgrade_complete('v215_update_donor_user_roles'); |
|
2729 | 2729 | } |