This is the development respository for the Disable Comments WordPress plugin. Send pull requests here, download the latest stable version there!
Version and compatibility information can be found in the plugin readme file.
License: GPLv3+
The plugin provides two methods to programmatically check the current comment disable configuration:
Returns a simple string indicating the current comment disable status.
Return Values:
'all'
- Comments disabled site-wide for all content types'posts'
- Comments disabled only for blog posts'pages'
- Comments disabled only for pages'posts,pages'
- Comments disabled for both posts and pages'multiple'
- Comments disabled for multiple specific content types'none'
- Comments enabled everywhere- Custom post type name (e.g.,
'product'
) - Comments disabled for that specific post type
Returns a comprehensive array with complete plugin configuration details including disabled post types, API restrictions, network settings, role exclusions, and comment counts.
Key Array Elements:
status
- Main status string (same as above method)disabled_post_types
- Array of disabled post type slugstotal_comments
- Total number of comments in databasenetwork_active
- Whether plugin is network activatedxmlrpc_disabled
/rest_api_disabled
- API restriction statusrole_exclusion_enabled
- Whether role-based exclusions are active
// Get simple status
$instance = Disable_Comments::get_instance();
$status = $instance->get_current_comment_status();
if ($status === 'all') {
echo 'Comments are disabled everywhere';
} elseif ($status === 'none') {
echo 'Comments are enabled';
}
// Get detailed information
$details = $instance->get_detailed_comment_status();
echo 'Total comments: ' . $details['total_comments'];
echo 'Plugin configured: ' . ($details['is_configured'] ? 'Yes' : 'No');
Note: Call these methods on or after the init
hook to ensure proper plugin initialization.
Plugin status is automatically displayed in Tools > Site Health > Info > Disable Comments section, providing administrators with a complete overview of all plugin settings including comment counts, disabled post types, API restrictions, and network configuration. No additional setup required.
A must-use version of the plugin is also available.