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.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

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.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

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

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 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.