1

Heyo,

I was wondering if there is any difference between the 'type' => 'text' option in the $wp_customize->add_control control

$wp_customize->add_control( 'textfield_1_control', array(
    'label' => __('Textfield 1', 'cvh'),
    'section' => 'test_section',
    'settings' => 'textfield_setting_1',
    'type' => 'text',
    'description' => 'type => text',
));

and the new WP_Customize_Control control.

$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'textfield_2_control', array(
    'label' => __('Textfield 2', 'cvh'),
    'section' => 'test_section',
    'settings' => 'textfield_setting_2',
    'description' => 'WP_Customize_Control',
)));

The output is the exact same (textfield).

enter image description here

2

There isn't really much of a difference for the default controls. Using the Class is needed for using custom built controls. So basically your first example is the short form of the second one only available for core controls.

For details have a look at the documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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