首页 > CMS建站 > Wordpress > 正文

AUTHOR_EMAIL FILTER自定义评论作者的EMAIL

2020-06-10 12:57:18
字体:
来源:转载
供稿:网友

wordpress4.1新增了一个钩子:author_email,可以利用这个filter显示自定义评论作者的email,形式如下:

apply_filters ( ‘author_email’, string $author_email, int $comment_ID )

在wp-includes/comment-template.php的comment_author_email函数中用到了author_email的filter.

  1. function comment_author_email( $comment_ID = 0 ) { 
  2.     $author_email = get_comment_author_email( $comment_ID ); 
  3.  
  4.     /** 
  5.      * Filter the comment author's email for display. 
  6.      * 
  7.      * @since 1.2.0 
  8.      * @since 4.1.0 The `$comment_ID` parameter was added. 
  9.      * //Cuoxin.com 
  10.      * @param string $author_email The comment author's email address. 
  11.      * @param int    $comment_ID   The comment ID. 
  12.      */ 
  13.     echo apply_filters( 'author_email'$author_email$comment_ID ); 
  14. }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选