chriswallace/UpThemes-Framework — Issue #12: reset defaults not working with elements that output an array
Author: andyjamesneale
Created: 2011-10-20 16:40:00+00:00
State: open

Hi Guys,

Love the upthemes framework :)

I have been working with it for some time now, but recently I have stumbled across one main issue I have not been able to resolve myself and hoping for some assistance.

When I import the theme options I am getting some strange results.

After I import the theme options, I get the following javascript error.

"A is not defined"

Looking in the code I see all font slider values are set to "A" .. the first letter in "Array"
/* Font Size Slider */
$( "#font_h4-font-size" ).slider({
range: "min",
value: A,

Also the actual css selectors in the font css are all

A {
font-family:Arial;
}

The same thing is happening with all elements that outputs an array instead of string. Like the repeatable text field. After an import the default values are gone and there is only one text input with the value set to "Array"

I have done some digging to try and see what the cause is and also tried to fix it but had no luck unfortunately.

It appears to be that when an import is done any value that was an array before (checkbox, text_list, fonts etc) will get its value set as a string of "Array" instead of the actual array values after the "$new_options" is created.

I managed to work around this so I dont get any errors by adding a check to import-export.php

if($v):
$encoded .= $k.'|'.$v.'||';
endif;

To

if($v && is_array($v)):
$encoded .= $k.'|'.$v.'||';
endif;

Now when I import the settings, I dont get any errors as all array values are ignored and when I save for the first time, it adds the default values. Obviously not ideal but a workaround for now, so things dont completely break.

I really wanted to try fix this and provide the solution, but after much digging, I just could not figure it out, so over to you guys. Hopefully you can provide a fix for it.

Many thanks,

Andy