imath / wp-statuses

WordPress plugin to ease Custom Post Statuses integration
GNU General Public License v2.0
160 stars 27 forks source link

Ensure the REST API status hijack is only applied in the admin #60

Closed BronsonQuick closed 2 years ago

BronsonQuick commented 2 years ago

Hey @imath,

Thanks so much for making and maintaining this plugin and for all your open source work! 🙏🏻 I'm currently using this plugin for the first time on a client site and I noticed a little bug. When I create posts with the REST API for my client I could see that the post status was always being returned as status": "private" when I received the 201 response from the REST API. e.g.

Postman_2022-04-14_11-05-13

After some digging I found where you are setting this so that you get the "Update" button to show in Gutenberg. Ideally I think it's better to wrap this in a check to see if we're in the admin area that way the 201 responses from WordPress via external calls to the REST API will return the correct status when a post is created. e.g.

Postman_2022-04-14_11-09-53

I should also note that I did check to make sure this maintains backwards compatibility in the block editor and it does 😁

Hopefully in the future we might be able to be able to extend the PostPublishButton component to get the Publish button working for this plugin as well!

imath commented 2 years ago

Hi @BronsonQuick

You're very welcome 😍. Many thanks to you for catching this. I totally agree with your PR, let's have it in 👍