WordPress 3.0 and add_action

It seems as though, with WordPress 3.0, the add_action function (in some cases) has become a little more strict. Tag Grouping has a call to save_post that worked perfectly in WordPress 2.9 and up but broke completely once WordPress 3.0 came out. After some research I found that you needed to pass in an array instead of just your function. The array I used consisted of a reference to the class containing the function I was going to use along with the function name, see below:

add_action ( ‘save_post’, Array(&$update, ‘update_group_posts’) );

Prior to WordPress 3.0 this same call looked like:

add_action ( ‘save_post’, ‘update_group_posts’ );

What I had to do in order to make this WordPress 3.0 compatible was wrap the functions I needed in a class. Instantiate that class inside the Main function of my plugin and then pass that instantiated name along with the function name to the save_post action.

Facebook Twitter Linkedin

Related posts:

  1. Adding AJAX to your WordPress plug-in
  2. Update to Tag Grouping for WordPress 3.0
  3. Tag Grouping v1.1 – Beta out!
  4. Tag Grouping V1.2 & v1.3!
  5. WordPress Plugin – Grouping Your Tags (PHP5 and MySQL)

About Mike

I am a Software Quality Assurance Professional that recently graduated college with a Bachelor's of Science in Computer Information Systems.
This entry was posted to the following categories: HTML, MS-SQL, MySQL, PHP, Tag Group Plug-in, Wordpress. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>