mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Coding Standards: Rename $r variable used with wp_parse_args() to $parsed_args for clarity.
Props freewebmentor. Fixes #45059. git-svn-id: https://develop.svn.wordpress.org/trunk@45667 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -139,11 +139,12 @@ function get_bookmarks( $args = '' ) {
|
||||
'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' );
|
||||
if ( 'rand' !== $r['orderby'] && $cache ) {
|
||||
|
||||
if ( 'rand' !== $parsed_args['orderby'] && $cache ) {
|
||||
if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
|
||||
$bookmarks = $cache[ $key ];
|
||||
/**
|
||||
@@ -159,9 +160,9 @@ function get_bookmarks( $args = '' ) {
|
||||
* @see get_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 = '';
|
||||
if ( ! empty( $r['include'] ) ) {
|
||||
$r['exclude'] = ''; //ignore exclude, category, and category_name params if using include
|
||||
$r['category'] = '';
|
||||
$r['category_name'] = '';
|
||||
$inclinks = wp_parse_id_list( $r['include'] );
|
||||
if ( ! empty( $parsed_args['include'] ) ) {
|
||||
$parsed_args['exclude'] = ''; //ignore exclude, category, and category_name params if using include
|
||||
$parsed_args['category'] = '';
|
||||
$parsed_args['category_name'] = '';
|
||||
|
||||
$inclinks = wp_parse_id_list( $parsed_args['include'] );
|
||||
if ( count( $inclinks ) ) {
|
||||
foreach ( $inclinks as $inclink ) {
|
||||
if ( empty( $inclusions ) ) {
|
||||
@@ -190,8 +192,8 @@ function get_bookmarks( $args = '' ) {
|
||||
}
|
||||
|
||||
$exclusions = '';
|
||||
if ( ! empty( $r['exclude'] ) ) {
|
||||
$exlinks = wp_parse_id_list( $r['exclude'] );
|
||||
if ( ! empty( $parsed_args['exclude'] ) ) {
|
||||
$exlinks = wp_parse_id_list( $parsed_args['exclude'] );
|
||||
if ( count( $exlinks ) ) {
|
||||
foreach ( $exlinks as $exlink ) {
|
||||
if ( empty( $exclusions ) ) {
|
||||
@@ -206,28 +208,28 @@ function get_bookmarks( $args = '' ) {
|
||||
$exclusions .= ')';
|
||||
}
|
||||
|
||||
if ( ! empty( $r['category_name'] ) ) {
|
||||
$r['category'] = get_term_by( 'name', $r['category_name'], 'link_category' );
|
||||
if ( $r['category'] ) {
|
||||
$r['category'] = $r['category']->term_id;
|
||||
if ( ! empty( $parsed_args['category_name'] ) ) {
|
||||
$parsed_args['category'] = get_term_by( 'name', $parsed_args['category_name'], 'link_category' );
|
||||
if ( $parsed_args['category'] ) {
|
||||
$parsed_args['category'] = $parsed_args['category']->term_id;
|
||||
} else {
|
||||
$cache[ $key ] = array();
|
||||
wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
|
||||
/** 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 = '';
|
||||
if ( ! empty( $r['search'] ) ) {
|
||||
$like = '%' . $wpdb->esc_like( $r['search'] ) . '%';
|
||||
if ( ! empty( $parsed_args['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 );
|
||||
}
|
||||
|
||||
$category_query = '';
|
||||
$join = '';
|
||||
if ( ! empty( $r['category'] ) ) {
|
||||
$incategories = wp_parse_id_list( $r['category'] );
|
||||
if ( ! empty( $parsed_args['category'] ) ) {
|
||||
$incategories = wp_parse_id_list( $parsed_args['category'] );
|
||||
if ( count( $incategories ) ) {
|
||||
foreach ( $incategories as $incat ) {
|
||||
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";
|
||||
}
|
||||
|
||||
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 ';
|
||||
} else {
|
||||
$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 = '';
|
||||
switch ( $orderby ) {
|
||||
case 'length':
|
||||
@@ -282,21 +284,21 @@ function get_bookmarks( $args = '' ) {
|
||||
$orderby = 'link_name';
|
||||
}
|
||||
|
||||
$order = strtoupper( $r['order'] );
|
||||
$order = strtoupper( $parsed_args['order'] );
|
||||
if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
$visible = '';
|
||||
if ( $r['hide_invisible'] ) {
|
||||
if ( $parsed_args['hide_invisible'] ) {
|
||||
$visible = "AND link_visible = 'Y'";
|
||||
}
|
||||
|
||||
$query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
|
||||
$query .= " $exclusions $inclusions $search";
|
||||
$query .= " ORDER BY $orderby $order";
|
||||
if ( $r['limit'] != -1 ) {
|
||||
$query .= ' LIMIT ' . $r['limit'];
|
||||
if ( $parsed_args['limit'] != -1 ) {
|
||||
$query .= ' LIMIT ' . $parsed_args['limit'];
|
||||
}
|
||||
|
||||
$results = $wpdb->get_results( $query );
|
||||
@@ -307,7 +309,7 @@ function get_bookmarks( $args = '' ) {
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-includes/bookmark.php */
|
||||
return apply_filters( 'get_bookmarks', $results, $r );
|
||||
return apply_filters( 'get_bookmarks', $results, $parsed_args );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user