10up / 10up-experience

The 10up Experience plugin configures WordPress to better protect and inform clients, aligned to 10up’s best practices.
GNU General Public License v2.0
129 stars 27 forks source link

Disable comments and comments related UI #154

Closed sksaju closed 3 weeks ago

sksaju commented 6 months ago

Description of the Change

Closes https://github.com/10up/10up-experience/issues/152

How to test the Change

Changelog Entry

Added - New feature Changed - Existing functionality Deprecated - Soon-to-be removed feature Removed - Feature Fixed - Bug fix Security - Vulnerability

Credits

Props @username, @username2, ...

Checklist:

sksaju commented 6 months ago

@darylldoyle I've removed comments support from every post type, but please let me know if it should be specified! Thanks

sksaju commented 5 months ago

@sksaju thanks for your work on this! This is a great start, removing the UI elements from the admin, but this should also disable the comments form etc on the front end of the site.

See something like https://keithgreer.dev/wordpress-code-completely-disable-comments-using-functions-php/ for inspiration.

I also wonder if we should make it an option within the admin UI, whether they're enabled or not 🤔

Thanks for your feedback @darylldoyle, I've updated the PR, please retake a look. Thanks

claytoncollie commented 4 months ago

@sksaju @darylldoyle Is it too late to request an additional feature? It would be nice to provide a filter to set the option value as well as a wp-config constant to also set this value. Meaning that we can disable or enable comments in three places; wp-config, themes or plugins, and the wp-admin. I've done something similar in a personal plugin that might help explain the idea.

https://github.com/claytoncollie/tracking-code-for-google-analytics/blob/master/inc/tracking-id.php

claytoncollie commented 4 months ago

@sksaju @darylldoyle Is this PR only to handle UI elements or be something a bit more comprehensive like some of the open source plugins? If more comprehensive, I suggest looking through the code from Uncomment. It is built by a 10upper, Barry Ceelen, and takes into account blocks, queries, UI, admin, and frontend. I have used it on a few sites and really like it.

darylldoyle commented 3 weeks ago

@claytoncollie, thanks for the feedback! Can you check if this now solves your concerns? I've added in logic to remove the comment blocks and widgets when comments are disabled and I've added a const and filter that allow you to disable it other ways (I appreciate the sample there)

claytoncollie commented 3 weeks ago

@darylldoyle Very nice. Thank you for the additions.