5

I upgraded from PHP 5.3 to 7.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!

0

1 Answer 1

14

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");
} );
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.