diff --git a/wp-admin/includes/class-walker-category-checklist.php b/wp-admin/includes/class-walker-category-checklist.php index 171e731987..9e360d62fe 100644 --- a/wp-admin/includes/class-walker-category-checklist.php +++ b/wp-admin/includes/class-walker-category-checklist.php @@ -61,14 +61,18 @@ class Walker_Category_Checklist extends Walker { * @see Walker::start_el() * * @since 2.5.1 + * @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support. * - * @param string $output Used to append additional content (passed by reference). - * @param WP_Term $category The current term object. - * @param int $depth Depth of the term in reference to parents. Default 0. - * @param array $args An array of arguments. @see wp_terms_checklist() - * @param int $id ID of the current term. + * @param string $output Used to append additional content (passed by reference). + * @param WP_Term $data_object The current term object. + * @param int $depth Depth of the term in reference to parents. Default 0. + * @param array $args An array of arguments. @see wp_terms_checklist() + * @param int $id ID of the current term. */ - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) { + // Restores the more descriptive, specific name for use within this method. + $category = $data_object; + if ( empty( $args['taxonomy'] ) ) { $taxonomy = 'category'; } else { diff --git a/wp-admin/includes/class-walker-nav-menu-checklist.php b/wp-admin/includes/class-walker-nav-menu-checklist.php index afafe4a96b..e1ff27a59b 100644 --- a/wp-admin/includes/class-walker-nav-menu-checklist.php +++ b/wp-admin/includes/class-walker-nav-menu-checklist.php @@ -61,22 +61,26 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { * @see Walker_Nav_Menu::start_el() * * @since 3.0.0 + * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support. * * @global int $_nav_menu_placeholder * @global int|string $nav_menu_selected_id * - * @param string $output Used to append additional content (passed by reference). - * @param WP_Post $item Menu item data object. - * @param int $depth Depth of menu item. Used for padding. - * @param stdClass $args Not used. - * @param int $id Not used. + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $data_object Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args Not used. + * @param int $id Not used. */ - public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) { global $_nav_menu_placeholder, $nav_menu_selected_id; + // Restores the more descriptive, specific name for use within this method. + $menu_item = $data_object; + $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; - $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' === $item->post_type ? $item->object_id : $_nav_menu_placeholder; - $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0; + $possible_object_id = isset( $menu_item->post_type ) && 'nav_menu_item' === $menu_item->post_type ? $menu_item->object_id : $_nav_menu_placeholder; + $possible_db_id = ( ! empty( $menu_item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $menu_item->ID : 0; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; @@ -84,39 +88,39 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { $output .= ''; // Menu item hidden fields. $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; - $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; } } diff --git a/wp-admin/includes/class-walker-nav-menu-edit.php b/wp-admin/includes/class-walker-nav-menu-edit.php index bf8e77ec2a..1b5be7d8c4 100644 --- a/wp-admin/includes/class-walker-nav-menu-edit.php +++ b/wp-admin/includes/class-walker-nav-menu-edit.php @@ -46,21 +46,25 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { * * @see Walker_Nav_Menu::start_el() * @since 3.0.0 + * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support. * * @global int $_wp_nav_menu_max_depth * - * @param string $output Used to append additional content (passed by reference). - * @param WP_Post $item Menu item data object. - * @param int $depth Depth of menu item. Used for padding. - * @param stdClass $args Not used. - * @param int $id Not used. + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $data_object Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args Not used. + * @param int $id Not used. */ - public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) { global $_wp_nav_menu_max_depth; + + // Restores the more descriptive, specific name for use within this method. + $menu_item = $data_object; $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; ob_start(); - $item_id = esc_attr( $item->ID ); + $item_id = esc_attr( $menu_item->ID ); $removed_args = array( 'action', 'customlink-tab', @@ -72,18 +76,18 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { $original_title = false; - if ( 'taxonomy' === $item->type ) { - $original_object = get_term( (int) $item->object_id, $item->object ); + if ( 'taxonomy' === $menu_item->type ) { + $original_object = get_term( (int) $menu_item->object_id, $menu_item->object ); if ( $original_object && ! is_wp_error( $original_object ) ) { $original_title = $original_object->name; } - } elseif ( 'post_type' === $item->type ) { - $original_object = get_post( $item->object_id ); + } elseif ( 'post_type' === $menu_item->type ) { + $original_object = get_post( $menu_item->object_id ); if ( $original_object ) { $original_title = get_the_title( $original_object->ID ); } - } elseif ( 'post_type_archive' === $item->type ) { - $original_object = get_post_type_object( $item->object ); + } elseif ( 'post_type_archive' === $menu_item->type ) { + $original_object = get_post_type_object( $menu_item->object ); if ( $original_object ) { $original_title = $original_object->labels->archives; } @@ -91,23 +95,23 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { $classes = array( 'menu-item menu-item-depth-' . $depth, - 'menu-item-' . esc_attr( $item->object ), + 'menu-item-' . esc_attr( $menu_item->object ), 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ), ); - $title = $item->title; + $title = $menu_item->title; - if ( ! empty( $item->_invalid ) ) { + if ( ! empty( $menu_item->_invalid ) ) { $classes[] = 'menu-item-invalid'; /* translators: %s: Title of an invalid menu item. */ - $title = sprintf( __( '%s (Invalid)' ), $item->title ); - } elseif ( isset( $item->post_status ) && 'draft' === $item->post_status ) { + $title = sprintf( __( '%s (Invalid)' ), $menu_item->title ); + } elseif ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { $classes[] = 'pending'; /* translators: %s: Title of a menu item in draft status. */ - $title = sprintf( __( '%s (Pending)' ), $item->title ); + $title = sprintf( __( '%s (Pending)' ), $menu_item->title ); } - $title = ( ! isset( $item->label ) || '' === $item->label ) ? $title : $item->label; + $title = ( ! isset( $menu_item->label ) || '' === $menu_item->label ) ? $title : $menu_item->label; $submenu_text = ''; if ( 0 === $depth ) { @@ -124,7 +128,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { > - type_label ); ?> + type_label ); ?> name, $category ); diff --git a/wp-includes/class-walker-category.php b/wp-includes/class-walker-category.php index 94ebc58db2..651bd1310f 100644 --- a/wp-includes/class-walker-category.php +++ b/wp-includes/class-walker-category.php @@ -86,16 +86,21 @@ class Walker_Category extends Walker { * Starts the element output. * * @since 2.1.0 + * @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support. * * @see Walker::start_el() * - * @param string $output Used to append additional content (passed by reference). - * @param WP_Term $category Category data object. - * @param int $depth Optional. Depth of category in reference to parents. Default 0. - * @param array $args Optional. An array of arguments. See wp_list_categories(). Default empty array. - * @param int $id Optional. ID of the current category. Default 0. + * @param string $output Used to append additional content (passed by reference). + * @param WP_Term $data_object Category data object. + * @param int $depth Optional. Depth of category in reference to parents. Default 0. + * @param array $args Optional. An array of arguments. See wp_list_categories(). + * Default empty array. + * @param int $id Optional. ID of the current category. Default 0. */ - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) { + // Restores the more descriptive, specific name for use within this method. + $category = $data_object; + /** This filter is documented in wp-includes/category-template.php */ $cat_name = apply_filters( 'list_cats', esc_attr( $category->name ), $category ); diff --git a/wp-includes/class-walker-comment.php b/wp-includes/class-walker-comment.php index 0ac661e547..4d871ff73d 100644 --- a/wp-includes/class-walker-comment.php +++ b/wp-includes/class-walker-comment.php @@ -157,19 +157,23 @@ class Walker_Comment extends Walker { * Starts the element output. * * @since 2.7.0 + * @since 5.9.0 Renamed `$comment` to `$data_object` to match parent class for PHP 8 named parameter support. * * @see Walker::start_el() * @see wp_list_comments() * @global int $comment_depth * @global WP_Comment $comment Global comment object. * - * @param string $output Used to append additional content. Passed by reference. - * @param WP_Comment $comment Comment data object. - * @param int $depth Optional. Depth of the current comment in reference to parents. Default 0. - * @param array $args Optional. An array of arguments. Default empty array. - * @param int $id Optional. ID of the current comment. Default 0 (unused). + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Comment $data_object Comment data object. + * @param int $depth Optional. Depth of the current comment in reference to parents. Default 0. + * @param array $args Optional. An array of arguments. Default empty array. + * @param int $id Optional. ID of the current comment. Default 0 (unused). */ - public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) { + // Restores the more descriptive, specific name for use within this method. + $comment = $data_object; + $depth++; $GLOBALS['comment_depth'] = $depth; $GLOBALS['comment'] = $comment; diff --git a/wp-includes/class-walker-nav-menu.php b/wp-includes/class-walker-nav-menu.php index ecbb8d9642..9ae4354364 100644 --- a/wp-includes/class-walker-nav-menu.php +++ b/wp-includes/class-walker-nav-menu.php @@ -106,16 +106,20 @@ class Walker_Nav_Menu extends Walker { * * @since 3.0.0 * @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added. + * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support. * * @see Walker::start_el() * - * @param string $output Used to append additional content (passed by reference). - * @param WP_Post $item Menu item data object. - * @param int $depth Depth of menu item. Used for padding. - * @param stdClass $args An object of wp_nav_menu() arguments. - * @param int $id Current item ID. + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $data_object Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $id Current item ID. */ - public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) { + // Restores the more descriptive, specific name for use within this method. + $menu_item = $data_object; + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; @@ -125,19 +129,19 @@ class Walker_Nav_Menu extends Walker { } $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; - $classes = empty( $item->classes ) ? array() : (array) $item->classes; - $classes[] = 'menu-item-' . $item->ID; + $classes = empty( $menu_item->classes ) ? array() : (array) $menu_item->classes; + $classes[] = 'menu-item-' . $menu_item->ID; /** * Filters the arguments for a single nav menu item. * * @since 4.4.0 * - * @param stdClass $args An object of wp_nav_menu() arguments. - * @param WP_Post $item Menu item data object. - * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param WP_Post $menu_item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. */ - $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); + $args = apply_filters( 'nav_menu_item_args', $args, $menu_item, $depth ); /** * Filters the CSS classes applied to a menu item's list item element. @@ -145,12 +149,12 @@ class Walker_Nav_Menu extends Walker { * @since 3.0.0 * @since 4.1.0 The `$depth` parameter was added. * - * @param string[] $classes Array of the CSS classes that are applied to the menu item's `
  • ` element. - * @param WP_Post $item The current menu item. - * @param stdClass $args An object of wp_nav_menu() arguments. - * @param int $depth Depth of menu item. Used for padding. + * @param string[] $classes Array of the CSS classes that are applied to the menu item's `
  • ` element. + * @param WP_Post $menu_item The current menu item object. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. */ - $class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); + $class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) ); $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; /** @@ -159,26 +163,26 @@ class Walker_Nav_Menu extends Walker { * @since 3.0.1 * @since 4.1.0 The `$depth` parameter was added. * - * @param string $menu_id The ID that is applied to the menu item's `
  • ` element. - * @param WP_Post $item The current menu item. - * @param stdClass $args An object of wp_nav_menu() arguments. - * @param int $depth Depth of menu item. Used for padding. + * @param string $menu_id The ID that is applied to the menu item's `
  • ` element. + * @param WP_Post $menu_item The current menu item. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. */ - $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth ); + $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $menu_item->ID, $menu_item, $args, $depth ); $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; $atts = array(); - $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; - if ( '_blank' === $item->target && empty( $item->xfn ) ) { + $atts['title'] = ! empty( $menu_item->attr_title ) ? $menu_item->attr_title : ''; + $atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : ''; + if ( '_blank' === $menu_item->target && empty( $menu_item->xfn ) ) { $atts['rel'] = 'noopener'; } else { - $atts['rel'] = $item->xfn; + $atts['rel'] = $menu_item->xfn; } - $atts['href'] = ! empty( $item->url ) ? $item->url : ''; - $atts['aria-current'] = $item->current ? 'page' : ''; + $atts['href'] = ! empty( $menu_item->url ) ? $menu_item->url : ''; + $atts['aria-current'] = $menu_item->current ? 'page' : ''; /** * Filters the HTML attributes applied to a menu item's anchor element. @@ -195,11 +199,11 @@ class Walker_Nav_Menu extends Walker { * @type string $href The href attribute. * @type string $aria-current The aria-current attribute. * } - * @param WP_Post $item The current menu item. - * @param stdClass $args An object of wp_nav_menu() arguments. - * @param int $depth Depth of menu item. Used for padding. + * @param WP_Post $menu_item The current menu item object. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. */ - $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); + $atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ); $attributes = ''; foreach ( $atts as $attr => $value ) { @@ -210,19 +214,19 @@ class Walker_Nav_Menu extends Walker { } /** This filter is documented in wp-includes/post-template.php */ - $title = apply_filters( 'the_title', $item->title, $item->ID ); + $title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID ); /** * Filters a menu item's title. * * @since 4.4.0 * - * @param string $title The menu item's title. - * @param WP_Post $item The current menu item. - * @param stdClass $args An object of wp_nav_menu() arguments. - * @param int $depth Depth of menu item. Used for padding. + * @param string $title The menu item's title. + * @param WP_Post $menu_item The current menu item object. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. */ - $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); + $title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth ); $item_output = $args->before; $item_output .= ''; @@ -240,11 +244,11 @@ class Walker_Nav_Menu extends Walker { * @since 3.0.0 * * @param string $item_output The menu item's starting HTML output. - * @param WP_Post $item Menu item data object. + * @param WP_Post $menu_item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param stdClass $args An object of wp_nav_menu() arguments. */ - $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); + $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args ); } /** diff --git a/wp-includes/class-walker-page-dropdown.php b/wp-includes/class-walker-page-dropdown.php index 1e3a2fd3aa..f391f1ace8 100644 --- a/wp-includes/class-walker-page-dropdown.php +++ b/wp-includes/class-walker-page-dropdown.php @@ -44,20 +44,23 @@ class Walker_PageDropdown extends Walker { * Starts the element output. * * @since 2.1.0 + * @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support. * * @see Walker::start_el() * - * @param string $output Used to append additional content. Passed by reference. - * @param WP_Post $page Page data object. - * @param int $depth Optional. Depth of page in reference to parent pages. Used for padding. - * Default 0. - * @param array $args Optional. Uses 'selected' argument for selected page to set selected HTML - * attribute for option element. Uses 'value_field' argument to fill "value" - * attribute. See wp_dropdown_pages(). Default empty array. - * @param int $id Optional. ID of the current page. Default 0 (unused). + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $data_object Page data object. + * @param int $depth Optional. Depth of page in reference to parent pages. Used for padding. + * Default 0. + * @param array $args Optional. Uses 'selected' argument for selected page to set selected HTML + * attribute for option element. Uses 'value_field' argument to fill "value" + * attribute. See wp_dropdown_pages(). Default empty array. + * @param int $id Optional. ID of the current page. Default 0 (unused). */ - public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) { - $pad = str_repeat( ' ', $depth * 3 ); + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) { + // Restores the more descriptive, specific name for use within this method. + $page = $data_object; + $pad = str_repeat( ' ', $depth * 3 ); if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) { $args['value_field'] = 'ID'; diff --git a/wp-includes/class-walker-page.php b/wp-includes/class-walker-page.php index 5c2684929d..6eaa147050 100644 --- a/wp-includes/class-walker-page.php +++ b/wp-includes/class-walker-page.php @@ -93,14 +93,18 @@ class Walker_Page extends Walker { * * @see Walker::start_el() * @since 2.1.0 + * @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support. * * @param string $output Used to append additional content. Passed by reference. - * @param WP_Post $page Page data object. + * @param WP_Post $data_object Page data object. * @param int $depth Optional. Depth of page. Used for padding. Default 0. * @param array $args Optional. Array of arguments. Default empty array. * @param int $current_page Optional. Page ID. Default 0. */ - public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_page = 0 ) { + // Restores the more descriptive, specific name for use within this method. + $page = $data_object; + if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { $t = "\t"; $n = "\n"; diff --git a/wp-includes/class-wp-walker.php b/wp-includes/class-wp-walker.php index c76451cd94..b3c5c6e696 100644 --- a/wp-includes/class-wp-walker.php +++ b/wp-includes/class-wp-walker.php @@ -83,15 +83,16 @@ class Walker { * class methods. Includes the element output also. * * @since 2.1.0 + * @since 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support. * @abstract * * @param string $output Used to append additional content (passed by reference). - * @param object $object The data object. + * @param object $data_object The data object. * @param int $depth Depth of the item. * @param array $args An array of additional arguments. * @param int $current_object_id ID of the current item. */ - public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {} + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {} /** * Ends the element output, if needed. diff --git a/wp-includes/version.php b/wp-includes/version.php index ed88002d24..bdb85509ae 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51738'; +$wp_version = '5.9-alpha-51739'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.