Пример #1
0
function athena_icon_sanitize($input)
{
    $valid_keys = athena_icons();
    if (array_key_exists($input, $valid_keys)) {
        return $input;
    } else {
        return '';
    }
}
Пример #2
0
/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function athena_customize_register($wp_customize)
{
    // reset some stuff
    $wp_customize->remove_section('header_image');
    $wp_customize->remove_section('background_image');
    $wp_customize->remove_section('colors');
    $wp_customize->remove_section('static_front_page');
    $wp_customize->remove_section('title_tagline');
    // *********************************************
    // ****************** General ******************
    // *********************************************
    $wp_customize->add_panel('logo', array('title' => __('Logo, Title & Favicon', 'athena'), 'description' => __('set the logo image, site title, description and site icon favicon', 'athena'), 'priority' => 10));
    $wp_customize->add_section('logo', array('title' => __('Logo', 'athena'), 'panel' => 'logo'));
    $wp_customize->add_panel('general', array('title' => __('General', 'athena'), 'description' => __('General settings for your site, such as title, favicon and more', 'athena'), 'priority' => 10));
    // *********************************************
    // ****************** Slider *****************
    // *********************************************
    $wp_customize->add_panel('slider', array('title' => __('Slider', 'athena'), 'description' => __('Customize the slider', 'athena'), 'priority' => 10));
    $wp_customize->add_section('slide1', array('title' => __('Slide #1', 'athena'), 'description' => __('Use the settings below to upload your images, set main callout text and button text & URLs', 'athena'), 'panel' => 'slider'));
    $wp_customize->add_section('slide2', array('title' => __('Slide #2', 'athena'), 'description' => __('Use the settings below to upload your images, set main callout text and button text & URLs', 'athena'), 'panel' => 'slider'));
    // 1st slide
    $wp_customize->add_setting('featured_image1', array('default' => get_template_directory_uri() . '/inc/images/athena.jpg', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'image_control1', array('label' => __('Background Image', 'athena'), 'section' => 'slide1', 'mime_type' => 'image', 'settings' => 'featured_image1', 'description' => __('Select the image file that you would like to use as the featured images', 'athena'))));
    $wp_customize->add_setting('featured_image1_title', array('default' => __('Welcome to Athena', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('featured_image1_title', array('type' => 'text', 'section' => 'slide1', 'label' => __('Header Text', 'athena'), 'description' => __('The main heading text, leave blank to hide', 'athena')));
    $wp_customize->add_setting('slide1_button1_text', array('default' => __('View Features', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide1_button1_text', array('type' => 'text', 'section' => 'slide1', 'label' => __('Button #1 Text', 'athena'), 'description' => __('The text for the button, leave blank to hide', 'athena')));
    $wp_customize->add_setting('slide1_button1_url', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide1_button1_url', array('type' => 'text', 'section' => 'slide1', 'label' => __('Button #1 URL', 'athena')));
    $wp_customize->add_setting('slide1_button2_text', array('default' => __('Learn More', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide1_button2_text', array('type' => 'text', 'section' => 'slide1', 'label' => __('Button #2 Text', 'athena'), 'description' => __('The text for the button, leave blank to hide', 'athena')));
    $wp_customize->add_setting('slide1_button2_url', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide1_button2_url', array('type' => 'text', 'section' => 'slide1', 'label' => __('Button #2 URL', 'athena')));
    // 2nd slide
    $wp_customize->add_setting('featured_image2', array('default' => get_template_directory_uri() . '/inc/images/athena2.jpg', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'image_control2', array('label' => __('Background Image', 'athena'), 'section' => 'slide2', 'mime_type' => 'image', 'settings' => 'featured_image2', 'description' => __('Select the image file that you would like to use as the featured images', 'athena'))));
    $wp_customize->add_setting('featured_image2_title', array('default' => __('Welcome to Athena', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('featured_image2_title', array('type' => 'text', 'section' => 'slide2', 'label' => __('Header Text', 'athena'), 'description' => __('The main heading text, leave blank to hide', 'athena')));
    $wp_customize->add_setting('slide2_button1_text', array('default' => __('View Features', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide2_button1_text', array('type' => 'text', 'section' => 'slide2', 'label' => __('Button #1 Text', 'athena'), 'description' => __('The text for the button, leave blank to hide', 'athena')));
    $wp_customize->add_setting('slide2_button1_url', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide2_button1_url', array('type' => 'text', 'section' => 'slide2', 'label' => __('Button #1 URL', 'athena')));
    $wp_customize->add_setting('slide2_button2_text', array('default' => __('Learn More', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide2_button2_text', array('type' => 'text', 'section' => 'slide2', 'label' => __('Button #2 Text', 'athena'), 'description' => __('The text for the button, leave blank to hide', 'athena')));
    $wp_customize->add_setting('slide2_button2_url', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('slide2_button2_url', array('type' => 'text', 'section' => 'slide2', 'label' => __('Button #2 URL', 'athena')));
    // *********************************************
    // ****************** Homepage *****************
    // *********************************************
    $wp_customize->add_panel('homepage', array('title' => __('Frontpage', 'athena'), 'description' => __('Customize the appearance of your homepage', 'athena'), 'priority' => 10));
    $wp_customize->add_section('homepage_callouts', array('title' => __('Icon Callouts', 'athena'), 'panel' => 'homepage'));
    $wp_customize->add_section('homepage_widget', array('title' => __('Homepage Widget', 'athena'), 'panel' => 'homepage'));
    // 1st slide
    $wp_customize->add_setting('homepage_widget_background', array('default' => get_template_directory_uri() . '/inc/images/widget.jpg', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'image_control1', array('label' => __('Widget Background', 'athena'), 'section' => 'homepage_widget', 'mime_type' => 'image', 'settings' => 'homepage_widget_background', 'description' => __('Select the image file that you would like to use as the background image', 'athena'))));
    $wp_customize->add_section('homepage_overlay', array('title' => __('Overlay', 'athena'), 'description' => __('The overlay appears after the user clicks the icon on the bottom-right of the slider', 'athena'), 'panel' => 'homepage'));
    $wp_customize->add_section('static_front_page', array('title' => __('Static Front Page', 'athena'), 'panel' => 'homepage'));
    $wp_customize->add_section('title_tagline', array('title' => __('Site Title, Tagline & Favicon', 'athena'), 'panel' => 'logo'));
    $wp_customize->add_setting('overlay_bool', array('default' => 'on', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('overlay_bool', array('label' => __('Enable Homepage Overlay Widget', 'athena'), 'section' => 'homepage_overlay', 'type' => 'radio', 'choices' => array('on' => __('Show', 'athena'), 'off' => __('Hide', 'athena'))));
    $wp_customize->add_setting('overlay_icon', array('default' => 'fa fa-question-circle', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('overlay_icon', array('label' => __('Overlay Trigger Icon', 'athena'), 'section' => 'homepage_overlay', 'type' => 'select', 'choices' => athena_icons()));
    // Callout #1
    $wp_customize->add_setting('callout1_icon', array('default' => 'fa fa-laptop', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout1_icon', array('label' => __('Callout #1: Select Icon', 'athena'), 'section' => 'homepage_callouts', 'type' => 'select', 'choices' => athena_icons()));
    $wp_customize->add_setting('callout1_title', array('default' => 'Responsive', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout1_title', array('type' => 'text', 'section' => 'homepage_callouts', 'label' => __('Callout #1: Title', 'athena'), 'description' => __('Set the callout title text', 'athena')));
    $wp_customize->add_setting('callout1_text', array('default' => __('Athena is a carefully designed and developed theme that you can use to make your site stand out', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout1_text', array('type' => 'textarea', 'section' => 'homepage_callouts', 'label' => __('Callout #1: Description', 'athena'), 'description' => __('Set the callout detail text', 'athena')));
    // Callout #2
    $wp_customize->add_setting('callout2_icon', array('default' => 'fa fa-magic', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout2_icon', array('label' => __('Callout #2: Select Icon', 'athena'), 'section' => 'homepage_callouts', 'type' => 'select', 'choices' => athena_icons()));
    $wp_customize->add_setting('callout2_title', array('default' => __('Customizable', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout2_title', array('type' => 'text', 'section' => 'homepage_callouts', 'label' => __('Callout #2: Title', 'athena'), 'description' => __('Set the callout title text', 'athena')));
    $wp_customize->add_setting('callout2_text', array('default' => __('Athena is easy to use and customize without having to touch code', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout2_text', array('type' => 'textarea', 'section' => 'homepage_callouts', 'label' => __('Callout #2: Description', 'athena'), 'description' => __('Set the callout detail text', 'athena')));
    // Callout #3
    $wp_customize->add_setting('callout3_icon', array('default' => 'fa fa-shopping-cart', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout3_icon', array('label' => __('Callout #3: Select Icon', 'athena'), 'section' => 'homepage_callouts', 'type' => 'select', 'choices' => athena_icons()));
    $wp_customize->add_setting('callout3_title', array('default' => __('WooCommerce', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout3_title', array('type' => 'text', 'section' => 'homepage_callouts', 'label' => __('Callout #3: Title', 'athena'), 'description' => __('Set the callout title text', 'athena')));
    $wp_customize->add_setting('callout3_text', array('default' => __('Athena supports WooCommerce to build an online shopping site', 'athena'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('callout3_text', array('type' => 'textarea', 'section' => 'homepage_callouts', 'label' => __('Callout #3: Description', 'athena'), 'description' => __('Set the callout detail text', 'athena')));
    // *********************************************
    // ****************** Apperance *****************
    // *********************************************
    $wp_customize->add_panel('appearance', array('title' => __('Appearance', 'athena'), 'description' => __('Customize your site colros, fonts and other appearance settings', 'athena'), 'priority' => 10));
    $wp_customize->add_section('color', array('title' => __('Skin Color', 'athena'), 'panel' => 'appearance'));
    $wp_customize->add_section('font', array('title' => __('Fonts', 'athena'), 'panel' => 'appearance'));
    //    $wp_customize->add_section( 'templates', array (
    //        'title'                 => __( 'Sidebars', 'athena' ),
    //        'panel'                 => 'appearance',
    //    ) );
    // Logo Bool
    $wp_customize->add_setting('logo_bool', array('default' => 'on', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('logo_bool', array('type' => 'radio', 'section' => 'logo', 'label' => __('Display Logo', 'athena'), 'description' => __('If you do not use a logo, the site title will be displayed', 'athena'), 'choices' => array('on' => __('Yes', 'athena'), 'off' => __('No', 'athena'))));
    // Logo Image
    $wp_customize->add_setting('logo', array('default' => get_template_directory_uri() . '/inc/images/logo.png', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'image_control4', array('label' => __('Logo', 'athena'), 'section' => 'logo', 'mime_type' => 'image', 'settings' => 'logo', 'description' => __('Image for your site', 'athena'))));
    $wp_customize->add_setting('sidebar_location', array('default' => 'right', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('sidebar_location', array('type' => 'radio', 'section' => 'templates', 'label' => __('Sidebar Location', 'athena'), 'description' => __('Do you want the sidebar to be on the left or the right side ?', 'athena'), 'choices' => array('none' => __('No Sidebar', 'athena'), 'right' => __('Right', 'athena'), 'left' => __('Left', 'athena'))));
    $wp_customize->add_setting('home_sidebar', array('default' => 'on', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('home_sidebar', array('type' => 'radio', 'section' => 'templates', 'label' => __('Sidebar on Frontpage', 'athena'), 'description' => __('You can select on/off to display/hide the sidebar on the Homepage', 'athena'), 'choices' => array('on' => __('On', 'athena'), 'off' => __('Off', 'athena'))));
    $wp_customize->add_setting('single_sidebar', array('default' => 'on', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('single_sidebar', array('type' => 'radio', 'section' => 'templates', 'label' => __('Sidebar on Single Posts', 'athena'), 'description' => __('You can select on/off to display/hide the sidebar on single Posts', 'athena'), 'choices' => array('on' => __('On', 'athena'), 'off' => __('Off', 'athena'))));
    $wp_customize->add_setting('page_sidebar', array('default' => 'on', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('page_sidebar', array('type' => 'radio', 'section' => 'templates', 'label' => __('Sidebar on Pages', 'athena'), 'description' => __('You can select on/off to display/hide the sidebar on Pages', 'athena'), 'choices' => array('on' => __('On', 'athena'), 'off' => __('Off', 'athena'))));
    $wp_customize->add_setting('theme_color', array('default' => 'green', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('theme_color', array('type' => 'radio', 'section' => 'color', 'label' => __('Theme Skin Color', 'athena'), 'description' => __('Select the theme main color', 'athena'), 'choices' => array('green' => __('Green', 'athena'), 'blue' => __('Blue', 'athena'), 'red' => __('Red', 'athena'), 'pink' => __('Pink', 'athena'), 'yellow' => __('Yellow', 'athena'), 'darkblue' => __('Dark Blue', 'athena'))));
    $wp_customize->add_setting('header_font', array('default' => 'Raleway, sans-serif', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('header_font', array('type' => 'select', 'section' => 'font', 'label' => __('Headers Font', 'athena'), 'description' => __('Applies to the slider header, callouts headers, post page & widget titles etc..', 'athena'), 'choices' => athena_fonts()));
    $wp_customize->add_setting('theme_font', array('default' => 'Raleway, sans-serif', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('theme_font', array('type' => 'select', 'section' => 'font', 'label' => __('General font for the site body', 'athena'), 'choices' => athena_fonts()));
    $wp_customize->add_setting('menu_font_size', array('default' => '14px', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('menu_font_size', array('type' => 'select', 'section' => 'font', 'label' => __('Menu Font Size', 'athena'), 'choices' => athena_font_sizes()));
    $wp_customize->add_setting('theme_font_size', array('default' => '14px', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('theme_font_size', array('type' => 'select', 'section' => 'font', 'label' => __('Content Font Size', 'athena'), 'choices' => athena_font_sizes()));
    // *********************************************
    // ****************** Footer *****************
    // *********************************************
    $wp_customize->add_panel('footer', array('title' => __('Footer', 'athena'), 'description' => __('Customize the site footer', 'athena'), 'priority' => 10));
    $wp_customize->add_section('footer_background', array('title' => __('Footer Background', 'athena'), 'panel' => 'footer'));
    $wp_customize->add_setting('footer_background_image', array('default' => get_template_directory_uri() . '/inc/images/footer.jpg', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'image_control3', array('label' => __('Footer Background Image ( Parallax )', 'athena'), 'section' => 'footer_background', 'mime_type' => 'image', 'settings' => 'footer_background_image', 'description' => __('Select the image file that you would like to use as the footer background', 'athena'))));
    $wp_customize->add_section('footer_text', array('title' => __('Copyright Text', 'athena'), 'panel' => 'footer'));
    $wp_customize->add_setting('copyright_text', array('default' => __('Copyright Company Name', 'athena') . date('Y'), 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('copyright_text', array('type' => 'text', 'section' => 'footer_text', 'label' => __('Copyright Text', 'athena')));
    $wp_customize->add_section('social_links', array('title' => __('Social Icons & Links', 'athena'), 'panel' => 'footer'));
    $wp_customize->add_setting('facebook_url', array('default' => '#', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('facebook_url', array('type' => 'text', 'section' => 'social_links', 'label' => __('Facebook URL', 'athena')));
    $wp_customize->add_setting('gplus_url', array('default' => '#', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('gplus_url', array('type' => 'text', 'section' => 'social_links', 'label' => __('Google Plus URL', 'athena')));
    $wp_customize->add_setting('instagram_url', array('default' => '#', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('instagram_url', array('type' => 'text', 'section' => 'social_links', 'label' => __('Instagram URL', 'athena')));
    $wp_customize->add_setting('linkedin_url', array('default' => '#', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('linkedin_url', array('type' => 'text', 'section' => 'social_links', 'label' => __('Linkedin URL', 'athena')));
    $wp_customize->add_setting('pinterest_url', array('default' => '#', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('pinterest_url', array('type' => 'text', 'section' => 'social_links', 'label' => __('Pinterest URL', 'athena')));
    $wp_customize->add_setting('twitter_url', array('default' => '#', 'transport' => 'postMessage', 'sanitize_callback' => 'athena_sanitize'));
    $wp_customize->add_control('twitter_url', array('type' => 'text', 'section' => 'social_links', 'label' => __('Twitter URL', 'athena')));
    // *********************************************
    // ****************** Social Icons *****************
    // *********************************************
    $wp_customize->add_panel('social', array('title' => __('Social', 'athena'), 'description' => __('Social Icons, Links & Location', 'athena'), 'priority' => 10));
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
    $wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
    $wp_customize->get_setting('featured_image1')->transport = 'postMessage';
    $wp_customize->get_setting('featured_image2')->transport = 'postMessage';
    $wp_customize->get_setting('callout1_icon')->transport = 'postMessage';
    //    $wp_customize->get_setting( 'header_font' )->transport      = 'postMessage';
}