PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | lib/experimental/pages/site-editor.php +81 -3 23.5.3 → 24.1.0 View file →
@@ -24,12 +24,90 @@
24 24 * Register default menu items for the site editor page.
25 25 */
26 26 function gutenberg_site_editor_register_default_menu_items() {
27 27 gutenberg_register_site_editor_v2_menu_item( 'home', __( 'Home', 'gutenberg' ), '/', '' );
28 + gutenberg_register_site_editor_v2_menu_item( 'identity', _x( 'Identity', 'site identity', 'gutenberg' ), '/identity', '' );
28 29 gutenberg_register_site_editor_v2_menu_item( 'styles', __( 'Styles', 'gutenberg' ), '/styles', '' );
29 - gutenberg_register_site_editor_v2_menu_item( 'navigation', __( 'Navigation', 'gutenberg' ), '/navigation', '' );
30 +
31 + // The screen edits `wp_navigation` posts, which only block themes render.
32 + // Classic themes manage their menus through Appearance > Menus instead.
33 + if ( wp_is_block_theme() ) {
34 + gutenberg_register_site_editor_v2_menu_item( 'navigation', __( 'Navigation', 'gutenberg' ), '/navigation', '' );
35 + }
36 +
30 37 gutenberg_register_site_editor_v2_menu_item( 'pages', __( 'Pages', 'gutenberg' ), '/types/page', '' );
31 - gutenberg_register_site_editor_v2_menu_item( 'templates', __( 'Templates', 'gutenberg' ), '/templates', '' );
32 - gutenberg_register_site_editor_v2_menu_item( 'templateParts', __( 'Template Parts', 'gutenberg' ), '/template-parts', '' );
38 +
39 + // Block themes and classic themes shipping a `theme.json` file opt in
40 + // automatically, other classic themes have to call
41 + // `add_theme_support( 'block-templates' )`.
42 + if ( current_theme_supports( 'block-templates' ) ) {
43 + gutenberg_register_site_editor_v2_menu_item( 'templates', __( 'Templates', 'gutenberg' ), '/templates', '' );
44 + }
45 +
46 + // `block-template-parts` lets a classic theme opt into template parts alone,
47 + // as the Template Part block itself allows.
48 + if ( current_theme_supports( 'block-templates' ) || current_theme_supports( 'block-template-parts' ) ) {
49 + gutenberg_register_site_editor_v2_menu_item( 'templateParts', __( 'Template Parts', 'gutenberg' ), '/template-parts', '' );
50 + }
51 +
33 52 gutenberg_register_site_editor_v2_menu_item( 'patterns', __( 'Patterns', 'gutenberg' ), '/patterns', '' );
34 53 }
35 54 add_action( 'site-editor-v2_init', 'gutenberg_site_editor_register_default_menu_items', 5 );
55 +
56 +/**
57 + * Renders the admin bar on the site editor page.
58 + */
59 +function gutenberg_site_editor_enable_admin_bar() {
60 + if ( ! is_admin_bar_showing() ) {
61 + return;
62 + }
63 +
64 + remove_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );
65 + add_action( 'admin_footer-site-editor-v2', 'wp_admin_bar_render' );
66 +
67 + $admin_color = get_user_option( 'admin_color' );
68 + if ( empty( $admin_color ) ) {
69 + $admin_color = 'modern';
70 + }
71 + $admin_color_class = 'admin-color-' . sanitize_html_class( $admin_color );
72 +
73 + add_action(
74 + 'admin_footer-site-editor-v2',
75 + static function () use ( $admin_color_class ) {
76 + echo '<script>'
77 + . 'document.body.classList.add(' . wp_json_encode( $admin_color_class ) . ');'
78 + . '</script>';
79 + }
80 + );
81 +
82 + wp_enqueue_script( 'admin-bar' );
83 + wp_enqueue_style( 'admin-bar' );
84 + wp_enqueue_style( 'colors' );
85 +
86 + $css = <<<CSS
87 +#wpadminbar {
88 + display: block;
89 +}
90 +
91 +#site-editor-v2-app {
92 + position: fixed;
93 + top: var(--wp-admin--admin-bar--height, 0);
94 + left: 0;
95 + right: 0;
96 + bottom: 0;
97 + height: calc(100vh - var(--wp-admin--admin-bar--height, 0)) !important;
98 +}
99 +
100 +@media (min-width: 782px) {
101 + body:has(.editor-editor-interface.is-distraction-free) {
102 + --wp-admin--admin-bar--height: 0px;
103 + }
104 +
105 + body:has(.editor-editor-interface.is-distraction-free) #wpadminbar {
106 + display: none;
107 + }
108 +}
109 +CSS;
110 +
111 + wp_add_inline_style( 'admin-bar', $css );
112 +}
113 +add_action( 'site-editor-v2_init', 'gutenberg_site_editor_enable_admin_bar' );