template-helpers.php
37 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' ) . '</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 |