Menus: Fix the Custom Links text fallback.

When adding a Custom Link and leaving the "Link Text" field empty, WordPress used to set a default fallback text: "Menu Item".

The changes in [36379] broke this behavior making the fallback text: `(Pending)`, with a leading space.

Pending major refactoring of the Menus page (which is going to use a block-based user interface) this change just restores the original behavior by adding the fallback text to the related AJAX response.

Props christophherr, Fencer04, thakkarhardik, backermann1978, audrasjb.
Merges [45727] to the 5.2 branch.
Fixes #38415.
Built from https://develop.svn.wordpress.org/branches/5.2@45828


git-svn-id: http://core.svn.wordpress.org/branches/5.2@45639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-08-19 03:56:53 +00:00
parent 7bde97c5d1
commit 37b995b2bb
2 changed files with 2 additions and 1 deletions

View File

@ -1423,6 +1423,7 @@ function wp_ajax_add_menu_item() {
$menu_obj = get_post( $menu_item_id ); $menu_obj = get_post( $menu_item_id );
if ( ! empty( $menu_obj->ID ) ) { if ( ! empty( $menu_obj->ID ) ) {
$menu_obj = wp_setup_nav_menu_item( $menu_obj ); $menu_obj = wp_setup_nav_menu_item( $menu_obj );
$menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title;
$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items $menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
$menu_items[] = $menu_obj; $menu_items[] = $menu_obj;
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.2.3-alpha-45666'; $wp_version = '5.2.3-alpha-45828';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.