Version Description
- Added
DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS
configuration.
Download this release
Release Info
Developer | solarissmoke |
Plugin | Disable Comments |
Version | 1.8.0 |
Comparing to | |
See all releases |
Code changes from version 1.7.1 to 1.8.0
- disable-comments.php +29 -15
- includes/settings-page.php +1 -1
- readme.txt +7 -2
disable-comments.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Disable Comments
|
4 |
Plugin URI: https://wordpress.org/plugins/disable-comments/
|
5 |
Description: Allows administrators to globally disable comments on their site. Comments can be disabled according to post type.
|
6 |
-
Version: 1.
|
7 |
Author: Samir Shah
|
8 |
Author URI: http://www.rayofsolaris.net/
|
9 |
License: GPL2
|
@@ -52,11 +52,11 @@ class Disable_Comments {
|
|
52 |
}
|
53 |
|
54 |
private function check_compatibility() {
|
55 |
-
if ( version_compare( $GLOBALS['wp_version'], '
|
56 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
57 |
deactivate_plugins( __FILE__ );
|
58 |
if ( isset( $_GET['action'] ) && ( $_GET['action'] == 'activate' || $_GET['action'] == 'error_scrape' ) ) {
|
59 |
-
exit( sprintf( __( 'Disable Comments requires WordPress version %s or greater.', 'disable-comments' ), '
|
60 |
}
|
61 |
}
|
62 |
}
|
@@ -155,7 +155,11 @@ class Disable_Comments {
|
|
155 |
add_filter( 'comments_open', array( $this, 'filter_comment_status' ), 20, 2 );
|
156 |
add_filter( 'pings_open', array( $this, 'filter_comment_status' ), 20, 2 );
|
157 |
}
|
158 |
-
elseif( is_admin() ) {
|
|
|
|
|
|
|
|
|
159 |
add_action( 'all_admin_notices', array( $this, 'setup_notice' ) );
|
160 |
}
|
161 |
|
@@ -174,7 +178,7 @@ class Disable_Comments {
|
|
174 |
register_deactivation_hook( __FILE__, array( $this, 'single_site_deactivate' ) );
|
175 |
}
|
176 |
|
177 |
-
add_action( '
|
178 |
add_filter( 'plugin_row_meta', array( $this, 'set_plugin_meta' ), 10, 2 );
|
179 |
|
180 |
// if only certain types are disabled, remember the original post status
|
@@ -277,19 +281,14 @@ class Disable_Comments {
|
|
277 |
}
|
278 |
}
|
279 |
|
280 |
-
public function discussion_notice(){
|
281 |
$disabled_post_types = $this->get_disabled_post_types();
|
282 |
if( get_current_screen()->id == 'options-discussion' && !empty( $disabled_post_types ) ) {
|
283 |
$names = array();
|
284 |
foreach( $disabled_post_types as $type )
|
285 |
$names[$type] = get_post_type_object( $type )->labels->name;
|
286 |
-
|
287 |
-
<
|
288 |
-
jQuery(document).ready(function($){
|
289 |
-
$(".wrap h2").first().after( <?php echo json_encode( '<div style="color: #900"><p>' . sprintf( __( 'Note: The <em>Disable Comments</em> plugin is currently active, and comments are completely disabled on: %s. Many of the settings below will not be applicable for those post types.', 'disable-comments' ), implode( __( ', ' ), $names ) ) . '</p></div>' );?> );
|
290 |
-
});
|
291 |
-
</script>
|
292 |
-
<?php
|
293 |
}
|
294 |
}
|
295 |
|
@@ -321,11 +320,17 @@ jQuery(document).ready(function($){
|
|
321 |
public function filter_admin_menu(){
|
322 |
global $pagenow;
|
323 |
|
324 |
-
if ( $pagenow == 'comment.php' || $pagenow == 'edit-comments.php'
|
325 |
wp_die( __( 'Comments are closed.' ), '', array( 'response' => 403 ) );
|
326 |
|
327 |
remove_menu_page( 'edit-comments.php' );
|
328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
}
|
330 |
|
331 |
public function filter_dashboard(){
|
@@ -356,6 +361,9 @@ jQuery(document).ready(function($){
|
|
356 |
|
357 |
public function disable_rc_widget() {
|
358 |
unregister_widget( 'WP_Widget_Recent_Comments' );
|
|
|
|
|
|
|
359 |
}
|
360 |
|
361 |
public function set_plugin_meta( $links, $file ) {
|
@@ -442,6 +450,12 @@ jQuery(document).ready(function($){
|
|
442 |
}
|
443 |
}
|
444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
public function single_site_deactivate() {
|
446 |
// for single sites, delete the options upon deactivation, not uninstall
|
447 |
delete_option( 'disable_comments_options' );
|
3 |
Plugin Name: Disable Comments
|
4 |
Plugin URI: https://wordpress.org/plugins/disable-comments/
|
5 |
Description: Allows administrators to globally disable comments on their site. Comments can be disabled according to post type.
|
6 |
+
Version: 1.8.0
|
7 |
Author: Samir Shah
|
8 |
Author URI: http://www.rayofsolaris.net/
|
9 |
License: GPL2
|
52 |
}
|
53 |
|
54 |
private function check_compatibility() {
|
55 |
+
if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
|
56 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
57 |
deactivate_plugins( __FILE__ );
|
58 |
if ( isset( $_GET['action'] ) && ( $_GET['action'] == 'activate' || $_GET['action'] == 'error_scrape' ) ) {
|
59 |
+
exit( sprintf( __( 'Disable Comments requires WordPress version %s or greater.', 'disable-comments' ), '4.7' ) );
|
60 |
}
|
61 |
}
|
62 |
}
|
155 |
add_filter( 'comments_open', array( $this, 'filter_comment_status' ), 20, 2 );
|
156 |
add_filter( 'pings_open', array( $this, 'filter_comment_status' ), 20, 2 );
|
157 |
}
|
158 |
+
elseif( is_admin() && !$this->options['remove_everywhere'] ) {
|
159 |
+
// It is possible that $disabled_post_types is empty if other
|
160 |
+
// plugins have disabled comments. Hence we also check for
|
161 |
+
// remove_everywhere. If you still get a warning you probably
|
162 |
+
// shouldn't be using this plugin.
|
163 |
add_action( 'all_admin_notices', array( $this, 'setup_notice' ) );
|
164 |
}
|
165 |
|
178 |
register_deactivation_hook( __FILE__, array( $this, 'single_site_deactivate' ) );
|
179 |
}
|
180 |
|
181 |
+
add_action( 'admin_notices', array( $this, 'discussion_notice' ) );
|
182 |
add_filter( 'plugin_row_meta', array( $this, 'set_plugin_meta' ), 10, 2 );
|
183 |
|
184 |
// if only certain types are disabled, remember the original post status
|
281 |
}
|
282 |
}
|
283 |
|
284 |
+
public function discussion_notice() {
|
285 |
$disabled_post_types = $this->get_disabled_post_types();
|
286 |
if( get_current_screen()->id == 'options-discussion' && !empty( $disabled_post_types ) ) {
|
287 |
$names = array();
|
288 |
foreach( $disabled_post_types as $type )
|
289 |
$names[$type] = get_post_type_object( $type )->labels->name;
|
290 |
+
|
291 |
+
echo '<div class="notice notice-warning"><p>' . sprintf( __( 'Note: The <em>Disable Comments</em> plugin is currently active, and comments are completely disabled on: %s. Many of the settings below will not be applicable for those post types.', 'disable-comments' ), implode( __( ', ' ), $names ) ) . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
}
|
294 |
|
320 |
public function filter_admin_menu(){
|
321 |
global $pagenow;
|
322 |
|
323 |
+
if ( $pagenow == 'comment.php' || $pagenow == 'edit-comments.php' )
|
324 |
wp_die( __( 'Comments are closed.' ), '', array( 'response' => 403 ) );
|
325 |
|
326 |
remove_menu_page( 'edit-comments.php' );
|
327 |
+
|
328 |
+
if ( ! $this->discussion_settings_allowed() ) {
|
329 |
+
if ( $pagenow == 'options-discussion.php' )
|
330 |
+
wp_die( __( 'Comments are closed.' ), '', array( 'response' => 403 ) );
|
331 |
+
|
332 |
+
remove_submenu_page( 'options-general.php', 'options-discussion.php' );
|
333 |
+
}
|
334 |
}
|
335 |
|
336 |
public function filter_dashboard(){
|
361 |
|
362 |
public function disable_rc_widget() {
|
363 |
unregister_widget( 'WP_Widget_Recent_Comments' );
|
364 |
+
// The widget has added a style action when it was constructed - which will
|
365 |
+
// still fire even if we now unregister the widget... so filter that out
|
366 |
+
add_filter( 'show_recent_comments_widget_style', '__return_false');
|
367 |
}
|
368 |
|
369 |
public function set_plugin_meta( $links, $file ) {
|
450 |
}
|
451 |
}
|
452 |
|
453 |
+
private function discussion_settings_allowed() {
|
454 |
+
if( defined( 'DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS' ) && DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS == true ) {
|
455 |
+
return true;
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
public function single_site_deactivate() {
|
460 |
// for single sites, delete the options upon deactivation, not uninstall
|
461 |
delete_option( 'disable_comments_options' );
|
includes/settings-page.php
CHANGED
@@ -46,7 +46,7 @@ if ( isset( $_POST['submit'] ) ) {
|
|
46 |
?>
|
47 |
<style> .indent {padding-left: 2em} </style>
|
48 |
<div class="wrap">
|
49 |
-
<h1><?php
|
50 |
<?php
|
51 |
if( $this->networkactive )
|
52 |
echo '<div class="updated"><p>' . __( '<em>Disable Comments</em> is Network Activated. The settings below will affect <strong>all sites</strong> in this network.', 'disable-comments') . '</p></div>';
|
46 |
?>
|
47 |
<style> .indent {padding-left: 2em} </style>
|
48 |
<div class="wrap">
|
49 |
+
<h1><?php _ex( 'Disable Comments', 'settings page title', 'disable-comments') ?></h1>
|
50 |
<?php
|
51 |
if( $this->networkactive )
|
52 |
echo '<div class="updated"><p>' . __( '<em>Disable Comments</em> is Network Activated. The settings below will affect <strong>all sites</strong> in this network.', 'disable-comments') . '</p></div>';
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: solarissmoke
|
3 |
Donate link: http://www.rayofsolaris.net/donate/
|
4 |
Tags: comments, disable, global
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to:
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Allows administrators to globally disable comments on their site. Comments can be disabled according to post type. Multisite friendly. Provides tool to delete all comments or according to post type.
|
@@ -68,10 +68,15 @@ Some of the plugin's behaviour can be modified by site administrators and plugin
|
|
68 |
|
69 |
* Define `DISABLE_COMMENTS_REMOVE_COMMENTS_TEMPLATE` and set it to `false` to prevent the plugin from replacing the theme's comment template with an empty one.
|
70 |
|
|
|
|
|
71 |
These definitions can be made either in your main `wp-config.php` or in your theme's `functions.php` file.
|
72 |
|
73 |
== Changelog ==
|
74 |
|
|
|
|
|
|
|
75 |
= 1.7.1 =
|
76 |
* Small enhancements to hiding comment-related functionality in the admin.
|
77 |
|
2 |
Contributors: solarissmoke
|
3 |
Donate link: http://www.rayofsolaris.net/donate/
|
4 |
Tags: comments, disable, global
|
5 |
+
Requires at least: 4.7
|
6 |
+
Tested up to: 5.0
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Allows administrators to globally disable comments on their site. Comments can be disabled according to post type. Multisite friendly. Provides tool to delete all comments or according to post type.
|
68 |
|
69 |
* Define `DISABLE_COMMENTS_REMOVE_COMMENTS_TEMPLATE` and set it to `false` to prevent the plugin from replacing the theme's comment template with an empty one.
|
70 |
|
71 |
+
* Define `DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS` and set it to `true` to prevent the plugin from hiding the Discussion settings page.
|
72 |
+
|
73 |
These definitions can be made either in your main `wp-config.php` or in your theme's `functions.php` file.
|
74 |
|
75 |
== Changelog ==
|
76 |
|
77 |
+
= 1.8.0 =
|
78 |
+
* Added `DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS` configuration.
|
79 |
+
|
80 |
= 1.7.1 =
|
81 |
* Small enhancements to hiding comment-related functionality in the admin.
|
82 |
|