bp_core_admin_components_activation_handler()
Handle saving the Component settings.
Description
Source
File: bp-core/admin/bp-core-admin-components.php
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | function bp_core_admin_components_activation_handler() { if ( ! isset( $_GET [ 'bp_component' ] ) ) { return ; } // Bail if nonce fails. if ( ! check_admin_referer( 'bp-admin-component-activation' ) ) return ; // Settings form submitted, now save the settings. First, set active components. if ( isset( $_GET [ 'bp_component' ] ) ) { // Load up BuddyPress. $bp = buddypress(); // Save settings and upgrade schema. require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' ); require_once ( $bp ->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' ); $current_action = 'active' ; if ( isset( $_GET [ 'do_action' ] ) && in_array( $_GET [ 'do_action' ], array ( 'activate' , 'deactivate' ) ) ) { $current_action = $_GET [ 'do_action' ]; } $current_components = $bp ->active_components; $submitted = stripslashes_deep( $_GET [ 'bp_component' ] ); switch ( $current_action ) { case 'deactivate' : foreach ( $current_components as $key => $component ) { if ( $submitted == $key ) { unset( $current_components [ $key ] ); } } $bp ->active_components = $current_components ; break ; case 'activate' : default : $bp ->active_components = array_merge ( array ( $submitted => $current_action == 'activate' ? '1' : '0' ), $current_components ); break ; } $uninstalled_components = array_diff_key ( $current_components , $bp ->active_components); bp_core_install( $bp ->active_components ); bp_core_add_page_mappings( $bp ->active_components ); bp_update_option( 'bp-active-components' , $bp ->active_components ); bp_core_uninstall( $uninstalled_components ); } // Assign the Forum Page to forum component. if ( array_key_exists ( 'forums' , $bp ->active_components ) ) { $option = bp_get_option( '_bbp_root_slug_custom_slug' , '' ); if ( '' === $option ) { $default_title = bp_core_get_directory_page_default_titles(); $title = ( isset( $default_title [ 'new_forums_page' ] ) ) ? $default_title [ 'new_forums_page' ] : '' ; $new_page = array ( 'post_title' => $title , 'post_status' => 'publish' , 'post_author' => bp_loggedin_user_id(), 'post_type' => 'page' , 'comment_status' => 'closed' , 'ping_status' => 'closed' , ); $page_id = wp_insert_post( $new_page ); bp_update_option( '_bbp_root_slug_custom_slug' , $page_id ); $slug = get_post_field( 'post_name' , $page_id ); bp_update_option( '_bbp_root_slug' , $slug ); } } $current_action = 'all' ; if ( isset( $_GET [ 'action' ] ) && in_array( $_GET [ 'action' ], array ( 'active' , 'inactive' ) ) ) { $current_action = $_GET [ 'action' ]; } // Where are we redirecting to? $base_url = bp_get_admin_url( add_query_arg( array ( 'page' => 'bp-components' , 'action' => $current_action , 'updated' => 'true' , 'added' => 'true' ), 'admin.php' ) ); // Redirect. wp_redirect( $base_url ); die (); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.