Changeset 51779 for trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php
- Timestamp:
- 09/09/2021 12:38:36 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php
r51739 r51779 21 21 * 22 22 * @since Twenty Twenty 1.0 23 * @since Twenty Twenty 1.9 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support. 23 * @since Twenty Twenty 1.9 Renamed `$page` to `$data_object` and `$current_page` to `$current_object_id` 24 * to match parent class for PHP 8 named parameter support. 24 25 * 25 26 * @see Walker::start_el() 26 27 * 27 * @param string $output Used to append additional content. Passed by reference.28 * @param WP_Post $data_object Page data object.29 * @param int $depth Optional. Depth of page. Used for padding. Default 0.30 * @param array $args Optional. Array of arguments. Default empty array.31 * @param int $current_ page Optional. Page ID. Default 0.28 * @param string $output Used to append additional content. Passed by reference. 29 * @param WP_Post $data_object Page data object. 30 * @param int $depth Optional. Depth of page. Used for padding. Default 0. 31 * @param array $args Optional. Array of arguments. Default empty array. 32 * @param int $current_object_id Optional. ID of the current page. Default 0. 32 33 */ 33 public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_ page= 0 ) {34 public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) { 34 35 // Restores the more descriptive, specific name for use within this method. 35 $page = $data_object; 36 $page = $data_object; 37 $current_page_id = $current_object_id; 36 38 37 39 if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { … … 54 56 } 55 57 56 if ( ! empty( $current_page ) ) {57 $_current_page = get_post( $current_page );58 if ( ! empty( $current_page_id ) ) { 59 $_current_page = get_post( $current_page_id ); 58 60 if ( $_current_page && in_array( $page->ID, $_current_page->ancestors, true ) ) { 59 61 $css_class[] = 'current_page_ancestor'; 60 62 } 61 if ( $page->ID === $current_page ) {63 if ( $page->ID === $current_page_id ) { 62 64 $css_class[] = 'current_page_item'; 63 65 } elseif ( $_current_page && $page->ID === $_current_page->post_parent ) { … … 69 71 70 72 /** This filter is documented in wp-includes/class-walker-page.php */ 71 $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );73 $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page_id ) ); 72 74 $css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : ''; 73 75 … … 82 84 $atts = array(); 83 85 $atts['href'] = get_permalink( $page->ID ); 84 $atts['aria-current'] = ( $page->ID === $current_page ) ? 'page' : '';86 $atts['aria-current'] = ( $page->ID === $current_page_id ) ? 'page' : ''; 85 87 86 88 /** This filter is documented in wp-includes/class-walker-page.php */ 87 $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page );89 $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page_id ); 88 90 89 91 $attributes = '';
Note: See TracChangeset
for help on using the changeset viewer.