Thread Starter
msteel
(@msteelnapcocom)
Also, around 141 I had to update to this:
$callback = $this->actions[$action]['callback'];
if ( is_array( $callback ) ) {
if (method_exists( $callback[0], $callback[1] ) ) {
call_user_func_array(array($callback[0], $callback[1]), $post_ids);
}
} else {
$this->actions[$action]['callback']($post_ids);
}
Don’t get me wrong, it’s a great plugin, I just needed to expand it a bit.
Thanks!
Is there a way to avoid anonymous functions altogether taking into consideration the fact that my hosting company has PHP 5.2.17 and therefore even after applying the tweak suggested I cannot initialize the bulk actions in functions.php.
Thank You
Hi bogdan.melinte, you should be able to just use the name of the in place of an anonymous function. Here is “ACTION EXAMPLE 1” without using an anonymous function:
// ACTION EXAMPLE 1:
function wp6215656_bulk_actions_callback( $post_ids ) {
if ( ! is_array( $post_ids ) || ! count( $post_ids ) ) {
return false;
}
foreach ( $post_ids as $post_id ) {
update_post_meta( $post_id, '_property_status', 'sold' );
}
return true;
}
$bulk_actions->register_bulk_action( array(
'menu_text' => 'Mark as sold (Myyty)',
'admin_notice' => 'Properties marked as sold',
'callback' => wp6215656_bulk_actions_callback,
) );
Please note that the name of the callback function is not quoted and does not have parenthesis.