Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/11/2014 02:13:05 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Clean up bp_blogs_get_blogs():

  • Use bp_parse_args() to allow just-in-time filtering of query arguments.
  • Remove explode() usage.
  • Add inline phpdoc to arguments.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-functions.php

    r8589 r8593  
    4545function bp_blogs_get_blogs( $args = '' ) {
    4646
    47         $defaults = array(
    48                 'type'              => 'active', // active, alphabetical, newest, or random
    49                 'user_id'           => false,    // Pass a user_id to limit to only blogs that this user has privilages higher than subscriber on
    50                 'include_blog_ids'  => false,
    51                 'search_terms'      => false,    // Limit to blogs that match these search terms
     47        // Parse query arguments
     48        $r = bp_parse_args( $args, array(
     49                'type'              => 'active', // 'active', 'alphabetical', 'newest', or 'random'
     50                'include_blog_ids'  => false,    // Array of blog IDs to include
     51                'user_id'           => false,    // Limit to blogs this user can post to
     52                'search_terms'      => false,    // Limit to blogs matching these search terms
    5253                'per_page'          => 20,       // The number of results to return per page
    5354                'page'              => 1,        // The page to return if limiting per page
    54                 'update_meta_cache' => true,
     55                'update_meta_cache' => true      // Whether to pre-fetch blogmeta
     56        ), 'blogs_get_blogs' );
     57
     58        // Get the blogs
     59        $blogs = BP_Blogs_Blog::get(
     60                $r['type'],
     61                $r['per_page'],
     62                $r['page'],
     63                $r['user_id'],
     64                $r['search_terms'],
     65                $r['update_meta_cache'],
     66                $r['include_blog_ids']
    5567        );
    5668
    57         $params = wp_parse_args( $args, $defaults );
    58         extract( $params, EXTR_SKIP );
    59 
    60         return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms, $update_meta_cache, $include_blog_ids ), $params );
     69        // Filter and return
     70        return apply_filters( 'bp_blogs_get_blogs', $blogs, $r );
    6171}
    6272
Note: See TracChangeset for help on using the changeset viewer.