Skip to content

Commit 9576fa0

Browse files
fix: enhance nav menu item validation for private post access
1 parent bb09cf8 commit 9576fa0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/wp-includes/nav-menu.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,11 @@ function wp_setup_nav_menu_item( $menu_item ) {
886886
$menu_item->_invalid = true;
887887
}
888888

889-
if ( 'publish' !== get_post_status( $menu_item->object_id ) ) {
889+
$post_status = get_post_status( $menu_item->object_id );
890+
891+
if ( 'private' === $post_status && ! current_user_can( 'read_private_posts' ) ) {
892+
$menu_item->_invalid = true;
893+
} elseif ( 'private' !== $post_status && ! is_post_status_viewable( $post_status ) ) {
890894
$menu_item->_invalid = true;
891895
}
892896

0 commit comments

Comments
 (0)