bp_core_admin_components_settings_handler

Handle saving the Component settings.

Description

bp_core_admin_components_settings_handler(); 

Usage

  1. if ( !function_exists( 'bp_core_admin_components_settings_handler' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-components.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_core_admin_components_settings_handler(); 
  7.  

Defined (1)

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

/bp-core/admin/bp-core-admin-components.php  
  1. function bp_core_admin_components_settings_handler() { 
  2.  
  3. // Bail if not saving settings. 
  4. if ( ! isset( $_POST['bp-admin-component-submit'] ) ) 
  5. return; 
  6.  
  7. // Bail if nonce fails. 
  8. if ( ! check_admin_referer( 'bp-admin-component-setup' ) ) 
  9. return; 
  10.  
  11. // Settings form submitted, now save the settings. First, set active components. 
  12. if ( isset( $_POST['bp_components'] ) ) { 
  13.  
  14. // Load up BuddyPress. 
  15. $bp =buddypress); 
  16.  
  17. // Save settings and upgrade schema. 
  18. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 
  19. require_once( $bp->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' ); 
  20.  
  21. $submitted = stripslashes_deep( $_POST['bp_components'] ); 
  22. $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $submitted ); 
  23.  
  24. bp_core_install( $bp->active_components ); 
  25. bp_core_add_page_mappings( $bp->active_components ); 
  26. bp_update_option( 'bp-active-components', $bp->active_components ); 
  27.  
  28. // Where are we redirecting to? 
  29. $base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components', 'updated' => 'true' ), 'admin.php' ) ); 
  30.  
  31. // Redirect. 
  32. wp_redirect( $base_url ); 
  33. die();