get_delete_post_link() - WordPress 函数参考中文文档

返回介绍

get_delete_post_link()

发布于 2017-09-10 字数3127 浏览 726 评论 0

get_delete_post_link( int $id,  string $deprecated = '',  bool $force_delete = false )

Retrieves the delete posts link for post.


描述

Can be used within the WordPress loop or outside of it, with any post type.


参数

$id

(int)
(Optional)
Post ID. Default is the ID of the global $post.

$deprecated

(string)
(Optional)
Not used.

Default value: ”

$force_delete

(bool)
(Optional)
Whether to bypass trash and force deletion.

Default value: false


返回值

(string|void) The delete post link URL for the given post.


源代码

File: wp-includes/link-template.php

function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
	if ( ! empty( $deprecated ) )
		_deprecated_argument( __FUNCTION__, '3.0.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 ) ) );

	/**
	 * Filters 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 );
}

更新日志

Version 描述
2.9.0 Introduced.

相关函数

Uses

  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/functions.php:
    _deprecated_argument()
  • wp-includes/functions.php:
    wp_nonce_url()
  • wp-includes/functions.php:
    add_query_arg()
  • wp-includes/link-template.php:
    admin_url()
  • wp-includes/link-template.php:
    get_delete_post_link
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/post.php:
    get_post()
  • wp-includes/post.php:
    get_post_type_object()
  • Show 4 more uses
    Hide more uses


Used By

  • wp-admin/includes/class-wp-posts-list-table.php:
    WP_Posts_List_Table::handle_row_actions()
  • wp-admin/includes/meta-boxes.php:
    post_submit_meta_box()
  • wp-admin/includes/meta-boxes.php:
    attachment_submit_meta_box()

User Contributed Notes

上一篇:get_default_post_to_edit()

下一篇:get_dirsize()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!