BP_Admin_Setting_Activity::settings_save()

Description

Source

File: bp-core/admin/settings/bp-admin-setting-activity.php

	public function settings_save() {
		parent::settings_save();

		$bp = buddypress();
		$active_components = $bp->active_components;

		// Flag for activate the blogs component
		$is_blog_component_active = false;

		// Get all active custom post type.
		$post_types = get_post_types( [ 'public' => true ] );

		foreach ( $post_types as $cpt ) {
			// Exclude all the custom post type which is already in BuddyPress Activity support.
			if ( in_array( $cpt,
				[ 'forum', 'topic', 'reply', 'page', 'attachment', 'bp-group-type', 'bp-member-type' ] ) ) {
				continue;
			}

			$enable_blog_feeds = isset( $_POST["bp-feed-custom-post-type-$cpt"] );

			if ( $enable_blog_feeds ) {
				$is_blog_component_active = true;
			}

		}

		if ( $is_blog_component_active ) {
			$active_components['blogs'] = '1';
		} else {
			unset( $active_components['blogs'] );
		}

		// 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' );

		$bp->active_components = $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 );

	}

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.