Mastodon

Jan MT Mc Kell

Web . Write . WP.

Deprecation of create_function

If you get this error whilst working with WordPress:
“Deprecated: Function create_function() is deprecated in…”, the following advice works:

“It addresses the add_filter statement:

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

switch it out, and use this instead:

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

We can see the usage of function(), very typical function creation instead of a deprecated create_function() to create functions. Hope it helps.”

I originally found a solution to this error log issue here:

https://stackoverflow.com/questions/48161526/php-7-2-function-create-function-is-deprecated