get_allowed_block_template_part_areas example

foreach ( get_default_block_template_types() as $slug => $template_type ) {
    $template_type['slug']    = (string) $slug;
    $indexed_template_types[] = $template_type;
}

$block_editor_context = new WP_Block_Editor_Context( array( 'name' => 'core/edit-site' ) );
$custom_settings      = array(
    'siteUrl'                   => site_url(),
    'postsPerPage'              => get_option( 'posts_per_page' ),
    'styles'                    => get_block_editor_theme_styles(),
    'defaultTemplateTypes'      => $indexed_template_types,
    'defaultTemplatePartAreas'  => get_allowed_block_template_part_areas(),
    'supportsLayout'            => wp_theme_has_theme_json(),
    'supportsTemplatePartsMode' => ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ),
);

// Add additional back-compat patterns registered by `current_screen` et al. $custom_settings['__experimentalAdditionalBlockPatterns']          = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true );
$custom_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true );

$editor_settings = get_block_editor_settings( $custom_settings$block_editor_context );

if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) {
    

function _filter_block_template_part_area( $type ) {
    $allowed_areas = array_map(
        static function D $item ) {
            return $item['area'];
        },
        get_allowed_block_template_part_areas()
    );
    if ( in_array( $type$allowed_areas, true ) ) {
        return $type;
    }

    $warning_message = sprintf(
        /* translators: %1$s: Template area type, %2$s: the uncategorized template area value. */
        __( '"%1$s" is not a supported wp_template_part area value and has been added as "%2$s".' ),
        $type,
        WP_TEMPLATE_PART_AREA_UNCATEGORIZED
    );
    


// If there's no template set on a new post, use the post format, instead. if ( $is_new_post && ! isset( $editor_settings['template'] ) && 'post' === $post->post_type ) {
    $post_format = get_post_format( $post );
    if ( in_array( $post_format, array( 'audio', 'gallery', 'image', 'quote', 'video' ), true ) ) {
        $editor_settings['template'] = array( array( "core/$post_format) );
    }
}

if ( wp_is_block_theme() && $editor_settings['supportsTemplateMode'] ) {
    $editor_settings['defaultTemplatePartAreas'] = get_allowed_block_template_part_areas();
}

/** * Scripts */
wp_enqueue_media(
    array(
        'post' => $post->ID,
    )
);
wp_tinymce_inline_scripts();


    if ( isset( $seen_ids[ $template_part_id ] ) ) {
        return $is_debug ?
            // translators: Visible only in the front end, this warning takes the place of a faulty block.             __( '[block rendering halted]' ) :
            '';
    }

    // Look up area definition.     $area_definition = null;
    $defined_areas   = get_allowed_block_template_part_areas();
    foreach ( $defined_areas as $defined_area ) {
        if ( $defined_area['area'] === $area ) {
            $area_definition = $defined_area;
            break;
        }
    }

    // If $area is not allowed, set it back to the uncategorized default.     if ( ! $area_definition ) {
        $area = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
    }

    
Home | Imprint | This part of the site doesn't use cookies.