^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_edit_post_link()用法示例

get_edit_post_link( int $id,  string $context = 'display' )

Retrieves the edit post link for post.


描述

Can be used within the WordPress loop or outside of it. Can be used with pages, posts, attachments, and revisions.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


参数

$id

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

$context

(string)
(Optional)
How to output the ‘&’ character. Default ‘&’.

Default value: ‘display’


返回值

(string|null) The edit post link for the given post. null if the post type is invalid or does not allow an editing UI.


源代码

File: wp-includes/link-template.php

function get_edit_post_link( $id = 0, $context = 'display' ) {
	if ( ! $post = get_post( $id ) )
		return;

	if ( 'revision' === $post->post_type )
		$action = '';
	elseif ( 'display' == $context )
		$action = '&action=edit';
	else
		$action = '&action=edit';

	$post_type_object = get_post_type_object( $post->post_type );
	if ( !$post_type_object )
		return;

	if ( !current_user_can( 'edit_post', $post->ID ) )
		return;

	if ( $post_type_object->_edit_link ) {
		$link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) );
	} else {
		$link = '';
	}

	/**
	 * Filters the post edit link.
	 *
	 * @since 2.3.0
	 *
	 * @param string $link    The edit link.
	 * @param int    $post_id Post ID.
	 * @param string $context The link context. If set to 'display' then ampersands
	 *                        are encoded.
	 */
	return apply_filters( 'get_edit_post_link', $link, $post->ID, $context );
}

更新日志

Version 描述
2.3.0 Introduced.

相关函数

Uses

  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/link-template.php:
    admin_url()
  • wp-includes/link-template.php:
    get_edit_post_link
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/post.php:
    get_post()
  • wp-includes/post.php:
    get_post_type_object()
  • Show 1 more use


Used By

  • wp-admin/includes/class-wp-posts-list-table.php:
    WP_Posts_List_Table::handle_row_actions()
  • wp-admin/includes/class-wp-posts-list-table.php:
    WP_Posts_List_Table::column_title()
  • wp-admin/includes/class-wp-media-list-table.php:
    WP_Media_List_Table::column_parent()
  • wp-admin/includes/class-wp-media-list-table.php:
    WP_Media_List_Table::column_title()
  • wp-admin/includes/class-wp-press-this.php:
    WP_Press_This::save_post()
  • wp-admin/includes/dashboard.php:
    wp_welcome_panel()
  • wp-admin/includes/dashboard.php:
    wp_dashboard_recent_posts()
  • wp-admin/includes/dashboard.php:
    wp_dashboard_recent_drafts()
  • wp-admin/includes/post.php:
    _admin_notice_post_locked()
  • wp-admin/includes/meta-boxes.php:
    post_submit_meta_box()
  • wp-admin/includes/class-wp-media-list-table.php:
    WP_Media_List_Table::_get_row_actions()
  • wp-admin/includes/class-wp-comments-list-table.php:
    WP_Comments_List_Table::column_response()
  • wp-admin/includes/post.php:
    redirect_post()
  • wp-includes/link-template.php:
    edit_post_link()
  • wp-includes/admin-bar.php:
    wp_admin_bar_edit_menu()
  • wp-includes/post-template.php:
    wp_post_revision_title()
  • wp-includes/post-template.php:
    wp_post_revision_title_expanded()
  • wp-includes/media.php:
    wp_prepare_attachment_for_js()
  • Show 13 more used by
    Hide more used by


让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈