customizer.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Radcliffe 2 Theme Customizer
  4. *
  5. * @package Radcliffe 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 radcliffe_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_text' )->transport = 'postMessage';
  16. $wp_customize->selective_refresh->add_partial( 'blogname', array(
  17. 'selector' => '.site-title a',
  18. 'render_callback' => 'radcliffe_2_customize_partial_blogname',
  19. ) );
  20. $wp_customize->selective_refresh->add_partial( 'blogdescription', array(
  21. 'selector' => '.site-description',
  22. 'render_callback' => 'radcliffe_2_customize_partial_blogdescription',
  23. ) );
  24. // Set placeholders for Site Title and Tagline
  25. $wp_customize->get_control( 'blogname' )->input_attrs = array(
  26. 'placeholder' => esc_attr__( 'Enter a name for your site', 'radcliffe-2' ),
  27. );
  28. $wp_customize->get_control( 'blogdescription' )->input_attrs = array(
  29. 'placeholder' => esc_attr__( 'A short phrase describing your site', 'radcliffe-2' ),
  30. );
  31. // Reorder Radcliffe 2 Customizer Panels
  32. $wp_customize->get_section( 'title_tagline' )->priority = 11;
  33. $wp_customize->get_section( 'style_pack_theme_options' )->priority = 14;
  34. }
  35. add_action( 'customize_register', 'radcliffe_2_customize_register' );
  36. /**
  37. * Render the site title for the selective refresh partial.
  38. *
  39. * @return void
  40. */
  41. function radcliffe_2_customize_partial_blogname() {
  42. bloginfo( 'name' );
  43. }
  44. /**
  45. * Render the site tagline for the selective refresh partial.
  46. *
  47. * @return void
  48. */
  49. function radcliffe_2_customize_partial_blogdescription() {
  50. bloginfo( 'description' );
  51. }
  52. /**
  53. * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
  54. */
  55. function radcliffe_2_customize_preview_js() {
  56. wp_enqueue_script( 'radcliffe-2-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151215', true );
  57. }
  58. add_action( 'customize_preview_init', 'radcliffe_2_customize_preview_js' );
  59. /**
  60. * Logo Resizer Awesomeness - Bringing logo resizing to the Customizer since 2017
  61. */
  62. require get_template_directory() . '/inc/logo-resizer.php';