Skip to content

Latest commit

 

History

History
27 lines (16 loc) · 1.93 KB

readme.md

File metadata and controls

27 lines (16 loc) · 1.93 KB

Unpublish Media Endpoint

PHP CodeSniffer Unit tests SonarCloud Coverage

Quality Gate Status Coverage

This plugin will enable media endpoint in case of the post it was uploaded from ( set as post parent ) is no longer in publish status, to fix issue of not able to use it in another post REST endpoint as featured image.

Core ticket ref: https://core.trac.wordpress.org/ticket/41445

If media is uploaded for a post, then used as a featured image on another post, and the original parent is not accessible via the REST API (e.g. because it's in the trash, not published etc), then it cannot be embedded on the post that is accessible.

To reproduce issue:

  1. Create a new post with a featured image.
  2. Move the post to trash.
  3. Create another post and use the image uploaded from the post moved to trash and attache it as featured image.
  4. Check the response of this second post REST API with media embed enabled. ( i.e https://localhost/wp-json/wp/v2/posts/somePostID?_embed )
  5. You will notice rest_forbidden error as per below screenshot.

Before

Enable this plugin and notice the response for step 4, you'll see expected media endpoint output:

After