Make WordPress Core


Ignore:
Timestamp:
04/19/2022 03:11:22 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/template.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_popular_terms_checklist()
    • _post_states()
    • _media_states()
  • Renames the $default parameter to $default_term in wp_popular_terms_checklist().
  • Renames the $default parameter to $default_template in page_template_dropdown().
  • Renames the $default parameter to $default_page in parent_dropdown().
  • Renames the $object parameter to $data_object in:
    • do_block_editor_incompatible_meta_box()
    • do_meta_boxes()
    • do_accordion_sections()
  • Amends the $item_object parameter in other functions for consistency:
    • 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], [53207], [53215], [53216].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.

File:
1 edited

Legend:

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

    r53207 r53220  
    326326 * @global int|string $nav_menu_selected_id
    327327 *
    328  * @param string $item_object Not used.
     328 * @param string $data_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( $item_object, $box ) {
     338function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
    339339    global $_nav_menu_placeholder, $nav_menu_selected_id;
    340340
     
    690690 * @global int|string $nav_menu_selected_id
    691691 *
    692  * @param string $item_object Not used.
     692 * @param string $data_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( $item_object, $box ) {
     702function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
    703703    global $nav_menu_selected_id;
    704704
     
    990990 * @access private
    991991 *
    992  * @param object $item_object The post type or taxonomy meta-object.
     992 * @param object $data_object The post type or taxonomy meta-object.
    993993 * @return object The post type or taxonomy object.
    994994 */
    995995function _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(
     996    if ( isset( $data_object->name ) ) {
     997
     998        if ( 'page' === $data_object->name ) {
     999            $data_object->_default_query = array(
    10001000                'orderby'     => 'menu_order title',
    10011001                'post_status' => 'publish',
     
    10031003
    10041004            // Posts should show only published items.
    1005         } elseif ( 'post' === $item_object->name ) {
    1006             $item_object->_default_query = array(
     1005        } elseif ( 'post' === $data_object->name ) {
     1006            $data_object->_default_query = array(
    10071007                'post_status' => 'publish',
    10081008            );
    10091009
    10101010            // Categories should be in reverse chronological order.
    1011         } elseif ( 'category' === $item_object->name ) {
    1012             $item_object->_default_query = array(
     1011        } elseif ( 'category' === $data_object->name ) {
     1012            $data_object->_default_query = array(
    10131013                'orderby' => 'id',
    10141014                'order'   => 'DESC',
     
    10171017            // Custom post types should show only published items.
    10181018        } else {
    1019             $item_object->_default_query = array(
     1019            $data_object->_default_query = array(
    10201020                'post_status' => 'publish',
    10211021            );
     
    10231023    }
    10241024
    1025     return $item_object;
     1025    return $data_object;
    10261026}
    10271027
Note: See TracChangeset for help on using the changeset viewer.