Changeset 7918
- Timestamp:
- 02/18/2014 12:50:11 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-blogs/bp-blogs-cache.php
r7555 r7918 14 14 if ( !defined( 'ABSPATH' ) ) exit; 15 15 16 /** 17 * Slurp up blogmeta for a specified set of blogs. 18 * 19 * It grabs all blogmeta associated with all of the blogs passed 20 * in $blog_ids and adds it to the WP cache. This improves efficiency when 21 * using querying blogmeta inline. 22 * 23 * @param int|str|array $blog_ids Accepts a single blog ID, or a comma- 24 * separated list or array of blog IDs. 25 */ 26 function bp_blogs_update_meta_cache( $blog_ids = false ) { 27 $cache_args = array( 28 'object_ids' => $blog_ids, 29 'object_type' => buddypress()->blogs->id, 30 'object_column' => 'blog_id', 31 'cache_group' => 'blog_meta', 32 'meta_table' => buddypress()->blogs->table_name_blogmeta, 33 ); 34 35 bp_update_meta_cache( $cache_args ); 36 } 16 37 /** 17 38 * Clear the blog object cache. -
trunk/bp-blogs/bp-blogs-classes.php
r7699 r7918 115 115 * @param string|bool $search_terms Optional. Search by text stored in 116 116 * blogmeta (such as the blog name). Default: false. 117 * @param bool $update_meta_cache Whether to pre-fetch metadata for 118 * blogs. Default: true. 117 119 * @return array Multidimensional results array, structured as follows: 118 120 * 'blogs' - Array of located blog objects 119 121 * 'total' - A count of the total blogs matching the filter params 120 122 */ 121 public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false ) {123 public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true ) { 122 124 global $bp, $wpdb; 123 125 … … 162 164 $paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type ); 163 165 166 if ( $update_meta_cache ) { 167 bp_blogs_update_meta_cache( $blog_ids ); 168 } 169 164 170 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs ); 165 171 } -
trunk/bp-blogs/bp-blogs-functions.php
r7885 r7918 38 38 * @type int $per_page Default: 20. 39 39 * @type int $page Default: 1. 40 * @type bool $update_meta_cache Whether to pre-fetch blogmeta. Default: true. 40 41 * } 41 42 * @return array See {@link BP_Blogs_Blog::get()}. … … 49 50 'per_page' => 20, // The number of results to return per page 50 51 'page' => 1, // The page to return if limiting per page 52 'update_meta_cache' => true, 51 53 ); 52 54 … … 54 56 extract( $params, EXTR_SKIP ); 55 57 56 return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms ), $params );58 return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms, $update_meta_cache ), $params ); 57 59 } 58 60 -
trunk/bp-blogs/bp-blogs-template.php
r7828 r7918 170 170 * @param string $page_arg The string used as a query parameter in 171 171 * pagination links. Default: 'bpage'. 172 */ 173 function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage' ) { 172 * @param bool $update_meta_cache Whether to pre-fetch metadata for 173 * queried blogs. 174 */ 175 function __construct( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg = 'bpage', $update_meta_cache = true ) { 174 176 175 177 $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page; … … 179 181 $this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 180 182 else 181 $this->blogs = bp_blogs_get_blogs( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms ) );183 $this->blogs = bp_blogs_get_blogs( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'update_meta_cache' => $update_meta_cache, ) ); 182 184 183 185 if ( !$max || $max >= (int) $this->blogs['total'] ) … … 360 362 361 363 'user_id' => $user_id, // Pass a user_id to limit to only blogs this user has higher than subscriber access to 362 'search_terms' => $search_terms // Pass search terms to filter on the blog title or description. 364 'search_terms' => $search_terms, // Pass search terms to filter on the blog title or description. 365 'update_meta_cache' => true, 363 366 ); 364 367 … … 379 382 } 380 383 381 $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg );384 $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $page_arg, $update_meta_cache ); 382 385 return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template ); 383 386 }
Note: See TracChangeset
for help on using the changeset viewer.