get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'ampface_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'ampface_customize_partial_blogdescription', ) ); } /******************************************* AMPFace base options Section ********************************************/ $wp_customize->add_section('ampface_base_options', array( 'title' => __('Ampface Base Options', 'ampface'), 'description' => '', 'priority' => 2, )); // ============================= // = AMPFace base width Select Box = // ============================= $wp_customize->add_setting('setting_ampface_base_width', array( 'transport' => 'refresh', 'default' => ampface_defaults( 'default_setting_ampface_base_width' ), 'sanitize_callback' => 'wp_filter_nohtml_kses', )); $wp_customize->add_control( 'control_ampface_base_width', array( 'settings' => 'setting_ampface_base_width', 'label' => __('Theme width', 'ampface'), 'section' => 'ampface_base_options', 'type' => 'select', 'choices' => array( 'narrow' => 'Narrow (920px)', 'wide' => 'Wide (1120px)', ), )); // ============================= // = AMPFace top notice = // ============================= $wp_customize->add_setting( 'setting_topbar_text' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_topbar_text', array( 'label' => 'Topbar Text', 'section' => 'ampface_base_options', 'settings' => 'setting_topbar_text', 'type' => 'text', ) ); /** * Google fonts * */ $url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDwe8tl4YMbg8asbjzbXDDFuxzR1Wm9EQ0'; $response = wp_remote_get( 'http://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDwe8tl4YMbg8asbjzbXDDFuxzR1Wm9EQ0', array( 'sslverify' => true ) ); $response = wp_remote_retrieve_body( wp_remote_get($url, array('sslverify' => false ))); $url2 = 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDwe8tl4YMbg8asbjzbXDDFuxzR1Wm9EQ0'; $response2 = wp_remote_get( 'http://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDwe8tl4YMbg8asbjzbXDDFuxzR1Wm9EQ0', array( 'sslverify' => true ) ); $response2 = wp_remote_retrieve_body( wp_remote_get($url2, array('sslverify' => false ))); if( is_wp_error( $response ) ) { echo 'Something went wrong!'; } else { $json_a = json_decode($response, true); $font_items = $json_a['items']; $firstfont = array(); $json_atwo = json_decode($response2, true); $font_itemstwo = $json_atwo['items']; $secondfont = array(); foreach ($font_items as $font_value => $font_item) { $firstfont[$font_item['family']] = $font_item['family'].' (Google)'; } foreach ($font_itemstwo as $font_valuetwo => $font_itemtwo) { $secondfont[$font_itemtwo['family']] = $font_itemtwo['family'].' (Google)'; } $font_args = array( 'label' => 'Header Title Font', 'section' => 'ampface_base_options', 'settings' => 'setting_AMPFace', 'type' => 'select', 'choices' => $firstfont ); $font_args_body = array( 'label' => 'Body Text Font', 'section' => 'ampface_base_options', 'settings' => 'setting_AMPFace_bodytext', 'type' => 'select', 'choices' => $secondfont ); } $wp_customize->add_setting( 'setting_AMPFace' , array( 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_AmpFonts', $font_args); $wp_customize->add_setting( 'setting_AMPFace_bodytext' , array( 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_AmpFonts_bodytext', $font_args_body); $wp_customize->add_setting( 'setting_AMPFace_bodytext_default' , array( 'transport' => 'refresh', 'default' => false, 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_AMPFace_bodytext_default', array( 'label' => 'Or use default body/text font', 'section' => 'ampface_base_options', 'settings' => 'setting_AMPFace_bodytext_default', 'type' => 'checkbox', 'description' => __( 'Overwrites selected Google body font', 'ampface' ), ) ); /** * end Google fonts * */ $wp_customize->add_setting( 'setting_ampFace_HeaderImage_homepage_only' , array( 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_ampFace_HeaderImage_homepage_only', array( 'label' => 'Show header image on homepage only', 'section' => 'ampface_base_options', 'settings' => 'setting_ampFace_HeaderImage_homepage_only', 'type' => 'checkbox', 'description' => __( 'Must have header image active', 'ampface' ), ) ); $wp_customize->add_setting( 'setting_ampFace_HeaderImage_fullwidth' , array( 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_ampFace_HeaderImage_fullwidth', array( 'label' => 'Restrict header width', 'section' => 'ampface_base_options', 'settings' => 'setting_ampFace_HeaderImage_fullwidth', 'type' => 'checkbox', ) ); /** * social media links * */ $wp_customize->add_section( 'section_afsocialmedia' , array( 'title' => __('AMPFace Social Media Buttons', 'ampface'), 'priority' => 32, ) ); $wp_customize->add_setting( 'setting_afsm_home' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_home', array( 'label' => 'Home URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_home', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_fb' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_fb', array( 'label' => 'Facebook URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_fb', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_twitter' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_twitter', array( 'label' => 'Twitter URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_twitter', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_linkedin' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_linkedin', array( 'label' => 'Linked URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_linkedin', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_google' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', )); $wp_customize->add_control( 'control_afsm_google', array( 'label' => 'Google URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_google', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_rss' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_rss', array( 'label' => 'rss URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_rss', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_youtube' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_youtube', array( 'label' => 'YouTube URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_youtube', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_skype' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_skype', array( 'label' => 'Skype URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_skype', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_pinterest' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_pinterest', array( 'label' => 'Pinterest URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_pinterest', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_instagram' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_instagram', array( 'label' => 'Instagram URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_instagram', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_tripadvisor' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_tripadvisor', array( 'label' => 'Tripadvisor URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_tripadvisor', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_contact' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_contact', array( 'label' => 'Contact URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_contact', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_whatsapp' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_whatsapp', array( 'label' => 'Whatsapp URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_whatsapp', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_snapchat' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_snapchat', array( 'label' => 'Snapchat URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_snapchat', 'type' => 'text', ) ); $wp_customize->add_setting( 'setting_afsm_yelp' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_yelp', array( 'label' => 'Yelp URL', 'section' => 'section_afsocialmedia', 'settings' => 'setting_afsm_yelp', 'type' => 'text', ) ); /** * End social media links * */ /** * start social media share buttoms * */ $wp_customize->add_section( 'section_afsocialmediaShare' , array( 'title' => __('AMPFace Social Media Share', 'ampface'), 'priority' => 32, ) ); $wp_customize->add_setting( 'setting_afsm_share_fb' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_fb', array( 'label' => 'Facebook Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_fb', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_afsm_share_tw' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_tw', array( 'label' => 'Twitter Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_tw', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_afsm_share_ln' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_ln', array( 'label' => 'LinkedIn Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_ln', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_afsm_share_pn' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_pn', array( 'label' => 'Pinterest Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_pn', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_afsm_share_tm' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_tm', array( 'label' => 'Tumblr Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_tm', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_afsm_share_wh' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_wh', array( 'label' => 'Whatsapp Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_wh', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_afsm_share_li' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_li', array( 'label' => 'Line Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_li', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_afsm_share_em' , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afsm_share_em', array( 'label' => 'Email Share Button?', 'section' => 'section_afsocialmediaShare', 'settings' => 'setting_afsm_share_em', 'type' => 'checkbox', ) ); /** * end social media share buttoms * */ $wp_customize->add_section( 'section_cookie' , array( 'title' => __('AMPFace Cookie / Popup Notice','ampface'), 'priority' => 32, ) ); $wp_customize->add_setting( 'setting_cookie' , array( 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_enableCookie', array( 'label' => 'Enable Popup Notice?', 'section' => 'section_cookie', 'settings' => 'setting_cookie', 'type' => 'checkbox', 'description' => __( 'Set a popup for visitors to your site','ampface' ), ) ); $wp_customize->add_setting( 'setting_cookietext' , array( 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_cookietext', array( 'label' => 'Notice Text', 'section' => 'section_cookie', 'settings' => 'setting_cookietext', 'type' => 'textarea', 'description' => __( 'Enter your cookie or message notice here - it will replace the default text notice. When the user agrees to the cookies policy, the status is saved in the local storage.','ampface' ), ) ); // AMPFace Blog Settings $wp_customize->add_section( 'section_blog' , array( 'title' => __('AMPFace Blog Settings', 'ampface'), 'priority' => 33, ) ); $wp_customize->add_setting( 'setting_blog' , array( 'transport' => 'postMessage', 'default' => 'single', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_blog_width', array( 'label' => 'Blog Style', 'section' => 'section_blog', 'settings' => 'setting_blog', 'type' => 'select', 'choices' => array( 'single' => __( '1 / single column', 'ampface' ), '2columns' => __( '2 columns', 'ampface' ), '3columns' => __( '3 columns', 'ampface' ),), ) ); $wp_customize->add_setting( 'setting_ampFace_showAuthor' , array( 'default' => true, 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_ampFace_showAuthor', array( 'label' => 'Hide author info', 'section' => 'section_blog', 'settings' => 'setting_ampFace_showAuthor', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_ampFace_showTags' , array( 'default' => true, 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_ampFace_showTags', array( 'label' => 'Hide tags', 'section' => 'section_blog', 'settings' => 'setting_ampFace_showTags', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_ampFace_showDate' , array( 'default' => true, 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_ampFace_showDate', array( 'label' => 'Hide Date', 'section' => 'section_blog', 'settings' => 'setting_ampFace_showDate', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'setting_ampFace_showcategory' , array( 'default' => true, 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_ampFace_showcategory', array( 'label' => 'Hide category', 'section' => 'section_blog', 'settings' => 'setting_ampFace_showcategory', 'type' => 'checkbox', ) ); // end AMPFace Blog Settings // add color picker setting $wp_customize->add_setting( 'link_color', array( 'default' => ampface_defaults( 'default_link_color' ), 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); // add color picker control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array( 'label' => 'Link Color', 'section' => 'colors', 'settings' => 'link_color', ) ) ); // AMPFace header - Footer scripts $wp_customize->add_section( 'section_scripts' , array( 'title' => __('AMPFace Header Scripts', 'ampface'), 'priority' => 33, ) ); $wp_customize->add_setting( 'setting_afscripts' , array( 'transport' => 'postMessage', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( 'control_afHeaderScripts', array( 'label' => 'Add header scripts / style', 'section' => 'section_scripts', 'settings' => 'setting_afscripts', 'type' => 'textarea', 'description' => __( 'Add header scripts here, such as Google analytics or Tag manager code. For AMP urls you should only use AMP valid content.' ), ) ); } add_action( 'customize_register', 'ampface_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function ampface_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function ampface_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function ampface_customize_preview_js() { wp_enqueue_script( 'ampface-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'ampface_customize_preview_js' ); add_theme_support( 'custom-header', apply_filters( 'ampface_header_args', array( 'default-text-color' => $default_text_color, 'width' => 2000, 'height' => 340, 'flex-height' => true, ) ) ); function ampface_customizer_head_styles() { $link_color = get_theme_mod( 'link_color',ampface_defaults( 'default_link_color' ) ); if ( $link_color != '#ff0000' ) : ?>