Skip to content

TABARC-Code/post-discussion-toggle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Post Discussion Toggle

Fine-grained comment and ping control for WordPress, without the usual noise.

What this is

This plugin lets me override WordPress’ global Discussion settings on a per-post basis.

Per post. Per page. Per any public post type that supports comments.

Sometimes I want comments off across the whole site but open on one key article.
Sometimes I want the opposite.
Core WordPress makes that possible, but not exactly obvious or consistent, especially once Gutenberg gets involved.

So I wired in a clean, explicit override layer.

For each supported post type, I get:

  • Comments:

    • Use global setting
    • Always allow
    • Always disallow
  • Pings / trackbacks:

    • Use global setting
    • Always allow
    • Always disallow

If I don’t touch anything, the global Discussion settings keep doing their job.
If I do, my choice wins.

No settings page. No JS build step. No “options framework”. Just a small meta box that does the work.


Features

  • Per-post and per-page overrides for:
    • Comments
    • Pings / trackbacks
  • Automatically available on all public post types that support comments.
  • Keeps the database clean:.
    • “Use global setting” is never stored as meta.
  • Defensive coding:
    • Nonces, capability checks, sanitisation.
  • Works in Classic Editor and Block Editor.
  • No front-end templates, no theme lock-in.

Installation

  1. Drop the folder into wp-content/plugins/post-discussion-toggle
    or clone the repository there.
  2. Activate Post Discussion Toggle in the WordPress admin.
  3. Edit any post, page., or other public post type that supports comments.
  4. In the sidebar, look for Discussion controls.
  5. Pick what you want:
    • Use global setting
    • Always allow
    • Always disallow

That’s it. No extra setup..


How it behaves

  • If I set Use global setting, the plugin deletes any override meta and lets WordPress decide.
  • If I set Always allow, the plugin forces comments_open() / pings_open() to return true for that post.
  • If I set Always disallow, the plugin forces them to return false.

The override is applied using the comments_open and pings_open filters, so anything that respects those (themes, plugins, core) will see the correct state.

If a theme bypasses the proper APIs and hardcodes logic, that’s on the theme.


Customisation ideas

Things I may or may not add later:

  • A small settings page for:
    • Per post-type defaults (e.g. pages closed by default, posts open by default).
  • Quick Edit / Bulk Edit support so I can flip lots of posts in one go.
  • Gutenberg sidebar panel using register_post_meta() with show_in_rest.

The current version deliberately stays minimal so it doesn’t drag unnecessary complexity into simple sites.


Known caveats

  • Trackbacks are a legacy thing. The plugin still respects them for the handful of use cases where they matter. or might in the future.
  • If another plugin or theme aggressively overrides comments_open() or pings_open() after my filters, it can win. That’s how the hook system works.

Folder structure

post-discussion-toggle/
├── post-discussion-toggle.php
├── README.md
├── CHANGELOG.md
├── LICENSE
├── .gitignore
└── languages/
    └── (placeholder for translation files)

About

Per-post controls to force comments and pingbacks on or off, overriding global Discussion settings. I made iit as got sick of going through and forgetting to click. AdHD it happens.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages