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

'input_attrs' parameter for controls created in Kirki #1074

Closed
allysonsouza opened this issue Aug 5, 2016 · 3 comments
Closed

'input_attrs' parameter for controls created in Kirki #1074

allysonsouza opened this issue Aug 5, 2016 · 3 comments

Comments

@allysonsouza
Copy link

allysonsouza commented Aug 5, 2016

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

@aristath
Copy link
Contributor

aristath commented Aug 6, 2016

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... 👍

@allysonsouza
Copy link
Author

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

@aristath
Copy link
Contributor

Fixed, will be included in the next release. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants