kirki icon indicating copy to clipboard operation
kirki copied to clipboard

Problems with PHP 5.4

Open LuisAlejandre opened this issue 11 years ago • 4 comments

For servers running on PHP 5.4 I´m getting Warning: Illegal string offset 'settings' PHP messages.

The problem is in lines 151 and 385 of class-kirki-fields.php

It looks like in some cases the variable $field is not an array and that fires the error, but I can´t figure out where and why. I went through all my code and all fields in all my sections are created as arrays.

LuisAlejandre avatar Apr 24 '15 21:04 LuisAlejandre

Hey there!

Can you please post your code here so that I may try to replicate this issue and see what goes on?

aristath avatar Apr 25 '15 10:04 aristath

Hi, Aris, and thank you for your fast reply.

My code includes dozens of files, and it is a child theme for the commercial WP theme Divi by Elegant Themes. It would be a real mess for you to try to replicate the issue.

This is for example the file for one of the sections. All of them are alike, with fields defined as arrays:

 $value) {
            $fields[] = check_production_mode( 'dce_custom_fullwidth_header_' . $key );
            /* GROUP TITLE: Module background */
            $fields[] = array(
                'type'      => 'custom',
                'settings'  => 'gt_cfwhmb_' . $key,
                'label'     => __( 'Module background:', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'priority'  => 100,
            );
            /* Background opacity */
            $fields[] = array(
                'type'      => 'slider',
                'settings'  => 'dce_cfwh_background_opacity_' . $key,
                'label'     => __( 'Background opacity (%)', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'help'      => __( 'Opacity of the background in percentage. Default: 0% (fully transparent).', 'divi-children-engine' ),               
                'default'   => 0,
                'priority'  => 110,
                'choices'   => array(
                    'min'   => 0,
                    'max'   => 100,
                    'step'  => 1,
                ),
            );
            /* Background color */
            $fields[] = array(
                'type'      => 'color',
                'settings'  => 'dce_cfwh_background_color_' . $key,
                'label'     => __( 'Background color', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'default'   => '#fff',
                'priority'  => 120,
            );
            /* GROUP TITLE: Paddings */
            $fields[] = array(
                'type'      => 'custom',
                'settings'  => 'gt_cfwhp_' . $key,
                'label'     => __( 'Paddings:', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'priority'  => 200,
            );
            /* Top padding */
            $fields[] = array(
                'type'      => 'slider',
                'settings'  => 'dce_cfwh_top_padding_' . $key,
                'label'     => __( 'Top padding (px)', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'help'      => __( 'Padding over header title in pixels. Default: 50px.', 'divi-children-engine' ),             
                'default'   => 50,
                'priority'  => 210,
                'choices'   => array(
                    'min'   => 0,
                    'max'   => 100,
                    'step'  => 5,
                ),
            );
            /* Bottom padding */
            $fields[] = array(
                'type'      => 'slider',
                'settings'  => 'dce_cfwh_bottom_padding_' . $key,
                'label'     => __( 'Bottom padding (px)', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'help'      => __( 'Padding below subheader in pixels. Default: 50px.', 'divi-children-engine' ),               
                'default'   => 50,
                'priority'  => 220,
                'choices'   => array(
                    'min'   => 0,
                    'max'   => 100,
                    'step'  => 5,
                ),
            );
            /* GROUP TITLE: Headers and subheaders */
            $fields[] = array(
                'type'      => 'custom',
                'settings'  => 'gt_cfwhhs_' . $key,
                'label'     => __( 'Headers and subheaders:', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'priority'  => 300,
            );
            /* Header font size */
            $fields[] = array(
                'type'      => 'slider',
                'settings'  => 'dce_cfwh_header_size_' . $key,
                'label'     => __( 'Header font size (px)', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'help'      => __( 'Font size for the header title in pixels. Default: 30px.', 'divi-children-engine' ),                
                'default'   => 30,
                'priority'  => 310,
                'choices'   => array(
                    'min'   => 10,
                    'max'   => 50,
                    'step'  => 1,
                ),
            );
            /* Header font color */
            $fields[] = array(
                'type'      => 'color',
                'settings'  => 'dce_cfwh_header_color_' . $key,
                'label'     => __( 'Header font color', 'divi-children-engine' ),
                'section' => 'dce_custom_fullwidth_header_' . $key,
                'default'   => '#999999',
                'priority'  => 320,
            );
            /* Subheader font size */
            $fields[] = array(
                'type'      => 'slider',
                'settings'  => 'dce_cfwh_subheader_size_' . $key,
                'label'     => __( 'Subheader font size (px)', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'help'      => __( 'Font size for the subheader text in pixels. Default: 16px.', 'divi-children-engine' ),              
                'default'   => 16,
                'priority'  => 330,
                'choices'   => array(
                    'min'   => 10,
                    'max'   => 40,
                    'step'  => 1,
                ),
            );
            /* Subheader font color */
            $fields[] = array(
                'type'      => 'color',
                'settings'  => 'dce_cfwh_subheader_color_' . $key,
                'label'     => __( 'Subheader font color', 'divi-children-engine' ),
                'section' => 'dce_custom_fullwidth_header_' . $key,
                'default'   => '#999999',
                'priority'  => 340,
            );
            /* GROUP TITLE: Responsiveness for mobile */
            $fields[] = array(
                'type'      => 'custom',
                'settings'  => 'gt_cfwhrm_' . $key,
                'label'     => __( 'Responsiveness for mobile:', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'priority'  => 400,
            );  
            /* Mobile Header font size */
            $fields[] = array(
                'type'      => 'slider',
                'settings'  => 'dce_cfwh_header_size_mobile_' . $key,
                'label'     => __( 'Header font size for mobile (px)', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'help'      => __( 'Font size for the header title on devices with screen width lower than 768px. Default: 30px.', 'divi-children-engine' ),                
                'default'   => 30,
                'priority'  => 410,
                'choices'   => array(
                    'min'   => 10,
                    'max'   => 50,
                    'step'  => 1,
                ),
            );
            /* Mobile Subheader font size */
            $fields[] = array(
                'type'      => 'slider',
                'settings'  => 'dce_cfwh_subheader_size_mobile_' . $key,
                'label'     => __( 'Subheader font size for mobile (px)', 'divi-children-engine' ),
                'section'   => 'dce_custom_fullwidth_header_' . $key,
                'help'      => __( 'Font size for the subheader text on devices with screen width lower than 768px. Default: 16px.', 'divi-children-engine' ),              
                'default'   => 16,
                'priority'  => 420,
                'choices'   => array(
                    'min'   => 10,
                    'max'   => 40,
                    'step'  => 1,
                ),
            );
        }
        
    }
    
    return $fields;
    
}
add_filter( 'kirki/fields', 'dce_custom_fw_headers_settings' );

LuisAlejandre avatar Apr 25 '15 11:04 LuisAlejandre

Hi again, Aris.

Please don´t waste a single minute on this issue. I just realized there could be some problem in some cases with the function I´m calling by this line:

$fields[] = check_production_mode( 'dce_custom_fullwidth_header_' . $key );

I have to check it out. I´ll report back if the problem doesn´t come from there. Thanks.

Bu the way, the top part of the code didn´t show up on my previous reply, I don´t know why. I made sure I´d included the complete file.

LuisAlejandre avatar Apr 25 '15 11:04 LuisAlejandre

Closing this one. :)

aristath avatar May 24 '15 14:05 aristath