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

Props freewebmentor.
Fixes #45059.
Built from https://develop.svn.wordpress.org/trunk@45667


git-svn-id: http://core.svn.wordpress.org/trunk@45478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-07-25 00:48:58 +00:00
parent 7112ee7132
commit 18bd01985b
22 changed files with 624 additions and 619 deletions

View File

@ -162,12 +162,12 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
'link_rating' => 0, 'link_rating' => 0,
); );
$args = wp_parse_args( $linkdata, $defaults ); $parsed_args = wp_parse_args( $linkdata, $defaults );
$r = wp_unslash( sanitize_bookmark( $args, 'db' ) ); $parsed_args = wp_unslash( sanitize_bookmark( $parsed_args, 'db' ) );
$link_id = $r['link_id']; $link_id = $parsed_args['link_id'];
$link_name = $r['link_name']; $link_name = $parsed_args['link_name'];
$link_url = $r['link_url']; $link_url = $parsed_args['link_url'];
$update = false; $update = false;
if ( ! empty( $link_id ) ) { if ( ! empty( $link_id ) ) {
@ -186,16 +186,16 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
return 0; return 0;
} }
$link_rating = ( ! empty( $r['link_rating'] ) ) ? $r['link_rating'] : 0; $link_rating = ( ! empty( $parsed_args['link_rating'] ) ) ? $parsed_args['link_rating'] : 0;
$link_image = ( ! empty( $r['link_image'] ) ) ? $r['link_image'] : ''; $link_image = ( ! empty( $parsed_args['link_image'] ) ) ? $parsed_args['link_image'] : '';
$link_target = ( ! empty( $r['link_target'] ) ) ? $r['link_target'] : ''; $link_target = ( ! empty( $parsed_args['link_target'] ) ) ? $parsed_args['link_target'] : '';
$link_visible = ( ! empty( $r['link_visible'] ) ) ? $r['link_visible'] : 'Y'; $link_visible = ( ! empty( $parsed_args['link_visible'] ) ) ? $parsed_args['link_visible'] : 'Y';
$link_owner = ( ! empty( $r['link_owner'] ) ) ? $r['link_owner'] : get_current_user_id(); $link_owner = ( ! empty( $parsed_args['link_owner'] ) ) ? $parsed_args['link_owner'] : get_current_user_id();
$link_notes = ( ! empty( $r['link_notes'] ) ) ? $r['link_notes'] : ''; $link_notes = ( ! empty( $parsed_args['link_notes'] ) ) ? $parsed_args['link_notes'] : '';
$link_description = ( ! empty( $r['link_description'] ) ) ? $r['link_description'] : ''; $link_description = ( ! empty( $parsed_args['link_description'] ) ) ? $parsed_args['link_description'] : '';
$link_rss = ( ! empty( $r['link_rss'] ) ) ? $r['link_rss'] : ''; $link_rss = ( ! empty( $parsed_args['link_rss'] ) ) ? $parsed_args['link_rss'] : '';
$link_rel = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : ''; $link_rel = ( ! empty( $parsed_args['link_rel'] ) ) ? $parsed_args['link_rel'] : '';
$link_category = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array(); $link_category = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array();
// Make sure we set a valid category. // Make sure we set a valid category.
if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) { if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {

View File

@ -1493,7 +1493,8 @@ function get_media_item( $attachment_id, $args = null ) {
'toggle' => true, 'toggle' => true,
'show_title' => 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. * 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 * @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_on = __( 'Show' );
$toggle_off = __( 'Hide' ); $toggle_off = __( 'Hide' );
@ -1518,10 +1519,10 @@ function get_media_item( $attachment_id, $args = null ) {
$type = reset( $keys ); $type = reset( $keys );
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; $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'] ) { if ( $parsed_args['toggle'] ) {
$class = empty( $r['errors'] ) ? 'startclosed' : 'startopen'; $class = empty( $parsed_args['errors'] ) ? 'startclosed' : 'startopen';
$toggle_links = " $toggle_links = "
<a class='toggle describe-toggle-on' href='#'>$toggle_on</a> <a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
<a class='toggle describe-toggle-off' href='#'>$toggle_off</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 = ( ! 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 ) ); $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
$order = ''; $order = '';
@ -1609,11 +1610,11 @@ function get_media_item( $attachment_id, $args = null ) {
'extra_rows' => array(), 'extra_rows' => array(),
); );
if ( $r['send'] ) { if ( $parsed_args['send'] ) {
$r['send'] = get_submit_button( __( 'Insert into Post' ), '', "send[$attachment_id]", false ); $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 ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
if ( ! EMPTY_TRASH_DAYS ) { 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>'; $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>'; $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'] ) ) { 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'>" . $r['send'] . " $thumbnail $delete</td></tr>\n" ); $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(); $hidden_fields = array();

View File

@ -492,9 +492,9 @@ function post_tags_meta_box( $post, $box ) {
} else { } else {
$args = $box['args']; $args = $box['args'];
} }
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $r['taxonomy'] ); $tax_name = esc_attr( $parsed_args['taxonomy'] );
$taxonomy = get_taxonomy( $r['taxonomy'] ); $taxonomy = get_taxonomy( $parsed_args['taxonomy'] );
$user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
$comma = _x( ',', 'tag delimiter' ); $comma = _x( ',', 'tag delimiter' );
$terms_to_edit = get_terms_to_edit( $post->ID, $tax_name ); $terms_to_edit = get_terms_to_edit( $post->ID, $tax_name );
@ -555,9 +555,9 @@ function post_categories_meta_box( $post, $box ) {
} else { } else {
$args = $box['args']; $args = $box['args'];
} }
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$tax_name = esc_attr( $r['taxonomy'] ); $tax_name = esc_attr( $parsed_args['taxonomy'] );
$taxonomy = get_taxonomy( $r['taxonomy'] ); $taxonomy = get_taxonomy( $parsed_args['taxonomy'] );
?> ?>
<div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv"> <div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv">
<ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs"> <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> <th scope="row"><label for="link_rating"><?php _e( 'Rating' ); ?></label></th>
<td><select name="link_rating" id="link_rating" size="1"> <td><select name="link_rating" id="link_rating" size="1">
<?php <?php
for ( $r = 0; $r <= 10; $r++ ) { for ( $parsed_args = 0; $parsed_args <= 10; $parsed_args++ ) {
echo '<option value="' . $r . '"'; echo '<option value="' . $parsed_args . '"';
if ( isset( $link->link_rating ) && $link->link_rating == $r ) { if ( isset( $link->link_rating ) && $link->link_rating == $parsed_args ) {
echo ' selected="selected"'; echo ' selected="selected"';
} }
echo( '>' . $r . '</option>' ); echo( '>' . $parsed_args . '</option>' );
} }
?> ?>
</select>&nbsp;<?php _e( '(Leave at 0 for no rating.)' ); ?> </select>&nbsp;<?php _e( '(Leave at 0 for no rating.)' ); ?>

View File

@ -1089,7 +1089,7 @@ function network_edit_site_nav( $args = array() ) {
); );
// Parse arguments // Parse arguments
$r = wp_parse_args( $parsed_args = wp_parse_args(
$args, $args,
array( array(
'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0, '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(); $screen_links = array();
// Loop through tabs // 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 // 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; continue;
} }
@ -1116,7 +1116,7 @@ function network_edit_site_nav( $args = array() ) {
$aria_current = ''; $aria_current = '';
// Selected is set by the parent OR assumed by the $pagenow global // 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'; $classes[] = 'nav-tab-active';
$aria_current = ' aria-current="page"'; $aria_current = ' aria-current="page"';
} }
@ -1125,7 +1125,7 @@ function network_edit_site_nav( $args = array() ) {
$esc_classes = implode( ' ', $classes ); $esc_classes = implode( ' ', $classes );
// Get the URL for this link // 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 // 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>'; $screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>';

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 ); $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; $walker = new Walker_Category_Checklist;
} else { } else {
$walker = $r['walker']; $walker = $parsed_args['walker'];
} }
$taxonomy = $r['taxonomy']; $taxonomy = $parsed_args['taxonomy'];
$descendants_and_self = (int) $r['descendants_and_self']; $descendants_and_self = (int) $parsed_args['descendants_and_self'];
$args = array( 'taxonomy' => $taxonomy ); $args = array( 'taxonomy' => $taxonomy );
$tax = get_taxonomy( $taxonomy ); $tax = get_taxonomy( $taxonomy );
$args['disabled'] = ! current_user_can( $tax->cap->assign_terms ); $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'] ) ) { if ( is_array( $parsed_args['selected_cats'] ) ) {
$args['selected_cats'] = $r['selected_cats']; $args['selected_cats'] = $parsed_args['selected_cats'];
} elseif ( $post_id ) { } elseif ( $post_id ) {
$args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) ); $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
} else { } else {
$args['selected_cats'] = array(); $args['selected_cats'] = array();
} }
if ( is_array( $r['popular_cats'] ) ) { if ( is_array( $parsed_args['popular_cats'] ) ) {
$args['popular_cats'] = $r['popular_cats']; $args['popular_cats'] = $parsed_args['popular_cats'];
} else { } else {
$args['popular_cats'] = get_terms( $args['popular_cats'] = get_terms(
$taxonomy, $taxonomy,
@ -156,7 +156,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
$output = ''; $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) // 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(); $checked_categories = array();
$keys = array_keys( $categories ); $keys = array_keys( $categories );
@ -174,7 +174,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
// Then the rest of them // Then the rest of them
$output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) ); $output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $output; echo $output;
} }
@ -2441,19 +2441,19 @@ function _local_storage_notice() {
* @return string Star rating HTML. * @return string Star rating HTML.
*/ */
function wp_star_rating( $args = array() ) { function wp_star_rating( $args = array() ) {
$defaults = array( $defaults = array(
'rating' => 0, 'rating' => 0,
'type' => 'rating', 'type' => 'rating',
'number' => 0, 'number' => 0,
'echo' => true, '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 // 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 // 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; $rating = round( $rating / 10, 0 ) / 2;
} }
@ -2462,10 +2462,10 @@ function wp_star_rating( $args = array() ) {
$half_stars = ceil( $rating - $full_stars ); $half_stars = ceil( $rating - $full_stars );
$empty_stars = 5 - $full_stars - $half_stars; $empty_stars = 5 - $full_stars - $half_stars;
if ( $r['number'] ) { if ( $parsed_args['number'] ) {
/* translators: 1: the rating, 2: the number of ratings */ /* 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'] ); $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( $r['number'] ) ); $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $parsed_args['number'] ) );
} else { } else {
/* translators: %s: the rating */ /* translators: %s: the rating */
$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) ); $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 .= str_repeat( '<div class="star star-empty" aria-hidden="true"></div>', $empty_stars );
$output .= '</div>'; $output .= '</div>';
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $output; echo $output;
} }

View File

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

View File

@ -139,11 +139,12 @@ function get_bookmarks( $args = '' ) {
'search' => '', 'search' => '',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$key = md5( serialize( $r ) ); $key = md5( serialize( $parsed_args ) );
$cache = wp_cache_get( 'get_bookmarks', 'bookmark' ); $cache = wp_cache_get( 'get_bookmarks', 'bookmark' );
if ( 'rand' !== $r['orderby'] && $cache ) {
if ( 'rand' !== $parsed_args['orderby'] && $cache ) {
if ( is_array( $cache ) && isset( $cache[ $key ] ) ) { if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
$bookmarks = $cache[ $key ]; $bookmarks = $cache[ $key ];
/** /**
@ -159,9 +160,9 @@ function get_bookmarks( $args = '' ) {
* @see get_bookmarks() * @see get_bookmarks()
* *
* @param array $bookmarks List of the cached bookmarks. * @param array $bookmarks List of the cached bookmarks.
* @param array $r An array of bookmark query arguments. * @param array $parsed_args An array of bookmark query arguments.
*/ */
return apply_filters( 'get_bookmarks', $bookmarks, $r ); return apply_filters( 'get_bookmarks', $bookmarks, $parsed_args );
} }
} }
@ -170,11 +171,12 @@ function get_bookmarks( $args = '' ) {
} }
$inclusions = ''; $inclusions = '';
if ( ! empty( $r['include'] ) ) { if ( ! empty( $parsed_args['include'] ) ) {
$r['exclude'] = ''; //ignore exclude, category, and category_name params if using include $parsed_args['exclude'] = ''; //ignore exclude, category, and category_name params if using include
$r['category'] = ''; $parsed_args['category'] = '';
$r['category_name'] = ''; $parsed_args['category_name'] = '';
$inclinks = wp_parse_id_list( $r['include'] );
$inclinks = wp_parse_id_list( $parsed_args['include'] );
if ( count( $inclinks ) ) { if ( count( $inclinks ) ) {
foreach ( $inclinks as $inclink ) { foreach ( $inclinks as $inclink ) {
if ( empty( $inclusions ) ) { if ( empty( $inclusions ) ) {
@ -190,8 +192,8 @@ function get_bookmarks( $args = '' ) {
} }
$exclusions = ''; $exclusions = '';
if ( ! empty( $r['exclude'] ) ) { if ( ! empty( $parsed_args['exclude'] ) ) {
$exlinks = wp_parse_id_list( $r['exclude'] ); $exlinks = wp_parse_id_list( $parsed_args['exclude'] );
if ( count( $exlinks ) ) { if ( count( $exlinks ) ) {
foreach ( $exlinks as $exlink ) { foreach ( $exlinks as $exlink ) {
if ( empty( $exclusions ) ) { if ( empty( $exclusions ) ) {
@ -206,28 +208,28 @@ function get_bookmarks( $args = '' ) {
$exclusions .= ')'; $exclusions .= ')';
} }
if ( ! empty( $r['category_name'] ) ) { if ( ! empty( $parsed_args['category_name'] ) ) {
$r['category'] = get_term_by( 'name', $r['category_name'], 'link_category' ); $parsed_args['category'] = get_term_by( 'name', $parsed_args['category_name'], 'link_category' );
if ( $r['category'] ) { if ( $parsed_args['category'] ) {
$r['category'] = $r['category']->term_id; $parsed_args['category'] = $parsed_args['category']->term_id;
} else { } else {
$cache[ $key ] = array(); $cache[ $key ] = array();
wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
/** This filter is documented in wp-includes/bookmark.php */ /** This filter is documented in wp-includes/bookmark.php */
return apply_filters( 'get_bookmarks', array(), $r ); return apply_filters( 'get_bookmarks', array(), $parsed_args );
} }
} }
$search = ''; $search = '';
if ( ! empty( $r['search'] ) ) { if ( ! empty( $parsed_args['search'] ) ) {
$like = '%' . $wpdb->esc_like( $r['search'] ) . '%'; $like = '%' . $wpdb->esc_like( $parsed_args['search'] ) . '%';
$search = $wpdb->prepare( ' AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ', $like, $like, $like ); $search = $wpdb->prepare( ' AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ', $like, $like, $like );
} }
$category_query = ''; $category_query = '';
$join = ''; $join = '';
if ( ! empty( $r['category'] ) ) { if ( ! empty( $parsed_args['category'] ) ) {
$incategories = wp_parse_id_list( $r['category'] ); $incategories = wp_parse_id_list( $parsed_args['category'] );
if ( count( $incategories ) ) { if ( count( $incategories ) ) {
foreach ( $incategories as $incat ) { foreach ( $incategories as $incat ) {
if ( empty( $category_query ) ) { if ( empty( $category_query ) ) {
@ -243,15 +245,15 @@ function get_bookmarks( $args = '' ) {
$join = " INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id"; $join = " INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
} }
if ( $r['show_updated'] ) { if ( $parsed_args['show_updated'] ) {
$recently_updated_test = ', IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated '; $recently_updated_test = ', IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated ';
} else { } else {
$recently_updated_test = ''; $recently_updated_test = '';
} }
$get_updated = ( $r['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : ''; $get_updated = ( $parsed_args['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';
$orderby = strtolower( $r['orderby'] ); $orderby = strtolower( $parsed_args['orderby'] );
$length = ''; $length = '';
switch ( $orderby ) { switch ( $orderby ) {
case 'length': case 'length':
@ -282,21 +284,21 @@ function get_bookmarks( $args = '' ) {
$orderby = 'link_name'; $orderby = 'link_name';
} }
$order = strtoupper( $r['order'] ); $order = strtoupper( $parsed_args['order'] );
if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) { if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) {
$order = 'ASC'; $order = 'ASC';
} }
$visible = ''; $visible = '';
if ( $r['hide_invisible'] ) { if ( $parsed_args['hide_invisible'] ) {
$visible = "AND link_visible = 'Y'"; $visible = "AND link_visible = 'Y'";
} }
$query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
$query .= " $exclusions $inclusions $search"; $query .= " $exclusions $inclusions $search";
$query .= " ORDER BY $orderby $order"; $query .= " ORDER BY $orderby $order";
if ( $r['limit'] != -1 ) { if ( $parsed_args['limit'] != -1 ) {
$query .= ' LIMIT ' . $r['limit']; $query .= ' LIMIT ' . $parsed_args['limit'];
} }
$results = $wpdb->get_results( $query ); $results = $wpdb->get_results( $query );
@ -307,7 +309,7 @@ function get_bookmarks( $args = '' ) {
} }
/** This filter is documented in wp-includes/bookmark.php */ /** This filter is documented in wp-includes/bookmark.php */
return apply_filters( 'get_bookmarks', $results, $r ); return apply_filters( 'get_bookmarks', $results, $parsed_args );
} }
/** /**

View File

@ -365,14 +365,15 @@ function wp_dropdown_categories( $args = '' ) {
$args['taxonomy'] = 'link_category'; $args['taxonomy'] = 'link_category';
} }
$r = wp_parse_args( $args, $defaults ); // Parse incoming $args into an array and merge it with $defaults
$option_none_value = $r['option_none_value']; $parsed_args = wp_parse_args( $args, $defaults );
$option_none_value = $args['option_none_value'];
if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { if ( ! isset( $parsed_args['pad_counts'] ) && $parsed_args['show_count'] && $parsed_args['hierarchical'] ) {
$r['pad_counts'] = true; $parsed_args['pad_counts'] = true;
} }
$tab_index = $r['tab_index']; $tab_index = $parsed_args['tab_index'];
$tab_index_attribute = ''; $tab_index_attribute = '';
if ( (int) $tab_index > 0 ) { if ( (int) $tab_index > 0 ) {
@ -380,21 +381,21 @@ function wp_dropdown_categories( $args = '' ) {
} }
// Avoid clashes with the 'name' param of get_terms(). // Avoid clashes with the 'name' param of get_terms().
$get_terms_args = $r; $get_terms_args = $parsed_args;
unset( $get_terms_args['name'] ); unset( $get_terms_args['name'] );
$categories = get_terms( $r['taxonomy'], $get_terms_args ); $categories = get_terms( $parsed_args['taxonomy'], $get_terms_args );
$name = esc_attr( $r['name'] ); $name = esc_attr( $parsed_args['name'] );
$class = esc_attr( $r['class'] ); $class = esc_attr( $parsed_args['class'] );
$id = $r['id'] ? esc_attr( $r['id'] ) : $name; $id = $parsed_args['id'] ? esc_attr( $parsed_args['id'] ) : $name;
$required = $r['required'] ? 'required' : ''; $required = $parsed_args['required'] ? 'required' : '';
if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) { if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) {
$output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n"; $output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n";
} else { } else {
$output = ''; $output = '';
} }
if ( empty( $categories ) && ! $r['hide_if_empty'] && ! empty( $r['show_option_none'] ) ) { if ( empty( $categories ) && ! $parsed_args['hide_if_empty'] && ! empty( $parsed_args['show_option_none'] ) ) {
/** /**
* Filters a taxonomy drop-down display element. * Filters a taxonomy drop-down display element.
@ -411,37 +412,37 @@ function wp_dropdown_categories( $args = '' ) {
* @param string $element Category name. * @param string $element Category name.
* @param WP_Term|null $category The category object, or null if there's no corresponding category. * @param WP_Term|null $category The category object, or null if there's no corresponding category.
*/ */
$show_option_none = apply_filters( 'list_cats', $r['show_option_none'], null ); $show_option_none = apply_filters( 'list_cats', $parsed_args['show_option_none'], null );
$output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n"; $output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n";
} }
if ( ! empty( $categories ) ) { if ( ! empty( $categories ) ) {
if ( $r['show_option_all'] ) { if ( $parsed_args['show_option_all'] ) {
/** This filter is documented in wp-includes/category-template.php */ /** This filter is documented in wp-includes/category-template.php */
$show_option_all = apply_filters( 'list_cats', $r['show_option_all'], null ); $show_option_all = apply_filters( 'list_cats', $parsed_args['show_option_all'], null );
$selected = ( '0' === strval( $r['selected'] ) ) ? " selected='selected'" : ''; $selected = ( '0' === strval( $parsed_args['selected'] ) ) ? " selected='selected'" : '';
$output .= "\t<option value='0'$selected>$show_option_all</option>\n"; $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
} }
if ( $r['show_option_none'] ) { if ( $parsed_args['show_option_none'] ) {
/** This filter is documented in wp-includes/category-template.php */ /** This filter is documented in wp-includes/category-template.php */
$show_option_none = apply_filters( 'list_cats', $r['show_option_none'], null ); $show_option_none = apply_filters( 'list_cats', $parsed_args['show_option_none'], null );
$selected = selected( $option_none_value, $r['selected'], false ); $selected = selected( $option_none_value, $parsed_args['selected'], false );
$output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n"; $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n";
} }
if ( $r['hierarchical'] ) { if ( $parsed_args['hierarchical'] ) {
$depth = $r['depth']; // Walk the full depth. $depth = $parsed_args['depth']; // Walk the full depth.
} else { } else {
$depth = -1; // Flat. $depth = -1; // Flat.
} }
$output .= walk_category_dropdown_tree( $categories, $depth, $r ); $output .= walk_category_dropdown_tree( $categories, $depth, $parsed_args );
} }
if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) { if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) {
$output .= "</select>\n"; $output .= "</select>\n";
} }
/** /**
@ -450,11 +451,11 @@ function wp_dropdown_categories( $args = '' ) {
* @since 2.1.0 * @since 2.1.0
* *
* @param string $output HTML output. * @param string $output HTML output.
* @param array $r Arguments used to build the drop-down. * @param array $parsed_args Arguments used to build the drop-down.
*/ */
$output = apply_filters( 'wp_dropdown_cats', $output, $r ); $output = apply_filters( 'wp_dropdown_cats', $output, $parsed_args );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $output; echo $output;
} }
return $output; return $output;
@ -537,48 +538,48 @@ function wp_list_categories( $args = '' ) {
'use_desc_for_title' => 1, 'use_desc_for_title' => 1,
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { if ( ! isset( $parsed_args['pad_counts'] ) && $parsed_args['show_count'] && $parsed_args['hierarchical'] ) {
$r['pad_counts'] = true; $parsed_args['pad_counts'] = true;
} }
// Descendants of exclusions should be excluded too. // Descendants of exclusions should be excluded too.
if ( true == $r['hierarchical'] ) { if ( true == $parsed_args['hierarchical'] ) {
$exclude_tree = array(); $exclude_tree = array();
if ( $r['exclude_tree'] ) { if ( $parsed_args['exclude_tree'] ) {
$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude_tree'] ) ); $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $parsed_args['exclude_tree'] ) );
} }
if ( $r['exclude'] ) { if ( $parsed_args['exclude'] ) {
$exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude'] ) ); $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $parsed_args['exclude'] ) );
} }
$r['exclude_tree'] = $exclude_tree; $parsed_args['exclude_tree'] = $exclude_tree;
$r['exclude'] = ''; $parsed_args['exclude'] = '';
} }
if ( ! isset( $r['class'] ) ) { if ( ! isset( $parsed_args['class'] ) ) {
$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy']; $parsed_args['class'] = ( 'category' == $parsed_args['taxonomy'] ) ? 'categories' : $parsed_args['taxonomy'];
} }
if ( ! taxonomy_exists( $r['taxonomy'] ) ) { if ( ! taxonomy_exists( $parsed_args['taxonomy'] ) ) {
return false; return false;
} }
$show_option_all = $r['show_option_all']; $show_option_all = $parsed_args['show_option_all'];
$show_option_none = $r['show_option_none']; $show_option_none = $parsed_args['show_option_none'];
$categories = get_categories( $r ); $categories = get_categories( $parsed_args );
$output = ''; $output = '';
if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) { if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) {
$output = '<li class="' . esc_attr( $r['class'] ) . '">' . $r['title_li'] . '<ul>'; $output = '<li class="' . esc_attr( $parsed_args['class'] ) . '">' . $parsed_args['title_li'] . '<ul>';
} }
if ( empty( $categories ) ) { if ( empty( $categories ) ) {
if ( ! empty( $show_option_none ) ) { if ( ! empty( $show_option_none ) ) {
if ( 'list' == $r['style'] ) { if ( 'list' == $parsed_args['style'] ) {
$output .= '<li class="cat-item-none">' . $show_option_none . '</li>'; $output .= '<li class="cat-item-none">' . $show_option_none . '</li>';
} else { } else {
$output .= $show_option_none; $output .= $show_option_none;
@ -590,7 +591,7 @@ function wp_list_categories( $args = '' ) {
$posts_page = ''; $posts_page = '';
// For taxonomies that belong only to custom post types, point to a valid archive. // For taxonomies that belong only to custom post types, point to a valid archive.
$taxonomy_object = get_taxonomy( $r['taxonomy'] ); $taxonomy_object = get_taxonomy( $parsed_args['taxonomy'] );
if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) { if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) {
foreach ( $taxonomy_object->object_type as $object_type ) { foreach ( $taxonomy_object->object_type as $object_type ) {
$_object_type = get_post_type_object( $object_type ); $_object_type = get_post_type_object( $object_type );
@ -613,29 +614,29 @@ function wp_list_categories( $args = '' ) {
} }
$posts_page = esc_url( $posts_page ); $posts_page = esc_url( $posts_page );
if ( 'list' == $r['style'] ) { if ( 'list' == $parsed_args['style'] ) {
$output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>"; $output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>";
} else { } else {
$output .= "<a href='$posts_page'>$show_option_all</a>"; $output .= "<a href='$posts_page'>$show_option_all</a>";
} }
} }
if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) { if ( empty( $parsed_args['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
$current_term_object = get_queried_object(); $current_term_object = get_queried_object();
if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) { if ( $current_term_object && $parsed_args['taxonomy'] === $current_term_object->taxonomy ) {
$r['current_category'] = get_queried_object_id(); $parsed_args['current_category'] = get_queried_object_id();
} }
} }
if ( $r['hierarchical'] ) { if ( $parsed_args['hierarchical'] ) {
$depth = $r['depth']; $depth = $parsed_args['depth'];
} else { } else {
$depth = -1; // Flat. $depth = -1; // Flat.
} }
$output .= walk_category_tree( $categories, $depth, $r ); $output .= walk_category_tree( $categories, $depth, $parsed_args );
} }
if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) { if ( $parsed_args['title_li'] && 'list' == $parsed_args['style'] && ( ! empty( $categories ) || ! $parsed_args['hide_title_if_empty'] ) ) {
$output .= '</ul></li>'; $output .= '</ul></li>';
} }
@ -649,7 +650,7 @@ function wp_list_categories( $args = '' ) {
*/ */
$html = apply_filters( 'wp_list_categories', $output, $args ); $html = apply_filters( 'wp_list_categories', $output, $args );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $html; echo $html;
} else { } else {
return $html; return $html;

View File

@ -220,20 +220,20 @@ class WP_Http {
$defaults['redirection'] = 0; $defaults['redirection'] = 0;
} }
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
/** /**
* Filters the arguments used in an HTTP request. * Filters the arguments used in an HTTP request.
* *
* @since 2.7.0 * @since 2.7.0
* *
* @param array $r An array of HTTP request arguments. * @param array $parsed_args An array of HTTP request arguments.
* @param string $url The request URL. * @param string $url The request URL.
*/ */
$r = apply_filters( 'http_request_args', $r, $url ); $parsed_args = apply_filters( 'http_request_args', $parsed_args, $url );
// The transports decrement this, store a copy of the original value for loop purposes. // The transports decrement this, store a copy of the original value for loop purposes.
if ( ! isset( $r['_redirection'] ) ) { if ( ! isset( $parsed_args['_redirection'] ) ) {
$r['_redirection'] = $r['redirection']; $parsed_args['_redirection'] = $parsed_args['redirection'];
} }
/** /**
@ -251,17 +251,17 @@ class WP_Http {
* @since 2.9.0 * @since 2.9.0
* *
* @param false|array|WP_Error $preempt Whether to preempt an HTTP request's return value. Default false. * @param false|array|WP_Error $preempt Whether to preempt an HTTP request's return value. Default false.
* @param array $r HTTP request arguments. * @param array $parsed_args HTTP request arguments.
* @param string $url The request URL. * @param string $url The request URL.
*/ */
$pre = apply_filters( 'pre_http_request', false, $r, $url ); $pre = apply_filters( 'pre_http_request', false, $parsed_args, $url );
if ( false !== $pre ) { if ( false !== $pre ) {
return $pre; return $pre;
} }
if ( function_exists( 'wp_kses_bad_protocol' ) ) { if ( function_exists( 'wp_kses_bad_protocol' ) ) {
if ( $r['reject_unsafe_urls'] ) { if ( $parsed_args['reject_unsafe_urls'] ) {
$url = wp_http_validate_url( $url ); $url = wp_http_validate_url( $url );
} }
if ( $url ) { if ( $url ) {
@ -274,88 +274,88 @@ class WP_Http {
if ( empty( $url ) || empty( $arrURL['scheme'] ) ) { if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
$response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) ); $response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
/** This action is documented in wp-includes/class-http.php */ /** This action is documented in wp-includes/class-http.php */
do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url ); do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
return $response; return $response;
} }
if ( $this->block_request( $url ) ) { if ( $this->block_request( $url ) ) {
$response = new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) ); $response = new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) );
/** This action is documented in wp-includes/class-http.php */ /** This action is documented in wp-includes/class-http.php */
do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url ); do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
return $response; return $response;
} }
// If we are streaming to a file but no filename was given drop it in the WP temp dir // If we are streaming to a file but no filename was given drop it in the WP temp dir
// and pick its name using the basename of the $url // and pick its name using the basename of the $url
if ( $r['stream'] ) { if ( $parsed_args['stream'] ) {
if ( empty( $r['filename'] ) ) { if ( empty( $parsed_args['filename'] ) ) {
$r['filename'] = get_temp_dir() . basename( $url ); $parsed_args['filename'] = get_temp_dir() . basename( $url );
} }
// Force some settings if we are streaming to a file and check for existence and perms of destination directory // Force some settings if we are streaming to a file and check for existence and perms of destination directory
$r['blocking'] = true; $parsed_args['blocking'] = true;
if ( ! wp_is_writable( dirname( $r['filename'] ) ) ) { if ( ! wp_is_writable( dirname( $parsed_args['filename'] ) ) ) {
$response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) ); $response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
/** This action is documented in wp-includes/class-http.php */ /** This action is documented in wp-includes/class-http.php */
do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url ); do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
return $response; return $response;
} }
} }
if ( is_null( $r['headers'] ) ) { if ( is_null( $parsed_args['headers'] ) ) {
$r['headers'] = array(); $parsed_args['headers'] = array();
} }
// WP allows passing in headers as a string, weirdly. // WP allows passing in headers as a string, weirdly.
if ( ! is_array( $r['headers'] ) ) { if ( ! is_array( $parsed_args['headers'] ) ) {
$processedHeaders = WP_Http::processHeaders( $r['headers'] ); $processedHeaders = WP_Http::processHeaders( $parsed_args['headers'] );
$r['headers'] = $processedHeaders['headers']; $parsed_args['headers'] = $processedHeaders['headers'];
} }
// Setup arguments // Setup arguments
$headers = $r['headers']; $headers = $parsed_args['headers'];
$data = $r['body']; $data = $parsed_args['body'];
$type = $r['method']; $type = $parsed_args['method'];
$options = array( $options = array(
'timeout' => $r['timeout'], 'timeout' => $parsed_args['timeout'],
'useragent' => $r['user-agent'], 'useragent' => $parsed_args['user-agent'],
'blocking' => $r['blocking'], 'blocking' => $parsed_args['blocking'],
'hooks' => new WP_HTTP_Requests_Hooks( $url, $r ), 'hooks' => new WP_HTTP_Requests_Hooks( $url, $parsed_args ),
); );
// Ensure redirects follow browser behaviour. // Ensure redirects follow browser behaviour.
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) ); $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
// Validate redirected URLs. // Validate redirected URLs.
if ( function_exists( 'wp_kses_bad_protocol' ) && $r['reject_unsafe_urls'] ) { if ( function_exists( 'wp_kses_bad_protocol' ) && $parsed_args['reject_unsafe_urls'] ) {
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'validate_redirects' ) ); $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'validate_redirects' ) );
} }
if ( $r['stream'] ) { if ( $parsed_args['stream'] ) {
$options['filename'] = $r['filename']; $options['filename'] = $parsed_args['filename'];
} }
if ( empty( $r['redirection'] ) ) { if ( empty( $parsed_args['redirection'] ) ) {
$options['follow_redirects'] = false; $options['follow_redirects'] = false;
} else { } else {
$options['redirects'] = $r['redirection']; $options['redirects'] = $parsed_args['redirection'];
} }
// Use byte limit, if we can // Use byte limit, if we can
if ( isset( $r['limit_response_size'] ) ) { if ( isset( $parsed_args['limit_response_size'] ) ) {
$options['max_bytes'] = $r['limit_response_size']; $options['max_bytes'] = $parsed_args['limit_response_size'];
} }
// If we've got cookies, use and convert them to Requests_Cookie. // If we've got cookies, use and convert them to Requests_Cookie.
if ( ! empty( $r['cookies'] ) ) { if ( ! empty( $parsed_args['cookies'] ) ) {
$options['cookies'] = WP_Http::normalize_cookies( $r['cookies'] ); $options['cookies'] = WP_Http::normalize_cookies( $parsed_args['cookies'] );
} }
// SSL certificate handling // SSL certificate handling
if ( ! $r['sslverify'] ) { if ( ! $parsed_args['sslverify'] ) {
$options['verify'] = false; $options['verify'] = false;
$options['verifyname'] = false; $options['verifyname'] = false;
} else { } else {
$options['verify'] = $r['sslcertificates']; $options['verify'] = $parsed_args['sslcertificates'];
} }
// All non-GET/HEAD requests should put the arguments in the form body. // All non-GET/HEAD requests should put the arguments in the form body.
@ -393,7 +393,7 @@ class WP_Http {
$requests_response = Requests::request( $url, $headers, $data, $type, $options ); $requests_response = Requests::request( $url, $headers, $data, $type, $options );
// Convert the response into an array // Convert the response into an array
$http_response = new WP_HTTP_Requests_Response( $requests_response, $r['filename'] ); $http_response = new WP_HTTP_Requests_Response( $requests_response, $parsed_args['filename'] );
$response = $http_response->to_array(); $response = $http_response->to_array();
// Add the original object to the array. // Add the original object to the array.
@ -412,15 +412,15 @@ class WP_Http {
* @param array|WP_Error $response HTTP response or WP_Error object. * @param array|WP_Error $response HTTP response or WP_Error object.
* @param string $context Context under which the hook is fired. * @param string $context Context under which the hook is fired.
* @param string $class HTTP transport used. * @param string $class HTTP transport used.
* @param array $r HTTP request arguments. * @param array $parsed_args HTTP request arguments.
* @param string $url The request URL. * @param string $url The request URL.
*/ */
do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url ); do_action( 'http_api_debug', $response, 'response', 'Requests', $parsed_args, $url );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {
return $response; return $response;
} }
if ( ! $r['blocking'] ) { if ( ! $parsed_args['blocking'] ) {
return array( return array(
'headers' => array(), 'headers' => array(),
'body' => '', 'body' => '',
@ -439,10 +439,10 @@ class WP_Http {
* @since 2.9.0 * @since 2.9.0
* *
* @param array $response HTTP response. * @param array $response HTTP response.
* @param array $r HTTP request arguments. * @param array $parsed_args HTTP request arguments.
* @param string $url The request URL. * @param string $url The request URL.
*/ */
return apply_filters( 'http_response', $response, $r, $url ); return apply_filters( 'http_response', $response, $parsed_args, $url );
} }
/** /**
@ -600,9 +600,9 @@ class WP_Http {
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
*/ */
public function post( $url, $args = array() ) { public function post( $url, $args = array() ) {
$defaults = array( 'method' => 'POST' ); $defaults = array( 'method' => 'POST' );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
return $this->request( $url, $r ); return $this->request( $url, $parsed_args );
} }
/** /**
@ -617,9 +617,9 @@ class WP_Http {
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
*/ */
public function get( $url, $args = array() ) { public function get( $url, $args = array() ) {
$defaults = array( 'method' => 'GET' ); $defaults = array( 'method' => 'GET' );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
return $this->request( $url, $r ); return $this->request( $url, $parsed_args );
} }
/** /**
@ -634,9 +634,9 @@ class WP_Http {
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
*/ */
public function head( $url, $args = array() ) { public function head( $url, $args = array() ) {
$defaults = array( 'method' => 'HEAD' ); $defaults = array( 'method' => 'HEAD' );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
return $this->request( $url, $r ); return $this->request( $url, $parsed_args );
} }
/** /**

View File

@ -73,14 +73,14 @@ class WP_Ajax_Response {
'supplemental' => array(), 'supplemental' => array(),
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$position = preg_replace( '/[^a-z0-9:_-]/i', '', $r['position'] ); $position = preg_replace( '/[^a-z0-9:_-]/i', '', $parsed_args['position'] );
$id = $r['id']; $id = $parsed_args['id'];
$what = $r['what']; $what = $parsed_args['what'];
$action = $r['action']; $action = $parsed_args['action'];
$old_id = $r['old_id']; $old_id = $parsed_args['old_id'];
$data = $r['data']; $data = $parsed_args['data'];
if ( is_wp_error( $id ) ) { if ( is_wp_error( $id ) ) {
$data = $id; $data = $id;
@ -118,8 +118,8 @@ class WP_Ajax_Response {
} }
$s = ''; $s = '';
if ( is_array( $r['supplemental'] ) ) { if ( is_array( $parsed_args['supplemental'] ) ) {
foreach ( $r['supplemental'] as $k => $v ) { foreach ( $parsed_args['supplemental'] as $k => $v ) {
$s .= "<$k><![CDATA[$v]]></$k>"; $s .= "<$k><![CDATA[$v]]></$k>";
} }
$s = "<supplemental>$s</supplemental>"; $s = "<supplemental>$s</supplemental>";

View File

@ -79,18 +79,18 @@ class WP_Http_Curl {
'cookies' => array(), 'cookies' => array(),
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
if ( isset( $r['headers']['User-Agent'] ) ) { if ( isset( $parsed_args['headers']['User-Agent'] ) ) {
$r['user-agent'] = $r['headers']['User-Agent']; $parsed_args['user-agent'] = $parsed_args['headers']['User-Agent'];
unset( $r['headers']['User-Agent'] ); unset( $parsed_args['headers']['User-Agent'] );
} elseif ( isset( $r['headers']['user-agent'] ) ) { } elseif ( isset( $parsed_args['headers']['user-agent'] ) ) {
$r['user-agent'] = $r['headers']['user-agent']; $parsed_args['user-agent'] = $parsed_args['headers']['user-agent'];
unset( $r['headers']['user-agent'] ); unset( $parsed_args['headers']['user-agent'] );
} }
// Construct Cookie: header if any cookies are set. // Construct Cookie: header if any cookies are set.
WP_Http::buildCookieHeader( $r ); WP_Http::buildCookieHeader( $parsed_args );
$handle = curl_init(); $handle = curl_init();
@ -109,8 +109,8 @@ class WP_Http_Curl {
} }
} }
$is_local = isset( $r['local'] ) && $r['local']; $is_local = isset( $parsed_args['local'] ) && $parsed_args['local'];
$ssl_verify = isset( $r['sslverify'] ) && $r['sslverify']; $ssl_verify = isset( $parsed_args['sslverify'] ) && $parsed_args['sslverify'];
if ( $is_local ) { if ( $is_local ) {
/** This filter is documented in wp-includes/class-wp-http-streams.php */ /** This filter is documented in wp-includes/class-wp-http-streams.php */
$ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify, $url ); $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify, $url );
@ -123,7 +123,7 @@ class WP_Http_Curl {
* CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since. * CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since.
* a value of 0 will allow an unlimited timeout. * a value of 0 will allow an unlimited timeout.
*/ */
$timeout = (int) ceil( $r['timeout'] ); $timeout = (int) ceil( $parsed_args['timeout'] );
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout ); curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout ); curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
@ -133,10 +133,10 @@ class WP_Http_Curl {
curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify ); curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify );
if ( $ssl_verify ) { if ( $ssl_verify ) {
curl_setopt( $handle, CURLOPT_CAINFO, $r['sslcertificates'] ); curl_setopt( $handle, CURLOPT_CAINFO, $parsed_args['sslcertificates'] );
} }
curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); curl_setopt( $handle, CURLOPT_USERAGENT, $parsed_args['user-agent'] );
/* /*
* The option doesn't work with safe mode or when open_basedir is set, and there's * The option doesn't work with safe mode or when open_basedir is set, and there's
@ -147,45 +147,45 @@ class WP_Http_Curl {
curl_setopt( $handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS ); curl_setopt( $handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS );
} }
switch ( $r['method'] ) { switch ( $parsed_args['method'] ) {
case 'HEAD': case 'HEAD':
curl_setopt( $handle, CURLOPT_NOBODY, true ); curl_setopt( $handle, CURLOPT_NOBODY, true );
break; break;
case 'POST': case 'POST':
curl_setopt( $handle, CURLOPT_POST, true ); curl_setopt( $handle, CURLOPT_POST, true );
curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); curl_setopt( $handle, CURLOPT_POSTFIELDS, $parsed_args['body'] );
break; break;
case 'PUT': case 'PUT':
curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, 'PUT' ); curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, 'PUT' );
curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); curl_setopt( $handle, CURLOPT_POSTFIELDS, $parsed_args['body'] );
break; break;
default: default:
curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, $r['method'] ); curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, $parsed_args['method'] );
if ( ! is_null( $r['body'] ) ) { if ( ! is_null( $parsed_args['body'] ) ) {
curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); curl_setopt( $handle, CURLOPT_POSTFIELDS, $parsed_args['body'] );
} }
break; break;
} }
if ( true === $r['blocking'] ) { if ( true === $parsed_args['blocking'] ) {
curl_setopt( $handle, CURLOPT_HEADERFUNCTION, array( $this, 'stream_headers' ) ); curl_setopt( $handle, CURLOPT_HEADERFUNCTION, array( $this, 'stream_headers' ) );
curl_setopt( $handle, CURLOPT_WRITEFUNCTION, array( $this, 'stream_body' ) ); curl_setopt( $handle, CURLOPT_WRITEFUNCTION, array( $this, 'stream_body' ) );
} }
curl_setopt( $handle, CURLOPT_HEADER, false ); curl_setopt( $handle, CURLOPT_HEADER, false );
if ( isset( $r['limit_response_size'] ) ) { if ( isset( $parsed_args['limit_response_size'] ) ) {
$this->max_body_length = intval( $r['limit_response_size'] ); $this->max_body_length = intval( $parsed_args['limit_response_size'] );
} else { } else {
$this->max_body_length = false; $this->max_body_length = false;
} }
// If streaming to a file open a file handle, and setup our curl streaming handler. // If streaming to a file open a file handle, and setup our curl streaming handler.
if ( $r['stream'] ) { if ( $parsed_args['stream'] ) {
if ( ! WP_DEBUG ) { if ( ! WP_DEBUG ) {
$this->stream_handle = @fopen( $r['filename'], 'w+' ); $this->stream_handle = @fopen( $parsed_args['filename'], 'w+' );
} else { } else {
$this->stream_handle = fopen( $r['filename'], 'w+' ); $this->stream_handle = fopen( $parsed_args['filename'], 'w+' );
} }
if ( ! $this->stream_handle ) { if ( ! $this->stream_handle ) {
return new WP_Error( return new WP_Error(
@ -194,7 +194,7 @@ class WP_Http_Curl {
/* translators: 1: fopen(), 2: file name */ /* translators: 1: fopen(), 2: file name */
__( 'Could not open handle for %1$s to %2$s.' ), __( 'Could not open handle for %1$s to %2$s.' ),
'fopen()', 'fopen()',
$r['filename'] $parsed_args['filename']
) )
); );
} }
@ -202,16 +202,16 @@ class WP_Http_Curl {
$this->stream_handle = false; $this->stream_handle = false;
} }
if ( ! empty( $r['headers'] ) ) { if ( ! empty( $parsed_args['headers'] ) ) {
// cURL expects full header strings in each element. // cURL expects full header strings in each element.
$headers = array(); $headers = array();
foreach ( $r['headers'] as $name => $value ) { foreach ( $parsed_args['headers'] as $name => $value ) {
$headers[] = "{$name}: $value"; $headers[] = "{$name}: $value";
} }
curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers ); curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers );
} }
if ( $r['httpversion'] == '1.0' ) { if ( $parsed_args['httpversion'] == '1.0' ) {
curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
} else { } else {
curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
@ -226,13 +226,13 @@ class WP_Http_Curl {
* @since 2.8.0 * @since 2.8.0
* *
* @param resource $handle The cURL handle returned by curl_init() (passed by reference). * @param resource $handle The cURL handle returned by curl_init() (passed by reference).
* @param array $r The HTTP request arguments. * @param array $parsed_args The HTTP request arguments.
* @param string $url The request URL. * @param string $url The request URL.
*/ */
do_action_ref_array( 'http_api_curl', array( &$handle, $r, $url ) ); do_action_ref_array( 'http_api_curl', array( &$handle, $parsed_args, $url ) );
// We don't need to return the body, so don't. Just execute request and return. // We don't need to return the body, so don't. Just execute request and return.
if ( ! $r['blocking'] ) { if ( ! $parsed_args['blocking'] ) {
curl_exec( $handle ); curl_exec( $handle );
$curl_error = curl_error( $handle ); $curl_error = curl_error( $handle );
@ -272,7 +272,7 @@ class WP_Http_Curl {
if ( $curl_error || ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) ) { if ( $curl_error || ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) ) {
if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) {
if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) {
if ( $r['stream'] ) { if ( $parsed_args['stream'] ) {
curl_close( $handle ); curl_close( $handle );
fclose( $this->stream_handle ); fclose( $this->stream_handle );
return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) );
@ -296,7 +296,7 @@ class WP_Http_Curl {
curl_close( $handle ); curl_close( $handle );
if ( $r['stream'] ) { if ( $parsed_args['stream'] ) {
fclose( $this->stream_handle ); fclose( $this->stream_handle );
} }
@ -305,16 +305,16 @@ class WP_Http_Curl {
'body' => null, 'body' => null,
'response' => $theHeaders['response'], 'response' => $theHeaders['response'],
'cookies' => $theHeaders['cookies'], 'cookies' => $theHeaders['cookies'],
'filename' => $r['filename'], 'filename' => $parsed_args['filename'],
); );
// Handle redirects. // Handle redirects.
$redirect_response = WP_HTTP::handle_redirects( $url, $r, $response ); $redirect_response = WP_HTTP::handle_redirects( $url, $parsed_args, $response );
if ( false !== $redirect_response ) { if ( false !== $redirect_response ) {
return $redirect_response; return $redirect_response;
} }
if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode( $theHeaders['headers'] ) ) { if ( true === $parsed_args['decompress'] && true === WP_Http_Encoding::should_decode( $theHeaders['headers'] ) ) {
$theBody = WP_Http_Encoding::decompress( $theBody ); $theBody = WP_Http_Encoding::decompress( $theBody );
} }

View File

@ -38,18 +38,18 @@ class WP_Http_Streams {
'cookies' => array(), 'cookies' => array(),
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
if ( isset( $r['headers']['User-Agent'] ) ) { if ( isset( $parsed_args['headers']['User-Agent'] ) ) {
$r['user-agent'] = $r['headers']['User-Agent']; $parsed_args['user-agent'] = $parsed_args['headers']['User-Agent'];
unset( $r['headers']['User-Agent'] ); unset( $parsed_args['headers']['User-Agent'] );
} elseif ( isset( $r['headers']['user-agent'] ) ) { } elseif ( isset( $parsed_args['headers']['user-agent'] ) ) {
$r['user-agent'] = $r['headers']['user-agent']; $parsed_args['user-agent'] = $parsed_args['headers']['user-agent'];
unset( $r['headers']['user-agent'] ); unset( $parsed_args['headers']['user-agent'] );
} }
// Construct Cookie: header if any cookies are set. // Construct Cookie: header if any cookies are set.
WP_Http::buildCookieHeader( $r ); WP_Http::buildCookieHeader( $parsed_args );
$arrURL = parse_url( $url ); $arrURL = parse_url( $url );
@ -70,13 +70,13 @@ class WP_Http_Streams {
$arrURL['path'] = '/'; $arrURL['path'] = '/';
} }
if ( isset( $r['headers']['Host'] ) || isset( $r['headers']['host'] ) ) { if ( isset( $parsed_args['headers']['Host'] ) || isset( $parsed_args['headers']['host'] ) ) {
if ( isset( $r['headers']['Host'] ) ) { if ( isset( $parsed_args['headers']['Host'] ) ) {
$arrURL['host'] = $r['headers']['Host']; $arrURL['host'] = $parsed_args['headers']['Host'];
} else { } else {
$arrURL['host'] = $r['headers']['host']; $arrURL['host'] = $parsed_args['headers']['host'];
} }
unset( $r['headers']['Host'], $r['headers']['host'] ); unset( $parsed_args['headers']['Host'], $parsed_args['headers']['host'] );
} }
/* /*
@ -90,8 +90,8 @@ class WP_Http_Streams {
$connect_host = $secure_transport ? 'ssl://' . $connect_host : 'tcp://' . $connect_host; $connect_host = $secure_transport ? 'ssl://' . $connect_host : 'tcp://' . $connect_host;
$is_local = isset( $r['local'] ) && $r['local']; $is_local = isset( $parsed_args['local'] ) && $parsed_args['local'];
$ssl_verify = isset( $r['sslverify'] ) && $r['sslverify']; $ssl_verify = isset( $parsed_args['sslverify'] ) && $parsed_args['sslverify'];
if ( $is_local ) { if ( $is_local ) {
/** /**
* Filters whether SSL should be verified for local requests. * Filters whether SSL should be verified for local requests.
@ -117,14 +117,14 @@ class WP_Http_Streams {
//'CN_match' => $arrURL['host'], // This is handled by self::verify_ssl_certificate() //'CN_match' => $arrURL['host'], // This is handled by self::verify_ssl_certificate()
'capture_peer_cert' => $ssl_verify, 'capture_peer_cert' => $ssl_verify,
'SNI_enabled' => true, 'SNI_enabled' => true,
'cafile' => $r['sslcertificates'], 'cafile' => $parsed_args['sslcertificates'],
'allow_self_signed' => ! $ssl_verify, 'allow_self_signed' => ! $ssl_verify,
), ),
) )
); );
$timeout = (int) floor( $r['timeout'] ); $timeout = (int) floor( $parsed_args['timeout'] );
$utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000; $utimeout = $timeout == $parsed_args['timeout'] ? 0 : 1000000 * $parsed_args['timeout'] % 1000000;
$connect_timeout = max( $timeout, 1 ); $connect_timeout = max( $timeout, 1 );
// Store error number. // Store error number.
@ -182,7 +182,7 @@ class WP_Http_Streams {
$requestPath = $arrURL['path'] . ( isset( $arrURL['query'] ) ? '?' . $arrURL['query'] : '' ); $requestPath = $arrURL['path'] . ( isset( $arrURL['query'] ) ? '?' . $arrURL['query'] : '' );
} }
$strHeaders = strtoupper( $r['method'] ) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n"; $strHeaders = strtoupper( $parsed_args['method'] ) . ' ' . $requestPath . ' HTTP/' . $parsed_args['httpversion'] . "\r\n";
$include_port_in_host_header = ( $include_port_in_host_header = (
( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) || ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) ||
@ -196,16 +196,16 @@ class WP_Http_Streams {
$strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n"; $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
} }
if ( isset( $r['user-agent'] ) ) { if ( isset( $parsed_args['user-agent'] ) ) {
$strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n"; $strHeaders .= 'User-agent: ' . $parsed_args['user-agent'] . "\r\n";
} }
if ( is_array( $r['headers'] ) ) { if ( is_array( $parsed_args['headers'] ) ) {
foreach ( (array) $r['headers'] as $header => $headerValue ) { foreach ( (array) $parsed_args['headers'] as $header => $headerValue ) {
$strHeaders .= $header . ': ' . $headerValue . "\r\n"; $strHeaders .= $header . ': ' . $headerValue . "\r\n";
} }
} else { } else {
$strHeaders .= $r['headers']; $strHeaders .= $parsed_args['headers'];
} }
if ( $proxy->use_authentication() ) { if ( $proxy->use_authentication() ) {
@ -214,13 +214,13 @@ class WP_Http_Streams {
$strHeaders .= "\r\n"; $strHeaders .= "\r\n";
if ( ! is_null( $r['body'] ) ) { if ( ! is_null( $parsed_args['body'] ) ) {
$strHeaders .= $r['body']; $strHeaders .= $parsed_args['body'];
} }
fwrite( $handle, $strHeaders ); fwrite( $handle, $strHeaders );
if ( ! $r['blocking'] ) { if ( ! $parsed_args['blocking'] ) {
stream_set_blocking( $handle, 0 ); stream_set_blocking( $handle, 0 );
fclose( $handle ); fclose( $handle );
return array( return array(
@ -238,16 +238,16 @@ class WP_Http_Streams {
$bodyStarted = false; $bodyStarted = false;
$keep_reading = true; $keep_reading = true;
$block_size = 4096; $block_size = 4096;
if ( isset( $r['limit_response_size'] ) ) { if ( isset( $parsed_args['limit_response_size'] ) ) {
$block_size = min( $block_size, $r['limit_response_size'] ); $block_size = min( $block_size, $parsed_args['limit_response_size'] );
} }
// If streaming to a file setup the file handle. // If streaming to a file setup the file handle.
if ( $r['stream'] ) { if ( $parsed_args['stream'] ) {
if ( ! WP_DEBUG ) { if ( ! WP_DEBUG ) {
$stream_handle = @fopen( $r['filename'], 'w+' ); $stream_handle = @fopen( $parsed_args['filename'], 'w+' );
} else { } else {
$stream_handle = fopen( $r['filename'], 'w+' ); $stream_handle = fopen( $parsed_args['filename'], 'w+' );
} }
if ( ! $stream_handle ) { if ( ! $stream_handle ) {
return new WP_Error( return new WP_Error(
@ -256,7 +256,7 @@ class WP_Http_Streams {
/* translators: 1: fopen(), 2: file name */ /* translators: 1: fopen(), 2: file name */
__( 'Could not open handle for %1$s to %2$s.' ), __( 'Could not open handle for %1$s to %2$s.' ),
'fopen()', 'fopen()',
$r['filename'] $parsed_args['filename']
) )
); );
} }
@ -277,8 +277,8 @@ class WP_Http_Streams {
$this_block_size = strlen( $block ); $this_block_size = strlen( $block );
if ( isset( $r['limit_response_size'] ) && ( $bytes_written + $this_block_size ) > $r['limit_response_size'] ) { if ( isset( $parsed_args['limit_response_size'] ) && ( $bytes_written + $this_block_size ) > $parsed_args['limit_response_size'] ) {
$this_block_size = ( $r['limit_response_size'] - $bytes_written ); $this_block_size = ( $parsed_args['limit_response_size'] - $bytes_written );
$block = substr( $block, 0, $this_block_size ); $block = substr( $block, 0, $this_block_size );
} }
@ -292,7 +292,7 @@ class WP_Http_Streams {
$bytes_written += $bytes_written_to_file; $bytes_written += $bytes_written_to_file;
$keep_reading = ! isset( $r['limit_response_size'] ) || $bytes_written < $r['limit_response_size']; $keep_reading = ! isset( $parsed_args['limit_response_size'] ) || $bytes_written < $parsed_args['limit_response_size'];
} }
fclose( $stream_handle ); fclose( $stream_handle );
@ -306,7 +306,7 @@ class WP_Http_Streams {
$header_length = strpos( $strResponse, "\r\n\r\n" ) + 4; $header_length = strpos( $strResponse, "\r\n\r\n" ) + 4;
$bodyStarted = true; $bodyStarted = true;
} }
$keep_reading = ( ! $bodyStarted || ! isset( $r['limit_response_size'] ) || strlen( $strResponse ) < ( $header_length + $r['limit_response_size'] ) ); $keep_reading = ( ! $bodyStarted || ! isset( $parsed_args['limit_response_size'] ) || strlen( $strResponse ) < ( $header_length + $parsed_args['limit_response_size'] ) );
} }
$process = WP_Http::processResponse( $strResponse ); $process = WP_Http::processResponse( $strResponse );
@ -324,11 +324,11 @@ class WP_Http_Streams {
'body' => null, 'body' => null,
'response' => $arrHeaders['response'], 'response' => $arrHeaders['response'],
'cookies' => $arrHeaders['cookies'], 'cookies' => $arrHeaders['cookies'],
'filename' => $r['filename'], 'filename' => $parsed_args['filename'],
); );
// Handle redirects. // Handle redirects.
$redirect_response = WP_Http::handle_redirects( $url, $r, $response ); $redirect_response = WP_Http::handle_redirects( $url, $parsed_args, $response );
if ( false !== $redirect_response ) { if ( false !== $redirect_response ) {
return $redirect_response; return $redirect_response;
} }
@ -338,12 +338,12 @@ class WP_Http_Streams {
$process['body'] = WP_Http::chunkTransferDecode( $process['body'] ); $process['body'] = WP_Http::chunkTransferDecode( $process['body'] );
} }
if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode( $arrHeaders['headers'] ) ) { if ( true === $parsed_args['decompress'] && true === WP_Http_Encoding::should_decode( $arrHeaders['headers'] ) ) {
$process['body'] = WP_Http_Encoding::decompress( $process['body'] ); $process['body'] = WP_Http_Encoding::decompress( $process['body'] );
} }
if ( isset( $r['limit_response_size'] ) && strlen( $process['body'] ) > $r['limit_response_size'] ) { if ( isset( $parsed_args['limit_response_size'] ) && strlen( $process['body'] ) > $parsed_args['limit_response_size'] ) {
$process['body'] = substr( $process['body'], 0, $r['limit_response_size'] ); $process['body'] = substr( $process['body'], 0, $parsed_args['limit_response_size'] );
} }
$response['body'] = $process['body']; $response['body'] = $process['body'];

View File

@ -2014,7 +2014,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
'echo' => true, 'echo' => true,
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
/** /**
* Filters the arguments used in retrieving the comment list. * Filters the arguments used in retrieving the comment list.
@ -2023,9 +2023,9 @@ function wp_list_comments( $args = array(), $comments = null ) {
* *
* @see wp_list_comments() * @see wp_list_comments()
* *
* @param array $r An array of arguments for displaying comments. * @param array $parsed_args An array of arguments for displaying comments.
*/ */
$r = apply_filters( 'wp_list_comments_args', $r ); $parsed_args = apply_filters( 'wp_list_comments_args', $parsed_args );
// Figure out what comments we'll be looping through ($_comments) // Figure out what comments we'll be looping through ($_comments)
if ( null !== $comments ) { if ( null !== $comments ) {
@ -2033,12 +2033,12 @@ function wp_list_comments( $args = array(), $comments = null ) {
if ( empty( $comments ) ) { if ( empty( $comments ) ) {
return; return;
} }
if ( 'all' != $r['type'] ) { if ( 'all' != $parsed_args['type'] ) {
$comments_by_type = separate_comments( $comments ); $comments_by_type = separate_comments( $comments );
if ( empty( $comments_by_type[ $r['type'] ] ) ) { if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) {
return; return;
} }
$_comments = $comments_by_type[ $r['type'] ]; $_comments = $comments_by_type[ $parsed_args['type'] ];
} else { } else {
$_comments = $comments; $_comments = $comments;
} }
@ -2047,14 +2047,14 @@ function wp_list_comments( $args = array(), $comments = null ) {
* If 'page' or 'per_page' has been passed, and does not match what's in $wp_query, * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
* perform a separate comment query and allow Walker_Comment to paginate. * perform a separate comment query and allow Walker_Comment to paginate.
*/ */
if ( $r['page'] || $r['per_page'] ) { if ( $parsed_args['page'] || $parsed_args['per_page'] ) {
$current_cpage = get_query_var( 'cpage' ); $current_cpage = get_query_var( 'cpage' );
if ( ! $current_cpage ) { if ( ! $current_cpage ) {
$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages; $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
} }
$current_per_page = get_query_var( 'comments_per_page' ); $current_per_page = get_query_var( 'comments_per_page' );
if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { if ( $parsed_args['page'] != $current_cpage || $parsed_args['per_page'] != $current_per_page ) {
$comment_args = array( $comment_args = array(
'post_id' => get_the_ID(), 'post_id' => get_the_ID(),
'orderby' => 'comment_date_gmt', 'orderby' => 'comment_date_gmt',
@ -2074,13 +2074,13 @@ function wp_list_comments( $args = array(), $comments = null ) {
$comments = get_comments( $comment_args ); $comments = get_comments( $comment_args );
if ( 'all' != $r['type'] ) { if ( 'all' != $parsed_args['type'] ) {
$comments_by_type = separate_comments( $comments ); $comments_by_type = separate_comments( $comments );
if ( empty( $comments_by_type[ $r['type'] ] ) ) { if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) {
return; return;
} }
$_comments = $comments_by_type[ $r['type'] ]; $_comments = $comments_by_type[ $parsed_args['type'] ];
} else { } else {
$_comments = $comments; $_comments = $comments;
} }
@ -2091,14 +2091,14 @@ function wp_list_comments( $args = array(), $comments = null ) {
if ( empty( $wp_query->comments ) ) { if ( empty( $wp_query->comments ) ) {
return; return;
} }
if ( 'all' != $r['type'] ) { if ( 'all' != $parsed_args['type'] ) {
if ( empty( $wp_query->comments_by_type ) ) { if ( empty( $wp_query->comments_by_type ) ) {
$wp_query->comments_by_type = separate_comments( $wp_query->comments ); $wp_query->comments_by_type = separate_comments( $wp_query->comments );
} }
if ( empty( $wp_query->comments_by_type[ $r['type'] ] ) ) { if ( empty( $wp_query->comments_by_type[ $parsed_args['type'] ] ) ) {
return; return;
} }
$_comments = $wp_query->comments_by_type[ $r['type'] ]; $_comments = $wp_query->comments_by_type[ $parsed_args['type'] ];
} else { } else {
$_comments = $wp_query->comments; $_comments = $wp_query->comments;
} }
@ -2107,73 +2107,73 @@ function wp_list_comments( $args = array(), $comments = null ) {
$default_comments_page = get_option( 'default_comments_page' ); $default_comments_page = get_option( 'default_comments_page' );
$cpage = get_query_var( 'cpage' ); $cpage = get_query_var( 'cpage' );
if ( 'newest' === $default_comments_page ) { if ( 'newest' === $default_comments_page ) {
$r['cpage'] = $cpage; $parsed_args['cpage'] = $cpage;
/* /*
* When first page shows oldest comments, post permalink is the same as * When first page shows oldest comments, post permalink is the same as
* the comment permalink. * the comment permalink.
*/ */
} elseif ( $cpage == 1 ) { } elseif ( $cpage == 1 ) {
$r['cpage'] = ''; $parsed_args['cpage'] = '';
} else { } else {
$r['cpage'] = $cpage; $parsed_args['cpage'] = $cpage;
} }
$r['page'] = 0; $parsed_args['page'] = 0;
$r['per_page'] = 0; $parsed_args['per_page'] = 0;
} }
} }
} }
if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { if ( '' === $parsed_args['per_page'] && get_option( 'page_comments' ) ) {
$r['per_page'] = get_query_var( 'comments_per_page' ); $parsed_args['per_page'] = get_query_var( 'comments_per_page' );
} }
if ( empty( $r['per_page'] ) ) { if ( empty( $parsed_args['per_page'] ) ) {
$r['per_page'] = 0; $parsed_args['per_page'] = 0;
$r['page'] = 0; $parsed_args['page'] = 0;
} }
if ( '' === $r['max_depth'] ) { if ( '' === $parsed_args['max_depth'] ) {
if ( get_option( 'thread_comments' ) ) { if ( get_option( 'thread_comments' ) ) {
$r['max_depth'] = get_option( 'thread_comments_depth' ); $parsed_args['max_depth'] = get_option( 'thread_comments_depth' );
} else { } else {
$r['max_depth'] = -1; $parsed_args['max_depth'] = -1;
} }
} }
if ( '' === $r['page'] ) { if ( '' === $parsed_args['page'] ) {
if ( empty( $overridden_cpage ) ) { if ( empty( $overridden_cpage ) ) {
$r['page'] = get_query_var( 'cpage' ); $parsed_args['page'] = get_query_var( 'cpage' );
} else { } else {
$threaded = ( -1 != $r['max_depth'] ); $threaded = ( -1 != $parsed_args['max_depth'] );
$r['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $r['per_page'], $threaded ) : 1; $parsed_args['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $parsed_args['per_page'], $threaded ) : 1;
set_query_var( 'cpage', $r['page'] ); set_query_var( 'cpage', $parsed_args['page'] );
} }
} }
// Validation check // Validation check
$r['page'] = intval( $r['page'] ); $parsed_args['page'] = intval( $parsed_args['page'] );
if ( 0 == $r['page'] && 0 != $r['per_page'] ) { if ( 0 == $parsed_args['page'] && 0 != $parsed_args['per_page'] ) {
$r['page'] = 1; $parsed_args['page'] = 1;
} }
if ( null === $r['reverse_top_level'] ) { if ( null === $parsed_args['reverse_top_level'] ) {
$r['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) ); $parsed_args['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) );
} }
wp_queue_comments_for_comment_meta_lazyload( $_comments ); wp_queue_comments_for_comment_meta_lazyload( $_comments );
if ( empty( $r['walker'] ) ) { if ( empty( $parsed_args['walker'] ) ) {
$walker = new Walker_Comment; $walker = new Walker_Comment;
} else { } else {
$walker = $r['walker']; $walker = $parsed_args['walker'];
} }
$output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r ); $output = $walker->paged_walk( $_comments, $parsed_args['max_depth'], $parsed_args['page'], $parsed_args['per_page'], $parsed_args );
$in_comment_loop = false; $in_comment_loop = false;
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $output; echo $output;
} else { } else {
return $output; return $output;

View File

@ -164,15 +164,15 @@ function get_approved_comments( $post_id, $args = array() ) {
return array(); return array();
} }
$defaults = array( $defaults = array(
'status' => 1, 'status' => 1,
'post_id' => $post_id, 'post_id' => $post_id,
'order' => 'ASC', 'order' => 'ASC',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$query = new WP_Comment_Query; $query = new WP_Comment_Query;
return $query->query( $r ); return $query->query( $parsed_args );
} }
/** /**

View File

@ -430,9 +430,9 @@ function wp_get_linksbyname($category, $args = '') {
'title_li' => '', 'title_li' => '',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
return wp_list_bookmarks($r); return wp_list_bookmarks($parsed_args);
} }
/** /**
@ -635,24 +635,24 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
function wp_list_cats($args = '') { function wp_list_cats($args = '') {
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' );
$r = wp_parse_args( $args ); $parsed_args = wp_parse_args( $args );
// Map to new names. // Map to new names.
if ( isset($r['optionall']) && isset($r['all'])) if ( isset($parsed_args['optionall']) && isset($parsed_args['all']))
$r['show_option_all'] = $r['all']; $parsed_args['show_option_all'] = $parsed_args['all'];
if ( isset($r['sort_column']) ) if ( isset($parsed_args['sort_column']) )
$r['orderby'] = $r['sort_column']; $parsed_args['orderby'] = $parsed_args['sort_column'];
if ( isset($r['sort_order']) ) if ( isset($parsed_args['sort_order']) )
$r['order'] = $r['sort_order']; $parsed_args['order'] = $parsed_args['sort_order'];
if ( isset($r['optiondates']) ) if ( isset($parsed_args['optiondates']) )
$r['show_last_update'] = $r['optiondates']; $parsed_args['show_last_update'] = $parsed_args['optiondates'];
if ( isset($r['optioncount']) ) if ( isset($parsed_args['optioncount']) )
$r['show_count'] = $r['optioncount']; $parsed_args['show_count'] = $parsed_args['optioncount'];
if ( isset($r['list']) ) if ( isset($parsed_args['list']) )
$r['style'] = $r['list'] ? 'list' : 'break'; $parsed_args['style'] = $parsed_args['list'] ? 'list' : 'break';
$r['title_li'] = ''; $parsed_args['title_li'] = '';
return wp_list_categories($r); return wp_list_categories($parsed_args);
} }
/** /**
@ -892,9 +892,9 @@ function wp_get_links($args = '') {
'title_li' => '', 'title_li' => '',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
return wp_list_bookmarks($r); return wp_list_bookmarks($parsed_args);
} }
/** /**

View File

@ -3080,13 +3080,13 @@ function wp_die( $message = '', $title = '', $args = array() ) {
* @param string|array $args Optional. Arguments to control behavior. Default empty array. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function _default_wp_die_handler( $message, $title = '', $args = array() ) { function _default_wp_die_handler( $message, $title = '', $args = array() ) {
list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
if ( is_string( $message ) ) { if ( is_string( $message ) ) {
if ( ! empty( $r['additional_errors'] ) ) { if ( ! empty( $parsed_args['additional_errors'] ) ) {
$message = array_merge( $message = array_merge(
array( $message ), array( $message ),
wp_list_pluck( $r['additional_errors'], 'message' ) wp_list_pluck( $parsed_args['additional_errors'], 'message' )
); );
$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $message ) . "</li>\n\t</ul>"; $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $message ) . "</li>\n\t</ul>";
} else { } else {
@ -3096,16 +3096,16 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
$have_gettext = function_exists( '__' ); $have_gettext = function_exists( '__' );
if ( ! empty( $r['link_url'] ) && ! empty( $r['link_text'] ) ) { if ( ! empty( $parsed_args['link_url'] ) && ! empty( $parsed_args['link_text'] ) ) {
$link_url = $r['link_url']; $link_url = $parsed_args['link_url'];
if ( function_exists( 'esc_url' ) ) { if ( function_exists( 'esc_url' ) ) {
$link_url = esc_url( $link_url ); $link_url = esc_url( $link_url );
} }
$link_text = $r['link_text']; $link_text = $parsed_args['link_text'];
$message .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>"; $message .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>";
} }
if ( isset( $r['back_link'] ) && $r['back_link'] ) { if ( isset( $parsed_args['back_link'] ) && $parsed_args['back_link'] ) {
$back_text = $have_gettext ? __( '&laquo; Back' ) : '&laquo; Back'; $back_text = $have_gettext ? __( '&laquo; Back' ) : '&laquo; Back';
$message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>"; $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";
} }
@ -3113,11 +3113,11 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
if ( ! did_action( 'admin_head' ) ) : if ( ! did_action( 'admin_head' ) ) :
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
header( 'Content-Type: text/html; charset=utf-8' ); header( 'Content-Type: text/html; charset=utf-8' );
status_header( $r['response'] ); status_header( $parsed_args['response'] );
nocache_headers(); nocache_headers();
} }
$text_direction = $r['text_direction']; $text_direction = $parsed_args['text_direction'];
if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) { if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) {
$dir_attr = get_language_attributes(); $dir_attr = get_language_attributes();
} else { } else {
@ -3258,7 +3258,7 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
</body> </body>
</html> </html>
<?php <?php
if ( $r['exit'] ) { if ( $parsed_args['exit'] ) {
die(); die();
} }
} }
@ -3282,12 +3282,12 @@ function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
array( 'response' => 200 ) array( 'response' => 200 )
); );
list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
// This is intentional. For backward-compatibility, support passing null here. // This is intentional. For backward-compatibility, support passing null here.
if ( null !== $args['response'] ) { if ( null !== $args['response'] ) {
status_header( $r['response'] ); status_header( $parsed_args['response'] );
} }
nocache_headers(); nocache_headers();
} }
@ -3298,7 +3298,7 @@ function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
$message = '0'; $message = '0';
} }
if ( $r['exit'] ) { if ( $parsed_args['exit'] ) {
die( $message ); die( $message );
} }
@ -3318,27 +3318,27 @@ function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
* @param string|array $args Optional. Arguments to control behavior. Default empty array. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function _json_wp_die_handler( $message, $title = '', $args = array() ) { function _json_wp_die_handler( $message, $title = '', $args = array() ) {
list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
$data = array( $data = array(
'code' => $r['code'], 'code' => $parsed_args['code'],
'message' => $message, 'message' => $message,
'data' => array( 'data' => array(
'status' => $r['response'], 'status' => $parsed_args['response'],
), ),
'additional_errors' => $r['additional_errors'], 'additional_errors' => $parsed_args['additional_errors'],
); );
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
header( 'Content-Type: application/json; charset=utf-8' ); header( 'Content-Type: application/json; charset=utf-8' );
if ( null !== $r['response'] ) { if ( null !== $parsed_args['response'] ) {
status_header( $r['response'] ); status_header( $parsed_args['response'] );
} }
nocache_headers(); nocache_headers();
} }
echo wp_json_encode( $data ); echo wp_json_encode( $data );
if ( $r['exit'] ) { if ( $parsed_args['exit'] ) {
die(); die();
} }
} }
@ -3356,23 +3356,23 @@ function _json_wp_die_handler( $message, $title = '', $args = array() ) {
* @param string|array $args Optional. Arguments to control behavior. Default empty array. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) { function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) {
list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
$data = array( $data = array(
'code' => $r['code'], 'code' => $parsed_args['code'],
'message' => $message, 'message' => $message,
'data' => array( 'data' => array(
'status' => $r['response'], 'status' => $parsed_args['response'],
), ),
'additional_errors' => $r['additional_errors'], 'additional_errors' => $parsed_args['additional_errors'],
); );
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
header( 'Content-Type: application/javascript; charset=utf-8' ); header( 'Content-Type: application/javascript; charset=utf-8' );
header( 'X-Content-Type-Options: nosniff' ); header( 'X-Content-Type-Options: nosniff' );
header( 'X-Robots-Tag: noindex' ); header( 'X-Robots-Tag: noindex' );
if ( null !== $r['response'] ) { if ( null !== $parsed_args['response'] ) {
status_header( $r['response'] ); status_header( $parsed_args['response'] );
} }
nocache_headers(); nocache_headers();
} }
@ -3380,7 +3380,7 @@ function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) {
$result = wp_json_encode( $data ); $result = wp_json_encode( $data );
$jsonp_callback = $_GET['_jsonp']; $jsonp_callback = $_GET['_jsonp'];
echo '/**/' . $jsonp_callback . '(' . $result . ')'; echo '/**/' . $jsonp_callback . '(' . $result . ')';
if ( $r['exit'] ) { if ( $parsed_args['exit'] ) {
die(); die();
} }
} }
@ -3402,17 +3402,17 @@ function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) {
function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
global $wp_xmlrpc_server; global $wp_xmlrpc_server;
list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
nocache_headers(); nocache_headers();
} }
if ( $wp_xmlrpc_server ) { if ( $wp_xmlrpc_server ) {
$error = new IXR_Error( $r['response'], $message ); $error = new IXR_Error( $parsed_args['response'], $message );
$wp_xmlrpc_server->output( $error->getXml() ); $wp_xmlrpc_server->output( $error->getXml() );
} }
if ( $r['exit'] ) { if ( $parsed_args['exit'] ) {
die(); die();
} }
} }
@ -3430,18 +3430,18 @@ function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
* @param string|array $args Optional. Arguments to control behavior. Default empty array. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function _xml_wp_die_handler( $message, $title = '', $args = array() ) { function _xml_wp_die_handler( $message, $title = '', $args = array() ) {
list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
$message = htmlspecialchars( $message ); $message = htmlspecialchars( $message );
$title = htmlspecialchars( $title ); $title = htmlspecialchars( $title );
$xml = <<<EOD $xml = <<<EOD
<error> <error>
<code>{$r['code']}</code> <code>{$parsed_args['code']}</code>
<title><![CDATA[{$title}]]></title> <title><![CDATA[{$title}]]></title>
<message><![CDATA[{$message}]]></message> <message><![CDATA[{$message}]]></message>
<data> <data>
<status>{$r['response']}</status> <status>{$parsed_args['response']}</status>
</data> </data>
</error> </error>
@ -3449,14 +3449,14 @@ EOD;
if ( ! headers_sent() ) { if ( ! headers_sent() ) {
header( 'Content-Type: text/xml; charset=utf-8' ); header( 'Content-Type: text/xml; charset=utf-8' );
if ( null !== $r['response'] ) { if ( null !== $parsed_args['response'] ) {
status_header( $r['response'] ); status_header( $parsed_args['response'] );
} }
nocache_headers(); nocache_headers();
} }
echo $xml; echo $xml;
if ( $r['exit'] ) { if ( $parsed_args['exit'] ) {
die(); die();
} }
} }
@ -3475,9 +3475,9 @@ EOD;
* @param string|array $args Optional. Arguments to control behavior. Default empty array. * @param string|array $args Optional. Arguments to control behavior. Default empty array.
*/ */
function _scalar_wp_die_handler( $message = '', $title = '', $args = array() ) { function _scalar_wp_die_handler( $message = '', $title = '', $args = array() ) {
list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
if ( $r['exit'] ) { if ( $parsed_args['exit'] ) {
if ( is_scalar( $message ) ) { if ( is_scalar( $message ) ) {
die( (string) $message ); die( (string) $message );
} }
@ -4107,17 +4107,17 @@ function smilies_init() {
*/ */
function wp_parse_args( $args, $defaults = '' ) { function wp_parse_args( $args, $defaults = '' ) {
if ( is_object( $args ) ) { if ( is_object( $args ) ) {
$r = get_object_vars( $args ); $parsed_args = get_object_vars( $args );
} elseif ( is_array( $args ) ) { } elseif ( is_array( $args ) ) {
$r =& $args; $parsed_args =& $args;
} else { } else {
wp_parse_str( $args, $r ); wp_parse_str( $args, $parsed_args );
} }
if ( is_array( $defaults ) ) { if ( is_array( $defaults ) ) {
return array_merge( $defaults, $r ); return array_merge( $defaults, $parsed_args );
} }
return $r; return $parsed_args;
} }
/** /**

View File

@ -1821,24 +1821,24 @@ function wp_get_archives( $args = '' ) {
'w' => get_query_var( 'w' ), 'w' => get_query_var( 'w' ),
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$post_type_object = get_post_type_object( $r['post_type'] ); $post_type_object = get_post_type_object( $parsed_args['post_type'] );
if ( ! is_post_type_viewable( $post_type_object ) ) { if ( ! is_post_type_viewable( $post_type_object ) ) {
return; return;
} }
$r['post_type'] = $post_type_object->name; $parsed_args['post_type'] = $post_type_object->name;
if ( '' == $r['type'] ) { if ( '' == $parsed_args['type'] ) {
$r['type'] = 'monthly'; $parsed_args['type'] = 'monthly';
} }
if ( ! empty( $r['limit'] ) ) { if ( ! empty( $parsed_args['limit'] ) ) {
$r['limit'] = absint( $r['limit'] ); $parsed_args['limit'] = absint( $parsed_args['limit'] );
$r['limit'] = ' LIMIT ' . $r['limit']; $parsed_args['limit'] = ' LIMIT ' . $parsed_args['limit'];
} }
$order = strtoupper( $r['order'] ); $order = strtoupper( $parsed_args['order'] );
if ( $order !== 'ASC' ) { if ( $order !== 'ASC' ) {
$order = 'DESC'; $order = 'DESC';
} }
@ -1846,7 +1846,7 @@ function wp_get_archives( $args = '' ) {
// this is what will separate dates on weekly archive links // this is what will separate dates on weekly archive links
$archive_week_separator = '&#8211;'; $archive_week_separator = '&#8211;';
$sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $r['post_type'] ); $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] );
/** /**
* Filters the SQL WHERE clause for retrieving archives. * Filters the SQL WHERE clause for retrieving archives.
@ -1854,27 +1854,27 @@ function wp_get_archives( $args = '' ) {
* @since 2.2.0 * @since 2.2.0
* *
* @param string $sql_where Portion of SQL query containing the WHERE clause. * @param string $sql_where Portion of SQL query containing the WHERE clause.
* @param array $r An array of default arguments. * @param array $parsed_args An array of default arguments.
*/ */
$where = apply_filters( 'getarchives_where', $sql_where, $r ); $where = apply_filters( 'getarchives_where', $sql_where, $parsed_args );
/** /**
* Filters the SQL JOIN clause for retrieving archives. * Filters the SQL JOIN clause for retrieving archives.
* *
* @since 2.2.0 * @since 2.2.0
* *
* @param string $sql_join Portion of SQL query containing JOIN clause. * @param string $sql_join Portion of SQL query containing JOIN clause.
* @param array $r An array of default arguments. * @param array $parsed_args An array of default arguments.
*/ */
$join = apply_filters( 'getarchives_join', '', $r ); $join = apply_filters( 'getarchives_join', '', $parsed_args );
$output = ''; $output = '';
$last_changed = wp_cache_get_last_changed( 'posts' ); $last_changed = wp_cache_get_last_changed( 'posts' );
$limit = $r['limit']; $limit = $parsed_args['limit'];
if ( 'monthly' == $r['type'] ) { if ( 'monthly' == $parsed_args['type'] ) {
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
$key = md5( $query ); $key = md5( $query );
$key = "wp_get_archives:$key:$last_changed"; $key = "wp_get_archives:$key:$last_changed";
@ -1884,22 +1884,22 @@ function wp_get_archives( $args = '' ) {
wp_cache_set( $key, $results, 'posts' ); wp_cache_set( $key, $results, 'posts' );
} }
if ( $results ) { if ( $results ) {
$after = $r['after']; $after = $parsed_args['after'];
foreach ( (array) $results as $result ) { foreach ( (array) $results as $result ) {
$url = get_month_link( $result->year, $result->month ); $url = get_month_link( $result->year, $result->month );
if ( 'post' !== $r['post_type'] ) { if ( 'post' !== $parsed_args['post_type'] ) {
$url = add_query_arg( 'post_type', $r['post_type'], $url ); $url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
} }
/* translators: 1: month name, 2: 4-digit year */ /* translators: 1: month name, 2: 4-digit year */
$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year ); $text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
if ( $r['show_post_count'] ) { if ( $parsed_args['show_post_count'] ) {
$r['after'] = '&nbsp;(' . $result->posts . ')' . $after; $parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
} }
$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month; $selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month;
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected ); $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
} }
} }
} elseif ( 'yearly' == $r['type'] ) { } elseif ( 'yearly' == $parsed_args['type'] ) {
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
$key = md5( $query ); $key = md5( $query );
$key = "wp_get_archives:$key:$last_changed"; $key = "wp_get_archives:$key:$last_changed";
@ -1909,21 +1909,21 @@ function wp_get_archives( $args = '' ) {
wp_cache_set( $key, $results, 'posts' ); wp_cache_set( $key, $results, 'posts' );
} }
if ( $results ) { if ( $results ) {
$after = $r['after']; $after = $parsed_args['after'];
foreach ( (array) $results as $result ) { foreach ( (array) $results as $result ) {
$url = get_year_link( $result->year ); $url = get_year_link( $result->year );
if ( 'post' !== $r['post_type'] ) { if ( 'post' !== $parsed_args['post_type'] ) {
$url = add_query_arg( 'post_type', $r['post_type'], $url ); $url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
} }
$text = sprintf( '%d', $result->year ); $text = sprintf( '%d', $result->year );
if ( $r['show_post_count'] ) { if ( $parsed_args['show_post_count'] ) {
$r['after'] = '&nbsp;(' . $result->posts . ')' . $after; $parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
} }
$selected = is_archive() && (string) $r['year'] === $result->year; $selected = is_archive() && (string) $parsed_args['year'] === $result->year;
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected ); $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
} }
} }
} elseif ( 'daily' == $r['type'] ) { } elseif ( 'daily' == $parsed_args['type'] ) {
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
$key = md5( $query ); $key = md5( $query );
$key = "wp_get_archives:$key:$last_changed"; $key = "wp_get_archives:$key:$last_changed";
@ -1933,22 +1933,22 @@ function wp_get_archives( $args = '' ) {
wp_cache_set( $key, $results, 'posts' ); wp_cache_set( $key, $results, 'posts' );
} }
if ( $results ) { if ( $results ) {
$after = $r['after']; $after = $parsed_args['after'];
foreach ( (array) $results as $result ) { foreach ( (array) $results as $result ) {
$url = get_day_link( $result->year, $result->month, $result->dayofmonth ); $url = get_day_link( $result->year, $result->month, $result->dayofmonth );
if ( 'post' !== $r['post_type'] ) { if ( 'post' !== $parsed_args['post_type'] ) {
$url = add_query_arg( 'post_type', $r['post_type'], $url ); $url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
} }
$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth ); $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
$text = mysql2date( get_option( 'date_format' ), $date ); $text = mysql2date( get_option( 'date_format' ), $date );
if ( $r['show_post_count'] ) { if ( $parsed_args['show_post_count'] ) {
$r['after'] = '&nbsp;(' . $result->posts . ')' . $after; $parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
} }
$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month && (string) $r['day'] === $result->dayofmonth; $selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month && (string) $parsed_args['day'] === $result->dayofmonth;
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected ); $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
} }
} }
} elseif ( 'weekly' == $r['type'] ) { } elseif ( 'weekly' == $parsed_args['type'] ) {
$week = _wp_mysql_week( '`post_date`' ); $week = _wp_mysql_week( '`post_date`' );
$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
$key = md5( $query ); $key = md5( $query );
@ -1960,7 +1960,7 @@ function wp_get_archives( $args = '' ) {
} }
$arc_w_last = ''; $arc_w_last = '';
if ( $results ) { if ( $results ) {
$after = $r['after']; $after = $parsed_args['after'];
foreach ( (array) $results as $result ) { foreach ( (array) $results as $result ) {
if ( $result->week != $arc_w_last ) { if ( $result->week != $arc_w_last ) {
$arc_year = $result->yr; $arc_year = $result->yr;
@ -1975,20 +1975,20 @@ function wp_get_archives( $args = '' ) {
), ),
home_url( '/' ) home_url( '/' )
); );
if ( 'post' !== $r['post_type'] ) { if ( 'post' !== $parsed_args['post_type'] ) {
$url = add_query_arg( 'post_type', $r['post_type'], $url ); $url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
} }
$text = $arc_week_start . $archive_week_separator . $arc_week_end; $text = $arc_week_start . $archive_week_separator . $arc_week_end;
if ( $r['show_post_count'] ) { if ( $parsed_args['show_post_count'] ) {
$r['after'] = '&nbsp;(' . $result->posts . ')' . $after; $parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
} }
$selected = is_archive() && (string) $r['year'] === $result->yr && (string) $r['w'] === $result->week; $selected = is_archive() && (string) $parsed_args['year'] === $result->yr && (string) $parsed_args['w'] === $result->week;
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected ); $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
} }
} }
} }
} elseif ( ( 'postbypost' == $r['type'] ) || ( 'alpha' == $r['type'] ) ) { } elseif ( ( 'postbypost' == $parsed_args['type'] ) || ( 'alpha' == $parsed_args['type'] ) ) {
$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC '; $orderby = ( 'alpha' == $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
$key = md5( $query ); $key = md5( $query );
$key = "wp_get_archives:$key:$last_changed"; $key = "wp_get_archives:$key:$last_changed";
@ -2008,12 +2008,12 @@ function wp_get_archives( $args = '' ) {
$text = $result->ID; $text = $result->ID;
} }
$selected = $result->ID === get_the_ID(); $selected = $result->ID === get_the_ID();
$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected ); $output .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
} }
} }
} }
} }
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $output; echo $output;
} else { } else {
return $output; return $output;

View File

@ -78,24 +78,24 @@ function the_title( $before = '', $after = '', $echo = true ) {
* @return string|void String when echo is false. * @return string|void String when echo is false.
*/ */
function the_title_attribute( $args = '' ) { function the_title_attribute( $args = '' ) {
$defaults = array( $defaults = array(
'before' => '', 'before' => '',
'after' => '', 'after' => '',
'echo' => true, 'echo' => true,
'post' => get_post(), 'post' => get_post(),
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$title = get_the_title( $r['post'] ); $title = get_the_title( $parsed_args['post'] );
if ( strlen( $title ) == 0 ) { if ( strlen( $title ) == 0 ) {
return; return;
} }
$title = $r['before'] . $title . $r['after']; $title = $parsed_args['before'] . $title . $parsed_args['after'];
$title = esc_attr( strip_tags( $title ) ); $title = esc_attr( strip_tags( $title ) );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $title; echo $title;
} else { } else {
return $title; return $title;
@ -946,27 +946,27 @@ function wp_link_pages( $args = '' ) {
'echo' => 1, 'echo' => 1,
); );
$params = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
/** /**
* Filters the arguments used in retrieving page links for paginated posts. * Filters the arguments used in retrieving page links for paginated posts.
* *
* @since 3.0.0 * @since 3.0.0
* *
* @param array $params An array of arguments for page links for paginated posts. * @param array $parsed_args An array of arguments for page links for paginated posts.
*/ */
$r = apply_filters( 'wp_link_pages_args', $params ); $parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args );
$output = ''; $output = '';
if ( $multipage ) { if ( $multipage ) {
if ( 'number' == $r['next_or_number'] ) { if ( 'number' == $parsed_args['next_or_number'] ) {
$output .= $r['before']; $output .= $parsed_args['before'];
for ( $i = 1; $i <= $numpages; $i++ ) { for ( $i = 1; $i <= $numpages; $i++ ) {
$link = $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after']; $link = $parsed_args['link_before'] . str_replace( '%', $i, $parsed_args['pagelink'] ) . $parsed_args['link_after'];
if ( $i != $page || ! $more && 1 == $page ) { if ( $i != $page || ! $more && 1 == $page ) {
$link = _wp_link_page( $i ) . $link . '</a>'; $link = _wp_link_page( $i ) . $link . '</a>';
} elseif ( $i === $page ) { } elseif ( $i === $page ) {
$link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $r['aria_current'] ) . '">' . $link . '</span>'; $link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $parsed_args['aria_current'] ) . '">' . $link . '</span>';
} }
/** /**
* Filters the HTML output of individual page number links. * Filters the HTML output of individual page number links.
@ -979,15 +979,15 @@ function wp_link_pages( $args = '' ) {
$link = apply_filters( 'wp_link_pages_link', $link, $i ); $link = apply_filters( 'wp_link_pages_link', $link, $i );
// Use the custom links separator beginning with the second link. // Use the custom links separator beginning with the second link.
$output .= ( 1 === $i ) ? ' ' : $r['separator']; $output .= ( 1 === $i ) ? ' ' : $parsed_args['separator'];
$output .= $link; $output .= $link;
} }
$output .= $r['after']; $output .= $parsed_args['after'];
} elseif ( $more ) { } elseif ( $more ) {
$output .= $r['before']; $output .= $parsed_args['before'];
$prev = $page - 1; $prev = $page - 1;
if ( $prev > 0 ) { if ( $prev > 0 ) {
$link = _wp_link_page( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>'; $link = _wp_link_page( $prev ) . $parsed_args['link_before'] . $parsed_args['previouspagelink'] . $parsed_args['link_after'] . '</a>';
/** This filter is documented in wp-includes/post-template.php */ /** This filter is documented in wp-includes/post-template.php */
$output .= apply_filters( 'wp_link_pages_link', $link, $prev ); $output .= apply_filters( 'wp_link_pages_link', $link, $prev );
@ -995,14 +995,14 @@ function wp_link_pages( $args = '' ) {
$next = $page + 1; $next = $page + 1;
if ( $next <= $numpages ) { if ( $next <= $numpages ) {
if ( $prev ) { if ( $prev ) {
$output .= $r['separator']; $output .= $parsed_args['separator'];
} }
$link = _wp_link_page( $next ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>'; $link = _wp_link_page( $next ) . $parsed_args['link_before'] . $parsed_args['nextpagelink'] . $parsed_args['link_after'] . '</a>';
/** This filter is documented in wp-includes/post-template.php */ /** This filter is documented in wp-includes/post-template.php */
$output .= apply_filters( 'wp_link_pages_link', $link, $next ); $output .= apply_filters( 'wp_link_pages_link', $link, $next );
} }
$output .= $r['after']; $output .= $parsed_args['after'];
} }
} }
@ -1016,7 +1016,7 @@ function wp_link_pages( $args = '' ) {
*/ */
$html = apply_filters( 'wp_link_pages', $output, $args ); $html = apply_filters( 'wp_link_pages', $output, $args );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $html; echo $html;
} }
return $html; return $html;
@ -1181,29 +1181,29 @@ function wp_dropdown_pages( $args = '' ) {
'value_field' => 'ID', 'value_field' => 'ID',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$pages = get_pages( $r ); $pages = get_pages( $parsed_args );
$output = ''; $output = '';
// Back-compat with old system where both id and name were based on $name argument // Back-compat with old system where both id and name were based on $name argument
if ( empty( $r['id'] ) ) { if ( empty( $parsed_args['id'] ) ) {
$r['id'] = $r['name']; $parsed_args['id'] = $parsed_args['name'];
} }
if ( ! empty( $pages ) ) { if ( ! empty( $pages ) ) {
$class = ''; $class = '';
if ( ! empty( $r['class'] ) ) { if ( ! empty( $parsed_args['class'] ) ) {
$class = " class='" . esc_attr( $r['class'] ) . "'"; $class = " class='" . esc_attr( $parsed_args['class'] ) . "'";
} }
$output = "<select name='" . esc_attr( $r['name'] ) . "'" . $class . " id='" . esc_attr( $r['id'] ) . "'>\n"; $output = "<select name='" . esc_attr( $parsed_args['name'] ) . "'" . $class . " id='" . esc_attr( $parsed_args['id'] ) . "'>\n";
if ( $r['show_option_no_change'] ) { if ( $parsed_args['show_option_no_change'] ) {
$output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n"; $output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
} }
if ( $r['show_option_none'] ) { if ( $parsed_args['show_option_none'] ) {
$output .= "\t<option value=\"" . esc_attr( $r['option_none_value'] ) . '">' . $r['show_option_none'] . "</option>\n"; $output .= "\t<option value=\"" . esc_attr( $parsed_args['option_none_value'] ) . '">' . $parsed_args['show_option_none'] . "</option>\n";
} }
$output .= walk_page_dropdown_tree( $pages, $r['depth'], $r ); $output .= walk_page_dropdown_tree( $pages, $parsed_args['depth'], $parsed_args );
$output .= "</select>\n"; $output .= "</select>\n";
} }
@ -1211,15 +1211,15 @@ function wp_dropdown_pages( $args = '' ) {
* Filters the HTML output of a list of pages as a drop down. * Filters the HTML output of a list of pages as a drop down.
* *
* @since 2.1.0 * @since 2.1.0
* @since 4.4.0 `$r` and `$pages` added as arguments. * @since 4.4.0 `$parsed_args` and `$pages` added as arguments.
* *
* @param string $output HTML output for drop down list of pages. * @param string $output HTML output for drop down list of pages.
* @param array $r The parsed arguments array. * @param array $parsed_args The parsed arguments array.
* @param array $pages List of WP_Post objects returned by `get_pages()` * @param array $pages List of WP_Post objects returned by `get_pages()`
*/ */
$html = apply_filters( 'wp_dropdown_pages', $output, $r, $pages ); $html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $html; echo $html;
} }
return $html; return $html;
@ -1282,21 +1282,21 @@ function wp_list_pages( $args = '' ) {
'walker' => '', 'walker' => '',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
if ( ! in_array( $r['item_spacing'], array( 'preserve', 'discard' ), true ) ) { if ( ! in_array( $parsed_args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
// invalid value, fall back to default. // invalid value, fall back to default.
$r['item_spacing'] = $defaults['item_spacing']; $parsed_args['item_spacing'] = $defaults['item_spacing'];
} }
$output = ''; $output = '';
$current_page = 0; $current_page = 0;
// sanitize, mostly to keep spaces out // sanitize, mostly to keep spaces out
$r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] ); $parsed_args['exclude'] = preg_replace( '/[^0-9,]/', '', $parsed_args['exclude'] );
// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
$exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array(); $exclude_array = ( $parsed_args['exclude'] ) ? explode( ',', $parsed_args['exclude'] ) : array();
/** /**
* Filters the array of pages to exclude from the pages list. * Filters the array of pages to exclude from the pages list.
@ -1305,15 +1305,16 @@ function wp_list_pages( $args = '' ) {
* *
* @param array $exclude_array An array of page IDs to exclude. * @param array $exclude_array An array of page IDs to exclude.
*/ */
$r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); $parsed_args['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
$parsed_args['hierarchical'] = 0;
// Query pages. // Query pages.
$r['hierarchical'] = 0; $pages = get_pages( $parsed_args );
$pages = get_pages( $r );
if ( ! empty( $pages ) ) { if ( ! empty( $pages ) ) {
if ( $r['title_li'] ) { if ( $parsed_args['title_li'] ) {
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>'; $output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>';
} }
global $wp_query; global $wp_query;
if ( is_page() || is_attachment() || $wp_query->is_posts_page ) { if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
@ -1325,9 +1326,9 @@ function wp_list_pages( $args = '' ) {
} }
} }
$output .= walk_page_tree( $pages, $r['depth'], $current_page, $r ); $output .= walk_page_tree( $pages, $parsed_args['depth'], $current_page, $parsed_args );
if ( $r['title_li'] ) { if ( $parsed_args['title_li'] ) {
$output .= '</ul></li>'; $output .= '</ul></li>';
} }
} }
@ -1340,13 +1341,13 @@ function wp_list_pages( $args = '' ) {
* *
* @see wp_list_pages() * @see wp_list_pages()
* *
* @param string $output HTML output of the pages list. * @param string $output HTML output of the pages list.
* @param array $r An array of page-listing arguments. * @param array $parsed_args An array of page-listing arguments.
* @param array $pages List of WP_Post objects returned by `get_pages()` * @param array $pages List of WP_Post objects returned by `get_pages()`
*/ */
$html = apply_filters( 'wp_list_pages', $output, $r, $pages ); $html = apply_filters( 'wp_list_pages', $output, $parsed_args, $pages );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $html; echo $html;
} else { } else {
return $html; return $html;

View File

@ -613,15 +613,15 @@ function get_children( $args = '', $output = OBJECT ) {
'post_parent' => 0, 'post_parent' => 0,
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$children = get_posts( $r ); $children = get_posts( $parsed_args );
if ( ! $children ) { if ( ! $children ) {
return $kids; return $kids;
} }
if ( ! empty( $r['fields'] ) ) { if ( ! empty( $parsed_args['fields'] ) ) {
return $children; return $children;
} }
@ -1954,29 +1954,29 @@ function get_posts( $args = null ) {
'suppress_filters' => true, 'suppress_filters' => true,
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
if ( empty( $r['post_status'] ) ) { if ( empty( $parsed_args['post_status'] ) ) {
$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish'; $parsed_args['post_status'] = ( 'attachment' == $parsed_args['post_type'] ) ? 'inherit' : 'publish';
} }
if ( ! empty( $r['numberposts'] ) && empty( $r['posts_per_page'] ) ) { if ( ! empty( $parsed_args['numberposts'] ) && empty( $parsed_args['posts_per_page'] ) ) {
$r['posts_per_page'] = $r['numberposts']; $parsed_args['posts_per_page'] = $parsed_args['numberposts'];
} }
if ( ! empty( $r['category'] ) ) { if ( ! empty( $parsed_args['category'] ) ) {
$r['cat'] = $r['category']; $parsed_args['cat'] = $parsed_args['category'];
} }
if ( ! empty( $r['include'] ) ) { if ( ! empty( $parsed_args['include'] ) ) {
$incposts = wp_parse_id_list( $r['include'] ); $incposts = wp_parse_id_list( $parsed_args['include'] );
$r['posts_per_page'] = count( $incposts ); // only the number of posts included $parsed_args['posts_per_page'] = count( $incposts ); // only the number of posts included
$r['post__in'] = $incposts; $parsed_args['post__in'] = $incposts;
} elseif ( ! empty( $r['exclude'] ) ) { } elseif ( ! empty( $parsed_args['exclude'] ) ) {
$r['post__not_in'] = wp_parse_id_list( $r['exclude'] ); $parsed_args['post__not_in'] = wp_parse_id_list( $parsed_args['exclude'] );
} }
$r['ignore_sticky_posts'] = true; $parsed_args['ignore_sticky_posts'] = true;
$r['no_found_rows'] = true; $parsed_args['no_found_rows'] = true;
$get_posts = new WP_Query; $get_posts = new WP_Query;
return $get_posts->query( $r ); return $get_posts->query( $parsed_args );
} }
@ -3381,9 +3381,9 @@ function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
'suppress_filters' => true, 'suppress_filters' => true,
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$results = get_posts( $r ); $results = get_posts( $parsed_args );
// Backward compatibility. Prior to 3.1 expected posts to be returned in array. // Backward compatibility. Prior to 3.1 expected posts to be returned in array.
if ( ARRAY_A == $output ) { if ( ARRAY_A == $output ) {
@ -5111,21 +5111,21 @@ function get_pages( $args = array() ) {
'post_status' => 'publish', 'post_status' => 'publish',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$number = (int) $r['number']; $number = (int) $parsed_args['number'];
$offset = (int) $r['offset']; $offset = (int) $parsed_args['offset'];
$child_of = (int) $r['child_of']; $child_of = (int) $parsed_args['child_of'];
$hierarchical = $r['hierarchical']; $hierarchical = $parsed_args['hierarchical'];
$exclude = $r['exclude']; $exclude = $parsed_args['exclude'];
$meta_key = $r['meta_key']; $meta_key = $parsed_args['meta_key'];
$meta_value = $r['meta_value']; $meta_value = $parsed_args['meta_value'];
$parent = $r['parent']; $parent = $parsed_args['parent'];
$post_status = $r['post_status']; $post_status = $parsed_args['post_status'];
// Make sure the post type is hierarchical. // Make sure the post type is hierarchical.
$hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
if ( ! in_array( $r['post_type'], $hierarchical_post_types ) ) { if ( ! in_array( $parsed_args['post_type'], $hierarchical_post_types ) ) {
return false; return false;
} }
@ -5142,7 +5142,7 @@ function get_pages( $args = array() ) {
} }
// $args can be whatever, only use the args defined in defaults to compute the key. // $args can be whatever, only use the args defined in defaults to compute the key.
$key = md5( serialize( wp_array_slice_assoc( $r, array_keys( $defaults ) ) ) ); $key = md5( serialize( wp_array_slice_assoc( $parsed_args, array_keys( $defaults ) ) ) );
$last_changed = wp_cache_get_last_changed( 'posts' ); $last_changed = wp_cache_get_last_changed( 'posts' );
$cache_key = "get_pages:$key:$last_changed"; $cache_key = "get_pages:$key:$last_changed";
@ -5151,19 +5151,19 @@ function get_pages( $args = array() ) {
// Convert to WP_Post instances. // Convert to WP_Post instances.
$pages = array_map( 'get_post', $cache ); $pages = array_map( 'get_post', $cache );
/** This filter is documented in wp-includes/post.php */ /** This filter is documented in wp-includes/post.php */
$pages = apply_filters( 'get_pages', $pages, $r ); $pages = apply_filters( 'get_pages', $pages, $parsed_args );
return $pages; return $pages;
} }
$inclusions = ''; $inclusions = '';
if ( ! empty( $r['include'] ) ) { if ( ! empty( $parsed_args['include'] ) ) {
$child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
$parent = -1; $parent = -1;
$exclude = ''; $exclude = '';
$meta_key = ''; $meta_key = '';
$meta_value = ''; $meta_value = '';
$hierarchical = false; $hierarchical = false;
$incpages = wp_parse_id_list( $r['include'] ); $incpages = wp_parse_id_list( $parsed_args['include'] );
if ( ! empty( $incpages ) ) { if ( ! empty( $incpages ) ) {
$inclusions = ' AND ID IN (' . implode( ',', $incpages ) . ')'; $inclusions = ' AND ID IN (' . implode( ',', $incpages ) . ')';
} }
@ -5178,8 +5178,8 @@ function get_pages( $args = array() ) {
} }
$author_query = ''; $author_query = '';
if ( ! empty( $r['authors'] ) ) { if ( ! empty( $parsed_args['authors'] ) ) {
$post_authors = wp_parse_list( $r['authors'] ); $post_authors = wp_parse_list( $parsed_args['authors'] );
if ( ! empty( $post_authors ) ) { if ( ! empty( $post_authors ) ) {
foreach ( $post_authors as $post_author ) { foreach ( $post_authors as $post_author ) {
@ -5233,10 +5233,10 @@ function get_pages( $args = array() ) {
} }
if ( 1 == count( $post_status ) ) { if ( 1 == count( $post_status ) ) {
$where_post_type = $wpdb->prepare( 'post_type = %s AND post_status = %s', $r['post_type'], reset( $post_status ) ); $where_post_type = $wpdb->prepare( 'post_type = %s AND post_status = %s', $parsed_args['post_type'], reset( $post_status ) );
} else { } else {
$post_status = implode( "', '", $post_status ); $post_status = implode( "', '", $post_status );
$where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $r['post_type'] ); $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $parsed_args['post_type'] );
} }
$orderby_array = array(); $orderby_array = array();
@ -5261,7 +5261,7 @@ function get_pages( $args = array() ) {
'comment_count', 'comment_count',
); );
foreach ( explode( ',', $r['sort_column'] ) as $orderby ) { foreach ( explode( ',', $parsed_args['sort_column'] ) as $orderby ) {
$orderby = trim( $orderby ); $orderby = trim( $orderby );
if ( ! in_array( $orderby, $allowed_keys ) ) { if ( ! in_array( $orderby, $allowed_keys ) ) {
continue; continue;
@ -5292,7 +5292,7 @@ function get_pages( $args = array() ) {
} }
$sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title"; $sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title";
$sort_order = strtoupper( $r['sort_order'] ); $sort_order = strtoupper( $parsed_args['sort_order'] );
if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) { if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) {
$sort_order = 'ASC'; $sort_order = 'ASC';
} }
@ -5311,7 +5311,7 @@ function get_pages( $args = array() ) {
wp_cache_set( $cache_key, array(), 'posts' ); wp_cache_set( $cache_key, array(), 'posts' );
/** This filter is documented in wp-includes/post.php */ /** This filter is documented in wp-includes/post.php */
$pages = apply_filters( 'get_pages', array(), $r ); $pages = apply_filters( 'get_pages', array(), $parsed_args );
return $pages; return $pages;
} }
@ -5328,8 +5328,8 @@ function get_pages( $args = array() ) {
$pages = get_page_children( $child_of, $pages ); $pages = get_page_children( $child_of, $pages );
} }
if ( ! empty( $r['exclude_tree'] ) ) { if ( ! empty( $parsed_args['exclude_tree'] ) ) {
$exclude = wp_parse_id_list( $r['exclude_tree'] ); $exclude = wp_parse_id_list( $parsed_args['exclude_tree'] );
foreach ( $exclude as $id ) { foreach ( $exclude as $id ) {
$children = get_page_children( $id, $pages ); $children = get_page_children( $id, $pages );
foreach ( $children as $child ) { foreach ( $children as $child ) {
@ -5361,9 +5361,9 @@ function get_pages( $args = array() ) {
* @since 2.1.0 * @since 2.1.0
* *
* @param array $pages List of pages to retrieve. * @param array $pages List of pages to retrieve.
* @param array $r Array of get_pages() arguments. * @param array $parsed_args Array of get_pages() arguments.
*/ */
return apply_filters( 'get_pages', $pages, $r ); return apply_filters( 'get_pages', $pages, $parsed_args );
} }
// //

View File

@ -4295,9 +4295,9 @@ function the_taxonomies( $args = array() ) {
'after' => '', 'after' => '',
); );
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
echo $r['before'] . join( $r['sep'], get_the_taxonomies( $r['post'], $r ) ) . $r['after']; echo $parsed_args['before'] . join( $parsed_args['sep'], get_the_taxonomies( $parsed_args['post'], $parsed_args ) ) . $parsed_args['after'];
} }
/** /**

View File

@ -1123,13 +1123,13 @@ function wp_dropdown_users( $args = '' ) {
$defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
$r = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
$query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who', 'role', 'role__in', 'role__not_in' ) ); $query_args = wp_array_slice_assoc( $parsed_args, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who', 'role', 'role__in', 'role__not_in' ) );
$fields = array( 'ID', 'user_login' ); $fields = array( 'ID', 'user_login' );
$show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; $show = ! empty( $parsed_args['show'] ) ? $parsed_args['show'] : 'display_name';
if ( 'display_name_with_login' === $show ) { if ( 'display_name_with_login' === $show ) {
$fields[] = 'display_name'; $fields[] = 'display_name';
} else { } else {
@ -1138,9 +1138,9 @@ function wp_dropdown_users( $args = '' ) {
$query_args['fields'] = $fields; $query_args['fields'] = $fields;
$show_option_all = $r['show_option_all']; $show_option_all = $parsed_args['show_option_all'];
$show_option_none = $r['show_option_none']; $show_option_none = $parsed_args['show_option_none'];
$option_none_value = $r['option_none_value']; $option_none_value = $parsed_args['option_none_value'];
/** /**
* Filters the query arguments for the list of users in the dropdown. * Filters the query arguments for the list of users in the dropdown.
@ -1148,43 +1148,43 @@ function wp_dropdown_users( $args = '' ) {
* @since 4.4.0 * @since 4.4.0
* *
* @param array $query_args The query arguments for get_users(). * @param array $query_args The query arguments for get_users().
* @param array $r The arguments passed to wp_dropdown_users() combined with the defaults. * @param array $parsed_args The arguments passed to wp_dropdown_users() combined with the defaults.
*/ */
$query_args = apply_filters( 'wp_dropdown_users_args', $query_args, $r ); $query_args = apply_filters( 'wp_dropdown_users_args', $query_args, $parsed_args );
$users = get_users( $query_args ); $users = get_users( $query_args );
$output = ''; $output = '';
if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { if ( ! empty( $users ) && ( empty( $parsed_args['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) {
$name = esc_attr( $r['name'] ); $name = esc_attr( $parsed_args['name'] );
if ( $r['multi'] && ! $r['id'] ) { if ( $parsed_args['multi'] && ! $parsed_args['id'] ) {
$id = ''; $id = '';
} else { } else {
$id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; $id = $parsed_args['id'] ? " id='" . esc_attr( $parsed_args['id'] ) . "'" : " id='$name'";
} }
$output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; $output = "<select name='{$name}'{$id} class='" . $parsed_args['class'] . "'>\n";
if ( $show_option_all ) { if ( $show_option_all ) {
$output .= "\t<option value='0'>$show_option_all</option>\n"; $output .= "\t<option value='0'>$show_option_all</option>\n";
} }
if ( $show_option_none ) { if ( $show_option_none ) {
$_selected = selected( $option_none_value, $r['selected'], false ); $_selected = selected( $option_none_value, $parsed_args['selected'], false );
$output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n";
} }
if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { if ( $parsed_args['include_selected'] && ( $parsed_args['selected'] > 0 ) ) {
$found_selected = false; $found_selected = false;
$r['selected'] = (int) $r['selected']; $parsed_args['selected'] = (int) $parsed_args['selected'];
foreach ( (array) $users as $user ) { foreach ( (array) $users as $user ) {
$user->ID = (int) $user->ID; $user->ID = (int) $user->ID;
if ( $user->ID === $r['selected'] ) { if ( $user->ID === $parsed_args['selected'] ) {
$found_selected = true; $found_selected = true;
} }
} }
if ( ! $found_selected ) { if ( ! $found_selected ) {
$users[] = get_userdata( $r['selected'] ); $users[] = get_userdata( $parsed_args['selected'] );
} }
} }
@ -1198,7 +1198,7 @@ function wp_dropdown_users( $args = '' ) {
$display = '(' . $user->user_login . ')'; $display = '(' . $user->user_login . ')';
} }
$_selected = selected( $user->ID, $r['selected'], false ); $_selected = selected( $user->ID, $parsed_args['selected'], false );
$output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
} }
@ -1214,7 +1214,7 @@ function wp_dropdown_users( $args = '' ) {
*/ */
$html = apply_filters( 'wp_dropdown_users', $output ); $html = apply_filters( 'wp_dropdown_users', $output );
if ( $r['echo'] ) { if ( $parsed_args['echo'] ) {
echo $html; echo $html;
} }
return $html; return $html;

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3-alpha-45665'; $wp_version = '5.3-alpha-45667';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.