øŸŒ Œ 0ŽŒ · 诎Œ ´ °ŽŒ ÈŽŒ ®ŽŒ ´ H Œ ´ h Œ ´ ŽŒ PŽŒ ³ 詎Œ h¬ŽŒ € ³ È Œ p!Œ Ø#Œ @ 8ÎŽŒ » @ ÀŒ » € » (!Œ » !Œ @!Œ @ óŽŒ » @ àŒ » » !Œ € » ¸!Œ ø!Œ "Œ ¨#Œ @ 0óŽŒ » @ pˆP@ » @ pÎŽŒ » @ Œ » @ Œ » » X"Œ € » p"Œ à"Œ @#Œ @ `óŽŒ » » °"Œ » È"Œ (#Œ @ ¨ÎŽŒ » » #Œ ¼ » ("Œ @"Œ €"Œ » p#Œ » #Œ » ˆ!Œ È!Œ ³ Ð©ŽŒ à Œ @ àÎŽŒ ¼ @ @Œ ¼ € ¼ $Œ ¼ $Œ 8$Œ @ ÏŽŒ ¼ @ PÏŽŒ ¼ @ óŽŒ ¼ @ `Œ ¼ ¼ È$Œ € ¼ à$Œ %Œ 8%Œ Ð&Œ @ €Œ ¼ @ P‚P@ ¼ @ ˆÏŽŒ ¼ @ Œ ¼ @ ÀŒ ¼ ¼ €%Œ € ¼ ˜%Œ &Œ h&Œ @ ÀóŽŒ ¼ ¼ Ø%Œ ¼ ð%Œ P&Œ @ ÀÏŽŒ ¼ ¼ 8&Œ ½ ¼ P%Œ h%Œ ¨%Œ ¼ ˜&Œ ¼ ¸&Œ ¼ °$Œ ð$Œ € ¼ 'Œ ¨'Œ H+Œ @ Œ ½ @ àŒ ½ € ½ `'Œ ½ H'Œ x'Œ @ ðóŽŒ ½ @ Œ ½ ½ Ø'Œ € ½ ð'Œ 0(Œ H(Œ +Œ @ Œ ½ @ P‚P@ ½ @ 8 Œ ½ @ @Œ ½ @ `Œ ½ ½ (Œ € ½ ¨(Œ )Œ °*Œ @ ôŽŒ ½ ½ è(Œ ½ )Œ `)Œ @ p Œ ½ ½ H)Œ @ ¾ @ À @ Œ À À ¨)Œ )Œ À À)Œ 8*Œ €*Œ @ Á @ PôŽŒ Á Á *Œ *Œ @  @ P‚P@   h*Œ P*Œ À ؼŒ x)Œ À ˜*Œ ½ `(Œ x(Œ ¸(Œ ½ à*Œ ½ +Œ ½ À'Œ (Œ ¼ ˜$Œ 'Œ € ¼ `+Œ ,Œ p.Œ @ ¨ Œ Ä @ €Œ Ä € Ä À+Œ Ä ¨+Œ Ø+Œ @ €ôŽŒ Ä @ Œ Ä Ä 8,Œ € Ä P,Œ ,Œ ¨,Œ @.Œ @ °ôŽŒ Ä @ pˆP@ Ä @ à Œ Ä @ ÀŒ Ä @ àŒ Ä Ä ð,Œ € Ä -Œ x-Œ Ø-Œ @ àôŽŒ Ä Ä H-Œ Ä `-Œ À-Œ @ ¡Œ Ä Ä ¨-Œ Å Ä À,Œ Ø,Œ -Œ Ä .Œ Ä (.Œ Ä ,Œ `,Œ ¼ €$Œ x+Œ € ° ©ŽŒ ¸©ŽŒ ð#Œ h$Œ ˆ.Œ ° (¥ŽŒ .Œ ¯ ¢ŽŒ €¤ŽŒ € ¯ ¸ ŽŒ ø ŽŒ (¡ŽŒ 8¡ŽŒ P¡ŽŒ ¸¡ŽŒ Ð¡ŽŒ 衎Œ /Œ ¯ p ŽŒ ˆ ŽŒ /Œ ¯ X ŽŒ °/Œ @ Œ Æ d', __( 'Invalid menu location.' ), array( 'status' => 404 ) ); } $location = new stdClass(); $location->name = $request['location']; $location->description = $registered_menus[ $location->name ]; $data = $this->prepare_item_for_response( $location, $request ); return rest_ensure_response( $data ); } /** * Prepares a menu location object for serialization. * * @since 5.9.0 * * @param stdClass $item Post status data. * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response Menu location data. */ public function prepare_item_for_response( $item, $request ) { // Restores the more descriptive, specific name for use within this method. $location = $item; $locations = get_nav_menu_locations(); $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0; $fields = $this->get_fields_for_response( $request ); $data = array(); if ( rest_is_field_included( 'name', $fields ) ) { $data['name'] = $location->name; } if ( rest_is_field_included( 'description', $fields ) ) { $data['description'] = $location->description; } if ( rest_is_field_included( 'menu', $fields ) ) { $data['menu'] = (int) $menu; } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); $response->add_links( $this->prepare_links( $location ) ); /** * Filters menu location data returned from the REST API. * * @since 5.9.0 * * @param WP_REST_Response $response The response object. * @param object $location The original location object. * @param WP_REST_Request $request Request used to generate the response. */ return apply_filters( 'rest_prepare_menu_location', $response, $location, $request ); } /** * Retrieves the menu location's schema, conforming to JSON Schema. * * @since 5.9.0 * * @return array Item schema data. */ public function get_item_schema() { if ( $this->schema ) { return $this->add_additional_fields_schema( $this->schema ); } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'menu-location', 'type' => 'object', 'properties' => array( 'name' => array( 'description' => __( 'The name of the menu location.' ), 'type' => 'string', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'description' => array( 'description' => __( 'The description of the menu location.' ), 'type' => 'string', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), 'menu' => array( 'description' => __( 'The ID of the assigned menu.' ), 'type' => 'integer', 'context' => array( 'embed', 'view', 'edit' ), 'readonly' => true, ), ), ); return $this->add_additional_fields_schema( $this->schema ); } /** * Retrieves the query params for collections. * * @since 5.9.0 * * @return array Collection parameters. */ public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } /** * Prepares links for the request. * * @since 5.9.0 * * @param stdClass $location Menu location. * @return array Links for the given menu location. */ protected function prepare_links( $location ) { $base = sprintf( '%s/%s', $this->namespace, $this->rest_base ); // Entity meta. $links = array( 'self' => array( 'href' => rest_url( trailingslashit( $base ) . $location->name ), ), 'collection' => array( 'href' => rest_url( $base ), ), ); $locations = get_nav_menu_locations(); $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0; if ( $menu ) { $path = rest_get_route_for_term( $menu ); if ( $path ) { $url = rest_url( $path ); $links['https://api.w.org/menu'][] = array( 'href' => $url, 'embeddable' => true, ); } } return $links; } }