Skip to content
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

Exclude in multicolor #1416

Closed
Slobork opened this issue Jun 23, 2017 · 1 comment
Closed

Exclude in multicolor #1416

Slobork opened this issue Jun 23, 2017 · 1 comment
Milestone

Comments

@Slobork
Copy link

Slobork commented Jun 23, 2017

Issue description:

While I've overcome the similar problem with a background field, I just cannot get exclude to work on the multicolor. Please can you look where's the mistake?

Version used:

develop branch

Using theme_mods or options?

theme_mods

Code to reproduce the issue (config + field(s))

    Kirki::add_field( 'MYTHEME', array(
        'settings'    => 'link_color',
        'section'     => 'SET_SECTOION',
        'type'        => 'multicolor',
        'label'       => esc_html__( 'Links color', 'mt' ),
        'priority'    => 10,
        'choices'     => array(
            'color'   => esc_html__( 'Color',  'mt' ),
            'hover'   => esc_html__( 'Hover',  'mt' ),
            'active'  => esc_html__( 'Active', 'mt' ),
        ),
        'default'     => array(
            'color'   => '#5B9fcc',
            'hover'   => '#ccc',
            'active'  => '#ddd',
        ),
        'transport'   => 'auto',
        'output'    => array(
            array(
                'choice'    => 'color',
                'element'   => 'a',
                'property'  => 'color',
                'exclude'   => array(
                                   array(
                                       'color'  => '#5B9fcc',
                                       'hover'  => '#ccc',
                                       'active' => '#ddd'
                                   ), 
                                ),
            ),
            array(
                'choice'    => 'hover',
                'element'   => 'a:hover',
                'property'  => 'color',
            ),
            array(
                'choice'    => 'active',
                'element'   => 'a:focus',
                'property'  => 'color',
            ),
        ),
    ) );

I've tried setting the exclude option for each choice, but that didn't work as well.
Thanks!

@aristath aristath modified the milestones: 3.0.5, 3.0.6, 3.0.7 Jun 25, 2017
@aristath
Copy link
Contributor

It was a matter of sanitization.
If I use this for default:

'default'     => array(
    'color'   => '#5b9fcc',
    'hover'   => '#cccccc',
    'active'  => '#dddddd',
),

and this for exclude it works:

'exclude'   => array(
    array(
        'color'  => '#5b9fcc',
        'hover'  => '#cccccc',
        'active' => '#dddddd'
    ), 
),

However, I see that I failed to take into account cases where choice is used, so I just pushed another commit that will allow you to do this:

'output'    => array(
    array(
        'choice'    => 'color',
        'element'   => 'a',
        'property'  => 'color',
        'exclude'   => array(
            '#5b9fcc',
        ),
    ),
    array(
        'choice'    => 'hover',
        'element'   => 'a:hover',
        'property'  => 'color',
        'exclude'   => array(
            '#cccccc',
        ),
    ),
    array(
        'choice'    => 'active',
        'element'   => 'a:focus',
        'property'  => 'color',
        'exclude'   => array(
            '#dddddd',
        ),
    ),
),

In other words, if you have a choice defined, then in the exclude argument you can either use a full array of the control's value - in which case it will check if all sub-values are true and only then will it exclude it, OR you can use an array of sub-values, in which case if it's equal to one of them it will be excluded.

aristath added a commit that referenced this issue Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants