testimonials
testimonials copied to clipboard
create_function() was deprecated in PHP 7.2
Since PHP 7.2 this plugin throws the following PHP Warning:
PHP Deprecated: Function create_function() is deprecated in /wp-content/plugins/testimonials-by-woothemes/classes/class-woothemes-widget-testimonials.php on line 270
Link to PHP Documentation with deprecation notice: http://php.net/manual/en/function.create-function.php
Solution stated in the docs are anonymous functions http://php.net/manual/en/functions.anonymous.php
If you need to upgrade more create_function
cases, Rector does it pretty well.
this looks like a pretty easy swap, but maybe I'm missing something:
in /testimonials-by-woothemes/classes/class-woothemes-widget-testimonials.php
replace line 270
add_action( 'widgets_init', create_function( '', 'return register_widget("Woothemes_Widget_Testimonials");' ), 1 );
with
add_action( 'widgets_init', function() { return register_widget("Woothemes_Widget_Testimonials"); }, 1 );
though the only testing I've done is to run it with error reporting on, and I'm not getting any errors or warnings anymore.