.gitkeep
3 years ago
block-helpers.php
1 year ago
block-style-helpers.php
1 year ago
collection-helpers.php
1 year ago
kses-helpers.php
1 year ago
product-helpers.php
1 year ago
route-helper.php
2 years ago
state-helpers.php
2 years ago
template-helpers.php
1 year ago
template-helpers.php
68 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Returns the markup for the current template. |
| 4 | * |
| 5 | * @access private |
| 6 | * @since 5.8.0 |
| 7 | * |
| 8 | * @global string $_wp_current_template_content |
| 9 | * @global WP_Embed $wp_embed |
| 10 | * |
| 11 | * @return string Block template markup. |
| 12 | */ |
| 13 | function surecart_get_the_block_template_html( $template_content ) { |
| 14 | global $wp_embed; |
| 15 | |
| 16 | if ( ! $template_content ) { |
| 17 | if ( is_user_logged_in() ) { |
| 18 | return '<h1>' . esc_html__( 'No matching template found', 'surecart' ) . '</h1>'; |
| 19 | } |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | $content = $wp_embed->run_shortcode( $template_content ); |
| 24 | $content = $wp_embed->autoembed( $content ); |
| 25 | $content = do_blocks( $content ); |
| 26 | $content = wptexturize( $content ); |
| 27 | $content = convert_smilies( $content ); |
| 28 | $content = shortcode_unautop( $content ); |
| 29 | $content = wp_filter_content_tags( $content, 'template' ); |
| 30 | $content = do_shortcode( $content ); |
| 31 | $content = str_replace( ']]>', ']]>', $content ); |
| 32 | |
| 33 | // Wrap block template in .wp-site-blocks to allow for specific descendant styles |
| 34 | // (e.g. `.wp-site-blocks > *`). |
| 35 | return '<div class="wp-site-blocks">' . $content . '</div>'; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Prints a block template part. |
| 40 | * |
| 41 | * @since 5.9.0 |
| 42 | * |
| 43 | * @param string $part The block template part to print. |
| 44 | */ |
| 45 | function sc_block_template_part( $part ) { |
| 46 | // add surecart/surecart prefix. |
| 47 | $template_part = get_block_template( $part, 'wp_template_part' ); |
| 48 | if ( ! $template_part || empty( $template_part->content ) ) { |
| 49 | return; |
| 50 | } |
| 51 | echo do_blocks( $template_part->content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Prints a block template part. |
| 56 | * |
| 57 | * @since 5.9.0 |
| 58 | * |
| 59 | * @param string $part The block template part to print. |
| 60 | */ |
| 61 | function sc_block_template( $part ) { |
| 62 | $template_part = get_block_template( 'surecart/surecart//' . $part ); |
| 63 | if ( ! $template_part || empty( $template_part->content ) ) { |
| 64 | return; |
| 65 | } |
| 66 | echo do_blocks( $template_part->content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 67 | } |
| 68 |