Make WordPress Core


Ignore:
Timestamp:
02/06/2024 07:40:21 PM (10 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.