WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/25/2019 12:47:53 AM (10 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename $r variable used with wp_parse_args() to $parsed_args for clarity.

Props freewebmentor.
Fixes #45059.

File:
1 edited

Legend:

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

    r45657 r45667  
    101101    $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
    102102
    103     $r = wp_parse_args( $params, $defaults );
    104 
    105     if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) {
     103    $parsed_args = wp_parse_args( $params, $defaults );
     104
     105    if ( empty( $parsed_args['walker'] ) || ! ( $parsed_args['walker'] instanceof Walker ) ) {
    106106        $walker = new Walker_Category_Checklist;
    107107    } else {
    108         $walker = $r['walker'];
    109     }
    110 
    111     $taxonomy             = $r['taxonomy'];
    112     $descendants_and_self = (int) $r['descendants_and_self'];
     108        $walker = $parsed_args['walker'];
     109    }
     110
     111    $taxonomy             = $parsed_args['taxonomy'];
     112    $descendants_and_self = (int) $parsed_args['descendants_and_self'];
    113113
    114114    $args = array( 'taxonomy' => $taxonomy );
     
    117117    $args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
    118118
    119     $args['list_only'] = ! empty( $r['list_only'] );
    120 
    121     if ( is_array( $r['selected_cats'] ) ) {
    122         $args['selected_cats'] = $r['selected_cats'];
     119    $args['list_only'] = ! empty( $parsed_args['list_only'] );
     120
     121    if ( is_array( $parsed_args['selected_cats'] ) ) {
     122        $args['selected_cats'] = $parsed_args['selected_cats'];
    123123    } elseif ( $post_id ) {
    124124        $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
     
    126126        $args['selected_cats'] = array();
    127127    }
    128     if ( is_array( $r['popular_cats'] ) ) {
    129         $args['popular_cats'] = $r['popular_cats'];
     128    if ( is_array( $parsed_args['popular_cats'] ) ) {
     129        $args['popular_cats'] = $parsed_args['popular_cats'];
    130130    } else {
    131131        $args['popular_cats'] = get_terms(
     
    157157    $output = '';
    158158
    159     if ( $r['checked_ontop'] ) {
     159    if ( $parsed_args['checked_ontop'] ) {
    160160        // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
    161161        $checked_categories = array();
     
    175175    $output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
    176176
    177     if ( $r['echo'] ) {
     177    if ( $parsed_args['echo'] ) {
    178178        echo $output;
    179179    }
     
    24422442 */
    24432443function wp_star_rating( $args = array() ) {
    2444     $defaults = array(
     2444    $defaults    = array(
    24452445        'rating' => 0,
    24462446        'type'   => 'rating',
     
    24482448        'echo'   => true,
    24492449    );
    2450     $r        = wp_parse_args( $args, $defaults );
     2450    $parsed_args = wp_parse_args( $args, $defaults );
    24512451
    24522452    // Non-English decimal places when the $rating is coming from a string
    2453     $rating = (float) str_replace( ',', '.', $r['rating'] );
     2453    $rating = (float) str_replace( ',', '.', $parsed_args['rating'] );
    24542454
    24552455    // Convert Percentage to star rating, 0..5 in .5 increments
    2456     if ( 'percent' === $r['type'] ) {
     2456    if ( 'percent' === $parsed_args['type'] ) {
    24572457        $rating = round( $rating / 10, 0 ) / 2;
    24582458    }
     
    24632463    $empty_stars = 5 - $full_stars - $half_stars;
    24642464
    2465     if ( $r['number'] ) {
     2465    if ( $parsed_args['number'] ) {
    24662466        /* translators: 1: the rating, 2: the number of ratings */
    2467         $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
    2468         $title  = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
     2467        $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $parsed_args['number'] );
     2468        $title  = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $parsed_args['number'] ) );
    24692469    } else {
    24702470        /* translators: %s: the rating */
     
    24792479    $output .= '</div>';
    24802480
    2481     if ( $r['echo'] ) {
     2481    if ( $parsed_args['echo'] ) {
    24822482        echo $output;
    24832483    }
Note: See TracChangeset for help on using the changeset viewer.