BP_Search::load_search_helpers()

Description

Source

File: bp-search/classes/class-bp-search.php

		public function load_search_helpers() {
			global $bp;

			//load the helper type parent class
			require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-types.php' );

			//load and associate helpers one by one
			if ( bp_is_search_post_type_enable( 'post' ) ) {
				require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-posts.php' );
				$this->search_helpers['posts'] = new Bp_Search_Posts( 'post', 'posts' );
				$this->searchable_items[] = 'posts';
			}

			if ( bp_is_search_post_type_enable( 'page' ) ) {
				require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-posts.php' );
				$this->search_helpers['pages'] = new Bp_Search_Posts( 'page', 'pages' );
			}

			if ( bp_is_active( 'forums' ) && bp_is_search_post_type_enable( 'forum' ) ) {

				require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-bbpress.php' );

				if ( bp_is_search_post_type_enable( 'forum' ) ) {
					require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-bbpress-forums.php' );
					$this->search_helpers['forum'] = Bp_Search_bbPress_Forums::instance();
					$this->searchable_items[]      = 'forum';
				}


				if ( bp_is_search_post_type_enable( 'topic' ) ) {
					require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-bbpress-forums-topics.php' );
					$this->search_helpers['topic'] = Bp_Search_bbPress_Topics::instance();
					$this->searchable_items[]      = 'topic';
				}

				if ( bp_is_search_post_type_enable( 'reply' ) ) {
					require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-bbpress-forums-replies.php' );
					$this->search_helpers['reply'] = Bp_Search_bbPress_Replies::instance();
					$this->searchable_items[]      = 'reply';
				}
			}

			//Check BuddyPress is active
			if ( bp_is_search_members_enable() ) {
				require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-members.php' );
				$this->search_helpers['members'] = Bp_Search_Members::instance();
				$this->searchable_items[]        = 'members';
			}

			if ( bp_is_active( 'groups' ) && bp_is_search_groups_enable() ) {
				require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-groups.php' );
				$this->search_helpers['groups'] = Bp_Search_Groups::instance();
				$this->searchable_items[]       = 'groups';
			}

			if ( bp_is_active( 'activity' ) && bp_is_search_activity_enable() ) {
				require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-activities.php' );
				$this->search_helpers['activity'] = Bp_Search_Activities::instance();
				$this->searchable_items[]         = 'activity';

				if ( bp_is_search_activity_comments_enable() ) {
					require_once( $bp->plugin_dir . 'bp-search/classes/class-bp-search-activity-comments.php' );
					$this->search_helpers['activity_comment'] = Bp_Search_Activity_Comment::instance();
					$this->searchable_items[]                 = 'activity_comment';

				}
			}

			/**
			 * Hook to load helper classes for additional search types.
			 */
			$additional_search_helpers = apply_filters( 'bp_search_additional_search_helpers', array() );
			if ( ! empty( $additional_search_helpers ) ) {
				foreach ( $additional_search_helpers as $search_type => $helper_object ) {
					/**
					 * All helper classes must inherit from bp_search_Type
					 */
					if ( ! isset( $this->search_helpers[ $search_type ] ) && is_a( $helper_object, 'BP_Search_Type' ) ) {
						$this->search_helpers[ $search_type ] = $helper_object;
					}
				}
			}

		}

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.