How to Fix PHP Deprecated: Function create_function() is deprecated
15,391
create_function was used to create anonymous function. So you can simply change it to function() {}
In example:
instead
add_action( 'widgets_init', create_function( '', 'register_widget("layerslider_widget");' ) );
use
add_action( 'widgets_init', function() {
register_widget("layerslider_widget");
} );
Related videos on Youtube
Author by
Ctichicago
Updated on June 04, 2022Comments
-
Ctichicago almost 2 years
I upgraded from
PHP
5.3
to7.2
and am getting the following error on 2 lines of code:PHP Deprecated: Function create_function() is deprecated
I searched the forum and tried various forms of code, but none of them worked.
Code 1:
add_action( 'widgets_init', create_function( '', 'register_widget("layerslider_widget");' ) );
Code 2:
add_action( 'widgets_init', create_function( '', 'register_widget( "advanced_featured_page_widget" );' ) );
Thanks for your assistance!