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

Props freewebmentor.
Fixes #45059.

git-svn-id: https://develop.svn.wordpress.org/trunk@45667 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-07-25 00:47:53 +00:00
parent 3d1714de71
commit e5a0610d53
21 changed files with 623 additions and 618 deletions
+15 -15
View File
@@ -162,12 +162,12 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
'link_rating' => 0,
);
$args = wp_parse_args( $linkdata, $defaults );
$r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
$parsed_args = wp_parse_args( $linkdata, $defaults );
$parsed_args = wp_unslash( sanitize_bookmark( $parsed_args, 'db' ) );
$link_id = $r['link_id'];
$link_name = $r['link_name'];
$link_url = $r['link_url'];
$link_id = $parsed_args['link_id'];
$link_name = $parsed_args['link_name'];
$link_url = $parsed_args['link_url'];
$update = false;
if ( ! empty( $link_id ) ) {
@@ -186,16 +186,16 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
return 0;
}
$link_rating = ( ! empty( $r['link_rating'] ) ) ? $r['link_rating'] : 0;
$link_image = ( ! empty( $r['link_image'] ) ) ? $r['link_image'] : '';
$link_target = ( ! empty( $r['link_target'] ) ) ? $r['link_target'] : '';
$link_visible = ( ! empty( $r['link_visible'] ) ) ? $r['link_visible'] : 'Y';
$link_owner = ( ! empty( $r['link_owner'] ) ) ? $r['link_owner'] : get_current_user_id();
$link_notes = ( ! empty( $r['link_notes'] ) ) ? $r['link_notes'] : '';
$link_description = ( ! empty( $r['link_description'] ) ) ? $r['link_description'] : '';
$link_rss = ( ! empty( $r['link_rss'] ) ) ? $r['link_rss'] : '';
$link_rel = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : '';
$link_category = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array();
$link_rating = ( ! empty( $parsed_args['link_rating'] ) ) ? $parsed_args['link_rating'] : 0;
$link_image = ( ! empty( $parsed_args['link_image'] ) ) ? $parsed_args['link_image'] : '';
$link_target = ( ! empty( $parsed_args['link_target'] ) ) ? $parsed_args['link_target'] : '';
$link_visible = ( ! empty( $parsed_args['link_visible'] ) ) ? $parsed_args['link_visible'] : 'Y';
$link_owner = ( ! empty( $parsed_args['link_owner'] ) ) ? $parsed_args['link_owner'] : get_current_user_id();
$link_notes = ( ! empty( $parsed_args['link_notes'] ) ) ? $parsed_args['link_notes'] : '';
$link_description = ( ! empty( $parsed_args['link_description'] ) ) ? $parsed_args['link_description'] : '';
$link_rss = ( ! empty( $parsed_args['link_rss'] ) ) ? $parsed_args['link_rss'] : '';
$link_rel = ( ! empty( $parsed_args['link_rel'] ) ) ? $parsed_args['link_rel'] : '';
$link_category = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array();
// Make sure we set a valid category.
if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {
+13 -12
View File
@@ -1493,7 +1493,8 @@ function get_media_item( $attachment_id, $args = null ) {
'toggle' => true,
'show_title' => true,
);
$args = wp_parse_args( $args, $default_args );
$parsed_args = wp_parse_args( $args, $default_args );
/**
* Filters the arguments used to retrieve an image for the edit image form.
@@ -1502,9 +1503,9 @@ function get_media_item( $attachment_id, $args = null ) {
*
* @see get_media_item
*
* @param array $args An array of arguments.
* @param array $parsed_args An array of arguments.
*/
$r = apply_filters( 'get_media_item_args', $args );
$parsed_args = apply_filters( 'get_media_item_args', $parsed_args );
$toggle_on = __( 'Show' );
$toggle_off = __( 'Hide' );
@@ -1518,10 +1519,10 @@ function get_media_item( $attachment_id, $args = null ) {
$type = reset( $keys );
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
$form_fields = get_attachment_fields_to_edit( $post, $r['errors'] );
$form_fields = get_attachment_fields_to_edit( $post, $parsed_args['errors'] );
if ( $r['toggle'] ) {
$class = empty( $r['errors'] ) ? 'startclosed' : 'startopen';
if ( $parsed_args['toggle'] ) {
$class = empty( $parsed_args['errors'] ) ? 'startclosed' : 'startopen';
$toggle_links = "
<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
@@ -1531,7 +1532,7 @@ function get_media_item( $attachment_id, $args = null ) {
}
$display_title = ( ! empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
$display_title = $r['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '&hellip;' ) . '</span></div>' : '';
$display_title = $parsed_args['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60, '&hellip;' ) . '</span></div>' : '';
$gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
$order = '';
@@ -1609,11 +1610,11 @@ function get_media_item( $attachment_id, $args = null ) {
'extra_rows' => array(),
);
if ( $r['send'] ) {
$r['send'] = get_submit_button( __( 'Insert into Post' ), '', "send[$attachment_id]", false );
if ( $parsed_args['send'] ) {
$parsed_args['send'] = get_submit_button( __( 'Insert into Post' ), '', "send[$attachment_id]", false );
}
$delete = empty( $r['delete'] ) ? '' : $r['delete'];
$delete = empty( $parsed_args['delete'] ) ? '' : $parsed_args['delete'];
if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
if ( ! EMPTY_TRASH_DAYS ) {
$delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>';
@@ -1650,8 +1651,8 @@ function get_media_item( $attachment_id, $args = null ) {
$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html( $calling_post_type_object->labels->use_featured_image ) . '</a>';
}
if ( ( $r['send'] || $thumbnail || $delete ) && ! isset( $form_fields['buttons'] ) ) {
$form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>" . $r['send'] . " $thumbnail $delete</td></tr>\n" );
if ( ( $parsed_args['send'] || $thumbnail || $delete ) && ! isset( $form_fields['buttons'] ) ) {
$form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>" . $parsed_args['send'] . " $thumbnail $delete</td></tr>\n" );
}
$hidden_fields = array();
+10 -10
View File
@@ -492,9 +492,9 @@ function post_tags_meta_box( $post, $box ) {
} else {
$args = $box['args'];
}
$r = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $r['taxonomy'] );
$taxonomy = get_taxonomy( $r['taxonomy'] );
$parsed_args = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $parsed_args['taxonomy'] );
$taxonomy = get_taxonomy( $parsed_args['taxonomy'] );
$user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
$comma = _x( ',', 'tag delimiter' );
$terms_to_edit = get_terms_to_edit( $post->ID, $tax_name );
@@ -555,9 +555,9 @@ function post_categories_meta_box( $post, $box ) {
} else {
$args = $box['args'];
}
$r = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $r['taxonomy'] );
$taxonomy = get_taxonomy( $r['taxonomy'] );
$parsed_args = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $parsed_args['taxonomy'] );
$taxonomy = get_taxonomy( $parsed_args['taxonomy'] );
?>
<div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv">
<ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs">
@@ -1310,12 +1310,12 @@ function link_advanced_meta_box( $link ) {
<th scope="row"><label for="link_rating"><?php _e( 'Rating' ); ?></label></th>
<td><select name="link_rating" id="link_rating" size="1">
<?php
for ( $r = 0; $r <= 10; $r++ ) {
echo '<option value="' . $r . '"';
if ( isset( $link->link_rating ) && $link->link_rating == $r ) {
for ( $parsed_args = 0; $parsed_args <= 10; $parsed_args++ ) {
echo '<option value="' . $parsed_args . '"';
if ( isset( $link->link_rating ) && $link->link_rating == $parsed_args ) {
echo ' selected="selected"';
}
echo( '>' . $r . '</option>' );
echo( '>' . $parsed_args . '</option>' );
}
?>
</select>&nbsp;<?php _e( '(Leave at 0 for no rating.)' ); ?>
+5 -5
View File
@@ -1089,7 +1089,7 @@ function network_edit_site_nav( $args = array() ) {
);
// Parse arguments
$r = wp_parse_args(
$parsed_args = wp_parse_args(
$args,
array(
'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
@@ -1102,10 +1102,10 @@ function network_edit_site_nav( $args = array() ) {
$screen_links = array();
// Loop through tabs
foreach ( $r['links'] as $link_id => $link ) {
foreach ( $parsed_args['links'] as $link_id => $link ) {
// Skip link if user can't access
if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) {
if ( ! current_user_can( $link['cap'], $parsed_args['blog_id'] ) ) {
continue;
}
@@ -1116,7 +1116,7 @@ function network_edit_site_nav( $args = array() ) {
$aria_current = '';
// Selected is set by the parent OR assumed by the $pagenow global
if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
if ( $parsed_args['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) {
$classes[] = 'nav-tab-active';
$aria_current = ' aria-current="page"';
}
@@ -1125,7 +1125,7 @@ function network_edit_site_nav( $args = array() ) {
$esc_classes = implode( ' ', $classes );
// Get the URL for this link
$url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) );
$url = add_query_arg( array( 'id' => $parsed_args['blog_id'] ), network_admin_url( $link['url'] ) );
// Add link to nav links
$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>';
+20 -20
View File
@@ -100,33 +100,33 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
*/
$params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
$r = wp_parse_args( $params, $defaults );
$parsed_args = wp_parse_args( $params, $defaults );
if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) {
if ( empty( $parsed_args['walker'] ) || ! ( $parsed_args['walker'] instanceof Walker ) ) {
$walker = new Walker_Category_Checklist;
} else {
$walker = $r['walker'];
$walker = $parsed_args['walker'];
}
$taxonomy = $r['taxonomy'];
$descendants_and_self = (int) $r['descendants_and_self'];
$taxonomy = $parsed_args['taxonomy'];
$descendants_and_self = (int) $parsed_args['descendants_and_self'];
$args = array( 'taxonomy' => $taxonomy );
$tax = get_taxonomy( $taxonomy );
$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
$args['list_only'] = ! empty( $r['list_only'] );
$args['list_only'] = ! empty( $parsed_args['list_only'] );
if ( is_array( $r['selected_cats'] ) ) {
$args['selected_cats'] = $r['selected_cats'];
if ( is_array( $parsed_args['selected_cats'] ) ) {
$args['selected_cats'] = $parsed_args['selected_cats'];
} elseif ( $post_id ) {
$args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
} else {
$args['selected_cats'] = array();
}
if ( is_array( $r['popular_cats'] ) ) {
$args['popular_cats'] = $r['popular_cats'];
if ( is_array( $parsed_args['popular_cats'] ) ) {
$args['popular_cats'] = $parsed_args['popular_cats'];
} else {
$args['popular_cats'] = get_terms(
$taxonomy,
@@ -156,7 +156,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
$output = '';
if ( $r['checked_ontop'] ) {
if ( $parsed_args['checked_ontop'] ) {
// 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)
$checked_categories = array();
$keys = array_keys( $categories );
@@ -174,7 +174,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
// Then the rest of them
$output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
if ( $r['echo'] ) {
if ( $parsed_args['echo'] ) {
echo $output;
}
@@ -2441,19 +2441,19 @@ function _local_storage_notice() {
* @return string Star rating HTML.
*/
function wp_star_rating( $args = array() ) {
$defaults = array(
$defaults = array(
'rating' => 0,
'type' => 'rating',
'number' => 0,
'echo' => true,
);
$r = wp_parse_args( $args, $defaults );
$parsed_args = wp_parse_args( $args, $defaults );
// Non-English decimal places when the $rating is coming from a string
$rating = (float) str_replace( ',', '.', $r['rating'] );
$rating = (float) str_replace( ',', '.', $parsed_args['rating'] );
// Convert Percentage to star rating, 0..5 in .5 increments
if ( 'percent' === $r['type'] ) {
if ( 'percent' === $parsed_args['type'] ) {
$rating = round( $rating / 10, 0 ) / 2;
}
@@ -2462,10 +2462,10 @@ function wp_star_rating( $args = array() ) {
$half_stars = ceil( $rating - $full_stars );
$empty_stars = 5 - $full_stars - $half_stars;
if ( $r['number'] ) {
if ( $parsed_args['number'] ) {
/* translators: 1: the rating, 2: the number of ratings */
$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
$title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $parsed_args['number'] );
$title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $parsed_args['number'] ) );
} else {
/* translators: %s: the rating */
$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
@@ -2478,7 +2478,7 @@ function wp_star_rating( $args = array() ) {
$output .= str_repeat( '<div class="star star-empty" aria-hidden="true"></div>', $empty_stars );
$output .= '</div>';
if ( $r['echo'] ) {
if ( $parsed_args['echo'] ) {
echo $output;
}