Make WordPress Core


Ignore:
Timestamp:
09/15/2022 12:18:30 PM (2 years 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.

File:
1 edited

Legend:

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

    r54165 r54176  
    215215}
    216216
     217if ( ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ) ) {
     218    $submenu['themes.php'][6] = array(
     219        __( 'Template Parts' ),
     220        'edit_theme_options',
     221        'site-editor.php?postType=wp_template_part',
     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 = ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) ? 7 : 6;
    223231
    224232    $submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
Note: See TracChangeset for help on using the changeset viewer.