Skip to content

Commit a691ce6

Browse files
Try adding attachment trashable status to REST API
1 parent 6b57942 commit a691ce6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,10 @@ public function prepare_item_for_response( $item, $request ) {
941941
$data['missing_image_sizes'] = array_keys( wp_get_missing_image_subsizes( $post->ID ) );
942942
}
943943

944+
if ( in_array( 'trashable', $fields, true ) ) {
945+
$data['trashable'] = ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH );
946+
}
947+
944948
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
945949

946950
$data = $this->filter_response_by_context( $data, $context );
@@ -1083,6 +1087,13 @@ public function get_item_schema() {
10831087
'readonly' => true,
10841088
);
10851089

1090+
$schema['properties']['trashable'] = array(
1091+
'description' => __( 'Whether the attachment can be moved to the trash.' ),
1092+
'type' => 'boolean',
1093+
'context' => array( 'view', 'edit' ),
1094+
'readonly' => true,
1095+
);
1096+
10861097
unset( $schema['properties']['password'] );
10871098

10881099
$this->schema = $schema;

0 commit comments

Comments
 (0)