[wp-trac] [WordPress Trac] #57897: REST attachments controller does not handle terms on creation
WordPress Trac
noreply at wordpress.org
Thu Mar 9 16:50:49 UTC 2023
#57897: REST attachments controller does not handle terms on creation
-------------------------+-----------------------------
Reporter: swissspidy | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords: needs-patch
Focuses: rest-api |
-------------------------+-----------------------------
`\WP_REST_Attachments_Controller::create_item()` does not call
`parent::create_item()`, thus it also doesn't call
`\WP_REST_Posts_Controller::handle_terms()`. That means it's impossible to
assign terms to the freshly uploaded attachment.
`rest_after_insert_attachment` can be used to work around this, but I
think it would make sense to have this built-in.
Requires only a few lines of code:
{{{#!php
$terms_update = $this->handle_terms( $post_id, $request );
if ( is_wp_error( $terms_update ) ) {
return $terms_update;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57897>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list