Support » Requests and Feedback » new add_filter in WP 2.2 breaks some plugins

Viewing 7 replies - 1 through 7 (of 7 total)
  • jasonmez


    As for raising a bug: There’s a ticket system on but see this page in the codex for all the info on reporting bugs.

    Perhaps someone else can be more helpful with the add_filter question. Sorry I can’t be of more help.




    Thanks Jasonmez,

    I’ve manage to find the ticket for the add_filter change. I’ve requested for the developer to have a look at it.




    I really miss Post-Teaser working on WordPress 2.2.1 . (On of my readers had told me that he really likes it. It could be because some of my posts are longer than the layman actually would like to read!)

    Could you post the ticket the you’re following, so that others could follow along as well. I’m not a PHP coder, so it’s not clear to me whether we should expect Post-Teaser to be changed, or whether the WordPress releases will fix everything.

    In the meantime, I’ve been using Evermore.




    Sure thing and here it is

    I would have to say that a __sleep() method should be added to those classes to function with serialize. Another option would be to create a function which calls the class.

    The issue is that you are serializing an array, an object, and an string. It doesn’t seem to me that it is needed. The purpose is so that it is unique. However, with the object, the properties can change and will change at some point. Therefore, you might end up adding two or more at some later point depending on how it is set up and if you change any properties before hooking to another action or filter.

    First Option use __sleep() method:

    function __sleep()
    return get_class($this);

    What this does, is return the name of the class, which will be serialized. It won’t interfere with the rest of the code, because it is not being serialized.
    $wp_filter[$tag][$priority][serialize($function_to_add)][‘function’ ] is called with call_user_func(), it will work like it would normally.

    Second Option Use static version:

    array(‘class_name’, ‘method_name’)

    The only downside is that the method can not use $this, because it will be called statically. So instead of using $this, use self::.

    I should make the assumption that you are using PHP 4, since you are referencing the object and that isn’t needed in PHP 5.

    Hi santosj,

    I understand what you are saying but the code I’ve included in my initial post is not mine. The code belongs to WordPress in plugin.php.

    The only code I’ve included that belongs to Post Teaser is:

    add_filter('the_content', array(&$post_teaser, 'process'));

    Hope that clears up the confusion.

    Anyway, I’ve decided and have made changes to Post Teaser to work with WP 2.2.x. What I did was to add a wrapper function that would call the member function of the post-teaser class. The change seems to work fine in WP 2.2.x and have since been released. However, I’m not sure that is the best thing to do.

    I know. I’ve fixed the problem and applied a patch to the Trac ticket, but it hasn’t been approved yet. You can apply the patch manually and it fixes the issue in add_filter and remove_filter.

    The only issue is that my solution is slower. Whereas serialize is log(O) or consist, mine isn’t. You have to decide whether you want something that is fast or something that works. if you (or whoever) used functions or a registry model for variables, it might be easier.

    From my testing, there are a lot of bugs (and/or inconsistencies) in plugin.php. That it works, means it was tested with functions with objects only as an afterthought.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘new add_filter in WP 2.2 breaks some plugins’ is closed to new replies.