diff --git a/gutenberg.php b/gutenberg.php index c04d95ba3d035b..9bfb2af06cf9a4 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -70,7 +70,11 @@ function gutenberg_menu() { if ( gutenberg_is_fse_theme() ) { add_menu_page( __( 'Site Editor (beta)', 'gutenberg' ), - __( 'Site Editor (beta)', 'gutenberg' ), + sprintf( + /* translators: %s: "beta" label. */ + __( 'Site Editor %s', 'gutenberg' ), + '' . __( 'beta', 'gutenberg' ) . '' + ), 'edit_theme_options', 'gutenberg-edit-site', 'gutenberg_edit_site_page', diff --git a/lib/full-site-editing.php b/lib/full-site-editing.php index 2541aed693c573..d858d0efa6a08b 100644 --- a/lib/full-site-editing.php +++ b/lib/full-site-editing.php @@ -28,3 +28,64 @@ function gutenberg_full_site_editing_notice() { $menu_item ) { + if ( + false !== strpos( $menu_item[2], 'customize.php' ) || + false !== strpos( $menu_item[2], 'gutenberg-widgets' ) + ) { + $indexes_to_remove[] = $index; + } + } + + foreach ( $indexes_to_remove as $index ) { + unset( $submenu['themes.php'][ $index ] ); + } + } +} + +add_action( 'admin_menu', 'gutenberg_remove_legacy_pages' ); + +/** + * Activates the 'menu_order' filter and then hooks into 'menu_order' + */ +add_filter( 'custom_menu_order', '__return_true' ); +add_filter( 'menu_order', 'gutenberg_menu_order' ); + +/** + * Filters WordPress default menu order + * + * @param array $menu_order Menu Order. + */ +function gutenberg_menu_order( $menu_order ) { + if ( ! gutenberg_is_fse_theme() ) { + return; + } + + $new_positions = array( + // Position the site editor before the appearnce menu. + 'gutenberg-edit-site' => array_search( 'themes.php', $menu_order, true ), + ); + + // Traverse through the new positions and move + // the items if found in the original menu_positions. + foreach ( $new_positions as $value => $new_index ) { + $current_index = array_search( $value, $menu_order, true ); + if ( $current_index ) { + $out = array_splice( $menu_order, $current_index, 1 ); + array_splice( $menu_order, $new_index, 0, $out ); + } + } + return $menu_order; +}