0

I'm trying to maintain compatibility of a crucial WordPress plugin (jQuery Vertical Accordion Menu) on my site.

There's one line in the plugin code that breaks the site with PHP 8.0:

add_action('widgets_init', create_function('', 'return register_widget("dc_jqaccordion_widget");'));

The problem is that the create_function() method has been removed from PHP 8.0 due to it being based on the eval() function which has security issues. Apparently, there's a way to rewrite this line to use an anonymous function instead of calling create_function(), but I don't know PHP.

How can I re-write this line to maintain functionality, but avoid using the create_function method?

boguslavsky
  • 155
  • 1
  • 7
  • Does this help? https://lindevs.com/function-create_function-has-been-removed-in-php-8-0/ – outlaw Mar 21 '22 at 16:47
  • 1
    If you don't know _any_ PHP, then go find someone who does and buy them a beer to do this for you. If you know _some_ PHP, or even just some programming in general, then [there's documentation on anonymous functions here](https://www.php.net/manual/en/functions.anonymous.php) and what you've got there is about the simplest case possible. – IMSoP Mar 21 '22 at 16:53

0 Answers0