WP_REST_Search_Controller::__construct() WordPress Method

The WP_REST_Search_Controller::__construct() method initializes the class and sets its properties.

WP_REST_Search_Controller::__construct( array $search_handlers ) #

Constructor.


Parameters

$search_handlers

(array)(Required)List of search handlers to use in the controller. Each search handler instance must extend the WP_REST_Search_Handler class.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php

	public function __construct( array $search_handlers ) {
		$this->namespace = 'wp/v2';
		$this->rest_base = 'search';

		foreach ( $search_handlers as $search_handler ) {
			if ( ! $search_handler instanceof WP_REST_Search_Handler ) {
				_doing_it_wrong(
					__METHOD__,
					/* translators: %s: PHP class name. */
					sprintf( __( 'REST search handlers must extend the %s class.' ), 'WP_REST_Search_Handler' ),
					'5.0.0'
				);
				continue;
			}

			$this->search_handlers[ $search_handler->get_type() ] = $search_handler;
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
5.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.