php 致命错误:未捕获的错误:在激活WordPress插件时调用未定义的函数create_function()

ahy6op9u  于 2023-03-21  发布在  PHP
关注(0)|答案(1)|浏览(122)

我在激活我的WordPress网站中的插件时出错
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
我想我得重写一个密码

$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 );

有人能帮帮我吗?

h43kikqp

h43kikqp1#

create_function()已从php 8中删除。网络罪犯发现它太容易被黑客攻击了。
对于您显示的代码来说,这不是必需的。您可以尝试在调用add_action()时使用anonymous function,如下所示。(未调试)

add_action( $location, function () use ( $location ) {
    global $woocommerce_product_options_order_option_group;
    $woocommerce_product_options_order_option_group->print_order_options
       ( $location );
    return;
});

use ( $location )子句使该变量可以从函数外部在函数内部访问。

相关问题