Shortcode.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Helpers\Frontend; |
| 4 | |
| 5 | class Shortcode { |
| 6 | /** |
| 7 | * Get give_receipt shortcode with attributes from confirmation page. |
| 8 | * |
| 9 | * @return string |
| 10 | * @since 2.7.0 |
| 11 | */ |
| 12 | public static function getReceiptShortcodeFromConfirmationPage() { |
| 13 | $pattern = get_shortcode_regex(); |
| 14 | $post = get_post( give_get_option( 'success_page', 0 ) ); |
| 15 | $content = $post->post_content; |
| 16 | |
| 17 | if ( |
| 18 | ! empty( $content ) && |
| 19 | preg_match_all( '/' . $pattern . '/s', $content, $matches ) && |
| 20 | array_key_exists( 2, $matches ) && |
| 21 | in_array( 'give_receipt', $matches[2], true ) |
| 22 | ) { |
| 23 | return $matches[0][0]; |
| 24 | } |
| 25 | |
| 26 | return ''; |
| 27 | } |
| 28 | } |
| 29 |