functiondeprecatedcreate-function

Deprecated: Function create_function() is deprecated PHP 7.2


add_filter( 'option_page_capability_' . ot_options_id(), create_function( '$caps', "return '$caps';" ), 999 );

How to write this correctly so that there is no error:

Deprecated: Function create_function() is deprecated


Solution

  • Use an anonymous function:

    add_filter( 'option_page_capability_' . ot_options_id(), function($caps) {return $caps;}, 999 );
    

    Keep in mind that this will have different functionality to your code, as your code substitutes $caps in function definition, which is buggy and asking for a code injection.