Make WordPress Core


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

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

Props freewebmentor.
Fixes #45059.

File:
1 edited

Legend:

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

    r45590 r45667  
    140140        );
    141141
    142         $r = wp_parse_args( $args, $defaults );
    143 
    144         $key   = md5( serialize( $r ) );
     142        $parsed_args = wp_parse_args( $args, $defaults );
     143
     144        $key   = md5( serialize( $parsed_args ) );
    145145        $cache = wp_cache_get( 'get_bookmarks', 'bookmark' );
    146         if ( 'rand' !== $r['orderby'] && $cache ) {
     146
     147        if ( 'rand' !== $parsed_args['orderby'] && $cache ) {
    147148                if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
    148149                        $bookmarks = $cache[ $key ];
     
    160161                         *
    161162                         * @param array $bookmarks List of the cached bookmarks.
    162                          * @param array $r         An array of bookmark query arguments.
     163                         * @param array $parsed_args         An array of bookmark query arguments.
    163164                         */
    164                         return apply_filters( 'get_bookmarks', $bookmarks, $r );
     165                        return apply_filters( 'get_bookmarks', $bookmarks, $parsed_args );
    165166                }
    166167        }
     
    171172
    172173        $inclusions = '';
    173         if ( ! empty( $r['include'] ) ) {
    174                 $r['exclude']       = '';  //ignore exclude, category, and category_name params if using include
    175                 $r['category']      = '';
    176                 $r['category_name'] = '';
    177                 $inclinks           = wp_parse_id_list( $r['include'] );
     174        if ( ! empty( $parsed_args['include'] ) ) {
     175                $parsed_args['exclude']       = '';  //ignore exclude, category, and category_name params if using include
     176                $parsed_args['category']      = '';
     177                $parsed_args['category_name'] = '';
     178
     179                $inclinks = wp_parse_id_list( $parsed_args['include'] );
    178180                if ( count( $inclinks ) ) {
    179181                        foreach ( $inclinks as $inclink ) {
     
    191193
    192194        $exclusions = '';
    193         if ( ! empty( $r['exclude'] ) ) {
    194                 $exlinks = wp_parse_id_list( $r['exclude'] );
     195        if ( ! empty( $parsed_args['exclude'] ) ) {
     196                $exlinks = wp_parse_id_list( $parsed_args['exclude'] );
    195197                if ( count( $exlinks ) ) {
    196198                        foreach ( $exlinks as $exlink ) {
     
    207209        }
    208210
    209         if ( ! empty( $r['category_name'] ) ) {
    210                 $r['category'] = get_term_by( 'name', $r['category_name'], 'link_category' );
    211                 if ( $r['category'] ) {
    212                         $r['category'] = $r['category']->term_id;
     211        if ( ! empty( $parsed_args['category_name'] ) ) {
     212                $parsed_args['category'] = get_term_by( 'name', $parsed_args['category_name'], 'link_category' );
     213                if ( $parsed_args['category'] ) {
     214                        $parsed_args['category'] = $parsed_args['category']->term_id;
    213215                } else {
    214216                        $cache[ $key ] = array();
    215217                        wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
    216218                        /** This filter is documented in wp-includes/bookmark.php */
    217                         return apply_filters( 'get_bookmarks', array(), $r );
     219                        return apply_filters( 'get_bookmarks', array(), $parsed_args );
    218220                }
    219221        }
    220222
    221223        $search = '';
    222         if ( ! empty( $r['search'] ) ) {
    223                 $like   = '%' . $wpdb->esc_like( $r['search'] ) . '%';
     224        if ( ! empty( $parsed_args['search'] ) ) {
     225                $like   = '%' . $wpdb->esc_like( $parsed_args['search'] ) . '%';
    224226                $search = $wpdb->prepare( ' AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ', $like, $like, $like );
    225227        }
     
    227229        $category_query = '';
    228230        $join           = '';
    229         if ( ! empty( $r['category'] ) ) {
    230                 $incategories = wp_parse_id_list( $r['category'] );
     231        if ( ! empty( $parsed_args['category'] ) ) {
     232                $incategories = wp_parse_id_list( $parsed_args['category'] );
    231233                if ( count( $incategories ) ) {
    232234                        foreach ( $incategories as $incat ) {
     
    244246        }
    245247
    246         if ( $r['show_updated'] ) {
     248        if ( $parsed_args['show_updated'] ) {
    247249                $recently_updated_test = ', IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated ';
    248250        } else {
     
    250252        }
    251253
    252         $get_updated = ( $r['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';
    253 
    254         $orderby = strtolower( $r['orderby'] );
     254        $get_updated = ( $parsed_args['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';
     255
     256        $orderby = strtolower( $parsed_args['orderby'] );
    255257        $length  = '';
    256258        switch ( $orderby ) {
     
    283285        }
    284286
    285         $order = strtoupper( $r['order'] );
     287        $order = strtoupper( $parsed_args['order'] );
    286288        if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) {
    287289                $order = 'ASC';
     
    289291
    290292        $visible = '';
    291         if ( $r['hide_invisible'] ) {
     293        if ( $parsed_args['hide_invisible'] ) {
    292294                $visible = "AND link_visible = 'Y'";
    293295        }
     
    296298        $query .= " $exclusions $inclusions $search";
    297299        $query .= " ORDER BY $orderby $order";
    298         if ( $r['limit'] != -1 ) {
    299                 $query .= ' LIMIT ' . $r['limit'];
     300        if ( $parsed_args['limit'] != -1 ) {
     301                $query .= ' LIMIT ' . $parsed_args['limit'];
    300302        }
    301303
     
    308310
    309311        /** This filter is documented in wp-includes/bookmark.php */
    310         return apply_filters( 'get_bookmarks', $results, $r );
     312        return apply_filters( 'get_bookmarks', $results, $parsed_args );
    311313}
    312314
Note: See TracChangeset for help on using the changeset viewer.