Changeset 51786
- Timestamp:
- 09/09/2021 06:35:34 PM (3 years ago)
- Location:
- trunk/src/wp-includes/rest-api/endpoints
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r51000 r51786 708 708 * 709 709 * @since 4.7.0 710 * 711 * @param WP_Post $post Attachment object. 710 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 711 * 712 * @param WP_Post $item Attachment object. 712 713 * @param WP_REST_Request $request Request object. 713 714 * @return WP_REST_Response Response object. 714 715 */ 715 public function prepare_item_for_response( $post, $request ) { 716 public function prepare_item_for_response( $item, $request ) { 717 // Restores the more descriptive, specific name for use within this method. 718 $post = $item; 716 719 $response = parent::prepare_item_for_response( $post, $request ); 717 720 $fields = $this->get_fields_for_response( $request ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
r51298 r51786 397 397 * 398 398 * @since 5.0.0 399 * 400 * @param WP_Post $post Post revision object. 399 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 400 * 401 * @param WP_Post $item Post revision object. 401 402 * @param WP_REST_Request $request Request object. 402 403 * @return WP_REST_Response Response object. 403 404 */ 404 public function prepare_item_for_response( $post, $request ) { 405 405 public function prepare_item_for_response( $item, $request ) { 406 // Restores the more descriptive, specific name for use within this method. 407 $post = $item; 406 408 $response = $this->revisions_controller->prepare_item_for_response( $post, $request ); 407 409 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
r51676 r51786 110 110 * 111 111 * @since 5.5.0 112 * 113 * @param array $plugin The plugin metadata. 112 * @since 5.9.0 Renamed `$plugin` to `$item` to match parent class for PHP 8 named parameter support. 113 * 114 * @param array $item The plugin metadata. 114 115 * @param WP_REST_Request $request Request object. 115 116 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. 116 117 */ 117 public function prepare_item_for_response( $plugin, $request ) { 118 public function prepare_item_for_response( $item, $request ) { 119 // Restores the more descriptive, specific name for use within this method. 120 $plugin = $item; 121 118 122 // There might be multiple blocks in a plugin. Only the first block is mapped. 119 123 $block_data = reset( $plugin['blocks'] ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
r51693 r51786 237 237 * 238 238 * @since 5.5.0 239 * 240 * @param WP_Block_Type $block_type Block type data. 241 * @param WP_REST_Request $request Full details about the request. 239 * @since 5.9.0 Renamed `$block_type` to `$item` to match parent class for PHP 8 named parameter support. 240 * 241 * @param WP_Block_Type $item Block type data. 242 * @param WP_REST_Request $request Full details about the request. 242 243 * @return WP_REST_Response Block type data. 243 244 */ 244 public function prepare_item_for_response( $block_type, $request ) { 245 246 $fields = $this->get_fields_for_response( $request ); 247 $data = array(); 245 public function prepare_item_for_response( $item, $request ) { 246 // Restores the more descriptive, specific name for use within this method. 247 $block_type = $item; 248 $fields = $this->get_fields_for_response( $request ); 249 $data = array(); 248 250 249 251 if ( rest_is_field_included( 'attributes', $fields ) ) { -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
r51293 r51786 1029 1029 * 1030 1030 * @since 4.7.0 1031 * 1032 * @param WP_Comment $comment Comment object. 1031 * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support. 1032 * 1033 * @param WP_Comment $item Comment object. 1033 1034 * @param WP_REST_Request $request Request object. 1034 1035 * @return WP_REST_Response Response object. 1035 1036 */ 1036 public function prepare_item_for_response( $comment, $request ) { 1037 1038 $fields = $this->get_fields_for_response( $request ); 1039 $data = array(); 1037 public function prepare_item_for_response( $item, $request ) { 1038 // Restores the more descriptive, specific name for use within this method. 1039 $comment = $item; 1040 $fields = $this->get_fields_for_response( $request ); 1041 $data = array(); 1040 1042 1041 1043 if ( in_array( 'id', $fields, true ) ) { -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
r51289 r51786 200 200 * 201 201 * @since 5.8.0 202 * 203 * @param object $raw_pattern A pattern from api.wordpress.org, before any changes. 204 * @param WP_REST_Request $request Request object. 202 * @since 5.9.0 Renamed `$raw_pattern` to `$item` to match parent class for PHP 8 named parameter support. 203 * 204 * @param object $item Raw pattern from api.wordpress.org, before any changes. 205 * @param WP_REST_Request $request Request object. 205 206 * @return WP_REST_Response 206 207 */ 207 public function prepare_item_for_response( $raw_pattern, $request ) { 208 public function prepare_item_for_response( $item, $request ) { 209 // Restores the more descriptive, specific name for use within this method. 210 $raw_pattern = $item; 208 211 $prepared_pattern = array( 209 212 'id' => absint( $raw_pattern->id ), -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php
r51000 r51786 214 214 * 215 215 * @since 4.7.0 216 * 217 * @param stdClass $status Post status data. 216 * @since 5.9.0 Renamed `$status` to `$item` to match parent class for PHP 8 named parameter support. 217 * 218 * @param stdClass $item Post status data. 218 219 * @param WP_REST_Request $request Full details about the request. 219 220 * @return WP_REST_Response Post status data. 220 221 */ 221 public function prepare_item_for_response( $status, $request ) { 222 222 public function prepare_item_for_response( $item, $request ) { 223 // Restores the more descriptive, specific name for use within this method. 224 $status = $item; 223 225 $fields = $this->get_fields_for_response( $request ); 224 226 $data = array(); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
r51000 r51786 169 169 * 170 170 * @since 4.7.0 171 * 172 * @param WP_Post_Type $post_type Post type object. 173 * @param WP_REST_Request $request Full details about the request. 171 * @since 5.9.0 Renamed `$post_type` to `$item` to match parent class for PHP 8 named parameter support. 172 * 173 * @param WP_Post_Type $item Post type object. 174 * @param WP_REST_Request $request Full details about the request. 174 175 * @return WP_REST_Response Response object. 175 176 */ 176 public function prepare_item_for_response( $post_type, $request ) { 177 public function prepare_item_for_response( $item, $request ) { 178 // Restores the more descriptive, specific name for use within this method. 179 $post_type = $item; 177 180 $taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) ); 178 181 $taxonomies = wp_list_pluck( $taxonomies, 'name' ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r51327 r51786 1680 1680 * 1681 1681 * @since 4.7.0 1682 * 1683 * @param WP_Post $post Post object. 1682 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 1683 * 1684 * @param WP_Post $item Post object. 1684 1685 * @param WP_REST_Request $request Request object. 1685 1686 * @return WP_REST_Response Response object. 1686 1687 */ 1687 public function prepare_item_for_response( $post, $request ) { 1688 public function prepare_item_for_response( $item, $request ) { 1689 // Restores the more descriptive, specific name for use within this method. 1690 $post = $item; 1688 1691 $GLOBALS['post'] = $post; 1689 1692 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
r51000 r51786 536 536 * 537 537 * @since 4.7.0 538 * 539 * @param WP_Post $post Post revision object. 538 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. 539 * 540 * @param WP_Post $item Post revision object. 540 541 * @param WP_REST_Request $request Request object. 541 542 * @return WP_REST_Response Response object. 542 543 */ 543 public function prepare_item_for_response( $post, $request ) { 544 public function prepare_item_for_response( $item, $request ) { 545 // Restores the more descriptive, specific name for use within this method. 546 $post = $item; 544 547 $GLOBALS['post'] = $post; 545 548 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php
r51302 r51786 187 187 * @since 5.0.0 188 188 * @since 5.6.0 The `$id` parameter can accept a string. 189 * 190 * @param int|string $id ID of the item to prepare. 189 * @since 5.9.0 Renamed `$id` to `$item` to match parent class for PHP 8 named parameter support. 190 * 191 * @param int|string $item ID of the item to prepare. 191 192 * @param WP_REST_Request $request Request object. 192 193 * @return WP_REST_Response Response object. 193 194 */ 194 public function prepare_item_for_response( $id, $request ) { 195 public function prepare_item_for_response( $item, $request ) { 196 // Restores the more descriptive, specific name for use within this method. 197 $item_id = $item; 195 198 $handler = $this->get_search_handler( $request ); 196 199 if ( is_wp_error( $handler ) ) { … … 200 203 $fields = $this->get_fields_for_response( $request ); 201 204 202 $data = $handler->prepare_item( $i d, $fields );205 $data = $handler->prepare_item( $item_id, $fields ); 203 206 $data = $this->add_additional_fields_to_object( $data, $request ); 204 207 … … 208 211 $response = rest_ensure_response( $data ); 209 212 210 $links = $handler->prepare_item_links( $i d );213 $links = $handler->prepare_item_links( $item_id ); 211 214 $links['collection'] = array( 212 215 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ), -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php
r51705 r51786 263 263 * 264 264 * @since 5.8.0 265 * @since 5.9.0 Renamed `$raw_sidebar` to `$item` to match parent class for PHP 8 named parameter support. 265 266 * 266 267 * @global array $wp_registered_sidebars The registered sidebars. 267 268 * @global array $wp_registered_widgets The registered widgets. 268 269 * 269 * @param array $ raw_sidebarSidebar instance.270 * @param WP_REST_Request $request 270 * @param array $item Sidebar instance. 271 * @param WP_REST_Request $request Full details about the request. 271 272 * @return WP_REST_Response Prepared response object. 272 273 */ 273 public function prepare_item_for_response( $ raw_sidebar, $request ) {274 public function prepare_item_for_response( $item, $request ) { 274 275 global $wp_registered_sidebars, $wp_registered_widgets; 275 276 276 $id = $raw_sidebar['id']; 277 $sidebar = array( 'id' => $id ); 277 // Restores the more descriptive, specific name for use within this method. 278 $raw_sidebar = $item; 279 $id = $raw_sidebar['id']; 280 $sidebar = array( 'id' => $id ); 278 281 279 282 if ( isset( $wp_registered_sidebars[ $id ] ) ) { -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
r51000 r51786 201 201 * 202 202 * @since 4.7.0 203 * 204 * @param WP_Taxonomy $taxonomy Taxonomy data. 205 * @param WP_REST_Request $request Full details about the request. 203 * @since 5.9.0 Renamed `$taxonomy` to `$item` to match parent class for PHP 8 named parameter support. 204 * 205 * @param WP_Taxonomy $item Taxonomy data. 206 * @param WP_REST_Request $request Full details about the request. 206 207 * @return WP_REST_Response Response object. 207 208 */ 208 public function prepare_item_for_response( $taxonomy, $request ) { 209 $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; 209 public function prepare_item_for_response( $item, $request ) { 210 // Restores the more descriptive, specific name for use within this method. 211 $taxonomy = $item; 212 $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; 210 213 211 214 $fields = $this->get_fields_for_response( $request ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php
r51349 r51786 403 403 * 404 404 * @since 5.8.0 405 * 406 * @param WP_Block_Template $template Template instance. 405 * @since 5.9.0 Renamed `$template` to `$item` to match parent class for PHP 8 named parameter support. 406 * 407 * @param WP_Block_Template $item Template instance. 407 408 * @param WP_REST_Request $request Request object. 408 409 * @return WP_REST_Response $data 409 410 */ 410 public function prepare_item_for_response( $template, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable 411 $result = array( 411 public function prepare_item_for_response( $item, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable 412 // Restores the more descriptive, specific name for use within this method. 413 $template = $item; 414 $result = array( 412 415 'id' => $template->id, 413 416 'theme' => $template->theme, -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php
r51289 r51786 205 205 * 206 206 * @since 5.0.0 207 * 208 * @param WP_Theme $theme Theme object. 207 * @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support. 208 * 209 * @param WP_Theme $item Theme object. 209 210 * @param WP_REST_Request $request Request object. 210 211 * @return WP_REST_Response Response object. 211 212 */ 212 public function prepare_item_for_response( $theme, $request ) { 213 public function prepare_item_for_response( $item, $request ) { 214 // Restores the more descriptive, specific name for use within this method. 215 $theme = $item; 213 216 $data = array(); 214 217 $fields = $this->get_fields_for_response( $request ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r51278 r51786 964 964 * 965 965 * @since 4.7.0 966 * 967 * @param WP_User $user User object. 966 * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support. 967 * 968 * @param WP_User $item User object. 968 969 * @param WP_REST_Request $request Request object. 969 970 * @return WP_REST_Response Response object. 970 971 */ 971 public function prepare_item_for_response( $user, $request ) { 972 972 public function prepare_item_for_response( $item, $request ) { 973 // Restores the more descriptive, specific name for use within this method. 974 $user = $item; 973 975 $data = array(); 974 976 $fields = $this->get_fields_for_response( $request ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
r51657 r51786 264 264 * 265 265 * @since 5.8.0 266 * 267 * @param array $widget_type Widget type data. 268 * @param WP_REST_Request $request Full details about the request. 266 * @since 5.9.0 Renamed `$widget_type` to `$item` to match parent class for PHP 8 named parameter support. 267 * 268 * @param array $item Widget type data. 269 * @param WP_REST_Request $request Full details about the request. 269 270 * @return WP_REST_Response Widget type data. 270 271 */ 271 public function prepare_item_for_response( $widget_type, $request ) { 272 $fields = $this->get_fields_for_response( $request ); 273 $data = array( 272 public function prepare_item_for_response( $item, $request ) { 273 // Restores the more descriptive, specific name for use within this method. 274 $widget_type = $item; 275 $fields = $this->get_fields_for_response( $request ); 276 $data = array( 274 277 'id' => $widget_type['id'], 275 278 );
Note: See TracChangeset
for help on using the changeset viewer.