Skip to content

Commit 72e6ecc

Browse files
committed
Initial commit of the Disable Comments WordPress plugin, including main plugin file, composer configuration, coding standards setup, and README documentation. Added .gitignore for development environment files and build artifacts.
0 parents  commit 72e6ecc

File tree

7 files changed

+706
-0
lines changed

7 files changed

+706
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Editors
2+
.vscode/
3+
.idea/
4+
*.sublime-project
5+
*.sublime-workspace
6+
.DS_Store
7+
8+
# Composer
9+
/vendor/
10+
composer.lock
11+
12+
# Node
13+
node_modules/
14+
npm-debug.log
15+
yarn-error.log
16+
package-lock.json
17+
18+
# Build files
19+
/build/
20+
/dist/
21+
22+
# WordPress
23+
wp-cli.local.yml
24+
25+
# DDev
26+
.ddev/

README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Disable Comments
2+
3+
A simple and lightweight WordPress plugin that completely disables comments functionality across your entire WordPress site.
4+
5+
## Description
6+
7+
This plugin disables all comments functionality in WordPress with no configuration needed. Simply activate the plugin and all comment features will be disabled.
8+
9+
## Features
10+
11+
### Core Functionality
12+
- Disables comments on all post types (posts, pages, attachments, custom post types)
13+
- Closes comments and trackbacks/pingbacks on the front-end
14+
- Hides existing comments from displaying
15+
- Automatically cleans up options from other comment disable plugins (one-time operation)
16+
17+
### Admin Interface
18+
- Removes Comments menu from admin sidebar
19+
- Redirects users trying to access the comments page
20+
- Removes comments from admin bar (front-end and back-end)
21+
- Removes comments metabox from dashboard
22+
- Removes "At a Glance" dashboard widget with comment count
23+
- Removes comments column from posts list
24+
25+
### Widgets & Scripts
26+
- Removes Recent Comments widget
27+
- Removes comment-reply script from front-end
28+
29+
### RSS & Feeds
30+
- Disables comments feed (returns 403 error)
31+
- Removes X-Pingback header from HTTP responses
32+
33+
### API & XML-RPC
34+
- Disables XML-RPC methods for comments and pingbacks
35+
- `pingback.ping`
36+
- `pingback.extensions.getPingbacks`
37+
- `wp.newComment`
38+
- Disables WordPress REST API comments endpoints
39+
- `/wp/v2/comments`
40+
- `/wp/v2/comments/{id}`
41+
- Prevents comment insertion via REST API
42+
43+
### Gutenberg Block Editor
44+
- Disables all 15 comment-related Gutenberg blocks:
45+
- Comment Author Name
46+
- Comment Content
47+
- Comment Date
48+
- Comment Edit Link
49+
- Comment Reply Link
50+
- Comment Template
51+
- Comments
52+
- Comments Pagination
53+
- Comments Pagination Next
54+
- Comments Pagination Numbers
55+
- Comments Pagination Previous
56+
- Comments Title
57+
- Latest Comments
58+
- Post Comments
59+
- Post Comments Form
60+
61+
### Multisite Support
62+
- Works on WordPress Multisite installations
63+
- Removes network comment links from admin bar
64+
65+
## Installation
66+
67+
1. Upload the `disable-comments` folder to the `/wp-content/plugins/` directory
68+
2. Activate the plugin through the 'Plugins' menu in WordPress
69+
3. That's it! Comments are now completely disabled
70+
71+
## Requirements
72+
73+
- WordPress 5.0 or higher
74+
- PHP 7.4 or higher
75+
76+
## Usage
77+
78+
This plugin works out of the box with no configuration needed. Once activated, all comment functionality will be disabled.
79+
80+
To re-enable comments, simply deactivate the plugin.
81+
82+
## Frequently Asked Questions
83+
84+
### Will this plugin delete existing comments?
85+
86+
No, this plugin does not delete any existing comments from your database. It simply hides them from displaying and prevents new comments from being submitted.
87+
88+
### Can I configure which features to disable?
89+
90+
This plugin is designed to be simple and lightweight with no configuration options. It disables all comment functionality when activated.
91+
92+
### Does this work with custom post types?
93+
94+
Yes, this plugin disables comments for all post types, including custom post types.
95+
96+
### Does this work with WordPress Multisite?
97+
98+
Yes, the plugin is fully compatible with WordPress Multisite installations and will work on individual sites or network-wide.
99+
100+
### Does this disable Gutenberg comment blocks?
101+
102+
Yes, the plugin disables all 15 comment-related Gutenberg blocks, preventing them from being inserted in the block editor.
103+
104+
### Does this block comments via REST API?
105+
106+
Yes, the plugin disables comment endpoints in the WordPress REST API and prevents comment insertion via API requests.
107+
108+
## Changelog
109+
110+
### 1.0.0
111+
* Initial release
112+
113+
## License
114+
115+
GPL v2 or later
116+
117+
## Credits
118+
119+
Inspired by:
120+
- [Disable Comments plugin](https://wordpress.org/plugins/disable-comments/) - The original WordPress.org plugin
121+
- [WPBeginner Tutorial](https://www.wpbeginner.com/wp-tutorials/how-to-completely-disable-comments-in-wordpress/) - Comprehensive guide on disabling comments
122+
123+
## Author
124+
125+
BeAPI - [https://beapi.fr](https://beapi.fr)
126+

assets/disable-comments-blocks.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Unregister comment-related Gutenberg blocks.
3+
*
4+
* @package DisableComments
5+
*/
6+
7+
( function() {
8+
// Wait for the blocks to be registered.
9+
wp.domReady( function() {
10+
// Check if required WordPress APIs are available.
11+
if ( ! wp.blocks || ! wp.data ) {
12+
return;
13+
}
14+
15+
// List of comment-related blocks to unregister.
16+
const commentsBlocks = [
17+
'core/comment-author-name',
18+
'core/comment-content',
19+
'core/comment-date',
20+
'core/comment-edit-link',
21+
'core/comment-reply-link',
22+
'core/comment-template',
23+
'core/comments',
24+
'core/comments-pagination',
25+
'core/comments-pagination-next',
26+
'core/comments-pagination-numbers',
27+
'core/comments-pagination-previous',
28+
'core/comments-title',
29+
'core/latest-comments',
30+
'core/post-comments',
31+
'core/post-comments-form',
32+
];
33+
34+
// Unregister each comment block if it exists.
35+
commentsBlocks.forEach( function( blockName ) {
36+
if ( wp.data.select( 'core/blocks' ).getBlockType( blockName ) ) {
37+
wp.blocks.unregisterBlockType( blockName );
38+
}
39+
} );
40+
} );
41+
} )();
42+

composer.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "beapi/disable-comments",
3+
"version": "1.0.0",
4+
"description": "Completely disables comments functionality in WordPress. Zero configuration needed.",
5+
"type": "wordpress-plugin",
6+
"license": "GPL-2.0-or-later",
7+
"authors": [
8+
{
9+
"name": "BeAPI",
10+
"email": "[email protected]",
11+
"homepage": "https://beapi.fr"
12+
}
13+
],
14+
"keywords": [
15+
"wordpress",
16+
"plugin",
17+
"comments",
18+
"disable",
19+
"gutenberg",
20+
"blocks"
21+
],
22+
"homepage": "https://github.com/BeAPI/disable-comments",
23+
"support": {
24+
"issues": "https://github.com/BeAPI/disable-comments/issues",
25+
"source": "https://github.com/BeAPI/disable-comments"
26+
},
27+
"require": {
28+
"php": ">=8.1",
29+
"composer/installers": "^1.0 || ^2.0"
30+
},
31+
"require-dev": {
32+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
33+
"overtrue/phplint": "^9.0",
34+
"php-parallel-lint/php-parallel-lint": "^1.4",
35+
"phpcompatibility/phpcompatibility-wp": "^2.1",
36+
"phpro/grumphp-shim": "^2.6",
37+
"roave/security-advisories": "dev-latest",
38+
"vimeo/psalm": "^5.25",
39+
"wp-coding-standards/wpcs": "^3.1"
40+
},
41+
"autoload": {
42+
"files": [
43+
"disable-comments.php"
44+
]
45+
},
46+
"config": {
47+
"allow-plugins": {
48+
"composer/installers": true,
49+
"dealerdirect/phpcodesniffer-composer-installer": true,
50+
"phpro/grumphp-shim": true
51+
},
52+
"sort-packages": true,
53+
"optimize-autoloader": true,
54+
"platform": {
55+
"php": "8.1"
56+
}
57+
},
58+
"scripts": {
59+
"cs": "./vendor/bin/phpcs",
60+
"cb": "./vendor/bin/phpcbf",
61+
"psalm": "./vendor/bin/psalm"
62+
},
63+
"scripts-descriptions": {
64+
"cs": "Run PHP CodeSniffer on codebase using our ruleset.",
65+
"cb": "Run PHP Code Beautifier and Fixer on codebase using our ruleset.",
66+
"psalm": "Run psalm on codebase using our ruleset."
67+
}
68+
}

0 commit comments

Comments
 (0)