Function create_function() is deprecated – PHP 7.2.0
-
I’m getting this PHP warning message on my logs:
PHP Deprecated: Function create_function() is deprecated in /var/www/[snip]/wp-content/plugins/nextcellent-gallery-nextgen-legacy/widgets/class-ngg-slideshow-widget.php on line 175
It relates to the last lines in the three widget files
/widgets/class-ngg-gallery-widget.php
/widgets/class-ngg-media-rss-widget.php
/widgets/class-ngg-slideshow-widget.phpAn example line :
add_action('widgets_init', create_function('', 'return register_widget("NGG_Media_RSS_Widget");') );
The PHP manual says :
Warning This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.
(My host said they were going to upgrade to 7.2).
I don’t actually use these widgets, but I also don’t like clogging my logs, so here’s a workaround example (for the class-ngg-media-rss-widget.php file)…
Comment out the ‘add_action’ line (above)
Append the following lines :/** * Register NGG Media RSS widget * * */ function ngg_register_media_rss_widget() { register_widget( 'NGG_Media_RSS_Widget' ); } add_action( 'widgets_init', 'ngg_register_media_rss_widget' );
The widget still appears on my ‘Appearance/Widgets’ file
Similar treatments to the other two files (using unique function names, of course) should resolve the issue.If anyone has a better solution, please feel free to chime in ??
- The topic ‘Function create_function() is deprecated – PHP 7.2.0’ is closed to new replies.