【问题标题】:Woocommerce, PHP 7.2 Function create_function() is deprecatedWoocommerce,PHP 7.2 函数 create_function() 已弃用
【发布时间】:2019-04-03 07:35:10
【问题描述】:

当我激活 Woocommerce 插件网站时出现 500 服务器错误。我已激活调试模式。

PHP 已弃用:函数 create_function() 在第 308 行的 /var/www/vhosts/WEBSITENAME/httpdocs/wp-content/plugins/features-by-woothemes/classes/class-woothemes-widget-features.php 中已弃用

这是 308 行:

add_action( 'widgets_init', create_function( '', 'return register_widget("WooThemes_Widget_Features");' ), 1 );

怎么解决???

【问题讨论】:

  • 当你用谷歌搜索你的确切标题时会弹出一些解决方案,但没有一个真正有很多“开箱即用的解决方案”。因此,请尝试升级您的 Woocommerce。这可能是您暂时抑制错误的少数情况之一。
  • @Martijn 我已经升级了 Woocommerce 它没有帮助

标签: php wordpress woocommerce


【解决方案1】:

只需将上述行替换为:

add_action( 
    'widgets_init', 
    function () { 
        return register_widget("WooThemes_Widget_Features");
    }, 
    1 
);

哦,顺便说一下,如果可行,请准备一份 PR,其中包含以下修复: https://github.com/woocommerce/features/pulls 然后联系作者 https://wordpress.org/support/plugin/features-by-woothemes 合并到

【讨论】:

  • 它不起作用:C 调试重复函数 create_function() 在 308 行中已弃用
  • 这是错误的,你刚刚用我的代码替换删除了创建函数。要么你告诉我不同​​的代码位置(错误应该提到 excat 位置 - 也许插件中有更多对 create_function 的调用?),或者你没有替换第 308 行的代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-05-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多