From 6b96b8d26066223f7ffb413420b045da46ba0c58 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 8 Sep 2020 04:44:20 +0000 Subject: [PATCH] Use WordPress Menu API --- gutenberg.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/gutenberg.php b/gutenberg.php index 6328f0883f431..80d7e57d8f5db 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -26,8 +26,6 @@ * @since 0.1.0 */ function gutenberg_menu() { - global $submenu; - add_menu_page( 'Gutenberg', 'Gutenberg', @@ -45,7 +43,7 @@ function gutenberg_menu() { 'gutenberg' ); - if ( gutenberg_use_widgets_block_editor() && isset( $submenu['themes.php'] ) ) { + if ( gutenberg_use_widgets_block_editor() ) { add_theme_page( __( 'Widgets', 'gutenberg' ), __( 'Widgets', 'gutenberg' ), @@ -53,12 +51,7 @@ function gutenberg_menu() { 'gutenberg-widgets', 'the_gutenberg_widgets' ); - $submenu['themes.php'] = array_filter( - $submenu['themes.php'], - function( $current_menu_item ) { - return isset( $current_menu_item[2] ) && 'widgets.php' !== $current_menu_item[2]; - } - ); + remove_submenu_page( 'themes.php', 'widgets.php' ); } if ( get_option( 'gutenberg-experiments' ) ) { @@ -85,16 +78,19 @@ function( $current_menu_item ) { } if ( current_user_can( 'edit_posts' ) ) { - $submenu['gutenberg'][] = array( + add_submenu_page( + 'gutenberg', + __( 'Support', 'gutenberg' ), __( 'Support', 'gutenberg' ), 'edit_posts', - __( 'https://wordpress.org/support/plugin/gutenberg', 'gutenberg' ), + __( 'https://wordpress.org/support/plugin/gutenberg/', 'gutenberg' ) ); - - $submenu['gutenberg'][] = array( + add_submenu_page( + 'gutenberg', + __( 'Documentation', 'gutenberg' ), __( 'Documentation', 'gutenberg' ), 'edit_posts', - 'https://developer.wordpress.org/block-editor/', + 'https://developer.wordpress.org/block-editor/' ); }