Make WordPress Core


Ignore:
Timestamp:
04/19/2022 01:49:19 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/taxonomy.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 $parent parameter to $category_parent in category_exists() and wp_create_category(). This matches the category object property of the same name.
  • Amends similar parameters in dropdown_categories() and wp_dropdown_cats() for consistency.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215].

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

File:
1 edited

Legend:

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

    r53184 r53216  
    7979 *
    8080 * @param int   $default_category Unused.
    81  * @param int   $parent_category  Unused.
     81 * @param int   $category_parent  Unused.
    8282 * @param array $popular_ids      Unused.
    8383 */
    84 function dropdown_categories( $default_category = 0, $parent_category = 0, $popular_ids = array() ) {
     84function dropdown_categories( $default_category = 0, $category_parent = 0, $popular_ids = array() ) {
    8585    _deprecated_function( __FUNCTION__, '2.6.0', 'wp_category_checklist()' );
    8686    global $post_ID;
     
    128128 * @see wp_dropdown_categories()
    129129 *
    130  * @param int $current_cat    Optional. ID of the current category. Default 0.
    131  * @param int $current_parent Optional. Current parent category ID. Default 0.
    132  * @param int $parent_cat    Optional. Parent ID to retrieve categories for. Default 0.
    133  * @param int $level          Optional. Number of levels deep to display. Default 0.
    134  * @param array $categories   Optional. Categories to include in the control. Default 0.
     130 * @param int $current_cat     Optional. ID of the current category. Default 0.
     131 * @param int $current_parent  Optional. Current parent category ID. Default 0.
     132 * @param int $category_parent Optional. Parent ID to retrieve categories for. Default 0.
     133 * @param int $level           Optional. Number of levels deep to display. Default 0.
     134 * @param array $categories    Optional. Categories to include in the control. Default 0.
    135135 * @return void|false Void on success, false if no categories were found.
    136136 */
    137 function wp_dropdown_cats( $current_cat = 0, $current_parent = 0, $parent_cat = 0, $level = 0, $categories = 0 ) {
     137function wp_dropdown_cats( $current_cat = 0, $current_parent = 0, $category_parent = 0, $level = 0, $categories = 0 ) {
    138138    _deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
    139139    if (!$categories )
     
    142142    if ( $categories ) {
    143143        foreach ( $categories as $category ) {
    144             if ( $current_cat != $category->term_id && $parent_cat == $category->parent) {
     144            if ( $current_cat != $category->term_id && $category_parent == $category->parent) {
    145145                $pad = str_repeat( '– ', $level );
    146146                $category->name = esc_html( $category->name );
Note: See TracChangeset for help on using the changeset viewer.