I got an error while activating a plugin in my WordPress website
Fatal error: Uncaught Error: Call to undefined function create_function() in /home4/seosexey/gifting.icowebtech.com/wp-content/plugins/woocommerce-product-options/includes/order-option-group.php:33 Stack trace: #0 /home4/seosexey/gifting.icowebtech.com/wp-content/plugins/woocommerce-product-options/includes/order-option-group.php(364): Woocommerce_Product_Options_Order_Option_Group->__construct() #1 /home4/seosexey/gifting.icowebtech.com/wp-content/plugins/woocommerce-product-options/woocommerce-product-options.php(22): require_once('/home4/seosexey...') #2 /home4/seosexey/gifting.icowebtech.com/wp-admin/includes/plugin.php(2314): include_once('/home4/seosexey...') #3 /home4/seosexey/gifting.icowebtech.com/wp-admin/plugins.php(192): plugin_sandbox_scrape('woocommerce-pro...') #4 {main} thrown in /home4/seosexey/gifting.icowebtech.com/wp-content/plugins/woocommerce-product-options/includes/order-option-group.php on line 33
I guess I need to rewrite a code
$func = create_function( '',
'global $woocommerce_product_options_order_option_group; $woocommerce_product_options_order_option_group->print_order_options( "' . $location . '"); return;' );
};
add_action( $location, $func );
Can someone help me?
create_function() has been removed from php 8. Cybercriminals found it far too easy to hack.
It's not necessary for the code you showed us. You can try using an anonymous function in your call to add_action(), like this. (Not debugged.)
add_action( $location, function () use ( $location ) {
global $woocommerce_product_options_order_option_group;
$woocommerce_product_options_order_option_group->print_order_options
( $location );
return;
});
The use ( $location )
clause makes that variable from outside the function accessible inside the function.