WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 6 weeks ago

#24146 accepted defect (bug)

Menu items with blank labels are removed on saving

Reported by: rodrigo@… Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version: 3.5.1
Component: Menus Keywords: dev-feedback has-patch needs-testing
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Hello,

When edit an item of menu leaving the label in blank, the item is auto deleted.
There are two problems in that:

  1. I could need an item with blank title to add some class with an background image
  2. When this item has subitems with two or more depth, all subitems are moved to first depth loosing submenus hierarchy. Moreover if i try to drag the subitems to make the hierarchy again, after save, all subitems come back to first depth. While i not change the depth of first item this issue occurs again.

Best regards

Attachments (5)

24146.patch (2.5 KB) - added by vinod dalvi 4 years ago.
Patch Added.
24146-2.patch (1.8 KB) - added by LeoPeo 3 years ago.
revision of patch 2
24146.diff (1.8 KB) - added by MikeHansenMe 2 years ago.
Refresh plus code standard formatting updates
24146.2.diff (1.9 KB) - added by SergeyBiryukov 2 years ago.
24146.3.diff (2.0 KB) - added by vinod dalvi 6 weeks ago.

Download all attachments as: .zip

Change History (27)

#1 @rodrigo@…
4 years ago

  • Cc rodrigo@… added

#2 @johnbillion
4 years ago

  • Component changed from General to Menus

#4 @SergeyBiryukov
4 years ago

Related: #23051, #25214.

I had the impression that it's a duplicate of #23051, but it's not. Menu items with blank titles are still deleted on saving.

#5 @SergeyBiryukov
4 years ago

  • Description modified (diff)
  • Summary changed from Auto delete of blank labels menu itens to Menu items with blank labels are removed on saving

#6 @SergeyBiryukov
4 years ago

#25218 was marked as a duplicate.

#7 @vinod dalvi
4 years ago

  • Cc mozillavvd@… added
  • Keywords has-patch needs-testing 2nd-opinion added

Patch Added.

@vinod dalvi
4 years ago

Patch Added.

@LeoPeo
3 years ago

revision of patch 2

#8 @LeoPeo
3 years ago

Hello,
I've tested the patch 24146 and it works!

Right now, this is what I see:

https://www.dropbox.com/s/bzd5j6i5g0yprml/24146.png?dl=0

WP: 4.0
Language:Italian

As you can see elements has no label and also element heigh is affected.

I've patched in this way:

1) If $title is not set, $title: (no label)
2) If $title is not set, I add to .menu-item-title the class "no-title" so it's styled like you delete the title in preview.

Last edited 3 years ago by LeoPeo (previous) (diff)

#9 @SergeyBiryukov
3 years ago

#29729 was marked as a duplicate.

#10 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 4.1

#11 @SergeyBiryukov
3 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#12 @johnbillion
3 years ago

  • Keywords 4.2-early added; needs-testing 2nd-opinion removed
  • Milestone changed from 4.1 to Future Release

#13 @iseulde
2 years ago

  • Milestone changed from Future Release to 4.2

has-patch 4.2-early so moving to 4.2.

@MikeHansenMe
2 years ago

Refresh plus code standard formatting updates

This ticket was mentioned in Slack in #core by drew. View the logs.


2 years ago

#15 @DrewAPicture
2 years ago

  • Keywords needs-patch added; has-patch 4.2-early removed

In testing 24146.diff, I noticed a couple of standout issues:

  • With the patch applied, the menus screen is tossing a notice:
    PHP Notice:  Undefined variable: no_title_class in /srv/www/core/mutrunk/src/wp-admin/includes/nav-menu.php on line 109
    
  • Creating and saving ordinary menu links with no label works as expected, though it looks like the same is not true for other types of menu items. Removing labels on category items, for instance, the label is simply restored on save.
Last edited 2 years ago by DrewAPicture (previous) (diff)

#16 @DrewAPicture
2 years ago

The latest patch gets us part-way toward a fix here, just need to new patch addressing the feedback in comment:15. We'll need the new patch pretty soon to remain in consideration for 4.2 inclusion.

#17 @SergeyBiryukov
2 years ago

24146.2.diff fixes the notice and uses an existing string, but still doesn't look like a complete solution.

As noted in comment:15, if you remove the label for a post type or category item, the change is not saved and the label is restored, making the first part of the patch irrelevant.

Looks like 24146.patch attempted to solve this, but it no longer applies cleanly and seems to break the labels of existing menu items when those changes are recreated manually. Also need to take [24560] into account.

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

#18 @alexgarces
2 years ago

  • Keywords dev-feedback added

You can make a blank label adding the string " " at the label field. Doing it this way, the item is not removed from the menu.

#19 @SergeyBiryukov
2 years ago

  • Milestone changed from 4.2 to Future Release

#20 @SergeyBiryukov
2 years ago

#22070 was marked as a duplicate.

#21 @ocean90
2 years ago

In 32895:

Customizer: Fix live preview for menu item titles.

Show also a default label for menu items without a label which are assigned to a menu. This is currently only supported in the Customizer, see #24146 for nav menus screen.

see #32576.

@vinod dalvi
6 weeks ago

#22 @vinod dalvi
6 weeks ago

  • Keywords has-patch needs-testing added; needs-patch removed

Updated patch to make it work with latest code changes.

The patch doesn't handle customizer menu as it is handled in another ticket.

Note: See TracTickets for help on using tickets.