new add_filter in WP 2.2 breaks some plugins
-
Hi,
I’ve think in WP 2.2 onwards, the add_filter have change in a way that breaks some plugins that is a class and the filter function the plugins ads are member functions. Particularly I’m talking about the post-teaser plugin. Please correct me if I’m wrong because I’m not too familiar with PHP.
In the post-teaser plugin, the call to add_filter to the_content hook is:
add_filter('the_content', array(&$post_teaser, 'process'));
So in the add_filter function in plugin.php the line that adds the filter function is:
wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
The part I thinks breaks the plugin I think is: [serialize($function_to_add)]
The serialize array of a class and a member function used as the index to wp_filter seem wrong to me. So I’ve tried to capture the value of the serialize of the function_to_add and it is:
a:2:{i:0;O:11:”post_teaser”:16:{s:7:”version”;d:3.79999999999999982236431605997495353221893310546875;s:5:”debug”;b:0;s:15:”default_options”;a:8:{s:13:”full_template”;s:166:”Permanent link to this post (%word_image_count%, estimated %reading_time% reading time)”;s:15:”teaser_template”;s:194:”This is a preview of <q>%title%</q>. Read the full post (%word_image_count%, estimated %reading_time% reading time)“;s:6:”target”;s:3:”100″;s:9:”word_mins”;s:5:” mins”;s:9:”word_secs”;s:5:” secs”;s:14:”time_separator”;s:1:”:”;s:11:”zero_counts”;s:1:”0″;s:15:”count_separator”;s:2:”, “;}s:14:”static_options”;a:1:{s:6:”blocks”;s:30:”p|li|dt|dd|address|form|pre|tr”;}s:13:”debug_message”;N;s:13:”full_template”;s:166:”Permanent link to this post (%word_image_count%, estimated %reading_time% reading time)”;s:15:”teaser_template”;s:194:”This is a preview of <q>%title%</q>. Read the full post (%word_image_count%, estimated %reading_time% reading time)“;s:6:”target”;s:3:”100″;s:9:”word_mins”;s:5:” mins”;s:9:”word_secs”;s:5:” secs”;s:14:”time_separator”;s:1:”:”;s:11:”zero_counts”;s:1:”0″;s:15:”count_separator”;s:2:”, “;s:6:”blocks”;s:30:”p|li|dt|dd|address|form|pre|tr”;s:18:”doing_reading_time”;b:1;s:12:”doing_counts”;b:1;}i:1;s:7:”process”;}
I think this is a bug and it stops plugins authors from using OOP to develop their plugins. I would raise a bug if there is a bug system for the public but I couldn’t find one (I assume it is a developers only thing?)
So, the next best thing is to ask for help as to how I would be able to change the call to add_filter so to fix the post-teaser plugin. It seems that the original author has stop developing for it. Does anyone know how that can be done?
- The topic ‘new add_filter in WP 2.2 breaks some plugins’ is closed to new replies.