bp_core_admin_get_active_components_from_submitted_settings

Calculates the components that should be active after save, based on submitted settings.

Description

(array) bp_core_admin_get_active_components_from_submitted_settings( (array) $submitted ); 

The way that active components must be set after saving your settings must be calculated differently depending on which of the Components subtabs you are coming from: - When coming from All or Active, the submitted checkboxes accurately reflect the desired active components, so we simply pass them through - When coming from Inactive, components can only be activated - already active components will not be passed in the $_POST global. Thus, we must parse the newly activated components with the already active components saved in the $bp global - When activating a Retired component, the situation is similar to Inactive. - When deactivating a Retired component, no value is passed in the $_POST global (because the component settings are checkboxes). So, in order to determine whether a retired component is being deactivated, we retrieve a list of retired components, and check each one to ensure that its checkbox is not present, before merging the submitted components with the active ones.

Returns (array)

The calculated list of component settings

Parameters (1)

0. $submitted (array)
This is the array of component settings coming from the POST global. You should stripslashes_deep() before passing to this function.

Usage

  1. if ( !function_exists( 'bp_core_admin_get_active_components_from_submitted_settings' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-components.php'; 
  3.  
  4. // This is the array of component settings coming from the POST 
  5. // global. You should stripslashes_deep() before passing to this function. 
  6. $submitted = array(); 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_core_admin_get_active_components_from_submitted_settings($submitted); 
  10.  

Defined (1)

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

/bp-core/admin/bp-core-admin-components.php  
  1. function bp_core_admin_get_active_components_from_submitted_settings( $submitted ) { 
  2. $current_action = 'all'; 
  3.  
  4. if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'active', 'inactive', 'retired' ) ) ) { 
  5. $current_action = $_GET['action']; 
  6.  
  7. $current_components =buddypress)->active_components; 
  8.  
  9. switch ( $current_action ) { 
  10. case 'retired' : 
  11. $retired_components = bp_core_admin_get_components( 'retired' ); 
  12. foreach ( array_keys( $retired_components ) as $retired_component ) { 
  13. if ( ! isset( $submitted[ $retired_component ] ) ) { 
  14. unset( $current_components[ $retired_component ] ); 
  15. } // Fall through. 
  16.  
  17.  
  18. case 'inactive' : 
  19. $components = array_merge( $submitted, $current_components ); 
  20. break; 
  21.  
  22. case 'all' : 
  23. case 'active' : 
  24. default : 
  25. $components = $submitted; 
  26. break; 
  27.  
  28. return $components;