WP_REST_Sidebars_Controller::get_sidebar( string|int $id )

Retrieves the registered sidebar with the given id.

Parameters

$id

(string|int) (Required) ID of the sidebar.

Return

(array|null) The discovered sidebar, or null if it is not registered.

Source

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

protected function get_sidebar( $id ) {
		global $wp_registered_sidebars;

		foreach ( (array) $wp_registered_sidebars as $sidebar ) {
			if ( $sidebar['id'] === $id ) {
				return $sidebar;
			}
		}

		if ( 'wp_inactive_widgets' === $id ) {
			return array(
				'id'   => 'wp_inactive_widgets',
				'name' => __( 'Inactive widgets' ),
			);
		}

		return null;
	}

Changelog

Version Description
5.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_sidebars_controller/get_sidebar