Changeset 60917 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
- Timestamp:
- 10/09/2025 05:21:12 AM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r60916 r60917 71 71 * 72 72 * @since 4.7.0 73 * @since 6.9.0 Extends the `media_type` and `mime_type` request arguments to support array values. 73 74 * 74 75 * @param array $prepared_args Optional. Array of prepared arguments. Default empty array. … … 83 84 } 84 85 85 $media_types = $this->get_media_types(); 86 87 if ( ! empty( $request['media_type'] ) && isset( $media_types[ $request['media_type'] ] ) ) { 88 $query_args['post_mime_type'] = $media_types[ $request['media_type'] ]; 89 } 90 91 if ( ! empty( $request['mime_type'] ) ) { 92 $parts = explode( '/', $request['mime_type'] ); 93 if ( isset( $media_types[ $parts[0] ] ) && in_array( $request['mime_type'], $media_types[ $parts[0] ], true ) ) { 94 $query_args['post_mime_type'] = $request['mime_type']; 95 } 86 $all_mime_types = array(); 87 $media_types = $this->get_media_types(); 88 89 if ( ! empty( $request['media_type'] ) && is_array( $request['media_type'] ) ) { 90 foreach ( $request['media_type'] as $type ) { 91 if ( isset( $media_types[ $type ] ) ) { 92 $all_mime_types = array_merge( $all_mime_types, $media_types[ $type ] ); 93 } 94 } 95 } 96 97 if ( ! empty( $request['mime_type'] ) && is_array( $request['mime_type'] ) ) { 98 foreach ( $request['mime_type'] as $mime_type ) { 99 $parts = explode( '/', $mime_type ); 100 if ( isset( $media_types[ $parts[0] ] ) && in_array( $mime_type, $media_types[ $parts[0] ], true ) ) { 101 $all_mime_types[] = $mime_type; 102 } 103 } 104 } 105 106 if ( ! empty( $all_mime_types ) ) { 107 $query_args['post_mime_type'] = array_values( array_unique( $all_mime_types ) ); 96 108 } 97 109 … … 1343 1355 * 1344 1356 * @since 4.7.0 1357 * @since 6.9.0 Extends the `media_type` and `mime_type` request arguments to support array values. 1345 1358 * 1346 1359 * @return array Query parameters for the attachment collection as an array. … … 1350 1363 $params['status']['default'] = 'inherit'; 1351 1364 $params['status']['items']['enum'] = array( 'inherit', 'private', 'trash' ); 1352 $media_types = $this->get_media_types();1365 $media_types = array_keys( $this->get_media_types() ); 1353 1366 1354 1367 $params['media_type'] = array( 1355 1368 'default' => null, 1356 'description' => __( 'Limit result set to attachments of a particular media type.' ), 1357 'type' => 'string', 1358 'enum' => array_keys( $media_types ), 1369 'description' => __( 'Limit result set to attachments of a particular media type or media types.' ), 1370 'type' => 'array', 1371 'items' => array( 1372 'type' => 'string', 1373 'enum' => $media_types, 1374 ), 1359 1375 ); 1360 1376 1361 1377 $params['mime_type'] = array( 1362 1378 'default' => null, 1363 'description' => __( 'Limit result set to attachments of a particular MIME type.' ), 1364 'type' => 'string', 1379 'description' => __( 'Limit result set to attachments of a particular MIME type or MIME types.' ), 1380 'type' => 'array', 1381 'items' => array( 1382 'type' => 'string', 1383 ), 1365 1384 ); 1366 1385
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)