mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-20 19:24:32 +00:00
Menus: In wp_setup_nav_menu_item() and Walker_Nav_Menu_Edit::start_el(), check if the post or term associated with the menu item still exists to avoid a PHP notice.
If the associated post or term no longer exists, mark the menu item as invalid. Props mehulkaklotar, kamrankhorsandi, cristiano.zanca, SergeyBiryukov. Fixes #31703. git-svn-id: https://develop.svn.wordpress.org/trunk@45891 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -71,14 +71,17 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
||||
);
|
||||
|
||||
$original_title = false;
|
||||
|
||||
if ( 'taxonomy' == $item->type ) {
|
||||
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
|
||||
if ( is_wp_error( $original_title ) ) {
|
||||
$original_title = false;
|
||||
$original_object = get_term( (int) $item->object_id, $item->object );
|
||||
if ( $original_object && ! is_wp_error( $original_title ) ) {
|
||||
$original_title = $original_object->name;
|
||||
}
|
||||
} elseif ( 'post_type' == $item->type ) {
|
||||
$original_object = get_post( $item->object_id );
|
||||
$original_title = get_the_title( $original_object->ID );
|
||||
if ( $original_object ) {
|
||||
$original_title = get_the_title( $original_object->ID );
|
||||
}
|
||||
} elseif ( 'post_type_archive' == $item->type ) {
|
||||
$original_object = get_post_type_object( $item->object );
|
||||
if ( $original_object ) {
|
||||
|
||||
Reference in New Issue
Block a user