[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-blogs/ -> bp-blogs-cache.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Blogs Caching.
   4   *
   5   * Caching functions handle the clearing of cached objects and pages on specific
   6   * actions throughout BuddyPress.
   7   *
   8   * @package BuddyPress
   9   * @subpackage BlogsCache
  10   * @since 1.5.0
  11   */
  12  
  13  // Exit if accessed directly.
  14  defined( 'ABSPATH' ) || exit;
  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|string|array|bool $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'   => 'bp_blog_meta',
  32          'meta_table'    => buddypress()->blogs->table_name_blogmeta,
  33      );
  34  
  35      bp_update_meta_cache( $cache_args );
  36  }
  37  /**
  38   * Clear the blog object cache.
  39   *
  40   * @since 1.0.0
  41   *
  42   * @param int $blog_id ID of the current blog.
  43   * @param int $user_id ID of the user whose blog cache should be cleared.
  44   */
  45  function bp_blogs_clear_blog_object_cache( $blog_id = 0, $user_id = 0 ) {
  46      if ( ! empty( $user_id ) ) {
  47          wp_cache_delete( 'bp_blogs_of_user_'        . $user_id, 'bp' );
  48          wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
  49      }
  50  
  51      wp_cache_delete( 'bp_total_blogs', 'bp' );
  52  }
  53  
  54  // List actions to clear object caches on.
  55  add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
  56  add_action( 'bp_insert_site',                'bp_blogs_clear_blog_object_cache', 10, 2 );
  57  add_action( 'bp_blogs_remove_blog',          'bp_blogs_clear_blog_object_cache' );
  58  
  59  // List actions to clear super cached pages on, if super cache is installed.
  60  add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
  61  add_action( 'bp_blogs_remove_comment',       'bp_core_clear_cache' );
  62  add_action( 'bp_blogs_remove_post',          'bp_core_clear_cache' );
  63  add_action( 'bp_blogs_remove_blog_for_user', 'bp_core_clear_cache' );
  64  add_action( 'bp_blogs_remove_blog',          'bp_core_clear_cache' );
  65  add_action( 'bp_blogs_new_blog_comment',     'bp_core_clear_cache' );
  66  add_action( 'bp_blogs_new_blog_post',        'bp_core_clear_cache' );
  67  add_action( 'bp_blogs_new_blog',             'bp_core_clear_cache' );
  68  add_action( 'bp_blogs_remove_data',          'bp_core_clear_cache' );


Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1