You appear to be a bot. Output may be restricted
Description
Filters classes of wp_list_pages items to match menu items.
Filter the class applied to wp_list_pages() items with children to match the menu class, to simplify. styling of sub levels in the fallback. Only applied if the match_menu_classes argument is set.
Usage
$array = twentytwenty_filter_wp_list_pages_item_classes( $css_class, $page, $depth, $args, $current_page );
Parameters
- $css_class
- ( string[] ) required – An array of CSS classes to be applied to each list item.
- $page
- ( WP_Post ) required – Page data object.
- $depth
- ( int ) required – Depth of page, used for padding.
- $args
- ( array ) required – An array of arguments.
- $current_page
- ( int ) required – ID of the current page.
Returns
array CSS class names.
Source
File name: twentytwenty/inc/template-tags.php
Lines:
1 to 22 of 22
function twentytwenty_filter_wp_list_pages_item_classes( $css_class, $page, $depth, $args, $current_page ) { // Only apply to wp_list_pages() calls with match_menu_classes set to true. $match_menu_classes = isset( $args['match_menu_classes'] ); if ( ! $match_menu_classes ) { return $css_class; } // Add current menu item class. if ( in_array( 'current_page_item', $css_class, true ) ) { $css_class[] = 'current-menu-item'; } // Add menu item has children class. if ( in_array( 'page_item_has_children', $css_class, true ) ) { $css_class[] = 'menu-item-has-children'; } return $css_class; }