Reputation: 11
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,
Upvotes: 0
Views: 2092
Reputation: 15009
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"); } );
Upvotes: 1
Reputation: 9342
Try this code
add_action( 'widgets_init', 'custom_widget_func');
funcation custom_widget_func(){
register_widget( "Woocommerce_Header_Cart" );
}
Upvotes: 2