get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; } add_action( 'customize_register', 'apazit_customize_register' ); /** * Options for apazit Theme Customizer. */ function apazit_customizer( $wp_customize ) { /* Main option Settings Panel */ $wp_customize->add_panel('apazit_main_options', array( 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('apazit Options', 'apazit'), 'description' => __('Panel to update apazit theme options', 'apazit'), // Include html tags such as
. 'priority' => 10 // Mixed with top-level-section hierarchy. )); // add "Content Options" section $wp_customize->add_section( 'apazit_content_section' , array( 'title' => esc_html__( 'Content Options', 'apazit' ), 'priority' => 50, 'panel' => 'apazit_main_options' ) ); // add setting for excerpts/full posts toggle $wp_customize->add_setting( 'apazit_excerpts', array( 'default' => 1, 'sanitize_callback' => 'apazit_sanitize_checkbox', ) ); // add checkbox control for excerpts/full posts toggle $wp_customize->add_control( 'apazit_excerpts', array( 'label' => esc_html__( 'Show post excerpts?', 'apazit' ), 'section' => 'apazit_content_section', 'priority' => 10, 'type' => 'checkbox' ) ); $wp_customize->add_setting( 'apazit_page_comments', array( 'default' => 1, 'sanitize_callback' => 'apazit_sanitize_checkbox', ) ); $wp_customize->add_control( 'apazit_page_comments', array( 'label' => esc_html__( 'Display Comments on Static Pages?', 'apazit' ), 'section' => 'apazit_content_section', 'priority' => 20, 'type' => 'checkbox', ) ); /* apazit Main Options */ $wp_customize->add_section('apazit_slider_options', array( 'title' => __('Slider options', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); $wp_customize->add_setting( 'apazit[apazit_slider_checkbox]', array( 'default' => 0, 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_checkbox', ) ); $wp_customize->add_control( 'apazit[apazit_slider_checkbox]', array( 'label' => esc_html__( 'Check if you want to enable slider', 'apazit' ), 'section' => 'apazit_slider_options', 'priority' => 5, 'type' => 'checkbox', ) ); // Pull all the categories into an array global $options_categories; $wp_customize->add_setting('apazit[apazit_slide_categories]', array( 'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'apazit_sanitize_slidecat' )); $wp_customize->add_control('apazit[apazit_slide_categories]', array( 'label' => __('Slider Category', 'apazit'), 'section' => 'apazit_slider_options', 'type' => 'select', 'description' => __('Select a category for the featured post slider', 'apazit'), 'choices' => $options_categories )); $wp_customize->add_setting('apazit[apazit_slide_number]', array( 'default' => 3, 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_number' )); $wp_customize->add_control('apazit[apazit_slide_number]', array( 'label' => __('Number of slide items', 'apazit'), 'section' => 'apazit_slider_options', 'description' => __('Enter the number of slide items', 'apazit'), 'type' => 'text' )); $wp_customize->add_section('apazit_layout_options', array( 'title' => __('Layout options', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); // Layout options global $site_layout; $wp_customize->add_setting('apazit[site_layout]', array( 'default' => 'side-pull-left', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_layout' )); $wp_customize->add_control('apazit[site_layout]', array( 'label' => __('Website Layout Options', 'apazit'), 'section' => 'apazit_layout_options', 'type' => 'select', 'description' => __('Choose between different layout options to be used as default', 'apazit'), 'choices' => $site_layout )); if ( class_exists( 'WooCommerce' ) ) { $wp_customize->add_setting('apazit[woo_site_layout]', array( 'default' => 'full-width', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_layout' )); $wp_customize->add_control('apazit[woo_site_layout]', array( 'label' => __('WooCommerce Page Layout Options', 'apazit'), 'section' => 'apazit_layout_options', 'type' => 'select', 'description' => __('Choose between different layout options to be used as default for all woocommerce pages', 'apazit'), 'choices' => $site_layout )); } $wp_customize->add_setting('apazit[element_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[element_color]', array( 'label' => __('Element Color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_layout_options', 'settings' => 'apazit[element_color]', ))); $wp_customize->add_setting('apazit[element_color_hover]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[element_color_hover]', array( 'label' => __('Element color on hover', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_layout_options', 'settings' => 'apazit[element_color_hover]', ))); /* apazit Action Options */ $wp_customize->add_section('apazit_action_options', array( 'title' => __('Action Button', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); $wp_customize->add_setting('apazit[w2f_cfa_text]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_strip_slashes' )); $wp_customize->add_control('apazit[w2f_cfa_text]', array( 'label' => __('Call For Action Text', 'apazit'), 'description' => sprintf(__('Enter the text for call for action section', 'apazit')), 'section' => 'apazit_action_options', 'type' => 'textarea' )); $wp_customize->add_setting('apazit[w2f_cfa_button]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_nohtml' )); $wp_customize->add_control('apazit[w2f_cfa_button]', array( 'label' => __('Call For Action Button Title', 'apazit'), 'section' => 'apazit_action_options', 'description' => __('Enter the title for Call For Action button', 'apazit'), 'type' => 'text' )); $wp_customize->add_setting('apazit[w2f_cfa_link]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('apazit[w2f_cfa_link]', array( 'label' => __('CFA button link', 'apazit'), 'section' => 'apazit_action_options', 'description' => __('Enter the link for Call For Action button', 'apazit'), 'type' => 'text' )); $wp_customize->add_setting('apazit[cfa_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[cfa_color]', array( 'label' => __('Call For Action Text Color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_action_options', ))); $wp_customize->add_setting('apazit[cfa_bg_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[cfa_bg_color]', array( 'label' => __('Call For Action Background Color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_action_options', ))); $wp_customize->add_setting('apazit[cfa_btn_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[cfa_btn_color]', array( 'label' => __('Call For Action Button Border Color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_action_options', ))); $wp_customize->add_setting('apazit[cfa_btn_txt_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[cfa_btn_txt_color]', array( 'label' => __('Call For Action Button Text Color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_action_options', ))); /* apazit Typography Options */ $wp_customize->add_section('apazit_typography_options', array( 'title' => __('Typography', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); // Typography Defaults $typography_defaults = array( 'size' => '14px', 'face' => 'Open Sans', 'style' => 'normal', 'color' => '#6B6B6B' ); // Typography Options global $typography_options; $wp_customize->add_setting('apazit[main_body_typography][size]', array( 'default' => $typography_defaults['size'], 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_typo_size' )); $wp_customize->add_control('apazit[main_body_typography][size]', array( 'label' => __('Main Body Text', 'apazit'), 'description' => __('Used in p tags', 'apazit'), 'section' => 'apazit_typography_options', 'type' => 'select', 'choices' => $typography_options['sizes'] )); $wp_customize->add_setting('apazit[main_body_typography][face]', array( 'default' => $typography_defaults['face'], 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_typo_face' )); $wp_customize->add_control('apazit[main_body_typography][face]', array( 'section' => 'apazit_typography_options', 'type' => 'select', 'choices' => $typography_options['faces'] )); $wp_customize->add_setting('apazit[main_body_typography][style]', array( 'default' => $typography_defaults['style'], 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_typo_style' )); $wp_customize->add_control('apazit[main_body_typography][style]', array( 'section' => 'apazit_typography_options', 'type' => 'select', 'choices' => $typography_options['styles'] )); $wp_customize->add_setting('apazit[main_body_typography][color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[main_body_typography][color]', array( 'section' => 'apazit_typography_options', ))); $wp_customize->add_setting('apazit[heading_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[heading_color]', array( 'label' => __('Heading Color', 'apazit'), 'description' => __('Color for all headings (h1-h6)','apazit'), 'section' => 'apazit_typography_options', ))); $wp_customize->add_setting('apazit[link_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[link_color]', array( 'label' => __('Link Color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_typography_options', ))); $wp_customize->add_setting('apazit[link_hover_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[link_hover_color]', array( 'label' => __('Link:hover Color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_typography_options', ))); /* apazit Header Options */ $wp_customize->add_section('apazit_header_options', array( 'title' => __('Header', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); $wp_customize->add_setting('apazit[sticky_header]', array( 'default' => 0, 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_checkbox' )); $wp_customize->add_control('apazit[sticky_header]', array( 'label' => __('Sticky Header', 'apazit'), 'description' => sprintf(__('Check to show fixed header', 'apazit')), 'section' => 'apazit_header_options', 'type' => 'checkbox', )); $wp_customize->add_setting('apazit[nav_bg_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[nav_bg_color]', array( 'label' => __('Top nav background color', 'apazit'), 'description' => __('Default used if no color is selected','apazit'), 'section' => 'apazit_header_options', ))); $wp_customize->add_setting('apazit[nav_link_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[nav_link_color]', array( 'label' => __('Top nav item color', 'apazit'), 'description' => __('Link color','apazit'), 'section' => 'apazit_header_options', ))); $wp_customize->add_setting('apazit[nav_item_hover_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[nav_item_hover_color]', array( 'label' => __('Top nav item hover color', 'apazit'), 'description' => __('Link:hover color','apazit'), 'section' => 'apazit_header_options', ))); $wp_customize->add_setting('apazit[nav_dropdown_bg]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[nav_dropdown_bg]', array( 'label' => __('Top nav dropdown background color', 'apazit'), 'description' => __('Background of dropdown item hover color','apazit'), 'section' => 'apazit_header_options', ))); $wp_customize->add_setting('apazit[nav_dropdown_item]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[nav_dropdown_item]', array( 'label' => __('Top nav dropdown item color', 'apazit'), 'description' => __('Dropdown item color','apazit'), 'section' => 'apazit_header_options', ))); $wp_customize->add_setting('apazit[nav_dropdown_item_hover]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[nav_dropdown_item_hover]', array( 'label' => __('Top nav dropdown item hover color', 'apazit'), 'description' => __('Dropdown item hover color','apazit'), 'section' => 'apazit_header_options', ))); $wp_customize->add_setting('apazit[nav_dropdown_bg_hover]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[nav_dropdown_bg_hover]', array( 'label' => __('Top nav dropdown item background hover color', 'apazit'), 'description' => __('Background of dropdown item hover color','apazit'), 'section' => 'apazit_header_options', ))); /* apazit Footer Options */ $wp_customize->add_section('apazit_footer_options', array( 'title' => __('Footer', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); $wp_customize->add_setting('apazit[footer_widget_bg_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[footer_widget_bg_color]', array( 'label' => __('Footer widget area background color', 'apazit'), 'section' => 'apazit_footer_options', ))); $wp_customize->add_setting('apazit[footer_bg_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[footer_bg_color]', array( 'label' => __('Footer background color', 'apazit'), 'section' => 'apazit_footer_options', ))); $wp_customize->add_setting('apazit[footer_text_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[footer_text_color]', array( 'label' => __('Footer text color', 'apazit'), 'section' => 'apazit_footer_options', ))); $wp_customize->add_setting('apazit[footer_link_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[footer_link_color]', array( 'label' => __('Footer link color', 'apazit'), 'section' => 'apazit_footer_options', ))); $wp_customize->add_setting('apazit[custom_footer_text]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_strip_slashes' )); $wp_customize->add_control('apazit[custom_footer_text]', array( 'label' => __('Footer information', 'apazit'), 'description' => sprintf(__('Copyright text in footer', 'apazit')), 'section' => 'apazit_footer_options', 'type' => 'textarea' )); /* apazit Social Options */ $wp_customize->add_section('apazit_social_options', array( 'title' => __('Social', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); $wp_customize->add_setting('apazit[social_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[social_color]', array( 'label' => __('Social icon color', 'apazit'), 'description' => sprintf(__('Default used if no color is selected', 'apazit')), 'section' => 'apazit_social_options', ))); $wp_customize->add_setting('apazit[social_footer_color]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_hexcolor' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apazit[social_footer_color]', array( 'label' => __('Footer social icon color', 'apazit'), 'description' => sprintf(__('Default used if no color is selected', 'apazit')), 'section' => 'apazit_social_options', ))); $wp_customize->add_setting('apazit[footer_social]', array( 'default' => 0, 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_checkbox' )); $wp_customize->add_control('apazit[footer_social]', array( 'label' => __('Footer Social Icons', 'apazit'), 'description' => sprintf(__('Check to show social icons in footer', 'apazit')), 'section' => 'apazit_social_options', 'type' => 'checkbox', )); /* apazit Other Options */ $wp_customize->add_section('apazit_other_options', array( 'title' => __('Other', 'apazit'), 'priority' => 31, 'panel' => 'apazit_main_options' )); $wp_customize->add_setting('apazit[custom_css]', array( 'default' => '', 'type' => 'option', 'sanitize_callback' => 'apazit_sanitize_textarea' )); $wp_customize->add_control('apazit[custom_css]', array( 'label' => __('Custom CSS', 'apazit'), 'description' => sprintf(__('Additional CSS', 'apazit')), 'section' => 'apazit_other_options', 'type' => 'textarea' )); $wp_customize->add_section('apazit_important_links', array( 'priority' => 5, 'title' => __('Support and Documentation', 'apazit') )); $wp_customize->add_setting('apazit[imp_links]', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control( new apazit_Important_Links( $wp_customize, 'apazit[imp_links]', array( 'section' => 'apazit_important_links', 'type' => 'apazit-important-links' ))); } add_action( 'customize_register', 'apazit_customizer' ); /** * Sanitzie checkbox for WordPress customizer */ function apazit_sanitize_checkbox( $input ) { if ( $input == 1 ) { return 1; } else { return ''; } } /** * Adds sanitization callback function: colors * @package apazit */ function apazit_sanitize_hexcolor($color) { if ($unhashed = sanitize_hex_color_no_hash($color)) return '#' . $unhashed; return $color; } /** * Adds sanitization callback function: Nohtml * @package apazit */ function apazit_sanitize_nohtml($input) { return wp_filter_nohtml_kses($input); } /** * Adds sanitization callback function: Number * @package apazit */ function apazit_sanitize_number($input) { if ( isset( $input ) && is_numeric( $input ) ) { return $input; } } /** * Adds sanitization callback function: Strip Slashes * @package apazit */ function apazit_sanitize_strip_slashes($input) { return wp_kses_stripslashes($input); } /** * Adds sanitization callback function: Sanitize Text area * @package apazit */ function apazit_sanitize_textarea($input) { return sanitize_text_field($input); } /** * Adds sanitization callback function: Slider Category * @package apazit */ function apazit_sanitize_slidecat( $input ) { global $options_categories; if ( array_key_exists( $input, $options_categories ) ) { return $input; } else { return ''; } } /** * Adds sanitization callback function: Sidebar Layout * @package apazit */ function apazit_sanitize_layout( $input ) { global $site_layout; if ( array_key_exists( $input, $site_layout ) ) { return $input; } else { return ''; } } /** * Adds sanitization callback function: Typography Size * @package apazit */ function apazit_sanitize_typo_size( $input ) { global $typography_options, $typography_defaults; if ( array_key_exists( $input, $typography_options['sizes'] ) ) { return $input; } else { return $typography_defaults['size']; } } /** * Adds sanitization callback function: Typography Face * @package apazit */ function apazit_sanitize_typo_face( $input ) { global $typography_options, $typography_defaults; if ( array_key_exists( $input, $typography_options['faces'] ) ) { return $input; } else { return $typography_defaults['face']; } } /** * Adds sanitization callback function: Typography Style * @package apazit */ function apazit_sanitize_typo_style( $input ) { global $typography_options, $typography_defaults; if ( array_key_exists( $input, $typography_options['styles'] ) ) { return $input; } else { return $typography_defaults['style']; } } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function apazit_customize_preview_js() { wp_enqueue_script( 'apazit_customizer', get_template_directory_uri() . '/inc/js/customizer.js', array( 'customize-preview' ), '20140317', true ); } add_action( 'customize_preview_init', 'apazit_customize_preview_js' ); /** * Add CSS for custom controls */ function apazit_customizer_custom_control_css() { ?>