I got the following warning on my website: Deprecated: Function create_function() is deprecated it was being thrown by themes\bone\inc\widgets\minimaldog-post-list-widget.php on line 168 . Here is the fix for it.

Similar warnings popped up in the following files, lines:

  • minimaldog-post-list-widget.php on line 168
  • minimaldog-popular-widget.php on line 191
  • minimaldog-post-slider-widget.php on line 112
  • minimaldog-categories-widget.php on line 107
  • minimaldog-post-review-list-widget.php on line 187
  • minimaldog-ad-widget.php on line 82
  • minimaldog-social-widget.php on line 43

I didn’t see any fixes for it online so I went ahead and fized it myself. The root of this is that in PHP 7.2 the function called “create_function” to create anonymous functions has been deprecated. You can now create anonymous functions by typing them out function($var){ ... }

So basically this

create_function( '$hey', "return '$hey';" )
//becomes
function($hey){return $hey);

So in our case on minimaldog-post-list-widget.php on line 168:

// this line
// add_action('widgets_init', create_function('', 'return register_widget("md_posts_list_widget");'));

//becomes
add_action('widgets_init', function(){return register_widget("md_posts_list_widget");});

and so on for the rest:

// in minimaldog-post-review-list-widget.php

// add_action('widgets_init', create_function('', 'return register_widget("md_post_review_widget");'));
add_action('widgets_init', function(){return register_widget("md_post_review_widget");});


// in minimaldog-post-slider-widget.php

// add_action('widgets_init', create_function('', 'return register_widget("md_posts_slider_widget");'));
add_action('widgets_init', function(){return register_widget("md_posts_slider_widget");});


// in minimaldog-social-widget.php

// add_action('widgets_init', create_function('', 'return register_widget("md_social_widget");'));
add_action('widgets_init', function(){return register_widget("md_social_widget");});


// in minimaldog-popular-widget.php

// add_action('widgets_init', create_function('', 'return register_widget("md_popular_widget");'));
add_action('widgets_init', function(){return register_widget("md_popular_widget");});



// in minimaldog-categories-widget.php

// add_action('widgets_init', create_function('', 'return register_widget("md_categories_widget");'));
add_action('widgets_init', function(){return register_widget("md_categories_widget");});



//in minimaldog-ad-widget.php

// add_action('widgets_init', create_function('', 'return register_widget("md_ad_widget");'));
add_action('widgets_init', function(){return register_widget("md_ad_widget");});

I hope this helps, Cheers!

Lehel