imath / wp-statuses

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

title is Auto Draft #67

Closed shawfactor closed 11 months ago

shawfactor commented 2 years ago

I have tried to work out why but as soon as the library is in installed the title of any new post, page, cpt etc is Auto Draft this happens as soon as the the post, page, cpt etc is created. Do you have any idea why? if so can this be fixed? It is not big deal but rather confusing for users (I've tried looking in the code but there is nothing obvious).

imath commented 2 years ago

I never noticed this. I'll check!

bonny commented 1 year ago

Not much of help, but I started seeing this too after installing this plugin.

iniznet commented 1 year ago

This seems only to happen in the block editor especially built-in post types, the classic one is working fine since it doesn't use rest API on auto draft creation If I remember correctly.

By default, block editor gives us the "Auto Draft" title from the rest API when creating a new post but doesn't actually put it into the title field until we hit the save a draft or publish button (grayed when title or content field is empty).

However, in wp_statuses_rest_prepare_for_response function line 561 set the temporary post status to "private" which forces the publish into a clickable update button and that fill the title field on post creation, though also makes auto-save enabled if you wait for a while it will save the auto draft post.

(I may pointed wrong source) https://github.com/WordPress/gutenberg/blob/f5582817aa2c45ddc7d52dac50025fcfc2a438e3/packages/core-data/src/entities.js#L177-L205

https://github.com/imath/wp-statuses/blob/0f43173695f956dbd715b2fff8b2fe90300147d5/inc/core/functions.php#L559-L562

(Originally "auto-draft" before being replaced) image

shawfactor commented 1 year ago

Any new on this, yes it is block editor only, it is a bit beyond my understanding but it is an issue

imath commented 1 year ago

Unfortunately this is a downside of the lack of extensibility of the Block Editor, to be sure to get the update button, I need to use another field to save the status to use and force the WordPress status to be private. Otherwise you get the Publish button and you cannot customize the post status.

imath commented 11 months ago

I've been looking at it, I should be able to add a workaround to avoid the "Auto Draft" title when starting a new post. I'll add a PR to this issue asap.

shawfactor commented 11 months ago

Seems to work, many thanks for a great fix