WP_REST_Sidebars_Controller::get_items() WordPress Method

The WP_REST_Sidebars_Controller::get_items() method is used to retrieve a list of sidebars.

WP_REST_Sidebars_Controller::get_items( WP_REST_Request $request ) #

Retrieves the list of sidebars (active or inactive).


Parameters

$request

(WP_REST_Request)(Required)Full details about the request.


Top ↑

Return

(WP_REST_Response) Response object on success.


Top ↑

Source

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

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.8.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.