Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST attachments controller: Fix issue where terms cannot be assigned… #4209

Conversation

tanjimTC
Copy link

@tanjimTC tanjimTC commented Mar 10, 2023

This PR fixes an issue where terms could not be assigned to newly uploaded attachments through the REST API, due to the \WP_REST_Attachments_Controller::create_item() function not calling parent::create_item() and thus not calling \WP_REST_Posts_Controller::handle_terms(). This PR adds the necessary lines of code to call handle_terms() in create_item(), allowing terms to be assigned to attachments through the REST API. The changes have been tested and work as expected.

Trac ticket: https://core.trac.wordpress.org/ticket/57897

@TimothyBJacobs
Copy link
Member

Thanks for the patch @tanjimTC! This change looks good, could you add unit tests demonstrating that we can create an attachment with terms?

@spacedmonkey
Copy link
Member

Let's add a unit test.

@@ -188,6 +188,13 @@ public function create_item( $request ) {

$request->set_param( 'context', 'edit' );

// Assign terms to the freshly uploaded attachment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@swissspidy swissspidy closed this Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants