WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Validating 'type' => 'text' Customizer control (3 posts)

  1. Slobodan Manic
    Member
    Posted 1 year ago #

    Hi,

    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!

  2. Slobodan Manic
    Member
    Posted 1 year ago #

    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.

  3. Slobodan Manic
    Member
    Posted 1 year ago #

    Another option is to use filter hook:

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

Topic Closed

This topic has been closed to new replies.

About this Topic