bp_activity_privacy_check_config

Check the config for multisite.

Description

bp_activity_privacy_check_config(); 

Usage

  1. if ( !function_exists( 'bp_activity_privacy_check_config' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-activity-privacy/loader.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_activity_privacy_check_config(); 
  7.  

Defined (1)

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

/loader.php  
  1. function bp_activity_privacy_check_config() { 
  2. global $bp; 
  3.  
  4. $config = array( 
  5. 'blog_status' => false,  
  6. 'network_active' => false,  
  7. 'network_status' => true  
  8. ); 
  9. if ( get_current_blog_id() == bp_get_root_blog_id() ) { 
  10. $config['blog_status'] = true; 
  11.  
  12. $network_plugins = get_site_option( 'active_sitewide_plugins', array() ); 
  13.  
  14. // No Network plugins 
  15. if ( empty( $network_plugins ) ) 
  16.  
  17. // Looking for BuddyPress and bp-activity plugin 
  18. $check[] = $bp->basename; 
  19.  
  20. // Are they active on the network ? 
  21. $network_active = array_diff( $check, array_keys( $network_plugins ) ); 
  22.  
  23. // If result is 1, your plugin is network activated 
  24. // and not BuddyPress or vice & versa. Config is not ok 
  25. if ( count( $network_active ) == 1 ) 
  26. $config['network_status'] = false; 
  27.  
  28. // We need to know if the plugin is network activated to choose the right 
  29. // notice ( admin or network_admin ) to display the warning message. 
  30. $config['network_active'] = isset( $network_plugins[ BP_ACTIVITY_PRIVACY_PLUGIN_BASENAME ] ); 
  31.  
  32. // if BuddyPress config is different than bp-activity plugin 
  33. if ( !$config['blog_status'] || !$config['network_status'] ) { 
  34.  
  35. $warnings = array(); 
  36. if ( !bp_core_do_network_admin() && !$config['blog_status'] ) { 
  37. $warnings[] = __( 'Buddypress Activity Privacy requires to be activated on the blog where BuddyPress is activated.', 'bp-activity-privacy' ); 
  38.  
  39. if ( bp_core_do_network_admin() && !$config['network_status'] ) { 
  40. $warnings[] = __( 'Buddypress Activity Privacy and BuddyPress need to share the same network configuration.', 'bp-activity-privacy' ); 
  41.  
  42. if ( ! empty( $warnings ) ) : 
  43. ?> 
  44. <div id="message" class="error"> 
  45. <?php foreach ( $warnings as $warning ) : ?> 
  46. <p><?php echo esc_html( $warning ) ; ?></p> 
  47. <?php endforeach ; ?> 
  48. </div> 
  49. <?php 
  50. endif; 
  51.  
  52. // Display a warning message in network admin or admin 
  53.  
  54. return false; 
  55. }  
  56. return true;