Skip to content
Merged
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
33 changes: 33 additions & 0 deletions lib/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,36 @@ 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 ) {
$allowed_hooks = array( 'post.php', 'post-new.php' );
if ( ! in_array( $hook, $allowed_hooks, true ) ) {
return;
}

/**
* HACK: We're hiding the description field using CSS because this
* cannot be done using a filter or an action.
*/

$css = <<<CSS
body.post-type-wp_navigation div#minor-publishing {
display: none;
}
CSS;

wp_add_inline_style( 'common', $css );
}

add_action( 'admin_enqueue_scripts', 'gutenberg_hide_visibility_and_status_for_navigation_posts' );