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
+46 -46
View File
@@ -62,7 +62,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
'link_after' => '',
);
$r = wp_parse_args( $args, $defaults );
$parsed_args = wp_parse_args( $args, $defaults );
$output = ''; // Blank string to start with.
@@ -70,8 +70,8 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
if ( ! isset( $bookmark->recently_updated ) ) {
$bookmark->recently_updated = false;
}
$output .= $r['before'];
if ( $r['show_updated'] && $bookmark->recently_updated ) {
$output .= $parsed_args['before'];
if ( $parsed_args['show_updated'] && $bookmark->recently_updated ) {
$output .= '<em>';
}
$the_link = '#';
@@ -82,7 +82,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
$name = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) );
$title = $desc;
if ( $r['show_updated'] ) {
if ( $parsed_args['show_updated'] ) {
if ( '00' != substr( $bookmark->link_updated_f, 0, 2 ) ) {
$title .= ' (';
$title .= sprintf(
@@ -95,7 +95,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
$title .= ')';
}
}
$alt = ' alt="' . $name . ( $r['show_description'] ? ' ' . $title : '' ) . '"';
$alt = ' alt="' . $name . ( $parsed_args['show_description'] ? ' ' . $title : '' ) . '"';
if ( '' != $title ) {
$title = ' title="' . $title . '"';
@@ -110,42 +110,42 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
}
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
$output .= $r['link_before'];
$output .= $parsed_args['link_before'];
if ( $bookmark->link_image != null && $r['show_images'] ) {
if ( $bookmark->link_image != null && $parsed_args['show_images'] ) {
if ( strpos( $bookmark->link_image, 'http' ) === 0 ) {
$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
} else { // If it's a relative path
$output .= '<img src="' . get_option( 'siteurl' ) . "$bookmark->link_image\" $alt $title />";
}
if ( $r['show_name'] ) {
if ( $parsed_args['show_name'] ) {
$output .= " $name";
}
} else {
$output .= $name;
}
$output .= $r['link_after'];
$output .= $parsed_args['link_after'];
$output .= '</a>';
if ( $r['show_updated'] && $bookmark->recently_updated ) {
if ( $parsed_args['show_updated'] && $bookmark->recently_updated ) {
$output .= '</em>';
}
if ( $r['show_description'] && '' != $desc ) {
$output .= $r['between'] . $desc;
if ( $parsed_args['show_description'] && '' != $desc ) {
$output .= $parsed_args['between'] . $desc;
}
if ( $r['show_rating'] ) {
$output .= $r['between'] . sanitize_bookmark_field(
if ( $parsed_args['show_rating'] ) {
$output .= $parsed_args['between'] . sanitize_bookmark_field(
'link_rating',
$bookmark->link_rating,
$bookmark->link_id,
'display'
);
}
$output .= $r['after'] . "\n";
$output .= $parsed_args['after'] . "\n";
} // end while
return $output;
@@ -225,45 +225,45 @@ function wp_list_bookmarks( $args = '' ) {
'category_after' => '</li>',
);
$r = wp_parse_args( $args, $defaults );
$parsed_args = wp_parse_args( $args, $defaults );
$output = '';
if ( ! is_array( $r['class'] ) ) {
$r['class'] = explode( ' ', $r['class'] );
if ( ! is_array( $parsed_args['class'] ) ) {
$parsed_args['class'] = explode( ' ', $parsed_args['class'] );
}
$r['class'] = array_map( 'sanitize_html_class', $r['class'] );
$r['class'] = trim( join( ' ', $r['class'] ) );
$parsed_args['class'] = array_map( 'sanitize_html_class', $parsed_args['class'] );
$parsed_args['class'] = trim( join( ' ', $parsed_args['class'] ) );
if ( $r['categorize'] ) {
if ( $parsed_args['categorize'] ) {
$cats = get_terms(
'link_category',
array(
'name__like' => $r['category_name'],
'include' => $r['category'],
'exclude' => $r['exclude_category'],
'orderby' => $r['category_orderby'],
'order' => $r['category_order'],
'name__like' => $parsed_args['category_name'],
'include' => $parsed_args['category'],
'exclude' => $parsed_args['exclude_category'],
'orderby' => $parsed_args['category_orderby'],
'order' => $parsed_args['category_order'],
'hierarchical' => 0,
)
);
if ( empty( $cats ) ) {
$r['categorize'] = false;
$parsed_args['categorize'] = false;
}
}
if ( $r['categorize'] ) {
if ( $parsed_args['categorize'] ) {
// Split the bookmarks into ul's for each category
foreach ( (array) $cats as $cat ) {
$params = array_merge( $r, array( 'category' => $cat->term_id ) );
$params = array_merge( $parsed_args, array( 'category' => $cat->term_id ) );
$bookmarks = get_bookmarks( $params );
if ( empty( $bookmarks ) ) {
continue;
}
$output .= str_replace(
array( '%id', '%class' ),
array( "linkcat-$cat->term_id", $r['class'] ),
$r['category_before']
array( "linkcat-$cat->term_id", $parsed_args['class'] ),
$parsed_args['category_before']
);
/**
* Filters the category name.
@@ -274,34 +274,34 @@ function wp_list_bookmarks( $args = '' ) {
*/
$catname = apply_filters( 'link_category', $cat->name );
$output .= $r['title_before'];
$output .= $parsed_args['title_before'];
$output .= $catname;
$output .= $r['title_after'];
$output .= $parsed_args['title_after'];
$output .= "\n\t<ul class='xoxo blogroll'>\n";
$output .= _walk_bookmarks( $bookmarks, $r );
$output .= _walk_bookmarks( $bookmarks, $parsed_args );
$output .= "\n\t</ul>\n";
$output .= $r['category_after'] . "\n";
$output .= $parsed_args['category_after'] . "\n";
}
} else {
//output one single list using title_li for the title
$bookmarks = get_bookmarks( $r );
$bookmarks = get_bookmarks( $parsed_args );
if ( ! empty( $bookmarks ) ) {
if ( ! empty( $r['title_li'] ) ) {
if ( ! empty( $parsed_args['title_li'] ) ) {
$output .= str_replace(
array( '%id', '%class' ),
array( 'linkcat-' . $r['category'], $r['class'] ),
$r['category_before']
array( 'linkcat-' . $parsed_args['category'], $parsed_args['class'] ),
$parsed_args['category_before']
);
$output .= $r['title_before'];
$output .= $r['title_li'];
$output .= $r['title_after'];
$output .= $parsed_args['title_before'];
$output .= $parsed_args['title_li'];
$output .= $parsed_args['title_after'];
$output .= "\n\t<ul class='xoxo blogroll'>\n";
$output .= _walk_bookmarks( $bookmarks, $r );
$output .= _walk_bookmarks( $bookmarks, $parsed_args );
$output .= "\n\t</ul>\n";
$output .= $r['category_after'] . "\n";
$output .= $parsed_args['category_after'] . "\n";
} else {
$output .= _walk_bookmarks( $bookmarks, $r );
$output .= _walk_bookmarks( $bookmarks, $parsed_args );
}
}
}
@@ -315,7 +315,7 @@ function wp_list_bookmarks( $args = '' ) {
*/
$html = apply_filters( 'wp_list_bookmarks', $output );
if ( ! $r['echo'] ) {
if ( ! $parsed_args['echo'] ) {
return $html;
}
echo $html;