PJ Studio
PJ Studio

Reputation: 21

Woocommerce, PHP 7.2 Function create_function() is deprecated

When i activate Woocommerce plugin website giving 500 server error. I've activate debug mode.

PHP Deprecated: Function create_function() is deprecated in /var/www/vhosts/WEBSITENAME/httpdocs/wp-content/plugins/features-by-woothemes/classes/class-woothemes-widget-features.php on line 308

That's 308 line:

add_action( 'widgets_init', create_function( '', 'return register_widget("WooThemes_Widget_Features");' ), 1 );

How to fix it???

Upvotes: 2

Views: 3209

Answers (1)

Jan Myszkier
Jan Myszkier

Reputation: 2744

just replace the mentioned line with:

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

OH and by the way, if that works, please prepare a PR with the fix in: https://github.com/woocommerce/features/pulls then contact the author on https://wordpress.org/support/plugin/features-by-woothemes to merge it in

Upvotes: 1

Related Questions