-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Active Callback not Working #1620
Comments
Can you please try using a boolean value for your defaults? |
@aristath Sure ill try that thanks, ill let you know if this works, but 1 / 0 is in the docs. So the docs might need updating? https://aristath.github.io/kirki/docs/controls/switch.html |
Yes, the docs are definitely wrong.... Docs for some controls (including toggle/switch) have not been updated in 2 years |
@aristath I've just tried this and unfortunately this hasn't worked. :(
It still shows the body border colour even when disabled? Thanks Jake. |
Closed this one by mistake, reopening. |
@JakeHenshall I'm sorry but I just noticed this... It was so obvious that I missed it. You have a switch and a color control. The way this works is the reverse of what you have on your code. Kirki::add_field( 'malinois', array(
'type' => 'color',
'settings' => 'body_border_color',
'label' => __( 'Body Border Colour', 'my_textdomain' ),
'section' => 'settings',
'default' => '#000000',
'priority' => 7,
'choices' => array(
'alpha' => true,
),
'active_callback' => array(
array(
'setting' => 'body_border',
'operator' => '==',
'value' => 1,
),
),
) );
Kirki::add_field( 'malinois', array(
'type' => 'switch',
'settings' => 'body_border',
'label' => __( 'Body Border (Passepartout)', 'my_textdomain' ),
'section' => 'settings',
'default' => '1',
'priority' => 6,
'choices' => array(
'on' => esc_attr__( 'Enable', 'my_textdomain' ),
'off' => esc_attr__( 'Disable', 'my_textdomain' ),
),
) ); You don't tell the switch to turn on or off other controls. Instead you have to tell the other controls to watch the switch's value so that they may be show or hidden based on the switch's value. I don't know if that sentence makes a lot of sense, I hope it does 😄 Tested the code I just posted and it works fine so I'll go ahead and close this ticket 👍 |
@aristath Ahh awesome, works perfectly, thanks again. |
Issue description:
The Toggle and switch do not take the 'default' value into consideration. If I set it to 1 it's disabled if I set the 0 it's also disabled it doesn't matter which one. if the Switch/toggle has an active callback it doesn't display.
Version used:
(Did you try using the develop branch from github? There's a chance your issue has already been addressed there)
I'm currently embedding into the theme, I've tried the lastest and dev branches
Using theme_mods or options?
theme_mods
Code to reproduce the issue (config + field(s))
and
Hopefully ive got the active_callback right.
The text was updated successfully, but these errors were encountered: