From ccde5b8bd3aca3330e2585141a6dce65fb44b980 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 23 Apr 2022 20:59:10 +0000 Subject: [PATCH] Code Modernization: Rename parameters that use reserved keywords in `wp-includes/class-wp-customize-nav-menus.php`. While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit renames the `$type` and `$object` parameters to `$object_type` and `$object_name` in `WP_Customize_Nav_Menus::load_available_items_query()`. Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. Built from https://develop.svn.wordpress.org/trunk@53245 git-svn-id: http://core.svn.wordpress.org/trunk@52834 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-nav-menus.php | 38 ++++++++++---------- wp-includes/version.php | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php index 9e78356c26..80c6df8bcb 100644 --- a/wp-includes/class-wp-customize-nav-menus.php +++ b/wp-includes/class-wp-customize-nav-menus.php @@ -131,17 +131,17 @@ final class WP_Customize_Nav_Menus { * * @since 4.3.0 * - * @param string $type Optional. Accepts any custom object type and has built-in support for - * 'post_type' and 'taxonomy'. Default is 'post_type'. - * @param string $object Optional. Accepts any registered taxonomy or post type name. Default is 'page'. - * @param int $page Optional. The page number used to generate the query offset. Default is '0'. + * @param string $object_type Optional. Accepts any custom object type and has built-in support for + * 'post_type' and 'taxonomy'. Default is 'post_type'. + * @param string $object_name Optional. Accepts any registered taxonomy or post type name. Default is 'page'. + * @param int $page Optional. The page number used to generate the query offset. Default is '0'. * @return array|WP_Error An array of menu items on success, a WP_Error object on failure. */ - public function load_available_items_query( $type = 'post_type', $object = 'page', $page = 0 ) { + public function load_available_items_query( $object_type = 'post_type', $object_name = 'page', $page = 0 ) { $items = array(); - if ( 'post_type' === $type ) { - $post_type = get_post_type_object( $object ); + if ( 'post_type' === $object_type ) { + $post_type = get_post_type_object( $object_name ); if ( ! $post_type ) { return new WP_Error( 'nav_menus_invalid_post_type' ); } @@ -152,7 +152,7 @@ final class WP_Customize_Nav_Menus { */ $important_pages = array(); $suppress_page_ids = array(); - if ( 0 === $page && 'page' === $object ) { + if ( 0 === $page && 'page' === $object_name ) { // Insert Front Page or custom "Home" link. $front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; if ( ! empty( $front_page ) ) { @@ -188,15 +188,15 @@ final class WP_Customize_Nav_Menus { $suppress_page_ids[] = $privacy_policy_page->ID; } } - } elseif ( 'post' !== $object && 0 === $page && $post_type->has_archive ) { + } elseif ( 'post' !== $object_name && 0 === $page && $post_type->has_archive ) { // Add a post type archive link. $items[] = array( - 'id' => $object . '-archive', + 'id' => $object_name . '-archive', 'title' => $post_type->labels->archives, 'type' => 'post_type_archive', 'type_label' => __( 'Post Type Archive' ), - 'object' => $object, - 'url' => get_post_type_archive_link( $object ), + 'object' => $object_name, + 'url' => get_post_type_archive_link( $object_name ), ); } @@ -216,7 +216,7 @@ final class WP_Customize_Nav_Menus { 'offset' => 10 * $page, 'orderby' => 'date', 'order' => 'DESC', - 'post_type' => $object, + 'post_type' => $object_name, ); // Add suppression array to arguments for get_posts. @@ -253,10 +253,10 @@ final class WP_Customize_Nav_Menus { 'url' => get_permalink( (int) $post->ID ), ); } - } elseif ( 'taxonomy' === $type ) { + } elseif ( 'taxonomy' === $object_type ) { $terms = get_terms( array( - 'taxonomy' => $object, + 'taxonomy' => $object_name, 'child_of' => 0, 'exclude' => '', 'hide_empty' => false, @@ -292,12 +292,12 @@ final class WP_Customize_Nav_Menus { * * @since 4.3.0 * - * @param array $items The array of menu items. - * @param string $type The object type. - * @param string $object The object name. + * @param array $items The array of menu items. + * @param string $object_type The object type. + * @param string $object_name The object name. * @param int $page The current page number. */ - $items = apply_filters( 'customize_nav_menu_available_items', $items, $type, $object, $page ); + $items = apply_filters( 'customize_nav_menu_available_items', $items, $object_type, $object_name, $page ); return $items; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 20bd4efa66..8476316ca3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-beta2-53244'; +$wp_version = '6.0-beta2-53245'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.