Kirki: 'input_attrs' parameter for controls created in Kirki

Created on 6 Aug 2016  路  3Comments  路  Source: kirki-framework/kirki

Issue description:

Hi, I'm tying to define a class for some controls, so I can style then, but I think Kirki is not working with default 'input_attrs' parameters to define the control class, it's right?

Version used:

2.3.5

Using theme_mods or options?

theme_mods

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

Kirki::add_field( 'my_config', array(
    'type'     => 'text',
    'settings' => 'my_setting',
    'label'    => __( 'Text Control', 'my_textdomain' ),
    'section'  => 'my_section',
    'default'  => esc_attr__( 'This is a defualt value', 'my_textdomain' ),
    'priority' => 10,
    'input_attrs' => array( 'class' => 'my_custom_class' ),
) );

Here's the customizer api example: https://developer.wordpress.org/themes/advanced-topics/customizer-api/#controls

bug feature

All 3 comments

wow, to be honest I didn't even know about input_attrs.

I have a generic control that you can use until I implement this one... Won't be long, I'll try to get it done in the weekend.
In the meantime here's how you can do it with the existing implementation:

Kirki::add_field( 'my_config', array(
    'type'     => 'generic',
    'settings' => 'my_setting',
    'label'    => __( 'Text Control', 'my_textdomain' ),
    'section'  => 'my_section',
    'default'  => esc_attr__( 'This is a defualt value', 'my_textdomain' ),
    'priority' => 10,
    'choices'  => array(
        'element'     => 'input',
        'type'        => 'text',
        'class'       => 'my-custom-class',
        'data-foo'    => 'bar',
        'placeholder' => 'something',
    ),
) );

This will basically create this:
<input type="text" class="my-custom-class" data-foo="bar" placeholder="something">
So you can put anything in there... 馃憤

Thanks @aristath, this will be helpfull! (I also didn't know about 'input_attrs' until need it...)

Fixed, will be included in the next release. 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pagelab picture pagelab  路  3Comments

carasmo picture carasmo  路  7Comments

VladNov picture VladNov  路  6Comments

stylethemes picture stylethemes  路  6Comments

hussainnayani picture hussainnayani  路  4Comments