WordPress.org

Plugin Directory

Changeset 635275


Ignore:
Timestamp:
12/07/12 08:31:47 (17 months ago)
Author:
solarissmoke
Message:

Releasing version 0.8

Location:
disable-comments/trunk
Files:
2 edited

Legend:

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

    r632893 r635275  
    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.7 
     6Version: 0.8 
    77Author: Samir Shah 
    88Author URI: http://rayofsolaris.net/ 
     
    5757         
    5858        // these need to happen now 
    59         if( $this->options['remove_everywhere'] ) 
     59        if( $this->options['remove_everywhere'] ) { 
    6060            add_action( 'widgets_init', array( $this, 'disable_rc_widget' ) ); 
     61            add_filter( 'wp_headers', array( $this, 'filter_wp_headers' ) ); 
     62            add_action( 'template_redirect', array( $this, 'filter_query' ), 9 );   // before redirect_canonical 
     63        } 
    6164         
    6265        // these can happen later 
     
    115118                add_action( 'admin_head', array( $this, 'hide_discussion_rightnow' ) ); 
    116119                add_action( 'wp_dashboard_setup', array( $this, 'filter_dashboard' ) ); 
    117             } 
     120                add_filter( 'pre_option_default_pingback_flag', '__return_zero' ); 
     121            } 
     122        } 
     123    } 
     124     
     125    function filter_wp_headers( $headers ) { 
     126        unset( $headers['X-Pingback'] ); 
     127        return $headers; 
     128    } 
     129     
     130    function filter_query() { 
     131        if( is_comment_feed() ) { 
     132            if( isset( $_GET['feed'] ) ) { 
     133                wp_redirect( remove_query_arg( 'feed' ), 301 ); 
     134                exit; 
     135            } 
     136 
     137            set_query_var( 'feed', '' );    // redirect_canonical will do the rest 
    118138        } 
    119139    } 
     
    178198    function filter_comment_status( $open, $post_id ) { 
    179199        $post = get_post( $post_id ); 
    180         return in_array( $post->post_type, $this->options['disabled_post_types'] ) ? false : $open; 
     200        return ( $this->options['remove_everywhere'] || in_array( $post->post_type, $this->options['disabled_post_types'] ) ) ? false : $open; 
    181201    } 
    182202     
     
    203223         
    204224        if ( isset( $_POST['submit'] ) ) { 
    205             $disabled_post_types =  empty( $_POST['disabled_types'] ) ? array() : (array) $_POST['disabled_types']; 
    206             $disabled_post_types = array_intersect( $disabled_post_types, array_keys( $types ) );    
     225            $this->options['remove_everywhere'] = ( $_POST['mode'] == 'remove_everywhere' ); 
     226             
     227            if( $this->options['remove_everywhere'] ) 
     228                $disabled_post_types = array_keys( $types ); 
     229            else 
     230                $disabled_post_types =  empty( $_POST['disabled_types'] ) ? array() : (array) $_POST['disabled_types']; 
     231 
     232            $disabled_post_types = array_intersect( $disabled_post_types, array_keys( $types ) ); 
     233             
    207234            // entering permanent mode, or post types have changed 
    208235            if( !empty( $_POST['permanent'] ) && ( !$this->options['permanent'] || $disabled_post_types != $this->options['disabled_post_types'] ) ) 
     
    210237             
    211238            $this->options['disabled_post_types'] = $disabled_post_types; 
    212             foreach( array( 'remove_everywhere', 'permanent' ) as $v ) 
    213                 $this->options[$v] = !empty( $_POST[$v] );   
     239            $this->options['permanent'] = isset( $_POST['permanent'] ); 
    214240             
    215241            $this->update_options(); 
     
    228254    ?> 
    229255    <form action="" method="post" id="disable-comments"> 
    230     <p>Globally disable comments on:</p> 
    231     <ul class="indent"> 
    232         <?php foreach( $types as $k => $v ) echo "<li><label for='post-type-$k'><input type='checkbox' name='disabled_types[]' value='$k' ". checked( in_array( $k, $this->options['disabled_post_types'] ), true, false ) ." id='post-type-$k'> {$v->labels->name}</label></li>";?> 
    233     </ul> 
    234     <p><strong>Note:</strong> disabling comments will also disable trackbacks and pingbacks. All comment-related fields will also be hidden from the edit/quick-edit screens of the affected posts. These settings cannot be overridden for individual posts.</p> 
     256    <ul> 
     257    <li><label for="remove_everywhere"><input type="radio" id="remove_everywhere" name="mode" value="remove_everywhere" <?php checked( $this->options['remove_everywhere'] );?> /> <strong>Everywhere</strong>, and disable all comment-related controls and settings in WordPress.</label> 
     258        <p class="indent"><strong style="color: #900">Warning:</strong> this option is global and will affect your entire site. Use it only if you want to disable comments <em>everywhere</em>. A complete description of what this option does is <a href="http://wordpress.org/extend/plugins/disable-comments/details/" target="_blank">available here</a>.</p> 
     259    </li> 
     260    <li><label for="selected_types"><input type="radio" id="selected_types" name="mode" value="selected_types" <?php checked( ! $this->options['remove_everywhere'] );?> /> <strong>On certain post types</strong>: 
     261        <p></p> 
     262        <ul class="indent" id="listoftypes"> 
     263            <?php foreach( $types as $k => $v ) echo "<li><label for='post-type-$k'><input type='checkbox' name='disabled_types[]' value='$k' ". checked( in_array( $k, $this->options['disabled_post_types'] ), true, false ) ." id='post-type-$k'> {$v->labels->name}</label></li>";?> 
     264        </ul> 
     265        <p class="indent">Disabling comments will also disable trackbacks and pingbacks. All comment-related fields will also be hidden from the edit/quick-edit screens of the affected posts. These settings cannot be overridden for individual posts.</p> 
     266    </li> 
    235267    <h3>Other options</h3> 
    236     <ul class="indent"> 
    237         <li><label for="remove_everywhere"><input type="checkbox" name="remove_everywhere" id="remove_everywhere" <?php checked( $this->options['remove_everywhere'] );?>> Remove all comment-related controls from WordPress</label></li> 
    238             <p>Selecting this option will remove the following:</p> 
    239             <ul class="indent" style="list-style: disc"> 
    240             <li>The "Comments" link from the Admin Menu</li> 
    241             <li>The "Comments" icon from the Admin Bar</li> 
    242             <li>The "Recent Comments" Dashboard widget</li> 
    243             <li>The "Recent Comments" template widget (this prevents the widget from being available in <code>Appearance -> Widgets</code> and from being used by themes)</li> 
    244             <li>The "Discussion" section from the WordPress Dashboard <span class="hide-if-js"><strong>(Note: this requires Javascript to be enabled in the browser)</strong></span></li> 
    245             <li>The "Discussion Settings" page</strong></span></li> 
    246             </ul> 
    247             <p><strong>Note:</strong> this option is global. They will affect all users, everywhere, regardless of whether comments are enabled on portions of your site. Use it only if you want to remove all references to comments <em>everywhere</em>.</p> 
    248         </li> 
    249         <li><label for="permanent"><input type="checkbox" name="permanent" id="permanent" <?php checked( $this->options['permanent'] );?>> Use permanent mode (use only if normal mode doesn't work - see the <a href="http://wordpress.org/extend/plugins/disable-comments/faq/" target="_blank">FAQ</a> for what this means)</a></label> 
    250         <?php if( $this->networkactive ) echo '<p><strong>Warning:</strong> entering permanent mode on large multi-site networks requires a large number of database queries and can take a while. Use with caution!</p>';?> 
     268    <ul> 
     269        <li><label for="permanent"><input type="checkbox" name="permanent" id="permanent" <?php checked( $this->options['permanent'] );?>> Use permanent mode (use only if normal mode doesn't work - see the <a href="http://wordpress.org/extend/plugins/disable-comments/faq/" target="_blank">FAQ</a> for what this means)</a>.</label> 
     270        <?php if( $this->networkactive ) echo '<p class="indent"><strong>Warning:</strong> entering permanent mode on large multi-site networks requires a large number of database queries and can take a while. Use with caution!</p>';?> 
    251271        </li> 
    252272    </ul> 
     
    256276    <script> 
    257277    jQuery(document).ready(function($){ 
     278        function disable_comments_uihelper(){ 
     279            if( $("#remove_everywhere").is(":checked") ) 
     280                $("#listoftypes").css("color", "#888").find(":input").attr("disabled", true ); 
     281            else 
     282                $("#listoftypes").css("color", "#000").find(":input").attr("disabled", false ); 
     283        } 
     284         
    258285        $("#disable-comments :input").change(function(){ 
    259286            $("#message").slideUp(); 
     287            disable_comments_uihelper(); 
    260288        }); 
     289         
     290        disable_comments_uihelper(); 
    261291    }); 
    262292    </script> 
  • disable-comments/trunk/readme.txt

    r614399 r635275  
    4646You can also bulk-edit the comment status of multiple posts from the [posts screen](http://codex.wordpress.org/Posts_Screen). 
    4747 
     48== Details == 
     49 
     50The plugin provides the option to **completely disable the commenting feature in WordPress**. When this option is selected, the following changes are made: 
     51 
     52* All "Comments" links are hidden from the Admin Menu and Admin Bar; 
     53* All comment-related sections ("Recent Comments", "Discussion" etc.) are hidden from the WordPress Dashboard; 
     54* All comment-related widgets are disabled (so your theme cannot use them); 
     55* The "Discussion" settings page is hidden; 
     56* All comment RSS/Atom feeds are disabled (and requests for these will be redirected to the parent post); 
     57* The X-Pingback HTTP header is removed from all pages; 
     58* Outgoing pingbacks are disabled. 
     59 
    4860== Changelog == 
     61 
     62= 0.8 = 
     63* Remove X-Pingback header when comments are completely disabled. 
     64* Disable comment feeds when comment are completely disabled. 
     65* Simplified settings page. 
    4966 
    5067= 0.7 = 
Note: See TracChangeset for help on using the changeset viewer.