Plugin Directory

Changeset 815233


Ignore:
Timestamp:
12/05/2013 04:25:44 AM (12 years ago)
Author:
titopandub
Message:

Add force option for certain author

Location:
advanced-comments-moderation/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • advanced-comments-moderation/trunk/advanced-comments-moderation.php

    r807903 r815233  
    44Plugin URI: http://www.leavingworkbehind.com
    55Description: Advanced Comments Moderation makes managing your WordPress blog's comments far easier.
    6 Version: 1.2
     6Version: 1.3
    77Author: Tom Ewer and Tito Pandu
    88Author URI: http://www.leavingworkbehind.com
     
    9090        add_action( 'admin_enqueue_scripts', array( $this, 'admin_stylesheets' ) );
    9191
    92        
    93        
    94             if ( isset( $_GET['advanced_comments_moderation'] ) ) {
    95 
    96                 $this->comments_dismissed = implode( ',', $this->comments_dismissed() );
    97                 $this->comments_has_replied = implode( ',', $this->comments_has_replied() );
    98                 $this->comments_from_author = implode( ',', $this->comments_from_author() );
    99 
    100                 if ( $this->options['have_replied'] ) {
    101                     add_filter(
    102                         'comments_clauses',
    103                         array( $this, 'get_comments_missing_replies_and_not_dismissed' ), 10, 2
    104                     );
    105                    
    106                     add_filter(
    107                         'comment_row_actions',
    108                         array( $this, 'add_dismiss_to_comment_row' ), 10, 2
    109                     );
    110                 }
    111 
    112                 if ( $this->options['authors_comments'] ) {
    113                     add_filter(
    114                         'comments_clauses',
    115                         array( $this, 'get_comment_list_except_by_author' ), 10, 2
    116                     );
    117                 }
    118 
    119                 if ( $this->options['show_pingbacks'] ) {
    120                     add_filter(
    121                         'comments_clauses', array( $this, 'except_pingback_and_trackback' ), 10, 2
    122                     );
    123                 }
    124 
    125                 // add_action( 'pre_get_comments', array( $this, 'return_not_replied_list' ) );
     92        if ( isset( $_GET['advanced_comments_moderation'] ) ) {
     93
     94            $this->comments_dismissed = implode( ',', $this->comments_dismissed() );
     95            $this->comments_has_replied = implode( ',', $this->comments_has_replied() );
     96            $this->comments_from_author = implode( ',', $this->comments_from_author() );
     97
     98            if ( $this->options['have_replied'] ) {
     99                add_filter(
     100                    'comments_clauses',
     101                    array( $this, 'get_comments_missing_replies_and_not_dismissed' ), 10, 2
     102                );
     103               
     104                add_filter(
     105                    'comment_row_actions',
     106                    array( $this, 'add_dismiss_to_comment_row' ), 10, 2
     107                );
    126108            }
    127109
    128             add_filter( 'comment_status_links', array( $this, 'get_list_dismissed_comments' ) );
    129             add_filter( 'comment_status_links', array( $this, 'get_list_comments_has_not_replied' ) );
     110            if ( $this->options['authors_comments'] ) {
     111                add_filter(
     112                    'comments_clauses',
     113                    array( $this, 'get_comment_list_except_by_author' ), 10, 2
     114                );
     115            }
     116
     117            if ( $this->options['show_pingbacks'] ) {
     118                add_filter(
     119                    'comments_clauses', array( $this, 'except_pingback_and_trackback' ), 10, 2
     120                );
     121            }
     122
     123            // add_action( 'pre_get_comments', array( $this, 'return_not_replied_list' ) );
     124        }
     125
     126        add_filter( 'comment_status_links', array( $this, 'get_list_dismissed_comments' ) );
     127        add_filter( 'comment_status_links', array( $this, 'get_list_comments_has_not_replied' ) );
    130128
    131129        if ( isset( $_GET['dismissed_comment'] ) ) {
     
    228226            return;
    229227
    230         if ( $comm_email == $this->get_post_author_email( $comm_post_id ) ) {
     228        if (
     229            $this->comment_is_by_post_author( $comment_id )
     230        ) {
    231231            update_comment_meta( $comm_parent, '_acm_has_replied', 1 );
    232232        }
     
    252252            return;
    253253
    254         if ( $comm_email == $this->get_post_author_email( $comm_post_id ) ) {
     254        if (
     255            $this->comment_is_by_post_author( $comment_id )
     256        ) {
    255257            update_comment_meta( $comm_parent, '_acm_has_replied', 0 );
    256258        }
     
    272274        $comm_post_auth = $comm_post_obj->post_author;
    273275
    274         if ( $comm_email == $this->get_post_author_email( $comm_post_id ) ) {
     276        if (
     277            $this->comment_is_by_post_author( $comment_id )
     278        ) {
    275279            update_comment_meta( $comm_post_id, '_acm_is_author', 1 );
    276280        } else {
     
    561565        $post    = get_post( $comment->comment_post_ID );
    562566
    563         return $comment->comment_author_email == $this->get_post_author_email( $post->ID );
     567        return $comment->comment_author_email == $this->get_post_author_email( $post->ID ) ||
     568                in_array( $comment->comment_author_email, $this->options['hide_authors'] );
    564569
    565570    } // end if
     
    930935        'Hide pingbacks',                       // The text used to label the field
    931936        'acm_pingbacks_display',                // The callback function used to render the field
     937        'discussion',                           // The page on which we'll be rendering this field
     938        'acm_section'                           // The section to which we're adding the setting
     939    );
     940
     941    add_settings_field(
     942        'acm_hide_authors',                     // The ID (or the name) of the field
     943        'Hide specified authors',               // The text used to label the field
     944        'acm_hide_authors_display',             // The callback function used to render the field
    932945        'discussion',                           // The page on which we'll be rendering this field
    933946        'acm_section'                           // The section to which we're adding the setting
     
    9921005    <?php
    9931006} // end acm_pingbacks_display
     1007
     1008function acm_hide_authors_display() {
     1009    // Read the options for the hide_authors section
     1010    $options = (array)get_option( 'acm_options' );
     1011    $hide_authors = $options['hide_authors'];
     1012    $authors = new WP_User_Query( array( 'who' => 'authors' ) );
     1013
     1014    if ( ! empty( $authors ) ) { ?>
     1015        <ul class="author-list" style="padding: 0; margin-top: 0;">
     1016    <?php
     1017        // echo var_dump($hide_authors);
     1018        foreach ($authors->results as $author) {
     1019            $is_checked = '';
     1020            if ( in_array( $author->user_email, $hide_authors ) ) {
     1021                $is_checked = 'checked="checked"';
     1022            }
     1023        ?>
     1024            <li>
     1025                <label for="acm_options[hide_authors][<?php echo $author->user_email ?>]">
     1026                    <input type="checkbox" name="acm_options[hide_authors][]" id="acm_options[hide_authors][<?php echo $author->user_email ?>]" value="<?php echo $author->user_email; ?>" <?php echo $is_checked; ?> />
     1027                    <?php echo $author->user_login . " (" . $author->user_nicename . ")"; ?>
     1028                </label>
     1029            </li>
     1030        <?php
     1031        }
     1032    ?>
     1033        </ul>
     1034    <?php
     1035    }
     1036} // end acm_hide_authors_display
    9941037 
    9951038class ACM_Custom_Bulk_Action {
  • advanced-comments-moderation/trunk/readme.txt

    r807903 r815233  
    66Requires at least: 3.5
    77Tested up to: 3.7.1
    8 Stable tag: 1.2
     8Stable tag: 1.3
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5252== Upgrade Notice ==
    5353
     54= 1.3 =
     55* Add force option for certain author.
     56
    5457= 1.2 =
    5558* Fix problem for different table prefix.
     
    6467== Changelog ==
    6568
     69= 1.3=
     70* Add force option for certain author.
     71
    6672= 1.2 =
    6773* Fix problem for different table prefix.
Note: See TracChangeset for help on using the changeset viewer.