Per Søderlind

I code for fun

  1. wp-plugins
  2. WordPress plugin: Remove "Comments are closed"

WordPress plugin: Remove “Comments are closed”

On posts where comments are closed, the plugin will remove the text ‘Comments are closed.’ The plugin supports any languages/text domains, and will remove the text from themes and plugins.

Prerequisite: Since the plugin is filtering gettext, your theme/plugin must be localized.

The plugin is available in the WordPress plugin directory


Plugin source code:
[php]
<?php
/*
Plugin Name: Remove "Comments are closed"
Plugin URI: http://soderlind.no/archives/2012/01/11/wordpress-plugin-remove-comments-are-closed/
Description: On posts where comments are closed, the plugin will remove the text ‘Comments are closed.’ The plugin supports any languages/text domains, and will remove the text from themes and plugins.
Author: Per Soderlind
Version: 1.2
Author URI: http://soderlind.no/
*/

add_filter(‘gettext’, ‘ps_remove_comments_are_closed’, 20, 3);

function ps_remove_comments_are_closed($translated_text, $untranslated_text, $domain) {
if ( $untranslated_text == ‘Comments are closed.’ ) {
return ”;
}
return $translated_text;
}
?>
[/php]

Changelog:

  • 1.2 removed unnecessary code
  • 1.1 initial public release

Previous

Adding custom headers to the WordPress plugin directory

Next

Adding WP-PageNavi to the Yoko theme

27 Comments

  1. I intstalled this Plugin. The “Comments Are Closed” tag still remains on my blog. Can you please help here.

  2. Alex

    If I want my WP theme to be only English do i need to localize to? I am a very beginner and the article you are referring for localization is too difficult to implement. I just want to remove comments are closed without touching any code. why can;t i do it? thank you.

    • PerS

      Hi Alex,

      No you don’t have to localize it yourself, but you must choose a theme that has localization code. If the text in the theme is wrapped in __() or _e() functions, you are fine.

      If you give me the url to where you found the theme, I can check this for you.

      Btw, the default themes, Twenty Ten an Twenty Eleven, has localization code.

  3. Joe

    I installed, it, on newest version of WP, it appears it set my site to use a static home page, then I tried to de activate it, and it seems on de activation, it does not revert everything it did?

    • PerS

      It doesn’t do anything to wordpress db etc, so turning it off will remove it.

      What’s the theme you’re running ? Are you running any caching plugins ? Any other new plugins added lately?

  4. Joe

    Hi. I tried it with the mainstream (woo themes) theme and it did not work.
    No no other plugins, no caching plugins. Yours is the only one activated.
    So I take it, when you de activate it, it does not revert the changes it made? Tks

    • PerS

      Most of the themes have their “internal plugins” aka THEMEFOLDER/functions.php, so for me to be able to see if there’s a conflict, I need to know which woo theme you’re using.

      The plugin (see code above) only filters gettext, the only reason that it doesn’t revert when you switch the plugin off is that your wordpress / theme is caching the output.

  5. Doesn’t work with the Flexibility theme, is it because they use different text – “Comment Off”

    • PerS

      You can change the text using the plugin editor (/wp-admin/plugin-editor.php?file=remove-comments-are-closed/ps_remove_comments_are_closed.php)

    • PerS

      ..or, instead of using my plugin, you can add the following to the (child ) theme functions.php:

      [php]
      add_filter(‘gettext’, ‘ps_remove_comments_are_closed’, 20, 3);

      function ps_remove_comments_are_closed($translated_text, $untranslated_text, $domain) {
      if ( $untranslated_text == ‘Comment Off’ ) {
      return ”;
      }
      return $translated_text;
      }
      [/php]

  6. The Plugin Spam Free WordPress has a comments.php file in it’s folder. Removing that file solved the problem on my blog

  7. Thanks for the plugin by it does not working for me. Using template monster’s template

    • PerS

      “not working for me” .. what’s not working ? If the text in monster’s template is different than the default; instead of using the plugin, add the routine to your (child) theme functions.php as described above

  8. Thank you for the reply but I’m not a programmer and I thought this plugin will do the work without getting into the code. “Not working” as this plugin does not remove the comments text. Can you assist?

  9. Hi,
    I installed the pluign but the text “comments closed” still shows up.
    My theme is Bombax and I have no idea if it is localized or not.
    Here you are my website:
    http://www.freereporter.info
    I would be grateful if you could help

    Cheers

    Stefano

  10. martin hugels

    Crap.
    Destroyed everything. Had to install everything new.

    • PerS

      There is no reason why this simple plugin will destroy anything. Read the code and you’ll see that I’m right.

  11. Andy Suarez

    It is not working for me. Can you pls check it out.

    • PerS

      I checked your site, but I couldn’t find “comments are closed”. Where’s the problem ?

  12. Hello. I’m using WordPress 3.8.2, just uploaded my draft site and installed your plugin to “remove comments closed”. My themes are made in Artisteer. I wonder if Artisteer or 3.8.2 is not compatible with your plugin, as the link has not disappeared.

    Thank you.

  13. Adam Kaktruska

    Hi, It does not work for me. I am using localized theme gamepress, and disable comments plugin, but your plugin does not work for me :/

    • Per Søderlind

      If your theme doesn’t have the exact text `Comments are closed.`it will not work, but as I’ve mentioned in the comments above, you can add the code to the (child) theme function.php and add the text you want to remove.

  14. You have to find out what Text is in the .po file !!!!
    Search für “Comment Off” or whatever appears on your website as “Comment Off” text!
    Then the PlugIn works fine. I promise :)
    It looked like this in my language.po file: “Comments Off on %s”

    Thanx 4 the PlugIn!

    Regards,
    Axel

Leave a Reply

Powered by WordPress & Theme by Anders Norén