add_setting( 'apex_dental_primary_color_setting', array( 'default' => '#309cf4', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'apex_dental_primary_color_control', array( 'section' => 'colors', 'label' => esc_html__( 'Primary Color', 'apex-dentist' ), 'settings' => 'apex_dental_primary_color_setting', ) ) ); // Documentation Setting $wp_customize->add_setting( 'apex_dental_color_desc_setting', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'apex_dental_color_desc_control', array( /* Translators: %s: Documentation Link */ 'description' => sprintf( __( '%1$sUpgrade Premium%2$s for More Color Options!', 'apex-dentist' ), '', '' ), 'section' => 'colors', 'settings' => 'apex_dental_color_desc_setting', 'type' => 'hidden', ) ) ); } add_action( 'customize_register', 'apex_dentist_accent_color_setup'); /************************************************************************************************************************* * Topbar Settings ************************************************************************************************************************/ function apex_dentist_topbar_setup( $wp_customize ) { // Theme Options Panel $wp_customize->add_panel( 'apex-dental-topbar-panel', array( 'priority' => 10, 'title' => __( 'Top Bar Settings', 'apex-dentist' ), ) ); $wp_customize->add_section( 'apex-dental-topbar-setup-section', array( 'title' => 'Topbar Settings', 'priority' => 10, 'panel' => 'apex-dental-topbar-panel' ) ); // Enable/disable Topbar $wp_customize->add_setting( 'apex-dental-set-topbar-setting', array( 'default' => 'yes', 'sanitize_callback' => 'apex_dentist_sanitize_select', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'apex-dental-set-topbar-control', array( 'label' => __( 'Enable bottom bar copyright section?', 'apex-dentist' ), 'section' => 'apex-dental-topbar-setup-section', 'settings' => 'apex-dental-set-topbar-setting', 'type' => 'select', 'choices' => array( 'yes' => 'Yes', 'no' => 'No', ), ) ) ); // Display top bar phone number $wp_customize->add_setting( 'apex-dental-mob-number-setting', array( 'default' => '1800 666 5555', 'sanitize_callback' => 'apex_dental_sanitize_text', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'apex-dental-mob-number-control', array( 'label' => __( 'Enter Mobile Number', 'apex-dentist' ), 'type' => 'text', 'section' => 'apex-dental-topbar-setup-section', 'settings' => 'apex-dental-mob-number-setting', 'active_callback' => 'apex_dentist_is_topbar_enabled' ) ) ); // Display top bar email $wp_customize->add_setting( 'apex-dental-email-setting', array( 'default' => 'hello@example.com', 'sanitize_callback' => 'apex_dental_sanitize_text', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'apex-dental-email-control', array( 'label' => __( 'Enter Email Address', 'apex-dentist' ), 'type' => 'text', 'section' => 'apex-dental-topbar-setup-section', 'settings' => 'apex-dental-email-setting', 'active_callback' => 'apex_dentist_is_topbar_enabled' ) ) ); // Display top bar Location $wp_customize->add_setting( 'apex-dental-location-setting', array( 'default' => '', 'sanitize_callback' => 'apex_dental_sanitize_text', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'apex-dental-location-control', array( 'label' => __( 'Enter Location', 'apex-dentist' ), 'type' => 'text', 'section' => 'apex-dental-topbar-setup-section', 'settings' => 'apex-dental-location-setting', 'active_callback' => 'apex_dentist_is_topbar_enabled' ) ) ); } add_action( 'customize_register', 'apex_dentist_topbar_setup'); /************************************************************************************************************************* * General Settings ************************************************************************************************************************/ function apex_dentist_general_setup( $wp_customize ) { // Theme Options Panel $wp_customize->add_section( 'apex-dental-gen-settings-section', array( 'title' => 'General Settings', 'priority' => 10, ) ); // Enable/disable Topbar $wp_customize->add_setting( 'apex-dental-show-date-setting', array( 'default' => 'yes', 'sanitize_callback' => 'apex_dentist_sanitize_select', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'apex-dental-show-date-control', array( 'label' => __( 'Show Post Dates?', 'apex-dentist' ), 'section' => 'apex-dental-gen-settings-section', 'settings' => 'apex-dental-show-date-setting', 'type' => 'select', 'choices' => array( 'yes' => 'Yes', 'no' => 'No', ), ) ) ); } add_action( 'customize_register', 'apex_dentist_general_setup'); // if topbar enabled function apex_dentist_is_topbar_enabled() { if( get_theme_mod( "apex-dental-set-topbar-setting", 'yes' ) == 'yes' ) { return true; } return false; } function apex_dentist_sanitize_select( $input ) { $valid = array( 'yes' => 'Yes', 'no' => 'No', ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } }