Plugin Directory

Changeset 2042603


Ignore:
Timestamp:
03/02/2019 04:08:56 AM (7 years ago)
Author:
solarissmoke
Message:

Version 1.9.0

Location:
disable-comments/trunk
Files:
4 edited

Legend:

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

    r1959549 r2042603  
    44Plugin URI: https://wordpress.org/plugins/disable-comments/
    55Description: Allows administrators to globally disable comments on their site. Comments can be disabled according to post type.
    6 Version: 1.8.0
     6Version: 1.9.0
    77Author: Samir Shah
    88Author URI: http://www.rayofsolaris.net/
     
    7777            }
    7878
    79             foreach( array( 'remove_everywhere', 'permanent', 'extra_post_types' ) as $v ) {
     79            foreach( array( 'remove_everywhere', 'extra_post_types' ) as $v ) {
    8080                if( !isset( $this->options[$v] ) ) {
    8181                    $this->options[$v] = false;
     
    182182            add_filter( 'plugin_row_meta', array( $this, 'set_plugin_meta' ), 10, 2 );
    183183
    184             // if only certain types are disabled, remember the original post status
    185             if( !( $this->persistent_mode_allowed() && $this->options['permanent'] ) && !$this->options['remove_everywhere'] ) {
    186                 add_action( 'edit_form_advanced', array( $this, 'edit_form_inputs' ) );
    187                 add_action( 'edit_page_form', array( $this, 'edit_form_inputs' ) );
    188             }
    189 
    190184            if( $this->options['remove_everywhere'] ) {
    191185                add_action( 'admin_menu', array( $this, 'filter_admin_menu' ), 9999 );  // do this as late as possible
     
    271265            // We have no way to know whether the plugin is active on other sites, so only remove this one
    272266            $wp_admin_bar->remove_menu( 'blog-' . get_current_blog_id() . '-c' );
    273         }
    274     }
    275 
    276     public function edit_form_inputs() {
    277         global $post;
    278         // Without a dicussion meta box, comment_status will be set to closed on new/updated posts
    279         if( in_array( $post->post_type, $this->modified_types ) ) {
    280             echo '<input type="hidden" name="comment_status" value="' . $post->comment_status . '" /><input type="hidden" name="ping_status" value="' . $post->ping_status . '" />';
    281267        }
    282268    }
     
    417403    }
    418404
    419     private function enter_permanent_mode() {
    420         $types = $this->get_disabled_post_types();
    421         if( empty( $types ) )
    422             return;
    423 
    424         global $wpdb;
    425 
    426         if( $this->networkactive ) {
    427             // NOTE: this can be slow on large networks!
    428             $blogs = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND deleted = '0'", $wpdb->siteid ) );
    429 
    430             foreach ( $blogs as $id ) {
    431                 switch_to_blog( $id );
    432                 $this->close_comments_in_db( $types );
    433                 restore_current_blog();
    434             }
    435         }
    436         else {
    437             $this->close_comments_in_db( $types );
    438         }
    439     }
    440 
    441     private function close_comments_in_db( $types ){
    442         global $wpdb;
    443         $bits = implode( ', ', array_pad( array(), count( $types ), '%s' ) );
    444         $wpdb->query( $wpdb->prepare( "UPDATE `$wpdb->posts` SET `comment_status` = 'closed', ping_status = 'closed' WHERE `post_type` IN ( $bits )", $types ) );
    445     }
    446 
    447     private function persistent_mode_allowed() {
    448         if( defined( 'DISABLE_COMMENTS_ALLOW_PERSISTENT_MODE' ) && DISABLE_COMMENTS_ALLOW_PERSISTENT_MODE == false ) {
    449             return false;
    450         }
    451     }
    452 
    453405    private function discussion_settings_allowed() {
    454406        if( defined( 'DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS' ) && DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS == true ) {
  • disable-comments/trunk/includes/settings-page.php

    r1959549 r2042603  
    1414}
    1515
    16 $persistent_allowed = $this->persistent_mode_allowed();
    17 
    1816if ( isset( $_POST['submit'] ) ) {
    1917    check_admin_referer( 'disable-comments-admin' );
     
    2725    $disabled_post_types = array_intersect( $disabled_post_types, array_keys( $types ) );
    2826
    29     // entering permanent mode, or post types have changed
    30     if( $persistent_allowed && !empty( $_POST['permanent'] ) && ( !$this->options['permanent'] || $disabled_post_types != $this->options['disabled_post_types'] ) )
    31         $this->enter_permanent_mode();
    32 
    3327    $this->options['disabled_post_types'] = $disabled_post_types;
    34     $this->options['permanent'] = $persistent_allowed && isset( $_POST['permanent'] );
    3528
    3629    // Extra custom post types
     
    7265</ul>
    7366
    74 <?php if( $persistent_allowed && $this->options['permanent'] ): ?>
    75 <h2><?php _e( 'Other options', 'disable-comments') ?></h2>
    76 <ul>
    77     <li>
    78     <?php
    79     echo '<label for="permanent"><input type="checkbox" name="permanent" id="permanent" '. checked( $this->options['permanent'], true, false ) . '> <strong>' . __( 'Use persistent mode', 'disable-comments') . '</strong></label>';
    80     echo '<p class="indent">' . sprintf( __( '%s: <strong>This will make persistent changes to your database &mdash; comments will remain closed even if you later disable the plugin!</strong> You should not use it if you only want to disable comments temporarily. Please <a href="%s" target="_blank">read the FAQ</a> before selecting this option.', 'disable-comments'), '<strong style="color: #900">' . __('Warning', 'disable-comments') . '</strong>', 'https://wordpress.org/plugins/disable-comments/faq/' ) . '</p>';
    81     if( $this->networkactive )
    82         echo '<p class="indent">' . sprintf( __( '%s: Entering persistent mode on large multi-site networks requires a large number of database queries and can take a while. Use with caution!', 'disable-comments'), '<strong style="color: #900">' . __('Warning', 'disable-comments') . '</strong>' ) . '</p>';
    83     ?>
    84     </li>
    85 </ul>
    86 <?php endif; ?>
    87 
    8867<?php wp_nonce_field( 'disable-comments-admin' ); ?>
    8968<p class="submit"><input class="button-primary" type="submit" name="submit" value="<?php _e( 'Save Changes', 'disable-comments') ?>"></p>
     
    10685
    10786    disable_comments_uihelper();
    108 
    109     $("#permanent").change( function() {
    110         if( $(this).is(":checked") && ! confirm(<?php echo json_encode( sprintf( __( '%s: Selecting this option will make persistent changes to your database. Are you sure you want to enable it?', 'disable-comments'), __( 'Warning', 'disable-comments' ) ) );?>) )
    111             $(this).attr("checked", false );
    112     });
    11387});
    11488</script>
  • disable-comments/trunk/includes/tools-page.php

    r1546961 r2042603  
    6060                $wpdb->query( "DELETE comments FROM $wpdb->comments comments INNER JOIN $wpdb->posts posts ON comments.comment_post_ID=posts.ID WHERE posts.post_type = '$delete_post_type'" );
    6161                $wpdb->query( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0 AND post_type = '$delete_post_type'" );
    62                 echo "<p style='color:green'><strong>" . sprintf( __( 'All comments have been deleted for %ss.', 'disable-comments' ), $delete_post_type ) . "</strong></p>";
     62
     63                $post_type_object = get_post_type_object( $delete_post_type );
     64                $post_type_label = $post_type_object ? $post_type_object->labels->name : $delete_post_type;
     65                echo "<p style='color:green'><strong>" . sprintf( __( 'All comments have been deleted for %s.', 'disable-comments' ), $post_type_label ) . "</strong></p>";
    6366            }
    6467
  • disable-comments/trunk/readme.txt

    r1959549 r2042603  
    33Donate link: http://www.rayofsolaris.net/donate/
    44Tags: comments, disable, global
    5 Requires at least: 4.7
    6 Tested up to: 5.0
     5Requires at least: 5.0
     6Tested up to: 5.1
    77Stable tag: trunk
    88
     
    7575== Changelog ==
    7676
     77= 1.9.0 =
     78* Fix compatibility with WordPress 5.0 and above.
     79* Remove deprecated "persistent mode" feature.
     80
    7781= 1.8.0 =
    7882* Added `DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS` configuration.
Note: See TracChangeset for help on using the changeset viewer.