Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move and rename the site editor menu item #36064

Merged
merged 2 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ function gutenberg_extend_block_editor_styles_html() {

echo "<script>window.__editorAssets = $editor_assets</script>";
}
add_action( 'admin_footer-toplevel_page_gutenberg-edit-site', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-appearance_page_gutenberg-edit-site', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-post.php', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-post-new.php', 'gutenberg_extend_block_editor_styles_html' );
add_action( 'admin_footer-widgets.php', 'gutenberg_extend_block_editor_styles_html' );
2 changes: 1 addition & 1 deletion lib/full-site-editing/edit-site-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class="edit-site"
* @return bool True for Site Editor pages, false otherwise.
*/
function gutenberg_is_edit_site_page( $page ) {
return 'toplevel_page_gutenberg-edit-site' === $page;
return 'appearance_page_gutenberg-edit-site' === $page;
}

/**
Expand Down
37 changes: 2 additions & 35 deletions lib/full-site-editing/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,55 +90,22 @@ function gutenberg_adminbar_items( $wp_admin_bar ) {
array(
'id' => 'site-editor',
'title' => __( 'Edit site', 'gutenberg' ),
'href' => admin_url( 'admin.php?page=gutenberg-edit-site' ),
'href' => admin_url( 'themes.php?page=gutenberg-edit-site' ),
)
);
}
}

add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 );

/**
* 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 $menu_order;
}

$new_positions = array(
// Position the site editor before the appearance 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;
}

/**
* Tells the script loader to load the scripts and styles of custom block on site editor screen.
*
* @param bool $is_block_editor_screen Current decision about loading block assets.
* @return bool Filtered decision about loading block assets.
*/
function gutenberg_site_editor_load_block_editor_scripts_and_styles( $is_block_editor_screen ) {
return ( is_callable( 'get_current_screen' ) && get_current_screen() && 'toplevel_page_gutenberg-edit-site' === get_current_screen()->base )
return ( is_callable( 'get_current_screen' ) && get_current_screen() && 'appearance_page_gutenberg-edit-site' === get_current_screen()->base )
? true
: $is_block_editor_screen;
}
Expand Down
9 changes: 4 additions & 5 deletions lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,16 @@ function gutenberg_menu() {
*/
function gutenberg_site_editor_menu() {
if ( gutenberg_experimental_is_site_editor_available() ) {
add_menu_page(
__( 'Site Editor (beta)', 'gutenberg' ),
add_theme_page(
__( 'Editor (beta)', 'gutenberg' ),
sprintf(
/* translators: %s: "beta" label. */
__( 'Site Editor %s', 'gutenberg' ),
__( 'Editor %s', 'gutenberg' ),
'<span class="awaiting-mod">' . __( 'beta', 'gutenberg' ) . '</span>'
),
'edit_theme_options',
'gutenberg-edit-site',
'gutenberg_edit_site_page',
'dashicons-layout'
'gutenberg_edit_site_page'
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/experimental-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const siteEditor = {
page: 'gutenberg-edit-site',
...query,
} ).slice( 1 );
await visitAdminPage( 'admin.php', query );
await visitAdminPage( 'themes.php', query );
await page.waitForSelector( '.edit-site-visual-editor iframe' );
},

Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ html.wp-toolbar {
background: $white;
}

body.toplevel_page_gutenberg-edit-site {
body.appearance_page_gutenberg-edit-site {
@include wp-admin-reset(".edit-site");
}

Expand Down