function azeria_add_customizer($wp_customize) { /* Header Logo section ---------------------------------------------------------*/ $wp_customize->add_section('azeria_header_logo', array('title' => __('Header Logo', 'azeria'), 'priority' => 40)); /* Logo image */ $wp_customize->add_setting('azeria[logo_img]', array('default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_image')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'azeria_logo_img', array('label' => __('Logo Image', 'azeria'), 'section' => 'azeria_header_logo', 'settings' => 'azeria[logo_img]', 'priority' => 1))); /* Slider section ----------------------------------------------------*/ $wp_customize->add_section('azeria_slider', array('title' => __('Slider', 'azeria'), 'priority' => 61)); /* Enable slider */ $wp_customize->add_setting('azeria[slider_enabled]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_slider_enabled', array('label' => __('Enable/disable slider', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slider_enabled]', 'type' => 'checkbox', 'priority' => 1)); /* Slider visibility */ $wp_customize->add_setting('azeria[slider_visibility]', array('default' => 'front', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_select')); $wp_customize->add_control('azeria_slider_visibility', array('label' => __('Slider visibility', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slider_visibility]', 'type' => 'select', 'priority' => 2, 'choices' => array('front' => __('Only on Front page', 'azeria'), 'all' => __('On all pages', 'azeria')))); /* Get slides from */ $wp_customize->add_setting('azeria[slides_from]', array('default' => 'recent_posts', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_select')); $wp_customize->add_control('azeria_slides_from', array('label' => __('Get slides from', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slides_from]', 'type' => 'select', 'priority' => 2, 'choices' => apply_filters('azeria_slides_from_choices', array('recent_posts' => __('Recent Posts (Default)', 'azeria'), 'sticky' => __('Sticky Posts (Recommended)', 'azeria'), 'category' => __('Specific Category', 'azeria'))))); /* Category to get from */ $wp_customize->add_setting('azeria[slides_cat]', array('default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field')); $wp_customize->add_control('azeria_slides_cat', array('label' => __('Category slug to get slides from (only if Specific Category selected)', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slides_cat]', 'type' => 'text', 'priority' => 3)); /* Slides number */ $wp_customize->add_setting('azeria[slides_num]', array('default' => 4, 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_num')); $wp_customize->add_control('azeria_slides_num', array('label' => __('Slides number to show', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slides_num]', 'type' => 'number', 'input_attrs' => array('min' => 0, 'max' => 20, 'step' => 1), 'priority' => 4)); /* Show/hide slides banners */ $wp_customize->add_setting('azeria[slider_banner]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_slider_banner', array('label' => __('Show/hide slider banner', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slider_banner]', 'type' => 'checkbox', 'priority' => 5)); /* Banner button text */ $wp_customize->add_setting('azeria[slider_btn_text]', array('default' => __('Read', 'azeria'), 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field')); $wp_customize->add_control('azeria_slider_btn_text', array('label' => __('Banner read more button text', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slider_btn_text]', 'type' => 'text', 'priority' => 6)); /* Show arrows */ $wp_customize->add_setting('azeria[slider_arrows]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_slider_arrows', array('label' => __('Show/hide control arrows', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slider_arrows]', 'type' => 'checkbox', 'priority' => 7)); /* Show pager */ $wp_customize->add_setting('azeria[slider_pager]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_slider_pager', array('label' => __('Show/hide pager control', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slider_pager]', 'type' => 'checkbox', 'priority' => 8)); /* Animation type */ $wp_customize->add_setting('azeria[slider_animation]', array('default' => 'slide', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_select')); $wp_customize->add_control('azeria_slider_animation', array('label' => __('Select animation type', 'azeria'), 'section' => 'azeria_slider', 'settings' => 'azeria[slider_animation]', 'type' => 'select', 'priority' => 9, 'choices' => array('slide' => __('Slide', 'azeria'), 'fade' => __('Fade', 'azeria')))); /* Blog section ----------------------------------------------------*/ $wp_customize->add_section('azeria_blog', array('title' => __('Blog', 'azeria'), 'priority' => 62)); /* Blog content */ $wp_customize->add_setting('azeria[blog_content]', array('default' => 'excerpt', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_select')); $wp_customize->add_control('azeria_blog_content', array('label' => __('Slider visibility', 'azeria'), 'section' => 'azeria_blog', 'settings' => 'azeria[blog_content]', 'type' => 'select', 'priority' => 1, 'choices' => array('excerpt' => __('Only excerpt', 'azeria'), 'content' => __('Full content', 'azeria')))); /* Loop featured image */ $wp_customize->add_setting('azeria[blog_loop_image]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_blog_loop_image', array('label' => __('Loop page: show featured image', 'azeria'), 'section' => 'azeria_blog', 'settings' => 'azeria[blog_loop_image]', 'type' => 'checkbox', 'priority' => 2)); /* Single featured image */ $wp_customize->add_setting('azeria[blog_single_image]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_blog_single_image', array('label' => __('Single page: show featured image', 'azeria'), 'section' => 'azeria_blog', 'settings' => 'azeria[blog_single_image]', 'type' => 'checkbox', 'priority' => 3)); /* Loop show button */ $wp_customize->add_setting('azeria[blog_more]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_blog_more', array('label' => __('Loop page: show read more button', 'azeria'), 'section' => 'azeria_blog', 'settings' => 'azeria[blog_more]', 'type' => 'checkbox', 'priority' => 4)); /* Read button text */ $wp_customize->add_setting('azeria[blog_more_text]', array('default' => __('Read', 'azeria'), 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field')); $wp_customize->add_control('azeria_blog_more_text', array('label' => __('Loop page: read more button text', 'azeria'), 'section' => 'azeria_blog', 'settings' => 'azeria[blog_more_text]', 'type' => 'text', 'priority' => 5)); /* Sidebar position */ $wp_customize->add_setting('azeria[sidebar_position]', array('default' => 'right', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_select')); $wp_customize->add_control('azeria_sidebar_position', array('label' => __('Sidebar position', 'azeria'), 'section' => 'azeria_blog', 'settings' => 'azeria[sidebar_position]', 'type' => 'select', 'priority' => 6, 'choices' => array('right' => __('Right', 'azeria'), 'left' => __('Left', 'azeria')))); /* Footer section ----------------------------------------------------*/ $wp_customize->add_section('azeria_footer', array('title' => __('Footer', 'azeria'), 'priority' => 63)); /* Custom copyright */ $wp_customize->add_setting('azeria[footer_copyright]', array('default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_textarea')); $wp_customize->add_control('azeria_blog_more_text', array('label' => __('Set custom copyright text', 'azeria'), 'section' => 'azeria_footer', 'settings' => 'azeria[footer_copyright]', 'type' => 'textarea', 'priority' => 1)); /* About section ----------------------------------------------------*/ $wp_customize->add_section('azeria_about', array('title' => __('About box', 'azeria'), 'priority' => 81)); /* Enable about */ $wp_customize->add_setting('azeria[about_enabled]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_about_enabled', array('label' => __('Enable About box in sidebar', 'azeria'), 'section' => 'azeria_about', 'settings' => 'azeria[about_enabled]', 'type' => 'checkbox', 'priority' => 1)); /* About title */ $wp_customize->add_setting('azeria[about_title]', array('default' => __('About Me', 'azeria'), 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field')); $wp_customize->add_control('azeria_about_title', array('label' => __('Enter sidebar about box title', 'azeria'), 'section' => 'azeria_about', 'settings' => 'azeria[about_title]', 'type' => 'text', 'priority' => 2)); /* About image */ $wp_customize->add_setting('azeria[about_img]', array('default' => '', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_image')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'azeria_about_img', array('label' => __('About Image', 'azeria'), 'section' => 'azeria_about', 'settings' => 'azeria[about_img]', 'priority' => 3))); /* About message */ $wp_customize->add_setting('azeria[about_message]', array('default' => __('Hello! And welcome to my personal website!', 'azeria'), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_textarea')); $wp_customize->add_control('azeria_about_message', array('label' => __('Set about box message text', 'azeria'), 'section' => 'azeria_about', 'settings' => 'azeria[about_message]', 'type' => 'textarea', 'priority' => 4)); /* Follow section ----------------------------------------------------*/ $wp_customize->add_section('azeria_follow', array('title' => __('Follow box', 'azeria'), 'priority' => 82)); /* Enable follow */ $wp_customize->add_setting('azeria[follow_enabled]', array('default' => '1', 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_checkbox')); $wp_customize->add_control('azeria_follow_enabled', array('label' => __('Enable Follow box in sidebar', 'azeria'), 'section' => 'azeria_follow', 'settings' => 'azeria[follow_enabled]', 'type' => 'checkbox', 'priority' => 1)); /* Follow title */ $wp_customize->add_setting('azeria[follow_title]', array('default' => __('Follow Me', 'azeria'), 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field')); $wp_customize->add_control('azeria_follow_title', array('label' => __('Enter follow about box title', 'azeria'), 'section' => 'azeria_follow', 'settings' => 'azeria[follow_title]', 'type' => 'text', 'priority' => 2)); /* Social links */ $socials = azeria_allowed_socials(); // prevent error from wrong filters applied if (is_array($socials)) { // add allowed nets to customizer foreach ($socials as $net => $data) { $data = wp_parse_args($data, array('label' => '', 'icon' => '', 'default' => '')); $wp_customize->add_setting('azeria[follow_' . $net . ']', array('default' => $data['default'], 'type' => 'theme_mod', 'sanitize_callback' => 'azeria_sanitize_url')); $wp_customize->add_control('azeria_follow_' . $net, array('label' => sprintf(__('Link to %s account:', 'azeria'), $data['label']), 'section' => 'azeria_follow', 'settings' => 'azeria[follow_' . $net . ']', 'type' => 'text', 'priority' => 3)); } } }
function azeria_follow_box() { $is_enabled = azeria_get_option('follow_enabled', true); if (!$is_enabled) { return; } $socials = azeria_allowed_socials(); if (!is_array($socials)) { return; } $title = azeria_get_option('follow_title', __('Follow Me', 'azeria')); $title_html = !empty($title) ? sprintf('<h4 class="widget-title">%s</h4>', sanitize_text_field($title)) : ''; $social_list = ''; $item_format = '<div class="custom-box-follow-item"><a href="%1$s" class="item-%3$s"><i class="%2$s"></i></a></div>'; foreach ($socials as $net => $data) { $data = wp_parse_args($data, array('label' => '', 'icon' => '', 'default' => '')); $url = azeria_get_option('follow_' . $net, $data['default']); if (!$url) { continue; } $social_list .= sprintf($item_format, esc_url($url), esc_attr($data['icon']), esc_attr($net)); } $social_list_html = !empty($social_list) ? sprintf('<div class="custom-box-follow-list">%s</div>', $social_list) : ''; ?> <div class="widget custom-box-follow"> <?php echo $title_html; ?> <?php echo $social_list_html; ?> </div> <?php }