WordPress.org

Plugin Directory

Changeset 571062


Ignore:
Timestamp:
07/12/12 04:55:47 (21 months ago)
Author:
solarissmoke
Message:

Releasing version 0.3

Location:
comment-control/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • comment-control/trunk/comment-control.php

    r472364 r571062  
    44Plugin URI: http://rayofsolaris.net/code/comment-control-for-wordpress 
    55Description: Gives administrators some more flexible options for controlling comments - e.g., independently setting the default comment status for Posts and Pages 
    6 Version: 0.2 
     6Version: 0.3 
    77Author: Samir Shah 
    88Author URI: http://rayofsolaris.net/ 
     
    1414 
    1515class Comment_control { 
    16     const db_version = 2; 
     16    const db_version = 3; 
    1717    private $options; 
    1818     
     
    2222         
    2323        if( !isset( $this->options['db_version'] ) || $this->options['db_version'] < self::db_version ) { 
    24             $defaults = array( 'allow_comments_on' => array(), 'allow_pings_on' => array(), 'no_tb' => false, 'attachments_inherit' => false ); 
     24            $defaults = array( 'allow_comments_on' => array(), 'allow_pings_on' => array(), 'no_tb' => false, 'attachments_inherit' => false, 'attachments_nocomment' => false ); 
    2525             
    2626            foreach( $defaults as $k => $v ) 
     
    4444            add_filter( 'pings_open', array( $this, 'no_trackback' ) ); 
    4545             
    46         if( $this->options['attachments_inherit'] ) 
     46        if( $this->options['attachments_inherit'] || $this->options['attachments_nocomment'] ) 
    4747            add_filter( 'comments_open', array( $this, 'attachment_comment_status' ), 10, 2 ); 
    4848    } 
     
    7676    function attachment_comment_status( $status, $post_id ) { 
    7777        $post = get_post( $post_id ); 
    78         if( $post->post_type == 'attachment' && $post->post_parent ) 
    79             return comments_open( $post->post_parent ); 
     78        if( $post->post_type == 'attachment' ) { 
     79            if ( $this->options['attachments_nocomment'] ) 
     80                return false; 
     81            elseif( $this->options['attachments_inherit'] && $post->post_parent ) 
     82                return comments_open( $post->post_parent ); 
     83        } 
    8084        return $status; 
    8185    } 
     
    103107 
    104108            $this->options['no_tb'] = isset( $_POST['no_tb'] );  
    105             $this->options['attachments_inherit'] = isset( $_POST['attachments_inherit'] );  
     109            $this->options['attachments_inherit'] = isset( $_POST['attachments_inherit'] ); 
     110            $this->options['attachments_nocomment'] = isset( $_POST['attachments_nocomment'] ) && !isset( $_POST['attachments_inherit'] );  // can't check both 
    106111 
    107112            update_option( 'comment_control_options', $this->options ); 
     
    136141    <ul class="indent"> 
    137142        <li><label for="no_tb"><input type="checkbox" name="no_tb" id="no_tb" <?php checked( $this->options['no_tb'] );?>> Disable trackbacks</label></li> 
    138         <li><label for="attachments_inherit"><input type="checkbox" name="attachments_inherit" id="attachments_inherit" <?php checked( $this->options['attachments_inherit'] );?>> Force attachments to always inherit their comment status from their parent post.<br>(so if comments are closed on a post, then comments will also be closed on its attachments)</label></li> 
     143        <li><label for="attachments_inherit"><input type="checkbox" class="att_exclusive" name="attachments_inherit" id="attachments_inherit" <?php checked( $this->options['attachments_inherit'] );?>> Force attachments to always inherit their comment status from their parent post (if comments are closed on a post, then comments will be closed on its attachments).</label> 
     144        <br/><strong>or</strong><br/> 
     145        <label for="attachments_nocomment"><input type="checkbox" class="att_exclusive" name="attachments_nocomment" id="attachments_nocomment" <?php checked( $this->options['attachments_nocomment'] );?>> Keep comments closed on all attachments.</label> 
     146        </li> 
    139147    </ul> 
    140148    <p class="submit"><input class="button-primary" type="submit" name="submit" value="Update settings" /></p> 
     
    177185            }, "html"); 
    178186        }); 
     187        $(".att_exclusive").change( function(){ 
     188            if( $(this).is(":checked") ) { 
     189                $(".att_exclusive").attr("checked", false); 
     190                $(this).attr("checked", true); 
     191            } 
     192        }); 
    179193    }); 
    180194    </script> 
  • comment-control/trunk/readme.txt

    r472364 r571062  
    33Tags: comments, default, status, control 
    44Requires at least: 3.1 
    5 Tested up to: 3.3 
     5Tested up to: 3.4 
    66Stable tag: trunk 
    77 
     
    1818== Changelog == 
    1919 
     20= 0.3 = 
     21* Add the option to turn off comments on all attachments. 
     22 
    2023= 0.2 = 
    2124* Add the ability to force attachments to inherit their comment status from their parent post. I've no idea why WordPress doesn't do this by default. See http://core.trac.wordpress.org/ticket/8177 
Note: See TracChangeset for help on using the changeset viewer.