0

I have used create_function in my theme below.

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

But for PHP 7.3.0, the create_function() is deprecated.

Any idea, how to fix my codes above on PHP 7.3.0.

Thanks for your help,

1

2 Answers 2

2

Try this code

add_action( 'widgets_init', 'custom_widget_func');

funcation custom_widget_func(){
    register_widget( "Woocommerce_Header_Cart" );
}
Sign up to request clarification or add additional context in comments.

Comments

1

Replace

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

with this, using an anonymous function instead :

add_action( 'widgets_init', function() { return register_widget("Woocommerce_Header_Cart"); } );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.