diff --git a/src/wp-admin/includes/class-walker-nav-menu-edit.php b/src/wp-admin/includes/class-walker-nav-menu-edit.php index 7576de123f..9a2f3ecb69 100644 --- a/src/wp-admin/includes/class-walker-nav-menu-edit.php +++ b/src/wp-admin/includes/class-walker-nav-menu-edit.php @@ -70,7 +70,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { '_wpnonce', ); - $original_title = ''; + $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 ) ) diff --git a/tests/phpunit/tests/menu/walker-nav-menu-edit.php b/tests/phpunit/tests/menu/walker-nav-menu-edit.php new file mode 100644 index 0000000000..6bf931608d --- /dev/null +++ b/tests/phpunit/tests/menu/walker-nav-menu-edit.php @@ -0,0 +1,60 @@ +walker = new Walker_Nav_Menu_Edit(); + + $this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth; + } + + function tearDown() { + global $_wp_nav_menu_max_depth; + + $_wp_nav_menu_max_depth = $this->_wp_nav_menu_max_depth; + + parent::tearDown(); + } + + /** + * @ticket 36729 + */ + function test_original_title_prefix_should_not_be_shown_if_empty() { + $expected = ''; + + $post_id = $this->factory->post->create(); + + $item = array( + 'classes' => array(), + 'description' => '', + 'ID' => $post_id, + 'menu_item_parent' => 0, + 'menu_order' => 0, + 'object_id' => $post_id, + 'object' => 'post', + 'post_excerpt' => get_the_excerpt( $post_id ), + 'title' => get_the_title( $post_id ), + 'type' => 'foobar', + 'type_label' => 'Foo Bar', + 'target' => '_blank', + 'url' => '', + 'xfn' => '', + ); + + $this->walker->start_el( $expected, (object) $item ); + + $this->assertNotRegExp( '#