Support » Themes and Templates » Validating 'type' => 'text' Customizer control

  • Resolved Slobodan Manic



    I’m ditching theme settings page in favor of Customizer, a few things I can’t figure out:

    1. Do I still need to do the entire ‘register_setting’, ‘add_settings_section’ and ‘add_settings_field’ thing, or is Customizer enough?
    2. How would I validate ‘type’ = ‘text’ control in Customizer?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Figured it out by browsing core code. In case someone else runs into this, when doing $wp_customize->add_setting you can set ‘sanitize_callback’ argument.

    Since it’s all working, I guess there’s absolutely no need to go through Settings API.

    Another option is to use filter hook:

    add_filter( 'customize_sanitize_{$customize_setting_id}', 'your_sanitize_function' );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Validating 'type' => 'text' Customizer control’ is closed to new replies.