Changeset 59921
- Timestamp:
- 03/03/2025 10:51:24 PM (7 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentynineteen/inc/template-functions.php
r59218 r59921 168 168 * @link https://www.w3.org/WAI/tutorials/menus/flyout/ 169 169 * 170 * @param array $atts {170 * @param array $atts { 171 171 * The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored. 172 172 * … … 177 177 * @type string $aria-current The aria-current attribute. 178 178 * } 179 * @param WP_Post $item The current menu item object. 179 * @param WP_Post $item The current menu item object. 180 * @param stdClass $args An object of `wp_nav_menu()` arguments. 180 181 * @return string[] Modified attributes. 181 182 */ 182 function twentynineteen_nav_menu_link_attributes( $atts, $item ) { 183 184 // Add [aria-haspopup] and [aria-expanded] to menu items that have children. 185 $item_has_children = in_array( 'menu-item-has-children', $item->classes, true ); 186 if ( $item_has_children ) { 187 $atts['aria-haspopup'] = 'true'; 188 $atts['aria-expanded'] = 'false'; 183 function twentynineteen_nav_menu_link_attributes( $atts, $item, $args ) { 184 185 // Check that this is the primary menu. 186 if ( isset( $args->theme_location ) && 'menu-1' === $args->theme_location ) { 187 // Add [aria-haspopup] and [aria-expanded] to menu items that have children. 188 $item_has_children = in_array( 'menu-item-has-children', $item->classes, true ); 189 if ( $item_has_children ) { 190 $atts['aria-haspopup'] = 'true'; 191 $atts['aria-expanded'] = 'false'; 192 } 189 193 } 190 194 191 195 return $atts; 192 196 } 193 add_filter( 'nav_menu_link_attributes', 'twentynineteen_nav_menu_link_attributes', 10, 2);197 add_filter( 'nav_menu_link_attributes', 'twentynineteen_nav_menu_link_attributes', 10, 3 ); 194 198 195 199 /**
Note: See TracChangeset
for help on using the changeset viewer.