customizer.php 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Libretto Theme Customizer
  4. *
  5. * @package Libretto
  6. */
  7. /**
  8. * Add postMessage support for site title and description for the Theme Customizer.
  9. *
  10. * @param WP_Customize_Manager $wp_customize Theme Customizer object.
  11. *
  12. */
  13. function libretto_theme_customizer( $wp_customize ) {
  14. // Set various built-in site settings to be previewed live in the customizer
  15. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
  16. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
  17. $wp_customize->get_setting( 'background_color' )->transport = 'postMessage';
  18. $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
  19. } // libretto_theme_customizer()
  20. add_action( 'customize_register', 'libretto_theme_customizer' );
  21. /**
  22. * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
  23. */
  24. function libretto_customize_preview_js() {
  25. wp_enqueue_script( 'libretto_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
  26. }
  27. add_action( 'customize_preview_init', 'libretto_customize_preview_js' );