bbp_get_search_terms( string $passed_terms = '' )

Get the search terms


Description Description


Parameters Parameters

$passed_terms

(Optional) Search terms

Default value: ''


Top ↑

Return Return

(bool|string) Search terms on success, false on failure


Top ↑

Source Source

File: includes/search/template.php

	function bbp_get_search_terms( $passed_terms = '' ) {

		// Sanitize terms if they were passed in
		if ( ! empty( $passed_terms ) ) {
			$search_terms = sanitize_title( $passed_terms );

		// Use query variable if not
		} else {

			// Global
			if ( get_query_var( bbp_get_search_rewrite_id() ) ) {
				$search_terms = get_query_var( bbp_get_search_rewrite_id() );

			// Other searches
			} else {

				// Get known search type IDs
				$types = bbp_get_search_type_ids();

				// Filterable, so make sure types exist
				if ( ! empty( $types ) ) {

					// Loop through types
					foreach ( $types as $type ) {

						// Look for search terms
						$terms = bbp_sanitize_search_request( $type );

						// Skip if no terms
						if ( empty( $terms ) ) {
							continue;
						}

						// Set terms if not empty
						$search_terms = $terms;
					}
				}
			}
		}

		// Trim whitespace & decode if non-empty string, or set to false
		$search_terms = ! empty( $search_terms ) && is_string( $search_terms )
			? urldecode( trim( $search_terms ) )
			: false;

		// Filter & return
		return apply_filters( 'bbp_get_search_terms', $search_terms, $passed_terms );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.