label); ?>
label); ?>
choices as $choice): ?>
remove_section('colors'); $wp_customize->remove_section('background_image'); $wp_customize->get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; if (isset($wp_customize->selective_refresh)) { $wp_customize->selective_refresh->add_partial('blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'blogdescription_rcb' )); $wp_customize->selective_refresh->add_partial('blogname', array( 'selector' => 'a.site-logo', 'render_callback' => 'blogname_rcb' )); } /* Load Panels, Sections, Settings, Controls array */ require_once(dirname(__FILE__) . '/customizer-config.php'); /* Adding support for Child Themes */ $attire_panels = apply_filters(ATTIRE_THEME_PREFIX . 'customizer_panels', $attire_panels); $attire_sections = apply_filters(ATTIRE_THEME_PREFIX . 'customizer_sections', $attire_sections); $attire_options = apply_filters(ATTIRE_THEME_PREFIX . 'customizer_options', $attire_options); /* Basic Config */ $theme_option = $attire_config['option_name']; $capability = $attire_config['capability']; $option_type = $attire_config['option_type']; /* Add Panels */ foreach ($attire_panels as $id => $args) { $wp_customize->add_panel($id, $args); } /* Add Sections */ foreach ($attire_sections as $id => $args) { $wp_customize->add_section($id, $args); } /* Add Settings and Controls */ foreach ($attire_options as $id => $args) { extract($args); switch ($type) { case 'text': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control($id, array( 'label' => $label, 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', )); break; case 'textarea': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control($id, array( 'label' => $label, 'type' => 'textarea', 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', )); break; case 'email': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'attire_sanitize_email', )); $wp_customize->add_control($id, array( 'label' => $label, 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', )); break; case 'url': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control($id, array( 'label' => $label, 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', )); break; case 'number': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'attire_sanitize_integer', )); $wp_customize->add_control($id, array( 'label' => $label, 'type' => 'number', 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', 'input_attrs' => array( 'min' => isset($min) ? $min : 0, 'max' => isset($max) ? $max : 5, ) )); break; case 'image': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, $id, array( 'label' => $label, 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', ))); break; case 'select': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control($id, array( 'label' => $label, 'type' => 'select', 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', 'choices' => $choices, )); break; case 'color': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_hex_color', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $id, array( 'label' => $label, 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', ))); break; case 'layout': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control(new Layout_Picker_Custom_Control($wp_customize, $id, array( 'label' => $label, 'description' => '', 'type' => 'layout', 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', ))); break; case 'image-picker': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control(new Image_Picker_Custom_Control($wp_customize, $id, array( 'label' => $label, 'description' => '', 'type' => 'image-picker', 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', 'choices' => $choices, ))); break; case 'dropdown-pages': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'capability' => $capability, 'default' => $default, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'attire_sanitize_integer', )); $wp_customize->add_control($id, array( 'label' => $label, 'section' => $section, 'type' => 'dropdown-pages', 'settings' => $theme_option . '[' . $id . ']', )); break; case 'dropdown-taxonomy': $choices = array(); $taxonomies = get_terms($taxonomy, 'hide_empty=0'); if (count($taxonomies) > 0) { foreach ($taxonomies as $taxo) { $tid = isset($taxo->term_id) ? $taxo->term_id : null; $name = isset($taxo->name) ? $taxo->name : null; $choices[$tid] = $name; } } $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control($id, array( 'label' => $label, 'type' => 'select', 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', 'choices' => $choices, )); break; case 'typography': $fontsdata = AttireOptionFields::GetFonts(); $fonts = array(); $fonts[''] = 'Default'; foreach ($fontsdata as $key => $font) { $fonts[$key] = $font['name']; } asort($fonts); $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control($id, array( 'settings' => $theme_option . '[' . $id . ']', 'label' => $label, 'section' => $section, 'type' => 'select', 'choices' => $fonts, )); break; case 'range': $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => $default, 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'attire_sanitize_integer', )); $wp_customize->add_control( new WP_Customize_Range_Control( $wp_customize, $id, array( 'label' => $label, 'section' => $section, 'settings' => $theme_option . '[' . $id . ']', 'description' => __('Measurement is in pixel.', 'attire'), 'input_attrs' => $input_attrs, ) ) ); break; case 'dropdown-sidebar': global $wp_registered_sidebars; $sidebars = array(); $sidebars['no_sidebar'] = 'Do not apply'; foreach ($wp_registered_sidebars as $sidebar) { $sid = $sidebar['id']; $sidebars[$sid] = $sidebar['name']; } $wp_customize->add_setting($theme_option . '[' . $id . ']', array( 'default' => '', 'capability' => $capability, 'type' => $option_type, 'transport' => $transport, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control($id, array( 'settings' => $theme_option . '[' . $id . ']', 'label' => $label, 'section' => $section, 'type' => 'select', 'choices' => $sidebars, )); break; default: break; } if ($id === 'site_logo') { $wp_customize->selective_refresh->add_partial('site_logo_partial', array( 'settings' => array('attire_options[site_logo]'), 'selector' => '.site-logo', 'render_callback' => 'site_logo_rcb', 'fallback_refresh' => false, 'container_inclusive' => false, )); } elseif ($id === 'site_logo_footer') { $wp_customize->selective_refresh->add_partial('site_logo_footer_partial', array( 'settings' => array('attire_options[site_logo_footer]'), 'selector' => '.footer-logo', 'render_callback' => 'site_logo_footer_rcb', 'fallback_refresh' => false, 'container_inclusive' => false, )); } elseif ($id === 'nav_header') { $wp_customize->selective_refresh->add_partial('nav_header_partial', array( 'settings' => array('attire_options[nav_header]'), 'selector' => '.header-div', 'render_callback' => 'nav_header_rcb', 'fallback_refresh' => false, 'container_inclusive' => false, )); } elseif ($id === 'footer_style') { $wp_customize->selective_refresh->add_partial('footer_style_partial', array( 'settings' => array('attire_options[footer_style]'), 'selector' => '.footer-div', 'render_callback' => 'footer_style_rcb', 'fallback_refresh' => false, 'container_inclusive' => false, )); } elseif ($id === 'copyright_info') { $wp_customize->selective_refresh->add_partial('copyright_info_partial', array( 'settings' => array('attire_options[copyright_info]'), 'selector' => '.copyright-text', 'render_callback' => 'copyright_info_rcb', 'fallback_refresh' => false, 'container_inclusive' => false, )); } elseif ($id === 'copyright_info_visibility') { $wp_customize->selective_refresh->add_partial('copyright_info_visibility_partial', array( 'settings' => array('attire_options[copyright_info_visibility]'), 'selector' => '.copyright-outer', 'render_callback' => 'copyright_info_visibility_rcb', 'fallback_refresh' => false, 'container_inclusive' => false, )); } elseif ($id === 'attire_archive_page_post_view') { $wp_customize->selective_refresh->add_partial('attire_archive_page_post_view_partial', array( 'settings' => array('attire_options[attire_archive_page_post_view]'), 'selector' => '.archive-div', 'render_callback' => 'attire_archive_page_post_view_rcb', 'fallback_refresh' => false, 'container_inclusive' => false, )); } } } add_action('customize_register', 'attire_customize_register'); /** * * Sanitize Input Data */ function attire_sanitize_integer($input) { if (is_numeric($input)) { return intval($input); } } function attire_sanitize_email($input) { if (is_email($input)) { return $input; } } /** * * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function attire_customize_preview_js() { wp_enqueue_script('attire_customizer', get_template_directory_uri() . '/admin/js/customizer.js', array('customize-preview'), '20171015', true); } add_action('customize_preview_init', 'attire_customize_preview_js'); /** * * Customizing Customizer Controls */ function attire_customizer_style() { wp_enqueue_style('attire-customizer-controls-css', get_template_directory_uri() . '/admin/css/attire-customizer-controls.css'); wp_enqueue_script('attire-customizer-controls-js', get_template_directory_uri() . '/admin/js/attire-customizer-controls.js', array( 'jquery', 'customize-controls' ), false, true); } add_action('customize_controls_enqueue_scripts', 'attire_customizer_style'); /** * * Partials Render Callbacks * */ function blogdescription_rcb() { bloginfo('description'); } function blogname_rcb() { bloginfo('name'); } function site_logo_rcb() { return ''; } function site_logo_footer_rcb() { $logourl = esc_url(AttireThemeEngine::NextGetOption('site_logo_footer')); if ($logourl) { return " " . get_bloginfo("; } else { return get_bloginfo('sitename'); } } function nav_header_rcb() { AttireThemeEngine::HeaderStyle(); } function footer_style_rcb() { AttireThemeEngine::FooterStyle(); } function copyright_info_rcb() { return AttireThemeEngine::NextGetOption('copyright_info'); } function copyright_info_visibility_rcb() { $show = AttireThemeEngine::NextGetOption('copyright_info_visibility'); if ($show === 'show') { return '