Make WordPress Core

Changeset 54176

Timestamp:
09/15/2022 12:18:30 PM (23 months ago)
Author:
hellofromTonya
Message:

Themes: Introduces block-based template parts for Classic themes.

Allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates.

  • Exposes the Site Editor's template parts UI
  • Adds Appearance > "Template Parts" menu
  • Enabled within the theme via adding a theme support for 'block-template-parts'
    add_theme_support( 'block-template-parts' );
    

This is a backport from Gutenberg.See WordPress/gutenberg PR 42729.

Follow-up to [52330], [52069], [52178].

Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya.
See #56467.

Location:
trunk
Files:
5 edited

Legend:

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

    r54165 r54176  
    215215}
    216216
     217
     218
     219
     220
     221
     222
     223
     224
    217225$customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
    218226
     
    220228// is using 'customize_register' to add a setting.
    221229if ( ! wp_is_block_theme() || has_action( 'customize_register' ) ) {
    222     $position = wp_is_block_theme() ? 7 : 6;
     230    $position = ) ? 7 : 6;
    223231
    224232    $submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
  • trunk/src/wp-admin/site-editor.php

    r53784 r54176  
    2020}
    2121
    22 if ( ! wp_is_block_theme() ) {
     22if ( ! ) ) {
    2323    wp_die( __( 'The theme you are currently using is not compatible with Full Site Editing.' ) );
     24
     25
     26
     27
     28
    2429}
    2530
     
    6570$block_editor_context = new WP_Block_Editor_Context( array( 'name' => 'core/edit-site' ) );
    6671$custom_settings      = array(
    67     'siteUrl'                  => site_url(),
    68     'postsPerPage'             => get_option( 'posts_per_page' ),
    69     'styles'                   => get_block_editor_theme_styles(),
    70     'defaultTemplateTypes'     => $indexed_template_types,
    71     'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(),
    72     '__unstableHomeTemplate'   => $home_template,
     72    'siteUrl'                   => site_url(),
     73    'postsPerPage'              => get_option( 'posts_per_page' ),
     74    'styles'                    => get_block_editor_theme_styles(),
     75    'defaultTemplateTypes'      => $indexed_template_types,
     76    'defaultTemplatePartAreas'  => get_allowed_block_template_part_areas(),
     77    'supportsLayout'            => WP_Theme_JSON_Resolver::theme_has_support(),
     78    'supportsTemplatePartsMode' => ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ),
     79    '__unstableHomeTemplate'    => $home_template,
    7380);
     81
     82
     83
     84
     85
     86
     87
     88
    7489
    7590// Add additional back-compat patterns registered by `current_screen` et al.
  • trunk/src/wp-includes/functions.php

    r54157 r54176  
    52625262
    52635263    $menu_name = __( 'Widgets' );
    5264     if ( wp_is_block_theme() ) {
     5264    if ( wp_is_block_theme() ) {
    52655265        $submenu['themes.php'][] = array( $menu_name, 'edit_theme_options', 'widgets.php' );
    52665266    } else {
  • trunk/src/wp-includes/theme.php

    r54174 r54176  
    38453845    );
    38463846    register_theme_feature(
     3847
     3848
     3849
     3850
     3851
     3852
     3853
    38473854        'custom-background',
    38483855        array(
  • trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php

    r54162 r54176  
    389389        $this->assertArrayHasKey( 'automatic-feed-links', $theme_supports );
    390390        $this->assertArrayHasKey( 'block-templates', $theme_supports );
     391
    391392        $this->assertArrayHasKey( 'custom-header', $theme_supports );
    392393        $this->assertArrayHasKey( 'custom-background', $theme_supports );
     
    408409        $this->assertArrayHasKey( 'title-tag', $theme_supports );
    409410        $this->assertArrayHasKey( 'wp-block-styles', $theme_supports );
    410         $this->assertCount( 22, $theme_supports );
     411        $this->assertCount( 2 );
    411412    }
    412413
Note: See TracChangeset for help on using the changeset viewer.