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

output argument to add_field not working #1478

Closed
PrafullaKumarSahu opened this issue Jul 25, 2017 · 3 comments
Closed

output argument to add_field not working #1478

PrafullaKumarSahu opened this issue Jul 25, 2017 · 3 comments

Comments

@PrafullaKumarSahu
Copy link

PrafullaKumarSahu commented Jul 25, 2017

Issue description:

The auto output is not working . Can you give me some idea about it ? The default values are coming very correctly just the changed value are not coming .

Version used: 3.0.9

WordPress Version 4.8 and ACF pro 5.6

(Did you try using the develop branch from github? There's a chance your issue has already been adressed there)

Using theme_mods or options?

theme_mods

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

if(class_exists('\\KirkiHelpers\\My_Kirki')) {
     
    $paragraph_settings = [
        $this->slug . '_style[paragraph][font]' => [
            'type' => 'select',
            'label' => __( 'Font', $this->slug ),
            'default' => 'Open Sans',
            'priority' => 10,
            'choices' => \Kirki_Fonts::get_font_choices(),
            'output' => array(array(
                'element' => 'p',
                'property' => 'font-family',
                'units' => ' !important'
            ))
        ],
        $this->slug . '_style[paragraph][font_size]' => [
            'type' => 'select',
            'default' => '14',
            'priority' => 11,
            'label' => __( 'Font Size', $this->slug ),
            'choices' => $this->get_font_size_args(
                $this->slug . '_text_paragraph'
            ),
            'output' => array(array(
                'element' => 'p',
                'property' => 'font-size',
                'units' => ' !important'
            ))
        ],
        $this->slug . '_style[paragraph][font_weight]' => [
            'default' => 'normal',
            'type' => 'select',
            'label' => __( 'Font Weight', $this->slug ),
            'priority' => 12,
            'choices' => $this->get_font_weight_args(
                $this->slug . '_text_paragraph'
            ),
            'output' => array(array(
                'element' => 'p',
                'property' => 'font-weight',
                'units' => ' !important'
            ))
        ],
        $this->slug . '_style[paragraph][font_style]' => [
            'default' => 'normal',
            'label' => 'Font Style',
            'type' => 'select',
            'priority' => 13,
            'choices' => [
                'normal' => __( 'Normal' ),
                'italic' => __( 'Italic' ),
            ],
            'output' => [[
                'element' => 'p',
                'property' => 'font-style',
                'units' => ' !important'
            ]]
        ],
        $this->slug . '_style[paragraph][font_color]' => [
            'default' => '',
            'type' => 'color',
            'label' => 'Font Color',
            'priority' => 14,
        ],
    ];

    foreach($paragraph_settings as $id => $item) {
        $item['section'] = $this->slug . '_text_paragraph';
        $key = $this->slug . '_style_panel';
        $item['settings'] = $id;
        My_Kirki::add_field($key, $item);
    }
}
@PrafullaKumarSahu
Copy link
Author

PrafullaKumarSahu commented Jul 25, 2017

In network section the changed data is going to admin section correctly .

wp_customize:on
customize_theme:my_theme
nonce:7fb73fb54e
customize_changeset_uuid:e1d58150-23c2-42f7-abf7-4ac5e63817ad
customize_changeset_data:{"my_theme_style[paragraph][font_size]":{"value":"47px"}}
action:customize_save
customize_preview_nonce:0134be589e

even response is {"success":true,"data":{"setting_validities":{"mytheme_style[paragraph][font_size]":true},"changeset_status":"auto-draft"}}

but that is not changing the paragraph style . Does output still not works on typography ? As you mentioned this here.

@aristath
Copy link
Contributor

@PrafullaKumarSahu There are a couple of things I don't quite get.

Why not simply use a typography control?

Why do you use option-names like $this->slug . '_style[paragraph][font_weight]'? Why not just $this->slug . '_style_paragraph_font_weight'?

I can't test anything using the code you posted. Please post code that I can just copy-paste like this:

Kirki::add_field( 'style_paragraph_font' => array(
    'type'     => 'select',
    'label'    => __( 'Font', 'textdomain' ),
    'default'  => 'Open Sans',
    'priority' => 10,
    'choices'  => Kirki_Fonts::get_font_choices(),
    'section'  => 'my_section',
    'output'   => array(
        array(
            'element'  => 'p',
            'property' => 'font-family',
            'units'    => ' !important',
        ),
    ),
));

OR paste the whole implementation and not just a part of it that won't work without the rest of your code.

@DannyCooper
Copy link
Contributor

Closing this as it's an implementation question that never received followup from the original poster.

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

3 participants