Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/05/2014 03:04:57 AM (10 years ago)
Author:
boonebgorges
Message:

Add 'include_blog_ids' param to bp_has_blogs() stack

The key 'include_blog_ids' was chosen because of the somewhat odd schema of
the blogs table: the primary key in that table is not the blog, but is for the
user-blog relationship. 'include_blog_ids' underscores that results will be
limited by the 'blog_id' table.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-template.php

    r7965 r8042  
    172172     * @param bool $update_meta_cache Whether to pre-fetch metadata for
    173173     *        queried blogs.
    174      */
    175     function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true ) {
     174     * @param array $include_blog_ids Array of blog IDs to include.
     175     */
     176    function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true, $include_blog_ids = false ) {
    176177
    177178        $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page;
     
    188189                'search_terms'      => $search_terms,
    189190                'update_meta_cache' => $update_meta_cache,
     191                'include_blog_ids'  => $include_blog_ids,
    190192            ) );
    191193        }
     
    336338 *           Default: false (unlimited).
    337339 *     @type string $type The order in which results should be fetched.
    338          'active', 'alphabetical', 'newest', or 'random'.
     340 *       'active', 'alphabetical', 'newest', or 'random'.
     341 *     @type array $include_blog_ids Array of blog IDs to limit results to.
    339342 *     @type string $sort 'ASC' or 'DESC'. Default: 'DESC'.
    340343 *     @type string $search_terms Limit results by a search term. Default: null.
     
    370373
    371374        'user_id'           => $user_id,       // Pass a user_id to limit to only blogs this user has higher than subscriber access to
     375        'include_blog_ids'  => false,
    372376        'search_terms'      => $search_terms,  // Pass search terms to filter on the blog title or description.
    373377        'update_meta_cache' => true,
     
    390394    }
    391395
    392     $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg, $update_meta_cache );
     396    $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg, $update_meta_cache, $include_blog_ids );
    393397    return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template );
    394398}
Note: See TracChangeset for help on using the changeset viewer.