-
Notifications
You must be signed in to change notification settings - Fork 7
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
has_children class exists for a parent when all children are actually hidden #18
Comments
Hi @mchev2, |
Hi @awbauer, is there any update on this issue? If there is anything that I can help with please let me know. Thank you. |
Mentioned on Slack by Andrew Bauer in #cms. View the logs ➡️ |
@mchev2 Still taking a look into this. Will update when we have a fix ready to go. |
Mentioned on Slack by Andrew Bauer in #wp-dev. View the logs ➡️ |
We came up with this solution to add an extra class 'has_visible_children'. function bu_navigation_item_class_visible_children($item_classes, $page){
if( bu_navigation_page_has_visible_children($page->ID) ){
$item_classes[] = 'has_visible_children';
}
return $item_classes;
}
add_filter('bu_navigation_filter_item_attrs', 'bu_navigation_item_class_visible_children', 10, 2);
function bu_navigation_page_has_visible_children($page_id){
static $pages;
if( !$pages ){
// Get all visible pages
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'fields' => 'id=>parent',
'meta_key' => BU_NAV_META_PAGE_EXCLUDE,
'meta_value' => 0
);
$query = new WP_Query( $args );
$pages = $query->get_posts();
}
// If the page_id is not a parent of any of the visible pages, then it does not have any visible children
return !!array_search($page_id, $pages);
} |
For the navigation widget, we noticed that
has_children
class for a navigationli
is added even when all the children are hidden (visibility hidden). It seems like the widget is only checking if there are children and then addinghas_children
class. It should addhas_children
only if the parent has any visible children.The text was updated successfully, but these errors were encountered: