From 3289f2912b63d033aefee924100b0f4a8e13949c Mon Sep 17 00:00:00 2001 From: Anton Vlasenko Date: Tue, 9 Nov 2021 22:46:09 +0100 Subject: [PATCH 1/2] Hide visilibility and status for navigation posts. These fields are not appropriate for navigation posts. --- lib/navigation.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/navigation.php b/lib/navigation.php index 8a3587ae7dff12..72d3c34c842ea2 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -386,3 +386,35 @@ function gutenberg_parse_blocks_from_menu_items( $menu_items, $menu_items_by_par return $blocks; } + +/** + * Shim that hides ability to edit visibility and status for wp_navigation type posts. + * When merged to Core, the CSS below should be moved to wp-admin/css/edit.css. + * + * This shim can be removed when the Gutenberg plugin requires a WordPress + * version that has the ticket below. + * + * @see https://core.trac.wordpress.org/ticket/54407 + * + * @param string $hook The current admin page. + */ +function gutenberg_hide_visibility_and_status_for_navigation_posts( $hook ) { + if ( 'post.php' !== $hook ) { + return; + } + + /** + * HACK: We're hiding the description field using CSS because this + * cannot be done using a filter or an action. + */ + + $css = << Date: Tue, 9 Nov 2021 23:45:56 +0100 Subject: [PATCH 2/2] Hide visibility and status for new posts too. --- lib/navigation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/navigation.php b/lib/navigation.php index 72d3c34c842ea2..78ea46e8c95c35 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -399,7 +399,8 @@ function gutenberg_parse_blocks_from_menu_items( $menu_items, $menu_items_by_par * @param string $hook The current admin page. */ function gutenberg_hide_visibility_and_status_for_navigation_posts( $hook ) { - if ( 'post.php' !== $hook ) { + $allowed_hooks = array( 'post.php', 'post-new.php' ); + if ( ! in_array( $hook, $allowed_hooks, true ) ) { return; }