警告:尝试访问 /mytheme/functions.php 第 43 行中 bool 类型值的数组偏移量

问题描述 投票:0回答:2

警告:尝试访问 /mytheme/functions.php 第 43 行中 bool 类型值的数组偏移量

// Add woocommerce support
$start_extended_woo = get_option( 'swp_woo' );
if( $start_extended_woo[0] == 'Enable' ){
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_action( 'init', 'woo_remove_wc_breadcrumbs' );
function woo_remove_wc_breadcrumbs() {
    remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
}

我在将 php 从 7.4 升级到 php 8.0 后收到此错误,知道如何解决此问题吗?

我使用的是Start Wp主题,不幸的是它已经3年没有更新了

php wordpress wordpress-theming
2个回答
2
投票

根据文档,如果找不到该选项,则

get_option()
返回
false
。您的选择可能不再存在。为了保持“安全”,更改为

if( is_array($start_extended) && $start_extended_woo[0] == 'Enable' ){

这将防止您引用的确切错误。

另一种方法是将

get_option()
调用更改为:

$start_extended_woo = get_option( 'swp_woo' , ['Disabled'] );

这将返回与您的调用相反的假设。

或者,在数据库中添加

swp_woo
的选项,无需更改任何代码。


0
投票

我的网站上有以下错误消息。 你能帮我吗

注意:尝试访问第 107 行 /home/ruchercom/public_html/wp-content/plugins/proelements-3.19.3/updater/updater.php 中 bool 类型值的数组偏移量

注意:尝试访问第 110 行 /home/ruchercom/public_html/wp-content/plugins/proelements-3.19.3/updater/updater.php 中 bool 类型值的数组偏移量

注意:尝试访问第 113 行 /home/ruchercom/public_html/wp-content/plugins/proelements-3.19.3/updater/updater.php 中 bool 类型值的数组偏移量

注意:尝试访问第 116 行 /home/ruchercom/public_html/wp-content/plugins/proelements-3.19.3/updater/updater.php 中 bool 类型值的数组偏移量

}

    if ( ! isset( $this->config['new_version'] ) )
        $this->config['new_version'] = $this->get_new_version();

    if ( ! isset( $this->config['last_updated'] ) )
        $this->config['last_updated'] = $this->get_date();

    if ( ! isset( $this->config['description'] ) )
        $this->config['description'] = $this->get_description();

    $plugin_data = $this->get_plugin_data();
    if ( ! isset( $this->config['plugin_name'] ) )
        $this->config['plugin_name'] = $plugin_data['Name'];

    if ( ! isset( $this->config['version'] ) )
        $this->config['version'] = $plugin_data['Version'];

    if ( ! isset( $this->config['author'] ) )
        $this->config['author'] = $plugin_data['Author'];

    if ( ! isset( $this->config['homepage'] ) )
        $this->config['homepage'] = $plugin_data['PluginURI'];

    if ( ! isset( $this->config['readme'] ) )
        $this->config['readme'] = 'README.md';
© www.soinside.com 2019 - 2024. All rights reserved.