Skip to content

Commit

Permalink
Use WordPress Menu API (#25132)
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 authored Sep 8, 2020
1 parent 939aef9 commit 2407c9e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
* @since 0.1.0
*/
function gutenberg_menu() {
global $submenu;

add_menu_page(
'Gutenberg',
'Gutenberg',
Expand All @@ -45,20 +43,15 @@ 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' ),
'edit_theme_options',
'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' ) ) {
Expand All @@ -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/'
);
}

Expand Down

0 comments on commit 2407c9e

Please sign in to comment.