1

What I'm trying to achieve is to add new args ( output ) as below:

$wp_customize->add_setting(
    'modular_header_main_border_bottom_color', array(
        'default'    => '#e9ecef',
        'capability' => 'edit_theme_options',
        'output'     => array(
            array(
                'element'  => 'body',
                'property' => 'background-color',
            ),
        ),
    )
);

And, get output array in front and enqueue it as a valid CSS. Till now, I've tried achieve the same using customize_dynamic_setting_args hook which works fine in Customizer. But the problem is data from it is not accessible in frontend. https://pastebin.com/AEdmPJDV

I guess there should be another way of doing same.

1 Answer 1

1

This might be what you are looking for

$args = array(
    'default'    => '#e9ecef',
    'capability' => 'edit_theme_options',
);

if ( something() ) {
    $args['output'] = array(
        array(
            'element'  => 'body',
            'property' => 'background-color',
        ),
    );
}

$wp_customize->add_setting( 'modular_header_main_border_bottom_color', $args );

We are first creating an array for arguments. Later we are pushing a key value to that array with some conditions.

1
  • Do you mind explaining the code?
    – user9447
    Commented Jul 18, 2018 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.