-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. 如何在testdox名稱中使用大寫字母的首字母縮寫?
- 2. 在html中顯示名字首字母
- 3. 如何在顯示Wordpress評論數的計數中顯示Facebook評論?
- 4. 如何在MySQL中獲取姓名首字母縮寫?
- 5. CKeditor中首字母大寫首字母縮寫
- 6. Python:使用首字母縮寫命名
- 7. 在cakephp中找到首字母縮寫
- 8. 僅在WordPress中顯示評論
- 9. WordPress 4個字母的評論錯誤
- 10. 在wordpress中如何在評論中顯示USER ROLE
- 11. 如何讓wordpress僅在評論和評論表單的首頁顯示一篇文章?
- 12. 如何顯示撰寫評論的用戶名(Rails)
- 13. 評論不顯示在wordpress 3.1
- 14. 在插件之前顯示wordpress評論?
- 15. 在WordPress主頁上顯示評論
- 16. Java字符串首字母縮寫
- 17. 紅寶石中的短命名空間首字母縮寫詞
- 18. 專有名詞檢測首字母縮寫詞縮略語
- 19. C#Create Word的首字母縮寫
- 20. 如何在WordPress管理面板中突出顯示評論?
- 21. 如何在Wordpress評論中顯示「自定義暱稱」?
- 22. 添加評論後,在php網站的評論框中顯示字母。如何限制每行顯示的字母?
- 23. 如何在頁面頂部/首頁顯示新評論
- 24. 我如何限制在評論框中顯示評論
- 25. WordPress的 - 顯示帖子,我評論
- 26. WordPress的評論顯示修改
- 27. WordPress的只顯示評論數
- 28. WordPress的評論沒有顯示
- 29. 如何在Django Admin中顯示評論?
- 30. 如何在評論中顯示用戶