evertiro / historical-redux2

A simple, easily extendable options framework for WordPress based on NHP Theme Options Framework.
http://reduxframework.com
Other
105 stars 43 forks source link

Bug in Switch option...current build #43

Closed hookedonweb closed 11 years ago

hookedonweb commented 11 years ago

I can not set the switch option to 'on' as a default. Even if you remove the extra white space as in the sample, the switch is always in the off position. 2013-01-08_1052 2013-01-08_1053

pcescato commented 11 years ago

It seems that this issue is the same that issue 41 I've opened. In fact, after removing some validated fields, I've no more problems, neither with checkboxes, neither with colors... perhaps some buggy code in a validation function breaks std process, I've not looked at code in fact, too tired and involved in my theme building.

denis0706 commented 11 years ago

i have tried to remove all validated field but it didn't help. At first sight it seems that there is a problem in defaults.php Function _set_default_options (line:155) checks if redux option array exists in wp DB, but doesn't check if there is option name in redux option array keys.

psaikali commented 11 years ago

Does this merge fix this checkbox bug for you? If my checkbox (switch => true or false) has std => '1' (or 1), unchecking the checkbox doesn't get saved, it's always checked...

denis0706 commented 11 years ago

Sorry, i have hurried. The problem with checkbox is that if it is uncheked its value are not sent. So we need to check it:

if(isset($field['type']) && $field['type']=='checkbox'){
    if(!isset($plugin_options[$field['id']]))
    $plugin_options[$field['id']] = 0;
}

Add this code to defaults.php at function _validate_values after $field['section_id'] = $k; (line:498)

psaikali commented 11 years ago

Awesome, I'll try that soon, thx a lot!

denis0706 commented 11 years ago

also we should check other checkbox fields type: _checkbox_hideall, _checkbox_hidebelow I have found another problem with switch style checkbox. Sometimes after press "Save changes" button, checkbox stop working. Javascript catches change and fire warning "Settings have changed", but checkbox state isn't changed. It's look like switch "label" loose relation checkbox input, either we use <label><input/></label> or we use <input/><label for="input_id"></label> it doesn't happen after option page reload, but after 3-5 times pressing "save button" there is this problem.

denis0706 commented 11 years ago

Solved. The problem with switch style exists only in opera, caused by display:none; for input. So we should hide checkbox not using display:none We could set its position to absolute and set opacity:0 or huge offset for browser with no opacity support (left:-9999px;)

evertiro commented 11 years ago

This bug has been resolved.

hookedonweb commented 11 years ago

has the fix been applied to a the existing download build?

evertiro commented 11 years ago

It was fixed in https://github.com/ghost1227/Redux-Framework/commit/0ed37d096eb2794eb0d12fa0530998e396818e52

hookedonweb commented 11 years ago

How does one know if they are using the right build if the version number is not incremented? Pre-bug report version was 1.0.1 and post bug fix is version 1.0.1. Is there a patch file to download somewhere I am not seeing?

evertiro commented 11 years ago

If you're using the development builds, the best practice is probably to use Redux as a submodule. Instructions for doing this are in the readme file. Beyond that, just keep an eye on the commit logs for changes that affect you!