Check for WP_Error return values when using get_term_field() to set up nav menu items. fixes #17958 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@18426 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2011-07-11 19:03:04 +00:00
parent 486b75c370
commit bb7c1ac6d7
2 changed files with 5 additions and 1 deletions

View File

@ -54,6 +54,8 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$original_title = '';
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;
} elseif ( 'post_type' == $item->type ) {
$original_object = get_post( $item->object_id );
$original_title = $original_object->post_title;
@ -171,7 +173,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
</p>
<div class="menu-item-actions description-wide submitbox">
<?php if( 'custom' != $item->type ) : ?>
<?php if( 'custom' != $item->type && $original_title !== false ) : ?>
<p class="link-to-original">
<?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
</p>

View File

@ -605,6 +605,8 @@ function wp_setup_nav_menu_item( $menu_item ) {
$menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';
$original_title = get_term_field( 'name', $menu_item->object_id, $menu_item->object, 'raw' );
if ( is_wp_error( $original_title ) )
$original_title = false;
$menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
} else {