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', ) ); /** * start social media links 2 - with array * */ $ampface_sm_link = array("home", "Facebook", "Twitter", "Github", "Instagram","Behance", "Linkedin", "Play", "Pinterest", "Reddit", "RSS", "Mail","Whatsapp", "WordPress", "Skype"); $wp_customize->add_section( 'jozz_section_afsocialmedia' , array( 'title' => __('AMPFace Social Media Links', 'ampface'), 'priority' => 32, ) ); // One way of Looping through an array usign foreach foreach ($ampface_sm_link as $val){ $wp_customize->add_setting( $val , array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'wp_filter_nohtml_kses', ) ); $wp_customize->add_control( $val , array( 'label' => $val , 'section' => 'jozz_section_afsocialmedia', 'settings' => $val , 'type' => 'text', ) ); } /** * end social media links 2 - with array * */ // 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' => false, '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' => false, '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' => false, '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' => false, '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.','ampface' ), ) ); } 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( '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' ) : ?>