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");'

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 );
  • 2
    i would like to replace all instances of create_function as its a secuirty concern after php 5
    – YLN
    Jul 3 '14 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.