-
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 operator using '<=' or '>=' #1427
Comments
I just tested your code and it looks to me like it's working perfectly fine. Kirki::add_config( '_s' );
Kirki::add_section( 'theme_options', array(
'title' => esc_attr__( 'Theme Options', '_s' ),
'icon' => 'dashicons-admin-customizer',
));
Kirki::add_field( '_s', array(
'type' => 'slider',
'settings' => '_s_slides_slide_number',
'label' => esc_attr__( 'Number of slides', '_s' ),
'section' => 'theme_options',
'default' => 1,
'choices' => array(
'min' => 1,
'max' => 7,
'step' => 1,
),
) );
Kirki::add_field( '_s', array(
'settings' => '_s_slides_slide_2',
'label' => __( 'Slide 2', '_s' ),
'section' => 'theme_options',
'type' => 'editor',
'priority' => 30,
'default' => '',
'active_callback' => array(
array(
'setting' => '_s_slides_slide_number',
'operator' => '<=',
'value' => 2,
),
),
) ); When if ( get_theme_mod( '_s_slides_slide_number' ) <= 2 ) {
// SHOW CONTROL
} else {
// HIDE CONTROL
} |
Can you please post the code for ALL those fields so that I may replicate this? In your previous reply you only included 1. |
Sure, here's a simplified version based on your example:
|
OK, I see the problem now. |
Fixed, will be included in 3.0.8. |
Great, thank you so much! |
Issue description:
The latest Kirki update seems to have switched the operator logic for greater than/less than or equal to.
I have a number slider (from 1 through 7) that controls the visibility of other fields. For example, if the number slider is set to 3,
field_1
,field_2
, andfield_3
would show, butfield_4
throughfield_7
would be hidden. (Field names are just to illustrate/simplify).Up until the latest update, this has worked perfectly using the
<=
operator on each field, and checking the number slider value within theactive_callback
. However, with the latest release, I had to switch to the>=
operator to get it to work—in essence, the logic has switched.There also appears to be different logic used during the page refresh—if I have the operator set to
<=
and I change the number slider, I'll see the correct logic during the page refresh, but once the refresh is complete it will switch to using the incorrect logic.Version used:
3.0.4
Using theme_mods or options?
theme_mod
Code to reproduce the issue (config + field(s))
Example number slider (setting number of slides to show):
Example field, using the
<=
operator that is no longer working correctly in the latest update:The text was updated successfully, but these errors were encountered: