From 540498a0b249df10dc921059b790061440b4c04f Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Tue, 5 May 2020 17:26:01 +0200 Subject: [PATCH] beginning to implement custom settings in customizer --- kit/functions.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/kit/functions.php b/kit/functions.php index 25b7bcf..e119654 100644 --- a/kit/functions.php +++ b/kit/functions.php @@ -128,20 +128,33 @@ function theme_customize_register( $wp_customize ) { 'label' => esc_html__( 'Theme color', 'theme' ), ) ) ); - $wp_customize->add_setting('contact_mail', array( - 'default' => '', - 'type' => 'option', - 'transport' => 'refresh', - )); + $wp_customize->add_section( 'kit_advanced_settings' , array( + 'title' => __('Advanced settings','kit'), + 'priority' => 30, + ) ); - $wp_customize->add_control('contact_mail', array( - 'label' => __('Contact mail', 'contact_mail'), - 'section' => 'core', - 'settings' => 'contact_mail', - )); + $wp_customize->add_setting( 'kit_url_setting_id', array( + 'capability' => 'edit_theme_options', + 'sanitize_callback' => 'kit_sanitize_url', + ) ); + + $wp_customize->add_control( 'kit_url_setting_id', array( + 'type' => 'url', + 'section' => 'nav', + 'label' => __( 'Custom URL' ), + 'description' => __( 'This is a custom url input.' ), + 'input_attrs' => array( + 'placeholder' => __( 'http://www.google.com' ), + ), + ) ); + + function kit_sanitize_url( $url ) { + return esc_url_raw( $url ); + } } +add_action( 'customize_register', 'kit_advanced_settings' ); add_action( 'customize_register', 'theme_customize_register' ); function kit_customize_css()