customizer.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Theme Customizer enhancements for a better user experience.
  3. *
  4. * Contains handlers to make Theme Customizer preview reload changes asynchronously.
  5. */
  6. ( function( $ ) {
  7. // Site title and description.
  8. wp.customize( 'blogname', function( value ) {
  9. value.bind( function( to ) {
  10. $( '.site-title a' ).text( to );
  11. } );
  12. } );
  13. wp.customize( 'blogdescription', function( value ) {
  14. value.bind( function( to ) {
  15. $( '.site-description' ).text( to );
  16. } );
  17. } );
  18. // Header text color.
  19. wp.customize( 'header_textcolor', function( value ) {
  20. value.bind( function( to ) {
  21. if ( 'blank' === to ) {
  22. $( '.site-title, .site-description' ).css( {
  23. 'clip': 'rect(1px, 1px, 1px, 1px)',
  24. 'position': 'absolute'
  25. } );
  26. } else {
  27. $( '.site-title, .site-description' ).css( {
  28. 'clip': 'auto',
  29. 'position': 'relative'
  30. } );
  31. $( '.site-title' ).css( {
  32. 'color': to
  33. } );
  34. }
  35. } );
  36. } );
  37. // Body borders.
  38. wp.customize( 'background_image', function( value ) {
  39. value.bind( function( to ) {
  40. if ( '' === to ) {
  41. $( 'body' ).addClass( 'body-borders' );
  42. } else {
  43. $( 'body' ).removeClass( 'body-borders' );
  44. }
  45. } );
  46. } );
  47. } )( jQuery );