_inject_theme_attribute_in_block_template_content example


            do_action( 'render_block_core_template_part_post', $template_part_id$attributes$template_part_post$content );
        } else {
            $template_part_file_path = '';
            // Else, if the template part was provided by the active theme,             // render the corresponding file content.             if ( 0 === validate_file( $attributes['slug'] ) ) {
                $block_template_file = _get_block_template_file( 'wp_template_part', $attributes['slug'] );
                if ( $block_template_file ) {
                    $template_part_file_path = $block_template_file['path'];
                    $content                 = (string) file_get_contents( $template_part_file_path );
                    $content                 = '' !== $content ? _inject_theme_attribute_in_block_template_content( $content ) : '';
                    if ( isset( $block_template_file['area'] ) ) {
                        $area = $block_template_file['area'];
                    }
                }
            }

            if ( '' !== $content && null !== $content ) {
                /** * Fires when a block template part is loaded from a template part in the theme. * * @since 5.9.0 * * @param string $template_part_id The requested template part namespaced to the theme. * @param array $attributes The block attributes. * @param string $template_part_file_path Absolute path to the template path. * @param string $content The template part content. */

function _build_block_template_result_from_file( $template_file$template_type ) {
    $default_template_types = get_default_block_template_types();
    $template_content       = file_get_contents( $template_file['path'] );
    $theme                  = get_stylesheet();

    $template                 = new WP_Block_Template();
    $template->id             = $theme . '//' . $template_file['slug'];
    $template->theme          = $theme;
    $template->content        = _inject_theme_attribute_in_block_template_content( $template_content );
    $template->slug           = $template_file['slug'];
    $template->source         = 'theme';
    $template->type           = $template_type;
    $template->title          = ! empty( $template_file['title'] ) ? $template_file['title'] : $template_file['slug'];
    $template->status         = 'publish';
    $template->has_theme_file = true;
    $template->is_custom      = true;
    $template->modified       = null;

    if ( 'wp_template' === $template_type && isset( $default_template_types[ $template_file['slug'] ] ) ) {
        $template->description = $default_template_types[ $template_file['slug'] ]['description'];
        
Home | Imprint | This part of the site doesn't use cookies.