customizer.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Apostrophe 2 Theme Customizer
  4. *
  5. * @package Apostrophe 2 2
  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 apostrophe_2_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. function apostrophe_2_sanitize_checkbox( $checked ){
  17. return ( ( isset( $checked ) && true == $checked ) ? true : false );
  18. }
  19. if ( function_exists( 'jetpack_social_menu' ) ) {
  20. $wp_customize->add_setting( 'apostrophe_2_mobile_social', array(
  21. 'capability' => 'edit_theme_options',
  22. 'transport' => 'refresh',
  23. 'sanitize_callback' => 'apostrophe_2_sanitize_checkbox',
  24. ) );
  25. $wp_customize->add_control( 'apostrophe_2_mobile_social', array(
  26. 'type' => 'checkbox',
  27. 'section' => 'jetpack_content_options',
  28. 'label' => __( 'Display social menu on mobile devices', 'apostrophe-2' ),
  29. ) );
  30. }
  31. }
  32. add_action( 'customize_register', 'apostrophe_2_customize_register' );
  33. /**
  34. * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
  35. */
  36. function apostrophe_2_customize_preview_js() {
  37. wp_enqueue_script( 'apostrophe-2-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
  38. }
  39. add_action( 'customize_preview_init', 'apostrophe_2_customize_preview_js' );