wppaste
WordPress

apply_filters( 'page_menu_link_attributes', array $atts, WP_Post $page, int $depth, array $args, int $current_page_id )

Since
4.8.0
Filters the HTML attributes applied to a page menu item's anchor element.

Compatibility

WordPress
since 4.8.0
  • 6.7.10
  • 6.8.11
  • 6.9.10
  • 7.0.7
  • 7.1.3

Present in every tracked release (6.7.10 to 7.1.3).

Parameters

$attsarray
{ The HTML attributes applied to the menu item's <a> element, empty strings are ignored.
@type string $href The href attribute.
@type string $aria-current The aria-current attribute.
}
  • $hrefstring

    The href attribute.
  • $aria-currentstring

    The aria-current attribute.
$pageWP_Post
Page data object.
$depthint
Depth of page, used for padding.
$argsarray
An array of arguments.
$current_page_idint
ID of the current page.

Where this hook fires · 2

  • wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php:87TwentyTwenty_Walker_Page::start_el()
  • wp-includes/class-walker-page.php:190Walker_Page::start_el()

Source code

		 * }		 * @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.		 */		$atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page_id ); 		$attributes = '';		foreach ( $atts as $attr => $value ) {			if ( is_scalar( $value ) && '' !== $value && false !== $value ) {				$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );				$attributes .= ' ' . $attr . '="' . $value . '"';

Changelog

Introduced in 4.8.0. Unchanged from 6.7.10 through 7.1.3.

  1. 6.7.10
  2. 6.8.11
  3. 6.9.10
  4. 7.0.7
  5. 7.1.3

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.10 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.