• Hi All,

    I’m developing my first plugin which changes some functionality using the comments_open hook. No problems there, worked great on my local install.

    However, I tried it on a live 2.8 site and it didn’t work, in this case because the theme didn’t use comments_open()

    Instead the theme used ('open' == $post-> comment_status) which as far as I can tell does exactly the same thing, but without allowing plugins to hook in. I’m guessing this was a nice up-to-date 2.8 site but using an older theme.

    So my question is…

    Is this anything to worry about when releasing a plugin? I managed to get this site working by changing the theme to use comments_open(), but I was wondering if there was a way I could hook into $post-> comment_status directly as well, just to make sure the plugin works. Is this a case of it being the site-owners job to upgrade their theme or is there something I can do as the plugin developer to make their job easier?

    Any feedback appreciated.

    Harvey.

Viewing 1 replies (of 1 total)
  • I was wondering if there was a way I could hook into $post-> comment_status directly as well

    I doubt that you can hook into the $post->comment_status way of doing things, simply because it’s not a function call, its an instance property. It’s theoretically possible to execute code from magic methods in PHP 5 (using php’s __get and __set) but that’s not how it’s implemented. $post is an instance of stdClass, created using $post = new stdClass; I believe.

    See https://www.php.net/manual/en/language.oop5.overloading.php for more information.

Viewing 1 replies (of 1 total)
  • The topic ‘comments_open vs $post->comment_status’ is closed to new replies.