Menus: Add the `menu-item-home` class to the static front page item.
When a site is using a static front page, and that page is in a menu, it isn't given the CSS class `menu-item-home`, contrary to the developer documentation. An incorrect solution was originally added in [35272], and is now gone. Let us never speak of it again. Props mdgl, adamsilverstein, welcher, pento. Fixes #35272. Built from https://develop.svn.wordpress.org/trunk@38940 git-svn-id: http://core.svn.wordpress.org/trunk@38883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ed2e427b9d
commit
fe86e61f0b
|
@ -334,6 +334,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
|||
$possible_object_parents = array_filter( $possible_object_parents );
|
||||
|
||||
$front_page_url = home_url();
|
||||
$front_page_id = (int) get_option( 'page_on_front' );
|
||||
|
||||
foreach ( (array) $menu_items as $key => $menu_item ) {
|
||||
|
||||
|
@ -344,6 +345,11 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
|||
$classes[] = 'menu-item-type-' . $menu_item->type;
|
||||
$classes[] = 'menu-item-object-' . $menu_item->object;
|
||||
|
||||
// This menu item is set as the 'Front Page'.
|
||||
if ( 'post_type' === $menu_item->type && $front_page_id === (int) $menu_item->object_id ) {
|
||||
$classes[] = 'menu-item-home';
|
||||
}
|
||||
|
||||
// if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object
|
||||
if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) {
|
||||
$active_parent_object_ids[] = (int) $menu_item->object_id;
|
||||
|
@ -377,10 +383,6 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
|||
$classes[] = 'current_page_item';
|
||||
}
|
||||
|
||||
if ( 'page_on_front' ) {
|
||||
$classes[] = 'menu-item-home';
|
||||
}
|
||||
|
||||
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
|
||||
$active_parent_object_ids[] = (int) $menu_item->post_parent;
|
||||
$active_object = $menu_item->object;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-alpha-38939';
|
||||
$wp_version = '4.7-alpha-38940';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue