1. Procedure Title
Name of the Process: Disabling Comments Completely on WordPress Using WPCode Lite Plugin
2. Purpose
Brief Description: To completely disable comments on a WordPress website using the WPCode Lite plugin by adding a custom PHP snippet. This procedure ensures that comments are removed from all posts, pages, and the WordPress admin dashboard.
3. Scope
Involved Areas: WordPress Administration
4. Responsibilities
Roles and Responsibilities:
- Site Administrator: Responsible for implementing the PHP snippet and verifying changes.
- IT Support: Assists in resolving potential issues related to the implementation.
5. Definitions and Key Terms
Glossary:
- WPCode Lite Plugin: A WordPress plugin used for managing custom code snippets.
- PHP Snippet: A piece of PHP code that performs specific tasks within WordPress.
- Comments: User-generated responses typically associated with blog posts or pages.
6. Procedure Details
6.1. Preparation and Prerequisites
- Administrator access to the WordPress Admin Dashboard.
- WPCode Lite plugin installed and activated.
6.2 Timeline for Task Completion
- Estimated Time: 10-20 minutes.
- Frequency: Once during setup or as needed for updates.
- Review Schedule: Annually or when plugin updates occurs
6.3. Step-by-Step Procedure
Install and Activate WPCode Lite Plugin
-
Log in to your WordPress Admin Dashboard.
-
Navigate to Plugins > Add New.
-
Search for “WPCode Lite” in the search bar.
-
Click Install Now and then Activate.
Navigate to the WPCode Snippet Manager
-
Go to Code Snippets > + Add Snippet in the WordPress Admin Dashboard.
-
Click on Add Your Custom Code (New Snippet) to create a new PHP snippet.
Add the Custom PHP Snippet
-
Copy the following PHP code snippet:
add_action(‘admin_init’, function () {
// Redirect any user trying to access comments page
global $pagenow;
/*
if ($pagenow === ‘edit-comments.php’) {
wp_safe_redirect(admin_url());
exit;
}
*/
// Remove comments metabox from dashboard
remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’);
// Disable support for comments and trackbacks in post types
foreach (get_post_types() as $post_type) {
if (post_type_supports($post_type, ‘comments’)) {
remove_post_type_support($post_type, ‘comments’);
remove_post_type_support($post_type, ‘trackbacks’);
}
}
});
// Close comments on the front-end
add_filter(‘comments_open’, ‘__return_false’, 20, 2);
add_filter(‘pings_open’, ‘__return_false’, 20, 2);
// Hide existing comments
add_filter(‘comments_array’, ‘__return_empty_array’, 10, 2);
/*
// Remove comments page in menu
add_action(‘admin_menu’, function () {
remove_menu_page(‘edit-comments.php’);
});
*/
// Remove comments links from admin bar
add_action(‘init’, function () {
if (is_admin_bar_showing()) {
remove_action(‘admin_bar_menu’, ‘wp_admin_bar_comments_menu’, 60);
}
});
-
Paste the code snippet into the WPCode editor.
-
In the Code Title field, enter “Disable Comments”.
-
In the Code Type dropdown, select PHP Snippet.
-
Under Insertion, select Auto Insert to ensure the snippet runs site-wide.
-
Click Save Snippet.
Activate the Snippet
-
After saving, toggle the snippet to Active.
-
Verify that the snippet is running by checking its status in the WPCode Snippet Manager.
Verifying the Changes
Front-End Verification
- Visit your website’s pages and posts.
- Ensure that the comment section is no longer visible.
Admin Dashboard Verification
- Navigate to Dashboard > Comments.
- Verify that the Comments menu is no longer accessible (if the optional menu removal code is uncommented).
- Ensure the “Recent Comments” widget is removed from the dashboard.
6.4. Tools and Resources
- WordPress Admin Dashboard.
- WPCode Lite plugin.
- Text editor for modifying and reviewing PHP snippets.
7. Safety and Compliance Measures
Applicable Regulations:
- Ensure compliance with organizational policies regarding user-generated content.
- Back up the website before implementing PHP snippets to prevent unintended issues.
8. Quality Control and Evaluation Metrics
Performance Indicators:
- Comments are fully disabled site-wide.
- No comment-related links or menus are visible in the WordPress Admin Dashboard.
9. Exception and Problem Handling
Common Issues and Solutions:
-
Snippet Not Executing
-
Cause: WPCode Lite plugin is inactive or the snippet is disabled.
-
Solution: Ensure the WPCode Lite plugin is active and the snippet is toggled to Active in the Snippet Manager.
-
-
Comments Menu Still Visible
-
Cause: The optional menu removal code is commented out.
-
Solution: Uncomment the following section in the PHP snippet:
-
-
add_action(‘admin_menu’, function () {
-
remove_menu_page(‘edit-comments.php’);
});
-
Save and activate the snippet again.
-
Comments Form Still Appears
-
Cause: Theme or plugin conflict.
-
Solution: Check your theme’s files (e.g., comments.php) and ensure no hardcoded comment forms exist. Disable other plugins that may override comment settings.
-
10. Documentation and Record Keeping
Documentation Requirements:
- Maintain a record of PHP snippets added via WPCode Lite.
- Document any changes made to the PHP code or plugin settings.
- Backup logs prior to implementation.
11. Procedure Review and Update
Review Frequency:
- Annually or when updates are made to WPCode Lite or WordPress core.
