get_delete_post_link

Definition:
function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {}

Retrieve delete posts link for post.
Can be used within the WordPress loop or outside of it, with any post type.

Parameters

  • int $id: Optional. Post ID.
  • string $deprecated: Not used.
  • bool $force_delete: Whether to bypass trash and force deletion. Default is false.

Defined filters

  • get_delete_post_link
    apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-{$post->post_type}_{$post->ID}" )

Source code

function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {

	if ( ! empty( $deprecated ) )

		_deprecated_argument( __FUNCTION__, '3.0' );



	if ( !$post = &get_post( $id ) )

		return;



	$post_type_object = get_post_type_object( $post->post_type );

	if ( !$post_type_object )

		return;



	if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) )

		return;



	$action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';



	$delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );



	return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-{$post->post_type}_{$post->ID}" ), $post->ID, $force_delete );

1364

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: