customizer.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Illustratr Theme Customizer
  4. *
  5. * @package Illustratr
  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. function illustratr_customize_register( $wp_customize ) {
  13. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
  14. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
  15. $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
  16. $wp_customize->add_setting( 'illustratr_hide_portfolio_page_content', array(
  17. 'default' => '',
  18. 'sanitize_callback' => 'illustratr_sanitize_checkbox',
  19. ) );
  20. $wp_customize->add_control( 'illustratr_hide_portfolio_page_content', array(
  21. 'label' => __( 'Hide title and content on Portfolio Page Template', 'illustratr' ),
  22. 'section' => 'jetpack_portfolio',
  23. 'type' => 'checkbox',
  24. ) );
  25. }
  26. add_action( 'customize_register', 'illustratr_customize_register' );
  27. /**
  28. * Sanitize the checkbox.
  29. *
  30. * @param boolean $input.
  31. * @return boolean true if portfolio page template displays title and content.
  32. */
  33. function illustratr_sanitize_checkbox( $input ) {
  34. if ( 1 == $input ) {
  35. return true;
  36. } else {
  37. return false;
  38. }
  39. }
  40. /**
  41. * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
  42. */
  43. function illustratr_customize_preview_js() {
  44. wp_enqueue_script( 'illustratr_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
  45. }
  46. add_action( 'customize_preview_init', 'illustratr_customize_preview_js' );