Plugin / Safe Report Comments

Thorsten Ott, Daniel Bachhuber, Automattic

Description

Description

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.

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

A possible callback function could look like this:

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
}

Furthermore there are various actions and filters within the script to allow easy alteration of implemented behavior. Please see inline documentation.

Known issues

Automatic mode implementation currently does not work with threaded comments in the last level of threading. As the script attaches itself to the comment_reply which is not displayed once the maximum threading level is reached the abuse link is missing at this point. As a workaround set the threading level higher than the likely amount of threading depth.

Ratings

3
7 reviews

Rating breakdown

Details Information

Version

0.4.1

First Released

31 Jan, 2014

Total Downloads

12,742

Wordpress Version

3.3 or higher

Tested up to:

5.0.7

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.