anonymous function could be an action
-
Great!
I had trouble with the anonymous callback function so I replaced it with a
do_action(). My application is to bulk tag a custom post type withwp_set_post_terms( $id, $tag, 'foo-custom-taxonomy', true );Putting that in an anonymous callback failed in some mysterious way.
I think it is easier and cleaner to change the plugin as follows (version 0.1.1):
Delete line 64:
$func["callback"] = $callback;Delete lines 146 – 159:
if (version_compare(PHP_VERSION... else ... }Add this line after the deleted line 159:
do_action( "seravo_custom_bulk_action_{$action}", $post_ids );Then in you application, instead of specifying a callback in register_bulk_action(), add an action to your code:
add_action( "seravo_custom_bulk_action_{$action}", 'foo' ); function foo( $post_ids ) { // whatever you had in your anonymous callback }My
foois actually in class, soarray( $this, 'foo' ). Maybe the class methods in my anonymous callback caused it to fail. Works now. And no PHP version checking is needed.
The topic ‘anonymous function could be an action’ is closed to new replies.