diff --git a/wp-content/plugins/disable-comments/assets/disable-comments.js b/wp-content/plugins/disable-comments/assets/disable-comments.js new file mode 100644 index 0000000000000000000000000000000000000000..ec3141fdf80601df1697ae6647f26c133db14285 --- /dev/null +++ b/wp-content/plugins/disable-comments/assets/disable-comments.js @@ -0,0 +1,12 @@ +"use strict"; + +wp.domReady(function () { + if (wp.blocks) { + wp.blocks.getBlockTypes().forEach(function (block) { + if (disable_comments.disabled_blocks.includes(block.name)) { + wp.blocks.unregisterBlockType(block.name); + } + }); + } +}); +//# sourceMappingURL=disable-comments.js.map diff --git a/wp-content/plugins/disable-comments/assets/disable-comments.js.map b/wp-content/plugins/disable-comments/assets/disable-comments.js.map new file mode 100644 index 0000000000000000000000000000000000000000..92b5e177ff4ebc570cb3867ff55bbf8b71203ece --- /dev/null +++ b/wp-content/plugins/disable-comments/assets/disable-comments.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/disable-comments.js"],"names":["wp","domReady","blocks","getBlockTypes","forEach","block","disable_comments","disabled_blocks","includes","name","unregisterBlockType"],"mappings":";;AAAAA,EAAE,CAACC,QAAH,CAAY,YAAM;AACjB,MAAGD,EAAE,CAACE,MAAN,EAAc;AACbF,IAAAA,EAAE,CAACE,MAAH,CAAUC,aAAV,GAA0BC,OAA1B,CAAkC,UAACC,KAAD,EAAW;AAC5C,UAAIC,gBAAgB,CAACC,eAAjB,CAAiCC,QAAjC,CAA0CH,KAAK,CAACI,IAAhD,CAAJ,EAA2D;AAC1DT,QAAAA,EAAE,CAACE,MAAH,CAAUQ,mBAAV,CAA8BL,KAAK,CAACI,IAApC;AACA;AACD,KAJD;AAKA;AACD,CARD","sourcesContent":["wp.domReady(() => {\n\tif(wp.blocks) {\n\t\twp.blocks.getBlockTypes().forEach((block) => {\n\t\t\tif (disable_comments.disabled_blocks.includes(block.name)) {\n\t\t\t\twp.blocks.unregisterBlockType(block.name);\n\t\t\t}\n\t\t});\n\t}\n});\n"],"file":"disable-comments.js"} \ No newline at end of file diff --git a/wp-content/plugins/disable-comments/disable-comments.php b/wp-content/plugins/disable-comments/disable-comments.php index bd4611ac28658ecb5fb0d446e27c2a0a0e5004c4..b4bf8da85f4269cd7ae36112670ee690ad80289c 100644 --- a/wp-content/plugins/disable-comments/disable-comments.php +++ b/wp-content/plugins/disable-comments/disable-comments.php @@ -3,7 +3,7 @@ Plugin Name: Disable Comments Plugin URI: https://wordpress.org/plugins/disable-comments/ Description: Allows administrators to globally disable comments on their site. Comments can be disabled according to post type. -Version: 1.9.0 +Version: 1.10.2 Author: Samir Shah Author URI: http://www.rayofsolaris.net/ License: GPL2 @@ -11,11 +11,12 @@ Text Domain: disable-comments Domain Path: /languages/ */ -if( !defined( 'ABSPATH' ) ) +if ( ! defined( 'ABSPATH' ) ) { exit; +} class Disable_Comments { - const DB_VERSION = 6; + const DB_VERSION = 6; private static $instance = null; private $options; private $networkactive; @@ -33,15 +34,14 @@ class Disable_Comments { $this->networkactive = ( is_multisite() && array_key_exists( plugin_basename( __FILE__ ), (array) get_site_option( 'active_sitewide_plugins' ) ) ); // Load options - if( $this->networkactive ) { + if ( $this->networkactive ) { $this->options = get_site_option( 'disable_comments_options', array() ); - } - else { + } else { $this->options = get_option( 'disable_comments_options', array() ); } // If it looks like first run, check compat - if( empty( $this->options ) ) { + if ( empty( $this->options ) ) { $this->check_compatibility(); } @@ -63,22 +63,23 @@ class Disable_Comments { private function check_db_upgrades() { $old_ver = isset( $this->options['db_version'] ) ? $this->options['db_version'] : 0; - if( $old_ver < self::DB_VERSION ) { - if( $old_ver < 2 ) { + if ( $old_ver < self::DB_VERSION ) { + if ( $old_ver < 2 ) { // upgrade options from version 0.2.1 or earlier to 0.3 $this->options['disabled_post_types'] = get_option( 'disable_comments_post_types', array() ); delete_option( 'disable_comments_post_types' ); } - if( $old_ver < 5 ) { + if ( $old_ver < 5 ) { // simple is beautiful - remove multiple settings in favour of one $this->options['remove_everywhere'] = isset( $this->options['remove_admin_menu_comments'] ) ? $this->options['remove_admin_menu_comments'] : false; - foreach( array( 'remove_admin_menu_comments', 'remove_admin_bar_comments', 'remove_recent_comments', 'remove_discussion', 'remove_rc_widget' ) as $v ) - unset( $this->options[$v] ); + foreach ( array( 'remove_admin_menu_comments', 'remove_admin_bar_comments', 'remove_recent_comments', 'remove_discussion', 'remove_rc_widget' ) as $v ) { + unset( $this->options[ $v ] ); + } } - foreach( array( 'remove_everywhere', 'extra_post_types' ) as $v ) { - if( !isset( $this->options[$v] ) ) { - $this->options[$v] = false; + foreach ( array( 'remove_everywhere', 'extra_post_types' ) as $v ) { + if ( ! isset( $this->options[ $v ] ) ) { + $this->options[ $v ] = false; } } @@ -88,10 +89,9 @@ class Disable_Comments { } private function update_options() { - if( $this->networkactive ) { + if ( $this->networkactive ) { update_site_option( 'disable_comments_options', $this->options ); - } - else { + } else { update_option( 'disable_comments_options', $this->options ); } } @@ -102,9 +102,9 @@ class Disable_Comments { private function get_disabled_post_types() { $types = $this->options['disabled_post_types']; // Not all extra_post_types might be registered on this particular site - if( $this->networkactive ) { - foreach( (array) $this->options['extra_post_types'] as $extra ) { - if( post_type_exists( $extra ) ) { + if ( $this->networkactive ) { + foreach ( (array) $this->options['extra_post_types'] as $extra ) { + if ( post_type_exists( $extra ) ) { $types[] = $extra; } } @@ -121,10 +121,10 @@ class Disable_Comments { private function init_filters() { // These need to happen now - if( $this->options['remove_everywhere'] ) { + if ( $this->options['remove_everywhere'] ) { add_action( 'widgets_init', array( $this, 'disable_rc_widget' ) ); add_filter( 'wp_headers', array( $this, 'filter_wp_headers' ) ); - add_action( 'template_redirect', array( $this, 'filter_query' ), 9 ); // before redirect_canonical + add_action( 'template_redirect', array( $this, 'filter_query' ), 9 ); // before redirect_canonical // Admin bar filtering has to happen here since WP 3.6 add_action( 'template_redirect', array( $this, 'filter_admin_bar' ) ); @@ -134,18 +134,21 @@ class Disable_Comments { // These can happen later add_action( 'plugins_loaded', array( $this, 'register_text_domain' ) ); add_action( 'wp_loaded', array( $this, 'init_wploaded_filters' ) ); + + // Disable "Latest comments" block in Gutenberg + add_action( 'enqueue_block_editor_assets', array( $this, 'filter_gutenberg_blocks') ); } public function register_text_domain() { - load_plugin_textdomain( 'disable-comments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); + load_plugin_textdomain( 'disable-comments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } - public function init_wploaded_filters(){ + public function init_wploaded_filters() { $disabled_post_types = $this->get_disabled_post_types(); - if( !empty( $disabled_post_types ) ) { - foreach( $disabled_post_types as $type ) { + if ( ! empty( $disabled_post_types ) ) { + foreach ( $disabled_post_types as $type ) { // we need to know what native support was for later - if( post_type_supports( $type, 'comments' ) ) { + if ( post_type_supports( $type, 'comments' ) ) { $this->modified_types[] = $type; remove_post_type_support( $type, 'comments' ); remove_post_type_support( $type, 'trackbacks' ); @@ -154,8 +157,8 @@ class Disable_Comments { add_filter( 'comments_array', array( $this, 'filter_existing_comments' ), 20, 2 ); add_filter( 'comments_open', array( $this, 'filter_comment_status' ), 20, 2 ); add_filter( 'pings_open', array( $this, 'filter_comment_status' ), 20, 2 ); - } - elseif( is_admin() && !$this->options['remove_everywhere'] ) { + add_filter( 'get_comments_number', array( $this, 'filter_comments_number' ), 20, 2 ); + } elseif ( is_admin() && ! $this->options['remove_everywhere'] ) { // It is possible that $disabled_post_types is empty if other // plugins have disabled comments. Hence we also check for // remove_everywhere. If you still get a warning you probably @@ -164,25 +167,25 @@ class Disable_Comments { } // Filters for the admin only - if( is_admin() ) { - if( $this->networkactive ) { + if ( is_admin() ) { + if ( $this->networkactive ) { add_action( 'network_admin_menu', array( $this, 'settings_menu' ) ); add_action( 'network_admin_menu', array( $this, 'tools_menu' ) ); - add_filter( 'network_admin_plugin_action_links', array( $this, 'plugin_actions_links'), 10, 2 ); - } - else { + add_filter( 'network_admin_plugin_action_links', array( $this, 'plugin_actions_links' ), 10, 2 ); + } else { add_action( 'admin_menu', array( $this, 'settings_menu' ) ); add_action( 'admin_menu', array( $this, 'tools_menu' ) ); - add_filter( 'plugin_action_links', array( $this, 'plugin_actions_links'), 10, 2 ); - if( is_multisite() ) // We're on a multisite setup, but the plugin isn't network activated. + add_filter( 'plugin_action_links', array( $this, 'plugin_actions_links' ), 10, 2 ); + if ( is_multisite() ) { // We're on a multisite setup, but the plugin isn't network activated. register_deactivation_hook( __FILE__, array( $this, 'single_site_deactivate' ) ); + } } add_action( 'admin_notices', array( $this, 'discussion_notice' ) ); add_filter( 'plugin_row_meta', array( $this, 'set_plugin_meta' ), 10, 2 ); - if( $this->options['remove_everywhere'] ) { - add_action( 'admin_menu', array( $this, 'filter_admin_menu' ), 9999 ); // do this as late as possible + if ( $this->options['remove_everywhere'] ) { + add_action( 'admin_menu', array( $this, 'filter_admin_menu' ), 9999 ); // do this as late as possible add_action( 'admin_print_styles-index.php', array( $this, 'admin_css' ) ); add_action( 'admin_print_styles-profile.php', array( $this, 'admin_css' ) ); add_action( 'wp_dashboard_setup', array( $this, 'filter_dashboard' ) ); @@ -193,7 +196,7 @@ class Disable_Comments { else { add_action( 'template_redirect', array( $this, 'check_comment_template' ) ); - if( $this->options['remove_everywhere'] ) { + if ( $this->options['remove_everywhere'] ) { add_filter( 'feed_links_show_comments_feed', '__return_false' ); } } @@ -205,8 +208,8 @@ class Disable_Comments { * and set it to True */ public function check_comment_template() { - if( is_singular() && ( $this->options['remove_everywhere'] || $this->is_post_type_disabled( get_post_type() ) ) ) { - if( !defined( 'DISABLE_COMMENTS_REMOVE_COMMENTS_TEMPLATE' ) || DISABLE_COMMENTS_REMOVE_COMMENTS_TEMPLATE == true ) { + if ( is_singular() && ( $this->options['remove_everywhere'] || $this->is_post_type_disabled( get_post_type() ) ) ) { + if ( ! defined( 'DISABLE_COMMENTS_REMOVE_COMMENTS_TEMPLATE' ) || DISABLE_COMMENTS_REMOVE_COMMENTS_TEMPLATE == true ) { // Kill the comments template. add_filter( 'comments_template', array( $this, 'dummy_comments_template' ), 20 ); } @@ -234,7 +237,7 @@ class Disable_Comments { * Issue a 403 for all comment feed requests. */ public function filter_query() { - if( is_comment_feed() ) { + if ( is_comment_feed() ) { wp_die( __( 'Comments are closed.' ), '', array( 'response' => 403 ) ); } } @@ -243,25 +246,49 @@ class Disable_Comments { * Remove comment links from the admin bar. */ public function filter_admin_bar() { - if( is_admin_bar_showing() ) { + if ( is_admin_bar_showing() ) { // Remove comments links from admin bar remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 ); - if( is_multisite() ) { + if ( is_multisite() ) { add_action( 'admin_bar_menu', array( $this, 'remove_network_comment_links' ), 500 ); } } } + /** + * Determines if scripts should be enqueued + */ + public function filter_gutenberg_blocks( $hook ) { + global $post; + + if ( $this->options['remove_everywhere'] || ( isset( $post->post_type ) && in_array( $post->post_type, $this->get_disabled_post_types(), true ) ) ) { + return $this->disable_comments_script(); + } + } + + /** + * Enqueues scripts + */ + public function disable_comments_script() { + wp_enqueue_script( 'disable-comments-gutenberg', plugin_dir_url( __FILE__ ) . 'assets/disable-comments.js', array(), false, true ); + wp_localize_script( + 'disable-comments-gutenberg', + 'disable_comments', + array( + 'disabled_blocks' => array( 'core/latest-comments' ), + ) + ); + } + /* * Remove comment links from the admin bar in a multisite network. */ public function remove_network_comment_links( $wp_admin_bar ) { - if( $this->networkactive && is_user_logged_in() ) { - foreach( (array) $wp_admin_bar->user->blogs as $blog ) { + if ( $this->networkactive && is_user_logged_in() ) { + foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { $wp_admin_bar->remove_menu( 'blog-' . $blog->userblog_id . '-c' ); } - } - else { + } else { // We have no way to know whether the plugin is active on other sites, so only remove this one $wp_admin_bar->remove_menu( 'blog-' . get_current_blog_id() . '-c' ); } @@ -269,10 +296,11 @@ class Disable_Comments { public function discussion_notice() { $disabled_post_types = $this->get_disabled_post_types(); - if( get_current_screen()->id == 'options-discussion' && !empty( $disabled_post_types ) ) { + if ( get_current_screen()->id == 'options-discussion' && ! empty( $disabled_post_types ) ) { $names = array(); - foreach( $disabled_post_types as $type ) - $names[$type] = get_post_type_object( $type )->labels->name; + foreach ( $disabled_post_types as $type ) { + $names[ $type ] = get_post_type_object( $type )->labels->name; + } 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>'; } @@ -282,7 +310,7 @@ class Disable_Comments { * Return context-aware settings page URL */ private function settings_page_url() { - $base = $this->networkactive ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' ); + $base = $this->networkactive ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' ); return add_query_arg( 'page', 'disable_comments_settings', $base ); } @@ -290,40 +318,43 @@ class Disable_Comments { * Return context-aware tools page URL */ private function tools_page_url() { - $base = $this->networkactive ? network_admin_url( 'settings.php' ) : admin_url( 'tools.php' ); + $base = $this->networkactive ? network_admin_url( 'settings.php' ) : admin_url( 'tools.php' ); return add_query_arg( 'page', 'disable_comments_tools', $base ); } - public function setup_notice(){ - if( strpos( get_current_screen()->id, 'settings_page_disable_comments_settings' ) === 0 ) + public function setup_notice() { + if ( strpos( get_current_screen()->id, 'settings_page_disable_comments_settings' ) === 0 ) { return; + } $hascaps = $this->networkactive ? is_network_admin() && current_user_can( 'manage_network_plugins' ) : current_user_can( 'manage_options' ); - if( $hascaps ) { - echo '<div class="updated fade"><p>' . sprintf( __( 'The <em>Disable Comments</em> plugin is active, but isn\'t configured to do anything yet. Visit the <a href="%s">configuration page</a> to choose which post types to disable comments on.', 'disable-comments'), esc_attr( $this->settings_page_url() ) ) . '</p></div>'; + if ( $hascaps ) { + echo '<div class="updated fade"><p>' . sprintf( __( 'The <em>Disable Comments</em> plugin is active, but isn\'t configured to do anything yet. Visit the <a href="%s">configuration page</a> to choose which post types to disable comments on.', 'disable-comments' ), esc_attr( $this->settings_page_url() ) ) . '</p></div>'; } } - public function filter_admin_menu(){ + public function filter_admin_menu() { global $pagenow; - if ( $pagenow == 'comment.php' || $pagenow == 'edit-comments.php' ) + if ( $pagenow == 'comment.php' || $pagenow == 'edit-comments.php' ) { wp_die( __( 'Comments are closed.' ), '', array( 'response' => 403 ) ); + } remove_menu_page( 'edit-comments.php' ); if ( ! $this->discussion_settings_allowed() ) { - if ( $pagenow == 'options-discussion.php' ) + if ( $pagenow == 'options-discussion.php' ) { wp_die( __( 'Comments are closed.' ), '', array( 'response' => 403 ) ); + } remove_submenu_page( 'options-general.php', 'options-discussion.php' ); } } - public function filter_dashboard(){ + public function filter_dashboard() { remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); } - public function admin_css(){ + public function admin_css() { echo '<style> #dashboard_right_now .comment-count, #dashboard_right_now .comment-mod-count, @@ -335,7 +366,7 @@ class Disable_Comments { </style>'; } - public function filter_existing_comments($comments, $post_id) { + public function filter_existing_comments( $comments, $post_id ) { $post = get_post( $post_id ); return ( $this->options['remove_everywhere'] || $this->is_post_type_disabled( $post->post_type ) ) ? array() : $comments; } @@ -345,11 +376,16 @@ class Disable_Comments { return ( $this->options['remove_everywhere'] || $this->is_post_type_disabled( $post->post_type ) ) ? false : $open; } + public function filter_comments_number( $count, $post_id ) { + $post = get_post( $post_id ); + return ( $this->options['remove_everywhere'] || $this->is_post_type_disabled( $post->post_type ) ) ? 0 : $count; + } + public function disable_rc_widget() { unregister_widget( 'WP_Widget_Recent_Comments' ); // The widget has added a style action when it was constructed - which will // still fire even if we now unregister the widget... so filter that out - add_filter( 'show_recent_comments_widget_style', '__return_false'); + add_filter( 'show_recent_comments_widget_style', '__return_false' ); } public function set_plugin_meta( $links, $file ) { @@ -363,11 +399,11 @@ class Disable_Comments { /** * Add links to Settings page - */ + */ public function plugin_actions_links( $links, $file ) { static $plugin; $plugin = plugin_basename( __FILE__ ); - if( $file == $plugin && current_user_can('manage_options') ) { + if ( $file == $plugin && current_user_can( 'manage_options' ) ) { array_unshift( $links, sprintf( '<a href="%s">%s</a>', esc_attr( $this->settings_page_url() ), __( 'Settings' ) ), @@ -380,10 +416,11 @@ class Disable_Comments { public function settings_menu() { $title = _x( 'Disable Comments', 'settings menu title', 'disable-comments' ); - if( $this->networkactive ) + if ( $this->networkactive ) { add_submenu_page( 'settings.php', $title, $title, 'manage_network_plugins', 'disable_comments_settings', array( $this, 'settings_page' ) ); - else + } else { add_submenu_page( 'options-general.php', $title, $title, 'manage_options', 'disable_comments_settings', array( $this, 'settings_page' ) ); + } } public function settings_page() { @@ -392,10 +429,11 @@ class Disable_Comments { public function tools_menu() { $title = __( 'Delete Comments', 'disable-comments' ); - if( $this->networkactive ) + if ( $this->networkactive ) { add_submenu_page( 'settings.php', $title, $title, 'manage_network_plugins', 'disable_comments_tools', array( $this, 'tools_page' ) ); - else + } else { add_submenu_page( 'tools.php', $title, $title, 'manage_options', 'disable_comments_tools', array( $this, 'tools_page' ) ); + } } public function tools_page() { @@ -403,7 +441,7 @@ class Disable_Comments { } private function discussion_settings_allowed() { - if( defined( 'DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS' ) && DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS == true ) { + if ( defined( 'DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS' ) && DISABLE_COMMENTS_ALLOW_DISCUSSION_SETTINGS == true ) { return true; } } diff --git a/wp-content/plugins/disable-comments/includes/comments-template.php b/wp-content/plugins/disable-comments/includes/comments-template.php index e8b1969f8ad534a0860b7a31380afc6e0c5507f0..daa0820f4f63a142b805fa50ffb5f761c0f0b0b8 100644 --- a/wp-content/plugins/disable-comments/includes/comments-template.php +++ b/wp-content/plugins/disable-comments/includes/comments-template.php @@ -1,4 +1,5 @@ <?php -/* Dummy comments template file. +/* + Dummy comments template file. * This replaces the theme's comment template when comments are disabled everywhere - */ \ No newline at end of file + */ diff --git a/wp-content/plugins/disable-comments/includes/settings-page.php b/wp-content/plugins/disable-comments/includes/settings-page.php index 5699a92c0144dadf559caa70afdcb037e704a417..a60390cda8fd2122e615ac30f0577566732d7e30 100644 --- a/wp-content/plugins/disable-comments/includes/settings-page.php +++ b/wp-content/plugins/disable-comments/includes/settings-page.php @@ -1,35 +1,37 @@ <?php -if( !defined( 'ABSPATH' ) ) { +if ( ! defined( 'ABSPATH' ) ) { exit; } $typeargs = array( 'public' => true ); -if( $this->networkactive ) { - $typeargs['_builtin'] = true; // stick to known types for network +if ( $this->networkactive ) { + $typeargs['_builtin'] = true; // stick to known types for network } $types = get_post_types( $typeargs, 'objects' ); -foreach( array_keys( $types ) as $type ) { - if( ! in_array( $type, $this->modified_types ) && ! post_type_supports( $type, 'comments' ) ) // the type doesn't support comments anyway - unset( $types[$type] ); +foreach ( array_keys( $types ) as $type ) { + if ( ! in_array( $type, $this->modified_types ) && ! post_type_supports( $type, 'comments' ) ) { // the type doesn't support comments anyway + unset( $types[ $type ] ); + } } if ( isset( $_POST['submit'] ) ) { check_admin_referer( 'disable-comments-admin' ); $this->options['remove_everywhere'] = ( $_POST['mode'] == 'remove_everywhere' ); - if( $this->options['remove_everywhere'] ) + if ( $this->options['remove_everywhere'] ) { $disabled_post_types = array_keys( $types ); - else - $disabled_post_types = empty( $_POST['disabled_types'] ) ? array() : (array) $_POST['disabled_types']; + } else { + $disabled_post_types = empty( $_POST['disabled_types'] ) ? array() : (array) $_POST['disabled_types']; + } $disabled_post_types = array_intersect( $disabled_post_types, array_keys( $types ) ); $this->options['disabled_post_types'] = $disabled_post_types; // Extra custom post types - if( $this->networkactive && !empty( $_POST['extra_post_types'] ) ) { - $extra_post_types = array_filter( array_map( 'sanitize_key', explode( ',', $_POST['extra_post_types'] ) ) ); - $this->options['extra_post_types'] = array_diff( $extra_post_types, array_keys( $types ) ); // Make sure we don't double up builtins + if ( $this->networkactive && ! empty( $_POST['extra_post_types'] ) ) { + $extra_post_types = array_filter( array_map( 'sanitize_key', explode( ',', $_POST['extra_post_types'] ) ) ); + $this->options['extra_post_types'] = array_diff( $extra_post_types, array_keys( $types ) ); // Make sure we don't double up builtins } $this->update_options(); @@ -39,33 +41,38 @@ if ( isset( $_POST['submit'] ) ) { ?> <style> .indent {padding-left: 2em} </style> <div class="wrap"> -<h1><?php _ex( 'Disable Comments', 'settings page title', 'disable-comments') ?></h1> +<h1><?php _ex( 'Disable Comments', 'settings page title', 'disable-comments' ); ?></h1> <?php -if( $this->networkactive ) - 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>'; -if( WP_CACHE ) - echo '<div class="updated"><p>' . __( "It seems that a caching/performance plugin is active on this site. Please manually invalidate that plugin's cache after making any changes to the settings below.", 'disable-comments') . '</p></div>'; +if ( $this->networkactive ) { + 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>'; +} +if ( WP_CACHE ) { + echo '<div class="updated"><p>' . __( "It seems that a caching/performance plugin is active on this site. Please manually invalidate that plugin's cache after making any changes to the settings below.", 'disable-comments' ) . '</p></div>'; +} ?> <form action="" method="post" id="disable-comments"> <ul> -<li><label for="remove_everywhere"><input type="radio" id="remove_everywhere" name="mode" value="remove_everywhere" <?php checked( $this->options['remove_everywhere'] );?> /> <strong><?php _e( 'Everywhere', 'disable-comments') ?></strong>: <?php _e( 'Disable all comment-related controls and settings in WordPress.', 'disable-comments') ?></label> - <p class="indent"><?php printf( __( '%s: 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="%s" target="_blank">available here</a>.', 'disable-comments' ), '<strong style="color: #900">' . __('Warning', 'disable-comments') . '</strong>', 'https://wordpress.org/plugins/disable-comments/other_notes/' ); ?></p> +<li><label for="remove_everywhere"><input type="radio" id="remove_everywhere" name="mode" value="remove_everywhere" <?php checked( $this->options['remove_everywhere'] ); ?> /> <strong><?php _e( 'Everywhere', 'disable-comments' ); ?></strong>: <?php _e( 'Disable all comment-related controls and settings in WordPress.', 'disable-comments' ); ?></label> + <p class="indent"><?php printf( __( '%1$s: 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="%2$s" target="_blank">available here</a>.', 'disable-comments' ), '<strong style="color: #900">' . __( 'Warning', 'disable-comments' ) . '</strong>', 'https://wordpress.org/plugins/disable-comments/other_notes/' ); ?></p> </li> -<li><label for="selected_types"><input type="radio" id="selected_types" name="mode" value="selected_types" <?php checked( ! $this->options['remove_everywhere'] );?> /> <strong><?php _e( 'On certain post types', 'disable-comments') ?></strong>:</label> +<li><label for="selected_types"><input type="radio" id="selected_types" name="mode" value="selected_types" <?php checked( ! $this->options['remove_everywhere'] ); ?> /> <strong><?php _e( 'On certain post types', 'disable-comments' ); ?></strong>:</label> <p></p> <ul class="indent" id="listoftypes"> - <?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>";?> + <?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>";} + ?> </ul> - <?php if( $this->networkactive ) :?> + <?php if ( $this->networkactive ) : ?> <p class="indent" id="extratypes"><?php _e( 'Only the built-in post types appear above. If you want to disable comments on other custom post types on the entire network, you can supply a comma-separated list of post types below (use the slug that identifies the post type).', 'disable-comments' ); ?> <br /><label><?php _e( 'Custom post types:', 'disable-comments' ); ?> <input type="text" name="extra_post_types" size="30" value="<?php echo implode( ', ', (array) $this->options['extra_post_types'] ); ?>" /></label></p> <?php endif; ?> - <p class="indent"><?php _e( '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.', 'disable-comments') ?></p> + <p class="indent"><?php _e( '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.', 'disable-comments' ); ?></p> </li> </ul> <?php wp_nonce_field( 'disable-comments-admin' ); ?> -<p class="submit"><input class="button-primary" type="submit" name="submit" value="<?php _e( 'Save Changes', 'disable-comments') ?>"></p> +<p class="submit"><input class="button-primary" type="submit" name="submit" value="<?php _e( 'Save Changes', 'disable-comments' ); ?>"></p> </form> </div> <script> diff --git a/wp-content/plugins/disable-comments/includes/tools-page.php b/wp-content/plugins/disable-comments/includes/tools-page.php index c1b7db2bff0126c87eef906d372374a7953f2216..08a079909ac3b7041e98aab22cab414c1337f256 100644 --- a/wp-content/plugins/disable-comments/includes/tools-page.php +++ b/wp-content/plugins/disable-comments/includes/tools-page.php @@ -1,109 +1,113 @@ <?php -if( !defined( 'ABSPATH' ) ) { +if ( ! defined( 'ABSPATH' ) ) { exit; } ?> <div class="wrap"> -<h1><?php _e( 'Delete Comments', 'disable-comments') ?></h1> +<h1><?php _e( 'Delete Comments', 'disable-comments' ); ?></h1> <?php global $wpdb; -$comments_count = $wpdb->get_var("SELECT count(comment_id) from $wpdb->comments"); -if ( $comments_count <= 0 ) { ?> -<p><strong><?php _e( 'No comments available for deletion.', 'disable-comments') ?></strong></p> +$comments_count = $wpdb->get_var( "SELECT count(comment_id) from $wpdb->comments" ); +if ( $comments_count <= 0 ) { + ?> +<p><strong><?php _e( 'No comments available for deletion.', 'disable-comments' ); ?></strong></p> </div> -<?php + <?php return; } $typeargs = array( 'public' => true ); -if( $this->networkactive ) { - $typeargs['_builtin'] = true; // stick to known types for network +if ( $this->networkactive ) { + $typeargs['_builtin'] = true; // stick to known types for network } $types = get_post_types( $typeargs, 'objects' ); -foreach( array_keys( $types ) as $type ) { - if( ! in_array( $type, $this->modified_types ) && ! post_type_supports( $type, 'comments' ) ) // the type doesn't support comments anyway - unset( $types[$type] ); +foreach ( array_keys( $types ) as $type ) { + if ( ! in_array( $type, $this->modified_types ) && ! post_type_supports( $type, 'comments' ) ) { // the type doesn't support comments anyway + unset( $types[ $type ] ); + } } if ( isset( $_POST['delete'] ) && isset( $_POST['delete_mode'] ) ) { check_admin_referer( 'delete-comments-admin' ); - if( $_POST['delete_mode'] == 'delete_everywhere' ) { - if ( $wpdb->query( "TRUNCATE $wpdb->commentmeta" ) != FALSE ){ - if ( $wpdb->query( "TRUNCATE $wpdb->comments" ) != FALSE ){ - $wpdb->query( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0" ); - $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" ); - $wpdb->query( "OPTIMIZE TABLE $wpdb->comments" ); - echo "<p style='color:green'><strong>" . __( 'All comments have been deleted.', 'disable-comments' ) . "</strong></p>"; - } else { - echo "<p style='color:red'><strong>" . __( 'Internal error occured. Please try again later.', 'disable-comments' ) . "</strong></p>"; - } - } else { - echo "<p style='color:red'><strong>" . __( 'Internal error occured. Please try again later.', 'disable-comments' ) . "</strong></p>"; - } + if ( $_POST['delete_mode'] == 'delete_everywhere' ) { + if ( $wpdb->query( "TRUNCATE $wpdb->commentmeta" ) != false ) { + if ( $wpdb->query( "TRUNCATE $wpdb->comments" ) != false ) { + $wpdb->query( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0" ); + $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" ); + $wpdb->query( "OPTIMIZE TABLE $wpdb->comments" ); + echo "<p style='color:green'><strong>" . __( 'All comments have been deleted.', 'disable-comments' ) . '</strong></p>'; + } else { + echo "<p style='color:red'><strong>" . __( 'Internal error occured. Please try again later.', 'disable-comments' ) . '</strong></p>'; + } + } else { + echo "<p style='color:red'><strong>" . __( 'Internal error occured. Please try again later.', 'disable-comments' ) . '</strong></p>'; + } } else { - $delete_post_types = empty( $_POST['delete_types'] ) ? array() : (array) $_POST['delete_types']; + $delete_post_types = empty( $_POST['delete_types'] ) ? array() : (array) $_POST['delete_types']; $delete_post_types = array_intersect( $delete_post_types, array_keys( $types ) ); // Extra custom post types - if( $this->networkactive && !empty( $_POST['delete_extra_post_types'] ) ) { + if ( $this->networkactive && ! empty( $_POST['delete_extra_post_types'] ) ) { $delete_extra_post_types = array_filter( array_map( 'sanitize_key', explode( ',', $_POST['delete_extra_post_types'] ) ) ); - $delete_extra_post_types = array_diff( $delete_extra_post_types, array_keys( $types ) ); // Make sure we don't double up builtins - $delete_post_types = array_merge($delete_post_types, $delete_extra_post_types); + $delete_extra_post_types = array_diff( $delete_extra_post_types, array_keys( $types ) ); // Make sure we don't double up builtins + $delete_post_types = array_merge( $delete_post_types, $delete_extra_post_types ); } if ( ! empty( $delete_post_types ) ) { // Loop through post_types and remove comments/meta and set posts comment_count to 0 foreach ( $delete_post_types as $delete_post_type ) { - $wpdb->query( "DELETE cmeta FROM $wpdb->commentmeta cmeta INNER JOIN $wpdb->comments comments ON cmeta.comment_id=comments.comment_ID INNER JOIN $wpdb->posts posts ON comments.comment_post_ID=posts.ID WHERE posts.post_type = '$delete_post_type'" ); - $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'" ); - $wpdb->query( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0 AND post_type = '$delete_post_type'" ); + $wpdb->query( "DELETE cmeta FROM $wpdb->commentmeta cmeta INNER JOIN $wpdb->comments comments ON cmeta.comment_id=comments.comment_ID INNER JOIN $wpdb->posts posts ON comments.comment_post_ID=posts.ID WHERE posts.post_type = '$delete_post_type'" ); + $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'" ); + $wpdb->query( "UPDATE $wpdb->posts SET comment_count = 0 WHERE post_author != 0 AND post_type = '$delete_post_type'" ); - $post_type_object = get_post_type_object( $delete_post_type ); - $post_type_label = $post_type_object ? $post_type_object->labels->name : $delete_post_type; - echo "<p style='color:green'><strong>" . sprintf( __( 'All comments have been deleted for %s.', 'disable-comments' ), $post_type_label ) . "</strong></p>"; + $post_type_object = get_post_type_object( $delete_post_type ); + $post_type_label = $post_type_object ? $post_type_object->labels->name : $delete_post_type; + echo "<p style='color:green'><strong>" . sprintf( __( 'All comments have been deleted for %s.', 'disable-comments' ), $post_type_label ) . '</strong></p>'; } - $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" ); - $wpdb->query( "OPTIMIZE TABLE $wpdb->comments" ); + $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" ); + $wpdb->query( "OPTIMIZE TABLE $wpdb->comments" ); - echo "<h4 style='color:green'><strong>" . __( 'Comment Deletion Complete', 'disable-comments') . "</strong></h4>"; + echo "<h4 style='color:green'><strong>" . __( 'Comment Deletion Complete', 'disable-comments' ) . '</strong></h4>'; } - } - $comments_count = $wpdb->get_var("SELECT count(comment_id) from $wpdb->comments"); - if ( $comments_count <= 0 ) { ?> - <p><strong><?php _e( 'No comments available for deletion.', 'disable-comments') ?></strong></p> + $comments_count = $wpdb->get_var( "SELECT count(comment_id) from $wpdb->comments" ); + if ( $comments_count <= 0 ) { + ?> + <p><strong><?php _e( 'No comments available for deletion.', 'disable-comments' ); ?></strong></p> </div> - <?php + <?php return; } - } ?> <form action="" method="post" id="delete-comments"> <ul> -<li><label for="delete_everywhere"><input type="radio" id="delete_everywhere" name="delete_mode" value="delete_everywhere" <?php checked( $this->options['remove_everywhere'] );?> /> <strong><?php _e( 'Everywhere', 'disable-comments') ?></strong>: <?php _e( 'Delete all comments in WordPress.', 'disable-comments') ?></label> - <p class="indent"><?php printf( __( '%s: This function and will affect your entire site. Use it only if you want to delete comments <em>everywhere</em>.', 'disable-comments' ), '<strong style="color: #900">' . __('Warning', 'disable-comments') . '</strong>' ); ?></p> +<li><label for="delete_everywhere"><input type="radio" id="delete_everywhere" name="delete_mode" value="delete_everywhere" <?php checked( $this->options['remove_everywhere'] ); ?> /> <strong><?php _e( 'Everywhere', 'disable-comments' ); ?></strong>: <?php _e( 'Delete all comments in WordPress.', 'disable-comments' ); ?></label> + <p class="indent"><?php printf( __( '%s: This function and will affect your entire site. Use it only if you want to delete comments <em>everywhere</em>.', 'disable-comments' ), '<strong style="color: #900">' . __( 'Warning', 'disable-comments' ) . '</strong>' ); ?></p> </li> -<li><label for="selected_delete_types"><input type="radio" id="selected_delete_types" name="delete_mode" value="selected_delete_types" <?php checked( ! $this->options['remove_everywhere'] );?> /> <strong><?php _e( 'For certain post types', 'disable-comments') ?></strong>:</label> +<li><label for="selected_delete_types"><input type="radio" id="selected_delete_types" name="delete_mode" value="selected_delete_types" <?php checked( ! $this->options['remove_everywhere'] ); ?> /> <strong><?php _e( 'For certain post types', 'disable-comments' ); ?></strong>:</label> <p></p> <ul class="indent" id="listofdeletetypes"> - <?php foreach( $types as $k => $v ) echo "<li><label for='post-type-$k'><input type='checkbox' name='delete_types[]' value='$k' ". checked( in_array( $k, $this->options['disabled_post_types'] ), true, false ) ." id='post-type-$k'> {$v->labels->name}</label></li>";?> + <?php + foreach ( $types as $k => $v ) { + echo "<li><label for='post-type-$k'><input type='checkbox' name='delete_types[]' value='$k' " . checked( in_array( $k, $this->options['disabled_post_types'] ), true, false ) . " id='post-type-$k'> {$v->labels->name}</label></li>";} + ?> </ul> - <?php if( $this->networkactive ) :?> + <?php if ( $this->networkactive ) : ?> <p class="indent" id="extradeletetypes"><?php _e( 'Only the built-in post types appear above. If you want to disable comments on other custom post types on the entire network, you can supply a comma-separated list of post types below (use the slug that identifies the post type).', 'disable-comments' ); ?> <br /><label><?php _e( 'Custom post types:', 'disable-comments' ); ?> <input type="text" name="delete_extra_post_types" size="30" value="<?php echo implode( ', ', (array) $this->options['extra_post_types'] ); ?>" /></label></p> <?php endif; ?> - <p class="indent"><?php printf( __( '%s: Deleting comments will remove existing comment entries in the database and cannot be reverted without a database backup.', 'disable-comments'), '<strong style="color: #900">' . __('Warning', 'disable-comments') . '</strong>' ); ?></p> + <p class="indent"><?php printf( __( '%s: Deleting comments will remove existing comment entries in the database and cannot be reverted without a database backup.', 'disable-comments' ), '<strong style="color: #900">' . __( 'Warning', 'disable-comments' ) . '</strong>' ); ?></p> </li> </ul> <?php wp_nonce_field( 'delete-comments-admin' ); ?> <h4><?php _e( 'Total Comments:', 'disable-comments' ); ?> <?php echo $comments_count; ?></h4> -<p class="submit"><input class="button-primary" type="submit" name="delete" value="<?php _e( 'Delete Comments', 'disable-comments') ?>"></p> +<p class="submit"><input class="button-primary" type="submit" name="delete" value="<?php _e( 'Delete Comments', 'disable-comments' ); ?>"></p> </form> </div> <script> diff --git a/wp-content/plugins/disable-comments/readme.txt b/wp-content/plugins/disable-comments/readme.txt index a5065b872f8ac16dba9eb016aaf73ba11e74ae6a..75893aa472ec94d68d172a1986d561191d5a4e2e 100644 --- a/wp-content/plugins/disable-comments/readme.txt +++ b/wp-content/plugins/disable-comments/readme.txt @@ -1,9 +1,9 @@ === Disable Comments === -Contributors: solarissmoke +Contributors: solarissmoke, garrett-eclipse Donate link: http://www.rayofsolaris.net/donate/ Tags: comments, disable, global Requires at least: 5.0 -Tested up to: 5.1 +Tested up to: 5.3 Stable tag: trunk 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. @@ -46,7 +46,7 @@ You can also bulk-edit the comment status of multiple posts from the [posts scre = I want to delete comments from my database. What do I do? = -Go to the settings page for the disable comments plugin and utlize the Delete Comments tool to delete all comments or according to the specified post types from your database. +Go to the tools page for the Disable Comments plugin and utlize the Delete Comments tool to delete all comments or according to the specified post types from your database. == Details == @@ -74,6 +74,9 @@ These definitions can be made either in your main `wp-config.php` or in your the == Changelog == += 1.10.0 = +* Disable "recent comments" Gutenberg block. + = 1.9.0 = * Fix compatibility with WordPress 5.0 and above. * Remove deprecated "persistent mode" feature. diff --git a/wp-content/plugins/disable-comments/src/disable-comments.js b/wp-content/plugins/disable-comments/src/disable-comments.js new file mode 100644 index 0000000000000000000000000000000000000000..fa19b0ef74fec67108a16faea7604975b71c9a1f --- /dev/null +++ b/wp-content/plugins/disable-comments/src/disable-comments.js @@ -0,0 +1,9 @@ +wp.domReady(() => { + if(wp.blocks) { + wp.blocks.getBlockTypes().forEach((block) => { + if (disable_comments.disabled_blocks.includes(block.name)) { + wp.blocks.unregisterBlockType(block.name); + } + }); + } +}); diff --git a/wp-content/plugins/disable-comments/uninstall.php b/wp-content/plugins/disable-comments/uninstall.php index 8eb0024a12a46b66f1259b88fefb7469b41844cd..7580dc0f281a1c6aa1a89ba6c66f8c343466b66a 100644 --- a/wp-content/plugins/disable-comments/uninstall.php +++ b/wp-content/plugins/disable-comments/uninstall.php @@ -1,5 +1,6 @@ -<?php -if( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) +<?php +if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { exit; +} -delete_site_option( 'disable_comments_options' ); \ No newline at end of file +delete_site_option( 'disable_comments_options' );