reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!
http://redux.io
Other
1.74k stars 583 forks source link

Illegal string offset #1043

Closed hectorgarrofe closed 10 years ago

hectorgarrofe commented 10 years ago

I get this error with the files exactly as the github repo files:

Warning: Illegal string offset 'opt-media' in C:\xampp\htdocs\xxxxxx\wp-content\themes\xxxxx\ReduxFramework\ReduxCore\framework.php on line 2142

I'm using XAMPP for Windows and PHP Version 5.5.9

In my production and online server works fine, the problem seems to be the PHP version... any idea?

kprovance commented 10 years ago

Read this: https://github.com/ReduxFramework/redux-framework/blob/master/CONTRIBUTING.md

dovy commented 10 years ago

Please update to the newest version of the repo. Things have just changed a bit. Give us the details and we'll help as we are able.

Also please re-post the error as the line number will have changed given my last commit.

hectorgarrofe commented 10 years ago

The version I'm using is the latests in the repo. (Latest commit: 281a2b3499)

Warning: Illegal string offset 'opt-media' in C:\xampp\htdocs\wp_hg_framework\wp-content\themes\hg_framework\ReduxFramework\ReduxCore\framework.php on line 2149

Warning: Illegal string offset 'opt-slider-label' in C:\xampp\htdocs\wp_hg_framework\wp-content\themes\hg_framework\ReduxFramework\ReduxCore\framework.php on line 2149

Warning: Illegal string offset 'opt-slider-text' in C:\xampp\htdocs\wp_hg_framework\wp-content\themes\hg_framework\ReduxFramework\ReduxCore\framework.php on line 2149

Warning: Illegal string offset 'opt-slider-select' in C:\xampp\htdocs\wp_hg_framework\wp-content\themes\hg_framework\ReduxFramework\ReduxCore\framework.php on line 2149

Warning: Illegal string offset 'opt-slider-float' in C:\xampp\htdocs\wp_hg_framework\wp-content\themes\hg_framework\ReduxFramework\ReduxCore\framework.php on line 2149

etc...

What kind of details you need?

It seems a PHP version issue.

Thanks in advance!

hectorgarrofe commented 10 years ago

As a note, this problem also appeared me in front end but i fixed it using isset().

In latests version of PHP you can't do: if($variable['setting']){} or the warning "Illegal string offset" appears.

I have to use if(isset($variable['setting'])){} to make sure is an array.

I don't know if it can help you.

The problem seems to be this lines checking default or empty values:

                    // Check fields for values in the default parameter
                    if ( !isset( $this->options[$field['id']] ) && isset( $field['default'] )) {
                        $this->options_defaults[$field['id']] = $this->options[$field['id']] = $field['default'];
                        $doUpdate = true;

                        // Check fields that hae no default value, but an options value with settings to
                        // be saved by default
                    } elseif ( !isset( $this->options[$field['id']] ) && isset( $field['options'] )) {

                        // If sorter field, check for options as save them as defaults
                        if ($field['type'] == 'sorter' || $field['type'] == 'sortable') {
                            $this->options_defaults[$field['id']] = $this->options[$field['id']] = $field['options'];
                            $doUpdate = true;
                        }
                    }

Thanks again.

dovy commented 10 years ago

Something is off from your pull of the repo. Here's line 2149:

if ( !isset( $this->options[$field['id']] ) && isset( $field['default'] )) {

As you can see, all the appropriate issets are in place.

I'd suggest doing a fresh pull.

hectorgarrofe commented 10 years ago

Hello,

In my pull of the repo my line 2149 is exactly as the line you posted.

I don't know what happens, but the problem isn't solved yet, please reopen the issue.

The isset() problem is only a suggestion, I'm not saying it's causing the problem. But in PHP Version 5.5.9 ReduxFramework doesn't work at all.

Maybe you need more information?

Thanks again.

hectorgarrofe commented 10 years ago

Sorry,

I begin from scratch and the repo files are okay.

This block of code seems to be break it all.

        /* LAYOUT */
        $this->sections[] = array(
            'icon' => 'el-icon-cogs',
            'title' => __('Layout', THEME_TEXT_DOMAIN),
            'fields' => array(
                array(
                    'id'=>'layout_type',
                    'type' => 'image_select',
                    'title' => __('Main Layout', 'redux-framework-demo'), 
                    'subtitle' => __('Select main content and sidebar alignment. Choose between no sidebar, left sidebar or right sidebar layout.', 'redux-framework-demo'),
                    'options' => array(
                            'full' => array('alt' => 'No sidebar', 'img' => ReduxFramework::$_url.'assets/img/1col.png'),
                            'left_sidebar' => array('alt' => 'Left sidebar', 'img' => ReduxFramework::$_url.'assets/img/2cl.png'),
                            'right_sidebar' => array('alt' => 'Right sidebar', 'img' => ReduxFramework::$_url.'assets/img/2cr.png')
                        ),
                    'default' => 'full'
                ),
                array(
                    'id'=>'width_type',
                    'type' => 'image_select',
                    'title' => __('Width of the layout', THEME_TEXT_DOMAIN), 
                    'subtitle' => __('Select main content and sidebar alignment. Choose between no sidebar, left sidebar or right sidebar layout.', THEME_TEXT_DOMAIN),
                    'options' => array(
                            'boxed' => array('alt' => 'Boxed', 'img' => ReduxFramework::$_url.'assets/img/3cm.png'),
                            'full_size' => array('alt' => 'Full size', 'img' => ReduxFramework::$_url.'assets/img/1col.png')
                        ),
                    'default' => 'boxed'
                ),
                array(
                    'id'=>'footer-text',
                    'type' => 'editor',
                    'title' => __('Footer Text', 'redux-framework-demo'), 
                    'subtitle' => __('You can use the following shortcodes in your footer text: [wp-url] [site-url] [theme-url] [login-url] [logout-url] [site-title] [site-tagline] [current-year]', 'redux-framework-demo'),
                    'default' => '©Copyright 2014. All Rights Reserved.',
                )
            )
        );

Something important has changed?

Thanks!