Support » Plugin: Ultimate Posts Widget » Getting deprecated function notices

  • PHP is reporting that create_function() is deprecated, in lines 146 and 150 of ultimate-posts-widget.php. PHP 7.2

Viewing 7 replies - 1 through 7 (of 7 total)
  • Change line 146 to this:

    	  $new_excerpt_more = function($more) {
    		  return '...';

    Then change line 150 (now line 152) to this:

    	  $new_excerpt_length = function($length) {
    		  return $excerpt_length;


    I did what you have said here, but I receive a new error then:
    Notice: Undefined variable: excerpt_length in
    wp-content/plugins/ultimate-posts-widget/ultimate-posts-widget.php on line 150

    Can you help out with that?



    Yep there’s a typo in this, the lower one should read:

             $new_excerpt_length = function($length) {
    		  return $new_excerpt_length;

    Okay, now I get an error again:
    Notice: Undefined variable: new_excerpt_length in /wp-content/plugins/ultimate-posts-widget/ultimate-posts-widget.php on line 150

    So what am I doing wrong?

    What is the latest version of php the pugin runs with?

    Sorry, thought this was for a different plugin, I don’t know

    • This reply was modified 10 months, 2 weeks ago by  Venutius.

    @zsujoker You have to tell the function to use the variable from the parent scope. The earlier answer is partially correct, but this form of the function works:

    $new_excerpt_length = function($length) use ($excerpt_length){
            return $excerpt_length;

    I submitted a pull request to the plugin developer to fix it, hopefully he’ll update it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Getting deprecated function notices’ is closed to new replies.