@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return void |
25 | 25 | */ |
26 | -function give_trigger_donation_receipt( $payment_id ) { |
|
26 | +function give_trigger_donation_receipt($payment_id) { |
|
27 | 27 | // Make sure we don't send a receipt while editing a donation. |
28 | - if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) { |
|
28 | + if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Send email. |
33 | - give_email_donation_receipt( $payment_id ); |
|
33 | + give_email_donation_receipt($payment_id); |
|
34 | 34 | } |
35 | 35 | |
36 | -add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999, 1 ); |
|
37 | 36 | \ No newline at end of file |
37 | +add_action('give_complete_donation', 'give_trigger_donation_receipt', 999, 1); |
|
38 | 38 | \ No newline at end of file |
@@ -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 | |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | * @param callable $func Hook to run when email tag is found |
57 | 57 | * @param string $context Email tag category |
58 | 58 | */ |
59 | - public function add( $tag, $description, $func, $context = '' ) { |
|
60 | - if ( is_callable( $func ) ) { |
|
61 | - $this->tags[ $tag ] = array( |
|
59 | + public function add($tag, $description, $func, $context = '') { |
|
60 | + if (is_callable($func)) { |
|
61 | + $this->tags[$tag] = array( |
|
62 | 62 | 'tag' => $tag, |
63 | 63 | 'description' => $description, |
64 | 64 | 'func' => $func, |
65 | - 'context' => give_check_variable( $context, 'empty', 'general' ), |
|
65 | + 'context' => give_check_variable($context, 'empty', 'general'), |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param string $tag Email tag to remove hook from |
76 | 76 | */ |
77 | - public function remove( $tag ) { |
|
78 | - unset( $this->tags[ $tag ] ); |
|
77 | + public function remove($tag) { |
|
78 | + unset($this->tags[$tag]); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - public function email_tag_exists( $tag ) { |
|
91 | - return array_key_exists( $tag, $this->tags ); |
|
90 | + public function email_tag_exists($tag) { |
|
91 | + return array_key_exists($tag, $this->tags); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -102,23 +102,23 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public function get_tags( $context_type = 'all', $field = '' ) { |
|
105 | + public function get_tags($context_type = 'all', $field = '') { |
|
106 | 106 | $tags = $this->tags; |
107 | 107 | |
108 | - if ( 'all' !== $context_type ) { |
|
108 | + if ('all' !== $context_type) { |
|
109 | 109 | $tags = array(); |
110 | 110 | |
111 | - foreach ( $this->tags as $tag ) { |
|
112 | - if ( empty( $tag['context'] ) || $context_type !== $tag['context'] ) { |
|
111 | + foreach ($this->tags as $tag) { |
|
112 | + if (empty($tag['context']) || $context_type !== $tag['context']) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
116 | - $tags[ $tag['tag'] ] = $tag; |
|
116 | + $tags[$tag['tag']] = $tag; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( ! empty( $tags ) && ! empty( $field ) ) { |
|
121 | - $tags = wp_list_pluck( $tags, $field ); |
|
120 | + if ( ! empty($tags) && ! empty($field)) { |
|
121 | + $tags = wp_list_pluck($tags, $field); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | return $tags; |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return string Content with email tags filtered out. |
138 | 138 | */ |
139 | - public function do_tags( $content, $tag_args ) { |
|
139 | + public function do_tags($content, $tag_args) { |
|
140 | 140 | |
141 | 141 | // Check if there is at least one tag added. |
142 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
142 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
143 | 143 | return $content; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $this->tag_args = $tag_args; |
147 | 147 | |
148 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
148 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
149 | 149 | |
150 | 150 | $this->tag_args = null; |
151 | 151 | |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return mixed |
163 | 163 | */ |
164 | - public function do_tag( $m ) { |
|
164 | + public function do_tag($m) { |
|
165 | 165 | |
166 | 166 | // Get tag |
167 | 167 | $tag = $m[1]; |
168 | 168 | |
169 | 169 | // Return tag if tag not set |
170 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
170 | + if ( ! $this->email_tag_exists($tag)) { |
|
171 | 171 | return $m[0]; |
172 | 172 | } |
173 | 173 | |
174 | - return call_user_func( $this->tags[ $tag ]['func'], $this->tag_args, $tag ); |
|
174 | + return call_user_func($this->tags[$tag]['func'], $this->tag_args, $tag); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param callable $func Hook to run when email tag is found |
187 | 187 | * @param string $context Email tag category |
188 | 188 | */ |
189 | -function give_add_email_tag( $tag, $description, $func, $context = '' ) { |
|
190 | - Give()->email_tags->add( $tag, $description, $func, $context ); |
|
189 | +function give_add_email_tag($tag, $description, $func, $context = '') { |
|
190 | + Give()->email_tags->add($tag, $description, $func, $context); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param string $tag Email tag to remove hook from |
199 | 199 | */ |
200 | -function give_remove_email_tag( $tag ) { |
|
201 | - Give()->email_tags->remove( $tag ); |
|
200 | +function give_remove_email_tag($tag) { |
|
201 | + Give()->email_tags->remove($tag); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return bool |
212 | 212 | */ |
213 | -function give_email_tag_exists( $tag ) { |
|
214 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
213 | +function give_email_tag_exists($tag) { |
|
214 | + return Give()->email_tags->email_tag_exists($tag); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | $email_tags = give_get_email_tags(); |
239 | 239 | |
240 | 240 | ob_start(); |
241 | - if ( count( $email_tags ) > 0 ) : ?> |
|
241 | + if (count($email_tags) > 0) : ?> |
|
242 | 242 | <div class="give-email-tags-wrap"> |
243 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
243 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
244 | 244 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
245 | 245 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
246 | 246 | </span> |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string Content with email tags filtered out. |
266 | 266 | */ |
267 | -function give_do_email_tags( $content, $tag_args ) { |
|
267 | +function give_do_email_tags($content, $tag_args) { |
|
268 | 268 | // Backward compatibility < 2.0 |
269 | - if ( ! is_array( $tag_args ) ) { |
|
270 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
269 | + if ( ! is_array($tag_args)) { |
|
270 | + $tag_args = array('payment_id' => $tag_args); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Replace all tags |
274 | - $content = Give()->email_tags->do_tags( $content, $tag_args ); |
|
274 | + $content = Give()->email_tags->do_tags($content, $tag_args); |
|
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Filter the filtered content text. |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @since 1.0 |
280 | 280 | * @since 2.0 $payment_meta, $payment_id removed and $tag_args added. |
281 | 281 | */ |
282 | - $content = apply_filters( 'give_email_template_tags', $content, $tag_args ); |
|
282 | + $content = apply_filters('give_email_template_tags', $content, $tag_args); |
|
283 | 283 | |
284 | 284 | // Return content |
285 | 285 | return $content; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @since 1.0 |
300 | 300 | */ |
301 | - do_action( 'give_add_email_tags' ); |
|
301 | + do_action('give_add_email_tags'); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
304 | +add_action('init', 'give_load_email_tags', - 999); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -316,67 +316,67 @@ discard block |
||
316 | 316 | /* Donation Payment */ |
317 | 317 | array( |
318 | 318 | 'tag' => 'donation', |
319 | - 'description' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
319 | + 'description' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'), |
|
320 | 320 | 'function' => 'give_email_tag_donation', |
321 | 321 | 'context' => 'donation', |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'amount', |
325 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
325 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_amount', |
327 | 327 | 'context' => 'donation', |
328 | 328 | ), |
329 | 329 | array( |
330 | 330 | 'tag' => 'price', |
331 | - 'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ), |
|
331 | + 'description' => esc_html__('The total donation amount with currency sign.', 'give'), |
|
332 | 332 | 'function' => 'give_email_tag_price', |
333 | 333 | 'context' => 'donation', |
334 | 334 | ), |
335 | 335 | array( |
336 | 336 | 'tag' => 'billing_address', |
337 | - 'description' => esc_html__( 'The donor\'s billing address.', 'give' ), |
|
337 | + 'description' => esc_html__('The donor\'s billing address.', 'give'), |
|
338 | 338 | 'function' => 'give_email_tag_billing_address', |
339 | 339 | 'context' => 'donation', |
340 | 340 | ), |
341 | 341 | array( |
342 | 342 | 'tag' => 'date', |
343 | - 'description' => esc_html__( 'The date of the donation.', 'give' ), |
|
343 | + 'description' => esc_html__('The date of the donation.', 'give'), |
|
344 | 344 | 'function' => 'give_email_tag_date', |
345 | 345 | 'context' => 'donation', |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'tag' => 'payment_id', |
349 | - 'description' => esc_html__( 'The unique ID number for this donation.', 'give' ), |
|
349 | + 'description' => esc_html__('The unique ID number for this donation.', 'give'), |
|
350 | 350 | 'function' => 'give_email_tag_payment_id', |
351 | 351 | 'context' => 'donation', |
352 | 352 | ), |
353 | 353 | array( |
354 | 354 | 'tag' => 'payment_method', |
355 | - 'description' => esc_html__( 'The method of payment used for this donation.', 'give' ), |
|
355 | + 'description' => esc_html__('The method of payment used for this donation.', 'give'), |
|
356 | 356 | 'function' => 'give_email_tag_payment_method', |
357 | 357 | 'context' => 'donation', |
358 | 358 | ), |
359 | 359 | array( |
360 | 360 | 'tag' => 'payment_total', |
361 | - 'description' => esc_html__( 'The payment total for this donation.', 'give' ), |
|
361 | + 'description' => esc_html__('The payment total for this donation.', 'give'), |
|
362 | 362 | 'function' => 'give_email_tag_payment_total', |
363 | 363 | 'context' => 'donation', |
364 | 364 | ), |
365 | 365 | array( |
366 | 366 | 'tag' => 'receipt_id', |
367 | - 'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ), |
|
367 | + 'description' => esc_html__('The unique ID number for this donation receipt.', 'give'), |
|
368 | 368 | 'function' => 'give_email_tag_receipt_id', |
369 | 369 | 'context' => 'donation', |
370 | 370 | ), |
371 | 371 | array( |
372 | 372 | 'tag' => 'receipt_link', |
373 | - 'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
373 | + 'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
374 | 374 | 'function' => 'give_email_tag_receipt_link', |
375 | 375 | 'context' => 'donation', |
376 | 376 | ), |
377 | 377 | array( |
378 | 378 | 'tag' => 'receipt_link_url', |
379 | - 'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
379 | + 'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
380 | 380 | 'function' => 'give_email_tag_receipt_link_url', |
381 | 381 | 'context' => 'donation', |
382 | 382 | ), |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | /* Donation Form */ |
385 | 385 | array( |
386 | 386 | 'tag' => 'form_title', |
387 | - 'description' => esc_html__( 'The donation form name.', 'give' ), |
|
387 | + 'description' => esc_html__('The donation form name.', 'give'), |
|
388 | 388 | 'function' => 'give_email_tag_form_title', |
389 | 389 | 'context' => 'form', |
390 | 390 | ), |
@@ -392,31 +392,31 @@ discard block |
||
392 | 392 | /* Donor */ |
393 | 393 | array( |
394 | 394 | 'tag' => 'name', |
395 | - 'description' => esc_html__( 'The donor\'s first name.', 'give' ), |
|
395 | + 'description' => esc_html__('The donor\'s first name.', 'give'), |
|
396 | 396 | 'function' => 'give_email_tag_first_name', |
397 | 397 | 'context' => 'donor', |
398 | 398 | ), |
399 | 399 | array( |
400 | 400 | 'tag' => 'fullname', |
401 | - 'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ), |
|
401 | + 'description' => esc_html__('The donor\'s full name, first and last.', 'give'), |
|
402 | 402 | 'function' => 'give_email_tag_fullname', |
403 | 403 | 'context' => 'donor', |
404 | 404 | ), |
405 | 405 | array( |
406 | 406 | 'tag' => 'username', |
407 | - 'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
407 | + 'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
408 | 408 | 'function' => 'give_email_tag_username', |
409 | 409 | 'context' => 'donor', |
410 | 410 | ), |
411 | 411 | array( |
412 | 412 | 'tag' => 'user_email', |
413 | - 'description' => esc_html__( 'The donor\'s email address.', 'give' ), |
|
413 | + 'description' => esc_html__('The donor\'s email address.', 'give'), |
|
414 | 414 | 'function' => 'give_email_tag_user_email', |
415 | 415 | 'context' => 'donor', |
416 | 416 | ), |
417 | 417 | array( |
418 | 418 | 'tag' => 'email_access_link', |
419 | - 'description' => esc_html__( 'The donor\'s email access link.', 'give' ), |
|
419 | + 'description' => esc_html__('The donor\'s email access link.', 'give'), |
|
420 | 420 | 'function' => 'give_email_tag_email_access_link', |
421 | 421 | 'context' => 'donor', |
422 | 422 | ), |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | /* General */ |
425 | 425 | array( |
426 | 426 | 'tag' => 'sitename', |
427 | - 'description' => esc_html__( 'The name of your site.', 'give' ), |
|
427 | + 'description' => esc_html__('The name of your site.', 'give'), |
|
428 | 428 | 'function' => 'give_email_tag_sitename', |
429 | 429 | 'context' => 'general', |
430 | 430 | ), |
431 | 431 | |
432 | 432 | array( |
433 | 433 | 'tag' => 'reset_password_link', |
434 | - 'description' => esc_html__( 'The reset password link for user.', 'give' ), |
|
434 | + 'description' => esc_html__('The reset password link for user.', 'give'), |
|
435 | 435 | 'function' => 'give_email_tag_reset_password_link', |
436 | 436 | 'context' => 'general', |
437 | 437 | ), |
@@ -439,21 +439,21 @@ discard block |
||
439 | 439 | ); |
440 | 440 | |
441 | 441 | // Apply give_email_tags filter |
442 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
442 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
443 | 443 | |
444 | 444 | // Add email tags |
445 | - foreach ( $email_tags as $email_tag ) { |
|
445 | + foreach ($email_tags as $email_tag) { |
|
446 | 446 | give_add_email_tag( |
447 | 447 | $email_tag['tag'], |
448 | 448 | $email_tag['description'], |
449 | 449 | $email_tag['function'], |
450 | - ( ! empty( $email_tag['context'] ) ? $email_tag['context'] : '' ) |
|
450 | + ( ! empty($email_tag['context']) ? $email_tag['context'] : '') |
|
451 | 451 | ); |
452 | 452 | } |
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
456 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
457 | 457 | |
458 | 458 | |
459 | 459 | /** |
@@ -465,26 +465,26 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string $firstname |
467 | 467 | */ |
468 | -function give_email_tag_first_name( $tag_args ) { |
|
468 | +function give_email_tag_first_name($tag_args) { |
|
469 | 469 | $user_info = array(); |
470 | 470 | $firstname = ''; |
471 | 471 | |
472 | 472 | // Backward compatibility. |
473 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
473 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
474 | 474 | |
475 | - switch ( true ) { |
|
476 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
477 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
475 | + switch (true) { |
|
476 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
477 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
478 | 478 | |
479 | 479 | // Get firstname. |
480 | - if ( ! empty( $payment->user_info ) ) { |
|
481 | - $email_names = give_get_email_names( $payment->user_info ); |
|
480 | + if ( ! empty($payment->user_info)) { |
|
481 | + $email_names = give_get_email_names($payment->user_info); |
|
482 | 482 | $firstname = $email_names['name']; |
483 | 483 | } |
484 | 484 | break; |
485 | 485 | |
486 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
487 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
486 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
487 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
488 | 488 | $firstname = $donor->get_first_name(); |
489 | 489 | break; |
490 | 490 | |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @since 2.0 |
495 | 495 | */ |
496 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
497 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
496 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
497 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
498 | 498 | $firstname = $donor->get_first_name(); |
499 | 499 | break; |
500 | 500 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @param string $firstname |
508 | 508 | * @param array $tag_args |
509 | 509 | */ |
510 | - $firstname = apply_filters( 'give_email_tag_first_name', $firstname, $tag_args ); |
|
510 | + $firstname = apply_filters('give_email_tag_first_name', $firstname, $tag_args); |
|
511 | 511 | |
512 | 512 | return $firstname; |
513 | 513 | } |
@@ -521,26 +521,26 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string $fullname |
523 | 523 | */ |
524 | -function give_email_tag_fullname( $tag_args ) { |
|
524 | +function give_email_tag_fullname($tag_args) { |
|
525 | 525 | $fullname = ''; |
526 | 526 | |
527 | 527 | // Backward compatibility. |
528 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
528 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
529 | 529 | |
530 | - switch ( true ) { |
|
531 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
532 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
530 | + switch (true) { |
|
531 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
532 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
533 | 533 | |
534 | 534 | // Get fullname. |
535 | - if ( ! empty( $payment->user_info ) ) { |
|
536 | - $email_names = give_get_email_names( $payment->user_info ); |
|
535 | + if ( ! empty($payment->user_info)) { |
|
536 | + $email_names = give_get_email_names($payment->user_info); |
|
537 | 537 | $fullname = $email_names['fullname']; |
538 | 538 | } |
539 | 539 | break; |
540 | 540 | |
541 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
542 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
543 | - $fullname = trim( "{$donor->get_first_name()} {$donor->get_last_name()}" ); |
|
541 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
542 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
543 | + $fullname = trim("{$donor->get_first_name()} {$donor->get_last_name()}"); |
|
544 | 544 | break; |
545 | 545 | |
546 | 546 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @since 2.0 |
550 | 550 | */ |
551 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
552 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
551 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
552 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
553 | 553 | $fullname = $donor->name; |
554 | 554 | break; |
555 | 555 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @param string $fullname |
563 | 563 | * @param array $tag_args |
564 | 564 | */ |
565 | - $fullname = apply_filters( 'give_email_tag_fullname', $fullname, $tag_args ); |
|
565 | + $fullname = apply_filters('give_email_tag_fullname', $fullname, $tag_args); |
|
566 | 566 | |
567 | 567 | return $fullname; |
568 | 568 | } |
@@ -576,25 +576,25 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return string username. |
578 | 578 | */ |
579 | -function give_email_tag_username( $tag_args ) { |
|
579 | +function give_email_tag_username($tag_args) { |
|
580 | 580 | $username = ''; |
581 | 581 | |
582 | 582 | // Backward compatibility. |
583 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
583 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
584 | 584 | |
585 | - switch ( true ) { |
|
586 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
587 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
585 | + switch (true) { |
|
586 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
587 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
588 | 588 | |
589 | 589 | // Get username. |
590 | - if ( ! empty( $payment->user_info ) ) { |
|
591 | - $email_names = give_get_email_names( $payment->user_info ); |
|
590 | + if ( ! empty($payment->user_info)) { |
|
591 | + $email_names = give_get_email_names($payment->user_info); |
|
592 | 592 | $username = $email_names['username']; |
593 | 593 | } |
594 | 594 | break; |
595 | 595 | |
596 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
597 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
596 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
597 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
598 | 598 | $username = $user_info->user_login; |
599 | 599 | break; |
600 | 600 | |
@@ -603,10 +603,10 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @since 2.0 |
605 | 605 | */ |
606 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
607 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
608 | - if ( ! empty( $donor->id ) && ! empty( $donor->user_id ) ) { |
|
609 | - $user_info = get_user_by( 'id', $donor->user_id ); |
|
606 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
607 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
608 | + if ( ! empty($donor->id) && ! empty($donor->user_id)) { |
|
609 | + $user_info = get_user_by('id', $donor->user_id); |
|
610 | 610 | $username = $user_info->user_login; |
611 | 611 | } |
612 | 612 | break; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @param string $username |
621 | 621 | * @param array $tag_args |
622 | 622 | */ |
623 | - $username = apply_filters( 'give_email_tag_username', $username, $tag_args ); |
|
623 | + $username = apply_filters('give_email_tag_username', $username, $tag_args); |
|
624 | 624 | |
625 | 625 | return $username; |
626 | 626 | } |
@@ -634,20 +634,20 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return string user_email |
636 | 636 | */ |
637 | -function give_email_tag_user_email( $tag_args ) { |
|
637 | +function give_email_tag_user_email($tag_args) { |
|
638 | 638 | $email = ''; |
639 | 639 | |
640 | 640 | // Backward compatibility. |
641 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
641 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
642 | 642 | |
643 | - switch ( true ) { |
|
644 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
645 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
643 | + switch (true) { |
|
644 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
645 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
646 | 646 | $email = $payment->email; |
647 | 647 | break; |
648 | 648 | |
649 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
650 | - $user_info = get_user_by( 'id', $tag_args['user_id'] ); |
|
649 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
650 | + $user_info = get_user_by('id', $tag_args['user_id']); |
|
651 | 651 | $email = $user_info->user_email; |
652 | 652 | break; |
653 | 653 | |
@@ -656,9 +656,9 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @since 2.0 |
658 | 658 | */ |
659 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
660 | - $donor = new Give_Donor( $tag_args['donor_id'] ); |
|
661 | - $email = $donor->email; |
|
659 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
660 | + $donor = new Give_Donor($tag_args['donor_id']); |
|
661 | + $email = $donor->email; |
|
662 | 662 | break; |
663 | 663 | } |
664 | 664 | |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @param string $email |
671 | 671 | * @param array $tag_args |
672 | 672 | */ |
673 | - $email = apply_filters( 'give_email_tag_user_email', $email, $tag_args ); |
|
673 | + $email = apply_filters('give_email_tag_user_email', $email, $tag_args); |
|
674 | 674 | |
675 | 675 | return $email; |
676 | 676 | } |
@@ -684,15 +684,15 @@ discard block |
||
684 | 684 | * |
685 | 685 | * @return string billing_address |
686 | 686 | */ |
687 | -function give_email_tag_billing_address( $tag_args ) { |
|
687 | +function give_email_tag_billing_address($tag_args) { |
|
688 | 688 | $address = ''; |
689 | 689 | |
690 | 690 | // Backward compatibility. |
691 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
691 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
692 | 692 | |
693 | - switch ( true ) { |
|
694 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
695 | - $user_info = give_get_payment_meta_user_info( $tag_args['payment_id'] ); |
|
693 | + switch (true) { |
|
694 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
695 | + $user_info = give_get_payment_meta_user_info($tag_args['payment_id']); |
|
696 | 696 | $user_address = give_check_variable( |
697 | 697 | $user_info, |
698 | 698 | 'isset', |
@@ -707,13 +707,13 @@ discard block |
||
707 | 707 | 'address' |
708 | 708 | ); |
709 | 709 | |
710 | - $address = $user_address['line1'] . "\n"; |
|
710 | + $address = $user_address['line1']."\n"; |
|
711 | 711 | |
712 | - if ( ! empty( $user_address['line2'] ) ) { |
|
713 | - $address .= $user_address['line2'] . "\n"; |
|
712 | + if ( ! empty($user_address['line2'])) { |
|
713 | + $address .= $user_address['line2']."\n"; |
|
714 | 714 | } |
715 | 715 | |
716 | - $address .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n"; |
|
716 | + $address .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n"; |
|
717 | 717 | $address .= $user_address['country']; |
718 | 718 | break; |
719 | 719 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * @param string $address |
727 | 727 | * @param array $tag_args |
728 | 728 | */ |
729 | - $address = apply_filters( 'give_email_tag_billing_address', $address, $tag_args ); |
|
729 | + $address = apply_filters('give_email_tag_billing_address', $address, $tag_args); |
|
730 | 730 | |
731 | 731 | return $address; |
732 | 732 | } |
@@ -740,16 +740,16 @@ discard block |
||
740 | 740 | * |
741 | 741 | * @return string date |
742 | 742 | */ |
743 | -function give_email_tag_date( $tag_args ) { |
|
743 | +function give_email_tag_date($tag_args) { |
|
744 | 744 | $date = ''; |
745 | 745 | |
746 | 746 | // Backward compatibility. |
747 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
747 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
748 | 748 | |
749 | - switch ( true ) { |
|
750 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
751 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
752 | - $date = date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
749 | + switch (true) { |
|
750 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
751 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
752 | + $date = date_i18n(give_date_format(), strtotime($payment->date)); |
|
753 | 753 | break; |
754 | 754 | } |
755 | 755 | |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | * @param string $date |
762 | 762 | * @param array $tag_args |
763 | 763 | */ |
764 | - $date = apply_filters( 'give_email_tag_date', $date, $tag_args ); |
|
764 | + $date = apply_filters('give_email_tag_date', $date, $tag_args); |
|
765 | 765 | |
766 | 766 | return $date; |
767 | 767 | } |
@@ -775,17 +775,17 @@ discard block |
||
775 | 775 | * |
776 | 776 | * @return string amount |
777 | 777 | */ |
778 | -function give_email_tag_amount( $tag_args ) { |
|
778 | +function give_email_tag_amount($tag_args) { |
|
779 | 779 | $amount = ''; |
780 | 780 | |
781 | 781 | // Backward compatibility. |
782 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
782 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
783 | 783 | |
784 | - switch ( true ) { |
|
785 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
786 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
787 | - $give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), array( 'currency_code' => $payment->currency ) ); |
|
788 | - $amount = html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
784 | + switch (true) { |
|
785 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
786 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
787 | + $give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), array('currency_code' => $payment->currency)); |
|
788 | + $amount = html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
789 | 789 | break; |
790 | 790 | } |
791 | 791 | |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | * @param string $amount |
798 | 798 | * @param array $tag_args |
799 | 799 | */ |
800 | - $amount = apply_filters( 'give_email_tag_amount', $amount, $tag_args ); |
|
800 | + $amount = apply_filters('give_email_tag_amount', $amount, $tag_args); |
|
801 | 801 | |
802 | 802 | return $amount; |
803 | 803 | } |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | * |
812 | 812 | * @return string price |
813 | 813 | */ |
814 | -function give_email_tag_price( $tag_args ) { |
|
815 | - return give_email_tag_amount( $tag_args ); |
|
814 | +function give_email_tag_price($tag_args) { |
|
815 | + return give_email_tag_amount($tag_args); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | /** |
@@ -824,15 +824,15 @@ discard block |
||
824 | 824 | * |
825 | 825 | * @return int payment_id |
826 | 826 | */ |
827 | -function give_email_tag_payment_id( $tag_args ) { |
|
827 | +function give_email_tag_payment_id($tag_args) { |
|
828 | 828 | $payment_id = ''; |
829 | 829 | |
830 | 830 | // Backward compatibility. |
831 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
831 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
832 | 832 | |
833 | - switch ( true ) { |
|
834 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
835 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
833 | + switch (true) { |
|
834 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
835 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
836 | 836 | $payment_id = $payment->number; |
837 | 837 | break; |
838 | 838 | } |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @param string $payment_id |
846 | 846 | * @param array $tag_args |
847 | 847 | */ |
848 | - return apply_filters( 'give_email_tag_payment_id', $payment_id, $tag_args ); |
|
848 | + return apply_filters('give_email_tag_payment_id', $payment_id, $tag_args); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
@@ -857,15 +857,15 @@ discard block |
||
857 | 857 | * |
858 | 858 | * @return string receipt_id |
859 | 859 | */ |
860 | -function give_email_tag_receipt_id( $tag_args ) { |
|
860 | +function give_email_tag_receipt_id($tag_args) { |
|
861 | 861 | $receipt_id = ''; |
862 | 862 | |
863 | 863 | // Backward compatibility. |
864 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
864 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
865 | 865 | |
866 | - switch ( true ) { |
|
867 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
868 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
866 | + switch (true) { |
|
867 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
868 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
869 | 869 | $receipt_id = $payment->key; |
870 | 870 | break; |
871 | 871 | } |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | * @param string $receipt_id |
879 | 879 | * @param array $tag_args |
880 | 880 | */ |
881 | - return apply_filters( 'give_email_tag_receipt_id', $receipt_id, $tag_args ); |
|
881 | + return apply_filters('give_email_tag_receipt_id', $receipt_id, $tag_args); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -890,23 +890,23 @@ discard block |
||
890 | 890 | * |
891 | 891 | * @return string $form_title |
892 | 892 | */ |
893 | -function give_email_tag_donation( $tag_args ) { |
|
893 | +function give_email_tag_donation($tag_args) { |
|
894 | 894 | $donation_form_title = ''; |
895 | 895 | |
896 | 896 | // Backward compatibility. |
897 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
897 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
898 | 898 | |
899 | - switch ( true ) { |
|
900 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
901 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
902 | - $level_title = give_has_variable_prices( $payment->form_id ); |
|
899 | + switch (true) { |
|
900 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
901 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
902 | + $level_title = give_has_variable_prices($payment->form_id); |
|
903 | 903 | $separator = $level_title ? '-' : ''; |
904 | - $donation_form_title = strip_tags( give_check_variable( give_get_donation_form_title( |
|
904 | + $donation_form_title = strip_tags(give_check_variable(give_get_donation_form_title( |
|
905 | 905 | $payment, |
906 | 906 | array( |
907 | 907 | 'separator' => $separator, |
908 | 908 | ) |
909 | - ), 'empty', '' ) ); |
|
909 | + ), 'empty', '')); |
|
910 | 910 | break; |
911 | 911 | } |
912 | 912 | |
@@ -934,17 +934,17 @@ discard block |
||
934 | 934 | * |
935 | 935 | * @return string $form_title |
936 | 936 | */ |
937 | -function give_email_tag_form_title( $tag_args ) { |
|
937 | +function give_email_tag_form_title($tag_args) { |
|
938 | 938 | $donation_form_title = ''; |
939 | 939 | |
940 | 940 | // Backward compatibility. |
941 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
941 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
942 | 942 | |
943 | - switch ( true ) { |
|
944 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
945 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
943 | + switch (true) { |
|
944 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
945 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
946 | 946 | $payment_meta = $payment->payment_meta; |
947 | - $donation_form_title = strip_tags( give_check_variable( $payment_meta, 'empty', '', 'form_title' ) ); |
|
947 | + $donation_form_title = strip_tags(give_check_variable($payment_meta, 'empty', '', 'form_title')); |
|
948 | 948 | break; |
949 | 949 | } |
950 | 950 | |
@@ -972,19 +972,19 @@ discard block |
||
972 | 972 | * |
973 | 973 | * @return string gateway |
974 | 974 | */ |
975 | -function give_email_tag_payment_method( $tag_args ) { |
|
975 | +function give_email_tag_payment_method($tag_args) { |
|
976 | 976 | $payment_method = ''; |
977 | 977 | |
978 | 978 | // Backward compatibility. |
979 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
979 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
980 | 980 | |
981 | 981 | // Backward compatibility. |
982 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
982 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
983 | 983 | |
984 | - switch ( true ) { |
|
985 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
986 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
987 | - $payment_method = give_get_gateway_checkout_label( $payment->gateway ); |
|
984 | + switch (true) { |
|
985 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
986 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
987 | + $payment_method = give_get_gateway_checkout_label($payment->gateway); |
|
988 | 988 | break; |
989 | 989 | } |
990 | 990 | |
@@ -1015,16 +1015,16 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @return string |
1017 | 1017 | */ |
1018 | -function give_email_tag_payment_total( $tag_args ) { |
|
1018 | +function give_email_tag_payment_total($tag_args) { |
|
1019 | 1019 | $payment_total = ''; |
1020 | 1020 | |
1021 | 1021 | // Backward compatibility. |
1022 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1022 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1023 | 1023 | |
1024 | - switch ( true ) { |
|
1025 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1026 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1027 | - $payment_total = give_currency_filter( $payment->total ); |
|
1024 | + switch (true) { |
|
1025 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1026 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1027 | + $payment_total = give_currency_filter($payment->total); |
|
1028 | 1028 | break; |
1029 | 1029 | } |
1030 | 1030 | |
@@ -1052,11 +1052,11 @@ discard block |
||
1052 | 1052 | * |
1053 | 1053 | * @return string |
1054 | 1054 | */ |
1055 | -function give_email_tag_sitename( $tag_args = array() ) { |
|
1056 | - $sitename = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
1055 | +function give_email_tag_sitename($tag_args = array()) { |
|
1056 | + $sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
1057 | 1057 | |
1058 | 1058 | // Backward compatibility. |
1059 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1059 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1060 | 1060 | |
1061 | 1061 | /** |
1062 | 1062 | * Filter the {sitename} email template tag output. |
@@ -1082,26 +1082,26 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @return string receipt_link |
1084 | 1084 | */ |
1085 | -function give_email_tag_receipt_link( $tag_args ) { |
|
1085 | +function give_email_tag_receipt_link($tag_args) { |
|
1086 | 1086 | // Backward compatibility. |
1087 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1087 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1088 | 1088 | |
1089 | - $receipt_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1089 | + $receipt_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1090 | 1090 | |
1091 | 1091 | // Bailout. |
1092 | - if ( give_get_option( 'email_template' ) === 'none' ) { |
|
1092 | + if (give_get_option('email_template') === 'none') { |
|
1093 | 1093 | return $receipt_url; |
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | |
1097 | - $receipt_url = esc_url( add_query_arg( array( |
|
1098 | - 'payment_key' => give_get_payment_key( $tag_args['payment_id'] ), |
|
1099 | - ), give_get_history_page_uri() ) ); |
|
1097 | + $receipt_url = esc_url(add_query_arg(array( |
|
1098 | + 'payment_key' => give_get_payment_key($tag_args['payment_id']), |
|
1099 | + ), give_get_history_page_uri())); |
|
1100 | 1100 | |
1101 | - $formatted = sprintf( |
|
1101 | + $formatted = sprintf( |
|
1102 | 1102 | '<a href="%1$s">%2$s</a>', |
1103 | 1103 | $receipt_url, |
1104 | - __( 'View it in your browser »', 'give' ) |
|
1104 | + __('View it in your browser »', 'give') |
|
1105 | 1105 | ); |
1106 | 1106 | |
1107 | 1107 | /** |
@@ -1130,11 +1130,11 @@ discard block |
||
1130 | 1130 | * |
1131 | 1131 | * @return string receipt_url |
1132 | 1132 | */ |
1133 | -function give_email_tag_receipt_link_url( $tag_args ) { |
|
1133 | +function give_email_tag_receipt_link_url($tag_args) { |
|
1134 | 1134 | // Backward compatibility. |
1135 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1135 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1136 | 1136 | |
1137 | - $receipt_link_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) ); |
|
1137 | + $receipt_link_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id')); |
|
1138 | 1138 | |
1139 | 1139 | /** |
1140 | 1140 | * Filter the {receipt_link_url} email template tag output. |
@@ -1161,13 +1161,13 @@ discard block |
||
1161 | 1161 | * |
1162 | 1162 | * @return string |
1163 | 1163 | */ |
1164 | -function give_get_receipt_url( $payment_id ) { |
|
1164 | +function give_get_receipt_url($payment_id) { |
|
1165 | 1165 | $receipt_url = ''; |
1166 | 1166 | |
1167 | - if ( $payment_id ) { |
|
1168 | - $receipt_url = esc_url( add_query_arg( array( |
|
1169 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
1170 | - ), give_get_history_page_uri() ) ); |
|
1167 | + if ($payment_id) { |
|
1168 | + $receipt_url = esc_url(add_query_arg(array( |
|
1169 | + 'payment_key' => give_get_payment_key($payment_id), |
|
1170 | + ), give_get_history_page_uri())); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | return $receipt_url; |
@@ -1183,22 +1183,22 @@ discard block |
||
1183 | 1183 | * |
1184 | 1184 | * @return string |
1185 | 1185 | */ |
1186 | -function give_email_tag_email_access_link( $tag_args ) { |
|
1186 | +function give_email_tag_email_access_link($tag_args) { |
|
1187 | 1187 | $donor_id = 0; |
1188 | 1188 | $donor = array(); |
1189 | 1189 | $email_access_link = ''; |
1190 | 1190 | |
1191 | 1191 | // Backward compatibility. |
1192 | - $tag_args = __give_20_bc_str_type_email_tag_param( $tag_args ); |
|
1192 | + $tag_args = __give_20_bc_str_type_email_tag_param($tag_args); |
|
1193 | 1193 | |
1194 | - switch ( true ) { |
|
1195 | - case ! empty( $tag_args['donor_id'] ): |
|
1194 | + switch (true) { |
|
1195 | + case ! empty($tag_args['donor_id']): |
|
1196 | 1196 | $donor_id = $tag_args['donor_id']; |
1197 | - $donor = Give()->donors->get_by( 'id', $tag_args['donor_id'] ); |
|
1197 | + $donor = Give()->donors->get_by('id', $tag_args['donor_id']); |
|
1198 | 1198 | break; |
1199 | 1199 | |
1200 | - case ! empty( $tag_args['user_id'] ): |
|
1201 | - $donor = Give()->donors->get_by( 'user_id', $tag_args['user_id'] ); |
|
1200 | + case ! empty($tag_args['user_id']): |
|
1201 | + $donor = Give()->donors->get_by('user_id', $tag_args['user_id']); |
|
1202 | 1202 | $donor_id = $donor->id; |
1203 | 1203 | break; |
1204 | 1204 | |
@@ -1207,11 +1207,11 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | // Set email access link if donor exist. |
1210 | - if ( $donor_id ) { |
|
1211 | - $verify_key = wp_generate_password( 20, false ); |
|
1210 | + if ($donor_id) { |
|
1211 | + $verify_key = wp_generate_password(20, false); |
|
1212 | 1212 | |
1213 | 1213 | // Generate a new verify key |
1214 | - Give()->email_access->set_verify_key( $donor_id, $donor->email, $verify_key ); |
|
1214 | + Give()->email_access->set_verify_key($donor_id, $donor->email, $verify_key); |
|
1215 | 1215 | |
1216 | 1216 | $access_url = add_query_arg( |
1217 | 1217 | array( |
@@ -1221,28 +1221,28 @@ discard block |
||
1221 | 1221 | ); |
1222 | 1222 | |
1223 | 1223 | // Add Payment Key to email access url, if it exists. |
1224 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
1224 | + if ( ! empty($_GET['payment_key'])) { |
|
1225 | 1225 | $access_url = add_query_arg( |
1226 | 1226 | array( |
1227 | - 'payment_key' => give_clean( $_GET['payment_key'] ), |
|
1227 | + 'payment_key' => give_clean($_GET['payment_key']), |
|
1228 | 1228 | ), |
1229 | 1229 | $access_url |
1230 | 1230 | ); |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1233 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1234 | 1234 | $email_access_link = sprintf( |
1235 | 1235 | '<a href="%1$s" target="_blank">%2$s</a>', |
1236 | - esc_url( $access_url ), |
|
1237 | - __( 'View your donation history »', 'give' ) |
|
1236 | + esc_url($access_url), |
|
1237 | + __('View your donation history »', 'give') |
|
1238 | 1238 | ); |
1239 | 1239 | |
1240 | 1240 | } else { |
1241 | 1241 | |
1242 | 1242 | $email_access_link = sprintf( |
1243 | 1243 | '%1$s: %2$s', |
1244 | - __( 'View your donation history', 'give' ), |
|
1245 | - esc_url( $access_url ) |
|
1244 | + __('View your donation history', 'give'), |
|
1245 | + esc_url($access_url) |
|
1246 | 1246 | ); |
1247 | 1247 | } |
1248 | 1248 | } |
@@ -1274,23 +1274,23 @@ discard block |
||
1274 | 1274 | * |
1275 | 1275 | * @return array |
1276 | 1276 | */ |
1277 | -function __give_20_bc_str_type_email_tag_param( $tag_args ) { |
|
1278 | - if ( ! is_array( $tag_args ) ) { |
|
1279 | - switch ( true ) { |
|
1280 | - case ( 'give_payment' === get_post_type( $tag_args ) ): |
|
1281 | - $tag_args = array( 'payment_id' => $tag_args ); |
|
1277 | +function __give_20_bc_str_type_email_tag_param($tag_args) { |
|
1278 | + if ( ! is_array($tag_args)) { |
|
1279 | + switch (true) { |
|
1280 | + case ('give_payment' === get_post_type($tag_args)): |
|
1281 | + $tag_args = array('payment_id' => $tag_args); |
|
1282 | 1282 | break; |
1283 | 1283 | |
1284 | - case ( ! is_wp_error( get_user_by( 'id', $tag_args ) ) ): |
|
1285 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1284 | + case ( ! is_wp_error(get_user_by('id', $tag_args))): |
|
1285 | + $tag_args = array('user_id' => $tag_args); |
|
1286 | 1286 | break; |
1287 | 1287 | |
1288 | - case ( Give()->donors->get_by( 'id', $tag_args ) ): |
|
1289 | - $tag_args = array( 'donor_id' => $tag_args ); |
|
1288 | + case (Give()->donors->get_by('id', $tag_args)): |
|
1289 | + $tag_args = array('donor_id' => $tag_args); |
|
1290 | 1290 | break; |
1291 | 1291 | |
1292 | - case ( Give()->donors->get_by( 'user_id', $tag_args ) ): |
|
1293 | - $tag_args = array( 'user_id' => $tag_args ); |
|
1292 | + case (Give()->donors->get_by('user_id', $tag_args)): |
|
1293 | + $tag_args = array('user_id' => $tag_args); |
|
1294 | 1294 | break; |
1295 | 1295 | } |
1296 | 1296 | } |
@@ -1308,39 +1308,39 @@ discard block |
||
1308 | 1308 | * |
1309 | 1309 | * @return array |
1310 | 1310 | */ |
1311 | -function give_email_tag_reset_password_link( $tag_args, $payment_id ) { |
|
1311 | +function give_email_tag_reset_password_link($tag_args, $payment_id) { |
|
1312 | 1312 | |
1313 | 1313 | $reset_password_url = ''; |
1314 | 1314 | |
1315 | - switch ( true ) { |
|
1316 | - case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ): |
|
1317 | - $payment = new Give_Payment( $tag_args['payment_id'] ); |
|
1315 | + switch (true) { |
|
1316 | + case give_check_variable($tag_args, 'isset', 0, 'payment_id'): |
|
1317 | + $payment = new Give_Payment($tag_args['payment_id']); |
|
1318 | 1318 | $payment_id = $payment->number; |
1319 | 1319 | break; |
1320 | 1320 | |
1321 | - case give_check_variable( $tag_args, 'isset', 0, 'user_id' ): |
|
1322 | - $reset_password_url = give_get_reset_password_url( $tag_args['user_id'] ); |
|
1321 | + case give_check_variable($tag_args, 'isset', 0, 'user_id'): |
|
1322 | + $reset_password_url = give_get_reset_password_url($tag_args['user_id']); |
|
1323 | 1323 | break; |
1324 | 1324 | |
1325 | - case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ): |
|
1325 | + case give_check_variable($tag_args, 'isset', 0, 'donor_id'): |
|
1326 | 1326 | /* @var Give_Donor $donor */ |
1327 | - $donor = new Give_Donor( $tag_args['user_id'], true ); |
|
1328 | - $reset_password_url = give_get_reset_password_url( $donor->user_id ); |
|
1327 | + $donor = new Give_Donor($tag_args['user_id'], true); |
|
1328 | + $reset_password_url = give_get_reset_password_url($donor->user_id); |
|
1329 | 1329 | break; |
1330 | 1330 | } |
1331 | 1331 | |
1332 | - if( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) { |
|
1332 | + if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) { |
|
1333 | 1333 | // Generate link, if Email content type is html. |
1334 | 1334 | $reset_password_link = sprintf( |
1335 | 1335 | '<a href="%1$s" target="_blank">%2$s</a>', |
1336 | - esc_url( $reset_password_url ), |
|
1337 | - __( 'Reset your password »', 'give' ) |
|
1336 | + esc_url($reset_password_url), |
|
1337 | + __('Reset your password »', 'give') |
|
1338 | 1338 | ); |
1339 | - } else{ |
|
1339 | + } else { |
|
1340 | 1340 | $reset_password_link = sprintf( |
1341 | 1341 | '%1$s: %2$s', |
1342 | - __( 'Reset your password', 'give' ), |
|
1343 | - esc_url( $reset_password_url ) |
|
1342 | + __('Reset your password', 'give'), |
|
1343 | + esc_url($reset_password_url) |
|
1344 | 1344 | ); |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1369,21 +1369,21 @@ discard block |
||
1369 | 1369 | * |
1370 | 1370 | * @return mixed|string |
1371 | 1371 | */ |
1372 | -function give_get_reset_password_url( $user_id ) { |
|
1372 | +function give_get_reset_password_url($user_id) { |
|
1373 | 1373 | $reset_password_url = ''; |
1374 | 1374 | |
1375 | 1375 | // Proceed further only, if user_id exists. |
1376 | - if ( $user_id ) { |
|
1376 | + if ($user_id) { |
|
1377 | 1377 | |
1378 | 1378 | // Get User Object Details. |
1379 | - $user = get_user_by( 'ID', $user_id ); |
|
1379 | + $user = get_user_by('ID', $user_id); |
|
1380 | 1380 | |
1381 | 1381 | // Prepare Reset Password URL. |
1382 | - $reset_password_url = esc_url( add_query_arg( array( |
|
1382 | + $reset_password_url = esc_url(add_query_arg(array( |
|
1383 | 1383 | 'action' => 'rp', |
1384 | - 'key' => get_password_reset_key( $user ), |
|
1384 | + 'key' => get_password_reset_key($user), |
|
1385 | 1385 | 'login' => $user->user_login, |
1386 | - ), wp_login_url() ) ); |
|
1386 | + ), wp_login_url())); |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | return $reset_password_url; |
@@ -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,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
30 | - $payment = new Give_Payment( $payment_id ); |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | + $payment = new Give_Payment($payment_id); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Fire the action |
34 | 34 | */ |
35 | - do_action( 'give_donation-receipt_email_notification', $payment_id ); |
|
35 | + do_action('give_donation-receipt_email_notification', $payment_id); |
|
36 | 36 | |
37 | 37 | // If admin notifications are on, send the admin notice. |
38 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
38 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
39 | 39 | /** |
40 | 40 | * Fires in the donation email receipt. |
41 | 41 | * |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param int $payment_id Payment id. |
47 | 47 | * @param mixed $payment_data Payment meta data. |
48 | 48 | */ |
49 | - do_action( 'give_new-donation_email_notification', $payment_id, $payment->payment_meta ); |
|
49 | + do_action('give_new-donation_email_notification', $payment_id, $payment->payment_meta); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return void |
61 | 61 | */ |
62 | -function give_admin_email_notice( $payment_id ) { |
|
62 | +function give_admin_email_notice($payment_id) { |
|
63 | 63 | /** |
64 | 64 | * Fires in the donation email receipt. |
65 | 65 | * |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param int $payment_id Payment id. |
71 | 71 | * @param mixed $payment_data Payment meta data. |
72 | 72 | */ |
73 | - do_action( 'give_new-donation_email_notification', $payment_id ); |
|
73 | + do_action('give_new-donation_email_notification', $payment_id); |
|
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice' ); |
|
76 | +add_action('give_admin_donation_email', 'give_admin_email_notice'); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | /** |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function give_get_default_donation_notification_email() { |
88 | 88 | |
89 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n"; |
|
90 | - $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
91 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
92 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
93 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
94 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
95 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
96 | - $default_email_body .= '{sitename}' . "\n"; |
|
89 | + $default_email_body = __('Hi there,', 'give')."\n\n"; |
|
90 | + $default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
91 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n"; |
|
92 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
93 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
94 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
95 | + $default_email_body .= __('Thank you,', 'give')."\n\n"; |
|
96 | + $default_email_body .= '{sitename}'."\n"; |
|
97 | 97 | |
98 | - return apply_filters( 'give_default_donation_notification_email', $default_email_body ); |
|
98 | + return apply_filters('give_default_donation_notification_email', $default_email_body); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function give_get_default_donation_receipt_email() { |
111 | 111 | |
112 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
113 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
114 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
115 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
116 | - $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
117 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
118 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
119 | - $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
120 | - $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
121 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
112 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
113 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
114 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
115 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
116 | + $default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
117 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
118 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
119 | + $default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
120 | + $default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
121 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
122 | 122 | $default_email_body .= "\n\n"; |
123 | - $default_email_body .= __( 'Sincerely,', 'give' ) . "\n"; |
|
124 | - $default_email_body .= '{sitename}' . "\n"; |
|
123 | + $default_email_body .= __('Sincerely,', 'give')."\n"; |
|
124 | + $default_email_body .= '{sitename}'."\n"; |
|
125 | 125 | |
126 | - return apply_filters( 'give_default_donation_receipt_email', $default_email_body ); |
|
126 | + return apply_filters('give_default_donation_receipt_email', $default_email_body); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return array $email_names |
138 | 138 | */ |
139 | -function give_get_email_names( $user_info, $payment = false ) { |
|
139 | +function give_get_email_names($user_info, $payment = false) { |
|
140 | 140 | $email_names = array(); |
141 | 141 | |
142 | - if ( is_a( $payment, 'Give_Payment' ) ) { |
|
142 | + if (is_a($payment, 'Give_Payment')) { |
|
143 | 143 | |
144 | - if ( $payment->user_id > 0 ) { |
|
144 | + if ($payment->user_id > 0) { |
|
145 | 145 | |
146 | - $user_data = get_userdata( $payment->user_id ); |
|
146 | + $user_data = get_userdata($payment->user_id); |
|
147 | 147 | $email_names['name'] = $payment->first_name; |
148 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
148 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
149 | 149 | $email_names['username'] = $user_data->user_login; |
150 | 150 | |
151 | - } elseif ( ! empty( $payment->first_name ) ) { |
|
151 | + } elseif ( ! empty($payment->first_name)) { |
|
152 | 152 | |
153 | 153 | $email_names['name'] = $payment->first_name; |
154 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
154 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
155 | 155 | $email_names['username'] = $payment->first_name; |
156 | 156 | |
157 | 157 | } else { |
@@ -164,30 +164,30 @@ discard block |
||
164 | 164 | } else { |
165 | 165 | |
166 | 166 | // Support for old serialized data. |
167 | - if ( is_serialized( $user_info ) ) { |
|
167 | + if (is_serialized($user_info)) { |
|
168 | 168 | |
169 | 169 | // Security check. |
170 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
171 | - if ( ! empty( $matches ) ) { |
|
170 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
171 | + if ( ! empty($matches)) { |
|
172 | 172 | return array( |
173 | 173 | 'name' => '', |
174 | 174 | 'fullname' => '', |
175 | 175 | 'username' => '', |
176 | 176 | ); |
177 | 177 | } else { |
178 | - $user_info = maybe_unserialize( $user_info ); |
|
178 | + $user_info = maybe_unserialize($user_info); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
184 | - $user_data = get_userdata( $user_info['id'] ); |
|
183 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
184 | + $user_data = get_userdata($user_info['id']); |
|
185 | 185 | $email_names['name'] = $user_info['first_name']; |
186 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
186 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
187 | 187 | $email_names['username'] = $user_data->user_login; |
188 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
188 | + } elseif (isset($user_info['first_name'])) { |
|
189 | 189 | $email_names['name'] = $user_info['first_name']; |
190 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
190 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
191 | 191 | $email_names['username'] = $user_info['first_name']; |
192 | 192 | } else { |
193 | 193 | $email_names['name'] = $user_info['email']; |
@@ -207,37 +207,37 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @since 1.8.14 |
209 | 209 | */ |
210 | -function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) { |
|
210 | +function give_admin_email_user_donor_disconnection($user_id, $donor_id) { |
|
211 | 211 | |
212 | - $user_id = absint( $user_id ); |
|
213 | - $donor_id = absint( $donor_id ); |
|
212 | + $user_id = absint($user_id); |
|
213 | + $donor_id = absint($donor_id); |
|
214 | 214 | |
215 | 215 | // Bail Out, if user id doesn't exists. |
216 | - if ( empty( $user_id ) ) { |
|
216 | + if (empty($user_id)) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Bail Out, if donor id doesn't exists. |
221 | - if ( empty( $donor_id ) ) { |
|
221 | + if (empty($donor_id)) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
225 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
226 | 226 | |
227 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
227 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
228 | 228 | |
229 | 229 | /* translators: %s: payment id */ |
230 | - $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' ); |
|
230 | + $subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give'); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Filters the Donor-User Disconnection notification subject. |
234 | 234 | * |
235 | 235 | * @since 1.8.14 |
236 | 236 | */ |
237 | - $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) ); |
|
237 | + $subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject)); |
|
238 | 238 | |
239 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
240 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
239 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
240 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
241 | 241 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
242 | 242 | |
243 | 243 | /** |
@@ -245,25 +245,25 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @since 1.8.14 |
247 | 247 | */ |
248 | - $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers ); |
|
248 | + $headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers); |
|
249 | 249 | |
250 | - $message = __( 'Hi Admin,', 'give' ) . "\n\n"; |
|
251 | - $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n"; |
|
252 | - $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n"; |
|
250 | + $message = __('Hi Admin,', 'give')."\n\n"; |
|
251 | + $message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n"; |
|
252 | + $message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n"; |
|
253 | 253 | $message .= sprintf( |
254 | 254 | '<a href="%1$s">%2$s</a>', |
255 | - esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ), |
|
256 | - __( 'Reconnect User', 'give' ) . "\n\n" |
|
255 | + esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'), |
|
256 | + __('Reconnect User', 'give')."\n\n" |
|
257 | 257 | ); |
258 | - $message .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
259 | - $message .= '{sitename}' . "\n"; |
|
258 | + $message .= __('Thank you,', 'give')."\n\n"; |
|
259 | + $message .= '{sitename}'."\n"; |
|
260 | 260 | |
261 | 261 | $emails = Give()->emails; |
262 | - $emails->__set( 'from_name', $from_name ); |
|
263 | - $emails->__set( 'from_email', $from_email ); |
|
264 | - $emails->__set( 'headers', $headers ); |
|
265 | - $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) ); |
|
262 | + $emails->__set('from_name', $from_name); |
|
263 | + $emails->__set('from_email', $from_email); |
|
264 | + $emails->__set('headers', $headers); |
|
265 | + $emails->__set('heading', __('User - Donor Profile Disconnection', 'give')); |
|
266 | 266 | |
267 | - $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) ); |
|
267 | + $emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message)); |
|
268 | 268 | |
269 | 269 | } |
@@ -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 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return string $message Fully formatted message |
44 | 44 | */ |
45 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
46 | - return give_do_email_tags( $message, $payment_id ); |
|
45 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
46 | + return give_do_email_tags($message, $payment_id); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -57,45 +57,45 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string $message Fully formatted message |
59 | 59 | */ |
60 | -function give_email_preview_template_tags( $message ) { |
|
60 | +function give_email_preview_template_tags($message) { |
|
61 | 61 | |
62 | - $price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) ); |
|
62 | + $price = give_currency_filter(give_format_amount(10.50, array('sanitize' => false))); |
|
63 | 63 | |
64 | 64 | $gateway = 'PayPal'; |
65 | 65 | |
66 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
66 | + $receipt_id = strtolower(md5(uniqid())); |
|
67 | 67 | |
68 | - $payment_id = rand( 1, 100 ); |
|
69 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id ), give_get_history_page_uri() ) ); |
|
68 | + $payment_id = rand(1, 100); |
|
69 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id), give_get_history_page_uri())); |
|
70 | 70 | |
71 | 71 | $receipt_link = sprintf( |
72 | 72 | '<a href="%1$s">%2$s</a>', |
73 | 73 | $receipt_link_url, |
74 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
74 | + esc_html__('View the receipt in your browser »', 'give') |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | // Set user. |
78 | 78 | $user = wp_get_current_user(); |
79 | 79 | |
80 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
81 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
82 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
83 | - $message = str_replace( '{user_email}', $user->user_email, $message ); |
|
84 | - $message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message ); |
|
85 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
86 | - $message = str_replace( '{amount}', $price, $message ); |
|
87 | - $message = str_replace( '{price}', $price, $message ); |
|
88 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
89 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
90 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
91 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
92 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
93 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
94 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
95 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
96 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
97 | - |
|
98 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
80 | + $message = str_replace('{name}', $user->display_name, $message); |
|
81 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
82 | + $message = str_replace('{username}', $user->user_login, $message); |
|
83 | + $message = str_replace('{user_email}', $user->user_email, $message); |
|
84 | + $message = str_replace('{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message); |
|
85 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
86 | + $message = str_replace('{amount}', $price, $message); |
|
87 | + $message = str_replace('{price}', $price, $message); |
|
88 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
89 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
90 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
91 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
92 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
93 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
94 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
95 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
96 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
97 | + |
|
98 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return array |
113 | 113 | */ |
114 | -function give_email_preview_buttons_callback( $field ) { |
|
115 | - $field_id = str_replace( '_preview_buttons', '', $field['id'] ); |
|
114 | +function give_email_preview_buttons_callback($field) { |
|
115 | + $field_id = str_replace('_preview_buttons', '', $field['id']); |
|
116 | 116 | |
117 | 117 | ob_start(); |
118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | '<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>', |
121 | 121 | wp_nonce_url( |
122 | 122 | add_query_arg( |
123 | - array( 'give_action' => 'preview_email', 'email_type' => $field_id ), |
|
123 | + array('give_action' => 'preview_email', 'email_type' => $field_id), |
|
124 | 124 | home_url() |
125 | 125 | ), 'give-preview-email' |
126 | 126 | ), |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | echo sprintf( |
131 | 131 | ' <a href="%1$s" aria-label="%2$s" class="button-secondary">%3$s</a>', |
132 | 132 | wp_nonce_url( |
133 | - add_query_arg( array( |
|
133 | + add_query_arg(array( |
|
134 | 134 | 'give_action' => 'send_preview_email', |
135 | 135 | 'email_type' => $field_id, |
136 | 136 | 'give-message' => 'sent-test-email', |
137 | - ) ), 'give-send-preview-email' ), |
|
138 | - esc_attr__( 'Send Test Email.', 'give' ), |
|
139 | - esc_html__( 'Send Test Email', 'give' ) |
|
137 | + )), 'give-send-preview-email' ), |
|
138 | + esc_attr__('Send Test Email.', 'give'), |
|
139 | + esc_html__('Send Test Email', 'give') |
|
140 | 140 | ); |
141 | 141 | |
142 | 142 | echo ob_get_clean(); |
@@ -155,28 +155,28 @@ discard block |
||
155 | 155 | |
156 | 156 | //Payment receipt switcher |
157 | 157 | $payment_count = give_count_payments()->publish; |
158 | - $payment_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' ); |
|
158 | + $payment_id = give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id'); |
|
159 | 159 | |
160 | - if ( $payment_count <= 0 ) { |
|
160 | + if ($payment_count <= 0) { |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
164 | 164 | //Get payments. |
165 | - $payments = new Give_Payments_Query( array( |
|
165 | + $payments = new Give_Payments_Query(array( |
|
166 | 166 | 'number' => 100, |
167 | - ) ); |
|
167 | + )); |
|
168 | 168 | $payments = $payments->get_payments(); |
169 | 169 | $options = array(); |
170 | 170 | |
171 | 171 | // Default option. |
172 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
172 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
173 | 173 | |
174 | 174 | //Provide nice human readable options. |
175 | - if ( $payments ) { |
|
176 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
177 | - foreach ( $payments as $payment ) { |
|
175 | + if ($payments) { |
|
176 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
177 | + foreach ($payments as $payment) { |
|
178 | 178 | |
179 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
179 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | } |
@@ -185,27 +185,27 @@ discard block |
||
185 | 185 | $transaction_header = '<div style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;">'; |
186 | 186 | |
187 | 187 | // Remove payment id query param if set from request url. |
188 | - $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); |
|
188 | + $request_url_data = wp_parse_url($_SERVER['REQUEST_URI']); |
|
189 | 189 | $query = $request_url_data['query']; |
190 | - $query = remove_query_arg( array( 'preview_id' ), $query ); |
|
190 | + $query = remove_query_arg(array('preview_id'), $query); |
|
191 | 191 | |
192 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); |
|
192 | + $request_url = home_url('/?'.str_replace('', '', $query)); |
|
193 | 193 | |
194 | 194 | $transaction_header .= '<script> |
195 | 195 | function change_preview(){ |
196 | 196 | var transactions = document.getElementById("give_preview_email_payment_id"); |
197 | 197 | var selected_trans = transactions.options[transactions.selectedIndex]; |
198 | 198 | if (selected_trans){ |
199 | - var url_string = "' . $request_url . '&preview_id=" + selected_trans.value; |
|
199 | + var url_string = "' . $request_url.'&preview_id=" + selected_trans.value; |
|
200 | 200 | window.location = url_string; |
201 | 201 | } |
202 | 202 | } |
203 | 203 | </script>'; |
204 | 204 | |
205 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>'; |
|
205 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>'; |
|
206 | 206 | |
207 | 207 | //The select field with 100 latest transactions |
208 | - $transaction_header .= Give()->html->select( array( |
|
208 | + $transaction_header .= Give()->html->select(array( |
|
209 | 209 | 'name' => 'preview_email_payment_id', |
210 | 210 | 'selected' => $payment_id, |
211 | 211 | 'id' => 'give_preview_email_payment_id', |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | 'select_atts' => 'onchange="change_preview()"', |
216 | 216 | 'show_option_all' => false, |
217 | 217 | 'show_option_none' => false, |
218 | - ) ); |
|
218 | + )); |
|
219 | 219 | |
220 | 220 | //Closing tag |
221 | 221 | $transaction_header .= '</div>'; |
222 | 222 | |
223 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
223 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | \ No newline at end of file |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return static |
56 | 56 | */ |
57 | 57 | public static function get_instance() { |
58 | - if ( null === static::$instance ) { |
|
58 | + if (null === static::$instance) { |
|
59 | 59 | self::$instance = new static(); |
60 | 60 | } |
61 | 61 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @access public |
80 | 80 | */ |
81 | 81 | public function setup_hooks() { |
82 | - add_action( 'init', array( $this, 'load_translated_texts' ), 999 ); |
|
82 | + add_action('init', array($this, 'load_translated_texts'), 999); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool|WP_Error false on success otherwise WP_Error object |
112 | 112 | */ |
113 | - public static function add_text( $args = array() ) { |
|
113 | + public static function add_text($args = array()) { |
|
114 | 114 | $error = false; |
115 | 115 | |
116 | 116 | // Set text params. |
@@ -126,43 +126,43 @@ discard block |
||
126 | 126 | |
127 | 127 | try { |
128 | 128 | // Check for errors. |
129 | - if ( empty( $args['text'] ) ) { |
|
129 | + if (empty($args['text'])) { |
|
130 | 130 | /* @var WP_Error $error */ |
131 | - $error = new WP_Error( 'EMPTY_TEXT', __( 'Empty string is not allowed.', 'give' ), $args ); |
|
132 | - throw new Exception( $error->get_error_message( 'EMPTY_TEXT' ) ); |
|
131 | + $error = new WP_Error('EMPTY_TEXT', __('Empty string is not allowed.', 'give'), $args); |
|
132 | + throw new Exception($error->get_error_message('EMPTY_TEXT')); |
|
133 | 133 | |
134 | - } elseif ( empty( $args['id'] ) ) { |
|
134 | + } elseif (empty($args['id'])) { |
|
135 | 135 | /* @var WP_Error $error */ |
136 | - $error = new WP_Error( 'EMPTY_ID', __( 'Empty ID is not allowed.', 'give' ), $args ); |
|
137 | - throw new Exception( $error->get_error_message( 'EMPTY_ID' ) ); |
|
136 | + $error = new WP_Error('EMPTY_ID', __('Empty ID is not allowed.', 'give'), $args); |
|
137 | + throw new Exception($error->get_error_message('EMPTY_ID')); |
|
138 | 138 | |
139 | 139 | } elseif ( |
140 | - empty( $args['group'] ) && |
|
141 | - array_key_exists( $args['id'], self::$text_configs ) |
|
140 | + empty($args['group']) && |
|
141 | + array_key_exists($args['id'], self::$text_configs) |
|
142 | 142 | ) { |
143 | 143 | /* @var WP_Error $error */ |
144 | - $error = new WP_Error( 'TEXT_ID_ALREADY_EXIST', __( 'Text ID without group already exist.', 'give' ), $args ); |
|
145 | - throw new Exception( $error->get_error_message( 'TEXT_ID_ALREADY_EXIST' ) ); |
|
144 | + $error = new WP_Error('TEXT_ID_ALREADY_EXIST', __('Text ID without group already exist.', 'give'), $args); |
|
145 | + throw new Exception($error->get_error_message('TEXT_ID_ALREADY_EXIST')); |
|
146 | 146 | |
147 | 147 | } elseif ( |
148 | - ! empty( $args['group'] ) && |
|
149 | - ! empty( self::$text_configs[ $args['group'] ] ) && |
|
150 | - array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) |
|
148 | + ! empty($args['group']) && |
|
149 | + ! empty(self::$text_configs[$args['group']]) && |
|
150 | + array_key_exists($args['id'], self::$text_configs[$args['group']]) |
|
151 | 151 | ) { |
152 | 152 | /* @var WP_Error $error */ |
153 | - $error = new WP_Error( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __( 'Text ID with in group already exist.', 'give' ), $args ); |
|
154 | - throw new Exception( $error->get_error_message( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST' ) ); |
|
153 | + $error = new WP_Error('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __('Text ID with in group already exist.', 'give'), $args); |
|
154 | + throw new Exception($error->get_error_message('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST')); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add text. |
159 | - if ( ! empty( $args['group'] ) ) { |
|
160 | - self::$text_configs[ $args['group'] ][ $args['id'] ] = $args; |
|
159 | + if ( ! empty($args['group'])) { |
|
160 | + self::$text_configs[$args['group']][$args['id']] = $args; |
|
161 | 161 | } else { |
162 | - self::$text_configs[ $args['id'] ] = $args; |
|
162 | + self::$text_configs[$args['id']] = $args; |
|
163 | 163 | } |
164 | - } catch ( Exception $e ) { |
|
165 | - error_log( $e->getMessage() ); |
|
164 | + } catch (Exception $e) { |
|
165 | + error_log($e->getMessage()); |
|
166 | 166 | }// End try(). |
167 | 167 | |
168 | 168 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @since 2.0 |
172 | 172 | */ |
173 | - self::$text_configs = apply_filters( 'give_texts', self::$text_configs ); |
|
173 | + self::$text_configs = apply_filters('give_texts', self::$text_configs); |
|
174 | 174 | |
175 | 175 | return $error; |
176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public static function add_label( $args = array() ) { |
|
188 | + public static function add_label($args = array()) { |
|
189 | 189 | // Set text params. |
190 | 190 | $args = wp_parse_args( |
191 | 191 | $args, |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $args['type'] = 'label'; |
200 | 200 | $args['id'] = "{$args['id']}_label"; |
201 | 201 | |
202 | - return self::add_text( $args ); |
|
202 | + return self::add_text($args); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - public static function add_tooltip( $args = array() ) { |
|
215 | + public static function add_tooltip($args = array()) { |
|
216 | 216 | // Set text params. |
217 | 217 | $args = wp_parse_args( |
218 | 218 | $args, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $args['type'] = 'tooltip'; |
227 | 227 | $args['id'] = "{$args['id']}_tooltip"; |
228 | 228 | |
229 | - return self::add_text( $args ); |
|
229 | + return self::add_text($args); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return string |
241 | 241 | */ |
242 | - public static function add_translation( $args = array() ) { |
|
242 | + public static function add_translation($args = array()) { |
|
243 | 243 | $args = wp_parse_args( |
244 | 244 | $args, |
245 | 245 | array( |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | ); |
251 | 251 | |
252 | 252 | // Bailout. |
253 | - if ( empty( $args['id'] ) ) { |
|
253 | + if (empty($args['id'])) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | - if ( ! empty( $args['group'] ) ) { |
|
258 | - self::$text_translations[ $args['group'] ][ $args['id'] ] = $args['text']; |
|
257 | + if ( ! empty($args['group'])) { |
|
258 | + self::$text_translations[$args['group']][$args['id']] = $args['text']; |
|
259 | 259 | } else { |
260 | - self::$text_translations[ $args['id'] ] = $args['text']; |
|
260 | + self::$text_translations[$args['id']] = $args['text']; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return string |
275 | 275 | */ |
276 | - public static function add_label_translation( $id, $group = '', $text = '' ) { |
|
277 | - return self::get_text( array( |
|
276 | + public static function add_label_translation($id, $group = '', $text = '') { |
|
277 | + return self::get_text(array( |
|
278 | 278 | 'id' => "{$id}_label", |
279 | 279 | 'group' => $group, |
280 | 280 | 'text' => $text, |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return string |
295 | 295 | */ |
296 | - public static function add_tooltip_translation( $id, $group = '', $text = '' ) { |
|
297 | - return self::get_text( array( |
|
296 | + public static function add_tooltip_translation($id, $group = '', $text = '') { |
|
297 | + return self::get_text(array( |
|
298 | 298 | 'id' => "{$id}_label", |
299 | 299 | 'group' => $group, |
300 | 300 | 'text' => $text, |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return string |
314 | 314 | */ |
315 | - public static function get_label( $id, $group = '' ) { |
|
316 | - return self::get_text( array( |
|
315 | + public static function get_label($id, $group = '') { |
|
316 | + return self::get_text(array( |
|
317 | 317 | 'id' => "{$id}_label", |
318 | 318 | 'group' => $group, |
319 | 319 | 'type' => 'label', |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return string |
333 | 333 | */ |
334 | - public static function get_tooltip( $id, $group = '' ) { |
|
335 | - return self::get_text( array( |
|
334 | + public static function get_tooltip($id, $group = '') { |
|
335 | + return self::get_text(array( |
|
336 | 336 | 'id' => "{$id}_tooltip", |
337 | 337 | 'group' => $group, |
338 | 338 | 'type' => 'tooltip', |
339 | - ) ); |
|
339 | + )); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - public static function get_text( $args = array() ) { |
|
352 | + public static function get_text($args = array()) { |
|
353 | 353 | $text = ''; |
354 | 354 | |
355 | 355 | // Bailout. |
356 | - if ( empty( $args ) ) { |
|
356 | + if (empty($args)) { |
|
357 | 357 | return $text; |
358 | 358 | } |
359 | 359 | |
@@ -369,40 +369,40 @@ discard block |
||
369 | 369 | |
370 | 370 | // Check if text exist. |
371 | 371 | if ( |
372 | - empty( $args['id'] ) || |
|
373 | - ( empty( $args['group'] ) && ! array_key_exists( $args['id'], self::$text_configs ) ) || |
|
374 | - ( ! empty( $args['group'] ) && ! empty( self::$text_configs[ $args['group'] ] ) && ! array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) ) |
|
372 | + empty($args['id']) || |
|
373 | + (empty($args['group']) && ! array_key_exists($args['id'], self::$text_configs)) || |
|
374 | + ( ! empty($args['group']) && ! empty(self::$text_configs[$args['group']]) && ! array_key_exists($args['id'], self::$text_configs[$args['group']])) |
|
375 | 375 | ) { |
376 | 376 | return $text; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Get text value. |
380 | 380 | if ( |
381 | - ! empty( $args['group'] ) && |
|
382 | - array_key_exists( $args['group'], self::$text_configs ) |
|
381 | + ! empty($args['group']) && |
|
382 | + array_key_exists($args['group'], self::$text_configs) |
|
383 | 383 | ) { |
384 | - $text = self::$text_configs[ $args['group'] ][ $args['id'] ]['text']; |
|
384 | + $text = self::$text_configs[$args['group']][$args['id']]['text']; |
|
385 | 385 | |
386 | 386 | // Get translated text if exist. |
387 | 387 | if ( |
388 | - ! empty( self::$text_translations ) && |
|
389 | - ! empty( self::$text_translations[ $args['group'] ] ) && |
|
390 | - array_key_exists( $args['id'], self::$text_translations[ $args['group'] ] ) |
|
388 | + ! empty(self::$text_translations) && |
|
389 | + ! empty(self::$text_translations[$args['group']]) && |
|
390 | + array_key_exists($args['id'], self::$text_translations[$args['group']]) |
|
391 | 391 | ) { |
392 | - $text = self::$text_translations[ $args['group'] ][ $args['id'] ]; |
|
392 | + $text = self::$text_translations[$args['group']][$args['id']]; |
|
393 | 393 | } |
394 | 394 | } elseif ( |
395 | - empty( $args['group'] ) && |
|
396 | - array_key_exists( $args['id'], self::$text_configs ) |
|
395 | + empty($args['group']) && |
|
396 | + array_key_exists($args['id'], self::$text_configs) |
|
397 | 397 | ) { |
398 | - $text = self::$text_configs[ $args['id'] ]['text']; |
|
398 | + $text = self::$text_configs[$args['id']]['text']; |
|
399 | 399 | |
400 | 400 | // Get translated text if exist. |
401 | 401 | if ( |
402 | - ! empty( self::$text_translations ) && |
|
403 | - array_key_exists( $args['id'], self::$text_translations ) |
|
402 | + ! empty(self::$text_translations) && |
|
403 | + array_key_exists($args['id'], self::$text_translations) |
|
404 | 404 | ) { |
405 | - $text = self::$text_translations[ $args['id'] ]; |
|
405 | + $text = self::$text_translations[$args['id']]; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @since 2.0 |
413 | 413 | */ |
414 | - $text = apply_filters( 'give_text', $text, $args, self::$text_configs, self::$text_translations ); |
|
414 | + $text = apply_filters('give_text', $text, $args, self::$text_configs, self::$text_translations); |
|
415 | 415 | |
416 | 416 | return $text; |
417 | 417 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | $form_id = 0; |
168 | 168 | |
169 | 169 | // Set the form_id. |
170 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
170 | + if (isset($_POST['give-form-id'])) { |
|
171 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Need a URL to continue. If none, redirect back to single form. |
175 | - if ( empty( $url ) ) { |
|
176 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
175 | + if (empty($url)) { |
|
176 | + wp_safe_redirect(get_permalink($form_id)); |
|
177 | 177 | give_die(); |
178 | 178 | } |
179 | 179 | |
@@ -182,41 +182,41 @@ discard block |
||
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Set the $level_id. |
185 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
186 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
185 | + if (isset($_POST['give-price-id'])) { |
|
186 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check for backward compatibility. |
190 | - if ( is_string( $args ) ) { |
|
191 | - $args = str_replace( '?', '', $args ); |
|
190 | + if (is_string($args)) { |
|
191 | + $args = str_replace('?', '', $args); |
|
192 | 192 | } |
193 | 193 | |
194 | - $args = wp_parse_args( $args, $defaults ); |
|
194 | + $args = wp_parse_args($args, $defaults); |
|
195 | 195 | |
196 | 196 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
197 | - $url_data = wp_parse_url( $url ); |
|
197 | + $url_data = wp_parse_url($url); |
|
198 | 198 | |
199 | 199 | // Check if an array to prevent notices before parsing. |
200 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
201 | - parse_str( $url_data['query'], $query ); |
|
200 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
201 | + parse_str($url_data['query'], $query); |
|
202 | 202 | |
203 | 203 | // Precaution: don't allow any CC info. |
204 | - unset( $query['card_number'] ); |
|
205 | - unset( $query['card_cvc'] ); |
|
204 | + unset($query['card_number']); |
|
205 | + unset($query['card_cvc']); |
|
206 | 206 | |
207 | 207 | } else { |
208 | 208 | // No $url_data so pass empty array. |
209 | 209 | $query = array(); |
210 | 210 | } |
211 | 211 | |
212 | - $new_query = array_merge( $args, $query ); |
|
213 | - $new_query_string = http_build_query( $new_query ); |
|
212 | + $new_query = array_merge($args, $query); |
|
213 | + $new_query_string = http_build_query($new_query); |
|
214 | 214 | |
215 | 215 | // Assemble URL parts. |
216 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
216 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
217 | 217 | |
218 | 218 | // Redirect them. |
219 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
219 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
220 | 220 | give_die(); |
221 | 221 | |
222 | 222 | } |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_get_success_page_url( $query_string = null ) { |
|
235 | +function give_get_success_page_url($query_string = null) { |
|
236 | 236 | |
237 | - $success_page = give_get_option( 'success_page', 0 ); |
|
238 | - $success_page = get_permalink( $success_page ); |
|
237 | + $success_page = give_get_option('success_page', 0); |
|
238 | + $success_page = get_permalink($success_page); |
|
239 | 239 | |
240 | - if ( $query_string ) { |
|
240 | + if ($query_string) { |
|
241 | 241 | $success_page .= $query_string; |
242 | 242 | } |
243 | 243 | |
244 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
244 | + return apply_filters('give_success_page_url', $success_page); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
@@ -254,32 +254,31 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. |
256 | 256 | */ |
257 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
257 | +function give_get_failed_transaction_uri($extras = false) { |
|
258 | 258 | $give_options = give_get_settings(); |
259 | 259 | |
260 | 260 | // Remove question mark. |
261 | - if ( 0 === strpos( $extras, '?' ) ) { |
|
262 | - $extras = substr( $extras, 1 ); |
|
261 | + if (0 === strpos($extras, '?')) { |
|
262 | + $extras = substr($extras, 1); |
|
263 | 263 | } |
264 | 264 | |
265 | - $extras_args = wp_parse_args( $extras ); |
|
265 | + $extras_args = wp_parse_args($extras); |
|
266 | 266 | |
267 | 267 | // Set nonce if payment id exist in extra params. |
268 | - if ( array_key_exists( 'payment-id', $extras_args ) ) { |
|
269 | - $extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" ); |
|
270 | - $extras = http_build_query( $extras_args ); |
|
268 | + if (array_key_exists('payment-id', $extras_args)) { |
|
269 | + $extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}"); |
|
270 | + $extras = http_build_query($extras_args); |
|
271 | 271 | } |
272 | 272 | |
273 | - $uri = ! empty( $give_options['failure_page'] ) ? |
|
274 | - trailingslashit( get_permalink( $give_options['failure_page'] ) ) : |
|
275 | - home_url(); |
|
273 | + $uri = ! empty($give_options['failure_page']) ? |
|
274 | + trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
276 | 275 | |
277 | 276 | |
278 | - if ( $extras ) { |
|
277 | + if ($extras) { |
|
279 | 278 | $uri .= "?{$extras}"; |
280 | 279 | } |
281 | 280 | |
282 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
281 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
283 | 282 | } |
284 | 283 | |
285 | 284 | /** |
@@ -290,9 +289,9 @@ discard block |
||
290 | 289 | */ |
291 | 290 | function give_is_failed_transaction_page() { |
292 | 291 | $give_options = give_get_settings(); |
293 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
292 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
294 | 293 | |
295 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
294 | + return apply_filters('give_is_failure_page', $ret); |
|
296 | 295 | } |
297 | 296 | |
298 | 297 | /** |
@@ -305,25 +304,25 @@ discard block |
||
305 | 304 | */ |
306 | 305 | function give_listen_for_failed_payments() { |
307 | 306 | |
308 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
309 | - $payment_id = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0; |
|
310 | - $nonce = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false; |
|
307 | + $failed_page = give_get_option('failure_page', 0); |
|
308 | + $payment_id = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0; |
|
309 | + $nonce = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false; |
|
311 | 310 | |
312 | 311 | // Bailout. |
313 | - if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) { |
|
312 | + if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) { |
|
314 | 313 | return false; |
315 | 314 | } |
316 | 315 | |
317 | 316 | // Security check. |
318 | - if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) { |
|
319 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) ); |
|
317 | + if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) { |
|
318 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give')); |
|
320 | 319 | } |
321 | 320 | |
322 | 321 | // Set payment status to failure |
323 | - give_update_payment_status( $payment_id, 'failed' ); |
|
322 | + give_update_payment_status($payment_id, 'failed'); |
|
324 | 323 | } |
325 | 324 | |
326 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
325 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
327 | 326 | |
328 | 327 | /** |
329 | 328 | * Retrieve the Donation History page URI |
@@ -336,9 +335,9 @@ discard block |
||
336 | 335 | function give_get_history_page_uri() { |
337 | 336 | $give_options = give_get_settings(); |
338 | 337 | |
339 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
338 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
340 | 339 | |
341 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
340 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
342 | 341 | } |
343 | 342 | |
344 | 343 | /** |
@@ -351,11 +350,11 @@ discard block |
||
351 | 350 | * @since 1.0 |
352 | 351 | * @return bool |
353 | 352 | */ |
354 | -function give_field_is_required( $field = '', $form_id ) { |
|
353 | +function give_field_is_required($field = '', $form_id) { |
|
355 | 354 | |
356 | - $required_fields = give_get_required_fields( $form_id ); |
|
355 | + $required_fields = give_get_required_fields($form_id); |
|
357 | 356 | |
358 | - return array_key_exists( $field, $required_fields ); |
|
357 | + return array_key_exists($field, $required_fields); |
|
359 | 358 | } |
360 | 359 | |
361 | 360 | /** |
@@ -372,12 +371,12 @@ discard block |
||
372 | 371 | * |
373 | 372 | * @return void |
374 | 373 | */ |
375 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
374 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
376 | 375 | $log_data = array( |
377 | 376 | 'log_parent' => $payment_id, |
378 | 377 | 'log_type' => 'sale', |
379 | - 'log_date' => isset( $donation_date ) ? $donation_date : null, |
|
380 | - 'log_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
378 | + 'log_date' => isset($donation_date) ? $donation_date : null, |
|
379 | + 'log_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
381 | 380 | ); |
382 | 381 | |
383 | 382 | $log_meta = array( |
@@ -385,7 +384,7 @@ discard block |
||
385 | 384 | 'price_id' => (int) $price_id, |
386 | 385 | ); |
387 | 386 | |
388 | - Give()->logs->insert_log( $log_data, $log_meta ); |
|
387 | + Give()->logs->insert_log($log_data, $log_meta); |
|
389 | 388 | } |
390 | 389 | |
391 | 390 | |
@@ -399,11 +398,11 @@ discard block |
||
399 | 398 | * |
400 | 399 | * @return bool|int |
401 | 400 | */ |
402 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
401 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { |
|
403 | 402 | $quantity = (int) $quantity; |
404 | - $form = new Give_Donate_Form( $form_id ); |
|
403 | + $form = new Give_Donate_Form($form_id); |
|
405 | 404 | |
406 | - return $form->increase_sales( $quantity ); |
|
405 | + return $form->increase_sales($quantity); |
|
407 | 406 | } |
408 | 407 | |
409 | 408 | /** |
@@ -416,11 +415,11 @@ discard block |
||
416 | 415 | * |
417 | 416 | * @return bool|int |
418 | 417 | */ |
419 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
418 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
420 | 419 | $quantity = (int) $quantity; |
421 | - $form = new Give_Donate_Form( $form_id ); |
|
420 | + $form = new Give_Donate_Form($form_id); |
|
422 | 421 | |
423 | - return $form->decrease_sales( $quantity ); |
|
422 | + return $form->decrease_sales($quantity); |
|
424 | 423 | } |
425 | 424 | |
426 | 425 | /** |
@@ -433,10 +432,10 @@ discard block |
||
433 | 432 | * |
434 | 433 | * @return bool|int |
435 | 434 | */ |
436 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
437 | - $form = new Give_Donate_Form( $give_form_id ); |
|
435 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
436 | + $form = new Give_Donate_Form($give_form_id); |
|
438 | 437 | |
439 | - return $form->increase_earnings( $amount ); |
|
438 | + return $form->increase_earnings($amount); |
|
440 | 439 | } |
441 | 440 | |
442 | 441 | /** |
@@ -451,11 +450,11 @@ discard block |
||
451 | 450 | * |
452 | 451 | * @return bool|int |
453 | 452 | */ |
454 | -function give_decrease_form_earnings( $form_id = 0, $amount ) { |
|
453 | +function give_decrease_form_earnings($form_id = 0, $amount) { |
|
455 | 454 | |
456 | - $form = new Give_Donate_Form( $form_id ); |
|
455 | + $form = new Give_Donate_Form($form_id); |
|
457 | 456 | |
458 | - return $form->decrease_earnings( $amount ); |
|
457 | + return $form->decrease_earnings($amount); |
|
459 | 458 | } |
460 | 459 | |
461 | 460 | |
@@ -468,15 +467,15 @@ discard block |
||
468 | 467 | * |
469 | 468 | * @return int $earnings Earnings for a certain form |
470 | 469 | */ |
471 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
472 | - $give_form = new Give_Donate_Form( $form_id ); |
|
470 | +function give_get_form_earnings_stats($form_id = 0) { |
|
471 | + $give_form = new Give_Donate_Form($form_id); |
|
473 | 472 | |
474 | 473 | /** |
475 | 474 | * Filter the form earnings |
476 | 475 | * |
477 | 476 | * @since 1.8.17 |
478 | 477 | */ |
479 | - return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form ); |
|
478 | + return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form); |
|
480 | 479 | } |
481 | 480 | |
482 | 481 | |
@@ -489,8 +488,8 @@ discard block |
||
489 | 488 | * |
490 | 489 | * @return int $sales Amount of sales for a certain form |
491 | 490 | */ |
492 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
493 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
491 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
492 | + $give_form = new Give_Donate_Form($give_form_id); |
|
494 | 493 | |
495 | 494 | return $give_form->sales; |
496 | 495 | } |
@@ -505,16 +504,16 @@ discard block |
||
505 | 504 | * |
506 | 505 | * @return float $sales Average monthly sales |
507 | 506 | */ |
508 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
509 | - $sales = give_get_form_sales_stats( $form_id ); |
|
510 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
507 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
508 | + $sales = give_get_form_sales_stats($form_id); |
|
509 | + $release_date = get_post_field('post_date', $form_id); |
|
511 | 510 | |
512 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
511 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
513 | 512 | |
514 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
513 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
515 | 514 | |
516 | - if ( $months > 0 ) { |
|
517 | - $sales = ( $sales / $months ); |
|
515 | + if ($months > 0) { |
|
516 | + $sales = ($sales / $months); |
|
518 | 517 | } |
519 | 518 | |
520 | 519 | return $sales; |
@@ -530,16 +529,16 @@ discard block |
||
530 | 529 | * |
531 | 530 | * @return float $earnings Average monthly earnings |
532 | 531 | */ |
533 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
534 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
535 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
532 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
533 | + $earnings = give_get_form_earnings_stats($form_id); |
|
534 | + $release_date = get_post_field('post_date', $form_id); |
|
536 | 535 | |
537 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
536 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
538 | 537 | |
539 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
538 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
540 | 539 | |
541 | - if ( $months > 0 ) { |
|
542 | - $earnings = ( $earnings / $months ); |
|
540 | + if ($months > 0) { |
|
541 | + $earnings = ($earnings / $months); |
|
543 | 542 | } |
544 | 543 | |
545 | 544 | return $earnings < 0 ? 0 : $earnings; |
@@ -560,34 +559,34 @@ discard block |
||
560 | 559 | * |
561 | 560 | * @return string $price_name Name of the price option |
562 | 561 | */ |
563 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) { |
|
562 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) { |
|
564 | 563 | |
565 | - $prices = give_get_variable_prices( $form_id ); |
|
564 | + $prices = give_get_variable_prices($form_id); |
|
566 | 565 | $price_name = ''; |
567 | 566 | |
568 | - if ( false === $prices ) { |
|
567 | + if (false === $prices) { |
|
569 | 568 | return $price_name; |
570 | 569 | } |
571 | 570 | |
572 | - foreach ( $prices as $price ) { |
|
571 | + foreach ($prices as $price) { |
|
573 | 572 | |
574 | - if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) { |
|
573 | + if (intval($price['_give_id']['level_id']) === intval($price_id)) { |
|
575 | 574 | |
576 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
575 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
577 | 576 | $price_fallback = $use_fallback ? |
578 | 577 | give_currency_filter( |
579 | 578 | give_format_amount( |
580 | 579 | $price['_give_amount'], |
581 | - array( 'sanitize' => false ) |
|
580 | + array('sanitize' => false) |
|
582 | 581 | ), |
583 | - array( 'decode_currency' => true ) |
|
582 | + array('decode_currency' => true) |
|
584 | 583 | ) : ''; |
585 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
584 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
586 | 585 | |
587 | 586 | } |
588 | 587 | } |
589 | 588 | |
590 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
589 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
591 | 590 | } |
592 | 591 | |
593 | 592 | |
@@ -601,25 +600,25 @@ discard block |
||
601 | 600 | * |
602 | 601 | * @return string $range A fully formatted price range |
603 | 602 | */ |
604 | -function give_price_range( $form_id = 0, $formatted = true ) { |
|
605 | - $low = give_get_lowest_price_option( $form_id ); |
|
606 | - $high = give_get_highest_price_option( $form_id ); |
|
607 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
603 | +function give_price_range($form_id = 0, $formatted = true) { |
|
604 | + $low = give_get_lowest_price_option($form_id); |
|
605 | + $high = give_get_highest_price_option($form_id); |
|
606 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
608 | 607 | |
609 | 608 | $range = sprintf( |
610 | 609 | '<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep"> – </span><span class="give_price_range_%3$s">%4$s</span>', |
611 | 610 | 'asc' === $order_type ? 'low' : 'high', |
612 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), |
|
611 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), |
|
613 | 612 | 'asc' === $order_type ? 'high' : 'low', |
614 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) |
|
613 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) |
|
615 | 614 | |
616 | 615 | ); |
617 | 616 | |
618 | - if ( ! $formatted ) { |
|
619 | - $range = wp_strip_all_tags( $range ); |
|
617 | + if ( ! $formatted) { |
|
618 | + $range = wp_strip_all_tags($range); |
|
620 | 619 | } |
621 | 620 | |
622 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
621 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
623 | 622 | } |
624 | 623 | |
625 | 624 | |
@@ -634,35 +633,35 @@ discard block |
||
634 | 633 | * |
635 | 634 | * @return int ID of the lowest price |
636 | 635 | */ |
637 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
636 | +function give_get_lowest_price_id($form_id = 0) { |
|
638 | 637 | |
639 | - if ( empty( $form_id ) ) { |
|
638 | + if (empty($form_id)) { |
|
640 | 639 | $form_id = get_the_ID(); |
641 | 640 | } |
642 | 641 | |
643 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
644 | - return give_get_form_price( $form_id ); |
|
642 | + if ( ! give_has_variable_prices($form_id)) { |
|
643 | + return give_get_form_price($form_id); |
|
645 | 644 | } |
646 | 645 | |
647 | - $prices = give_get_variable_prices( $form_id ); |
|
646 | + $prices = give_get_variable_prices($form_id); |
|
648 | 647 | |
649 | 648 | $min = $min_id = 0; |
650 | 649 | |
651 | - if ( ! empty( $prices ) ) { |
|
650 | + if ( ! empty($prices)) { |
|
652 | 651 | |
653 | - foreach ( $prices as $key => $price ) { |
|
652 | + foreach ($prices as $key => $price) { |
|
654 | 653 | |
655 | - if ( empty( $price['_give_amount'] ) ) { |
|
654 | + if (empty($price['_give_amount'])) { |
|
656 | 655 | continue; |
657 | 656 | } |
658 | 657 | |
659 | - if ( ! isset( $min ) ) { |
|
658 | + if ( ! isset($min)) { |
|
660 | 659 | $min = $price['_give_amount']; |
661 | 660 | } else { |
662 | - $min = min( $min, $price['_give_amount'] ); |
|
661 | + $min = min($min, $price['_give_amount']); |
|
663 | 662 | } |
664 | 663 | |
665 | - if ( $price['_give_amount'] == $min ) { |
|
664 | + if ($price['_give_amount'] == $min) { |
|
666 | 665 | $min_id = $price['_give_id']['level_id']; |
667 | 666 | } |
668 | 667 | } |
@@ -680,22 +679,22 @@ discard block |
||
680 | 679 | * |
681 | 680 | * @return float Amount of the lowest price |
682 | 681 | */ |
683 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
684 | - if ( empty( $form_id ) ) { |
|
682 | +function give_get_lowest_price_option($form_id = 0) { |
|
683 | + if (empty($form_id)) { |
|
685 | 684 | $form_id = get_the_ID(); |
686 | 685 | } |
687 | 686 | |
688 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
689 | - return give_get_form_price( $form_id ); |
|
687 | + if ( ! give_has_variable_prices($form_id)) { |
|
688 | + return give_get_form_price($form_id); |
|
690 | 689 | } |
691 | 690 | |
692 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
691 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
693 | 692 | // Backward compatibility. |
694 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
695 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
693 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
694 | + $low = ! empty($prices) ? min($prices) : 0; |
|
696 | 695 | } |
697 | 696 | |
698 | - return give_maybe_sanitize_amount( $low ); |
|
697 | + return give_maybe_sanitize_amount($low); |
|
699 | 698 | } |
700 | 699 | |
701 | 700 | /** |
@@ -707,23 +706,23 @@ discard block |
||
707 | 706 | * |
708 | 707 | * @return float Amount of the highest price |
709 | 708 | */ |
710 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
709 | +function give_get_highest_price_option($form_id = 0) { |
|
711 | 710 | |
712 | - if ( empty( $form_id ) ) { |
|
711 | + if (empty($form_id)) { |
|
713 | 712 | $form_id = get_the_ID(); |
714 | 713 | } |
715 | 714 | |
716 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
717 | - return give_get_form_price( $form_id ); |
|
715 | + if ( ! give_has_variable_prices($form_id)) { |
|
716 | + return give_get_form_price($form_id); |
|
718 | 717 | } |
719 | 718 | |
720 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
719 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
721 | 720 | // Backward compatibility. |
722 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
723 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
721 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
722 | + $high = ! empty($prices) ? max($prices) : 0; |
|
724 | 723 | } |
725 | 724 | |
726 | - return give_maybe_sanitize_amount( $high ); |
|
725 | + return give_maybe_sanitize_amount($high); |
|
727 | 726 | } |
728 | 727 | |
729 | 728 | /** |
@@ -735,15 +734,15 @@ discard block |
||
735 | 734 | * |
736 | 735 | * @return mixed string|int Price of the form |
737 | 736 | */ |
738 | -function give_get_form_price( $form_id = 0 ) { |
|
737 | +function give_get_form_price($form_id = 0) { |
|
739 | 738 | |
740 | - if ( empty( $form_id ) ) { |
|
739 | + if (empty($form_id)) { |
|
741 | 740 | return false; |
742 | 741 | } |
743 | 742 | |
744 | - $form = new Give_Donate_Form( $form_id ); |
|
743 | + $form = new Give_Donate_Form($form_id); |
|
745 | 744 | |
746 | - return $form->__get( 'price' ); |
|
745 | + return $form->__get('price'); |
|
747 | 746 | } |
748 | 747 | |
749 | 748 | /** |
@@ -755,13 +754,13 @@ discard block |
||
755 | 754 | * |
756 | 755 | * @return mixed string|int Minimum price of the form |
757 | 756 | */ |
758 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
757 | +function give_get_form_minimum_price($form_id = 0) { |
|
759 | 758 | |
760 | - if ( empty( $form_id ) ) { |
|
759 | + if (empty($form_id)) { |
|
761 | 760 | return false; |
762 | 761 | } |
763 | 762 | |
764 | - $form = new Give_Donate_Form( $form_id ); |
|
763 | + $form = new Give_Donate_Form($form_id); |
|
765 | 764 | |
766 | 765 | return $form->get_minimum_price(); |
767 | 766 | |
@@ -778,48 +777,48 @@ discard block |
||
778 | 777 | * |
779 | 778 | * @return int $formatted_price |
780 | 779 | */ |
781 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
780 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
782 | 781 | $price = 0; |
783 | 782 | |
784 | - if ( empty( $form_id ) ) { |
|
783 | + if (empty($form_id)) { |
|
785 | 784 | $form_id = get_the_ID(); |
786 | 785 | } |
787 | 786 | |
788 | - if ( give_has_variable_prices( $form_id ) ) { |
|
787 | + if (give_has_variable_prices($form_id)) { |
|
789 | 788 | |
790 | - $prices = give_get_variable_prices( $form_id ); |
|
789 | + $prices = give_get_variable_prices($form_id); |
|
791 | 790 | |
792 | - if ( false !== $price_id ) { |
|
791 | + if (false !== $price_id) { |
|
793 | 792 | |
794 | 793 | // loop through multi-prices to see which is default |
795 | - foreach ( $prices as $price ) { |
|
794 | + foreach ($prices as $price) { |
|
796 | 795 | // this is the default price |
797 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
796 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
798 | 797 | $price = (float) $price['_give_amount']; |
799 | 798 | }; |
800 | 799 | } |
801 | 800 | } else { |
802 | 801 | |
803 | - $price = give_get_lowest_price_option( $form_id ); |
|
802 | + $price = give_get_lowest_price_option($form_id); |
|
804 | 803 | } |
805 | 804 | } else { |
806 | 805 | |
807 | - $price = give_get_form_price( $form_id ); |
|
806 | + $price = give_get_form_price($form_id); |
|
808 | 807 | } |
809 | 808 | |
810 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); |
|
811 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
812 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
809 | + $price = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); |
|
810 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
811 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
813 | 812 | |
814 | - if ( $echo ) { |
|
813 | + if ($echo) { |
|
815 | 814 | echo $formatted_price; |
816 | 815 | } else { |
817 | 816 | return $formatted_price; |
818 | 817 | } |
819 | 818 | } |
820 | 819 | |
821 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
822 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
820 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
821 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
823 | 822 | |
824 | 823 | |
825 | 824 | /** |
@@ -832,19 +831,19 @@ discard block |
||
832 | 831 | * |
833 | 832 | * @return float $amount Amount of the price option |
834 | 833 | */ |
835 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
836 | - $prices = give_get_variable_prices( $form_id ); |
|
834 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
835 | + $prices = give_get_variable_prices($form_id); |
|
837 | 836 | |
838 | 837 | $amount = 0.00; |
839 | 838 | |
840 | - foreach ( $prices as $price ) { |
|
841 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
842 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
839 | + foreach ($prices as $price) { |
|
840 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
841 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
843 | 842 | break; |
844 | 843 | }; |
845 | 844 | } |
846 | 845 | |
847 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); |
|
846 | + return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); |
|
848 | 847 | } |
849 | 848 | |
850 | 849 | /** |
@@ -856,13 +855,13 @@ discard block |
||
856 | 855 | * |
857 | 856 | * @return mixed string|int Goal of the form |
858 | 857 | */ |
859 | -function give_get_form_goal( $form_id = 0 ) { |
|
858 | +function give_get_form_goal($form_id = 0) { |
|
860 | 859 | |
861 | - if ( empty( $form_id ) ) { |
|
860 | + if (empty($form_id)) { |
|
862 | 861 | return false; |
863 | 862 | } |
864 | 863 | |
865 | - $form = new Give_Donate_Form( $form_id ); |
|
864 | + $form = new Give_Donate_Form($form_id); |
|
866 | 865 | |
867 | 866 | return $form->goal; |
868 | 867 | |
@@ -877,13 +876,13 @@ discard block |
||
877 | 876 | * |
878 | 877 | * @return mixed string|int Goal of the form |
879 | 878 | */ |
880 | -function give_get_form_goal_format( $form_id = 0 ) { |
|
879 | +function give_get_form_goal_format($form_id = 0) { |
|
881 | 880 | |
882 | - if ( empty( $form_id ) ) { |
|
881 | + if (empty($form_id)) { |
|
883 | 882 | return false; |
884 | 883 | } |
885 | 884 | |
886 | - return give_get_meta( $form_id, '_give_goal_format', true ); |
|
885 | + return give_get_meta($form_id, '_give_goal_format', true); |
|
887 | 886 | |
888 | 887 | } |
889 | 888 | |
@@ -897,19 +896,19 @@ discard block |
||
897 | 896 | * |
898 | 897 | * @return string $formatted_goal |
899 | 898 | */ |
900 | -function give_goal( $form_id = 0, $echo = true ) { |
|
899 | +function give_goal($form_id = 0, $echo = true) { |
|
901 | 900 | |
902 | - if ( empty( $form_id ) ) { |
|
901 | + if (empty($form_id)) { |
|
903 | 902 | $form_id = get_the_ID(); |
904 | 903 | } |
905 | 904 | |
906 | - $goal = give_get_form_goal( $form_id ); |
|
905 | + $goal = give_get_form_goal($form_id); |
|
907 | 906 | $goal_format = give_get_form_goal_format($form_id); |
908 | 907 | |
909 | - if ( 'donation' === $goal_format ) { |
|
908 | + if ('donation' === $goal_format) { |
|
910 | 909 | $goal = "{$goal} donations"; |
911 | 910 | } else { |
912 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); |
|
911 | + $goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); |
|
913 | 912 | } |
914 | 913 | |
915 | 914 | $formatted_goal = sprintf( |
@@ -917,17 +916,17 @@ discard block |
||
917 | 916 | $form_id, |
918 | 917 | $goal |
919 | 918 | ); |
920 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
919 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
921 | 920 | |
922 | - if ( $echo ) { |
|
921 | + if ($echo) { |
|
923 | 922 | echo $formatted_goal; |
924 | 923 | } else { |
925 | 924 | return $formatted_goal; |
926 | 925 | } |
927 | 926 | } |
928 | 927 | |
929 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
930 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
928 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
929 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
931 | 930 | |
932 | 931 | |
933 | 932 | /** |
@@ -939,15 +938,15 @@ discard block |
||
939 | 938 | * |
940 | 939 | * @return bool $ret Whether or not the logged_in_only setting is set |
941 | 940 | */ |
942 | -function give_logged_in_only( $form_id ) { |
|
941 | +function give_logged_in_only($form_id) { |
|
943 | 942 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
944 | 943 | // Otherwise it is member only donation form. |
945 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
946 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
944 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
945 | + $val = ! empty($val) ? $val : 'enabled'; |
|
947 | 946 | |
948 | - $ret = ! give_is_setting_enabled( $val ); |
|
947 | + $ret = ! give_is_setting_enabled($val); |
|
949 | 948 | |
950 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
949 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
951 | 950 | } |
952 | 951 | |
953 | 952 | |
@@ -960,11 +959,11 @@ discard block |
||
960 | 959 | * |
961 | 960 | * @return string |
962 | 961 | */ |
963 | -function give_show_login_register_option( $form_id ) { |
|
962 | +function give_show_login_register_option($form_id) { |
|
964 | 963 | |
965 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
964 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
966 | 965 | |
967 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
966 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
968 | 967 | |
969 | 968 | } |
970 | 969 | |
@@ -980,12 +979,12 @@ discard block |
||
980 | 979 | * |
981 | 980 | * @return array |
982 | 981 | */ |
983 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
982 | +function _give_get_prefill_form_field_values($form_id) { |
|
984 | 983 | $logged_in_donor_info = array(); |
985 | 984 | |
986 | - if ( is_user_logged_in() ) : |
|
987 | - $donor_data = get_userdata( get_current_user_id() ); |
|
988 | - $donor_address = give_get_donor_address( get_current_user_id() ); |
|
985 | + if (is_user_logged_in()) : |
|
986 | + $donor_data = get_userdata(get_current_user_id()); |
|
987 | + $donor_address = give_get_donor_address(get_current_user_id()); |
|
989 | 988 | |
990 | 989 | $logged_in_donor_info = array( |
991 | 990 | // First name. |
@@ -1019,21 +1018,21 @@ discard block |
||
1019 | 1018 | |
1020 | 1019 | // Bailout: Auto fill form field values only form form which donor is donating. |
1021 | 1020 | if ( |
1022 | - empty( $_GET['form-id'] ) |
|
1021 | + empty($_GET['form-id']) |
|
1023 | 1022 | || ! $form_id |
1024 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
1023 | + || ($form_id !== absint($_GET['form-id'])) |
|
1025 | 1024 | ) { |
1026 | 1025 | return $logged_in_donor_info; |
1027 | 1026 | } |
1028 | 1027 | |
1029 | 1028 | // Get purchase data. |
1030 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
1029 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
1031 | 1030 | |
1032 | 1031 | // Get donor info from form data. |
1033 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
1032 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
1034 | 1033 | ? array() |
1035 | 1034 | : $give_purchase_data['post_data']; |
1036 | 1035 | |
1037 | 1036 | // Output. |
1038 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
1037 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
1039 | 1038 | } |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @since 1.0 |
21 | 21 | */ |
22 | -class Give_Forms_Widget extends WP_Widget{ |
|
22 | +class Give_Forms_Widget extends WP_Widget { |
|
23 | 23 | /** |
24 | 24 | * The widget class name |
25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Instantiate the class |
32 | 32 | */ |
33 | - public function __construct(){ |
|
34 | - $this->self = get_class( $this ); |
|
33 | + public function __construct() { |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,19 +52,19 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ){ |
|
55 | + public function admin_widget_scripts($hook) { |
|
56 | 56 | // Directories of assets |
57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
60 | 60 | |
61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
63 | 63 | |
64 | 64 | // Widget Script |
65 | - if ( $hook == 'widgets.php' ) { |
|
65 | + if ($hook == 'widgets.php') { |
|
66 | 66 | |
67 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
67 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * before_widget, and after_widget. |
76 | 76 | * @param array $instance The settings for the particular instance of the widget. |
77 | 77 | */ |
78 | - public function widget( $args, $instance ){ |
|
79 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
80 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
78 | + public function widget($args, $instance) { |
|
79 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
80 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
81 | 81 | |
82 | 82 | echo $args['before_widget']; |
83 | 83 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @since 1.0 |
88 | 88 | */ |
89 | - do_action( 'give_before_forms_widget' ); |
|
89 | + do_action('give_before_forms_widget'); |
|
90 | 90 | |
91 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
91 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
92 | 92 | |
93 | - give_get_donation_form( $instance ); |
|
93 | + give_get_donation_form($instance); |
|
94 | 94 | |
95 | 95 | echo $args['after_widget']; |
96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @since 1.0 |
101 | 101 | */ |
102 | - do_action( 'give_after_forms_widget' ); |
|
102 | + do_action('give_after_forms_widget'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function form( $instance ){ |
|
112 | + public function form($instance) { |
|
113 | 113 | $defaults = array( |
114 | 114 | 'title' => '', |
115 | 115 | 'id' => '', |
@@ -119,84 +119,84 @@ discard block |
||
119 | 119 | 'continue_button_title' => '', |
120 | 120 | ); |
121 | 121 | |
122 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
122 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
123 | 123 | |
124 | 124 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
125 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
125 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
126 | 126 | |
127 | 127 | // Query Give Forms |
128 | 128 | $args = array( |
129 | 129 | 'post_type' => 'give_forms', |
130 | - 'posts_per_page' => - 1, |
|
130 | + 'posts_per_page' => -1, |
|
131 | 131 | 'post_status' => 'publish', |
132 | 132 | ); |
133 | 133 | |
134 | - $give_forms = get_posts( $args ); |
|
134 | + $give_forms = get_posts($args); |
|
135 | 135 | ?> |
136 | 136 | <div class="give_forms_widget_container"> |
137 | 137 | |
138 | 138 | <?php // Widget: widget Title. ?> |
139 | 139 | <p> |
140 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
141 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
142 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
140 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
141 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
142 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
143 | 143 | </p> |
144 | 144 | |
145 | 145 | <?php // Widget: Give Form?> |
146 | 146 | <p> |
147 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
148 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
149 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
150 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
151 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
152 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option> |
|
147 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
148 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
149 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
150 | + <?php foreach ($give_forms as $give_form) { ?> |
|
151 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
152 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option> |
|
153 | 153 | <?php } ?> |
154 | 154 | </select><br> |
155 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
155 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
156 | 156 | </p> |
157 | 157 | |
158 | 158 | <?php // Widget: Display Style ?> |
159 | 159 | <p class="give_forms_display_style_setting_row"> |
160 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
161 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
162 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
163 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
164 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
160 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
161 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
162 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
163 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
164 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
165 | 165 | <small class="give-field-description"> |
166 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
166 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
167 | 167 | </small> |
168 | 168 | </p> |
169 | 169 | |
170 | 170 | <?php // Widget: Continue Button Title. ?> |
171 | 171 | <p class="give_forms_continue_button_title_setting_row"> |
172 | - <label for="<?php echo $this->get_field_id( 'continue_button_title' ); ?>"><?php esc_html_e( 'Button Text:', 'give' ); ?></label> |
|
173 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'continue_button_title' ); ?>" name="<?php echo $this->get_field_name( 'continue_button_title' ); ?>" value="<?php esc_attr_e( $instance['continue_button_title'] ); ?>" /><br> |
|
174 | - <small class="give-field-description"><?php esc_html_e( 'The button label for displaying the additional payment fields.', 'give' ); ?></small> |
|
172 | + <label for="<?php echo $this->get_field_id('continue_button_title'); ?>"><?php esc_html_e('Button Text:', 'give'); ?></label> |
|
173 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('continue_button_title'); ?>" name="<?php echo $this->get_field_name('continue_button_title'); ?>" value="<?php esc_attr_e($instance['continue_button_title']); ?>" /><br> |
|
174 | + <small class="give-field-description"><?php esc_html_e('The button label for displaying the additional payment fields.', 'give'); ?></small> |
|
175 | 175 | </p> |
176 | 176 | |
177 | 177 | <?php // Widget: Floating Labels ?> |
178 | 178 | <p> |
179 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
180 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
181 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
182 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
179 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
180 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
181 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
182 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
183 | 183 | <small class="give-field-description"> |
184 | 184 | <?php |
185 | 185 | printf( |
186 | 186 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
187 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
188 | - esc_url( 'http://docs.givewp.com/form-floating-labels' ) |
|
187 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
188 | + esc_url('http://docs.givewp.com/form-floating-labels') |
|
189 | 189 | ); |
190 | 190 | ?></small> |
191 | 191 | </p> |
192 | 192 | |
193 | 193 | <?php // Widget: Display Content ?> |
194 | 194 | <p> |
195 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
196 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
197 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
198 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
199 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
195 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
196 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
197 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
198 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
199 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
200 | 200 | </div> |
201 | 201 | <?php |
202 | 202 | } |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return void |
208 | 208 | */ |
209 | - function widget_init(){ |
|
210 | - register_widget( $this->self ); |
|
209 | + function widget_init() { |
|
210 | + register_widget($this->self); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function update( $new_instance, $old_instance ){ |
|
221 | + public function update($new_instance, $old_instance) { |
|
222 | 222 | $this->flush_widget_cache(); |
223 | 223 | |
224 | 224 | return $new_instance; |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return void |
231 | 231 | */ |
232 | - public function flush_widget_cache(){ |
|
233 | - wp_cache_delete( $this->self, 'widget' ); |
|
232 | + public function flush_widget_cache() { |
|
233 | + wp_cache_delete($this->self, 'widget'); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 |
@@ -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 | |
@@ -75,40 +75,40 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function __construct() { |
77 | 77 | // Bailout. |
78 | - if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) { |
|
78 | + if (empty($this->supports) || ! $this->is_custom_meta_table_active()) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - if ( in_array( 'add_post_metadata', $this->supports ) ) { |
|
83 | - add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 ); |
|
82 | + if (in_array('add_post_metadata', $this->supports)) { |
|
83 | + add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5); |
|
84 | 84 | } |
85 | 85 | |
86 | - if ( in_array( 'get_post_metadata', $this->supports ) ) { |
|
87 | - add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 0, 4 ); |
|
86 | + if (in_array('get_post_metadata', $this->supports)) { |
|
87 | + add_filter('get_post_metadata', array($this, '__get_meta'), 0, 4); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( in_array( 'update_post_metadata', $this->supports ) ) { |
|
91 | - add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 ); |
|
90 | + if (in_array('update_post_metadata', $this->supports)) { |
|
91 | + add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( in_array( 'delete_post_metadata', $this->supports ) ) { |
|
95 | - add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 ); |
|
94 | + if (in_array('delete_post_metadata', $this->supports)) { |
|
95 | + add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( in_array( 'posts_where', $this->supports ) ) { |
|
99 | - add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
98 | + if (in_array('posts_where', $this->supports)) { |
|
99 | + add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
100 | 100 | } |
101 | 101 | |
102 | - if ( in_array( 'posts_join', $this->supports ) ) { |
|
103 | - add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
102 | + if (in_array('posts_join', $this->supports)) { |
|
103 | + add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( in_array( 'posts_groupby', $this->supports ) ) { |
|
107 | - add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
106 | + if (in_array('posts_groupby', $this->supports)) { |
|
107 | + add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
108 | 108 | } |
109 | 109 | |
110 | - if ( in_array( 'posts_orderby', $this->supports ) ) { |
|
111 | - add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
110 | + if (in_array('posts_orderby', $this->supports)) { |
|
111 | + add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -126,16 +126,16 @@ discard block |
||
126 | 126 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
127 | 127 | * is true. |
128 | 128 | */ |
129 | - public function get_meta( $id = 0, $meta_key = '', $single = false ) { |
|
130 | - $id = $this->sanitize_id( $id ); |
|
129 | + public function get_meta($id = 0, $meta_key = '', $single = false) { |
|
130 | + $id = $this->sanitize_id($id); |
|
131 | 131 | |
132 | 132 | // Bailout. |
133 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
133 | + if ( ! $this->is_valid_post_type($id)) { |
|
134 | 134 | return $this->check; |
135 | 135 | } |
136 | 136 | |
137 | - if ( $this->raw_result ) { |
|
138 | - if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) { |
|
137 | + if ($this->raw_result) { |
|
138 | + if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) { |
|
139 | 139 | $value = ''; |
140 | 140 | } |
141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $this->raw_result = false; |
144 | 144 | |
145 | 145 | } else { |
146 | - $value = get_metadata( $this->meta_type, $id, $meta_key, $single ); |
|
146 | + $value = get_metadata($this->meta_type, $id, $meta_key, $single); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $value; |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return int|bool False for failure. True for success. |
167 | 167 | */ |
168 | - public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
169 | - $id = $this->sanitize_id( $id ); |
|
168 | + public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
169 | + $id = $this->sanitize_id($id); |
|
170 | 170 | |
171 | 171 | // Bailout. |
172 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
172 | + if ( ! $this->is_valid_post_type($id)) { |
|
173 | 173 | return $this->check; |
174 | 174 | } |
175 | 175 | |
176 | - $meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
|
176 | + $meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique); |
|
177 | 177 | |
178 | - if ( $meta_id ) { |
|
179 | - $this->delete_cache( $id ); |
|
178 | + if ($meta_id) { |
|
179 | + $this->delete_cache($id); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | return $meta_id; |
@@ -202,18 +202,18 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return int|bool False on failure, true if success. |
204 | 204 | */ |
205 | - public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
206 | - $id = $this->sanitize_id( $id ); |
|
205 | + public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
206 | + $id = $this->sanitize_id($id); |
|
207 | 207 | |
208 | 208 | // Bailout. |
209 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
209 | + if ( ! $this->is_valid_post_type($id)) { |
|
210 | 210 | return $this->check; |
211 | 211 | } |
212 | 212 | |
213 | - $meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
|
213 | + $meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value); |
|
214 | 214 | |
215 | - if ( $meta_id ) { |
|
216 | - $this->delete_cache( $id ); |
|
215 | + if ($meta_id) { |
|
216 | + $this->delete_cache($id); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | return $meta_id; |
@@ -236,18 +236,18 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return bool False for failure. True for success. |
238 | 238 | */ |
239 | - public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
|
240 | - $id = $this->sanitize_id( $id ); |
|
239 | + public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') { |
|
240 | + $id = $this->sanitize_id($id); |
|
241 | 241 | |
242 | 242 | // Bailout. |
243 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
243 | + if ( ! $this->is_valid_post_type($id)) { |
|
244 | 244 | return $this->check; |
245 | 245 | } |
246 | 246 | |
247 | - $is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
|
247 | + $is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all); |
|
248 | 248 | |
249 | - if ( $is_meta_deleted ) { |
|
250 | - $this->delete_cache( $id ); |
|
249 | + if ($is_meta_deleted) { |
|
250 | + $this->delete_cache($id); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | return $is_meta_deleted; |
@@ -264,41 +264,41 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function __rename_meta_table_name_in_query( $clause, $wp_query ) { |
|
267 | + public function __rename_meta_table_name_in_query($clause, $wp_query) { |
|
268 | 268 | global $wpdb; |
269 | 269 | |
270 | 270 | // Add new table to sql query. |
271 | - if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) { |
|
272 | - $clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause ); |
|
273 | - $clause = str_replace( $wpdb->postmeta, $this->table_name, $clause ); |
|
271 | + if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) { |
|
272 | + $clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause); |
|
273 | + $clause = str_replace($wpdb->postmeta, $this->table_name, $clause); |
|
274 | 274 | |
275 | - switch( current_filter() ) { |
|
275 | + switch (current_filter()) { |
|
276 | 276 | case 'posts_join': |
277 | - $joins = array( 'INNER JOIN', 'LEFT JOIN' ); |
|
277 | + $joins = array('INNER JOIN', 'LEFT JOIN'); |
|
278 | 278 | |
279 | - foreach ( $joins as $join ) { |
|
280 | - if( false !== strpos( $clause, $join ) ) { |
|
281 | - $clause = explode( $join, $clause ); |
|
279 | + foreach ($joins as $join) { |
|
280 | + if (false !== strpos($clause, $join)) { |
|
281 | + $clause = explode($join, $clause); |
|
282 | 282 | |
283 | - foreach ( $clause as $key => $clause_part ) { |
|
284 | - if( empty( $clause_part ) ) { |
|
283 | + foreach ($clause as $key => $clause_part) { |
|
284 | + if (empty($clause_part)) { |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
288 | - preg_match( '/wp_give_paymentmeta AS (.*) ON/', $clause_part, $alias_table_name ); |
|
288 | + preg_match('/wp_give_paymentmeta AS (.*) ON/', $clause_part, $alias_table_name); |
|
289 | 289 | |
290 | - if( isset( $alias_table_name[1] ) ) { |
|
291 | - $clause[$key] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part ); |
|
290 | + if (isset($alias_table_name[1])) { |
|
291 | + $clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | - $clause = implode( "{$join} ", $clause ); |
|
295 | + $clause = implode("{$join} ", $clause); |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | break; |
299 | 299 | |
300 | 300 | case 'posts_where': |
301 | - $clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( "mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id" ), $clause ); |
|
301 | + $clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array("mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id"), $clause); |
|
302 | 302 | break; |
303 | 303 | } |
304 | 304 | } |
@@ -317,19 +317,19 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return bool |
319 | 319 | */ |
320 | - protected function is_post_type_query( $wp_query ) { |
|
320 | + protected function is_post_type_query($wp_query) { |
|
321 | 321 | $status = false; |
322 | 322 | |
323 | 323 | // Check if it is payment query. |
324 | - if ( ! empty( $wp_query->query['post_type'] ) ) { |
|
324 | + if ( ! empty($wp_query->query['post_type'])) { |
|
325 | 325 | if ( |
326 | - is_string( $wp_query->query['post_type'] ) && |
|
326 | + is_string($wp_query->query['post_type']) && |
|
327 | 327 | $this->post_type === $wp_query->query['post_type'] |
328 | 328 | ) { |
329 | 329 | $status = true; |
330 | 330 | } elseif ( |
331 | - is_array( $wp_query->query['post_type'] ) && |
|
332 | - in_array( $this->post_type, $wp_query->query['post_type'] ) |
|
331 | + is_array($wp_query->query['post_type']) && |
|
332 | + in_array($this->post_type, $wp_query->query['post_type']) |
|
333 | 333 | ) { |
334 | 334 | $status = true; |
335 | 335 | } |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - protected function is_valid_post_type( $ID ) { |
|
352 | - return $ID && ( $this->post_type === get_post_type( $ID ) ); |
|
351 | + protected function is_valid_post_type($ID) { |
|
352 | + return $ID && ($this->post_type === get_post_type($ID)); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | * |
376 | 376 | * @return void |
377 | 377 | */ |
378 | - private function delete_cache( $id, $meta_type = '' ) { |
|
379 | - $meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type; |
|
378 | + private function delete_cache($id, $meta_type = '') { |
|
379 | + $meta_type = empty($meta_type) ? $this->meta_type : $meta_type; |
|
380 | 380 | |
381 | 381 | $group = array( |
382 | 382 | // 'form' => 'give-forms', |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | // 'log' => 'give-logs', |
387 | 387 | ); |
388 | 388 | |
389 | - if ( array_key_exists( $meta_type, $group ) ) { |
|
390 | - Give_Cache::delete_group( $id, $group[ $meta_type ] ); |
|
389 | + if (array_key_exists($meta_type, $group)) { |
|
390 | + Give_Cache::delete_group($id, $group[$meta_type]); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return mixed |
404 | 404 | */ |
405 | - public function __call( $name, $arguments ) { |
|
406 | - switch ( $name ) { |
|
405 | + public function __call($name, $arguments) { |
|
406 | + switch ($name) { |
|
407 | 407 | case '__add_meta': |
408 | 408 | $this->check = $arguments[0]; |
409 | 409 | $id = $arguments[1]; |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | $unique = $arguments[4]; |
413 | 413 | |
414 | 414 | // Bailout. |
415 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
415 | + if ( ! $this->is_valid_post_type($id)) { |
|
416 | 416 | return $this->check; |
417 | 417 | } |
418 | 418 | |
419 | - return $this->add_meta( $id, $meta_key, $meta_value, $unique ); |
|
419 | + return $this->add_meta($id, $meta_key, $meta_value, $unique); |
|
420 | 420 | |
421 | 421 | case '__get_meta': |
422 | 422 | $this->check = $arguments[0]; |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | $single = $arguments[3]; |
426 | 426 | |
427 | 427 | // Bailout. |
428 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
428 | + if ( ! $this->is_valid_post_type($id)) { |
|
429 | 429 | return $this->check; |
430 | 430 | } |
431 | 431 | |
432 | 432 | $this->raw_result = true; |
433 | 433 | |
434 | - return $this->get_meta( $id, $meta_key, $single ); |
|
434 | + return $this->get_meta($id, $meta_key, $single); |
|
435 | 435 | |
436 | 436 | case '__update_meta': |
437 | 437 | $this->check = $arguments[0]; |
@@ -440,11 +440,11 @@ discard block |
||
440 | 440 | $meta_value = $arguments[3]; |
441 | 441 | |
442 | 442 | // Bailout. |
443 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
443 | + if ( ! $this->is_valid_post_type($id)) { |
|
444 | 444 | return $this->check; |
445 | 445 | } |
446 | 446 | |
447 | - return $this->update_meta( $id, $meta_key, $meta_value ); |
|
447 | + return $this->update_meta($id, $meta_key, $meta_value); |
|
448 | 448 | |
449 | 449 | case '__delete_meta': |
450 | 450 | $this->check = $arguments[0]; |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | $delete_all = $arguments[3]; |
455 | 455 | |
456 | 456 | // Bailout. |
457 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
457 | + if ( ! $this->is_valid_post_type($id)) { |
|
458 | 458 | return $this->check; |
459 | 459 | } |
460 | 460 | |
461 | - return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all ); |
|
461 | + return $this->delete_meta($id, $meta_key, $meta_value, $delete_all); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | } |
465 | 465 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @category Class |
12 | 12 | * @author WordImpress |
13 | 13 | */ |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * and data exists in the queue. |
43 | 43 | */ |
44 | 44 | public function handle_cron_healthcheck() { |
45 | - if ( $this->is_process_running() ) { |
|
45 | + if ($this->is_process_running()) { |
|
46 | 46 | // Background process already running. |
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | - if ( $this->is_queue_empty() ) { |
|
50 | + if ($this->is_queue_empty()) { |
|
51 | 51 | // No data to process. |
52 | 52 | $this->clear_scheduled_event(); |
53 | 53 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * Schedule fallback event. |
62 | 62 | */ |
63 | 63 | protected function schedule_event() { |
64 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { |
|
65 | - wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
64 | + if ( ! wp_next_scheduled($this->cron_hook_identifier)) { |
|
65 | + wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return mixed |
80 | 80 | */ |
81 | - protected function task( $update ) { |
|
82 | - if ( empty( $update ) ) { |
|
81 | + protected function task($update) { |
|
82 | + if (empty($update)) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
@@ -93,29 +93,29 @@ discard block |
||
93 | 93 | 'update_info' => $update, |
94 | 94 | 'step' => 1, |
95 | 95 | 'update' => 1, |
96 | - 'heading' => sprintf( 'Update %s of {update_count}', 1 ), |
|
96 | + 'heading' => sprintf('Update %s of {update_count}', 1), |
|
97 | 97 | 'percentage' => $give_updates->percentage, |
98 | 98 | ) |
99 | 99 | ); |
100 | 100 | |
101 | 101 | // Continuously skip update if previous update does not complete yet. |
102 | - if( |
|
102 | + if ( |
|
103 | 103 | $resume_update['update_info']['id'] !== $update['id'] && |
104 | - ! give_has_upgrade_completed( $resume_update['update_info']['id'] ) |
|
104 | + ! give_has_upgrade_completed($resume_update['update_info']['id']) |
|
105 | 105 | ) { |
106 | 106 | return $update; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // Set params. |
110 | 110 | $resume_update['update_info'] = $update; |
111 | - $give_updates->step = absint( $resume_update['step'] ); |
|
112 | - $give_updates->update = absint( $resume_update['update'] ); |
|
113 | - $is_parent_update_completed = $give_updates->is_parent_updates_completed( $update ); |
|
111 | + $give_updates->step = absint($resume_update['step']); |
|
112 | + $give_updates->update = absint($resume_update['update']); |
|
113 | + $is_parent_update_completed = $give_updates->is_parent_updates_completed($update); |
|
114 | 114 | |
115 | 115 | // Skip update if dependency update does not complete yet. |
116 | - if ( empty( $is_parent_update_completed ) ) { |
|
116 | + if (empty($is_parent_update_completed)) { |
|
117 | 117 | // @todo: set error when you have only one update with invalid dependency |
118 | - if ( ! is_null( $is_parent_update_completed ) ) { |
|
118 | + if ( ! is_null($is_parent_update_completed)) { |
|
119 | 119 | return $update; |
120 | 120 | } |
121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | Give_Cache::disable(); |
127 | 127 | |
128 | 128 | // Run update. |
129 | - if ( is_array( $update['callback'] ) ) { |
|
129 | + if (is_array($update['callback'])) { |
|
130 | 130 | $update['callback'][0]->$update['callback'][1](); |
131 | 131 | } else { |
132 | 132 | $update['callback'](); |
@@ -135,21 +135,21 @@ discard block |
||
135 | 135 | // Set update info. |
136 | 136 | $doing_upgrade_args = array( |
137 | 137 | 'update_info' => $update, |
138 | - 'step' => ++ $give_updates->step, |
|
138 | + 'step' => ++$give_updates->step, |
|
139 | 139 | 'update' => $give_updates->update, |
140 | - 'heading' => sprintf( 'Update %s of %s', $give_updates->update, get_option( 'give_db_update_count' ) ), |
|
140 | + 'heading' => sprintf('Update %s of %s', $give_updates->update, get_option('give_db_update_count')), |
|
141 | 141 | 'percentage' => $give_updates->percentage, |
142 | 142 | 'total_percentage' => $give_updates->get_db_update_processing_percentage(), |
143 | 143 | ); |
144 | 144 | |
145 | 145 | // Cache upgrade. |
146 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
146 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
147 | 147 | |
148 | 148 | // Enable cache. |
149 | 149 | Give_Cache::enable(); |
150 | 150 | |
151 | 151 | // Check if current update completed or not. |
152 | - if ( give_has_upgrade_completed( $update['id'] ) ) { |
|
152 | + if (give_has_upgrade_completed($update['id'])) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | protected function complete() { |
166 | 166 | parent::complete(); |
167 | 167 | |
168 | - delete_option( 'give_db_update_count' ); |
|
169 | - delete_option( 'give_doing_upgrade' ); |
|
170 | - add_option( 'give_show_db_upgrade_complete_notice', 1, '', 'no' ); |
|
168 | + delete_option('give_db_update_count'); |
|
169 | + delete_option('give_doing_upgrade'); |
|
170 | + add_option('give_show_db_upgrade_complete_notice', 1, '', 'no'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -176,18 +176,18 @@ discard block |
||
176 | 176 | * @return int |
177 | 177 | */ |
178 | 178 | protected function get_memory_limit() { |
179 | - if ( function_exists( 'ini_get' ) ) { |
|
180 | - $memory_limit = ini_get( 'memory_limit' ); |
|
179 | + if (function_exists('ini_get')) { |
|
180 | + $memory_limit = ini_get('memory_limit'); |
|
181 | 181 | } else { |
182 | 182 | // Sensible default. |
183 | 183 | $memory_limit = '128M'; |
184 | 184 | } |
185 | 185 | |
186 | - if ( ! $memory_limit || '-1' === $memory_limit ) { |
|
186 | + if ( ! $memory_limit || '-1' === $memory_limit) { |
|
187 | 187 | // Unlimited, set to 32GB. |
188 | 188 | $memory_limit = '32000M'; |
189 | 189 | } |
190 | 190 | |
191 | - return intval( $memory_limit ) * 1024 * 1024; |
|
191 | + return intval($memory_limit) * 1024 * 1024; |
|
192 | 192 | } |
193 | 193 | } |