WP_REST_Sidebars_Controller::get_sidebar( string|int $id )

Retrieves the registered sidebar with the given id.


Parameters Parameters

$id

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


Top ↑

Return Return

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


Top ↑

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


Top ↑

Changelog Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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