@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly. |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * |
72 | 72 | * } |
73 | 73 | */ |
74 | - public function add( $args ) { |
|
75 | - __give_211_bc_email_template_tag_param( $args, func_get_args() ); |
|
74 | + public function add($args) { |
|
75 | + __give_211_bc_email_template_tag_param($args, func_get_args()); |
|
76 | 76 | |
77 | - if ( is_callable( $args['func'] ) ) { |
|
78 | - $this->tags[ $args['tag'] ] = array( |
|
77 | + if (is_callable($args['func'])) { |
|
78 | + $this->tags[$args['tag']] = array( |
|
79 | 79 | 'tag' => $args['tag'], |
80 | 80 | 'desc' => $args['desc'], |
81 | 81 | 'func' => $args['func'], |
82 | - 'context' => give_check_variable( $args['context'], 'empty', 'general' ), |
|
82 | + 'context' => give_check_variable($args['context'], 'empty', 'general'), |
|
83 | 83 | 'is_admin' => (bool) $args['is_admin'], // Introduced in 2.2.1 |
84 | 84 | 'description' => $args['desc'], // deprecated in 2.2.1 |
85 | 85 | 'function' => $args['func'], // deprecated in 2.2.1 |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param string $tag Email tag to remove hook from |
96 | 96 | */ |
97 | - public function remove( $tag ) { |
|
98 | - unset( $this->tags[ $tag ] ); |
|
97 | + public function remove($tag) { |
|
98 | + unset($this->tags[$tag]); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - public function email_tag_exists( $tag ) { |
|
111 | - return array_key_exists( $tag, $this->tags ); |
|
110 | + public function email_tag_exists($tag) { |
|
111 | + return array_key_exists($tag, $this->tags); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -122,23 +122,23 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return array |
124 | 124 | */ |
125 | - public function get_tags( $context_type = 'all', $field = '' ) { |
|
125 | + public function get_tags($context_type = 'all', $field = '') { |
|
126 | 126 | $tags = $this->tags; |
127 | 127 | |
128 | - if ( 'all' !== $context_type ) { |
|
128 | + if ('all' !== $context_type) { |
|
129 | 129 | $tags = array(); |
130 | 130 | |
131 | - foreach ( $this->tags as $tag ) { |
|
132 | - if ( empty( $tag['context'] ) || $context_type !== $tag['context'] ) { |
|
131 | + foreach ($this->tags as $tag) { |
|
132 | + if (empty($tag['context']) || $context_type !== $tag['context']) { |
|
133 | 133 | continue; |
134 | 134 | } |
135 | 135 | |
136 | - $tags[ $tag['tag'] ] = $tag; |
|
136 | + $tags[$tag['tag']] = $tag; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - if ( ! empty( $tags ) && ! empty( $field ) ) { |
|
141 | - $tags = wp_list_pluck( $tags, $field ); |
|
140 | + if ( ! empty($tags) && ! empty($field)) { |
|
141 | + $tags = wp_list_pluck($tags, $field); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | return $tags; |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return string Content with email tags filtered out. |
158 | 158 | */ |
159 | - public function do_tags( $content, $tag_args ) { |
|
159 | + public function do_tags($content, $tag_args) { |
|
160 | 160 | |
161 | 161 | // Check if there is at least one tag added. |
162 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
162 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
163 | 163 | return $content; |
164 | 164 | } |
165 | 165 | |
166 | 166 | $this->tag_args = $tag_args; |
167 | 167 | |
168 | - $new_content = preg_replace_callback( '/{([A-z0-9\-\_]+)}/s', array( $this, 'do_tag' ), $content ); |
|
168 | + $new_content = preg_replace_callback('/{([A-z0-9\-\_]+)}/s', array($this, 'do_tag'), $content); |
|
169 | 169 | |
170 | 170 | $this->tag_args = null; |
171 | 171 | |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return mixed |
183 | 183 | */ |
184 | - public function do_tag( $m ) { |
|
184 | + public function do_tag($m) { |
|
185 | 185 | |
186 | 186 | // Get tag |
187 | 187 | $tag = $m[1]; |
188 | 188 | |
189 | 189 | // Return tag if tag not set |
190 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
190 | + if ( ! $this->email_tag_exists($tag)) { |
|
191 | 191 | return $m[0]; |
192 | 192 | } |
193 | 193 | |
194 | - return call_user_func( $this->tags[ $tag ]['func'], $this->tag_args, $tag ); |
|
194 | + return call_user_func($this->tags[$tag]['func'], $this->tag_args, $tag); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | * @param array $args Email template tag argument |
206 | 206 | * Check Give_Email_Template_Tags::add function description for more information |
207 | 207 | */ |
208 | -function give_add_email_tag( $args ) { |
|
209 | - __give_211_bc_email_template_tag_param( $args, func_get_args() ); |
|
208 | +function give_add_email_tag($args) { |
|
209 | + __give_211_bc_email_template_tag_param($args, func_get_args()); |
|
210 | 210 | |
211 | - Give()->email_tags->add( $args ); |
|
211 | + Give()->email_tags->add($args); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @param string $tag Email tag to remove hook from |
220 | 220 | */ |
221 | -function give_remove_email_tag( $tag ) { |
|
222 | - Give()->email_tags->remove( $tag ); |
|
221 | +function give_remove_email_tag($tag) { |
|
222 | + Give()->email_tags->remove($tag); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return bool |
233 | 233 | */ |
234 | -function give_email_tag_exists( $tag ) { |
|
235 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
234 | +function give_email_tag_exists($tag) { |
|
235 | + return Give()->email_tags->email_tag_exists($tag); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | $email_tags = give_get_email_tags(); |
260 | 260 | |
261 | 261 | ob_start(); |
262 | - if ( count( $email_tags ) > 0 ) : ?> |
|
262 | + if (count($email_tags) > 0) : ?> |
|
263 | 263 | <div class="give-email-tags-wrap"> |
264 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
264 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
265 | 265 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
266 | 266 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['desc']; ?> |
267 | 267 | </span> |
@@ -286,10 +286,10 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return string Content with email tags filtered out. |
288 | 288 | */ |
289 | -function give_do_email_tags( $content, $tag_args ) { |
|
289 | +function give_do_email_tags($content, $tag_args) { |
|
290 | 290 | // Backward compatibility < 2.0 |
291 | - if ( ! is_array( $tag_args ) && is_numeric( $tag_args ) ) { |
|
292 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
291 | + if ( ! is_array($tag_args) && is_numeric($tag_args)) { |
|
292 | + $tag_args = array('payment_id' => $tag_args); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | $email_tags = Give()->email_tags instanceof Give_Email_Template_Tags |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | : new Give_Email_Template_Tags(); |
298 | 298 | |
299 | 299 | // Replace all tags |
300 | - $content = $email_tags->do_tags( $content, $tag_args ); |
|
300 | + $content = $email_tags->do_tags($content, $tag_args); |
|
301 | 301 | |
302 | 302 | /** |
303 | 303 | * Filter the filtered content text. |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @since 1.0 |
306 | 306 | * @since 2.0 $payment_meta, $payment_id removed and $tag_args added. |
307 | 307 | */ |
308 | - $content = apply_filters( 'give_email_template_tags', $content, $tag_args ); |
|
308 | + $content = apply_filters('give_email_template_tags', $content, $tag_args); |
|
309 | 309 | |
310 | 310 | // Return content |
311 | 311 | return $content; |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @since 1.0 |
326 | 326 | */ |
327 | - do_action( 'give_add_email_tags' ); |
|
327 | + do_action('give_add_email_tags'); |
|
328 | 328 | } |
329 | 329 | |
330 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
330 | +add_action('init', 'give_load_email_tags', - 999); |
|
331 | 331 | |
332 | 332 | |
333 | 333 | /** |
@@ -342,67 +342,67 @@ discard block |
||
342 | 342 | /* Donation Payment */ |
343 | 343 | array( |
344 | 344 | 'tag' => 'donation', |
345 | - 'desc' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
345 | + 'desc' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'), |
|
346 | 346 | 'func' => 'give_email_tag_donation', |
347 | 347 | 'context' => 'donation', |
348 | 348 | ), |
349 | 349 | array( |
350 | 350 | 'tag' => 'amount', |
351 | - 'desc' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
351 | + 'desc' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
352 | 352 | 'func' => 'give_email_tag_amount', |
353 | 353 | 'context' => 'donation', |
354 | 354 | ), |
355 | 355 | array( |
356 | 356 | 'tag' => 'price', |
357 | - 'desc' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
357 | + 'desc' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
358 | 358 | 'func' => 'give_email_tag_price', |
359 | 359 | 'context' => 'donation', |
360 | 360 | ), |
361 | 361 | array( |
362 | 362 | 'tag' => 'billing_address', |
363 | - 'desc' => esc_html__( 'The donor\'s billing address.', 'give' ), |
|
363 | + 'desc' => esc_html__('The donor\'s billing address.', 'give'), |
|
364 | 364 | 'func' => 'give_email_tag_billing_address', |
365 | 365 | 'context' => 'donation', |
366 | 366 | ), |
367 | 367 | array( |
368 | 368 | 'tag' => 'date', |
369 | - 'desc' => esc_html__( 'The date of the donation.', 'give' ), |
|
369 | + 'desc' => esc_html__('The date of the donation.', 'give'), |
|
370 | 370 | 'func' => 'give_email_tag_date', |
371 | 371 | 'context' => 'donation', |
372 | 372 | ), |
373 | 373 | array( |
374 | 374 | 'tag' => 'payment_id', |
375 | - 'desc' => esc_html__( 'The unique ID number for this donation.', 'give' ), |
|
375 | + 'desc' => esc_html__('The unique ID number for this donation.', 'give'), |
|
376 | 376 | 'func' => 'give_email_tag_payment_id', |
377 | 377 | 'context' => 'donation', |
378 | 378 | ), |
379 | 379 | array( |
380 | 380 | 'tag' => 'payment_method', |
381 | - 'desc' => esc_html__( 'The method of payment used for this donation.', 'give' ), |
|
381 | + 'desc' => esc_html__('The method of payment used for this donation.', 'give'), |
|
382 | 382 | 'func' => 'give_email_tag_payment_method', |
383 | 383 | 'context' => 'donation', |
384 | 384 | ), |
385 | 385 | array( |
386 | 386 | 'tag' => 'payment_total', |
387 | - 'desc' => esc_html__( 'The payment total for this donation.', 'give' ), |
|
387 | + 'desc' => esc_html__('The payment total for this donation.', 'give'), |
|
388 | 388 | 'func' => 'give_email_tag_payment_total', |
389 | 389 | 'context' => 'donation', |
390 | 390 | ), |
391 | 391 | array( |
392 | 392 | 'tag' => 'receipt_id', |
393 | - 'desc' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ), |
|
393 | + 'desc' => esc_html__('The unique ID number for this donation receipt.', 'give'), |
|
394 | 394 | 'func' => 'give_email_tag_receipt_id', |
395 | 395 | 'context' => 'donation', |
396 | 396 | ), |
397 | 397 | array( |
398 | 398 | 'tag' => 'receipt_link', |
399 | - 'desc' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
399 | + 'desc' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
400 | 400 | 'func' => 'give_email_tag_receipt_link', |
401 | 401 | 'context' => 'donation', |
402 | 402 | ), |
403 | 403 | array( |
404 | 404 | 'tag' => 'receipt_link_url', |
405 | - 'desc' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
405 | + 'desc' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
406 | 406 | 'func' => 'give_email_tag_receipt_link_url', |
407 | 407 | 'context' => 'donation', |
408 | 408 | ), |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | /* Donation Form */ |
411 | 411 | array( |
412 | 412 | 'tag' => 'form_title', |
413 | - 'desc' => esc_html__( 'The donation form name.', 'give' ), |
|
413 | + 'desc' => esc_html__('The donation form name.', 'give'), |
|
414 | 414 | 'func' => 'give_email_tag_form_title', |
415 | 415 | 'context' => 'form', |
416 | 416 | ), |
@@ -418,37 +418,37 @@ discard block |
||
418 | 418 | /* Donor */ |
419 | 419 | array( |
420 | 420 | 'tag' => 'name', |
421 | - 'desc' => esc_html__( 'The donor\'s first name.', 'give' ), |
|
421 | + 'desc' => esc_html__('The donor\'s first name.', 'give'), |
|
422 | 422 | 'func' => 'give_email_tag_first_name', |
423 | 423 | 'context' => 'donor', |
424 | 424 | ), |
425 | 425 | array( |
426 | 426 | 'tag' => 'fullname', |
427 | - 'desc' => esc_html__( 'The donor\'s full name, first and last.', 'give' ), |
|
427 | + 'desc' => esc_html__('The donor\'s full name, first and last.', 'give'), |
|
428 | 428 | 'func' => 'give_email_tag_fullname', |
429 | 429 | 'context' => 'donor', |
430 | 430 | ), |
431 | 431 | array( |
432 | 432 | 'tag' => 'username', |
433 | - 'desc' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
433 | + 'desc' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
434 | 434 | 'func' => 'give_email_tag_username', |
435 | 435 | 'context' => 'donor', |
436 | 436 | ), |
437 | 437 | array( |
438 | 438 | 'tag' => 'company_name', |
439 | - 'desc' => esc_html__( 'Company name.', 'give' ), |
|
439 | + 'desc' => esc_html__('Company name.', 'give'), |
|
440 | 440 | 'func' => 'give_email_tag_company_name', |
441 | 441 | 'context' => 'donation', |
442 | 442 | ), |
443 | 443 | array( |
444 | 444 | 'tag' => 'user_email', |
445 | - 'desc' => esc_html__( 'The donor\'s email address.', 'give' ), |
|
445 | + 'desc' => esc_html__('The donor\'s email address.', 'give'), |
|
446 | 446 | 'func' => 'give_email_tag_user_email', |
447 | 447 | 'context' => 'donor', |
448 | 448 | ), |
449 | 449 | array( |
450 | 450 | 'tag' => 'email_access_link', |
451 | - 'desc' => esc_html__( 'The donor\'s email access link.', 'give' ), |
|
451 | + 'desc' => esc_html__('The donor\'s email access link.', 'give'), |
|
452 | 452 | 'func' => 'give_email_tag_email_access_link', |
453 | 453 | 'context' => 'donor', |
454 | 454 | ), |
@@ -456,35 +456,35 @@ discard block |
||
456 | 456 | /* General */ |
457 | 457 | array( |
458 | 458 | 'tag' => 'sitename', |
459 | - 'desc' => esc_html__( 'The name of your site.', 'give' ), |
|
459 | + 'desc' => esc_html__('The name of your site.', 'give'), |
|
460 | 460 | 'func' => 'give_email_tag_sitename', |
461 | 461 | 'context' => 'general', |
462 | 462 | ), |
463 | 463 | |
464 | 464 | array( |
465 | 465 | 'tag' => 'reset_password_link', |
466 | - 'desc' => esc_html__( 'The reset password link for user.', 'give' ), |
|
466 | + 'desc' => esc_html__('The reset password link for user.', 'give'), |
|
467 | 467 | 'func' => 'give_email_tag_reset_password_link', |
468 | 468 | 'context' => 'general', |
469 | 469 | ), |
470 | 470 | |
471 | 471 | array( |
472 | 472 | 'tag' => 'admin_email', |
473 | - 'desc' => esc_html__( 'The custom admin email which is set inside Emails > Contact Information. By default this tag will use your WordPress admin email.', 'give' ), |
|
473 | + 'desc' => esc_html__('The custom admin email which is set inside Emails > Contact Information. By default this tag will use your WordPress admin email.', 'give'), |
|
474 | 474 | 'func' => 'give_email_admin_email', |
475 | 475 | 'context' => 'general', |
476 | 476 | ), |
477 | 477 | |
478 | 478 | array( |
479 | 479 | 'tag' => 'site_url', |
480 | - 'desc' => esc_html__( 'The website URL.', 'give' ), |
|
480 | + 'desc' => esc_html__('The website URL.', 'give'), |
|
481 | 481 | 'func' => 'give_email_site_url', |
482 | 482 | 'context' => 'general', |
483 | 483 | ), |
484 | 484 | |
485 | 485 | array( |
486 | 486 | 'tag' => 'offline_mailing_address', |
487 | - 'desc' => esc_html__( 'The Offline Mailing Address which is used for the Offline Donations Payment Gateway.', 'give' ), |
|
487 | + 'desc' => esc_html__('The Offline Mailing Address which is used for the Offline Donations Payment Gateway.', 'give'), |
|
488 | 488 | 'func' => 'give_email_offline_mailing_address', |
489 | 489 | 'context' => 'general', |
490 | 490 | ), |
@@ -492,16 +492,16 @@ discard block |
||
492 | 492 | ); |
493 | 493 | |
494 | 494 | // Apply give_email_tags filter |
495 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
495 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
496 | 496 | |
497 | 497 | // Add email tags |
498 | - foreach ( $email_tags as $email_tag ) { |
|
499 | - give_add_email_tag( $email_tag ); |
|
498 | + foreach ($email_tags as $email_tag) { |
|
499 | + give_add_email_tag($email_tag); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | } |
503 | 503 | |
504 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
504 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
505 | 505 | |
506 | 506 | |
507 | 507 | /** |
@@ -513,24 +513,24 @@ discard block |
||
513 | 513 | * |
514 | 514 | * @return string $firstname |
515 | 515 | */ |
516 | -function give_email_tag_first_name( $tag_args ) { |
|
516 | +function give_email_tag_first_name($tag_args) { |
|
517 | 517 | $user_info = array(); |
518 | 518 | $firstname = ''; |
519 | 519 | |
520 | 520 | // Backward compatibility. |
521 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
521 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
522 | 522 | |
523 | - switch ( true ) { |
|
524 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
525 | - $donor_info = give_get_payment_meta_user_info( $tag_args['payment_id'] ); |
|
526 | - $email_names = give_get_email_names( $donor_info ); |
|
523 | + switch (true) { |
|
524 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
525 | + $donor_info = give_get_payment_meta_user_info($tag_args['payment_id']); |
|
526 | + $email_names = give_get_email_names($donor_info); |
|
527 | 527 | $firstname = $email_names['name']; |
528 | 528 | |
529 | 529 | break; |
530 | 530 | |
531 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
531 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
532 | 532 | $firstname = Give()->donor_meta->get_meta( |
533 | - Give()->donors->get_column_by( 'id', 'user_id', $tag_args['user_id'] ), |
|
533 | + Give()->donors->get_column_by('id', 'user_id', $tag_args['user_id']), |
|
534 | 534 | '_give_donor_first_name', |
535 | 535 | true |
536 | 536 | ); |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @since 2.0 |
543 | 543 | */ |
544 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
545 | - $firstname = Give()->donor_meta->get_meta( $tag_args['donor_id'], '_give_donor_first_name', true ); |
|
544 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
545 | + $firstname = Give()->donor_meta->get_meta($tag_args['donor_id'], '_give_donor_first_name', true); |
|
546 | 546 | break; |
547 | 547 | } |
548 | 548 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | * @param string $firstname |
555 | 555 | * @param array $tag_args |
556 | 556 | */ |
557 | - $firstname = apply_filters( 'give_email_tag_first_name', $firstname, $tag_args ); |
|
557 | + $firstname = apply_filters('give_email_tag_first_name', $firstname, $tag_args); |
|
558 | 558 | |
559 | 559 | return $firstname; |
560 | 560 | } |
@@ -568,21 +568,21 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @return string $fullname |
570 | 570 | */ |
571 | -function give_email_tag_fullname( $tag_args ) { |
|
571 | +function give_email_tag_fullname($tag_args) { |
|
572 | 572 | $fullname = ''; |
573 | 573 | |
574 | 574 | // Backward compatibility. |
575 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
575 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
576 | 576 | |
577 | - switch ( true ) { |
|
578 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
579 | - $donor_info = give_get_payment_meta_user_info( $tag_args['payment_id'] ); |
|
580 | - $email_names = give_get_email_names( $donor_info ); |
|
577 | + switch (true) { |
|
578 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
579 | + $donor_info = give_get_payment_meta_user_info($tag_args['payment_id']); |
|
580 | + $email_names = give_get_email_names($donor_info); |
|
581 | 581 | $fullname = $email_names['fullname']; |
582 | 582 | break; |
583 | 583 | |
584 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
585 | - $fullname = Give()->donors->get_column_by( 'name', 'user_id', $tag_args['user_id'] ); |
|
584 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
585 | + $fullname = Give()->donors->get_column_by('name', 'user_id', $tag_args['user_id']); |
|
586 | 586 | break; |
587 | 587 | |
588 | 588 | /** |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @since 2.0 |
592 | 592 | */ |
593 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
594 | - $fullname = Give()->donors->get_column( 'name', $tag_args['donor_id'] ); |
|
593 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
594 | + $fullname = Give()->donors->get_column('name', $tag_args['donor_id']); |
|
595 | 595 | break; |
596 | 596 | } |
597 | 597 | |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | * @param string $fullname |
604 | 604 | * @param array $tag_args |
605 | 605 | */ |
606 | - $fullname = apply_filters( 'give_email_tag_fullname', $fullname, $tag_args ); |
|
606 | + $fullname = apply_filters('give_email_tag_fullname', $fullname, $tag_args); |
|
607 | 607 | |
608 | 608 | return $fullname; |
609 | 609 | } |
@@ -617,21 +617,21 @@ discard block |
||
617 | 617 | * |
618 | 618 | * @return string username. |
619 | 619 | */ |
620 | -function give_email_tag_username( $tag_args ) { |
|
620 | +function give_email_tag_username($tag_args) { |
|
621 | 621 | $username = ''; |
622 | 622 | |
623 | 623 | // Backward compatibility. |
624 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
624 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
625 | 625 | |
626 | - switch ( true ) { |
|
627 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
628 | - $donor_info = give_get_payment_meta_user_info( $tag_args['payment_id'] ); |
|
629 | - $email_names = give_get_email_names( $donor_info ); |
|
626 | + switch (true) { |
|
627 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
628 | + $donor_info = give_get_payment_meta_user_info($tag_args['payment_id']); |
|
629 | + $email_names = give_get_email_names($donor_info); |
|
630 | 630 | $username = $email_names['username']; |
631 | 631 | break; |
632 | 632 | |
633 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
634 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
633 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
634 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
635 | 635 | $username = $user_info->user_login; |
636 | 636 | break; |
637 | 637 | |
@@ -640,9 +640,9 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @since 2.0 |
642 | 642 | */ |
643 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
644 | - if ( $user_id = Give()->donors->get_column( 'user_id', $tag_args['donor_id'] ) ) { |
|
645 | - $user_info = get_user_by( 'id', $user_id ); |
|
643 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
644 | + if ($user_id = Give()->donors->get_column('user_id', $tag_args['donor_id'])) { |
|
645 | + $user_info = get_user_by('id', $user_id); |
|
646 | 646 | $username = $user_info->user_login; |
647 | 647 | } |
648 | 648 | break; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | * @param string $username |
657 | 657 | * @param array $tag_args |
658 | 658 | */ |
659 | - $username = apply_filters( 'give_email_tag_username', $username, $tag_args ); |
|
659 | + $username = apply_filters('give_email_tag_username', $username, $tag_args); |
|
660 | 660 | |
661 | 661 | return $username; |
662 | 662 | } |
@@ -670,19 +670,19 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return string user_email |
672 | 672 | */ |
673 | -function give_email_tag_user_email( $tag_args ) { |
|
673 | +function give_email_tag_user_email($tag_args) { |
|
674 | 674 | $email = ''; |
675 | 675 | |
676 | 676 | // Backward compatibility. |
677 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
677 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
678 | 678 | |
679 | - switch ( true ) { |
|
680 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
681 | - $email = give_get_donation_donor_email( $tag_args['payment_id'] ); |
|
679 | + switch (true) { |
|
680 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
681 | + $email = give_get_donation_donor_email($tag_args['payment_id']); |
|
682 | 682 | break; |
683 | 683 | |
684 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
685 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
684 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
685 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
686 | 686 | $email = $user_info->user_email; |
687 | 687 | break; |
688 | 688 | |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @since 2.0 |
693 | 693 | */ |
694 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
695 | - $email = Give()->donors->get_column( 'email', $tag_args['donor_id'] ); |
|
694 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
695 | + $email = Give()->donors->get_column('email', $tag_args['donor_id']); |
|
696 | 696 | break; |
697 | 697 | } |
698 | 698 | |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param string $email |
705 | 705 | * @param array $tag_args |
706 | 706 | */ |
707 | - $email = apply_filters( 'give_email_tag_user_email', $email, $tag_args ); |
|
707 | + $email = apply_filters('give_email_tag_user_email', $email, $tag_args); |
|
708 | 708 | |
709 | 709 | return $email; |
710 | 710 | } |
@@ -718,22 +718,22 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @return string billing_address |
720 | 720 | */ |
721 | -function give_email_tag_billing_address( $tag_args ) { |
|
721 | +function give_email_tag_billing_address($tag_args) { |
|
722 | 722 | $address = ''; |
723 | 723 | |
724 | 724 | // Backward compatibility. |
725 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
725 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
726 | 726 | |
727 | - switch ( true ) { |
|
728 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
729 | - $donation_address = give_get_donation_address( $tag_args['payment_id'] ); |
|
727 | + switch (true) { |
|
728 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
729 | + $donation_address = give_get_donation_address($tag_args['payment_id']); |
|
730 | 730 | |
731 | 731 | $billing_address = array(); |
732 | 732 | $billing_address['street_address'] = ''; |
733 | 733 | $billing_address['street_address'] .= $donation_address['line1']; |
734 | 734 | |
735 | - if ( ! empty( $donation_address['line2'] ) ) { |
|
736 | - $billing_address['street_address'] .= "\n" . $donation_address['line2']; |
|
735 | + if ( ! empty($donation_address['line2'])) { |
|
736 | + $billing_address['street_address'] .= "\n".$donation_address['line2']; |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | $billing_address['city'] = $donation_address['city']; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $billing_address['postal_code'] = $donation_address['zip']; |
742 | 742 | $billing_address['country'] = $donation_address['country']; |
743 | 743 | |
744 | - $address = give_get_formatted_address( $billing_address ); |
|
744 | + $address = give_get_formatted_address($billing_address); |
|
745 | 745 | |
746 | 746 | break; |
747 | 747 | } |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * @param string $address |
755 | 755 | * @param array $tag_args |
756 | 756 | */ |
757 | - $address = apply_filters( 'give_email_tag_billing_address', $address, $tag_args ); |
|
757 | + $address = apply_filters('give_email_tag_billing_address', $address, $tag_args); |
|
758 | 758 | |
759 | 759 | return $address; |
760 | 760 | } |
@@ -768,15 +768,15 @@ discard block |
||
768 | 768 | * |
769 | 769 | * @return string $date Post Date. |
770 | 770 | */ |
771 | -function give_email_tag_date( $tag_args ) { |
|
771 | +function give_email_tag_date($tag_args) { |
|
772 | 772 | $date = ''; |
773 | 773 | |
774 | 774 | // Backward compatibility. |
775 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
775 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
776 | 776 | |
777 | - switch ( true ) { |
|
778 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
779 | - $date = date_i18n( give_date_format(), get_the_date( 'U', $tag_args['payment_id'] ) ); |
|
777 | + switch (true) { |
|
778 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
779 | + $date = date_i18n(give_date_format(), get_the_date('U', $tag_args['payment_id'])); |
|
780 | 780 | break; |
781 | 781 | } |
782 | 782 | |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | * @param string $date |
789 | 789 | * @param array $tag_args |
790 | 790 | */ |
791 | - $date = apply_filters( 'give_email_tag_date', $date, $tag_args ); |
|
791 | + $date = apply_filters('give_email_tag_date', $date, $tag_args); |
|
792 | 792 | |
793 | 793 | return $date; |
794 | 794 | } |
@@ -802,16 +802,16 @@ discard block |
||
802 | 802 | * |
803 | 803 | * @return string amount |
804 | 804 | */ |
805 | -function give_email_tag_amount( $tag_args ) { |
|
805 | +function give_email_tag_amount($tag_args) { |
|
806 | 806 | $amount = ''; |
807 | 807 | |
808 | 808 | // Backward compatibility. |
809 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
809 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
810 | 810 | |
811 | - switch ( true ) { |
|
812 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
813 | - $give_amount = give_donation_amount( $tag_args['payment_id'], true ); |
|
814 | - $amount = html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
811 | + switch (true) { |
|
812 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
813 | + $give_amount = give_donation_amount($tag_args['payment_id'], true); |
|
814 | + $amount = html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
815 | 815 | break; |
816 | 816 | } |
817 | 817 | |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | * @param string $amount |
824 | 824 | * @param array $tag_args |
825 | 825 | */ |
826 | - $amount = apply_filters( 'give_email_tag_amount', $amount, $tag_args ); |
|
826 | + $amount = apply_filters('give_email_tag_amount', $amount, $tag_args); |
|
827 | 827 | |
828 | 828 | return $amount; |
829 | 829 | } |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @return string price |
839 | 839 | */ |
840 | -function give_email_tag_price( $tag_args ) { |
|
841 | - return give_email_tag_amount( $tag_args ); |
|
840 | +function give_email_tag_price($tag_args) { |
|
841 | + return give_email_tag_amount($tag_args); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -850,15 +850,15 @@ discard block |
||
850 | 850 | * |
851 | 851 | * @return int payment_id |
852 | 852 | */ |
853 | -function give_email_tag_payment_id( $tag_args ) { |
|
853 | +function give_email_tag_payment_id($tag_args) { |
|
854 | 854 | $payment_id = ''; |
855 | 855 | |
856 | 856 | // Backward compatibility. |
857 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
857 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
858 | 858 | |
859 | - switch ( true ) { |
|
860 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
861 | - $payment_id = Give()->seq_donation_number->get_serial_code( $tag_args['payment_id'] ); |
|
859 | + switch (true) { |
|
860 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
861 | + $payment_id = Give()->seq_donation_number->get_serial_code($tag_args['payment_id']); |
|
862 | 862 | break; |
863 | 863 | } |
864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | * @param string $payment_id |
871 | 871 | * @param array $tag_args |
872 | 872 | */ |
873 | - return apply_filters( 'give_email_tag_payment_id', $payment_id, $tag_args ); |
|
873 | + return apply_filters('give_email_tag_payment_id', $payment_id, $tag_args); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -882,15 +882,15 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @return string receipt_id |
884 | 884 | */ |
885 | -function give_email_tag_receipt_id( $tag_args ) { |
|
885 | +function give_email_tag_receipt_id($tag_args) { |
|
886 | 886 | $receipt_id = ''; |
887 | 887 | |
888 | 888 | // Backward compatibility. |
889 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
889 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
890 | 890 | |
891 | - switch ( true ) { |
|
892 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
893 | - $receipt_id = give_get_payment_key( $tag_args['payment_id'] ); |
|
891 | + switch (true) { |
|
892 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
893 | + $receipt_id = give_get_payment_key($tag_args['payment_id']); |
|
894 | 894 | break; |
895 | 895 | } |
896 | 896 | |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @param string $receipt_id |
903 | 903 | * @param array $tag_args |
904 | 904 | */ |
905 | - return apply_filters( 'give_email_tag_receipt_id', $receipt_id, $tag_args ); |
|
905 | + return apply_filters('give_email_tag_receipt_id', $receipt_id, $tag_args); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -914,21 +914,21 @@ discard block |
||
914 | 914 | * |
915 | 915 | * @return string $form_title |
916 | 916 | */ |
917 | -function give_email_tag_donation( $tag_args ) { |
|
917 | +function give_email_tag_donation($tag_args) { |
|
918 | 918 | $donation_form_title = ''; |
919 | 919 | |
920 | 920 | // Backward compatibility. |
921 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
921 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
922 | 922 | |
923 | - switch ( true ) { |
|
924 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
925 | - $level_title = give_has_variable_prices( give_get_payment_form_id( $tag_args['payment_id'] ) ); |
|
923 | + switch (true) { |
|
924 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
925 | + $level_title = give_has_variable_prices(give_get_payment_form_id($tag_args['payment_id'])); |
|
926 | 926 | $separator = $level_title ? '-' : ''; |
927 | 927 | $donation_form_title = strip_tags( |
928 | 928 | give_check_variable( |
929 | 929 | give_get_donation_form_title( |
930 | 930 | $tag_args['payment_id'], |
931 | - array( 'separator' => $separator ) |
|
931 | + array('separator' => $separator) |
|
932 | 932 | ), |
933 | 933 | 'empty', |
934 | 934 | '' |
@@ -961,15 +961,15 @@ discard block |
||
961 | 961 | * |
962 | 962 | * @return string $form_title |
963 | 963 | */ |
964 | -function give_email_tag_form_title( $tag_args ) { |
|
964 | +function give_email_tag_form_title($tag_args) { |
|
965 | 965 | $donation_form_title = ''; |
966 | 966 | |
967 | 967 | // Backward compatibility. |
968 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
968 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
969 | 969 | |
970 | - switch ( true ) { |
|
971 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
972 | - $donation_form_title = give_get_payment_meta( $tag_args['payment_id'], '_give_payment_form_title' ); |
|
970 | + switch (true) { |
|
971 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
972 | + $donation_form_title = give_get_payment_meta($tag_args['payment_id'], '_give_payment_form_title'); |
|
973 | 973 | break; |
974 | 974 | } |
975 | 975 | |
@@ -998,15 +998,15 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return string $company_name |
1000 | 1000 | */ |
1001 | -function give_email_tag_company_name( $tag_args ) { |
|
1001 | +function give_email_tag_company_name($tag_args) { |
|
1002 | 1002 | $company_name = ''; |
1003 | 1003 | |
1004 | 1004 | // Backward compatibility. |
1005 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1005 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1006 | 1006 | |
1007 | - switch ( true ) { |
|
1008 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1009 | - $company_name = give_get_payment_meta( $tag_args['payment_id'], '_give_donation_company', true ); |
|
1007 | + switch (true) { |
|
1008 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1009 | + $company_name = give_get_payment_meta($tag_args['payment_id'], '_give_donation_company', true); |
|
1010 | 1010 | break; |
1011 | 1011 | } |
1012 | 1012 | |
@@ -1034,18 +1034,18 @@ discard block |
||
1034 | 1034 | * |
1035 | 1035 | * @return string gateway |
1036 | 1036 | */ |
1037 | -function give_email_tag_payment_method( $tag_args ) { |
|
1037 | +function give_email_tag_payment_method($tag_args) { |
|
1038 | 1038 | $payment_method = ''; |
1039 | 1039 | |
1040 | 1040 | // Backward compatibility. |
1041 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1041 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1042 | 1042 | |
1043 | 1043 | // Backward compatibility. |
1044 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1044 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1045 | 1045 | |
1046 | - switch ( true ) { |
|
1047 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1048 | - $payment_method = give_get_gateway_checkout_label( give_get_payment_gateway( $tag_args['payment_id'] ) ); |
|
1046 | + switch (true) { |
|
1047 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1048 | + $payment_method = give_get_gateway_checkout_label(give_get_payment_gateway($tag_args['payment_id'])); |
|
1049 | 1049 | break; |
1050 | 1050 | } |
1051 | 1051 | |
@@ -1076,15 +1076,15 @@ discard block |
||
1076 | 1076 | * |
1077 | 1077 | * @return string |
1078 | 1078 | */ |
1079 | -function give_email_tag_payment_total( $tag_args ) { |
|
1079 | +function give_email_tag_payment_total($tag_args) { |
|
1080 | 1080 | $payment_total = ''; |
1081 | 1081 | |
1082 | 1082 | // Backward compatibility. |
1083 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1083 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1084 | 1084 | |
1085 | - switch ( true ) { |
|
1086 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1087 | - $payment_total = give_currency_filter( give_get_payment_total( $tag_args['payment_id'] ) ); |
|
1085 | + switch (true) { |
|
1086 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1087 | + $payment_total = give_currency_filter(give_get_payment_total($tag_args['payment_id'])); |
|
1088 | 1088 | break; |
1089 | 1089 | } |
1090 | 1090 | |
@@ -1112,11 +1112,11 @@ discard block |
||
1112 | 1112 | * |
1113 | 1113 | * @return string |
1114 | 1114 | */ |
1115 | -function give_email_tag_sitename( $tag_args = array() ) { |
|
1116 | - $sitename = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
1115 | +function give_email_tag_sitename($tag_args = array()) { |
|
1116 | + $sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
1117 | 1117 | |
1118 | 1118 | // Backward compatibility. |
1119 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1119 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1120 | 1120 | |
1121 | 1121 | /** |
1122 | 1122 | * Filter the {sitename} email template tag output. |
@@ -1142,21 +1142,21 @@ discard block |
||
1142 | 1142 | * |
1143 | 1143 | * @return string receipt_link |
1144 | 1144 | */ |
1145 | -function give_email_tag_receipt_link( $tag_args ) { |
|
1145 | +function give_email_tag_receipt_link($tag_args) { |
|
1146 | 1146 | // Backward compatibility. |
1147 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1147 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1148 | 1148 | |
1149 | - $receipt_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1149 | + $receipt_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1150 | 1150 | |
1151 | 1151 | // Bailout. |
1152 | - if ( give_get_option( 'email_template' ) === 'none' ) { |
|
1152 | + if (give_get_option('email_template') === 'none') { |
|
1153 | 1153 | return $receipt_url; |
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | $receipt_url = esc_url( |
1157 | 1157 | add_query_arg( |
1158 | 1158 | array( |
1159 | - 'payment_key' => give_get_payment_key( $tag_args['payment_id'] ), |
|
1159 | + 'payment_key' => give_get_payment_key($tag_args['payment_id']), |
|
1160 | 1160 | ), give_get_history_page_uri() |
1161 | 1161 | ) |
1162 | 1162 | ); |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | $formatted = sprintf( |
1165 | 1165 | '<a href="%1$s">%2$s</a>', |
1166 | 1166 | $receipt_url, |
1167 | - __( 'View it in your browser »', 'give' ) |
|
1167 | + __('View it in your browser »', 'give') |
|
1168 | 1168 | ); |
1169 | 1169 | |
1170 | 1170 | /** |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | * |
1194 | 1194 | * @return string receipt_url |
1195 | 1195 | */ |
1196 | -function give_email_tag_receipt_link_url( $tag_args ) { |
|
1196 | +function give_email_tag_receipt_link_url($tag_args) { |
|
1197 | 1197 | // Backward compatibility. |
1198 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1198 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1199 | 1199 | |
1200 | - $receipt_link_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1200 | + $receipt_link_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1201 | 1201 | |
1202 | 1202 | /** |
1203 | 1203 | * Filter the {receipt_link_url} email template tag output. |
@@ -1224,14 +1224,14 @@ discard block |
||
1224 | 1224 | * |
1225 | 1225 | * @return string |
1226 | 1226 | */ |
1227 | -function give_get_receipt_url( $payment_id ) { |
|
1227 | +function give_get_receipt_url($payment_id) { |
|
1228 | 1228 | $receipt_url = ''; |
1229 | 1229 | |
1230 | - if ( $payment_id ) { |
|
1230 | + if ($payment_id) { |
|
1231 | 1231 | $receipt_url = esc_url( |
1232 | 1232 | add_query_arg( |
1233 | 1233 | array( |
1234 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
1234 | + 'payment_key' => give_get_payment_key($payment_id), |
|
1235 | 1235 | ), give_get_history_page_uri() |
1236 | 1236 | ) |
1237 | 1237 | ); |
@@ -1250,22 +1250,22 @@ discard block |
||
1250 | 1250 | * |
1251 | 1251 | * @return string |
1252 | 1252 | */ |
1253 | -function give_email_tag_email_access_link( $tag_args ) { |
|
1253 | +function give_email_tag_email_access_link($tag_args) { |
|
1254 | 1254 | $donor_id = 0; |
1255 | 1255 | $donor = array(); |
1256 | 1256 | $email_access_link = ''; |
1257 | 1257 | |
1258 | 1258 | // Backward compatibility. |
1259 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1259 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1260 | 1260 | |
1261 | - switch ( true ) { |
|
1262 | - case ! empty( $tag_args['donor_id'] ): |
|
1261 | + switch (true) { |
|
1262 | + case ! empty($tag_args['donor_id']): |
|
1263 | 1263 | $donor_id = $tag_args['donor_id']; |
1264 | - $donor = Give()->donors->get_by( 'id', $tag_args['donor_id'] ); |
|
1264 | + $donor = Give()->donors->get_by('id', $tag_args['donor_id']); |
|
1265 | 1265 | break; |
1266 | 1266 | |
1267 | - case ! empty( $tag_args['user_id'] ): |
|
1268 | - $donor = Give()->donors->get_by( 'user_id', $tag_args['user_id'] ); |
|
1267 | + case ! empty($tag_args['user_id']): |
|
1268 | + $donor = Give()->donors->get_by('user_id', $tag_args['user_id']); |
|
1269 | 1269 | $donor_id = $donor->id; |
1270 | 1270 | break; |
1271 | 1271 | |
@@ -1274,11 +1274,11 @@ discard block |
||
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | // Set email access link if donor exist. |
1277 | - if ( $donor_id ) { |
|
1278 | - $verify_key = wp_generate_password( 20, false ); |
|
1277 | + if ($donor_id) { |
|
1278 | + $verify_key = wp_generate_password(20, false); |
|
1279 | 1279 | |
1280 | 1280 | // Generate a new verify key |
1281 | - Give()->email_access->set_verify_key( $donor_id, $donor->email, $verify_key ); |
|
1281 | + Give()->email_access->set_verify_key($donor_id, $donor->email, $verify_key); |
|
1282 | 1282 | // update verify key in email tags. |
1283 | 1283 | $tag_args['verify_key'] = $verify_key; |
1284 | 1284 | |
@@ -1293,28 +1293,28 @@ discard block |
||
1293 | 1293 | ); |
1294 | 1294 | |
1295 | 1295 | // Add Payment Key to email access url, if it exists. |
1296 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
1296 | + if ( ! empty($_GET['payment_key'])) { |
|
1297 | 1297 | $access_url = add_query_arg( |
1298 | 1298 | array( |
1299 | - 'payment_key' => give_clean( $_GET['payment_key'] ), |
|
1299 | + 'payment_key' => give_clean($_GET['payment_key']), |
|
1300 | 1300 | ), |
1301 | 1301 | $access_url |
1302 | 1302 | ); |
1303 | 1303 | } |
1304 | 1304 | |
1305 | - if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1305 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1306 | 1306 | $email_access_link = sprintf( |
1307 | 1307 | '<a href="%1$s" target="_blank">%2$s</a>', |
1308 | - esc_url( $access_url ), |
|
1309 | - __( 'View your donation history »', 'give' ) |
|
1308 | + esc_url($access_url), |
|
1309 | + __('View your donation history »', 'give') |
|
1310 | 1310 | ); |
1311 | 1311 | |
1312 | 1312 | } else { |
1313 | 1313 | |
1314 | 1314 | $email_access_link = sprintf( |
1315 | 1315 | '%1$s: %2$s', |
1316 | - __( 'View your donation history', 'give' ), |
|
1317 | - esc_url( $access_url ) |
|
1316 | + __('View your donation history', 'give'), |
|
1317 | + esc_url($access_url) |
|
1318 | 1318 | ); |
1319 | 1319 | } |
1320 | 1320 | } |
@@ -1346,23 +1346,23 @@ discard block |
||
1346 | 1346 | * |
1347 | 1347 | * @return array |
1348 | 1348 | */ |
1349 | -function __give_20_bc_str_type_email_tag_param( $tag_args ) { |
|
1350 | - if ( ! is_array( $tag_args ) ) { |
|
1351 | - switch ( true ) { |
|
1352 | - case ( 'give_payment' === get_post_type( $tag_args ) ): |
|
1353 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
1349 | +function __give_20_bc_str_type_email_tag_param($tag_args) { |
|
1350 | + if ( ! is_array($tag_args)) { |
|
1351 | + switch (true) { |
|
1352 | + case ('give_payment' === get_post_type($tag_args)): |
|
1353 | + $tag_args = array('payment_id' => $tag_args); |
|
1354 | 1354 | break; |
1355 | 1355 | |
1356 | - case ( ! is_wp_error( get_user_by( 'id', $tag_args ) ) ): |
|
1357 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1356 | + case ( ! is_wp_error(get_user_by('id', $tag_args))): |
|
1357 | + $tag_args = array('user_id' => $tag_args); |
|
1358 | 1358 | break; |
1359 | 1359 | |
1360 | - case ( Give()->donors->get_by( 'id', $tag_args ) ): |
|
1361 | - $tag_args = array( 'donor_id' => $tag_args ); |
|
1360 | + case (Give()->donors->get_by('id', $tag_args)): |
|
1361 | + $tag_args = array('donor_id' => $tag_args); |
|
1362 | 1362 | break; |
1363 | 1363 | |
1364 | - case ( Give()->donors->get_by( 'user_id', $tag_args ) ): |
|
1365 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1364 | + case (Give()->donors->get_by('user_id', $tag_args)): |
|
1365 | + $tag_args = array('user_id' => $tag_args); |
|
1366 | 1366 | break; |
1367 | 1367 | } |
1368 | 1368 | } |
@@ -1380,29 +1380,29 @@ discard block |
||
1380 | 1380 | * |
1381 | 1381 | * @since 2.2.1 |
1382 | 1382 | */ |
1383 | -function __give_211_bc_email_template_tag_param( &$args, $func_args = array() ) { |
|
1383 | +function __give_211_bc_email_template_tag_param(&$args, $func_args = array()) { |
|
1384 | 1384 | |
1385 | 1385 | /** |
1386 | 1386 | * This is for backward-compatibility, i.e.; if the parameters are |
1387 | 1387 | * still passed as 4 separate arguments instead of 1 single array. |
1388 | 1388 | */ |
1389 | - if ( ! is_array( $args ) ) { |
|
1389 | + if ( ! is_array($args)) { |
|
1390 | 1390 | $args = array( |
1391 | - 'tag' => isset( $func_args[0] ) ? $func_args[0] : '', |
|
1392 | - 'desc' => isset( $func_args[1] ) ? $func_args[1] : '', |
|
1393 | - 'func' => isset( $func_args[2] ) ? $func_args[2] : '', |
|
1394 | - 'context' => isset( $func_args[3] ) ? $func_args[3] : '', |
|
1391 | + 'tag' => isset($func_args[0]) ? $func_args[0] : '', |
|
1392 | + 'desc' => isset($func_args[1]) ? $func_args[1] : '', |
|
1393 | + 'func' => isset($func_args[2]) ? $func_args[2] : '', |
|
1394 | + 'context' => isset($func_args[3]) ? $func_args[3] : '', |
|
1395 | 1395 | 'is_admin' => false, |
1396 | 1396 | ); |
1397 | 1397 | } else { |
1398 | 1398 | |
1399 | 1399 | // This is for backward compatibility. Use 'desc' instead of 'description'. |
1400 | - if ( array_key_exists( 'description', $args ) ) { |
|
1400 | + if (array_key_exists('description', $args)) { |
|
1401 | 1401 | $args['desc'] = $args['description']; |
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | // This is for backward compatibility. Use 'func' instead of 'function'. |
1405 | - if ( array_key_exists( 'function', $args ) ) { |
|
1405 | + if (array_key_exists('function', $args)) { |
|
1406 | 1406 | $args['func'] = $args['function']; |
1407 | 1407 | } |
1408 | 1408 | |
@@ -1429,36 +1429,36 @@ discard block |
||
1429 | 1429 | * |
1430 | 1430 | * @return array |
1431 | 1431 | */ |
1432 | -function give_email_tag_reset_password_link( $tag_args, $payment_id ) { |
|
1432 | +function give_email_tag_reset_password_link($tag_args, $payment_id) { |
|
1433 | 1433 | |
1434 | 1434 | $reset_password_url = ''; |
1435 | 1435 | |
1436 | - switch ( true ) { |
|
1437 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1438 | - $payment_id = Give()->seq_donation_number->get_serial_code( $tag_args['payment_id'] ); |
|
1436 | + switch (true) { |
|
1437 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1438 | + $payment_id = Give()->seq_donation_number->get_serial_code($tag_args['payment_id']); |
|
1439 | 1439 | break; |
1440 | 1440 | |
1441 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
1442 | - $reset_password_url = give_get_reset_password_url( $tag_args['user_id'] ); |
|
1441 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
1442 | + $reset_password_url = give_get_reset_password_url($tag_args['user_id']); |
|
1443 | 1443 | break; |
1444 | 1444 | |
1445 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
1446 | - $reset_password_url = give_get_reset_password_url( Give()->donors->get_column( 'user_id', $tag_args['donor_id'] ) ); |
|
1445 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
1446 | + $reset_password_url = give_get_reset_password_url(Give()->donors->get_column('user_id', $tag_args['donor_id'])); |
|
1447 | 1447 | break; |
1448 | 1448 | } |
1449 | 1449 | |
1450 | - if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1450 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1451 | 1451 | // Generate link, if Email content type is html. |
1452 | 1452 | $reset_password_link = sprintf( |
1453 | 1453 | '<a href="%1$s" target="_blank">%2$s</a>', |
1454 | - esc_url( $reset_password_url ), |
|
1455 | - __( 'Reset your password »', 'give' ) |
|
1454 | + esc_url($reset_password_url), |
|
1455 | + __('Reset your password »', 'give') |
|
1456 | 1456 | ); |
1457 | 1457 | } else { |
1458 | 1458 | $reset_password_link = sprintf( |
1459 | 1459 | '%1$s: %2$s', |
1460 | - __( 'Reset your password', 'give' ), |
|
1461 | - esc_url( $reset_password_url ) |
|
1460 | + __('Reset your password', 'give'), |
|
1461 | + esc_url($reset_password_url) |
|
1462 | 1462 | ); |
1463 | 1463 | } |
1464 | 1464 | |
@@ -1487,21 +1487,21 @@ discard block |
||
1487 | 1487 | * |
1488 | 1488 | * @return mixed|string |
1489 | 1489 | */ |
1490 | -function give_get_reset_password_url( $user_id ) { |
|
1490 | +function give_get_reset_password_url($user_id) { |
|
1491 | 1491 | $reset_password_url = ''; |
1492 | 1492 | |
1493 | 1493 | // Proceed further only, if user_id exists. |
1494 | - if ( $user_id ) { |
|
1494 | + if ($user_id) { |
|
1495 | 1495 | |
1496 | 1496 | // Get User Object Details. |
1497 | - $user = get_user_by( 'ID', $user_id ); |
|
1497 | + $user = get_user_by('ID', $user_id); |
|
1498 | 1498 | |
1499 | 1499 | // Prepare Reset Password URL. |
1500 | 1500 | $reset_password_url = esc_url( |
1501 | 1501 | add_query_arg( |
1502 | 1502 | array( |
1503 | 1503 | 'action' => 'rp', |
1504 | - 'key' => get_password_reset_key( $user ), |
|
1504 | + 'key' => get_password_reset_key($user), |
|
1505 | 1505 | 'login' => $user->user_login, |
1506 | 1506 | ), wp_login_url() |
1507 | 1507 | ) |
@@ -1520,15 +1520,15 @@ discard block |
||
1520 | 1520 | */ |
1521 | 1521 | function give_email_admin_email() { |
1522 | 1522 | |
1523 | - $admin_email = give_get_option( 'contact_admin_email' ); |
|
1523 | + $admin_email = give_get_option('contact_admin_email'); |
|
1524 | 1524 | |
1525 | - if ( empty( $admin_email ) ) { |
|
1526 | - give_delete_option( 'contact_admin_email' ); |
|
1525 | + if (empty($admin_email)) { |
|
1526 | + give_delete_option('contact_admin_email'); |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | - return ( ! empty( $admin_email ) ) |
|
1529 | + return ( ! empty($admin_email)) |
|
1530 | 1530 | ? $admin_email |
1531 | - : get_bloginfo( 'admin_email' ); |
|
1531 | + : get_bloginfo('admin_email'); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | /** |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | * @return string |
1540 | 1540 | */ |
1541 | 1541 | function give_email_site_url() { |
1542 | - return get_bloginfo( 'url' ); |
|
1542 | + return get_bloginfo('url'); |
|
1543 | 1543 | } |
1544 | 1544 | |
1545 | 1545 | |
@@ -1551,10 +1551,10 @@ discard block |
||
1551 | 1551 | * @return string |
1552 | 1552 | */ |
1553 | 1553 | function give_email_offline_mailing_address() { |
1554 | - $offline_address = give_get_option( 'contact_offline_mailing_address' ); |
|
1554 | + $offline_address = give_get_option('contact_offline_mailing_address'); |
|
1555 | 1555 | |
1556 | - if ( false === $offline_address ) { |
|
1557 | - return sprintf( ' <em>%s</em></em><br> <em>111 Not A Real St.</em><br> <em>Anytown, CA 12345 </em><br>', get_bloginfo( 'sitename' ) ); |
|
1556 | + if (false === $offline_address) { |
|
1557 | + return sprintf(' <em>%s</em></em><br> <em>111 Not A Real St.</em><br> <em>Anytown, CA 12345 </em><br>', get_bloginfo('sitename')); |
|
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | return $offline_address; |
@@ -1572,97 +1572,97 @@ discard block |
||
1572 | 1572 | * |
1573 | 1573 | * @return mixed |
1574 | 1574 | */ |
1575 | -function __give_render_metadata_email_tag( $content, $tag_args ) { |
|
1576 | - preg_match_all( '/{meta_([A-z0-9\-\_\ ]+)}/s', $content, $matches ); |
|
1575 | +function __give_render_metadata_email_tag($content, $tag_args) { |
|
1576 | + preg_match_all('/{meta_([A-z0-9\-\_\ ]+)}/s', $content, $matches); |
|
1577 | 1577 | |
1578 | - if ( ! empty( $matches[0] ) ) { |
|
1578 | + if ( ! empty($matches[0])) { |
|
1579 | 1579 | $search = $replace = array(); |
1580 | - foreach ( $matches[0] as $index => $meta_tag ) { |
|
1581 | - if ( in_array( $meta_tag, $search ) ) { |
|
1580 | + foreach ($matches[0] as $index => $meta_tag) { |
|
1581 | + if (in_array($meta_tag, $search)) { |
|
1582 | 1582 | continue; |
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | $search[] = $meta_tag; |
1586 | 1586 | |
1587 | - $meta_tag = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag ); |
|
1588 | - $meta_tag_arr = array_map( 'trim', explode( ' ', $meta_tag, 2 ) ); |
|
1589 | - $meta_tag = current( $meta_tag_arr ); |
|
1587 | + $meta_tag = str_replace(array('{', 'meta_', '}'), '', $meta_tag); |
|
1588 | + $meta_tag_arr = array_map('trim', explode(' ', $meta_tag, 2)); |
|
1589 | + $meta_tag = current($meta_tag_arr); |
|
1590 | 1590 | |
1591 | - $meta_tag = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag ); |
|
1592 | - $type = current( explode( '_', $meta_tag, 2 ) ); |
|
1593 | - $meta_name = preg_replace( "/^{$type}_/", '', $meta_tag ); |
|
1591 | + $meta_tag = str_replace(array('{', 'meta_', '}'), '', $meta_tag); |
|
1592 | + $type = current(explode('_', $meta_tag, 2)); |
|
1593 | + $meta_name = preg_replace("/^{$type}_/", '', $meta_tag); |
|
1594 | 1594 | |
1595 | - switch ( $type ) { |
|
1595 | + switch ($type) { |
|
1596 | 1596 | case 'donation': |
1597 | 1597 | // Bailout. |
1598 | - if ( ! isset( $tag_args['payment_id'] ) ) { |
|
1598 | + if ( ! isset($tag_args['payment_id'])) { |
|
1599 | 1599 | $replace[] = ''; |
1600 | 1600 | continue; |
1601 | 1601 | } |
1602 | 1602 | |
1603 | - $meta_data = give_get_meta( absint( $tag_args['payment_id'] ), $meta_name, true, '' ); |
|
1603 | + $meta_data = give_get_meta(absint($tag_args['payment_id']), $meta_name, true, ''); |
|
1604 | 1604 | |
1605 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1605 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1606 | 1606 | $replace[] = $meta_data; |
1607 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1608 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1607 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1608 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1609 | 1609 | } |
1610 | 1610 | |
1611 | 1611 | break; |
1612 | 1612 | |
1613 | 1613 | case 'form': |
1614 | - $form_id = isset( $tag_args['form_id'] ) ? absint( $tag_args['form_id'] ) : 0; |
|
1614 | + $form_id = isset($tag_args['form_id']) ? absint($tag_args['form_id']) : 0; |
|
1615 | 1615 | |
1616 | 1616 | // Bailout. |
1617 | - if ( ! $form_id && isset( $tag_args['payment_id'] ) ) { |
|
1618 | - $form_id = give_get_payment_form_id( $tag_args['payment_id'] ); |
|
1617 | + if ( ! $form_id && isset($tag_args['payment_id'])) { |
|
1618 | + $form_id = give_get_payment_form_id($tag_args['payment_id']); |
|
1619 | 1619 | } |
1620 | 1620 | |
1621 | - $meta_data = give_get_meta( $form_id, $meta_name, true, '' ); |
|
1622 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1621 | + $meta_data = give_get_meta($form_id, $meta_name, true, ''); |
|
1622 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1623 | 1623 | $replace[] = $meta_data; |
1624 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1625 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1624 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1625 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1626 | 1626 | } |
1627 | 1627 | break; |
1628 | 1628 | |
1629 | 1629 | case 'donor': |
1630 | - $donor_id = isset( $tag_args['donor_id'] ) ? absint( $tag_args['donor_id'] ) : 0; |
|
1630 | + $donor_id = isset($tag_args['donor_id']) ? absint($tag_args['donor_id']) : 0; |
|
1631 | 1631 | |
1632 | 1632 | // Bailout. |
1633 | - if ( ! $donor_id ) { |
|
1634 | - if ( isset( $tag_args['payment_id'] ) ) { |
|
1635 | - $donor_id = give_get_payment_donor_id( $tag_args['payment_id'] ); |
|
1636 | - } elseif ( isset( $tag_args['user_id'] ) ) { |
|
1637 | - $donor_id = Give()->donors->get_column_by( 'id', 'user_id', $tag_args['user_id'] ); |
|
1633 | + if ( ! $donor_id) { |
|
1634 | + if (isset($tag_args['payment_id'])) { |
|
1635 | + $donor_id = give_get_payment_donor_id($tag_args['payment_id']); |
|
1636 | + } elseif (isset($tag_args['user_id'])) { |
|
1637 | + $donor_id = Give()->donors->get_column_by('id', 'user_id', $tag_args['user_id']); |
|
1638 | 1638 | } |
1639 | 1639 | } |
1640 | 1640 | |
1641 | - $meta_data = Give()->donor_meta->get_meta( $donor_id, $meta_name, true ); |
|
1641 | + $meta_data = Give()->donor_meta->get_meta($donor_id, $meta_name, true); |
|
1642 | 1642 | |
1643 | - if ( empty( $meta_data ) && in_array( $meta_name, array_keys( Give()->donors->get_columns() ) ) ) { |
|
1644 | - $meta_data = Give()->donors->get_column_by( $meta_name, 'id', $donor_id ); |
|
1643 | + if (empty($meta_data) && in_array($meta_name, array_keys(Give()->donors->get_columns()))) { |
|
1644 | + $meta_data = Give()->donors->get_column_by($meta_name, 'id', $donor_id); |
|
1645 | 1645 | } |
1646 | 1646 | |
1647 | - if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) { |
|
1647 | + if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) { |
|
1648 | 1648 | $replace[] = $meta_data; |
1649 | - } elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) { |
|
1650 | - $replace[] = $meta_data[ $meta_tag_arr[1] ]; |
|
1649 | + } elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) { |
|
1650 | + $replace[] = $meta_data[$meta_tag_arr[1]]; |
|
1651 | 1651 | } |
1652 | 1652 | |
1653 | 1653 | break; |
1654 | 1654 | |
1655 | 1655 | default: |
1656 | - $replace[] = end( $search ); |
|
1656 | + $replace[] = end($search); |
|
1657 | 1657 | } |
1658 | 1658 | } |
1659 | 1659 | |
1660 | - if ( ! empty( $search ) && ! empty( $replace ) ) { |
|
1661 | - $content = str_replace( $search, $replace, $content ); |
|
1660 | + if ( ! empty($search) && ! empty($replace)) { |
|
1661 | + $content = str_replace($search, $replace, $content); |
|
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | return $content; |
1666 | 1666 | } |
1667 | 1667 | |
1668 | -add_filter( 'give_email_template_tags', '__give_render_metadata_email_tag', 10, 2 ); |
|
1668 | +add_filter('give_email_template_tags', '__give_render_metadata_email_tag', 10, 2); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return static |
54 | 54 | */ |
55 | 55 | public static function get_instance() { |
56 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
56 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
57 | 57 | self::$instance = new Give_Cache(); |
58 | 58 | } |
59 | 59 | |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setup() { |
70 | 70 | // Currently enable cache only for backend. |
71 | - self::$instance->is_cache = ( defined( 'GIVE_CACHE' ) ? GIVE_CACHE : give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) ) && is_admin(); |
|
71 | + self::$instance->is_cache = (defined('GIVE_CACHE') ? GIVE_CACHE : give_is_setting_enabled(give_get_option('cache', 'enabled'))) && is_admin(); |
|
72 | 72 | |
73 | 73 | // weekly delete all expired cache. |
74 | - Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) ); |
|
74 | + Give_Cron::add_weekly_event(array($this, 'delete_all_expired')); |
|
75 | 75 | |
76 | - add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) ); |
|
77 | - add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) ); |
|
78 | - add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 ); |
|
79 | - add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 ); |
|
76 | + add_action('save_post_give_forms', array($this, 'delete_form_related_cache')); |
|
77 | + add_action('save_post_give_payment', array($this, 'delete_payment_related_cache')); |
|
78 | + add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3); |
|
79 | + add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3); |
|
80 | 80 | |
81 | - add_action( 'give_save_settings_give_settings', array( __CLASS__, 'flush_cache' ) ); |
|
81 | + add_action('give_save_settings_give_settings', array(__CLASS__, 'flush_cache')); |
|
82 | 82 | |
83 | - add_action( 'wp', array( __CLASS__, 'prevent_caching' ) ); |
|
84 | - add_action( 'admin_notices', array( $this, '__notices' ) ); |
|
83 | + add_action('wp', array(__CLASS__, 'prevent_caching')); |
|
84 | + add_action('admin_notices', array($this, '__notices')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @credit WooCommerce |
93 | 93 | */ |
94 | 94 | public static function prevent_caching() { |
95 | - if ( ! is_blog_installed() ) { |
|
95 | + if ( ! is_blog_installed()) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | - $page_ids = array_filter( array( |
|
100 | - give_get_option( 'success_page' ), |
|
101 | - give_get_option( 'failure_page' ), |
|
102 | - give_get_option( 'history_page' ), |
|
103 | - ) ); |
|
99 | + $page_ids = array_filter(array( |
|
100 | + give_get_option('success_page'), |
|
101 | + give_get_option('failure_page'), |
|
102 | + give_get_option('history_page'), |
|
103 | + )); |
|
104 | 104 | |
105 | 105 | if ( |
106 | - is_page( $page_ids ) |
|
107 | - || is_singular( 'give_forms' ) |
|
106 | + is_page($page_ids) |
|
107 | + || is_singular('give_forms') |
|
108 | 108 | ) { |
109 | 109 | self::set_nocache_constants(); |
110 | 110 | nocache_headers(); |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return mixed |
124 | 124 | */ |
125 | - public static function set_nocache_constants( $return = true ) { |
|
126 | - give_maybe_define_constant( 'DONOTCACHEPAGE', true ); |
|
127 | - give_maybe_define_constant( 'DONOTCACHEOBJECT', true ); |
|
128 | - give_maybe_define_constant( 'DONOTCACHEDB', true ); |
|
125 | + public static function set_nocache_constants($return = true) { |
|
126 | + give_maybe_define_constant('DONOTCACHEPAGE', true); |
|
127 | + give_maybe_define_constant('DONOTCACHEOBJECT', true); |
|
128 | + give_maybe_define_constant('DONOTCACHEDB', true); |
|
129 | 129 | |
130 | 130 | return $return; |
131 | 131 | } |
@@ -138,18 +138,18 @@ discard block |
||
138 | 138 | * @credit WooCommerce |
139 | 139 | */ |
140 | 140 | public function __notices() { |
141 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
141 | + if ( ! function_exists('w3tc_pgcache_flush') || ! function_exists('w3_instance')) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - $config = w3_instance( 'W3_Config' ); |
|
146 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
147 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
145 | + $config = w3_instance('W3_Config'); |
|
146 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
147 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
148 | 148 | |
149 | - if ( $enabled && ! in_array( 'give', $settings, true ) ) { |
|
149 | + if ($enabled && ! in_array('give', $settings, true)) { |
|
150 | 150 | ?> |
151 | 151 | <div class="error"> |
152 | - <p><?php echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored query stems" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give' ), '<code>give</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache#dbcache_reject_sql' ) ) ) ); ?></p> |
|
152 | + <p><?php echo wp_kses_post(sprintf(__('In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored query stems" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give'), '<code>give</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache#dbcache_reject_sql')))); ?></p> |
|
153 | 153 | </div> |
154 | 154 | <?php |
155 | 155 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public static function get_key( $action, $query_args = null, $is_prefix = true ) { |
|
169 | + public static function get_key($action, $query_args = null, $is_prefix = true) { |
|
170 | 170 | // Bailout. |
171 | - if ( empty( $action ) ) { |
|
172 | - return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) ); |
|
171 | + if (empty($action)) { |
|
172 | + return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give')); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // Set cache key. |
176 | 176 | $cache_key = $is_prefix ? "give_cache_{$action}" : $action; |
177 | 177 | |
178 | 178 | // Bailout. |
179 | - if ( ! empty( $query_args ) ) { |
|
180 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
179 | + if ( ! empty($query_args)) { |
|
180 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @since 2.0 |
187 | 187 | */ |
188 | - return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args ); |
|
188 | + return apply_filters('give_get_cache_key', $cache_key, $action, $query_args); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -199,28 +199,28 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return mixed |
201 | 201 | */ |
202 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
203 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
204 | - if( empty( $cache_key ) ) { |
|
205 | - return new WP_Error( 'give_empty_cache_key', __( 'Do not pass invalid empty cache key', 'give' ) ); |
|
206 | - }elseif ( ! $custom_key ) { |
|
207 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
202 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
203 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
204 | + if (empty($cache_key)) { |
|
205 | + return new WP_Error('give_empty_cache_key', __('Do not pass invalid empty cache key', 'give')); |
|
206 | + }elseif ( ! $custom_key) { |
|
207 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
208 | 208 | } |
209 | 209 | |
210 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
210 | + $cache_key = self::get_key($cache_key, $query_args); |
|
211 | 211 | } |
212 | 212 | |
213 | - $option = get_option( $cache_key ); |
|
213 | + $option = get_option($cache_key); |
|
214 | 214 | |
215 | 215 | // Backward compatibility (<1.8.7). |
216 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
216 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
217 | 217 | return $option; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Get current time. |
221 | - $current_time = current_time( 'timestamp', 1 ); |
|
221 | + $current_time = current_time('timestamp', 1); |
|
222 | 222 | |
223 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
223 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
224 | 224 | $option = $option['data']; |
225 | 225 | } else { |
226 | 226 | $option = false; |
@@ -242,23 +242,23 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return mixed |
244 | 244 | */ |
245 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
246 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
247 | - if ( ! $custom_key ) { |
|
248 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
245 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
246 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
247 | + if ( ! $custom_key) { |
|
248 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
249 | 249 | } |
250 | 250 | |
251 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
251 | + $cache_key = self::get_key($cache_key, $query_args); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | $option_value = array( |
255 | 255 | 'data' => $data, |
256 | - 'expiration' => ! is_null( $expiration ) |
|
257 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
256 | + 'expiration' => ! is_null($expiration) |
|
257 | + ? ($expiration + current_time('timestamp', 1)) |
|
258 | 258 | : null, |
259 | 259 | ); |
260 | 260 | |
261 | - $result = update_option( $cache_key, $option_value, false ); |
|
261 | + $result = update_option($cache_key, $option_value, false); |
|
262 | 262 | |
263 | 263 | return $result; |
264 | 264 | } |
@@ -274,27 +274,27 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return bool|WP_Error |
276 | 276 | */ |
277 | - public static function delete( $cache_keys ) { |
|
277 | + public static function delete($cache_keys) { |
|
278 | 278 | $result = true; |
279 | 279 | $invalid_keys = array(); |
280 | 280 | |
281 | - if ( ! empty( $cache_keys ) ) { |
|
282 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
281 | + if ( ! empty($cache_keys)) { |
|
282 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
283 | 283 | |
284 | - foreach ( $cache_keys as $cache_key ) { |
|
285 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
284 | + foreach ($cache_keys as $cache_key) { |
|
285 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
286 | 286 | $invalid_keys[] = $cache_key; |
287 | 287 | $result = false; |
288 | 288 | } |
289 | 289 | |
290 | - delete_option( $cache_key ); |
|
290 | + delete_option($cache_key); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | - if ( ! $result ) { |
|
294 | + if ( ! $result) { |
|
295 | 295 | $result = new WP_Error( |
296 | 296 | 'give_invalid_cache_key', |
297 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
297 | + __('Cache key format should be give_cache_*', 'give'), |
|
298 | 298 | $invalid_keys |
299 | 299 | ); |
300 | 300 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return bool |
317 | 317 | */ |
318 | - public static function delete_all_expired( $force = false ) { |
|
318 | + public static function delete_all_expired($force = false) { |
|
319 | 319 | global $wpdb; |
320 | 320 | $options = $wpdb->get_results( |
321 | 321 | $wpdb->prepare( |
@@ -329,30 +329,30 @@ discard block |
||
329 | 329 | ); |
330 | 330 | |
331 | 331 | // Bailout. |
332 | - if ( empty( $options ) ) { |
|
332 | + if (empty($options)) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | |
336 | - $current_time = current_time( 'timestamp', 1 ); |
|
336 | + $current_time = current_time('timestamp', 1); |
|
337 | 337 | |
338 | 338 | // Delete log cache. |
339 | - foreach ( $options as $option ) { |
|
340 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
339 | + foreach ($options as $option) { |
|
340 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
341 | 341 | |
342 | 342 | if ( |
343 | 343 | ( |
344 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
345 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
346 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
347 | - || empty( $option['option_value']['expiration'] ) |
|
348 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
344 | + ! self::is_valid_cache_key($option['option_name']) |
|
345 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
346 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
347 | + || empty($option['option_value']['expiration']) |
|
348 | + || ($current_time < $option['option_value']['expiration']) |
|
349 | 349 | ) |
350 | 350 | && ! $force |
351 | 351 | ) { |
352 | 352 | continue; |
353 | 353 | } |
354 | 354 | |
355 | - self::delete( $option['option_name'] ); |
|
355 | + self::delete($option['option_name']); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return array |
372 | 372 | */ |
373 | - public static function get_options_like( $option_name, $fields = false ) { |
|
373 | + public static function get_options_like($option_name, $fields = false) { |
|
374 | 374 | global $wpdb; |
375 | 375 | |
376 | 376 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
377 | 377 | |
378 | - if ( $fields ) { |
|
378 | + if ($fields) { |
|
379 | 379 | $options = $wpdb->get_results( |
380 | 380 | $wpdb->prepare( |
381 | 381 | "SELECT {$field_names } |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | ); |
400 | 400 | } |
401 | 401 | |
402 | - if ( ! empty( $options ) && $fields ) { |
|
403 | - foreach ( $options as $index => $option ) { |
|
404 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
405 | - $options[ $index ] = $option; |
|
402 | + if ( ! empty($options) && $fields) { |
|
403 | + foreach ($options as $index => $option) { |
|
404 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
405 | + $options[$index] = $option; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return bool |
421 | 421 | */ |
422 | - public static function is_valid_cache_key( $cache_key ) { |
|
423 | - $is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
422 | + public static function is_valid_cache_key($cache_key) { |
|
423 | + $is_valid = (false !== strpos($cache_key, 'give_cache_')); |
|
424 | 424 | |
425 | 425 | |
426 | 426 | /** |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @since 2.0 |
430 | 430 | */ |
431 | - return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key ); |
|
431 | + return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return mixed |
445 | 445 | */ |
446 | - public static function get_group( $id, $group = '' ) { |
|
446 | + public static function get_group($id, $group = '') { |
|
447 | 447 | $cached_data = null; |
448 | 448 | |
449 | 449 | // Bailout. |
450 | - if ( self::$instance->is_cache && ! empty( $id ) ) { |
|
451 | - $group = self::$instance->filter_group_name( $group ); |
|
450 | + if (self::$instance->is_cache && ! empty($id)) { |
|
451 | + $group = self::$instance->filter_group_name($group); |
|
452 | 452 | |
453 | - $cached_data = wp_cache_get( $id, $group ); |
|
453 | + $cached_data = wp_cache_get($id, $group); |
|
454 | 454 | $cached_data = false !== $cached_data ? $cached_data : null; |
455 | 455 | } |
456 | 456 | |
@@ -470,17 +470,17 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return bool |
472 | 472 | */ |
473 | - public static function set_group( $id, $data, $group = '', $expire = 0 ) { |
|
473 | + public static function set_group($id, $data, $group = '', $expire = 0) { |
|
474 | 474 | $status = false; |
475 | 475 | |
476 | 476 | // Bailout. |
477 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
477 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
478 | 478 | return $status; |
479 | 479 | } |
480 | 480 | |
481 | - $group = self::$instance->filter_group_name( $group ); |
|
481 | + $group = self::$instance->filter_group_name($group); |
|
482 | 482 | |
483 | - $status = wp_cache_set( $id, $data, $group, $expire ); |
|
483 | + $status = wp_cache_set($id, $data, $group, $expire); |
|
484 | 484 | |
485 | 485 | return $status; |
486 | 486 | } |
@@ -496,15 +496,15 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return bool |
498 | 498 | */ |
499 | - public static function set_db_query( $id, $data ) { |
|
499 | + public static function set_db_query($id, $data) { |
|
500 | 500 | $status = false; |
501 | 501 | |
502 | 502 | // Bailout. |
503 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
503 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
504 | 504 | return $status; |
505 | 505 | } |
506 | 506 | |
507 | - return self::set_group( $id, $data, 'give-db-queries', 0 ); |
|
507 | + return self::set_group($id, $data, 'give-db-queries', 0); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return mixed |
519 | 519 | */ |
520 | - public static function get_db_query( $id ) { |
|
521 | - return self::get_group( $id, 'give-db-queries' ); |
|
520 | + public static function get_db_query($id) { |
|
521 | + return self::get_group($id, 'give-db-queries'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -533,21 +533,21 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return bool |
535 | 535 | */ |
536 | - public static function delete_group( $ids, $group = '', $expire = 0 ) { |
|
536 | + public static function delete_group($ids, $group = '', $expire = 0) { |
|
537 | 537 | $status = false; |
538 | 538 | |
539 | 539 | // Bailout. |
540 | - if ( ! self::$instance->is_cache || empty( $ids ) ) { |
|
540 | + if ( ! self::$instance->is_cache || empty($ids)) { |
|
541 | 541 | return $status; |
542 | 542 | } |
543 | 543 | |
544 | 544 | $group_prefix = $group; |
545 | - $group = self::$instance->filter_group_name( $group ); |
|
545 | + $group = self::$instance->filter_group_name($group); |
|
546 | 546 | |
547 | 547 | // Delete single or multiple cache items from cache. |
548 | - if ( ! is_array( $ids ) ) { |
|
549 | - $status = wp_cache_delete( $ids, $group ); |
|
550 | - self::$instance->get_incrementer( true ); |
|
548 | + if ( ! is_array($ids)) { |
|
549 | + $status = wp_cache_delete($ids, $group); |
|
550 | + self::$instance->get_incrementer(true); |
|
551 | 551 | |
552 | 552 | /** |
553 | 553 | * Fire action when cache deleted for specific id. |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | * @param string $group |
559 | 559 | * @param int $expire |
560 | 560 | */ |
561 | - do_action( "give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status ); |
|
561 | + do_action("give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status); |
|
562 | 562 | |
563 | 563 | } else { |
564 | - foreach ( $ids as $id ) { |
|
565 | - $status = wp_cache_delete( $id, $group ); |
|
566 | - self::$instance->get_incrementer( true ); |
|
564 | + foreach ($ids as $id) { |
|
565 | + $status = wp_cache_delete($id, $group); |
|
566 | + self::$instance->get_incrementer(true); |
|
567 | 567 | |
568 | 568 | /** |
569 | 569 | * Fire action when cache deleted for specific id . |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * @param string $group |
575 | 575 | * @param int $expire |
576 | 576 | */ |
577 | - do_action( "give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status ); |
|
577 | + do_action("give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -591,15 +591,15 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @param int $form_id |
593 | 593 | */ |
594 | - public function delete_form_related_cache( $form_id ) { |
|
594 | + public function delete_form_related_cache($form_id) { |
|
595 | 595 | // If this is just a revision, don't send the email. |
596 | - if ( wp_is_post_revision( $form_id ) ) { |
|
596 | + if (wp_is_post_revision($form_id)) { |
|
597 | 597 | return; |
598 | 598 | } |
599 | 599 | |
600 | 600 | $donation_query = new Give_Payments_Query( |
601 | 601 | array( |
602 | - 'number' => - 1, |
|
602 | + 'number' => -1, |
|
603 | 603 | 'give_forms' => $form_id, |
604 | 604 | 'output' => '', |
605 | 605 | 'fields' => 'ids', |
@@ -608,15 +608,15 @@ discard block |
||
608 | 608 | |
609 | 609 | $donations = $donation_query->get_payments(); |
610 | 610 | |
611 | - if ( ! empty( $donations ) ) { |
|
611 | + if ( ! empty($donations)) { |
|
612 | 612 | /* @var Give_Payment $donation */ |
613 | - foreach ( $donations as $donation_id ) { |
|
614 | - wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) ); |
|
615 | - wp_cache_delete( give_get_payment_donor_id( $donation_id ), $this->filter_group_name( 'give-donors' ) ); |
|
613 | + foreach ($donations as $donation_id) { |
|
614 | + wp_cache_delete($donation_id, $this->filter_group_name('give-donations')); |
|
615 | + wp_cache_delete(give_get_payment_donor_id($donation_id), $this->filter_group_name('give-donors')); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
619 | - self::$instance->get_incrementer( true ); |
|
619 | + self::$instance->get_incrementer(true); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -628,19 +628,19 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @param int $donation_id |
630 | 630 | */ |
631 | - public function delete_payment_related_cache( $donation_id ) { |
|
631 | + public function delete_payment_related_cache($donation_id) { |
|
632 | 632 | // If this is just a revision, don't send the email. |
633 | - if ( wp_is_post_revision( $donation_id ) ) { |
|
633 | + if (wp_is_post_revision($donation_id)) { |
|
634 | 634 | return; |
635 | 635 | } |
636 | 636 | |
637 | - if ( $donation_id && ( $donor_id = give_get_payment_donor_id( $donation_id ) ) ) { |
|
638 | - wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
637 | + if ($donation_id && ($donor_id = give_get_payment_donor_id($donation_id))) { |
|
638 | + wp_cache_delete($donor_id, $this->filter_group_name('give-donors')); |
|
639 | 639 | } |
640 | 640 | |
641 | - wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) ); |
|
641 | + wp_cache_delete($donation_id, $this->filter_group_name('give-donations')); |
|
642 | 642 | |
643 | - self::$instance->get_incrementer( true ); |
|
643 | + self::$instance->get_incrementer(true); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
@@ -654,18 +654,18 @@ discard block |
||
654 | 654 | * @param string $group |
655 | 655 | * @param int $expire |
656 | 656 | */ |
657 | - public function delete_donor_related_cache( $id, $group, $expire ) { |
|
658 | - $donation_ids = Give()->donors->get_column( 'payment_ids', $id ); |
|
657 | + public function delete_donor_related_cache($id, $group, $expire) { |
|
658 | + $donation_ids = Give()->donors->get_column('payment_ids', $id); |
|
659 | 659 | |
660 | - if ( ! empty( $donation_ids ) ) { |
|
661 | - $donation_ids = array_map( 'trim', (array) explode( ',', trim( $donation_ids ) ) ); |
|
660 | + if ( ! empty($donation_ids)) { |
|
661 | + $donation_ids = array_map('trim', (array) explode(',', trim($donation_ids))); |
|
662 | 662 | |
663 | - foreach ( $donation_ids as $donation ) { |
|
664 | - wp_cache_delete( $donation, $this->filter_group_name( 'give-donations' ) ); |
|
663 | + foreach ($donation_ids as $donation) { |
|
664 | + wp_cache_delete($donation, $this->filter_group_name('give-donations')); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | - self::$instance->get_incrementer( true ); |
|
668 | + self::$instance->get_incrementer(true); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -679,12 +679,12 @@ discard block |
||
679 | 679 | * @param string $group |
680 | 680 | * @param int $expire |
681 | 681 | */ |
682 | - public function delete_donations_related_cache( $id, $group, $expire ) { |
|
683 | - if ( $id && ( $donor_id = give_get_payment_donor_id( $id ) ) ) { |
|
684 | - wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
682 | + public function delete_donations_related_cache($id, $group, $expire) { |
|
683 | + if ($id && ($donor_id = give_get_payment_donor_id($id))) { |
|
684 | + wp_cache_delete($donor_id, $this->filter_group_name('give-donors')); |
|
685 | 685 | } |
686 | 686 | |
687 | - self::$instance->get_incrementer( true ); |
|
687 | + self::$instance->get_incrementer(true); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -702,12 +702,12 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @return string |
704 | 704 | */ |
705 | - public function get_incrementer( $refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries' ) { |
|
706 | - $incrementer_value = wp_cache_get( $incrementer_key ); |
|
705 | + public function get_incrementer($refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries') { |
|
706 | + $incrementer_value = wp_cache_get($incrementer_key); |
|
707 | 707 | |
708 | - if ( false === $incrementer_value || true === $refresh ) { |
|
709 | - $incrementer_value = microtime( true ); |
|
710 | - wp_cache_set( $incrementer_key, $incrementer_value ); |
|
708 | + if (false === $incrementer_value || true === $refresh) { |
|
709 | + $incrementer_value = microtime(true); |
|
710 | + wp_cache_set($incrementer_key, $incrementer_value); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | return $incrementer_value; |
@@ -725,21 +725,21 @@ discard block |
||
725 | 725 | * |
726 | 726 | * @return bool |
727 | 727 | */ |
728 | - public static function flush_cache( $force = false ) { |
|
728 | + public static function flush_cache($force = false) { |
|
729 | 729 | if ( |
730 | 730 | $force |
731 | - || ( Give_Admin_Settings::is_saving_settings() && isset( $_POST['cache'] ) && give_is_setting_enabled( give_clean( $_POST['cache'] ) ) ) |
|
732 | - || ( wp_doing_ajax() && isset( $_GET['action'] ) && 'give_cache_flush' === give_clean( $_GET['action'] ) ) |
|
731 | + || (Give_Admin_Settings::is_saving_settings() && isset($_POST['cache']) && give_is_setting_enabled(give_clean($_POST['cache']))) |
|
732 | + || (wp_doing_ajax() && isset($_GET['action']) && 'give_cache_flush' === give_clean($_GET['action'])) |
|
733 | 733 | ) { |
734 | - self::$instance->get_incrementer( true ); |
|
735 | - self::$instance->get_incrementer( true, 'give-cache-incrementer' ); |
|
734 | + self::$instance->get_incrementer(true); |
|
735 | + self::$instance->get_incrementer(true, 'give-cache-incrementer'); |
|
736 | 736 | |
737 | 737 | /** |
738 | 738 | * Fire the action when all cache deleted. |
739 | 739 | * |
740 | 740 | * @since 2.1.0 |
741 | 741 | */ |
742 | - do_action( 'give_flushed_cache' ); |
|
742 | + do_action('give_flushed_cache'); |
|
743 | 743 | |
744 | 744 | return true; |
745 | 745 | } |
@@ -758,23 +758,23 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return mixed |
760 | 760 | */ |
761 | - private function filter_group_name( $group ) { |
|
761 | + private function filter_group_name($group) { |
|
762 | 762 | /** |
763 | 763 | * Filter the group name |
764 | 764 | * |
765 | 765 | * @since 2.1.0 |
766 | 766 | */ |
767 | - $filtered_group = apply_filters( 'give_cache_filter_group_name', '', $group ); |
|
767 | + $filtered_group = apply_filters('give_cache_filter_group_name', '', $group); |
|
768 | 768 | |
769 | - if ( empty( $filtered_group ) ) { |
|
769 | + if (empty($filtered_group)) { |
|
770 | 770 | |
771 | - switch ( $group ) { |
|
771 | + switch ($group) { |
|
772 | 772 | case 'give-db-queries': |
773 | 773 | $incrementer = self::$instance->get_incrementer(); |
774 | 774 | break; |
775 | 775 | |
776 | 776 | default: |
777 | - $incrementer = self::$instance->get_incrementer( false, 'give-cache-incrementer' ); |
|
777 | + $incrementer = self::$instance->get_incrementer(false, 'give-cache-incrementer'); |
|
778 | 778 | |
779 | 779 | } |
780 | 780 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $get_data = give_clean( $_GET ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
28 | + $get_data = give_clean($_GET); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
29 | 29 | |
30 | - $_get_action = ! empty( $get_data['give_action'] ) ? $get_data['give_action'] : null; |
|
30 | + $_get_action = ! empty($get_data['give_action']) ? $get_data['give_action'] : null; |
|
31 | 31 | |
32 | 32 | // Add backward compatibility to give-action param ( $_GET ). |
33 | - if ( empty( $_get_action ) ) { |
|
34 | - $_get_action = ! empty( $get_data['give-action'] ) ? $get_data['give-action'] : null; |
|
33 | + if (empty($_get_action)) { |
|
34 | + $_get_action = ! empty($get_data['give-action']) ? $get_data['give-action'] : null; |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_get_action ) ) { |
|
37 | + if (isset($_get_action)) { |
|
38 | 38 | /** |
39 | 39 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
40 | 40 | * |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param array $_GET Array of HTTP GET variables. |
44 | 44 | */ |
45 | - do_action( "give_{$_get_action}", $get_data ); |
|
45 | + do_action("give_{$_get_action}", $get_data); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | } |
49 | 49 | |
50 | -add_action( 'init', 'give_get_actions' ); |
|
50 | +add_action('init', 'give_get_actions'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function give_post_actions() { |
62 | 62 | |
63 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
63 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
64 | 64 | |
65 | - $_post_action = ! empty( $post_data['give_action'] ) ? $post_data['give_action'] : null; |
|
65 | + $_post_action = ! empty($post_data['give_action']) ? $post_data['give_action'] : null; |
|
66 | 66 | |
67 | 67 | // Add backward compatibility to give-action param ( $_POST ). |
68 | - if ( empty( $_post_action ) ) { |
|
69 | - $_post_action = ! empty( $post_data['give-action'] ) ? $post_data['give-action'] : null; |
|
68 | + if (empty($_post_action)) { |
|
69 | + $_post_action = ! empty($post_data['give-action']) ? $post_data['give-action'] : null; |
|
70 | 70 | } |
71 | 71 | |
72 | - if ( isset( $_post_action ) ) { |
|
72 | + if (isset($_post_action)) { |
|
73 | 73 | /** |
74 | 74 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
75 | 75 | * |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param array $_POST Array of HTTP POST variables. |
79 | 79 | */ |
80 | - do_action( "give_{$_post_action}", $post_data ); |
|
80 | + do_action("give_{$_post_action}", $post_data); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | -add_action( 'init', 'give_post_actions' ); |
|
85 | +add_action('init', 'give_post_actions'); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Connect WordPress user with Donor. |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return void |
96 | 96 | */ |
97 | -function give_connect_donor_to_wpuser( $user_id, $user_data ) { |
|
97 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
98 | 98 | /* @var Give_Donor $donor */ |
99 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
99 | + $donor = new Give_Donor($user_data['user_email']); |
|
100 | 100 | |
101 | 101 | // Validate donor id and check if do nor is already connect to wp user or not. |
102 | - if ( $donor->id && ! $donor->user_id ) { |
|
102 | + if ($donor->id && ! $donor->user_id) { |
|
103 | 103 | |
104 | 104 | // Update donor user_id. |
105 | - if ( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
106 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
107 | - $donor->add_note( $donor_note ); |
|
105 | + if ($donor->update(array('user_id' => $user_id))) { |
|
106 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
107 | + $donor->add_note($donor_note); |
|
108 | 108 | |
109 | 109 | // Update user_id meta in payments. |
110 | 110 | // if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
120 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
121 | 121 | |
122 | 122 | |
123 | 123 | /** |
@@ -127,19 +127,19 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @param $data |
129 | 129 | */ |
130 | -function give_donor_batch_export_complete( $data ) { |
|
130 | +function give_donor_batch_export_complete($data) { |
|
131 | 131 | // Remove donor ids cache. |
132 | 132 | if ( |
133 | - isset( $data['class'] ) |
|
133 | + isset($data['class']) |
|
134 | 134 | && 'Give_Batch_Donors_Export' === $data['class'] |
135 | - && ! empty( $data['forms'] ) |
|
136 | - && isset( $data['give_export_option']['query_id'] ) |
|
135 | + && ! empty($data['forms']) |
|
136 | + && isset($data['give_export_option']['query_id']) |
|
137 | 137 | ) { |
138 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
138 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
142 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Print css for wordpress setting pages. |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | /* @var WP_Screen $screen */ |
151 | 151 | $screen = get_current_screen(); |
152 | 152 | |
153 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
153 | + if ( ! ($screen instanceof WP_Screen)) { |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 | |
157 | - switch ( true ) { |
|
158 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
157 | + switch (true) { |
|
158 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
159 | 159 | ?> |
160 | 160 | <style> |
161 | 161 | tr.active.update + tr.give-addon-notice-tr td { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
195 | +add_action('admin_head', 'give_admin_quick_css'); |
|
196 | 196 | |
197 | 197 | |
198 | 198 | /** |
@@ -204,31 +204,31 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return void |
206 | 206 | */ |
207 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
207 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
208 | 208 | if ( |
209 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
210 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
211 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
209 | + ('set' === $_POST['_give_price_option']) || |
|
210 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
211 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
212 | 212 | ) { |
213 | 213 | // Delete old meta. |
214 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
215 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
214 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
215 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
216 | 216 | |
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Sanitize donation level amounts. |
221 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
221 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
222 | 222 | |
223 | - $min_amount = min( $donation_levels_amounts ); |
|
224 | - $max_amount = max( $donation_levels_amounts ); |
|
223 | + $min_amount = min($donation_levels_amounts); |
|
224 | + $max_amount = max($donation_levels_amounts); |
|
225 | 225 | |
226 | 226 | // Set Minimum and Maximum amount for Multi Level Donation Forms. |
227 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
228 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
227 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
228 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
229 | 229 | } |
230 | 230 | |
231 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
231 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
232 | 232 | |
233 | 233 | |
234 | 234 | /** |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param int $payment_id |
240 | 240 | */ |
241 | -function _give_save_donor_billing_address( $payment_id ) { |
|
242 | - $donor_id = absint( give_get_payment_donor_id( $payment_id )); |
|
241 | +function _give_save_donor_billing_address($payment_id) { |
|
242 | + $donor_id = absint(give_get_payment_donor_id($payment_id)); |
|
243 | 243 | |
244 | 244 | // Bailout |
245 | - if ( ! $donor_id ) { |
|
245 | + if ( ! $donor_id) { |
|
246 | 246 | return; |
247 | 247 | } |
248 | 248 | |
249 | 249 | |
250 | 250 | /* @var Give_Donor $donor */ |
251 | - $donor = new Give_Donor( $donor_id ); |
|
251 | + $donor = new Give_Donor($donor_id); |
|
252 | 252 | |
253 | 253 | // Save address. |
254 | - $donor->add_address( 'billing[]', give_get_donation_address( $payment_id ) ); |
|
254 | + $donor->add_address('billing[]', give_get_donation_address($payment_id)); |
|
255 | 255 | } |
256 | 256 | |
257 | -add_action( 'give_complete_donation', '_give_save_donor_billing_address', 9999 ); |
|
257 | +add_action('give_complete_donation', '_give_save_donor_billing_address', 9999); |
|
258 | 258 | |
259 | 259 | |
260 | 260 | /** |
@@ -264,26 +264,26 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @param array $args |
266 | 266 | */ |
267 | -function give_update_log_form_id( $args ) { |
|
268 | - $new_form_id = absint( $args[0] ); |
|
269 | - $payment_id = absint( $args[1] ); |
|
270 | - $logs = Give()->logs->get_logs( $payment_id ); |
|
267 | +function give_update_log_form_id($args) { |
|
268 | + $new_form_id = absint($args[0]); |
|
269 | + $payment_id = absint($args[1]); |
|
270 | + $logs = Give()->logs->get_logs($payment_id); |
|
271 | 271 | |
272 | 272 | // Bailout. |
273 | - if ( empty( $logs ) ) { |
|
273 | + if (empty($logs)) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | 277 | /* @var object $log */ |
278 | - foreach ( $logs as $log ) { |
|
279 | - Give()->logs->logmeta_db->update_meta( $log->ID, '_give_log_form_id', $new_form_id ); |
|
278 | + foreach ($logs as $log) { |
|
279 | + Give()->logs->logmeta_db->update_meta($log->ID, '_give_log_form_id', $new_form_id); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Delete cache. |
283 | 283 | Give()->logs->delete_cache(); |
284 | 284 | } |
285 | 285 | |
286 | -add_action( 'give_update_log_form_id', 'give_update_log_form_id' ); |
|
286 | +add_action('give_update_log_form_id', 'give_update_log_form_id'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Verify addon dependency before addon update |
@@ -295,25 +295,25 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return WP_Error |
297 | 297 | */ |
298 | -function __give_verify_addon_dependency_before_update( $error, $hook_extra ) { |
|
298 | +function __give_verify_addon_dependency_before_update($error, $hook_extra) { |
|
299 | 299 | // Bailout. |
300 | 300 | if ( |
301 | - is_wp_error( $error ) |
|
302 | - || ! array_key_exists( 'plugin', $hook_extra ) |
|
301 | + is_wp_error($error) |
|
302 | + || ! array_key_exists('plugin', $hook_extra) |
|
303 | 303 | ) { |
304 | 304 | return $error; |
305 | 305 | } |
306 | 306 | |
307 | - $plugin_base = strtolower( $hook_extra['plugin'] ); |
|
308 | - $licensed_addon = array_map( 'strtolower', Give_License::get_licensed_addons() ); |
|
307 | + $plugin_base = strtolower($hook_extra['plugin']); |
|
308 | + $licensed_addon = array_map('strtolower', Give_License::get_licensed_addons()); |
|
309 | 309 | |
310 | 310 | // Skip if not a Give addon. |
311 | - if ( ! in_array( $plugin_base, $licensed_addon ) ) { |
|
311 | + if ( ! in_array($plugin_base, $licensed_addon)) { |
|
312 | 312 | return $error; |
313 | 313 | } |
314 | 314 | |
315 | - $plugin_base = strtolower( $plugin_base ); |
|
316 | - $plugin_slug = str_replace( '.php', '', basename( $plugin_base ) ); |
|
315 | + $plugin_base = strtolower($plugin_base); |
|
316 | + $plugin_slug = str_replace('.php', '', basename($plugin_base)); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Filter the addon readme.txt url |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | $plugin_slug |
327 | 327 | ); |
328 | 328 | |
329 | - $parser = new Give_Readme_Parser( $url ); |
|
329 | + $parser = new Give_Readme_Parser($url); |
|
330 | 330 | $give_min_version = $parser->requires_at_least(); |
331 | 331 | |
332 | 332 | |
333 | - if ( version_compare( GIVE_VERSION, $give_min_version, '<' ) ) { |
|
333 | + if (version_compare(GIVE_VERSION, $give_min_version, '<')) { |
|
334 | 334 | return new WP_Error( |
335 | 335 | 'Give_Addon_Update_Error', |
336 | 336 | sprintf( |
337 | - __( 'Give version %s is required to update this add-on.', 'give' ), |
|
337 | + __('Give version %s is required to update this add-on.', 'give'), |
|
338 | 338 | $give_min_version |
339 | 339 | ) |
340 | 340 | ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | return $error; |
344 | 344 | } |
345 | 345 | |
346 | -add_filter( 'upgrader_pre_install', '__give_verify_addon_dependency_before_update', 10, 2 ); |
|
346 | +add_filter('upgrader_pre_install', '__give_verify_addon_dependency_before_update', 10, 2); |
|
347 | 347 | |
348 | 348 | /** |
349 | 349 | * Function to add suppress_filters param if WPML add-on is activated. |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return array WP query argument for Total Goal. |
356 | 356 | */ |
357 | -function __give_wpml_total_goal_shortcode_agrs( $args ) { |
|
357 | +function __give_wpml_total_goal_shortcode_agrs($args) { |
|
358 | 358 | $args['suppress_filters'] = true; |
359 | 359 | |
360 | 360 | return $args; |
@@ -389,19 +389,19 @@ discard block |
||
389 | 389 | * @since 2.1.4 |
390 | 390 | */ |
391 | 391 | function give_add_support_for_wpml() { |
392 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
393 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
392 | + if ( ! function_exists('is_plugin_active')) { |
|
393 | + include_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
397 | - if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { |
|
397 | + if (is_plugin_active('sitepress-multilingual-cms/sitepress.php')) { |
|
398 | 398 | |
399 | - add_filter( 'give_totals_goal_shortcode_query_args', '__give_wpml_total_goal_shortcode_agrs' ); |
|
399 | + add_filter('give_totals_goal_shortcode_query_args', '__give_wpml_total_goal_shortcode_agrs'); |
|
400 | 400 | |
401 | 401 | // @see https://wpml.org/forums/topic/problem-with-query-filter-in-get_posts-function/#post-271309 |
402 | - add_action( 'give_totals_goal_shortcode_before_render', '__give_remove_wpml_parse_query_filter', 99 ); |
|
403 | - add_action( 'give_totals_goal_shortcode_after_render', '__give_add_wpml_parse_query_filter', 99 ); |
|
402 | + add_action('give_totals_goal_shortcode_before_render', '__give_remove_wpml_parse_query_filter', 99); |
|
403 | + add_action('give_totals_goal_shortcode_after_render', '__give_add_wpml_parse_query_filter', 99); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | -add_action( 'give_init', 'give_add_support_for_wpml', 1000 ); |
|
407 | +add_action('give_init', 'give_add_support_for_wpml', 1000); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -26,31 +26,31 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_test_ajax_works() { |
28 | 28 | // Handle ajax. |
29 | - if ( doing_action( 'wp_ajax_nopriv_give_test_ajax' ) ) { |
|
30 | - wp_die( 0, 200 ); |
|
29 | + if (doing_action('wp_ajax_nopriv_give_test_ajax')) { |
|
30 | + wp_die(0, 200); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // Check if the Airplane Mode plugin is installed. |
34 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
34 | + if (class_exists('Airplane_Mode_Core')) { |
|
35 | 35 | |
36 | 36 | $airplane = Airplane_Mode_Core::getInstance(); |
37 | 37 | |
38 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
38 | + if (method_exists($airplane, 'enabled')) { |
|
39 | 39 | |
40 | - if ( $airplane->enabled() ) { |
|
40 | + if ($airplane->enabled()) { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } else { |
44 | 44 | |
45 | - if ( 'on' === $airplane->check_status() ) { |
|
45 | + if ('on' === $airplane->check_status()) { |
|
46 | 46 | return true; |
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - add_filter( 'block_local_requests', '__return_false' ); |
|
51 | + add_filter('block_local_requests', '__return_false'); |
|
52 | 52 | |
53 | - if ( Give_Cache::get( '_give_ajax_works', true ) ) { |
|
53 | + if (Give_Cache::get('_give_ajax_works', true)) { |
|
54 | 54 | return true; |
55 | 55 | } |
56 | 56 | |
@@ -62,41 +62,41 @@ discard block |
||
62 | 62 | ), |
63 | 63 | ); |
64 | 64 | |
65 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
65 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
66 | 66 | |
67 | 67 | $works = true; |
68 | 68 | |
69 | - if ( is_wp_error( $ajax ) ) { |
|
69 | + if (is_wp_error($ajax)) { |
|
70 | 70 | |
71 | 71 | $works = false; |
72 | 72 | |
73 | 73 | } else { |
74 | 74 | |
75 | - if ( empty( $ajax['response'] ) ) { |
|
75 | + if (empty($ajax['response'])) { |
|
76 | 76 | $works = false; |
77 | 77 | } |
78 | 78 | |
79 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
79 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
80 | 80 | $works = false; |
81 | 81 | } |
82 | 82 | |
83 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
83 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
84 | 84 | $works = false; |
85 | 85 | } |
86 | 86 | |
87 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
87 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
88 | 88 | $works = false; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - if ( $works ) { |
|
93 | - Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true ); |
|
92 | + if ($works) { |
|
93 | + Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true); |
|
94 | 94 | } |
95 | 95 | |
96 | - return apply_filters( 'give_test_ajax_works', $works ); |
|
96 | + return apply_filters('give_test_ajax_works', $works); |
|
97 | 97 | } |
98 | 98 | |
99 | -add_action( 'wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works' ); |
|
99 | +add_action('wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works'); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Get AJAX URL |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | -function give_get_ajax_url( $query = array() ) { |
|
111 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
110 | +function give_get_ajax_url($query = array()) { |
|
111 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
112 | 112 | |
113 | 113 | $current_url = give_get_current_page_url(); |
114 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
114 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
115 | 115 | |
116 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
117 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
116 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
117 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $query ) ) { |
|
121 | - $ajax_url = add_query_arg( $query, $ajax_url ); |
|
120 | + if ( ! empty($query)) { |
|
121 | + $ajax_url = add_query_arg($query, $ajax_url); |
|
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
124 | + return apply_filters('give_ajax_url', $ajax_url); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @since 1.7 |
139 | 139 | */ |
140 | - do_action( 'give_donation_form_login_fields' ); |
|
140 | + do_action('give_donation_form_login_fields'); |
|
141 | 141 | |
142 | 142 | give_die(); |
143 | 143 | } |
144 | 144 | |
145 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
145 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Load Checkout Fields |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | function give_load_checkout_fields() { |
155 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
155 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
156 | 156 | |
157 | 157 | ob_start(); |
158 | 158 | |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @since 1.7 |
163 | 163 | */ |
164 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
164 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
165 | 165 | |
166 | 166 | $fields = ob_get_clean(); |
167 | 167 | |
168 | - wp_send_json( array( |
|
169 | - 'fields' => wp_json_encode( $fields ), |
|
170 | - 'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ), |
|
171 | - ) ); |
|
168 | + wp_send_json(array( |
|
169 | + 'fields' => wp_json_encode($fields), |
|
170 | + 'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)), |
|
171 | + )); |
|
172 | 172 | } |
173 | 173 | |
174 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
175 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
174 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
175 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | function give_ajax_get_form_title() { |
185 | - if ( isset( $_POST['form_id'] ) ) { |
|
186 | - $title = get_the_title( $_POST['form_id'] ); |
|
187 | - if ( $title ) { |
|
185 | + if (isset($_POST['form_id'])) { |
|
186 | + $title = get_the_title($_POST['form_id']); |
|
187 | + if ($title) { |
|
188 | 188 | echo $title; |
189 | 189 | } else { |
190 | 190 | echo 'fail'; |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | give_die(); |
194 | 194 | } |
195 | 195 | |
196 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
197 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
196 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
197 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Retrieve a states drop down |
@@ -208,41 +208,41 @@ discard block |
||
208 | 208 | $show_field = true; |
209 | 209 | $states_require = true; |
210 | 210 | // Get the Country code from the $_POST. |
211 | - $country = sanitize_text_field( $_POST['country'] ); |
|
211 | + $country = sanitize_text_field($_POST['country']); |
|
212 | 212 | |
213 | 213 | // Get the field name from the $_POST. |
214 | - $field_name = sanitize_text_field( $_POST['field_name'] ); |
|
214 | + $field_name = sanitize_text_field($_POST['field_name']); |
|
215 | 215 | |
216 | - $label = __( 'State', 'give' ); |
|
216 | + $label = __('State', 'give'); |
|
217 | 217 | $states_label = give_get_states_label(); |
218 | 218 | |
219 | 219 | $default_state = ''; |
220 | - if ( $country === give_get_country() ) { |
|
220 | + if ($country === give_get_country()) { |
|
221 | 221 | $default_state = give_get_state(); |
222 | 222 | } |
223 | 223 | |
224 | 224 | // Check if $country code exists in the array key for states label. |
225 | - if ( array_key_exists( $country, $states_label ) ) { |
|
226 | - $label = $states_label[ $country ]; |
|
225 | + if (array_key_exists($country, $states_label)) { |
|
226 | + $label = $states_label[$country]; |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( empty( $country ) ) { |
|
229 | + if (empty($country)) { |
|
230 | 230 | $country = give_get_country(); |
231 | 231 | } |
232 | 232 | |
233 | - $states = give_get_states( $country ); |
|
234 | - if ( ! empty( $states ) ) { |
|
235 | - $args = array( |
|
233 | + $states = give_get_states($country); |
|
234 | + if ( ! empty($states)) { |
|
235 | + $args = array( |
|
236 | 236 | 'name' => $field_name, |
237 | 237 | 'id' => $field_name, |
238 | - 'class' => $field_name . ' give-select', |
|
238 | + 'class' => $field_name.' give-select', |
|
239 | 239 | 'options' => $states, |
240 | 240 | 'show_option_all' => false, |
241 | 241 | 'show_option_none' => false, |
242 | 242 | 'placeholder' => $label, |
243 | 243 | 'selected' => $default_state, |
244 | 244 | ); |
245 | - $data = Give()->html->select( $args ); |
|
245 | + $data = Give()->html->select($args); |
|
246 | 246 | $states_found = true; |
247 | 247 | } else { |
248 | 248 | $data = 'nostates'; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $no_states_country = give_no_states_country_list(); |
252 | 252 | |
253 | 253 | // Check if $country code exists in the array key. |
254 | - if ( array_key_exists( $country, $no_states_country ) ) { |
|
254 | + if (array_key_exists($country, $no_states_country)) { |
|
255 | 255 | $show_field = false; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $states_not_required_country_list = give_states_not_required_country_list(); |
260 | 260 | |
261 | 261 | // Check if $country code exists in the array key. |
262 | - if ( array_key_exists( $country, $states_not_required_country_list ) ) { |
|
262 | + if (array_key_exists($country, $states_not_required_country_list)) { |
|
263 | 263 | $states_require = false; |
264 | 264 | } |
265 | 265 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | 'data' => $data, |
273 | 273 | 'default_state' => $default_state, |
274 | 274 | ); |
275 | - wp_send_json( $response ); |
|
275 | + wp_send_json($response); |
|
276 | 276 | } |
277 | 277 | |
278 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
279 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
278 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
279 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Retrieve donation forms via AJAX for chosen dropdown search field. |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | function give_ajax_form_search() { |
289 | 289 | $results = array(); |
290 | - $search = esc_sql( sanitize_text_field( $_POST['s'] ) ); |
|
290 | + $search = esc_sql(sanitize_text_field($_POST['s'])); |
|
291 | 291 | |
292 | 292 | $args = array( |
293 | 293 | 'post_type' => 'give_forms', |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | 'post_status' => 'publish', |
300 | 300 | 'orderby' => 'title', |
301 | 301 | 'order' => 'ASC', |
302 | - 'posts_per_page' => empty( $search ) ? 30 : -1, |
|
302 | + 'posts_per_page' => empty($search) ? 30 : -1, |
|
303 | 303 | ); |
304 | 304 | |
305 | 305 | /** |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return array $args Query argument for WP_query |
313 | 313 | */ |
314 | - $args = (array) apply_filters( 'give_ajax_form_search_args', $args ); |
|
314 | + $args = (array) apply_filters('give_ajax_form_search_args', $args); |
|
315 | 315 | |
316 | 316 | // get all the donation form. |
317 | - $query = new WP_Query( $args ); |
|
318 | - if ( $query->have_posts() ) { |
|
319 | - while ( $query->have_posts() ) { |
|
317 | + $query = new WP_Query($args); |
|
318 | + if ($query->have_posts()) { |
|
319 | + while ($query->have_posts()) { |
|
320 | 320 | $query->the_post(); |
321 | 321 | global $post; |
322 | 322 | |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return array $results Contain the Donation Form id |
339 | 339 | */ |
340 | - $results = (array) apply_filters( 'give_ajax_form_search_responce', $results ); |
|
340 | + $results = (array) apply_filters('give_ajax_form_search_responce', $results); |
|
341 | 341 | |
342 | - wp_send_json( $results ); |
|
342 | + wp_send_json($results); |
|
343 | 343 | } |
344 | 344 | |
345 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
346 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
345 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
346 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
347 | 347 | |
348 | 348 | /** |
349 | 349 | * Search the donors database via Ajax |
@@ -355,28 +355,28 @@ discard block |
||
355 | 355 | function give_ajax_donor_search() { |
356 | 356 | global $wpdb; |
357 | 357 | |
358 | - $search = esc_sql( sanitize_text_field( $_POST['s'] ) ); |
|
358 | + $search = esc_sql(sanitize_text_field($_POST['s'])); |
|
359 | 359 | $results = array(); |
360 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
360 | + if ( ! current_user_can('view_give_reports')) { |
|
361 | 361 | $donors = array(); |
362 | 362 | } else { |
363 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
363 | + $donors = $wpdb->get_results("SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( $donors ) { |
|
367 | - foreach ( $donors as $donor ) { |
|
366 | + if ($donors) { |
|
367 | + foreach ($donors as $donor) { |
|
368 | 368 | |
369 | 369 | $results[] = array( |
370 | 370 | 'id' => $donor->id, |
371 | - 'name' => $donor->name . ' (' . $donor->email . ')', |
|
371 | + 'name' => $donor->name.' ('.$donor->email.')', |
|
372 | 372 | ); |
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - wp_send_json( $results ); |
|
376 | + wp_send_json($results); |
|
377 | 377 | } |
378 | 378 | |
379 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
379 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
380 | 380 | |
381 | 381 | |
382 | 382 | /** |
@@ -389,37 +389,37 @@ discard block |
||
389 | 389 | function give_ajax_search_users() { |
390 | 390 | $results = array(); |
391 | 391 | |
392 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
392 | + if (current_user_can('manage_give_settings')) { |
|
393 | 393 | |
394 | - $search = esc_sql( sanitize_text_field( $_POST['s'] ) ); |
|
394 | + $search = esc_sql(sanitize_text_field($_POST['s'])); |
|
395 | 395 | |
396 | 396 | $get_users_args = array( |
397 | 397 | 'number' => 9999, |
398 | - 'search' => $search . '*', |
|
398 | + 'search' => $search.'*', |
|
399 | 399 | ); |
400 | 400 | |
401 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
401 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
402 | 402 | |
403 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search ); |
|
403 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search); |
|
404 | 404 | $results = array(); |
405 | 405 | |
406 | - if ( $found_users ) { |
|
406 | + if ($found_users) { |
|
407 | 407 | |
408 | - foreach ( $found_users as $user ) { |
|
408 | + foreach ($found_users as $user) { |
|
409 | 409 | |
410 | 410 | $results[] = array( |
411 | 411 | 'id' => $user->ID, |
412 | - 'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ), |
|
412 | + 'name' => esc_html($user->user_login.' ('.$user->user_email.')'), |
|
413 | 413 | ); |
414 | 414 | } |
415 | 415 | } |
416 | 416 | }// End if(). |
417 | 417 | |
418 | - wp_send_json( $results ); |
|
418 | + wp_send_json($results); |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | |
422 | -add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' ); |
|
422 | +add_action('wp_ajax_give_user_search', 'give_ajax_search_users'); |
|
423 | 423 | |
424 | 424 | |
425 | 425 | /** |
@@ -435,14 +435,14 @@ discard block |
||
435 | 435 | $data = array(); |
436 | 436 | $args = array( |
437 | 437 | 'post_type' => 'page', |
438 | - 's' => give_clean( $_POST['s'] ), |
|
438 | + 's' => give_clean($_POST['s']), |
|
439 | 439 | ); |
440 | 440 | |
441 | - $query = new WP_Query( $args ); |
|
441 | + $query = new WP_Query($args); |
|
442 | 442 | |
443 | 443 | // Query posts by title. |
444 | - if ( $query->have_posts() ) { |
|
445 | - while ( $query->have_posts() ) { |
|
444 | + if ($query->have_posts()) { |
|
445 | + while ($query->have_posts()) { |
|
446 | 446 | $query->the_post(); |
447 | 447 | |
448 | 448 | $data[] = array( |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
455 | - wp_send_json( $data ); |
|
455 | + wp_send_json($data); |
|
456 | 456 | } |
457 | 457 | |
458 | -add_action( 'wp_ajax_give_pages_search', 'give_ajax_pages_search' ); |
|
458 | +add_action('wp_ajax_give_pages_search', 'give_ajax_pages_search'); |
|
459 | 459 | |
460 | 460 | /** |
461 | 461 | * Retrieve Categories via AJAX for chosen dropdown search field. |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return array $args argument for get_terms |
478 | 478 | */ |
479 | - $args = (array) apply_filters( 'give_forms_categories_dropdown_args', array( |
|
479 | + $args = (array) apply_filters('give_forms_categories_dropdown_args', array( |
|
480 | 480 | 'number' => 30, |
481 | - 'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) ) |
|
482 | - ) ); |
|
481 | + 'name__like' => esc_sql(sanitize_text_field($_POST['s'])) |
|
482 | + )); |
|
483 | 483 | |
484 | - $categories = get_terms( 'give_forms_category', $args ); |
|
484 | + $categories = get_terms('give_forms_category', $args); |
|
485 | 485 | |
486 | - foreach ( $categories as $category ) { |
|
486 | + foreach ($categories as $category) { |
|
487 | 487 | $results[] = array( |
488 | 488 | 'id' => $category->term_id, |
489 | 489 | 'name' => $category->name, |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return array $results Contain the categories id and name |
501 | 501 | */ |
502 | - $results = (array) apply_filters( 'give_forms_categories_dropdown_responce', $results ); |
|
502 | + $results = (array) apply_filters('give_forms_categories_dropdown_responce', $results); |
|
503 | 503 | |
504 | - wp_send_json( $results ); |
|
504 | + wp_send_json($results); |
|
505 | 505 | } |
506 | 506 | |
507 | -add_action( 'wp_ajax_give_categories_search', 'give_ajax_categories_search' ); |
|
507 | +add_action('wp_ajax_give_categories_search', 'give_ajax_categories_search'); |
|
508 | 508 | |
509 | 509 | /** |
510 | 510 | * Retrieve Tags via AJAX for chosen dropdown search field. |
@@ -525,14 +525,14 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return array $args argument for get_terms |
527 | 527 | */ |
528 | - $args = (array) apply_filters( 'give_forms_tags_dropdown_args', array( |
|
528 | + $args = (array) apply_filters('give_forms_tags_dropdown_args', array( |
|
529 | 529 | 'number' => 30, |
530 | - 'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) ) |
|
531 | - ) ); |
|
530 | + 'name__like' => esc_sql(sanitize_text_field($_POST['s'])) |
|
531 | + )); |
|
532 | 532 | |
533 | - $categories = get_terms( 'give_forms_tag', $args ); |
|
533 | + $categories = get_terms('give_forms_tag', $args); |
|
534 | 534 | |
535 | - foreach ( $categories as $category ) { |
|
535 | + foreach ($categories as $category) { |
|
536 | 536 | $results[] = array( |
537 | 537 | 'id' => $category->term_id, |
538 | 538 | 'name' => $category->name, |
@@ -548,12 +548,12 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @return array $results Contain the tags id and name |
550 | 550 | */ |
551 | - $results = (array) apply_filters( 'give_forms_tags_dropdown_responce', $results ); |
|
551 | + $results = (array) apply_filters('give_forms_tags_dropdown_responce', $results); |
|
552 | 552 | |
553 | - wp_send_json( $results ); |
|
553 | + wp_send_json($results); |
|
554 | 554 | } |
555 | 555 | |
556 | -add_action( 'wp_ajax_give_tags_search', 'give_ajax_tags_search' ); |
|
556 | +add_action('wp_ajax_give_tags_search', 'give_ajax_tags_search'); |
|
557 | 557 | |
558 | 558 | /** |
559 | 559 | * Check for Price Variations (Multi-level donation forms) |
@@ -564,32 +564,32 @@ discard block |
||
564 | 564 | */ |
565 | 565 | function give_check_for_form_price_variations() { |
566 | 566 | |
567 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
568 | - die( '-1' ); |
|
567 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
568 | + die('-1'); |
|
569 | 569 | } |
570 | 570 | |
571 | - $form_id = intval( $_POST['form_id'] ); |
|
572 | - $form = get_post( $form_id ); |
|
571 | + $form_id = intval($_POST['form_id']); |
|
572 | + $form = get_post($form_id); |
|
573 | 573 | |
574 | - if ( 'give_forms' !== $form->post_type ) { |
|
575 | - die( '-2' ); |
|
574 | + if ('give_forms' !== $form->post_type) { |
|
575 | + die('-2'); |
|
576 | 576 | } |
577 | 577 | |
578 | - if ( give_has_variable_prices( $form_id ) ) { |
|
579 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
578 | + if (give_has_variable_prices($form_id)) { |
|
579 | + $variable_prices = give_get_variable_prices($form_id); |
|
580 | 580 | |
581 | - if ( $variable_prices ) { |
|
581 | + if ($variable_prices) { |
|
582 | 582 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
583 | 583 | |
584 | - if ( isset( $_POST['all_prices'] ) ) { |
|
585 | - $ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
584 | + if (isset($_POST['all_prices'])) { |
|
585 | + $ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>'; |
|
586 | 586 | } |
587 | 587 | |
588 | - foreach ( $variable_prices as $key => $price ) { |
|
588 | + foreach ($variable_prices as $key => $price) { |
|
589 | 589 | |
590 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
590 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))); |
|
591 | 591 | |
592 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
592 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
593 | 593 | } |
594 | 594 | $ajax_response .= '</select>'; |
595 | 595 | echo $ajax_response; |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | give_die(); |
600 | 600 | } |
601 | 601 | |
602 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
602 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
603 | 603 | |
604 | 604 | |
605 | 605 | /** |
@@ -610,28 +610,28 @@ discard block |
||
610 | 610 | * @return void |
611 | 611 | */ |
612 | 612 | function give_check_for_form_price_variations_html() { |
613 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
613 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
614 | 614 | wp_die(); |
615 | 615 | } |
616 | 616 | |
617 | - $form_id = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false; |
|
618 | - $payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false; |
|
619 | - if ( empty( $form_id ) || empty( $payment_id ) ) { |
|
617 | + $form_id = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false; |
|
618 | + $payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false; |
|
619 | + if (empty($form_id) || empty($payment_id)) { |
|
620 | 620 | wp_die(); |
621 | 621 | } |
622 | 622 | |
623 | - $form = get_post( $form_id ); |
|
624 | - if ( ! empty( $form->post_type ) && 'give_forms' !== $form->post_type ) { |
|
623 | + $form = get_post($form_id); |
|
624 | + if ( ! empty($form->post_type) && 'give_forms' !== $form->post_type) { |
|
625 | 625 | wp_die(); |
626 | 626 | } |
627 | 627 | |
628 | - if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) { |
|
629 | - esc_html_e( 'n/a', 'give' ); |
|
628 | + if ( ! give_has_variable_prices($form_id) || ! $form_id) { |
|
629 | + esc_html_e('n/a', 'give'); |
|
630 | 630 | } else { |
631 | 631 | $prices_atts = array(); |
632 | - if ( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
633 | - foreach ( $variable_prices as $variable_price ) { |
|
634 | - $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ); |
|
632 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
633 | + foreach ($variable_prices as $variable_price) { |
|
634 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false)); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
@@ -642,12 +642,12 @@ discard block |
||
642 | 642 | 'chosen' => true, |
643 | 643 | 'show_option_all' => '', |
644 | 644 | 'show_option_none' => '', |
645 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
645 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
646 | 646 | ); |
647 | 647 | |
648 | - if ( $payment_id ) { |
|
648 | + if ($payment_id) { |
|
649 | 649 | // Payment object. |
650 | - $payment = new Give_Payment( $payment_id ); |
|
650 | + $payment = new Give_Payment($payment_id); |
|
651 | 651 | |
652 | 652 | // Payment meta. |
653 | 653 | $payment_meta = $payment->get_meta(); |
@@ -655,13 +655,13 @@ discard block |
||
655 | 655 | } |
656 | 656 | |
657 | 657 | // Render variable prices select tag html. |
658 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
658 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | give_die(); |
662 | 662 | } |
663 | 663 | |
664 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
664 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
|
665 | 665 | |
666 | 666 | /** |
667 | 667 | * Send Confirmation Email For Complete Donation History Access. |
@@ -673,30 +673,30 @@ discard block |
||
673 | 673 | function give_confirm_email_for_donation_access() { |
674 | 674 | |
675 | 675 | // Verify Security using Nonce. |
676 | - if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) { |
|
676 | + if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) { |
|
677 | 677 | return false; |
678 | 678 | } |
679 | 679 | |
680 | 680 | // Bail Out, if email is empty. |
681 | - if ( empty( $_POST['email'] ) ) { |
|
681 | + if (empty($_POST['email'])) { |
|
682 | 682 | return false; |
683 | 683 | } |
684 | 684 | |
685 | - $donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) ); |
|
686 | - if ( Give()->email_access->can_send_email( $donor->id ) ) { |
|
685 | + $donor = Give()->donors->get_donor_by('email', give_clean($_POST['email'])); |
|
686 | + if (Give()->email_access->can_send_email($donor->id)) { |
|
687 | 687 | $return = array(); |
688 | - $email_sent = Give()->email_access->send_email( $donor->id, $donor->email ); |
|
688 | + $email_sent = Give()->email_access->send_email($donor->id, $donor->email); |
|
689 | 689 | |
690 | - if ( ! $email_sent ) { |
|
690 | + if ( ! $email_sent) { |
|
691 | 691 | $return['status'] = 'error'; |
692 | 692 | $return['message'] = Give()->notices->print_frontend_notice( |
693 | - __( 'Unable to send email. Please try again.', 'give' ), |
|
693 | + __('Unable to send email. Please try again.', 'give'), |
|
694 | 694 | false, |
695 | 695 | 'error' |
696 | 696 | ); |
697 | 697 | } |
698 | 698 | |
699 | - $return['status'] = 'success'; |
|
699 | + $return['status'] = 'success'; |
|
700 | 700 | |
701 | 701 | /** |
702 | 702 | * Filter to modify access mail send notice |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * |
708 | 708 | * @return string $message Send notice message for email access. |
709 | 709 | */ |
710 | - $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) ); |
|
710 | + $message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give')); |
|
711 | 711 | |
712 | 712 | $return['message'] = Give()->notices->print_frontend_notice( |
713 | 713 | $message, |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | $message = (string) apply_filters( |
734 | 734 | 'give_email_access_requests_exceed_notice', |
735 | 735 | sprintf( |
736 | - __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
|
737 | - sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
|
736 | + __('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'), |
|
737 | + sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value) |
|
738 | 738 | ), |
739 | 739 | $value |
740 | 740 | ); |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | ); |
747 | 747 | } |
748 | 748 | |
749 | - echo json_encode( $return ); |
|
749 | + echo json_encode($return); |
|
750 | 750 | give_die(); |
751 | 751 | } |
752 | 752 | |
753 | -add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' ); |
|
753 | +add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access'); |
|
754 | 754 | |
755 | 755 | /** |
756 | 756 | * Render receipt by ajax |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @since 2.2.0 |
760 | 760 | */ |
761 | -function __give_get_receipt(){ |
|
762 | - if( ! isset( $_GET['shortcode_atts'] ) ) { |
|
761 | +function __give_get_receipt() { |
|
762 | + if ( ! isset($_GET['shortcode_atts'])) { |
|
763 | 763 | give_die(); |
764 | 764 | } |
765 | 765 | |
766 | - $atts = urldecode_deep( give_clean( $_GET['shortcode_atts'] ) ); |
|
767 | - $data = give_receipt_shortcode( $atts ); |
|
766 | + $atts = urldecode_deep(give_clean($_GET['shortcode_atts'])); |
|
767 | + $data = give_receipt_shortcode($atts); |
|
768 | 768 | |
769 | - wp_send_json( $data ); |
|
769 | + wp_send_json($data); |
|
770 | 770 | } |
771 | -add_action( 'wp_ajax_get_receipt', '__give_get_receipt' ); |
|
772 | -add_action( 'wp_ajax_nopriv_get_receipt', '__give_get_receipt' ); |
|
771 | +add_action('wp_ajax_get_receipt', '__give_get_receipt'); |
|
772 | +add_action('wp_ajax_nopriv_get_receipt', '__give_get_receipt'); |
@@ -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 | |
@@ -26,42 +26,42 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string|bool |
28 | 28 | */ |
29 | -function give_donation_history( $atts, $content = false ) { |
|
29 | +function give_donation_history($atts, $content = false) { |
|
30 | 30 | |
31 | - $donation_history_args = shortcode_atts( array( |
|
31 | + $donation_history_args = shortcode_atts(array( |
|
32 | 32 | 'id' => true, |
33 | 33 | 'date' => true, |
34 | 34 | 'donor' => false, |
35 | 35 | 'amount' => true, |
36 | 36 | 'status' => false, |
37 | 37 | 'payment_method' => false, |
38 | - ), $atts, 'donation_history' ); |
|
38 | + ), $atts, 'donation_history'); |
|
39 | 39 | |
40 | 40 | // Always show receipt link. |
41 | 41 | $donation_history_args['details'] = true; |
42 | 42 | |
43 | 43 | // Set Donation History Shortcode Arguments in session variable. |
44 | - Give()->session->set( 'give_donation_history_args', $donation_history_args ); |
|
44 | + Give()->session->set('give_donation_history_args', $donation_history_args); |
|
45 | 45 | |
46 | 46 | // If payment_key query arg exists, return receipt instead of donation history. |
47 | - if ( isset( $_GET['payment_key'] ) ) { |
|
47 | + if (isset($_GET['payment_key'])) { |
|
48 | 48 | ob_start(); |
49 | 49 | |
50 | - echo give_receipt_shortcode( array() ); |
|
50 | + echo give_receipt_shortcode(array()); |
|
51 | 51 | |
52 | 52 | // Display donation history link only if Receipt Access Session is available. |
53 | - if ( give_get_receipt_session() ) { |
|
53 | + if (give_get_receipt_session()) { |
|
54 | 54 | echo sprintf( |
55 | 55 | '<a href="%s">%s</a>', |
56 | - esc_url( give_get_history_page_uri() ), |
|
57 | - __( '« Return to All Donations', 'give' ) |
|
56 | + esc_url(give_get_history_page_uri()), |
|
57 | + __('« Return to All Donations', 'give') |
|
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
61 | 61 | return ob_get_clean(); |
62 | 62 | } |
63 | 63 | |
64 | - $email_access = give_get_option( 'email_access' ); |
|
64 | + $email_access = give_get_option('email_access'); |
|
65 | 65 | |
66 | 66 | ob_start(); |
67 | 67 | |
@@ -74,23 +74,23 @@ discard block |
||
74 | 74 | if ( |
75 | 75 | is_user_logged_in() |
76 | 76 | || false !== Give()->session->get_session_expiration() |
77 | - || ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) |
|
77 | + || (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) |
|
78 | 78 | || true === give_get_history_session() |
79 | 79 | ) { |
80 | - give_get_template_part( 'history', 'donations' ); |
|
80 | + give_get_template_part('history', 'donations'); |
|
81 | 81 | |
82 | - if ( ! empty( $content ) ) { |
|
83 | - echo do_shortcode( $content ); |
|
82 | + if ( ! empty($content)) { |
|
83 | + echo do_shortcode($content); |
|
84 | 84 | } |
85 | 85 | |
86 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
86 | + } elseif (give_is_setting_enabled($email_access)) { |
|
87 | 87 | // Is Email-based access enabled? |
88 | - give_get_template_part( 'email', 'login-form' ); |
|
88 | + give_get_template_part('email', 'login-form'); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - echo apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) ); |
|
93 | - echo do_shortcode( '[give_login]' ); |
|
92 | + echo apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false)); |
|
93 | + echo do_shortcode('[give_login]'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return string HTML content |
106 | 106 | */ |
107 | - return apply_filters( 'give_donation_history_shortcode_html', ob_get_clean(), $atts, $content ); |
|
107 | + return apply_filters('give_donation_history_shortcode_html', ob_get_clean(), $atts, $content); |
|
108 | 108 | } |
109 | 109 | |
110 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
110 | +add_shortcode('donation_history', 'give_donation_history'); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Donation Form Shortcode |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function give_form_shortcode( $atts ) { |
|
124 | - $atts = shortcode_atts( array( |
|
123 | +function give_form_shortcode($atts) { |
|
124 | + $atts = shortcode_atts(array( |
|
125 | 125 | 'id' => '', |
126 | 126 | 'show_title' => true, |
127 | 127 | 'show_goal' => true, |
@@ -129,21 +129,21 @@ discard block |
||
129 | 129 | 'float_labels' => '', |
130 | 130 | 'display_style' => '', |
131 | 131 | 'continue_button_title' => '', |
132 | - ), $atts, 'give_form' ); |
|
132 | + ), $atts, 'give_form'); |
|
133 | 133 | |
134 | 134 | // Convert string to bool. |
135 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
136 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
135 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
136 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
137 | 137 | |
138 | 138 | // get the Give Form |
139 | 139 | ob_start(); |
140 | - give_get_donation_form( $atts ); |
|
140 | + give_get_donation_form($atts); |
|
141 | 141 | $final_output = ob_get_clean(); |
142 | 142 | |
143 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
143 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
144 | 144 | } |
145 | 145 | |
146 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
146 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Donation Form Goal Shortcode. |
@@ -156,36 +156,36 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return string |
158 | 158 | */ |
159 | -function give_goal_shortcode( $atts ) { |
|
160 | - $atts = shortcode_atts( array( |
|
159 | +function give_goal_shortcode($atts) { |
|
160 | + $atts = shortcode_atts(array( |
|
161 | 161 | 'id' => '', |
162 | 162 | 'show_text' => true, |
163 | 163 | 'show_bar' => true, |
164 | - ), $atts, 'give_goal' ); |
|
164 | + ), $atts, 'give_goal'); |
|
165 | 165 | |
166 | 166 | // get the Give Form. |
167 | 167 | ob_start(); |
168 | 168 | |
169 | 169 | // Sanity check 1: ensure there is an ID Provided. |
170 | - if ( empty( $atts['id'] ) ) { |
|
171 | - Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
170 | + if (empty($atts['id'])) { |
|
171 | + Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Sanity check 2: Check the form even has Goals enabled. |
175 | - if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
175 | + if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) { |
|
176 | 176 | |
177 | - Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true ); |
|
177 | + Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true); |
|
178 | 178 | } else { |
179 | 179 | // Passed all sanity checks: output Goal. |
180 | - give_show_goal_progress( $atts['id'], $atts ); |
|
180 | + give_show_goal_progress($atts['id'], $atts); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $final_output = ob_get_clean(); |
184 | 184 | |
185 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
185 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
186 | 186 | } |
187 | 187 | |
188 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
188 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
189 | 189 | |
190 | 190 | |
191 | 191 | /** |
@@ -202,22 +202,22 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string |
204 | 204 | */ |
205 | -function give_login_form_shortcode( $atts ) { |
|
205 | +function give_login_form_shortcode($atts) { |
|
206 | 206 | |
207 | - $atts = shortcode_atts( array( |
|
207 | + $atts = shortcode_atts(array( |
|
208 | 208 | // Add backward compatibility for redirect attribute. |
209 | 209 | 'redirect' => '', |
210 | 210 | 'login-redirect' => '', |
211 | 211 | 'logout-redirect' => '', |
212 | - ), $atts, 'give_login' ); |
|
212 | + ), $atts, 'give_login'); |
|
213 | 213 | |
214 | 214 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
215 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
215 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
216 | 216 | |
217 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
217 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
218 | 218 | } |
219 | 219 | |
220 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
220 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Register Shortcode. |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_register_form_shortcode( $atts ) { |
|
236 | - $atts = shortcode_atts( array( |
|
235 | +function give_register_form_shortcode($atts) { |
|
236 | + $atts = shortcode_atts(array( |
|
237 | 237 | 'redirect' => '', |
238 | - ), $atts, 'give_register' ); |
|
238 | + ), $atts, 'give_register'); |
|
239 | 239 | |
240 | - return give_register_form( $atts['redirect'] ); |
|
240 | + return give_register_form($atts['redirect']); |
|
241 | 241 | } |
242 | 242 | |
243 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
243 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Receipt Shortcode. |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string |
255 | 255 | */ |
256 | -function give_receipt_shortcode( $atts ) { |
|
256 | +function give_receipt_shortcode($atts) { |
|
257 | 257 | |
258 | 258 | global $give_receipt_args; |
259 | 259 | $payment_key = ''; |
260 | 260 | |
261 | - $give_receipt_args = shortcode_atts( array( |
|
262 | - 'error' => __( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
261 | + $give_receipt_args = shortcode_atts(array( |
|
262 | + 'error' => __('You are missing the payment key to view this donation receipt.', 'give'), |
|
263 | 263 | 'price' => true, |
264 | 264 | 'donor' => true, |
265 | 265 | 'date' => true, |
@@ -269,62 +269,62 @@ discard block |
||
269 | 269 | 'payment_status' => false, |
270 | 270 | 'company_name' => false, |
271 | 271 | 'status_notice' => true, |
272 | - ), $atts, 'give_receipt' ); |
|
272 | + ), $atts, 'give_receipt'); |
|
273 | 273 | |
274 | 274 | // set $session var |
275 | 275 | $session = give_get_purchase_session(); |
276 | 276 | |
277 | 277 | // set payment key var |
278 | - if ( isset( $_GET['payment_key'] ) ) { |
|
279 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
280 | - } elseif ( $session ) { |
|
278 | + if (isset($_GET['payment_key'])) { |
|
279 | + $payment_key = urldecode($_GET['payment_key']); |
|
280 | + } elseif ($session) { |
|
281 | 281 | $payment_key = $session['purchase_key']; |
282 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
282 | + } elseif ($give_receipt_args['payment_key']) { |
|
283 | 283 | $payment_key = $give_receipt_args['payment_key']; |
284 | 284 | } |
285 | 285 | |
286 | - if( ! wp_doing_ajax() ) { |
|
286 | + if ( ! wp_doing_ajax()) { |
|
287 | 287 | ob_start(); |
288 | - give_get_template_part( 'receipt/placeholder' ); |
|
288 | + give_get_template_part('receipt/placeholder'); |
|
289 | 289 | $placeholder = ob_get_clean(); |
290 | 290 | |
291 | 291 | return sprintf( |
292 | 292 | '<div id="give-receipt" data-shortcode="%s" data-donation-key="%s">%s</div>', |
293 | - urlencode_deep( wp_json_encode( $atts ) ), |
|
293 | + urlencode_deep(wp_json_encode($atts)), |
|
294 | 294 | $payment_key, |
295 | 295 | $placeholder |
296 | 296 | ); |
297 | 297 | } |
298 | 298 | |
299 | - $email_access = give_get_option( 'email_access' ); |
|
299 | + $email_access = give_get_option('email_access'); |
|
300 | 300 | |
301 | 301 | // No payment_key found & Email Access is Turned on. |
302 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
302 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
303 | 303 | |
304 | 304 | ob_start(); |
305 | 305 | |
306 | - give_get_template_part( 'email-login-form' ); |
|
306 | + give_get_template_part('email-login-form'); |
|
307 | 307 | |
308 | 308 | return ob_get_clean(); |
309 | 309 | |
310 | - } elseif ( ! isset( $payment_key ) ) { |
|
310 | + } elseif ( ! isset($payment_key)) { |
|
311 | 311 | |
312 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
312 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
313 | 313 | |
314 | 314 | } |
315 | 315 | |
316 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
316 | + $user_can_view = give_can_view_receipt($payment_key); |
|
317 | 317 | |
318 | 318 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
319 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
319 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
320 | 320 | |
321 | 321 | ob_start(); |
322 | 322 | |
323 | - give_get_template_part( 'email-login-form' ); |
|
323 | + give_get_template_part('email-login-form'); |
|
324 | 324 | |
325 | 325 | return ob_get_clean(); |
326 | 326 | |
327 | - } elseif ( ! $user_can_view ) { |
|
327 | + } elseif ( ! $user_can_view) { |
|
328 | 328 | |
329 | 329 | global $give_login_redirect; |
330 | 330 | |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | |
333 | 333 | ob_start(); |
334 | 334 | |
335 | - Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
335 | + Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give'))); |
|
336 | 336 | |
337 | - give_get_template_part( 'shortcode', 'login' ); |
|
337 | + give_get_template_part('shortcode', 'login'); |
|
338 | 338 | |
339 | 339 | $login_form = ob_get_clean(); |
340 | 340 | |
@@ -348,20 +348,20 @@ discard block |
||
348 | 348 | * or if user is logged out and donation was made as a guest, the donation session is checked for |
349 | 349 | * or if user is logged in and the user can view sensitive shop data. |
350 | 350 | */ |
351 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
352 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
351 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
352 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | ob_start(); |
356 | 356 | |
357 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
357 | + give_get_template_part('shortcode', 'receipt'); |
|
358 | 358 | |
359 | 359 | $display = ob_get_clean(); |
360 | 360 | |
361 | 361 | return $display; |
362 | 362 | } |
363 | 363 | |
364 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
364 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
365 | 365 | |
366 | 366 | /** |
367 | 367 | * Profile Editor Shortcode. |
@@ -380,26 +380,26 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return string Output generated from the profile editor |
382 | 382 | */ |
383 | -function give_profile_editor_shortcode( $atts ) { |
|
383 | +function give_profile_editor_shortcode($atts) { |
|
384 | 384 | |
385 | 385 | ob_start(); |
386 | 386 | |
387 | 387 | // Restrict access to donor profile, if donor and user are disconnected. |
388 | - $is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true ); |
|
389 | - if ( is_user_logged_in() && $is_donor_disconnected ) { |
|
390 | - Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' ); |
|
388 | + $is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true); |
|
389 | + if (is_user_logged_in() && $is_donor_disconnected) { |
|
390 | + Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error'); |
|
391 | 391 | |
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
395 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
395 | + give_get_template_part('shortcode', 'profile-editor'); |
|
396 | 396 | |
397 | 397 | $display = ob_get_clean(); |
398 | 398 | |
399 | 399 | return $display; |
400 | 400 | } |
401 | 401 | |
402 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
402 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
403 | 403 | |
404 | 404 | /** |
405 | 405 | * Process Profile Updater Form. |
@@ -412,31 +412,31 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @return bool |
414 | 414 | */ |
415 | -function give_process_profile_editor_updates( $data ) { |
|
415 | +function give_process_profile_editor_updates($data) { |
|
416 | 416 | // Profile field change request. |
417 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
417 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
418 | 418 | return false; |
419 | 419 | } |
420 | 420 | |
421 | 421 | // Nonce security. |
422 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
422 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
423 | 423 | return false; |
424 | 424 | } |
425 | 425 | |
426 | 426 | $user_id = get_current_user_id(); |
427 | - $old_user_data = get_userdata( $user_id ); |
|
427 | + $old_user_data = get_userdata($user_id); |
|
428 | 428 | |
429 | 429 | /* @var Give_Donor $donor */ |
430 | - $donor = new Give_Donor( $user_id, true ); |
|
430 | + $donor = new Give_Donor($user_id, true); |
|
431 | 431 | $old_company_name = $donor->get_company_name(); |
432 | 432 | |
433 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
434 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
435 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
436 | - $company_name = ! empty( $data['give_company_name'] ) ? sanitize_text_field( $data['give_company_name'] ) : $old_company_name; |
|
437 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
438 | - $password = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : ''; |
|
439 | - $confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : ''; |
|
433 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
434 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
435 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
436 | + $company_name = ! empty($data['give_company_name']) ? sanitize_text_field($data['give_company_name']) : $old_company_name; |
|
437 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
438 | + $password = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : ''; |
|
439 | + $confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : ''; |
|
440 | 440 | |
441 | 441 | $userdata = array( |
442 | 442 | 'ID' => $user_id, |
@@ -456,60 +456,60 @@ discard block |
||
456 | 456 | * @param int $user_id The ID of the user. |
457 | 457 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
458 | 458 | */ |
459 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
459 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
460 | 460 | |
461 | 461 | // Make sure to validate first name of existing donors. |
462 | - if ( empty( $first_name ) ) { |
|
462 | + if (empty($first_name)) { |
|
463 | 463 | // Empty First Name. |
464 | - give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) ); |
|
464 | + give_set_error('empty_first_name', __('Please enter your first name.', 'give')); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | // Make sure to validate passwords for existing Donors. |
468 | - give_validate_user_password( $password, $confirm_password ); |
|
468 | + give_validate_user_password($password, $confirm_password); |
|
469 | 469 | |
470 | - if ( empty( $email ) ) { |
|
470 | + if (empty($email)) { |
|
471 | 471 | // Make sure email should not be empty. |
472 | - give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) ); |
|
472 | + give_set_error('email_empty', __('The email you entered is empty.', 'give')); |
|
473 | 473 | |
474 | - } elseif ( ! is_email( $email ) ) { |
|
474 | + } elseif ( ! is_email($email)) { |
|
475 | 475 | // Make sure email should be valid. |
476 | - give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
476 | + give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give')); |
|
477 | 477 | |
478 | - } elseif ( $email != $old_user_data->user_email ) { |
|
478 | + } elseif ($email != $old_user_data->user_email) { |
|
479 | 479 | // Make sure the new email doesn't belong to another user. |
480 | - if ( email_exists( $email ) ) { |
|
481 | - give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
482 | - } elseif ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
480 | + if (email_exists($email)) { |
|
481 | + give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give')); |
|
482 | + } elseif (Give()->donors->get_donor_by('email', $email)) { |
|
483 | 483 | // Make sure the new email doesn't belong to another user. |
484 | - give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) ); |
|
484 | + give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give')); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | 488 | // Check for errors. |
489 | 489 | $errors = give_get_errors(); |
490 | 490 | |
491 | - if ( $errors ) { |
|
491 | + if ($errors) { |
|
492 | 492 | // Send back to the profile editor if there are errors. |
493 | - wp_redirect( $data['give_redirect'] ); |
|
493 | + wp_redirect($data['give_redirect']); |
|
494 | 494 | give_die(); |
495 | 495 | } |
496 | 496 | |
497 | 497 | // Update Donor First Name and Last Name. |
498 | - Give()->donors->update( $donor->id, array( |
|
499 | - 'name' => trim( "{$first_name} {$last_name}" ), |
|
500 | - ) ); |
|
501 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name ); |
|
502 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name ); |
|
503 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_company', $company_name ); |
|
498 | + Give()->donors->update($donor->id, array( |
|
499 | + 'name' => trim("{$first_name} {$last_name}"), |
|
500 | + )); |
|
501 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name); |
|
502 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name); |
|
503 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_company', $company_name); |
|
504 | 504 | |
505 | 505 | $current_user = wp_get_current_user(); |
506 | 506 | |
507 | 507 | // Compares new values with old values to detect change in values. |
508 | - $email_update = ( $email !== $current_user->user_email ) ? true : false; |
|
509 | - $display_name_update = ( $display_name !== $current_user->display_name ) ? true : false; |
|
510 | - $first_name_update = ( $first_name !== $current_user->first_name ) ? true : false; |
|
511 | - $last_name_update = ( $last_name !== $current_user->last_name ) ? true : false; |
|
512 | - $company_name_update = ( $company_name !== $old_company_name ) ? true : false; |
|
508 | + $email_update = ($email !== $current_user->user_email) ? true : false; |
|
509 | + $display_name_update = ($display_name !== $current_user->display_name) ? true : false; |
|
510 | + $first_name_update = ($first_name !== $current_user->first_name) ? true : false; |
|
511 | + $last_name_update = ($last_name !== $current_user->last_name) ? true : false; |
|
512 | + $company_name_update = ($company_name !== $old_company_name) ? true : false; |
|
513 | 513 | $update_code = 0; |
514 | 514 | |
515 | 515 | /** |
@@ -517,35 +517,35 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @var boolean |
519 | 519 | */ |
520 | - $profile_update = ( $email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update ); |
|
520 | + $profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update); |
|
521 | 521 | |
522 | 522 | /** |
523 | 523 | * True if password fields are filled. |
524 | 524 | * |
525 | 525 | * @var boolean |
526 | 526 | */ |
527 | - $password_update = ( ! empty( $password ) && ! empty( $confirm_password ) ); |
|
527 | + $password_update = ( ! empty($password) && ! empty($confirm_password)); |
|
528 | 528 | |
529 | - if ( $profile_update ) { |
|
529 | + if ($profile_update) { |
|
530 | 530 | |
531 | 531 | // If only profile fields are updated. |
532 | 532 | $update_code = '1'; |
533 | 533 | |
534 | - if ( $password_update ) { |
|
534 | + if ($password_update) { |
|
535 | 535 | |
536 | 536 | // If profile fields AND password both are updated. |
537 | 537 | $update_code = '2'; |
538 | 538 | } |
539 | - } elseif ( $password_update ) { |
|
539 | + } elseif ($password_update) { |
|
540 | 540 | |
541 | 541 | // If only password is updated. |
542 | 542 | $update_code = '3'; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // Update the user. |
546 | - $updated = wp_update_user( $userdata ); |
|
546 | + $updated = wp_update_user($userdata); |
|
547 | 547 | |
548 | - if ( $updated ) { |
|
548 | + if ($updated) { |
|
549 | 549 | |
550 | 550 | /** |
551 | 551 | * Fires after updating user profile. |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | * @param int $user_id The ID of the user. |
556 | 556 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
557 | 557 | */ |
558 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
558 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
559 | 559 | |
560 | 560 | $profile_edit_redirect_args = array( |
561 | 561 | 'updated' => 'true', |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | * Update codes '2' and '3' indicate a password change. |
567 | 567 | * If the password is changed, then logout and redirect to the same page. |
568 | 568 | */ |
569 | - if ( '2' === $update_code || '3' === $update_code ) { |
|
570 | - wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) ); |
|
569 | + if ('2' === $update_code || '3' === $update_code) { |
|
570 | + wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']))); |
|
571 | 571 | } else { |
572 | - wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ); |
|
572 | + wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | give_die(); |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | return false; |
579 | 579 | } |
580 | 580 | |
581 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
581 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
582 | 582 | |
583 | 583 | /** |
584 | 584 | * Give totals Shortcode. |
@@ -591,24 +591,24 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return string |
593 | 593 | */ |
594 | -function give_totals_shortcode( $atts ) { |
|
595 | - $total = get_option( 'give_earnings_total', false ); |
|
594 | +function give_totals_shortcode($atts) { |
|
595 | + $total = get_option('give_earnings_total', false); |
|
596 | 596 | |
597 | - $message = apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) ); |
|
597 | + $message = apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give')); |
|
598 | 598 | |
599 | - $atts = shortcode_atts( array( |
|
599 | + $atts = shortcode_atts(array( |
|
600 | 600 | 'total_goal' => 0, // integer |
601 | 601 | 'ids' => 0, // integer|array |
602 | 602 | 'cats' => 0, // integer|array |
603 | 603 | 'tags' => 0, // integer|array |
604 | 604 | 'message' => $message, |
605 | 605 | 'link' => '', // URL |
606 | - 'link_text' => __( 'Donate Now', 'give' ), // string, |
|
606 | + 'link_text' => __('Donate Now', 'give'), // string, |
|
607 | 607 | 'progress_bar' => true, // boolean |
608 | - ), $atts, 'give_totals' ); |
|
608 | + ), $atts, 'give_totals'); |
|
609 | 609 | |
610 | 610 | // Total Goal. |
611 | - $total_goal = give_maybe_sanitize_amount( $atts['total_goal'] ); |
|
611 | + $total_goal = give_maybe_sanitize_amount($atts['total_goal']); |
|
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Give Action fire before the shortcode is rendering is started. |
@@ -617,14 +617,14 @@ discard block |
||
617 | 617 | * |
618 | 618 | * @param array $atts shortcode attribute. |
619 | 619 | */ |
620 | - do_action( 'give_totals_goal_shortcode_before_render', $atts ); |
|
620 | + do_action('give_totals_goal_shortcode_before_render', $atts); |
|
621 | 621 | |
622 | 622 | // Build query based on cat, tag and Form ids. |
623 | - if ( ! empty( $atts['cats'] ) || ! empty( $atts['tags'] ) || ! empty( $atts['ids'] ) ) { |
|
623 | + if ( ! empty($atts['cats']) || ! empty($atts['tags']) || ! empty($atts['ids'])) { |
|
624 | 624 | |
625 | 625 | $form_ids = array(); |
626 | - if ( ! empty( $atts['ids'] ) ) { |
|
627 | - $form_ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ); |
|
626 | + if ( ! empty($atts['ids'])) { |
|
627 | + $form_ids = array_filter(array_map('trim', explode(',', $atts['ids']))); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
@@ -638,23 +638,23 @@ discard block |
||
638 | 638 | 'post_type' => 'give_forms', |
639 | 639 | 'post_status' => 'publish', |
640 | 640 | 'post__in' => $form_ids, |
641 | - 'posts_per_page' => - 1, |
|
641 | + 'posts_per_page' => -1, |
|
642 | 642 | 'fields' => 'ids', |
643 | 643 | 'tax_query' => array( |
644 | 644 | 'relation' => 'AND', |
645 | 645 | ), |
646 | 646 | ); |
647 | 647 | |
648 | - if ( ! empty( $atts['cats'] ) ) { |
|
649 | - $cats = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) ); |
|
648 | + if ( ! empty($atts['cats'])) { |
|
649 | + $cats = array_filter(array_map('trim', explode(',', $atts['cats']))); |
|
650 | 650 | $form_args['tax_query'][] = array( |
651 | 651 | 'taxonomy' => 'give_forms_category', |
652 | 652 | 'terms' => $cats, |
653 | 653 | ); |
654 | 654 | } |
655 | 655 | |
656 | - if ( ! empty( $atts['tags'] ) ) { |
|
657 | - $tags = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) ); |
|
656 | + if ( ! empty($atts['tags'])) { |
|
657 | + $tags = array_filter(array_map('trim', explode(',', $atts['tags']))); |
|
658 | 658 | $form_args['tax_query'][] = array( |
659 | 659 | 'taxonomy' => 'give_forms_tag', |
660 | 660 | 'terms' => $tags, |
@@ -670,15 +670,15 @@ discard block |
||
670 | 670 | * |
671 | 671 | * @return array $form_args WP query argument for Total Goal. |
672 | 672 | */ |
673 | - $form_args = (array) apply_filters( 'give_totals_goal_shortcode_query_args', $form_args ); |
|
673 | + $form_args = (array) apply_filters('give_totals_goal_shortcode_query_args', $form_args); |
|
674 | 674 | |
675 | - $forms = new WP_Query( $form_args ); |
|
675 | + $forms = new WP_Query($form_args); |
|
676 | 676 | |
677 | - if ( isset( $forms->posts ) ) { |
|
677 | + if (isset($forms->posts)) { |
|
678 | 678 | $total = 0; |
679 | - foreach ( $forms->posts as $post ) { |
|
680 | - $form_earning = give_get_meta( $post, '_give_form_earnings', true ); |
|
681 | - $form_earning = ! empty( $form_earning ) ? $form_earning : 0; |
|
679 | + foreach ($forms->posts as $post) { |
|
680 | + $form_earning = give_get_meta($post, '_give_form_earnings', true); |
|
681 | + $form_earning = ! empty($form_earning) ? $form_earning : 0; |
|
682 | 682 | |
683 | 683 | /** |
684 | 684 | * Update Form earnings. |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param int $post Form ID. |
689 | 689 | * @param string $form_earning Total earning of Form. |
690 | 690 | */ |
691 | - $total += apply_filters( 'give_totals_form_earning', $form_earning, $post ); |
|
691 | + $total += apply_filters('give_totals_form_earning', $form_earning, $post); |
|
692 | 692 | } |
693 | 693 | } |
694 | 694 | |
@@ -696,23 +696,23 @@ discard block |
||
696 | 696 | |
697 | 697 | // Append link with text. |
698 | 698 | $donate_link = ''; |
699 | - if ( ! empty( $atts['link'] ) ) { |
|
700 | - $donate_link = sprintf( ' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url( $atts['link'] ), esc_html( $atts['link_text'] ) ); |
|
699 | + if ( ! empty($atts['link'])) { |
|
700 | + $donate_link = sprintf(' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url($atts['link']), esc_html($atts['link_text'])); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | // Replace {total} in message. |
704 | - $message = str_replace( '{total}', give_currency_filter( |
|
705 | - give_format_amount( $total, |
|
706 | - array( 'sanitize' => false ) |
|
704 | + $message = str_replace('{total}', give_currency_filter( |
|
705 | + give_format_amount($total, |
|
706 | + array('sanitize' => false) |
|
707 | 707 | ) |
708 | - ), esc_html( $atts['message'] ) ); |
|
708 | + ), esc_html($atts['message'])); |
|
709 | 709 | |
710 | 710 | // Replace {total_goal} in message. |
711 | - $message = str_replace( '{total_goal}', give_currency_filter( |
|
712 | - give_format_amount( $total_goal, |
|
713 | - array( 'sanitize' => true ) |
|
711 | + $message = str_replace('{total_goal}', give_currency_filter( |
|
712 | + give_format_amount($total_goal, |
|
713 | + array('sanitize' => true) |
|
714 | 714 | ) |
715 | - ), $message ); |
|
715 | + ), $message); |
|
716 | 716 | |
717 | 717 | /** |
718 | 718 | * Update Give totals shortcode output. |
@@ -722,19 +722,19 @@ discard block |
||
722 | 722 | * @param string $message Shortcode Message. |
723 | 723 | * @param array $atts ShortCode attributes. |
724 | 724 | */ |
725 | - $message = apply_filters( 'give_totals_shortcode_message', $message, $atts ); |
|
725 | + $message = apply_filters('give_totals_shortcode_message', $message, $atts); |
|
726 | 726 | |
727 | 727 | ob_start(); |
728 | 728 | ?> |
729 | 729 | <div class="give-totals-shortcode-wrap"> |
730 | 730 | <?php |
731 | 731 | // Show Progress Bar if progress_bar set true. |
732 | - $show_progress_bar = isset( $atts['progress_bar'] ) ? filter_var( $atts['progress_bar'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
733 | - if ( $show_progress_bar ) { |
|
734 | - give_show_goal_totals_progress( $total, $total_goal ); |
|
732 | + $show_progress_bar = isset($atts['progress_bar']) ? filter_var($atts['progress_bar'], FILTER_VALIDATE_BOOLEAN) : true; |
|
733 | + if ($show_progress_bar) { |
|
734 | + give_show_goal_totals_progress($total, $total_goal); |
|
735 | 735 | } |
736 | 736 | |
737 | - echo sprintf( $message ) . $donate_link; |
|
737 | + echo sprintf($message).$donate_link; |
|
738 | 738 | ?> |
739 | 739 | </div> |
740 | 740 | <?php |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @param array $atts shortcode attribute. |
750 | 750 | * @param string $give_totals_output shortcode output. |
751 | 751 | */ |
752 | - do_action( 'give_totals_goal_shortcode_after_render', $atts, $give_totals_output ); |
|
752 | + do_action('give_totals_goal_shortcode_after_render', $atts, $give_totals_output); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Give Totals Shortcode output. |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @param string $give_totals_output |
760 | 760 | */ |
761 | - return apply_filters( 'give_totals_shortcode_output', $give_totals_output ); |
|
761 | + return apply_filters('give_totals_shortcode_output', $give_totals_output); |
|
762 | 762 | |
763 | 763 | } |
764 | 764 | |
765 | -add_shortcode( 'give_totals', 'give_totals_shortcode' ); |
|
765 | +add_shortcode('give_totals', 'give_totals_shortcode'); |
|
766 | 766 | |
767 | 767 | |
768 | 768 | /** |
@@ -793,11 +793,11 @@ discard block |
||
793 | 793 | * } |
794 | 794 | * @return string|bool The markup of the form grid or false. |
795 | 795 | */ |
796 | -function give_form_grid_shortcode( $atts ) { |
|
796 | +function give_form_grid_shortcode($atts) { |
|
797 | 797 | |
798 | 798 | $give_settings = give_get_settings(); |
799 | 799 | |
800 | - $atts = shortcode_atts( array( |
|
800 | + $atts = shortcode_atts(array( |
|
801 | 801 | 'forms_per_page' => 12, |
802 | 802 | 'paged' => true, |
803 | 803 | 'ids' => '', |
@@ -814,11 +814,11 @@ discard block |
||
814 | 814 | 'excerpt_length' => 16, |
815 | 815 | 'display_style' => 'modal_reveal', |
816 | 816 | 'status' => '', // open or closed |
817 | - ), $atts ); |
|
817 | + ), $atts); |
|
818 | 818 | |
819 | 819 | // Validate integer attributes. |
820 | - $atts['forms_per_page'] = intval( $atts['forms_per_page'] ); |
|
821 | - $atts['excerpt_length'] = intval( $atts['excerpt_length'] ); |
|
820 | + $atts['forms_per_page'] = intval($atts['forms_per_page']); |
|
821 | + $atts['excerpt_length'] = intval($atts['excerpt_length']); |
|
822 | 822 | |
823 | 823 | // Validate boolean attributes. |
824 | 824 | $boolean_attributes = array( |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | 'show_featured_image', |
830 | 830 | ); |
831 | 831 | |
832 | - foreach ( $boolean_attributes as $att ) { |
|
833 | - $atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN ); |
|
832 | + foreach ($boolean_attributes as $att) { |
|
833 | + $atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | // Set default form query args. |
@@ -844,9 +844,9 @@ discard block |
||
844 | 844 | ); |
845 | 845 | |
846 | 846 | // Filter results of form grid based on form status. |
847 | - $form_closed_status = trim( $atts['status'] ); |
|
847 | + $form_closed_status = trim($atts['status']); |
|
848 | 848 | |
849 | - if ( ! empty( $form_closed_status ) ) { |
|
849 | + if ( ! empty($form_closed_status)) { |
|
850 | 850 | $form_args['meta_query'] = array( |
851 | 851 | array( |
852 | 852 | 'key' => '_give_form_status', |
@@ -856,25 +856,25 @@ discard block |
||
856 | 856 | } |
857 | 857 | |
858 | 858 | // Maybe add pagination. |
859 | - if ( true === $atts['paged'] ) { |
|
860 | - $form_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; |
|
859 | + if (true === $atts['paged']) { |
|
860 | + $form_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | // Maybe filter forms by IDs. |
864 | - if ( ! empty( $atts['ids'] ) ) { |
|
865 | - $form_args['post__in'] = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ); |
|
864 | + if ( ! empty($atts['ids'])) { |
|
865 | + $form_args['post__in'] = array_filter(array_map('trim', explode(',', $atts['ids']))); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | // Convert comma-separated form IDs into array. |
869 | - if ( ! empty( $atts['exclude'] ) ) { |
|
870 | - $form_args['post__not_in'] = array_filter( array_map( function( $item ) { |
|
871 | - return intval( trim( $item ) ); |
|
872 | - }, explode( ',', $atts['exclude'] ) ) ); |
|
869 | + if ( ! empty($atts['exclude'])) { |
|
870 | + $form_args['post__not_in'] = array_filter(array_map(function($item) { |
|
871 | + return intval(trim($item)); |
|
872 | + }, explode(',', $atts['exclude']))); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | // Maybe filter by form category. |
876 | - if ( ! empty( $atts['cats'] ) ) { |
|
877 | - $cats = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) ); |
|
876 | + if ( ! empty($atts['cats'])) { |
|
877 | + $cats = array_filter(array_map('trim', explode(',', $atts['cats']))); |
|
878 | 878 | $tax_query = array( |
879 | 879 | 'taxonomy' => 'give_forms_category', |
880 | 880 | 'terms' => $cats, |
@@ -883,8 +883,8 @@ discard block |
||
883 | 883 | } |
884 | 884 | |
885 | 885 | // Maybe filter by form tag. |
886 | - if ( ! empty( $atts['tags'] ) ) { |
|
887 | - $tags = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) ); |
|
886 | + if ( ! empty($atts['tags'])) { |
|
887 | + $tags = array_filter(array_map('trim', explode(',', $atts['tags']))); |
|
888 | 888 | $tax_query = array( |
889 | 889 | 'taxonomy' => 'give_forms_tag', |
890 | 890 | 'terms' => $tags, |
@@ -893,24 +893,24 @@ discard block |
||
893 | 893 | } |
894 | 894 | |
895 | 895 | // Query to output donation forms. |
896 | - $form_query = new WP_Query( $form_args ); |
|
896 | + $form_query = new WP_Query($form_args); |
|
897 | 897 | |
898 | - if ( $form_query->have_posts() ) { |
|
898 | + if ($form_query->have_posts()) { |
|
899 | 899 | ob_start(); |
900 | 900 | |
901 | - add_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1 ); |
|
902 | - add_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1 ); |
|
903 | - add_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10, 3 ); |
|
904 | - add_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3 ); |
|
901 | + add_filter('add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1); |
|
902 | + add_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1); |
|
903 | + add_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10, 3); |
|
904 | + add_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3); |
|
905 | 905 | |
906 | 906 | echo '<div class="give-wrap">'; |
907 | - echo '<div class="give-grid give-grid--' . esc_attr( $atts['columns'] ) . '">'; |
|
907 | + echo '<div class="give-grid give-grid--'.esc_attr($atts['columns']).'">'; |
|
908 | 908 | |
909 | - while ( $form_query->have_posts() ) { |
|
909 | + while ($form_query->have_posts()) { |
|
910 | 910 | $form_query->the_post(); |
911 | 911 | |
912 | 912 | // Give/templates/shortcode-form-grid.php. |
913 | - give_get_template( 'shortcode-form-grid', array( $give_settings, $atts ) ); |
|
913 | + give_get_template('shortcode-form-grid', array($give_settings, $atts)); |
|
914 | 914 | |
915 | 915 | } |
916 | 916 | |
@@ -918,28 +918,28 @@ discard block |
||
918 | 918 | |
919 | 919 | echo '</div><!-- .give-grid -->'; |
920 | 920 | |
921 | - remove_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class' ); |
|
922 | - remove_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class' ); |
|
923 | - remove_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10 ); |
|
924 | - remove_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10 ); |
|
921 | + remove_filter('add_give_goal_progress_class', 'add_give_goal_progress_class'); |
|
922 | + remove_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class'); |
|
923 | + remove_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10); |
|
924 | + remove_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10); |
|
925 | 925 | |
926 | - if ( false !== $atts['paged'] ) { |
|
926 | + if (false !== $atts['paged']) { |
|
927 | 927 | $paginate_args = array( |
928 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
928 | + 'current' => max(1, get_query_var('paged')), |
|
929 | 929 | 'total' => $form_query->max_num_pages, |
930 | 930 | 'show_all' => false, |
931 | 931 | 'end_size' => 1, |
932 | 932 | 'mid_size' => 2, |
933 | 933 | 'prev_next' => true, |
934 | - 'prev_text' => __( '« Previous', 'give' ), |
|
935 | - 'next_text' => __( 'Next »', 'give' ), |
|
934 | + 'prev_text' => __('« Previous', 'give'), |
|
935 | + 'next_text' => __('Next »', 'give'), |
|
936 | 936 | 'type' => 'plain', |
937 | 937 | 'add_args' => false, |
938 | 938 | ); |
939 | 939 | |
940 | 940 | printf( |
941 | 941 | '<div class="give-page-numbers">%s</div>', |
942 | - paginate_links( $paginate_args ) |
|
942 | + paginate_links($paginate_args) |
|
943 | 943 | ); |
944 | 944 | } |
945 | 945 | echo '</div><!-- .give-wrap -->'; |
@@ -948,4 +948,4 @@ discard block |
||
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
951 | -add_shortcode( 'give_form_grid', 'give_form_grid_shortcode' ); |
|
951 | +add_shortcode('give_form_grid', 'give_form_grid_shortcode'); |