| @@ -20,33 +20,8 @@ | ||
| 20 | 20 | trait Helper |
| 21 | 21 | { |
| 22 | 22 | use Elements, ElementorHelper, WordPressHelper, TemplateQuery; |
| 23 | 23 | |
| 24 | - public function bp_template_render($filePath, $variables = array(), $print = true) | |
| 25 | - { | |
| 26 | - $output = NULL; | |
| 27 | - | |
| 28 | - if (file_exists($filePath)) { | |
| 29 | - // Extract the variables to a local namespace | |
| 30 | - extract($variables); | |
| 31 | - | |
| 32 | - // Start output buffering | |
| 33 | - ob_start(); | |
| 34 | - | |
| 35 | - // Include the template file | |
| 36 | - include $filePath; | |
| 37 | - | |
| 38 | - // End buffering and return its contents | |
| 39 | - $output = ob_get_clean(); | |
| 40 | - } | |
| 41 | - | |
| 42 | - if ( $print ) { | |
| 43 | - print $output; | |
| 44 | - } | |
| 45 | - | |
| 46 | - return $output; | |
| 47 | - } | |
| 48 | - | |
| 49 | 24 | /** |
| 50 | 25 | * List of allowed html tag for wp_kses |
| 51 | 26 | * |
| 52 | 27 | * bp_allowed_tags |
| @@ -558,8 +533,36 @@ | ||
| 558 | 533 | return $currency_data[$currency_code]['name']; |
| 559 | 534 | } |
| 560 | 535 | |
| 561 | 536 | return $currency_code; // Fallback to currency code |
| 537 | + } | |
| 538 | + | |
| 539 | + /** | |
| 540 | + * Whether a visitor may pay through a form stored on this post. | |
| 541 | + * | |
| 542 | + * Every payment handler takes the form's page id from the request, and nothing stopped it | |
| 543 | + * pointing at a draft, private, scheduled or password-protected post — so an unpublished | |
| 544 | + * form could be paid, and any form's configuration probed by id. A published post | |
| 545 | + * qualifies; anything else only for a user allowed to read it (an editor testing a draft | |
| 546 | + * in preview), and never while its password has not been entered. | |
| 547 | + * | |
| 548 | + * @since 2.3.4 | |
| 549 | + * | |
| 550 | + * @param int $page_id Post id. | |
| 551 | + * @return bool | |
| 552 | + */ | |
| 553 | + public function is_payable_form_page( $page_id ) { | |
| 554 | + $post = get_post( absint( $page_id ) ); | |
| 555 | + | |
| 556 | + if ( ! $post ) { | |
| 557 | + return false; | |
| 558 | + } | |
| 559 | + | |
| 560 | + if ( 'publish' !== $post->post_status && ! current_user_can( 'read_post', $post->ID ) ) { | |
| 561 | + return false; | |
| 562 | + } | |
| 563 | + | |
| 564 | + return ! post_password_required( $post ); | |
| 562 | 565 | } |
| 563 | 566 | |
| 564 | 567 | /** |
| 565 | 568 | * Widget settings |