From 4ed2a8b128bfbeb93558918ad873884f78509c4b Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Mon, 3 Mar 2025 17:20:36 +0000 Subject: [PATCH] Editor: Support Stylebook in the Site Editor for classic themes. This modifies the submenu for the Site Editor which previously linked directly to the Patterns page after [58278] to support accessing the Stylebook in classic themes via a new "Design" link. Currently, any classic themes that have either added support for `editor-styles` or have a theme.json file will automatically see this new link in the admin menu. Props isabel_brison, poena, wildworks, mamaduka, karmatosed, joemcgill. Fixes #62509. git-svn-id: https://develop.svn.wordpress.org/trunk@59905 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/menu.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/menu.php b/src/wp-admin/menu.php index 81fdefb8bd..82136429ba 100644 --- a/src/wp-admin/menu.php +++ b/src/wp-admin/menu.php @@ -211,7 +211,13 @@ if ( ! is_multisite() && current_user_can( 'update_themes' ) ) { if ( wp_is_block_theme() ) { $submenu['themes.php'][6] = array( _x( 'Editor', 'site editor menu item' ), 'edit_theme_options', 'site-editor.php' ); } else { - $submenu['themes.php'][6] = array( _x( 'Patterns', 'patterns menu item' ), 'edit_theme_options', 'site-editor.php?path=/patterns' ); + $supports_stylebook = ( current_theme_supports( 'editor-styles' ) || wp_theme_has_theme_json() ); + + if ( $supports_stylebook ) { + $submenu['themes.php'][6] = array( _x( 'Design', 'design menu item' ), 'edit_theme_options', 'site-editor.php' ); + } else { + $submenu['themes.php'][6] = array( _x( 'Patterns', 'patterns menu item' ), 'edit_theme_options', 'site-editor.php?p=/pattern' ); + } } $customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );