create_function is deprecated

code php wordpress

Php function ‘create_function‘ has been deprecated as of PHP 7.2.0.

So, while initializing widget I used to do this,

add_action( 'widgets_init', create_function( '', 'register_widget("Widget_Name");' ) );

Now, replacing deprecated function,

add_action(
    'widgets_init',
    function() {
        register_widget( 'Widget_Name' );
    }
);

 

create_function is deprecated

Leave a Reply

Your email address will not be published.

Scroll to top