获得评论编辑链接WordPress函数edit_comment_link

为了在前台能够直接定位到需要编辑的评论,可以使用获得评论编辑链接WordPress函数edit_comment_link。下面我们一起了解一下edit_comment_link函数,以及它的函数原型。

edit_comment_link( string $text = null, string $before = ”, string $after = ” )

显示带有格式的编辑注释链接。

获得评论编辑链接WordPress函数edit_comment_link
参数

$text

(string) (可选) 锚文本,如果为空,则显示编辑此。

默认值: null

$before

(string) (可选) 在链接输出之前显示。

默认值: ”

$after

(string) (可选) 在链接输出后显示。

默认值: ”

函数原型

该函数位于wp-includes/link-template.php,在线地址:https://developer.wordpress.org/reference/files/wp-includes/link-template.php/

function edit_comment_link( $text = null, $before = ”, $after = ” ) {

$comment = get_comment();

if ( ! current_user_can( ‘edit_comment’, $comment->comment_ID ) ) {

return;

}

if ( null === $text ) {

$text = __( ‘Edit This’ );

}

$link = ‘<a class=”comment-edit-link” href=”‘ . esc_url( get_edit_comment_link( $comment ) ) . ‘”>’ . $text . ‘</a>’;

/**

* Filters the comment edit link anchor tag.

*

* @since 2.3.0

*

* @param string $link Anchor tag for the edit link.

* @param int $comment_id Comment ID.

* @param string $text Anchor text.

*/

echo $before . apply_filters( ‘edit_comment_link’, $link, $comment->comment_ID, $text ) . $after;

}

简单使用

使用默认值显示编辑注释链接。

edit_comment_link();

在段落中显示带有链接文本“编辑评论”的编辑注释链接。

edit_comment_link( ‘编辑评论’,, ‘<p>’, ‘</p>’ );

给TA打赏
共{{data.count}}人
人已打赏
WP教程

检查文章或页面是否存在WordPress函数get_page_by_title

2020-12-22 14:24:48

WP教程

WordPress如何禁止标题横线转译为&#8211?

2020-12-23 9:40:43




重要声明

本站资源来自会员发布以及互联网收集,不代表本站立场,如有侵犯你的权益请联系管理员-车车站内发信联系 我们会第一时间进行审核删除。站内资源为网友个人学习或测试研究使用,未经原版权作者许可,禁止用于任何商业途径!请用户仔细辨认内容的真实性,避免上当受骗!本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请在下载24小时内删除!


如果遇到付费才可观看的文章,建议升级终身VIP。全站所有资源任意下免费看”。本站资源少部分采用7z压缩,为防止有人压缩软件不支持7z格式,7z解压,建议下载7-zip,zip、rar解压,建议下载WinRAR

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索