testimonials icon indicating copy to clipboard operation
testimonials copied to clipboard

create_function() was deprecated in PHP 7.2

Open michakrapp opened this issue 6 years ago • 2 comments

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

michakrapp avatar Mar 26 '18 17:03 michakrapp

If you need to upgrade more create_function cases, Rector does it pretty well.

TomasVotruba avatar Dec 16 '18 01:12 TomasVotruba

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.

SD-dthompson avatar Feb 08 '19 16:02 SD-dthompson