Make WordPress Core


Ignore:
Timestamp:
04/18/2022 03:20:16 PM (23 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/nav-menu.php

    r50981 r53207  
    263263 *
    264264 * @since 3.6.0
    265  * @since 5.3.1 The `$echo` parameter was added.
     265 * @since 5.3.1 The `$display` parameter was added.
    266266 *
    267267 * @global bool $one_theme_location_no_menus to determine if no menus exist
    268268 *
    269269 * @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu.
    270  * @param bool       $echo                 Whether to echo or just return the string.
     270 * @param bool       $display              Whether to display or just return the string.
    271271 * @return string|false Disabled attribute if at least one menu exists, false if not.
    272272 */
    273 function wp_nav_menu_disabled_check( $nav_menu_selected_id, $echo = true ) {
     273function wp_nav_menu_disabled_check( $nav_menu_selected_id, $display = true ) {
    274274    global $one_theme_location_no_menus;
    275275
     
    278278    }
    279279
    280     return disabled( $nav_menu_selected_id, 0, $echo );
     280    return disabled( $nav_menu_selected_id, 0, $display );
    281281}
    282282
     
    326326 * @global int|string $nav_menu_selected_id
    327327 *
    328  * @param string $object Not used.
     328 * @param string $item_object Not used.
    329329 * @param array  $box {
    330330 *     Post type menu item meta box arguments.
     
    336336 * }
    337337 */
    338 function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
     338function wp_nav_menu_item_post_type_meta_box( $item_object, $box ) {
    339339    global $_nav_menu_placeholder, $nav_menu_selected_id;
    340340
     
    690690 * @global int|string $nav_menu_selected_id
    691691 *
    692  * @param string $object Not used.
     692 * @param string $item_object Not used.
    693693 * @param array  $box {
    694694 *     Taxonomy menu item meta box arguments.
     
    700700 * }
    701701 */
    702 function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
     702function wp_nav_menu_item_taxonomy_meta_box( $item_object, $box ) {
    703703    global $nav_menu_selected_id;
    704704
     
    990990 * @access private
    991991 *
    992  * @param object $object The post type or taxonomy meta-object.
     992 * @param object $item_object The post type or taxonomy meta-object.
    993993 * @return object The post type or taxonomy object.
    994994 */
    995 function _wp_nav_menu_meta_box_object( $object = null ) {
    996     if ( isset( $object->name ) ) {
    997 
    998         if ( 'page' === $object->name ) {
    999             $object->_default_query = array(
     995function _wp_nav_menu_meta_box_object( $item_object = null ) {
     996    if ( isset( $item_object->name ) ) {
     997
     998        if ( 'page' === $item_object->name ) {
     999            $item_object->_default_query = array(
    10001000                'orderby'     => 'menu_order title',
    10011001                'post_status' => 'publish',
     
    10031003
    10041004            // Posts should show only published items.
    1005         } elseif ( 'post' === $object->name ) {
    1006             $object->_default_query = array(
     1005        } elseif ( 'post' === $item_object->name ) {
     1006            $item_object->_default_query = array(
    10071007                'post_status' => 'publish',
    10081008            );
    10091009
    10101010            // Categories should be in reverse chronological order.
    1011         } elseif ( 'category' === $object->name ) {
    1012             $object->_default_query = array(
     1011        } elseif ( 'category' === $item_object->name ) {
     1012            $item_object->_default_query = array(
    10131013                'orderby' => 'id',
    10141014                'order'   => 'DESC',
     
    10171017            // Custom post types should show only published items.
    10181018        } else {
    1019             $object->_default_query = array(
     1019            $item_object->_default_query = array(
    10201020                'post_status' => 'publish',
    10211021            );
     
    10231023    }
    10241024
    1025     return $object;
     1025    return $item_object;
    10261026}
    10271027
Note: See TracChangeset for help on using the changeset viewer.