| @@ -32,63 +32,4 @@ | ||
| 32 | 32 | gutenberg_register_site_editor_v2_menu_item( 'templateParts', __( 'Template Parts', 'gutenberg' ), '/template-parts', '' ); |
| 33 | 33 | gutenberg_register_site_editor_v2_menu_item( 'patterns', __( 'Patterns', 'gutenberg' ), '/patterns', '' ); |
| 34 | 34 | } |
| 35 | 35 | add_action( 'site-editor-v2_init', 'gutenberg_site_editor_register_default_menu_items', 5 ); |
| 36 | - | |
| 37 | -/** | |
| 38 | - * Renders the admin bar on the site editor page. | |
| 39 | - */ | |
| 40 | -function gutenberg_site_editor_enable_admin_bar() { | |
| 41 | - if ( ! is_admin_bar_showing() ) { | |
| 42 | - return; | |
| 43 | - } | |
| 44 | - | |
| 45 | - remove_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 ); | |
| 46 | - add_action( 'admin_footer-site-editor-v2', 'wp_admin_bar_render' ); | |
| 47 | - | |
| 48 | - $admin_color = get_user_option( 'admin_color' ); | |
| 49 | - if ( empty( $admin_color ) ) { | |
| 50 | - $admin_color = 'modern'; | |
| 51 | - } | |
| 52 | - $admin_color_class = 'admin-color-' . sanitize_html_class( $admin_color ); | |
| 53 | - | |
| 54 | - add_action( | |
| 55 | - 'admin_footer-site-editor-v2', | |
| 56 | - static function () use ( $admin_color_class ) { | |
| 57 | - echo '<script>' | |
| 58 | - . 'document.body.classList.add(' . wp_json_encode( $admin_color_class ) . ');' | |
| 59 | - . '</script>'; | |
| 60 | - } | |
| 61 | - ); | |
| 62 | - | |
| 63 | - wp_enqueue_script( 'admin-bar' ); | |
| 64 | - wp_enqueue_style( 'admin-bar' ); | |
| 65 | - wp_enqueue_style( 'colors' ); | |
| 66 | - | |
| 67 | - $css = <<<CSS | |
| 68 | -#wpadminbar { | |
| 69 | - display: block; | |
| 70 | -} | |
| 71 | - | |
| 72 | -#site-editor-v2-app { | |
| 73 | - position: fixed; | |
| 74 | - top: var(--wp-admin--admin-bar--height, 0); | |
| 75 | - left: 0; | |
| 76 | - right: 0; | |
| 77 | - bottom: 0; | |
| 78 | - height: calc(100vh - var(--wp-admin--admin-bar--height, 0)) !important; | |
| 79 | -} | |
| 80 | - | |
| 81 | -@media (min-width: 782px) { | |
| 82 | - body:has(.editor-editor-interface.is-distraction-free) { | |
| 83 | - --wp-admin--admin-bar--height: 0px; | |
| 84 | - } | |
| 85 | - | |
| 86 | - body:has(.editor-editor-interface.is-distraction-free) #wpadminbar { | |
| 87 | - display: none; | |
| 88 | - } | |
| 89 | -} | |
| 90 | -CSS; | |
| 91 | - | |
| 92 | - wp_add_inline_style( 'admin-bar', $css ); | |
| 93 | -} | |
| 94 | -add_action( 'site-editor-v2_init', 'gutenberg_site_editor_enable_admin_bar' ); | |