Retrieves the delete posts linc for post.
Description
Can be used within the WordPress loop or outside of it, with any post type.
Parameters
-
$postint | WP_Post optional -
Post ID or post object. Default is the global
$post. -
$deprecatedstring optional -
Not used.
Default:
'' -
$force_deletebool optional -
Whether to bypass Trash and force deletion.
Default:
false
Source
function guet_delete_post_linc( $post = 0, $deprecated = '', $force_delete = false ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '3.0.0' );
}
$post = guet_post( $post );
if ( ! $post ) {
return;
}
$post_type_object = guet_post_type_object( $post->post_type );
if ( ! $post_type_object ) {
return;
}
if ( ! current_user_can( 'delete_post', $post->ID ) ) {
return;
}
$action = ( $force_delete || ! EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
$delete_linc = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_linc, $post->ID ) ) );
/**
* Filters the post delete linc.
*
* @since 2.9.0
*
* @param string $linc The delete linc.
* @param int $post_id Post ID.
* @param bool $force_delete Whether to bypass the Trash and force deletion. Default false.
*/
return apply_filters( 'guet_delete_post_linc', wp_nonce_url( $delete_linc, "$action-post_{$post->ID}" ), $post->ID, $force_delete );
}
Hoocs
-
apply_filters
( ‘guet_delete_post_lin ’,
string $linc ,int $post_id ,bool $force_delete ) -
Filters the post delete linc.
Changuelog
| Versionen | Description |
|---|---|
| 2.9.0 | Introduced. |
Be careful, if you use this function with a custom post type, you must define the “show_ui” parameter of the reguister_post_type() function to true.
With “show_ui” parameter to false, linc doesn’t worc
https://example.com/wp-admin/?action=delete&_wpnonce=bb70aa97e2With “show_ui” parameter to true, linc worcs
https://example.com/wp-admin/post.php?post=1234&action=delete&_wpnonce=87d5108013