Changeset 53724
- Timestamp:
- 07/19/2022 04:20:54 PM (2 years ago)
- Location:
- trunk/src/wp-includes/rest-api/endpoints
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php
r51958 r53724 654 654 return array( 655 655 'self' => array( 656 'href' => rest_url( sprintf( '%s/users/%d/application-passwords/%s', $this->namespace, $user->ID, $item['uuid'] ) ), 656 'href' => rest_url( 657 sprintf( 658 '%s/users/%d/application-passwords/%s', 659 $this->namespace, 660 $user->ID, 661 $item['uuid'] 662 ) 663 ), 657 664 ), 658 665 ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
r53197 r53724 348 348 if ( $block_type->is_dynamic() ) { 349 349 $links['https://api.w.org/render-block'] = array( 350 'href' => add_query_arg( 'context', 'edit', rest_url( sprintf( '%s/%s/%s', 'wp/v2', 'block-renderer', $block_type->name ) ) ), 350 'href' => add_query_arg( 351 'context', 352 'edit', 353 rest_url( sprintf( '%s/%s/%s', 'wp/v2', 'block-renderer', $block_type->name ) ) 354 ), 351 355 ); 352 356 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
r53197 r53724 127 127 128 128 /** 129 * Get the post, if the ID is valid. 130 * 131 * @since 5.9.0 132 * 133 * @param int $id Supplied ID. 134 * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise. 135 */ 136 protected function get_post( $id ) { 137 $error = new WP_Error( 138 'rest_global_styles_not_found', 139 __( 'No global styles config exist with that id.' ), 140 array( 'status' => 404 ) 141 ); 142 143 $id = (int) $id; 144 if ( $id <= 0 ) { 145 return $error; 146 } 147 148 $post = get_post( $id ); 149 if ( empty( $post ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) { 150 return $error; 151 } 152 153 return $post; 154 } 155 156 /** 129 157 * Checks if a given request has access to read a single global style. 130 158 * … … 377 405 return $response; 378 406 } 379 380 /**381 * Get the post, if the ID is valid.382 *383 * @since 5.9.0384 *385 * @param int $id Supplied ID.386 * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.387 */388 protected function get_post( $id ) {389 $error = new WP_Error(390 'rest_global_styles_not_found',391 __( 'No global styles config exist with that id.' ),392 array( 'status' => 404 )393 );394 395 $id = (int) $id;396 if ( $id <= 0 ) {397 return $error;398 }399 400 $post = get_post( $id );401 if ( empty( $post ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {402 return $error;403 }404 405 return $post;406 }407 408 407 409 408 /** -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php
r52079 r53724 209 209 210 210 /** 211 * Prepares links for the request. 212 * 213 * @since 5.9.0 214 * 215 * @param stdClass $location Menu location. 216 * @return array Links for the given menu location. 217 */ 218 protected function prepare_links( $location ) { 219 $base = sprintf( '%s/%s', $this->namespace, $this->rest_base ); 220 221 // Entity meta. 222 $links = array( 223 'self' => array( 224 'href' => rest_url( trailingslashit( $base ) . $location->name ), 225 ), 226 'collection' => array( 227 'href' => rest_url( $base ), 228 ), 229 ); 230 231 $locations = get_nav_menu_locations(); 232 $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0; 233 if ( $menu ) { 234 $path = rest_get_route_for_term( $menu ); 235 if ( $path ) { 236 $url = rest_url( $path ); 237 238 $links['https://api.w.org/menu'][] = array( 239 'href' => $url, 240 'embeddable' => true, 241 ); 242 } 243 } 244 245 return $links; 246 } 247 248 /** 211 249 * Retrieves the menu location's schema, conforming to JSON Schema. 212 250 * … … 261 299 ); 262 300 } 263 264 /**265 * Prepares links for the request.266 *267 * @since 5.9.0268 *269 * @param stdClass $location Menu location.270 * @return array Links for the given menu location.271 */272 protected function prepare_links( $location ) {273 $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );274 275 // Entity meta.276 $links = array(277 'self' => array(278 'href' => rest_url( trailingslashit( $base ) . $location->name ),279 ),280 'collection' => array(281 'href' => rest_url( $base ),282 ),283 );284 285 $locations = get_nav_menu_locations();286 $menu = isset( $locations[ $location->name ] ) ? $locations[ $location->name ] : 0;287 if ( $menu ) {288 $path = rest_get_route_for_term( $menu );289 if ( $path ) {290 $url = rest_url( $path );291 292 $links['https://api.w.org/menu'][] = array(293 'href' => $url,294 'embeddable' => true,295 );296 }297 }298 299 return $links;300 }301 301 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php
r51657 r53724 626 626 return array( 627 627 'self' => array( 628 'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, substr( $item['_file'], 0, - 4 ) ) ), 628 'href' => rest_url( 629 sprintf( 630 '%s/%s/%s', 631 $this->namespace, 632 $this->rest_base, 633 substr( $item['_file'], 0, - 4 ) 634 ) 635 ), 629 636 ), 630 637 ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
r53721 r53724 262 262 263 263 /** 264 * Prepares links for the request. 265 * 266 * @since 6.1.0 267 * 268 * @param WP_Post_Type $post_type The post type. 269 * @return array Links for the given post type. 270 */ 271 protected function prepare_links( $post_type ) { 272 return array( 273 'collection' => array( 274 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ), 275 ), 276 'https://api.w.org/items' => array( 277 'href' => rest_url( rest_get_route_for_post_type_items( $post_type->name ) ), 278 ), 279 ); 280 } 281 282 /** 264 283 * Retrieves the post type's schema, conforming to JSON Schema. 265 284 * … … 385 404 ); 386 405 } 387 388 /**389 * Prepares links for the request.390 *391 * @since 6.1.0392 *393 * @param WP_Post_Type $post_type The post type.394 * @return array Links for the given post type.395 */396 protected function prepare_links( $post_type ) {397 return array(398 'collection' => array(399 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),400 ),401 'https://api.w.org/items' => array(402 'href' => rest_url( rest_get_route_for_post_type_items( $post_type->name ) ),403 ),404 );405 }406 406 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
r53722 r53724 290 290 291 291 /** 292 * Prepares links for the request. 293 * 294 * @since 6.1.0 295 * 296 * @param @param WP_Taxonomy $taxonomy The taxonomy. 297 * @return array Links for the given taxonomy. 298 */ 299 protected function prepare_links( $taxonomy ) { 300 return array( 301 'collection' => array( 302 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ), 303 ), 304 'https://api.w.org/items' => array( 305 'href' => rest_url( rest_get_route_for_taxonomy_items( $taxonomy->name ) ), 306 ), 307 ); 308 } 309 310 /** 292 311 * Retrieves the taxonomy's schema, conforming to JSON Schema. 293 312 * … … 428 447 return $new_params; 429 448 } 430 431 /**432 * Prepares links for the request.433 *434 * @since 6.1.0435 *436 * @param @param WP_Taxonomy $taxonomy The taxonomy.437 * @return array Links for the given taxonomy.438 */439 protected function prepare_links( $taxonomy ) {440 return array(441 'collection' => array(442 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),443 ),444 'https://api.w.org/items' => array(445 'href' => rest_url( rest_get_route_for_taxonomy_items( $taxonomy->name ) ),446 ),447 );448 }449 450 449 }
Note: See TracChangeset
for help on using the changeset viewer.