[wp-trac] [WordPress Trac] #24104: Remove duplicated separators in admin menu
WordPress Trac
noreply at wordpress.org
Tue Oct 13 17:11:14 UTC 2015
#24104: Remove duplicated separators in admin menu
--------------------------+-----------------------------
Reporter: rilwis | Owner: wonderboymusic
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 4.4
Component: Plugins | Version: 2.7
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: administration
--------------------------+-----------------------------
Comment (by johnjamesjacoby):
[https://core.trac.wordpress.org/attachment/ticket/24104/24104.02.patch
24104.02.patch] proposes the following changes:
* Use `stristr()`. It performs a case-insensitive haystack/needle string
search, which biases the code towards being greedy and deleting duplicate
separators even if someone is being clever with uppercase letters.
* Rename the `$separator_found` variable to `$prev_menu_was_separator` to
more accurately describe it's intended use. This helped me during the fix,
so my thinking here is that it might help the next tortured soul that
looks at it next.
* Add a bunch of inline documentation to try and make plain-english sense
out of what this code is supposed to do. Again, this helped me maintain
some sanity while unwinding this bit.
* Do not `false`y the `$prev_menu_was_separator` variable prematurely.
This retains the part of [34861] that is responsible for removing
triplicates and higher. If there are 8 separators in a row, only use one
of them.
And finally...
* Move this entire routine after the `custom_menu_order` and `menu_order`
filters have fired, but before the `$last_menu_key` separator check
removes a trailing separator. This is important because plugins might be
adding (and also relocating) separators to the `$menu` global at any point
in `menu.php`'s life-cycle, and WordPress cannot confidently guess at
adjacent separators until plugins have had the opportunity to reorder
their custom menu items.
----
This patch restores the plugins-with-separators under my watch to
WordPress 4.3-and-earlier visual-status, while also addressing the
adjacent-and-triplicate separator issue raised by the original reporter.
What should happen next, IMO:
* Scour the plugins directory for other plugins using separators
* Test with WordPress 4.3, trunk, with-and-without 02.patch applied to
confirm results
* Celebrate our collective triumph, or mourn my having mucked this all up
even further & kill `menu.php` with extreme prejudice in a future release.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/24104#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list