-1
A
回答
1
以下代码a)显示'POST'表单提交按钮后的输入字段,该按钮提供显示首字母而不是全名的选项,b)在数据库中添加commentmeta字段以显示信息,以及c)检索元并显示全名或首字母缩写。
/* Add an input field for posting comment form with the switch to show initials instead of full name */
function add_comment_stealth_input_formfield(){
echo '<input type="checkbox" name="stealth_comment" id="stealth_comment" value="0">';
echo __("I want only my initials to be displayed instead of my name","comments");
}
add_action('comment_form', 'add_comment_stealth_input_formfield');
/* Hide comment author name */
if(!function_exists("disable_comment_author_links")){
function abbreviate_authorname_in_comments($author_link){
$sw_initials = get_comment_meta(get_comment_ID(), 'sw_comment_initials',true);
if ($sw_initials == 1){
// remove any html tags
$fullname = strip_tags($author_link);
// explode with ' '
$separate = explode(" ", $fullname);
// make initials
$shrt = "";
foreach ($separate as $w){
$shrt .= strtoupper($w[0].".");
}
// if more than 3 initials then something is wrong. Hide the last ones to be safe
if (strlen($shrt) > 6)
$shrt = substr($shrt, 0, 6);
return $shrt;
} else {
return $author_link;
}
}
add_filter('get_comment_author_link', 'abbreviate_authorname_in_comments');
}
/* add a comment meta per comment */
function add_comment_field_initials_sw($comment_id) {
$isChecked = is_null($_REQUEST['stealth_comment']) ? 0:1;
add_comment_meta($comment_id, 'sw_comment_initials', $isChecked);
}
add_action('comment_post', 'add_comment_field_initials_sw');
相关问题
- 1. 在html中显示名字首字母
- 2. 仅在WordPress中显示评论
- 3. WordPress 4个字母的评论错误
- 4. 在wordpress中如何在评论中显示USER ROLE
- 5. 如何让wordpress仅在评论和评论表单的首页显示一篇文章?
- 6. 在WordPress主页上显示评论
- 7. 评论不显示在wordpress 3.1
- 8. 在插件之前显示wordpress评论?
- 9. Java字符串首字母缩写
- 10. 专有名词检测首字母缩写词缩略语
- 11. 如何在WordPress管理面板中突出显示评论?
- 12. 如何在页面顶部/首页显示新评论
- 13. WordPress的评论显示修改
- 14. WordPress的评论没有显示
- 15. WordPress的 - 显示帖子,我评论
- 16. 如何在评论中显示用户
- 17. 如何在Django Admin中显示评论?
- 18. 如何将句首字母的首字母大写?
- 19. 用户输入首字母缩写 - ImpactJS
- 20. 在UITableView中显示评论
- 21. 成员变量的首字母缩写命名约定
- 22. 如何使UITextField的文本在iPhone中显示为首字母大写
- 23. C#:首字母大写的方法名?
- 24. 如何获得列名首字母大写的Oracle SQL Developer中
- 25. 如何在C中缩写全名?
- 26. 显示一个人姓名首字母大写从他们输入的名称
- 27. 如何自动检测首字母缩写词的含义/扩展名
- 28. 如何写评论
- 29. WordPress - 如何显示来自条目的评论总数?
- 30. 如何显示小写字母和大写字母