WP_REST_Sidebars_Controller::get_items()publicWP 5.8.0

Retrieves the list of sidebars (active or inactive).

Метод класса: WP_REST_Sidebars_Controller{}

Хуков нет.

Возвращает

WP_REST_Response. Response object on success.

Использование

$WP_REST_Sidebars_Controller = new WP_REST_Sidebars_Controller();
$WP_REST_Sidebars_Controller->get_items( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Список изменений

С версии 5.8.0 Введена.

Код WP_REST_Sidebars_Controller::get_items() WP 6.6.2

public function get_items( $request ) {
	$this->retrieve_widgets();

	$data              = array();
	$permissions_check = $this->do_permissions_check();

	foreach ( wp_get_sidebars_widgets() as $id => $widgets ) {
		$sidebar = $this->get_sidebar( $id );

		if ( ! $sidebar ) {
			continue;
		}

		if ( is_wp_error( $permissions_check ) && ! $this->check_read_permission( $sidebar ) ) {
			continue;
		}

		$data[] = $this->prepare_response_for_collection(
			$this->prepare_item_for_response( $sidebar, $request )
		);
	}

	return rest_ensure_response( $data );
}