page_menu_link_attributes
Filters the HTML attributes applied to a page menu item's anchor element.
Использование
add_filter( 'page_menu_link_attributes', 'wp_kama_page_menu_link_attributes_filter', 10, 5 );
/**
* Function for `page_menu_link_attributes` filter-hook.
*
* @param array $atts The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
* @param WP_Post $page Page data object.
* @param int $depth Depth of page, used for padding.
* @param array $args An array of arguments.
* @param int $current_page_id ID of the current page.
*
* @return array
*/
function wp_kama_page_menu_link_attributes_filter( $atts, $page, $depth, $args, $current_page_id ){
// filter...
return $atts;
}
- $atts(массив)
The HTML attributes applied to the menu item's <a> element, empty strings are ignored.
-
href(строка)
The href attribute. - aria-current(строка)
The aria-current attribute.
-
- $page(WP_Post)
- Page data object.
- $depth(int)
- Depth of page, used for padding.
- $args(массив)
- An array of arguments.
- $current_page_id(int)
- ID of the current page.
Список изменений
| С версии 4.8.0 | Введена. |
Где вызывается хук
wp-includes/class-walker-page.php 190
$atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page_id );