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

为了在前台能够直接定位到需要编辑的评论,可以使用WordPress函数edit_comment_link来取得某条评论的编辑链接。下面一起来学习下edit_comment_link函数,以及它的函数原型,看看是如何实现的。

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

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

参数

$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>’ );

常见问题
Wordpress模板插件上传安装提示错误怎么办?
本站在打包插件或者模板的时候,一般会将官方文档、官方申明、已经其他文件一起打包,因此,大部分插件模板在安装前需要解压缩。
购买后无法下载或者提取码错误怎么办?
请联系客服QQ:125252828 或者微信:dobunkan,由于骚扰信息过多,加好友时请说明原由!
小白建站啥都不会怎么办?
请与客服联系,沟通具体的技术支持。由于搭建环境、调试程序需要花费一些时间,可能会收取一些费用。
怎样催促站长更新?
直接微信或者QQ联系本站客服,提供最新版本号以及软件名称,客服会在第一时间更新,如果超过2-3年未更新的请先联系站长后再确认是否需要下载。
为什么打开链接看不到最新版本?
因为网盘默认是按名称排序,最新版本不一定会排在第一个,请打开链接后点击右上角的“修改日期”,这时候更新列表就会按更新日期排序了。
原文链接:https://www.dobunkan.com/tools/26518,转载请注明出处。
0

评论0

请先
显示验证码
没有账号?注册  忘记密码?

社交账号快速登录

学课技术网欢迎您的加入!