PluginProbe
Gutenberg / 8.5.1
Gutenberg v8.5.1
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | lib/class-wp-rest-menu-locations-controller.php +8 -20 12.6.0 → 8.5.1 View file →
@@ -16,9 +16,9 @@
16 16 /**
17 17 * Constructor.
18 18 */
19 19 public function __construct() {
20 - $this->namespace = 'wp/v2';
20 + $this->namespace = '__experimental';
21 21 $this->rest_base = 'menu-locations';
22 22 }
23 23
24 24 /**
@@ -151,24 +151,14 @@
151 151 */
152 152 public function prepare_item_for_response( $location, $request ) {
153 153 $locations = get_nav_menu_locations();
154 154 $menu = ( isset( $locations[ $location->name ] ) ) ? $locations[ $location->name ] : 0;
155 + $data = array(
156 + 'name' => $location->name,
157 + 'description' => $location->description,
158 + 'menu' => $menu,
159 + );
155 160
156 - $fields = $this->get_fields_for_response( $request );
157 - $data = array();
158 -
159 - if ( rest_is_field_included( 'name', $fields ) ) {
160 - $data['name'] = $location->name;
161 - }
162 -
163 - if ( rest_is_field_included( 'description', $fields ) ) {
164 - $data['description'] = $location->description;
165 - }
166 -
167 - if ( rest_is_field_included( 'menu', $fields ) ) {
168 - $data['menu'] = (int) $menu;
169 - }
170 -
171 161 $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
172 162 $data = $this->add_additional_fields_to_object( $data, $request );
173 163 $data = $this->filter_response_by_context( $data, $context );
174 164
@@ -259,12 +249,10 @@
259 249 $menu = ( isset( $locations[ $location->name ] ) ) ? $locations[ $location->name ] : 0;
260 250 if ( $menu ) {
261 251 $taxonomy_object = get_taxonomy( 'nav_menu' );
262 252 if ( $taxonomy_object->show_in_rest ) {
263 - $rest_base = ! empty( $taxonomy_object->rest_base ) ? $taxonomy_object->rest_base : $taxonomy_object->name;
264 - $namespace = ! empty( $taxonomy_object->rest_namespace ) ? $taxonomy_object->rest_namespace : '__experimental';
265 - $url = rest_url( sprintf( '%s/%s/%d', $namespace, $rest_base, $menu ) );
266 -
253 + $rest_base = ! empty( $taxonomy_object->rest_base ) ? $taxonomy_object->rest_base : $taxonomy_object->name;
254 + $url = rest_url( sprintf( '__experimental/%s/%d', $rest_base, $menu ) );
267 255 $links['https://api.w.org/menu'][] = array(
268 256 'href' => $url,
269 257 'embeddable' => true,
270 258 );