Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect class for current page ancestor in _menus.scss #1073

Closed
aziznatour opened this issue Jan 13, 2017 · 9 comments
Closed

Incorrect class for current page ancestor in _menus.scss #1073

aziznatour opened this issue Jan 13, 2017 · 9 comments

Comments

@aziznatour
Copy link

The following is incorrect: .current_page_ancestor > a
File: /sass/navigation/_menus.scss
Line: 68

.current_page_item > a,
.current-menu-item > a,
.current_page_ancestor > a,
.current-menu-ancestor > a {
}

It should be .current-page-ancestor > a (hyphens instead of underscore)

@bahiirwa
Copy link
Contributor

@aziznatour Did you have a look at #1031?

@aziznatour
Copy link
Author

@bahiirwa I have now. Why does WordPress generate a hyphened class if it's supposed to be underscores? I'm confused.

@bahiirwa
Copy link
Contributor

@aziznatour
Copy link
Author

WordPress 4.7.1
File: wp/wp-includes/nav-menu-template.php
Line: 474


{
   $classes[] = empty( $queried_object->taxonomy ) ? 'current-' . $queried_object->post_type . '-ancestor' : 'current-' . $queried_object->taxonomy . '-ancestor';
}

This seems to be the code responsible for outputting the class in wp_nav_menu() and it is indeed hyphenated.

The underscore one is for wp_page_menu():

if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) {
   // Back compat classes for pages to match wp_page_menu()
   if ( in_array('current-menu-parent', $classes) )
      $classes[] = 'current_page_parent';
   if ( in_array('current-menu-ancestor', $classes) )
      $classes[] = 'current_page_ancestor';
}

I'm not sure if the docs are inaccurate or if something is being overridden :|

@joshmcrty
Copy link
Contributor

@aziznatour @bahiirwa I'm not sure what the issue here is. wp_nav_menu() falls back to wp_page_menu() by default if the site admin hasn't set up a custom menu (see https://developer.wordpress.org/reference/functions/wp_nav_menu/#usage), so it's important to include selectors (hyphens and underscores) for both functions' output in the CSS/Sass. That way the menu looks correct in either situation.

@aziznatour
Copy link
Author

aziznatour commented Jan 14, 2017

@joshmcrty that sounds like the ideal solution, maybe something as the following:

.current_page_item,
.current-page-item,
.current_menu_item,
.current-menu-item,
.current_page_ancestor,
.current-page-ancestor,
.current_menu_ancestor,
.current-menu-ancestor {
   a {
   }
}

@bahiirwa
Copy link
Contributor

bahiirwa commented Jan 14, 2017 via email

@joshmcrty
Copy link
Contributor

@aziznatour @bahiirwa actually I was saying that the ideal solution is already in place. All .current…item and .current…ancestor selectors that either function might output are already accounted for, so this issue can be closed.

@davidakennedy
Copy link
Contributor

Thanks for opening this issue @aziznatour! As @joshmcrty mentioned, this is already accounted for and not a problem, so I'll close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants