Changeset 54121
- Timestamp:
- 09/11/2022 06:53:28 PM (2 years ago)
- Location:
- trunk/src/wp-includes/rest-api/endpoints
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r53841 r54121 419 419 420 420 $request_params = $request->get_query_params(); 421 $base = add_query_arg( urlencode_deep( $request_params ), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) ); 421 $collection_url = rest_url( rest_get_route_for_post_type_items( $this->post_type ) ); 422 $base = add_query_arg( urlencode_deep( $request_params ), $collection_url ); 422 423 423 424 if ( $page > 1 ) { … … 778 779 779 780 $response->set_status( 201 ); 780 $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $post_id) ) );781 $response->header( 'Location', rest_url( rest_get_route_for_post( $post ) ) ); 781 782 782 783 return $response; … … 2031 2032 */ 2032 2033 protected function prepare_links( $post ) { 2033 $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );2034 2035 2034 // Entity meta. 2036 2035 $links = array( 2037 2036 'self' => array( 2038 'href' => rest_url( trailingslashit( $base ) . $post->ID),2037 'href' => rest_url( rest_get_route_for_post( $post->ID ) ), 2039 2038 ), 2040 2039 'collection' => array( 2041 'href' => rest_url( $base),2040 'href' => rest_url( rest_get_route_for_post_type_items( $this->post_type ) ), 2042 2041 ), 2043 2042 'about' => array( … … 2067 2066 $revisions = wp_get_latest_revision_id_and_total_count( $post->ID ); 2068 2067 $revisions_count = ! is_wp_error( $revisions ) ? $revisions['count'] : 0; 2068 $revisions_base = sprintf( '/%s/%s/%d/revisions', $this->namespace, $this->rest_base, $post->ID ); 2069 2069 2070 2070 $links['version-history'] = array( 2071 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions'),2071 'href' => rest_url( $revisions_base ), 2072 2072 'count' => $revisions_count, 2073 2073 ); … … 2075 2075 if ( $revisions_count > 0 ) { 2076 2076 $links['predecessor-version'] = array( 2077 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $revisions['latest_id'] ),2077 'href' => rest_url( $revisions_base . '/' . $revisions['latest_id'] ), 2078 2078 'id' => $revisions['latest_id'], 2079 2079 ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
r51962 r54121 335 335 336 336 $request_params = $request->get_query_params(); 337 $base = add_query_arg( urlencode_deep( $request_params ), rest_url( sprintf( '%s/%s/%d/%s', $this->namespace, $this->parent_base, $request['parent'], $this->rest_base ) ) ); 337 $base_path = rest_url( sprintf( '%s/%s/%d/%s', $this->namespace, $this->parent_base, $request['parent'], $this->rest_base ) ); 338 $base = add_query_arg( urlencode_deep( $request_params ), $base_path ); 338 339 339 340 if ( $page > 1 ) { … … 621 622 622 623 if ( ! empty( $data['parent'] ) ) { 623 $response->add_link( 'parent', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->parent_base,$data['parent'] ) ) );624 $response->add_link( 'parent', rest_url( rest_get_route_for_post( $data['parent'] ) ) ); 624 625 } 625 626 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
r53760 r54121 688 688 */ 689 689 protected function prepare_links( $id ) { 690 $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );691 692 690 $links = array( 693 691 'self' => array( 694 'href' => rest_url( trailingslashit( $base ) . $id),692 'href' => rest_url( rest_get_route_for_post( $id ) ), 695 693 ), 696 694 'collection' => array( 697 'href' => rest_url( $base),695 'href' => rest_url( rest_get_route_for_post_type_items( $this->post_type ) ), 698 696 ), 699 697 'about' => array( -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
r53760 r54121 304 304 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 305 305 306 $base = add_query_arg( urlencode_deep( $request->get_query_params() ), rest_url( $this->namespace . '/' . $this->rest_base ) ); 306 $request_params = $request->get_query_params(); 307 $collection_url = rest_url( rest_get_route_for_taxonomy_items( $this->taxonomy ) ); 308 $base = add_query_arg( urlencode_deep( $request_params ), $collection_url ); 309 307 310 if ( $page > 1 ) { 308 311 $prev_page = $page - 1; … … 894 897 */ 895 898 protected function prepare_links( $term ) { 896 $base = $this->namespace . '/' . $this->rest_base;897 899 $links = array( 898 900 'self' => array( 899 'href' => rest_url( trailingslashit( $base ) . $term->term_id),901 'href' => rest_url( rest_get_route_for_term( $term ) ), 900 902 ), 901 903 'collection' => array( 902 'href' => rest_url( $base),904 'href' => rest_url( rest_get_route_for_taxonomy_items( $this->taxonomy ) ), 903 905 ), 904 906 'about' => array( … … 912 914 if ( $parent_term ) { 913 915 $links['up'] = array( 914 'href' => rest_url( trailingslashit( $base ) . $parent_term->term_id),916 'href' => rest_url( rest_get_route_for_term( $parent_term ) ), 915 917 'embeddable' => true, 916 918 );
Note: See TracChangeset
for help on using the changeset viewer.