BP_Admin_Setting_Activity::register_fields()
Description
Source
File: bp-core/admin/settings/bp-admin-setting-activity.php
public function register_fields() {
$this->add_section( 'bp_activity', __( 'Activity Settings', 'buddyboss' ) );
// Blog Feeds Option (will sync with "blogs" component)
// $this->add_checkbox_field( 'bp-enable-blog-feeds', __( 'Blog Posts', 'buddyboss' ), [
// 'input_text' => __( 'Automatically publish new blog posts into the activity feed', 'buddyboss' )
// ] );
// Allow subscriptions setting.
$this->add_field( '_bp_enable_heartbeat_refresh', __( 'Activity auto-refresh', 'buddyboss' ), 'bp_admin_setting_callback_heartbeat', 'intval' );
// Allow autoload
$this->add_field( '_bp_enable_activity_autoload', __( 'Activity auto-load', 'buddyboss' ), 'bp_admin_setting_callback_enable_activity_autoload', 'intval' );
// Allow follow.
$this->add_field( '_bp_enable_activity_follow', __( 'Follow', 'buddyboss' ), 'bp_admin_setting_callback_enable_activity_follow', 'intval' );
// Allow like.
$this->add_field( '_bp_enable_activity_like', __( 'Likes', 'buddyboss' ), 'bp_admin_setting_callback_enable_activity_like', 'intval' );
// Allow link preview.
$this->add_field( '_bp_enable_activity_link_preview', __( 'Link Previews', 'buddyboss' ), 'bp_admin_setting_callback_enable_activity_link_preview', 'intval' );
// Allow subscriptions setting.
if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) {
// $this->add_field( '_bp_enable_akismet', __( 'Akismet', 'buddyboss' ), 'bp_admin_setting_callback_activity_akismet', 'intval' );
}
// Activity Settings Tutorial
$this->add_field( 'bp-activity-settings-tutorial','', 'bp_activity_settings_tutorial' );
$this->add_section( 'bp_custom_post_type', __( 'Posts in Activity Feeds', 'buddyboss' ) );
// create field for default Platform activity feed.
$get_default_platform_activity_types = bp_platform_default_activity_types();
$is_first = true;
foreach ( $get_default_platform_activity_types as $type ) {
$name = $type['activity_name'];
$class = ( true === $is_first ) ? 'child-no-padding-first' : 'child-no-padding';
$type['class'] = $class;
$this->add_field( "bp-feed-platform-$name", ( true === $is_first ) ? __( 'BuddyBoss Platform', 'buddyboss' ) : '', 'bp_feed_settings_callback_platform', 'intval', $type );
$is_first = false;
}
// Get all active custom post type.
$post_types = get_post_types( [ 'public' => true ] );
// Exclude BP CPT
$bp_exclude_cpt = [ 'forum', 'topic', 'reply', 'page', 'attachment', 'bp-group-type', 'bp-member-type' ];
$bp_excluded_cpt = array();
foreach ( $post_types as $post_type ) {
// Exclude all the custom post type which is already in BuddyPress Activity support.
if ( in_array( $post_type, $bp_exclude_cpt ) ) {
continue;
}
$bp_excluded_cpt[] = $post_type;
}
// flag for adding conditional CSS class.
$count = 0;
$description = 0;
foreach ( $bp_excluded_cpt as $key => $post_type ) {
$fields = [];
$fields['args'] = [
'post_type' => $post_type,
'description' => false,
];
if ( 'post' === $post_type ) {
// create field for each of custom post type.
$this->add_field( "bp-feed-custom-post-type-$post_type", __( 'WordPress', 'buddyboss' ), 'bp_feed_settings_callback_post_type', 'intval', $fields['args'] );
// Activity commenting on post and comments.
$this->add_field( 'bp-disable-blogforum-comments', __( 'Post Comments', 'buddyboss' ), 'bp_admin_setting_callback_blogforum_comments', 'bp_admin_sanitize_callback_blogforum_comments' );
} else {
if ( 0 === $description ) {
$fields['args']['description'] = true;
$description =1;
}
if ( 0 === $count ) {
$fields['args']['class'] = 'child-no-padding-first';
// create field for each of custom post type.
$this->add_field( "bp-feed-custom-post-type-$post_type", __( 'Custom Post Types', 'buddyboss' ), 'bp_feed_settings_callback_post_type', 'intval', $fields['args'] );
} else {
$fields['args']['class'] = 'child-no-padding';
// create field for each of custom post type.
$this->add_field( "bp-feed-custom-post-type-$post_type", '', 'bp_feed_settings_callback_post_type', 'intval', $fields['args'] );
}
$count++;
}
}
// Posts in Activity Tutorial
$this->add_field( 'bp-posts-in-activity-tutorial','', 'bp_posts_in_activity_tutorial' );
}
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.