How to add an anonymous function in wordpress hooks by removing create_function

Currently I have the code below which I would like to replace create_function with some anonymous function.

How can this be done?

add_action('widgets_init', create_function('',  
    'return  register_widget("time_more_on_time_widget");'
));

1 Answer
1

The create_function is already an anonymous function, what/why would you like to change? (php.net)

Some other way to do something is (although untested):

$anon_func = function() {
    return register_widget("time_more_on_time_widget");
}

add_action('widgets_init', $anon_func );

Leave a Comment