From 21b7928c4a4e0f99c66f94bd74c20736348cf7ec Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 6 Dec 2024 15:16:22 +1100 Subject: [PATCH] Move styles submenu item into compat folder --- lib/compat/wordpress-6.8/site-editor.php | 24 +++++++++++++++ lib/experimental/stylebook/classic-screen.php | 30 ------------------- 2 files changed, 24 insertions(+), 30 deletions(-) delete mode 100644 lib/experimental/stylebook/classic-screen.php diff --git a/lib/compat/wordpress-6.8/site-editor.php b/lib/compat/wordpress-6.8/site-editor.php index 25ad6b6f68d92..86690a6413e1c 100644 --- a/lib/compat/wordpress-6.8/site-editor.php +++ b/lib/compat/wordpress-6.8/site-editor.php @@ -122,3 +122,27 @@ function gutenberg_styles_wp_die_handler( $default_handler ) { return $default_handler; } add_filter( 'wp_die_handler', 'gutenberg_styles_wp_die_handler' ); + +/** + * Add a Styles submenu under the Appearance menu + * for Classic themes. + * + * @global array $submenu + */ +function gutenberg_add_styles_submenu_item() { + if ( ! wp_is_block_theme() ) { + global $submenu; + + $styles_menu_item = array( + __( 'Design', 'gutenberg' ), + 'edit_theme_options', + 'site-editor.php', + ); + // If $submenu exists, insert the Styles submenu item at position 2. + if ( $submenu && isset( $submenu['themes.php'] ) ) { + // This might not work as expected if the submenu has already been modified. + array_splice( $submenu['themes.php'], 1, 1, array( $styles_menu_item ) ); + } + } +} +add_action( 'admin_init', 'gutenberg_add_styles_submenu_item' ); diff --git a/lib/experimental/stylebook/classic-screen.php b/lib/experimental/stylebook/classic-screen.php deleted file mode 100644 index d0fbf33653899..0000000000000 --- a/lib/experimental/stylebook/classic-screen.php +++ /dev/null @@ -1,30 +0,0 @@ -