equal
deleted
inserted
replaced
13 * @since 4.7.0 |
13 * @since 4.7.0 |
14 * |
14 * |
15 * @see WP_REST_Posts_Controller |
15 * @see WP_REST_Posts_Controller |
16 */ |
16 */ |
17 class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { |
17 class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { |
|
18 |
|
19 /** |
|
20 * Whether the controller supports batching. |
|
21 * |
|
22 * @since 5.9.0 |
|
23 * @var false |
|
24 */ |
|
25 protected $allow_batch = false; |
18 |
26 |
19 /** |
27 /** |
20 * Registers the routes for attachments. |
28 * Registers the routes for attachments. |
21 * |
29 * |
22 * @since 5.3.0 |
30 * @since 5.3.0 |
705 |
713 |
706 /** |
714 /** |
707 * Prepares a single attachment output for response. |
715 * Prepares a single attachment output for response. |
708 * |
716 * |
709 * @since 4.7.0 |
717 * @since 4.7.0 |
710 * |
718 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
711 * @param WP_Post $post Attachment object. |
719 * |
|
720 * @param WP_Post $item Attachment object. |
712 * @param WP_REST_Request $request Request object. |
721 * @param WP_REST_Request $request Request object. |
713 * @return WP_REST_Response Response object. |
722 * @return WP_REST_Response Response object. |
714 */ |
723 */ |
715 public function prepare_item_for_response( $post, $request ) { |
724 public function prepare_item_for_response( $item, $request ) { |
|
725 // Restores the more descriptive, specific name for use within this method. |
|
726 $post = $item; |
716 $response = parent::prepare_item_for_response( $post, $request ); |
727 $response = parent::prepare_item_for_response( $post, $request ); |
717 $fields = $this->get_fields_for_response( $request ); |
728 $fields = $this->get_fields_for_response( $request ); |
718 $data = $response->get_data(); |
729 $data = $response->get_data(); |
719 |
730 |
720 if ( in_array( 'description', $fields, true ) ) { |
731 if ( in_array( 'description', $fields, true ) ) { |