[WordPress] 外掛分享: Safe Report Comments

首頁外掛目錄 › Safe Report Comments
200+
安裝啟用
★★★☆☆
3/5 分(7 則評價)
2665 天前
最後更新
問題解決
WordPress 3.3+ v0.4.1 上架:2010-05-13

內容簡介

這個外掛讓您的訪客有機會檢舉不當留言。當檢舉數量達到門檻值時,留言將進入審核階段,審核員會決定是否核准該留言。如果留言被審核員核准,則該留言不再自動進入審核階段,但仍會計算檢舉次數。

自訂化

預設情況下,此腳本會在多數現有佈景主題中正確連結,因為它使用「comment_reply_link」過濾器連結。
如果無法連結,您可以在主題的functions.php檔案中定義no_autostart_safe_report_comments,並通過$safe_report_comments = new Safe_Report_Comments(false);來初始化類別來手動放置旗幟連結。

以下是透過functions.php和放置回調函數來自訂設置的示例。

在functions.php中:

//flag comments plugin included in themes' functions.php - disable plugin.
define( 'no_autostart_safe_report_comments', true );
include_once( 'replace-with-path-to/safe-report-comments/safe-report-comments.php');
// make sure not to auto-attach to comment reply link
$safe_report_comments = new Safe_Report_Comments(false);

// change link layout to have a pipe prepended
add_filter( 'safe_report_comments_flagging_link', 'adjust_flagging_link' );
function adjust_flagging_link( $link ) {
return ' | ' . $link;
}

// adjust the text to "Report abuse" rather than "Report comment"
add_filter( 'safe_report_comments_flagging_link_text', 'adjust_flagging_text' );
function adjust_flagging_text( $text ) {
return 'Report abuse';
}

在wp_list_comments使用的自訂留言回調函數中,放置以下操作以列印旗幟連結

<?php do_action( 'comment_report_abuse_link' ); ?>

可能的回調函數如下所示:

function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>

<?php comment_text() ?>

<div class="reply">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<div class="report-abuse">
<?php do_action( 'comment_report_abuse_link' ); ?>
</div>
</div>
<?php
}

此外,腳本中還有各種操作和過濾器,使易於更改。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.4.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Safe Report Comments」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin gives your visitors the possibility to report a comment as inappropriate. After a set threshold is reached the comment is put into moderation where the moderator can decide whether or not he want to approve the comment or not. If a comment is approved by a moderator it will not be auto-moderated again while still counting the amount of reports.
Customizations
By default this script should hook in just fine in most existing themes as it attaches itsself after the comment-reply link via the comment_reply_link filter.
In case this does not work out you can place the flagging link manually by defining no_autostart_safe_report_comments in your themes’ functions.php file and initializing the class via $safe_report_comments = new Safe_Report_Comments(false);.
Here is an example of a custom setup via functions.php and placing the link comments callback function.
In functions.php:
//flag comments plugin included in themes' functions.php - disable plugin.
define( 'no_autostart_safe_report_comments', true );
include_once( 'replace-with-path-to/safe-report-comments/safe-report-comments.php');
// make sure not to auto-attach to comment reply link
$safe_report_comments = new Safe_Report_Comments(false);

// change link layout to have a pipe prepended
add_filter( 'safe_report_comments_flagging_link', 'adjust_flagging_link' );
function adjust_flagging_link( $link ) {
return ' | ' . $link;
}

// adjust the text to "Report abuse" rather than "Report comment"
add_filter( 'safe_report_comments_flagging_link_text', 'adjust_flagging_text' );
function adjust_flagging_text( $text ) {
return 'Report abuse';
}

In your custom comment callback function used by wp_list_comments: https://codex.wordpress.org/Template_Tags/wp_list_comments place the following action which will print the link.

A possible callback function could look like this:
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>

  • id="li-comment-">

    ' ); ?>
    %s says:'), get_comment_author_link()) ?>

    comment_approved == '0') : ?>


    $depth, 'max_depth' => $args['max_depth']))) ?>

    延伸相關外掛

  • 文章
    Filter
    Mastodon