bp_search_get_settings_fields()

Get all of the settings fields.

Description

Return

(array)

Source

File: bp-search/bp-search-settings.php

function bp_search_get_settings_fields() {

	$fields = [];

	/** General Section ******************************************************/
	$fields['bp_search_settings_general'] = [

		'bp_search_autocomplete' => [
			'title'             => __( 'Enable Autocomplete', 'buddyboss' ),
			'callback'          => 'bp_search_settings_callback_autocomplete',
			'sanitize_callback' => 'intval',
			'args'              => []
		],

		'bp_search_number_of_results' => [
			'title'             => __( 'Number of Results', 'buddyboss' ),
			'callback'          => 'bp_search_settings_callback_number_of_results',
			'sanitize_callback' => 'intval',
			'args'              => []
		],

		'bp_search_tutorial' => [
			'title'             => __( '&#65279', 'buddyboss' ),
			'callback'          => 'bp_search_settings_tutorial',
		],
	];

	$fields['bp_search_settings_community'] = [
		'bp_search_members' => [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_members',
			'sanitize_callback' => 'intval',
			'args'              => [
				'class' => 'bp-search-parent-field'
			]
		],
	];

	$fields['bp_search_settings_community']['bp_search_user_fields_label'] = [
		'title'    => '',
		'callback' => 'bp_search_settings_callback_user_fields_label',
		'args'     => [
			'class' => 'bp-search-child-field'
		]
	];

	$user_fields = bp_get_search_user_fields();

	foreach ( $user_fields as $field_key => $field_label ) {
		$fields['bp_search_settings_community']["bp_search_user_field_{$field_key}"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_user_field',
			'sanitize_callback' => 'intval',
			'args'              => [
				'field' => [
					'field_key'   => $field_key,
					'field_label' => $field_label
				],
				'class' => 'bp-search-child-field'
			]
		];
	}

	$groups = bp_xprofile_get_groups( array(
		'fetch_fields' => true
	) );

	if ( ! empty( $groups ) ) {
		foreach ( $groups as $group ) {
			if ( ! empty( $group->fields ) ) {

				$fields['bp_search_settings_community']["bp_search_xprofile_group_{$group->id}"] = [
					'title'    => '',
					'callback' => 'bp_search_settings_callback_xprofile_group',
					'args'     => [
						'group' => $group,
						'class' => 'bp-search-child-field bp-search-subgroup-heading'
					]
				];

				foreach ( $group->fields as $field ) {
					$fields['bp_search_settings_community']["bp_search_xprofile_{$field->id}"] = [
						'title'             => '',
						'callback'          => 'bp_search_settings_callback_xprofile',
						'sanitize_callback' => 'intval',
						'args'              => [
							'field' => $field,
							'class' => 'bp-search-child-field'
						]
					];
				}
			}
		}
	}


	if ( bp_is_active( 'forums' ) ) {
		$fields['bp_search_settings_community']["bp_search_post_type_forum"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_post_type',
			'sanitize_callback' => 'intval',
			'args'              => [
				'post_type' => 'forum',
				'class'     => 'bp-search-parent-field'
			]
		];

		$fields['bp_search_settings_community']["bp_search_post_type_topic"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_post_type',
			'sanitize_callback' => 'intval',
			'args'              => [
				'post_type' => 'topic',
				'class'     => 'bp-search-child-field'
			]
		];

		$fields['bp_search_settings_community']["bp_search_post_type_reply"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_post_type',
			'sanitize_callback' => 'intval',
			'args'              => [
				'post_type' => 'reply',
				'class'     => 'bp-search-child-field'
			]
		];
	}

	if ( bp_is_active( 'groups' ) ) {
		$fields['bp_search_settings_community']["bp_search_groups"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_groups',
			'sanitize_callback' => 'intval',
			'args'              => [
				'class' => 'bp-search-parent-field'
			]
		];
	}

	if ( bp_is_active( 'activity' ) ) {
		$fields['bp_search_settings_community']["bp_search_activity"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_activity',
			'sanitize_callback' => 'intval',
			'args'              => [
				'class' => 'bp-search-parent-field'
			]
		];

		$fields['bp_search_settings_community']["bp_search_activity_comments"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_activity_comments',
			'sanitize_callback' => 'intval',
			'args'              => [
				'class' => 'bp-search-child-field'
			]
		];
	}

	$post_types = get_post_types( [ 'public' => true ] );

	foreach ( $post_types as $post_type ) {

		if ( in_array( $post_type, [ 'forum', 'topic', 'reply' ] ) ) {
			continue;
		}

		$fields['bp_search_settings_post_types']["bp_search_post_type_$post_type"] = [
			'title'             => '',
			'callback'          => 'bp_search_settings_callback_post_type',
			'sanitize_callback' => 'intval',
			'args'              => [
				'post_type' => $post_type,
				'class'     => 'bp-search-parent-field'
			]
		];

		$taxonomies = get_object_taxonomies( $post_type );

		foreach ( $taxonomies as $taxonomy ) {
			$fields['bp_search_settings_post_types']["bp_search_{$post_type}_tax_{$taxonomy}"] = [
				'title'             => '',
				'callback'          => 'bp_search_settings_callback_post_type_taxonomy',
				'sanitize_callback' => 'intval',
				'args'              => [
					'post_type' => $post_type,
					'taxonomy'  => $taxonomy,
					'class'     => 'bp-search-child-field'
				]
			];
		}


		if ( in_array( $post_type, [ 'post', 'page' ] ) ) {
			$fields['bp_search_settings_post_types']["bp_search_post_type_meta_$post_type"] = [
				'title'             => '',
				'callback'          => 'bp_search_settings_callback_post_type_meta',
				'sanitize_callback' => 'intval',
				'args'              => [
					'post_type' => $post_type,
					'class'     => 'bp-search-child-field'
				]
			];
		}

	}

	return (array) apply_filters( 'bp_search_get_settings_fields', $fields );
}

Changelog

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.