Skip to content

Commit

Permalink
Site Editor: Elevate "Editor" menu item (#37175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Dec 7, 2021
1 parent d754759 commit fdedb36
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions lib/full-site-editing/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,36 @@ function gutenberg_remove_legacy_pages() {
}

global $submenu;
if ( isset( $submenu['themes.php'] ) ) {
$indexes_to_remove = array();
foreach ( $submenu['themes.php'] as $index => $menu_item ) {
if ( false !== strpos( $menu_item[2], 'customize.php' ) && ! gutenberg_site_requires_customizer() ) {
$indexes_to_remove[] = $index;
}

if ( false !== strpos( $menu_item[2], 'site-editor.php' ) ) {
$indexes_to_remove[] = $index;
}

if ( false !== strpos( $menu_item[2], 'gutenberg-widgets' ) ) {
$indexes_to_remove[] = $index;
}
if ( ! isset( $submenu['themes.php'] ) ) {
return;
}

$indexes_to_remove = array();
$customize_menu = null;
foreach ( $submenu['themes.php'] as $index => $menu_item ) {
if ( false !== strpos( $menu_item[2], 'customize.php' ) ) {
$indexes_to_remove[] = $index;
$customize_menu = $menu_item;
}

if ( false !== strpos( $menu_item[2], 'site-editor.php' ) ) {
$indexes_to_remove[] = $index;
}

foreach ( $indexes_to_remove as $index ) {
unset( $submenu['themes.php'][ $index ] );
if ( false !== strpos( $menu_item[2], 'gutenberg-widgets' ) ) {
$indexes_to_remove[] = $index;
}
}
}

foreach ( $indexes_to_remove as $index ) {
unset( $submenu['themes.php'][ $index ] );
}

// Add Customizer back but with a new sub-menu position when a site requires this feature.
if ( gutenberg_site_requires_customizer() && $customize_menu ) {
$submenu['themes.php'][20] = $customize_menu;
}
}
add_action( 'admin_menu', 'gutenberg_remove_legacy_pages' );

/**
Expand Down

0 comments on commit fdedb36

Please sign in to comment.