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

git-svn-id: http://svn.automattic.com/wordpress/trunk@18426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-07-11 19:03:04 +00:00
parent 8ead4891b9
commit 61afb5def3
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 {