bp_core_admin_get_active_components_from_submitted_settings( array $submitted )
Calculates the components that should be active after save, based on submitted settings.
Description Description
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.
Parameters Parameters
- $submitted
-
(Required) This is the array of component settings coming from the POST global. You should stripslashes_deep() before passing to this function.
Return Return
(array) The calculated list of component settings
Source Source
File: bp-core/admin/bp-core-admin-components.php
function bp_core_admin_get_active_components_from_submitted_settings( $submitted ) { $current_action = 'all'; if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'active', 'inactive', 'retired' ) ) ) { $current_action = $_GET['action']; } $current_components = buddypress()->active_components; switch ( $current_action ) { case 'retired' : $retired_components = bp_core_admin_get_components( 'retired' ); foreach ( array_keys( $retired_components ) as $retired_component ) { if ( ! isset( $submitted[ $retired_component ] ) ) { unset( $current_components[ $retired_component ] ); } } // Fall through. case 'inactive' : $components = array_merge( $submitted, $current_components ); break; case 'all' : case 'active' : default : $components = $submitted; break; } return $components; }
Changelog Changelog
Version | Description |
---|---|
1.7.0 | Introduced. |