WordPress.org

Plugin Directory

Changeset 589654


Ignore:
Timestamp:
08/24/12 06:22:36 (20 months ago)
Author:
solarissmoke
Message:

Releasing version 0.6

Location:
disable-comments/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • disable-comments/trunk/disable-comments.php

    r589170 r589654  
    44Plugin URI: http://wordpress.org/extend/plugins/disable-comments/ 
    55Description: Allows administrators to globally disable comments on their site. Comments can be disabled according to post type. 
    6 Version: 0.5 
     6Version: 0.6 
    77Author: Samir Shah 
    88Author URI: http://rayofsolaris.net/ 
     
    1414 
    1515class Disable_Comments { 
    16     const db_version = 3; 
     16    const db_version = 4; 
    1717    private $options; 
    1818    private $modified_types = array(); 
     
    3030            } 
    3131 
    32             foreach( array( 'remove_admin_menu_comments', 'remove_admin_bar_comments', 'remove_recent_comments', 'remove_discussion', 'remove_rc_widget' ) as $v ) 
     32            foreach( array( 'remove_admin_menu_comments', 'remove_admin_bar_comments', 'remove_recent_comments', 'remove_discussion', 'remove_rc_widget', 'permanent' ) as $v ) 
    3333                if( !isset( $this->options[$v] ) ) 
    3434                    $this->options[$v] = false; 
     
    155155        if ( isset( $_POST['submit'] ) ) { 
    156156            $disabled_post_types =  empty( $_POST['disabled_types'] ) ? array() : (array) $_POST['disabled_types']; 
    157             $this->options['disabled_post_types'] = array_intersect( $disabled_post_types, array_keys( $types ) );   
    158             foreach( array( 'remove_admin_menu_comments', 'remove_admin_bar_comments', 'remove_recent_comments', 'remove_discussion', 'remove_rc_widget' ) as $v ) 
     157            $disabled_post_types = array_intersect( $disabled_post_types, array_keys( $types ) );    
     158            // entering permanent mode, or post types have changed 
     159            if( !empty( $_POST['permanent'] ) && ( !$this->options['permanent'] || $disabled_post_types != $this->options['disabled_post_types'] ) ) 
     160                $this->enter_permanent_mode(); 
     161             
     162            $this->options['disabled_post_types'] = $disabled_post_types; 
     163            foreach( array( 'remove_admin_menu_comments', 'remove_admin_bar_comments', 'remove_recent_comments', 'remove_discussion', 'remove_rc_widget', 'permanent' ) as $v ) 
    159164                $this->options[$v] = !empty( $_POST[$v] );   
     165             
    160166            update_option( 'disable_comments_options', $this->options ); 
    161167            echo '<div id="message" class="updated fade"><p>Options updated. Changes to the Admin Menu and Admin Bar will not appear until you leave or reload this page.</p></div>'; 
     
    181187    </ul> 
    182188    <p><strong>Note:</strong> these options are global. They will affect all users, everywhere, regardless of whether comments are enabled on portions of your site. Use them only if you want to remove all references to comments <em>everywhere</em>. 
     189    <ul class="indent"><li><label for="permanent"><input type="checkbox" name="permanent" id="permanent" <?php checked( $this->options['permanent'] );?>> Use permanent mode (see the <a href="http://wordpress.org/extend/plugins/disable-comments/faq/" target="_blank">FAQ</a> for what this means)</a></label></li></ul> 
    183190    <p class="submit"><input class="button-primary" type="submit" name="submit" value="Update settings"></p> 
    184191    </form> 
     
    193200<?php 
    194201    } 
     202     
     203    private function enter_permanent_mode() { 
     204        $types = $this->options['disabled_post_types']; 
     205        if( empty( $types ) ) 
     206            return; 
     207             
     208        global $wpdb; 
     209        $bits = implode( ', ', array_pad( array(), count( $types ), '%s' ) ); 
     210        $wpdb->query( $wpdb->prepare( "UPDATE `$wpdb->posts` SET `comment_status` = 'closed' WHERE `post_type` IN ( $bits )", $types ) ); 
     211    } 
    195212} 
    196213 
  • disable-comments/trunk/readme.txt

    r589170 r589654  
    44Requires at least: 3.2 
    55Tested up to: 3.4 
    6 Stable tag: 0.5 
     6Stable tag: trunk 
    77 
    88Allows administrators to globally disable comments on their site. Comments can be disabled according to post type. 
     
    2222= Nothing happens after I disable comments on all posts - comment forms still appear when I view my posts. = 
    2323 
    24 **Before you report this as a bug, please do this simple test**: switch to the default WordPress theme (Twenty Eleven) and see whether the problem persists. If it works with the default theme, then the problem is there because your theme isn't using the correct procedure to check whether comments are open or closed on posts, and there is nothing I can do about that. 
     24This is because your theme is not checking the comment status of posts in the correct way. The solution is to switch the plugin to permanent mode (the last option on the plugin settings page). 
    2525 
    26 You may like to point your theme's author to [this explanation](http://rayofsolaris.net/blog/2012/how-to-check-if-comments-are-allowed-in-wordpress) of what they are doing wrong, and how to fix it. Alternatively you can modify your theme's code yourself. 
     26You may like to point your theme's author to [this explanation](http://rayofsolaris.net/blog/2012/how-to-check-if-comments-are-allowed-in-wordpress) of what they are doing wrong, and how to fix it. 
     27 
     28= What is "permanent mode"? = 
     29 
     30By default, the plugin does not make any permanent changes to your posts - it just dynamically closes comments on them. This means that you can use the plugin temporarily without permanently altering the comment status of all your posts. If the plugin works in this mode, then I recommend that you don't use permanent mode. 
     31 
     32Unfortunately some themes do not properly check the comment status of posts, and the plugin in default mode will have no effect with them (comments will still appear to be open). To fix this, switch to permanent mode. Note however that this will make permanent changes: comments will remain closed even if you later disable the plugin (you can always reopen them manually, of course). 
    2733 
    2834= How can I remove the text that says "comments are closed" at the bottom of articles where comments are disabled? = 
     
    4753 
    4854== Changelog == 
     55 
     56= 0.6 =  
     57* Add "permanent mode" to deal with themes that don't use filterable comment status checking. 
    4958 
    5059= 0.5 = 
Note: See TracChangeset for help on using the changeset viewer.