Support » Plugin: Code Snippets » ‘PHP Deprecated’ Messages

  • Resolved slomeli79


    Functionality doesn’t seem to be impacted (that I can tell), but I’m seeing this in logs:

    PHP Deprecated: Function create_function() is deprecated in /.../wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()'d code on line 1

    Line 352 of snippet-ops.php is:

    $result = eval( $code );

    • This topic was modified 2 years, 3 months ago by slomeli79.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge


    This message is coming from one of your snippets that is using the outdated create_function() function.

    If you are able to look through your snippets and locate the one that is causing the error, then I would be happy to help you update it to be compatible with newer versions of PHP.

    Got it. I had to change one of my go-to snippets.
    add_filter( 'jpeg_quality', create_function( '', 'return 100;' ) );


    function custom_jpeg_quality() { return 100; }
    add_filter( 'jpeg_quality', 'custom_jpeg_quality', 10, 2 );
    Plugin Author Shea Bunge


    Good to see that you could fix the problem.

    For reference, here’s another way that you could rewrite that snippet:

    add_filter( 'jpeg_quality', function ( $quality ) { return 100; } );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘‘PHP Deprecated’ Messages’ is closed to new replies.