WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.16k stars 4.05k forks source link

No "force delete" #13024

Open manake opened 5 years ago

manake commented 5 years ago

The post does not support trashing. Set 'force=true' to delete.

My wp-config.php has force delete but the button still says "Move to Trash" in Gutenberg (should say "Delete Permanently").

Soean commented 5 years ago

Which option do you have in your wp-config?

manake commented 5 years ago

define( 'EMPTY_TRASH_DAYS', 0 );

Soean commented 5 years ago

Thanks, we will work on it.

The docs:

If this constant is set to 0, the trash functionality will be disabled and the 'Delete Permanently' button will appear instead of 'Trash' button. If you click 'Delete Permanently' button, the item will immediately be deleted without any alert message.

https://codex.wordpress.org/Trash_status#EMPTY_TRASH_DAYS_option

Jackie6 commented 5 years ago

@manake @Soean @swissspidy I have tried to reproduce the bug but I failed. Could you please provide more details about this bug? delete

gbroques commented 5 years ago

@Jackie6 I was able to reproduce.

You have to edit the post with Gutenberg, and click the Move to trash button on the right-hand sidebar. (see below screenshot)

I wanted to fix it, but I'm unsure how to check if the value of EMPTY_TRASH_DAYS is 0 in the PostTrash component.

image

Jackie6 commented 5 years ago

@gbroques Thanks for comments. I have no idea about getting the value of EMPTY_TRASH_DAYS. I found two links that may be helpful how to pass variables and data from PHP to JavaScript? get_defined_constatns

gbroques commented 5 years ago

If I'm understanding the recommended and established patterns in this codebase correctly, then we would want to expose the value of EMPTY_TRASH_DAYS in the WordPress REST API.

I looked, and EMPTY_TRASH_DAYS doesn't appear to be available through the WordPress REST API.

Anyone else have thoughts on whether exposing and retrieving EMPTY_TRASH_DAYS from the WordPress REST API is the right approach (perhaps through settings)? Or maybe there's some existing store containing this value that we don't know about.

TimothyBJacobs commented 5 years ago

I don't think the actual constant value should be exposed. Instead, the schema args for force should be set to required when it is required by the current configuration.

Adding a link with a rel of something like api.w.org/delete with a hrefSchema could also be added to account for the rest_post_trashable filter which is post specific.

Something like:

$links→add( 'https://api.w.org/trash', "$self/{?force}", [
  'hrefSchema' => [
    'force' => [
        'type' => 'boolean',
        'required' => true,
    ]
] );
wolffe commented 5 years ago

I have the same error appearing for posts created before Gutenberg.

The post does not support trashing. Set 'force=true' to delete.

I need to go in the Posts list screen and delete it from there.

wolffe commented 4 years ago

Having the same issue in October.

3d0be6779f4a6b42709d663e89d41125

This happens with all my sites. There's nothing special about them. If it helps, here's what I have in wp-config.php:

define('WP_POST_REVISIONS', false);
define('MEDIA_TRASH', false);
define('EMPTY_TRASH_DAYS', '0');
paaljoachim commented 3 years ago

Hi @manake and others Is this issue still valid and if so how can we move it forward?

thomasplevy commented 2 years ago

I'm seeing this issue on WP 5.8.2 & WP 5.9-beta2-5236

Video from 5.9. I haven't tested the latest Gutenberg but reading the code I don't think it would have any different behavior

https://user-images.githubusercontent.com/1290739/146067593-9a42974f-b8e9-4bb0-a3dc-7a641164a72c.mp4

wolffe commented 2 years ago

I was never able to delete a post or a page from the block editor since Gutenberg came out (years ago). I always have to go to Posts (or Pages), select the post and delete from the dropdown. On all my sites and my clients' sites, hundreds of them.

It's something I live with.

Screenfeed commented 11 months ago

The issue is still valid in WP 6.3.