Make WordPress Core


Ignore:
Timestamp:
04/07/2022 01:33:03 PM (3 years ago)
Author:
gziolo
Message:

Site Editor: Resolve homepage template on server-side

Backports change from Gutenberg to support server-side home template resolution in the Site Editor. Original PR https://github.com/WordPress/gutenberg/pull/38817.

Props Mamaduka.
See #55505.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/site-editor.php

    r52995 r53093  
    2222if ( ! wp_is_block_theme() ) {
    2323    wp_die( __( 'The theme you are currently using is not compatible with Full Site Editing.' ) );
     24}
     25
     26/**
     27 * Do a server-side redirection if missing `postType` and `postId`
     28 * query args when visiting Site Editor.
     29 */
     30$home_template = _resolve_home_block_template();
     31if ( $home_template && empty( $_GET['postType'] ) && empty( $_GET['postId'] ) ) {
     32    $redirect_url = add_query_arg(
     33        $home_template,
     34        admin_url( 'site-editor.php' )
     35    );
     36    wp_safe_redirect( $redirect_url );
     37    exit;
    2438}
    2539
     
    5771    'defaultTemplateTypes'                 => $indexed_template_types,
    5872    'defaultTemplatePartAreas'             => get_allowed_block_template_part_areas(),
     73    '__unstableHomeTemplate'               => $home_template,
    5974    '__experimentalBlockPatterns'          => WP_Block_Patterns_Registry::get_instance()->get_all_registered(),
    6075    '__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(),
Note: See TracChangeset for help on using the changeset viewer.