bp_search_option_cpt_search( array $items_to_search )

Print all custom post types on settings screen.

Description

Parameters

$items_to_search

(array) (Required)

Source

File: bp-search/plugins/search-cpt/index.php

function bp_search_option_cpt_search( $items_to_search ){
	//all the cpts registered
	$cpts = get_post_types( array( 'public'=>true, 'publicly_queryable'=>true, 'exclude_from_search'=>false ), 'objects' );

	//remove posts
	$cpts['post'] = null;
	unset( $cpts['post'] );

	//remove attachment
	$cpts['attachment'] = null;
	unset( $cpts['attachment'] );

	$cpts = apply_filters( 'bp_search_cpts_to_search', $cpts );

	if( !empty( $cpts ) ){
		foreach( $cpts as $cpt=>$cpt_obj ){
			$checked = !empty( $items_to_search ) && in_array( 'cpt-' . $cpt, $items_to_search ) ? ' checked' : '';
			echo "<label><input type='checkbox' value='cpt-{$cpt}' name='bp_search_plugin_options[items-to-search][]' {$checked}>{$cpt_obj->label}</label><br>";
			do_action( 'bp_search_settings_item_'.$cpt, $items_to_search );
		}
	}
}

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.