get_delete_post_link()
get_delete_post_link( int|WP_Post $id, string $deprecat…
get_delete_post_link( int|WP_Post $id, string $deprecated = ”, bool $force_delete = false )
检索post的delete posts链接。
Retrieves the delete posts link for post.
目录锚点:#说明#参数#返回#源码
说明(Description)
可以在WordPress循环内使用,也可以在循环外使用,可以使用任何post类型。
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$id | (int | WP_Post) | 可选 | Post ID或Post对象。默认值为全局$post。 |
$deprecated | (string) | 可选 | 不使用。 |
$force_delete | (bool) | 可选 | 是否绕过垃圾箱并强制删除。 |
返回(Return)
(string|void)指定文章的删除文章链接URL。
源码(Source)
/** * Retrieve delete posts link for post. * * Can be used within the WordPress loop or outside of it, with any post type. * * @since 2.9.0 * * @param int $id Optional. Post ID. * @param string $deprecated Not used. * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. * @return string|void The delete post link URL for the given post. */ 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( '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 ) ) ); /** * Filter the post delete link. * * @since 2.9.0 * * @param string $link The delete link. * @param int $post_id Post ID. * @param bool $force_delete Whether to bypass the trash and force deletion. Default false. */ return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.9.0 | wp-includes/link-template.php:1454 | 3 | 9 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!