Multi picker is not working more, important & urgent
Hello!
This code worked before, but not working since latest Unyson update:
'rss_feed' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'enabled' => array(
'label' => esc_html__( 'RSS Feed', 'mytheme' ),
'type' => 'switch',
'left-choice' => array(
'value' => 'false',
'label' => esc_html__( 'Disabled', 'mytheme' )
),
'right-choice' => array(
'value' => 'true',
'label' => esc_html__( 'Enabled', 'mytheme' )
),
'value' => 'true',
)
),
'choices' => array(
'true' => array(
'display_thumbnails_in_rss' => array(
'label' => esc_html__( 'Add post thumbnails to the RSS Feed', 'mytheme' ),
'type' => 'switch',
'desc' => esc_html__( 'If enabled, post thumbnail will be added for each post in your RSS feed', 'mytheme' ),
'right-choice' => array(
'value' => 'true',
'label' => esc_html__( 'Yes', 'mytheme' )
),
'left-choice' => array(
'value' => 'false',
'label' => esc_html__( 'No', 'mytheme' )
),
'value' => 'true',
),
),
),
'show_borders' => false,
),
Unyson doesn't save the value and i always get "true", switcher doesn't work in admin panel
var_dump( filter_var( fw_get_db_settings_option( 'rss_feed/enabled' ), FILTER_VALIDATE_BOOLEAN ) );
why this happened? I have quite a lot of such structures in several themes and it is very bad that it just stopped working :( please help ASAP
I added the above code in
{theme}/framework-customizations/theme/options/settings.php
and tried all switches combinations and everything is saved fine.
How to test/reproduce this?
Thank you for a really fast answer! Could you leave your email here and i'll provide you test FTP website
P.S. I think it's a bad idea to use bool values as string, because of this. Instead of 'value' => 'true|false' better use another words, for e.g. 'value' => 'enabled|disabled'.
P.P.S. Have you tested your theme before we released latest version?
moldcraft[at]email.com
You made some changes due to this ticket i believe (15 days ago) https://github.com/ThemeFuse/Unyson/issues/1394 but, there was no such restrictions before :) how about themes, created before these changes?
p.s. I tested my theme 30 days ago and all worked perfectly (ThemeForest reviews new themes in 30+ days), and now, when some users bought my theme, i have a problem with Theme options
p.s. is it possible to add some backward compatibility option e.g. in theme manifest for themes, created before these changes?
p.p.s. i used such construction to validate booleans from theme options
filter_var( fw_get_db_settings_option( 'myoption' ), FILTER_VALIDATE_BOOLEAN )
and if i'll use "enabled / disabled", this will be impossible http://php.net/manual/en/filter.filters.validate.php
maybe I was wrong initially, but, please add some backward compatibility option, it is 99% that some of buyers will not like the fact that theme options do not work after the update, i created several themes in this way
I will add backward compatibility but a new version will be in a few days
thank you so much!
if this may help: i have just noticed that multi-picker doesn't work even if i use "yes / no" (not "string booleans"!) as values, e.g.: "autoplay" option will be always "disabled" in a Page Builder popup:
<?php
'autoplay' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'enabled' => array(
'label' => esc_html__( 'Autoplay', 'mytheme' ),
'type' => 'switch',
'left-choice' => array(
'value' => 'no',
'label' => esc_html__( 'Disabled', 'mytheme' )
),
'right-choice' => array(
'value' => 'yes',
'label' => esc_html__( 'Enabled', 'mytheme' )
),
'value' => 'no',
)
),
'choices' => array(
'yes' => array(
'autoplay_speed' => array(
'type' => 'text',
'label' => esc_html__('Autoplay speed', 'mytheme'),
'desc' => esc_html__('in milliseconds, e.g.: 2000 = 2 seconds', 'mytheme'),
),
)
)
),
so maybe the problem in Multi Picker option type, not in this https://github.com/ThemeFuse/Unyson/blob/v2.5.1/framework/core/components/backend.php#L1154-L1166
@WPJobs I jus tested mine and they work ok , try this
'test_switch' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'picked' => array(
'label' => __('Label', 'fw'),
'desc' => __('Desc', 'fw'),
'type' => 'switch',
'right-choice' => array(
'value' => 'hide',
'label' => __('Hide', 'fw')
),
'left-choice' => array(
'value' => 'show',
'label' => __('Show', 'fw')
),
'value' => 'show'
)
),
'choices' => array(
'show' => array(
),
)
),
@danyj i'm so sorry, i looked at another part of code (too late and need to rest). I confirm that "yes / no" works fine, but "true/false" doesn't work in a Page Builder, and works in a Theme options
ok, I had issues with booleans since the begining and best thing I did was stay away from them.
@danyj thak you, i believe i should do the same in my next themes! but, i believe, there is a way to fix this for my old themes without too many headache :(
@WPJobs instead of waiting for us to release a new Unyson version with the fix, you can add a fix in your theme. Let's say in your view you use:
$value = fw_get_db_settings_option( 'rss_feed/enabled' ); // or $atts['rss_feed']['enabled'];
if ($value === 'true') {
// ...
}
just change it to:
$value = fw_get_db_settings_option( 'rss_feed/enabled' ); // or $atts['rss_feed']['enabled'];
if (in_array($value, array('true', 'yes'), true)) {
// ...
}
that will work with both old saved values and new values.
We will not change the code in Unyson and you will release a theme update now. Is this solution ok for you?
@moldcraft it will work for theme options, but how about Page Builder? e.g.
'autoplay' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'enabled' => array(
'label' => esc_html__( 'Autoplay', 'mytheme' ),
'type' => 'switch',
'left-choice' => array(
'value' => 'false',
'label' => esc_html__( 'Disabled', 'mytheme' )
),
'right-choice' => array(
'value' => 'true',
'label' => esc_html__( 'Enabled', 'mytheme' )
),
'value' => 'false',
)
),
'choices' => array(
'true' => array(
'autoplay_speed' => array(
'type' => 'text',
'label' => esc_html__('Autoplay speed', 'mytheme'),
'desc' => esc_html__('in milliseconds, e.g.: 2000 = 2 seconds', 'mytheme'),
),
)
)
),
"autoplay" displays as "disabled" every time https://yadi.sk/i/KZ9qn9Xeqx5Ng
In page builder it doesn't work. You need to replace "true" with "yes" or "enabled" and "false" with "no" or "disabled", then add in view this fix
@moldcraft but it worked before, you said that backward compatibility will be added, so you're not going to do that?
I proposed here to not add backward compatibility but you instead to add a fix in your theme. Do you agree with this proposal?
The problem is because of this change https://github.com/ThemeFuse/Unyson/issues/1394
@moldcraft this solution will not work with Page Builder options, so it makes no sence for me. A lot of users who purchased my themes based on Unyson use Page Builder, and half of options are not working because of this change https://github.com/ThemeFuse/Unyson/issues/1394
Now andreiglingeanu, who asked for this update is happy, but 200+ of my customers are shocked
@moldcraft @WPJobs in the light of the issue and his users now being kinda stuck until the fix, we should have something like this https://github.com/ThemeFuse/Unyson/issues/1062 in place for Unyson in theme/manifest.php
'max_version' => '2.5.0',
optional of course but if used dev can test the theme few days after the new release, update the max_version for his customers and than customers can update.