Make WordPress Core

Changeset 57543


Ignore:
Timestamp:
02/06/2024 07:40:21 PM (14 months ago)
Author:
youknowriad
Message:

Editor: Show the patterns page for classic themes.

Block themes and classic themes with template parts support
can already access the patterns list within the site editor.
This adds a "Patterns" menu item under Appearance for classic themes
without template parts support.

Props wildworks, kevin940726, aaronrobertshaw, fabiankaegy, swissspidy, get_dave, kebbet.
Fixes #58827.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r57159 r57543  
    206206if ( wp_is_block_theme() ) {
    207207    $submenu['themes.php'][6] = array( _x( 'Editor', 'site editor menu item' ), 'edit_theme_options', 'site-editor.php' );
     208} else {
     209    $submenu['themes.php'][6] = array( __( 'Patterns', 'site editor menu item' ), 'edit_theme_options', 'edit.php?post_type=wp_block' );
    208210}
    209211
    210212if ( ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ) ) {
    211     $submenu['themes.php'][6] = array(
     213    $submenu['themes.php'][7] = array(
    212214        __( 'Template Parts' ),
    213215        'edit_theme_options',
     
    221223// is using 'customize_register' to add a setting.
    222224if ( ! wp_is_block_theme() || has_action( 'customize_register' ) ) {
    223     $position = ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) ? 7 : 6;
     225    $position = ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ) ? 8 : 7;
    224226
    225227    $submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
  • trunk/src/wp-admin/site-editor.php

    r56570 r57543  
    2020}
    2121
    22 if ( ! ( current_theme_supports( 'block-template-parts' ) || wp_is_block_theme() ) ) {
    23     wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) );
    24 }
    25 
    2622$is_template_part        = isset( $_GET['postType'] ) && 'wp_template_part' === sanitize_key( $_GET['postType'] );
    2723$is_template_part_path   = isset( $_GET['path'] ) && 'wp_template_partall' === sanitize_key( $_GET['path'] );
    2824$is_template_part_editor = $is_template_part || $is_template_part_path;
     25$is_patterns             = isset( $_GET['postType'] ) && 'wp_block' === sanitize_key( $_GET['postType'] );
     26$is_patterns_path        = isset( $_GET['path'] ) && 'patterns' === sanitize_key( $_GET['path'] );
     27$is_patterns_editor      = $is_patterns || $is_patterns_path;
    2928
    30 if ( ! wp_is_block_theme() && ! $is_template_part_editor ) {
    31     wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) );
     29if ( ! wp_is_block_theme() ) {
     30    if ( ! current_theme_supports( 'block-template-parts' ) && $is_template_part_editor ) {
     31        wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) );
     32    } elseif ( ! $is_patterns_editor && ! $is_template_part_editor ) {
     33        wp_die( __( 'The theme you are currently using is not compatible with the Site Editor.' ) );
     34    }
    3235}
    3336
  • trunk/src/wp-includes/functions.php

    r57532 r57543  
    53965396        $submenu['themes.php'][] = array( $menu_name, 'edit_theme_options', 'widgets.php' );
    53975397    } else {
    5398         $submenu['themes.php'][7] = array( $menu_name, 'edit_theme_options', 'widgets.php' );
     5398        $submenu['themes.php'][8] = array( $menu_name, 'edit_theme_options', 'widgets.php' );
    53995399    }
    54005400
Note: See TracChangeset for help on using the changeset viewer.