bp_core_clear_root_options_cache

Clear the root_blog_options cache when any of its options are updated.

Description

bp_core_clear_root_options_cache( (string) $option ); 

Parameters (1)

0. $option (string)
Option name.

Usage

  1. if ( !function_exists( 'bp_core_clear_root_options_cache' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-cache.php'; 
  3.  
  4. // Option name. 
  5. $option = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_clear_root_options_cache($option); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-cache.php  
  1. function bp_core_clear_root_options_cache( $option ) { 
  2. foreach ( array( 'add_option', 'add_site_option', 'update_option', 'update_site_option' ) as $action ) { 
  3. remove_action( $action, 'bp_core_clear_root_options_cache' ); 
  4.  
  5. // Surrounding code prevents infinite loops on WP < 4.4. 
  6. $keys = array_keys( bp_get_default_options() ); 
  7.  
  8. foreach ( array( 'add_option', 'add_site_option', 'update_option', 'update_site_option' ) as $action ) { 
  9. add_action( $action, 'bp_core_clear_root_options_cache' ); 
  10.  
  11. $keys = array_merge( $keys, array( 
  12. 'registration',  
  13. 'avatar_default',  
  14. 'tags_blog_id',  
  15. 'sitewide_tags_blog',  
  16. 'registration',  
  17. 'fileupload_mask',  
  18. ) ); 
  19.  
  20. if ( in_array( $option, $keys ) ) { 
  21. wp_cache_delete( 'root_blog_options', 'bp' );