警告:PHP 7.2非法字符串偏移量

时间:2019-04-08 17:54:43

标签: php

我有一个wordpress网站,由于将服务器升级到PHP 7.2,我使用的模板文件的页面上出现以下错误:

Warning: Illegal string offset 'header-background' in 
/homepages/21/d707839808/htdocs/wp-content/themes/businesshub/business- 
hub/framework/include/kode_front_func/kf_function_utility.php on line 991

给出错误的行是:

$businesshub_post_option['header-background'] = $businesshub_theme_option[$businesshub_post_title_bg];

我已将完整功能包含在从981行开始的php文件中

        if( !function_exists('businesshub_header_title_background') ){  
    function businesshub_header_title_background($businesshub_post_title_bg){
        global $businesshub_theme_option, $businesshub_post_option;
        $header_selected_class = '';
        $header_background = '';
        $businesshub_post_option = businesshub_decode_stopbackslashes(get_post_meta(get_the_ID(), 'post-option', true ));
        if( !empty($businesshub_post_option) ){
            $businesshub_post_option = json_decode( $businesshub_post_option, true );                   
        }
        if(!isset($businesshub_post_option['header-background']) || $businesshub_post_option['header-background'] == ''){
    $businesshub_post_option['header-background'] = $businesshub_theme_option[$businesshub_post_title_bg];
        }
        if(isset($businesshub_post_option['header-background'])){
            if( is_numeric($businesshub_post_option['header-background']) ){
                $image_src = wp_get_attachment_image_src($businesshub_post_option['header-background'], 'full');    
                $header_background = esc_url($image_src[0]);        
            }else{
                $header_background = esc_url($businesshub_post_option['header-background']);
            }
        }else{
            $header_background = '';
        }
        $businesshub_theme_option['kode-header-style'] = businesshub_get_selected_header_class($businesshub_post_option,$businesshub_theme_option);
        $page_caption = '';
        if(isset($businesshub_post_option['header-background'])){
            if( is_numeric($businesshub_post_option['header-background']) ){
                $image_src = wp_get_attachment_image_src($businesshub_post_option['header-background'], 'full');    
                $header_background = esc_url($image_src[0]);        
            }else{
                $header_background = esc_url($businesshub_post_option['header-background']);
            }
        }else{
            $header_background = '';
        }

        if(isset($header_background) && $header_background <> ''){
            $header_background = 'style="background-image: url('.esc_url($header_background).');"';
        }else{
            $header_background = 'style="background-image: url('.esc_url(BUSINESSHUB_PATH.'/images/theme-detail-banner-img.jpg').');"';
        }


        return $header_background;
    }
}

任何想法如何解决? 您的帮助将不胜感激。谢谢

0 个答案:

没有答案