4
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

Kirk Beard
  • 9,569
  • 12
  • 43
  • 47
  • 1
    Possible duplicate of [PHP 7.2 Function create\_function() is deprecated](https://stackoverflow.com/questions/48161526/php-7-2-function-create-function-is-deprecated) – miken32 Dec 18 '18 at 00:50

1 Answers1

4

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.

wizzwizz4
  • 6,140
  • 2
  • 26
  • 62