From a7b2e1b565edd47be19f8d995e142528a2c1c573 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 18 Apr 2022 15:20:16 +0000 Subject: [PATCH] Code Modernization: Rename parameters that use reserved keywords in `wp-admin/includes/nav-menu.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 `$echo` parameter to `$display` in `wp_nav_menu_disabled_check()`. * Renames the `$object` parameter to `$item_object` in: * `wp_nav_menu_item_post_type_meta_box()` * `wp_nav_menu_item_taxonomy_meta_box()` * `_wp_nav_menu_meta_box_object()` Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. git-svn-id: https://develop.svn.wordpress.org/trunk@53207 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/nav-menu.php | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/wp-admin/includes/nav-menu.php b/src/wp-admin/includes/nav-menu.php index 4475d08f96..d3b09ce5df 100644 --- a/src/wp-admin/includes/nav-menu.php +++ b/src/wp-admin/includes/nav-menu.php @@ -262,22 +262,22 @@ function wp_nav_menu_taxonomy_meta_boxes() { * Check whether to disable the Menu Locations meta box submit button and inputs. * * @since 3.6.0 - * @since 5.3.1 The `$echo` parameter was added. + * @since 5.3.1 The `$display` parameter was added. * * @global bool $one_theme_location_no_menus to determine if no menus exist * * @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu. - * @param bool $echo Whether to echo or just return the string. + * @param bool $display Whether to display or just return the string. * @return string|false Disabled attribute if at least one menu exists, false if not. */ -function wp_nav_menu_disabled_check( $nav_menu_selected_id, $echo = true ) { +function wp_nav_menu_disabled_check( $nav_menu_selected_id, $display = true ) { global $one_theme_location_no_menus; if ( $one_theme_location_no_menus ) { return false; } - return disabled( $nav_menu_selected_id, 0, $echo ); + return disabled( $nav_menu_selected_id, 0, $display ); } /** @@ -325,7 +325,7 @@ function wp_nav_menu_item_link_meta_box() { * @global int $_nav_menu_placeholder * @global int|string $nav_menu_selected_id * - * @param string $object Not used. + * @param string $item_object Not used. * @param array $box { * Post type menu item meta box arguments. * @@ -335,7 +335,7 @@ function wp_nav_menu_item_link_meta_box() { * @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box). * } */ -function wp_nav_menu_item_post_type_meta_box( $object, $box ) { +function wp_nav_menu_item_post_type_meta_box( $item_object, $box ) { global $_nav_menu_placeholder, $nav_menu_selected_id; $post_type_name = $box['args']->name; @@ -689,7 +689,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { * * @global int|string $nav_menu_selected_id * - * @param string $object Not used. + * @param string $item_object Not used. * @param array $box { * Taxonomy menu item meta box arguments. * @@ -699,7 +699,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { * @type object $args Extra meta box arguments (the taxonomy object for this meta box). * } */ -function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { +function wp_nav_menu_item_taxonomy_meta_box( $item_object, $box ) { global $nav_menu_selected_id; $taxonomy_name = $box['args']->name; @@ -989,40 +989,40 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { * * @access private * - * @param object $object The post type or taxonomy meta-object. + * @param object $item_object The post type or taxonomy meta-object. * @return object The post type or taxonomy object. */ -function _wp_nav_menu_meta_box_object( $object = null ) { - if ( isset( $object->name ) ) { +function _wp_nav_menu_meta_box_object( $item_object = null ) { + if ( isset( $item_object->name ) ) { - if ( 'page' === $object->name ) { - $object->_default_query = array( + if ( 'page' === $item_object->name ) { + $item_object->_default_query = array( 'orderby' => 'menu_order title', 'post_status' => 'publish', ); // Posts should show only published items. - } elseif ( 'post' === $object->name ) { - $object->_default_query = array( + } elseif ( 'post' === $item_object->name ) { + $item_object->_default_query = array( 'post_status' => 'publish', ); // Categories should be in reverse chronological order. - } elseif ( 'category' === $object->name ) { - $object->_default_query = array( + } elseif ( 'category' === $item_object->name ) { + $item_object->_default_query = array( 'orderby' => 'id', 'order' => 'DESC', ); // Custom post types should show only published items. } else { - $object->_default_query = array( + $item_object->_default_query = array( 'post_status' => 'publish', ); } } - return $object; + return $item_object; } /**