wp/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
   117 	 *
   117 	 *
   118 	 * @param WP_REST_Request $request Full details about the request.
   118 	 * @param WP_REST_Request $request Full details about the request.
   119 	 * @return WP_REST_Response Response object on success.
   119 	 * @return WP_REST_Response Response object on success.
   120 	 */
   120 	 */
   121 	public function get_items( $request ) {
   121 	public function get_items( $request ) {
       
   122 		if ( $request->is_method( 'HEAD' ) ) {
       
   123 			// Return early as this handler doesn't add any response headers.
       
   124 			return new WP_REST_Response( array() );
       
   125 		}
       
   126 
   122 		$this->retrieve_widgets();
   127 		$this->retrieve_widgets();
   123 
   128 
   124 		$data              = array();
   129 		$data              = array();
   125 		$permissions_check = $this->do_permissions_check();
   130 		$permissions_check = $this->do_permissions_check();
   126 
   131 
   318 	public function prepare_item_for_response( $item, $request ) {
   323 	public function prepare_item_for_response( $item, $request ) {
   319 		global $wp_registered_sidebars, $wp_registered_widgets;
   324 		global $wp_registered_sidebars, $wp_registered_widgets;
   320 
   325 
   321 		// Restores the more descriptive, specific name for use within this method.
   326 		// Restores the more descriptive, specific name for use within this method.
   322 		$raw_sidebar = $item;
   327 		$raw_sidebar = $item;
       
   328 
       
   329 		// Don't prepare the response body for HEAD requests.
       
   330 		if ( $request->is_method( 'HEAD' ) ) {
       
   331 			/** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php */
       
   332 			return apply_filters( 'rest_prepare_sidebar', new WP_REST_Response( array() ), $raw_sidebar, $request );
       
   333 		}
   323 
   334 
   324 		$id      = $raw_sidebar['id'];
   335 		$id      = $raw_sidebar['id'];
   325 		$sidebar = array( 'id' => $id );
   336 		$sidebar = array( 'id' => $id );
   326 
   337 
   327 		if ( isset( $wp_registered_sidebars[ $id ] ) ) {
   338 		if ( isset( $wp_registered_sidebars[ $id ] ) ) {