[wp-trac] [WordPress Trac] #35272: .menu-item-home class not applying to static front pages

WordPress Trac noreply at wordpress.org
Wed Oct 26 09:11:15 UTC 2016


#35272: .menu-item-home class not applying to static front pages
---------------------------------------------+---------------------
 Reporter:  RachieVee                        |       Owner:  pento
     Type:  defect (bug)                     |      Status:  closed
 Priority:  normal                           |   Milestone:  4.7
Component:  Menus                            |     Version:  4.4
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:
---------------------------------------------+---------------------

Comment (by mdgl):

 I think this is fine now and I don't want to reopen the ticket, but for
 completeness (and future work on #32367) I just wanted to raise a question
 about the unit tests, which I am not sure are strong enough to distinguish
 between the original (incorrect) patch and the final version.

 I'm afraid I don't know how to run the unit tests, so this is just based
 on inspection.

 The classes added by function `_wp_menu_item_classes_by_context()` are
 dependent on the value of the current query (i.e. the page being
 displayed), but this does not appear to be catered for by the tests.

 For example, if I create a menu with two page items: "Front" and "Back"
 and set my home page to "Front", I see the following behaviour with the
 original patch:

 || ||= Front Menu Item =||= Back Menu Item =||
 ||= Front Page Displayed =|| menu-item-home || - ||
 ||= Back Page Displayed =|| - || menu-item-home ||

 That is, the class `menu-item-home` is always and incorrectly added to the
 menu item corresponding to the currently displayed page, even if it is not
 actually the home page.  With the final version of the patch, I see the
 correct behaviour as follows:

 || ||= Front Menu Item =||= Back Menu Item =||
 ||= Front Page Displayed =|| menu-item-home || - ||
 ||= Back Page Displayed =|| menu-item-home || - ||

 Could somebody tell me whether the unit tests are able to pick up the
 difference between these two solutions? To my eyes, there doesn't appear
 to be quite enough code to do that.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35272#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list