【问题标题】:Wordpress Fatal Error - Cannot Make non Static Method StaticWordpress 致命错误 - 无法将非静态方法设为静态
【发布时间】:2021-03-29 07:28:32
【问题描述】:

抱歉,这听起来像是一个愚蠢的问题。昨天我更新了我的 Wordpress 插件,突然一切都崩溃了,返回了一个致命错误。我正在尝试通过恢复模式重新激活网站,但我无法恢复主题核心插件的活动,因为它返回此错误

An error of type E_COMPILE_ERROR was caused in line 130 of the file /var/www/wptbox/wp-content/plugins/lastudio/includes/extensions/swatch/class-lastudio-swatch-widget.php. Error message: Cannot make non static method WC_Widget_Layered_Nav::get_main_search_query_sql() static in class LaStudio_Swatch_Widget

在安全模式下,我的网站页脚消失了,网站每个页面中展示的所有产品也消失了。这些产品仍然存在于 WooCommerce 中,但展示网格已被完全删除。 我能做什么?

非常感谢您的热心帮助。

【问题讨论】:

    标签: php wordpress wordpress-theming


    【解决方案1】:

    可能与Fatal error: Cannot make non static method 重复

    代码参考是:https://woocommerce.github.io/code-reference/files/woocommerce-includes-widgets-class-wc-widget-layered-nav.html#source-view.429

    您可以联系插件开发人员处理此错误。

    临时解决方案是:

    转到文件/var/www/wptbox/wp-content/plugins/lastudio/includes/extensions/swatch/class-lastudio-swatch-widget.php上的130

    {class name}::get_main_search_query_sql() 更改为\WC_Query::get_main_search_query_sql()

    【讨论】:

    • 我现在正在尝试这样做。如果我理解正确,我必须更改“$_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();”使它变成“$_chosen_attributes = \WC_Query::get_layered_nav_chosen_attributes();”?非常感谢您的友好回复
    • 取决于类文件,命名空间内的类,是否已导入WC_Query类。但在当前版本上,referrence 不是静态方法。所以你必须先调用 new WC_Query
    猜你喜欢
    • 2021-01-14
    • 2022-01-22
    • 2013-03-31
    • 1970-01-01
    • 2019-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多