Last active
September 1, 2019 04:31
-
-
Save ajskelton/8d7122dfacdb33be83dba476e5dd10ae to your computer and use it in GitHub Desktop.
Add a Email field to the WordPress Customizer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$wp_customize->add_setting( 'themeslug_email_setting_id', array( | |
'capability' => 'edit_theme_options', | |
'default' => '', | |
'sanitize_callback' => 'themeslug_sanitize_email', | |
) ); | |
$wp_customize->add_control( 'themeslug_email_setting_id', array( | |
'type' => 'email', | |
'section' => 'custom_section', // Required, core or custom. | |
'label' => __( 'Custom Email' ), | |
'description' => __( 'This is a custom email input.' ), | |
'input_attrs' => array( | |
'placeholder' => __( 'email@domain.com' ), | |
), | |
) ); | |
function themeslug_sanitize_email( $email, $setting ) { | |
return ( is_email($email) ? $email : $setting->default ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment