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
This commit is contained in:
parent
af5365ff02
commit
ccde5b8bd3
|
@ -131,17 +131,17 @@ final class WP_Customize_Nav_Menus {
|
||||||
*
|
*
|
||||||
* @since 4.3.0
|
* @since 4.3.0
|
||||||
*
|
*
|
||||||
* @param string $type Optional. Accepts any custom object type and has built-in support for
|
* @param string $object_type Optional. Accepts any custom object type and has built-in support for
|
||||||
* 'post_type' and 'taxonomy'. Default is 'post_type'.
|
* 'post_type' and 'taxonomy'. Default is 'post_type'.
|
||||||
* @param string $object Optional. Accepts any registered taxonomy or post type name. Default is 'page'.
|
* @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'.
|
* @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.
|
* @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();
|
$items = array();
|
||||||
|
|
||||||
if ( 'post_type' === $type ) {
|
if ( 'post_type' === $object_type ) {
|
||||||
$post_type = get_post_type_object( $object );
|
$post_type = get_post_type_object( $object_name );
|
||||||
if ( ! $post_type ) {
|
if ( ! $post_type ) {
|
||||||
return new WP_Error( 'nav_menus_invalid_post_type' );
|
return new WP_Error( 'nav_menus_invalid_post_type' );
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ final class WP_Customize_Nav_Menus {
|
||||||
*/
|
*/
|
||||||
$important_pages = array();
|
$important_pages = array();
|
||||||
$suppress_page_ids = array();
|
$suppress_page_ids = array();
|
||||||
if ( 0 === $page && 'page' === $object ) {
|
if ( 0 === $page && 'page' === $object_name ) {
|
||||||
// Insert Front Page or custom "Home" link.
|
// Insert Front Page or custom "Home" link.
|
||||||
$front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;
|
$front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;
|
||||||
if ( ! empty( $front_page ) ) {
|
if ( ! empty( $front_page ) ) {
|
||||||
|
@ -188,15 +188,15 @@ final class WP_Customize_Nav_Menus {
|
||||||
$suppress_page_ids[] = $privacy_policy_page->ID;
|
$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.
|
// Add a post type archive link.
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'id' => $object . '-archive',
|
'id' => $object_name . '-archive',
|
||||||
'title' => $post_type->labels->archives,
|
'title' => $post_type->labels->archives,
|
||||||
'type' => 'post_type_archive',
|
'type' => 'post_type_archive',
|
||||||
'type_label' => __( 'Post Type Archive' ),
|
'type_label' => __( 'Post Type Archive' ),
|
||||||
'object' => $object,
|
'object' => $object_name,
|
||||||
'url' => get_post_type_archive_link( $object ),
|
'url' => get_post_type_archive_link( $object_name ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ final class WP_Customize_Nav_Menus {
|
||||||
'offset' => 10 * $page,
|
'offset' => 10 * $page,
|
||||||
'orderby' => 'date',
|
'orderby' => 'date',
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
'post_type' => $object,
|
'post_type' => $object_name,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add suppression array to arguments for get_posts.
|
// Add suppression array to arguments for get_posts.
|
||||||
|
@ -253,10 +253,10 @@ final class WP_Customize_Nav_Menus {
|
||||||
'url' => get_permalink( (int) $post->ID ),
|
'url' => get_permalink( (int) $post->ID ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif ( 'taxonomy' === $type ) {
|
} elseif ( 'taxonomy' === $object_type ) {
|
||||||
$terms = get_terms(
|
$terms = get_terms(
|
||||||
array(
|
array(
|
||||||
'taxonomy' => $object,
|
'taxonomy' => $object_name,
|
||||||
'child_of' => 0,
|
'child_of' => 0,
|
||||||
'exclude' => '',
|
'exclude' => '',
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
|
@ -292,12 +292,12 @@ final class WP_Customize_Nav_Menus {
|
||||||
*
|
*
|
||||||
* @since 4.3.0
|
* @since 4.3.0
|
||||||
*
|
*
|
||||||
* @param array $items The array of menu items.
|
* @param array $items The array of menu items.
|
||||||
* @param string $type The object type.
|
* @param string $object_type The object type.
|
||||||
* @param string $object The object name.
|
* @param string $object_name The object name.
|
||||||
* @param int $page The current page number.
|
* @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;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue