Ticket #38627: 38627.diff
| File 38627.diff, 2.4 KB (added by , 9 years ago) |
|---|
-
src/wp-content/themes/twentyseventeen/assets/js/customize-preview.js
6 6 7 7 ( function( $ ) { 8 8 9 var settings = _twentyseventeenCustomizePreviewSettings; 10 9 11 // Collect information from customize-controls.js about which panels are opening 10 12 wp.customize.bind( 'preview-ready', function() { 11 13 wp.customize.preview.bind( 'section-highlight', function( data ) { … … 102 104 } 103 105 } ); 104 106 } ); 107 108 // Whether a header image is available. 109 function hasHeaderImage() { 110 var image = wp.customize( 'header_image' )(); 111 return '' !== image && 'remove-header' !== image; 112 } 113 114 // Whether a header video is available. 115 function hasHeaderVideo() { 116 var externalVideo = wp.customize( 'external_header_video' )(), 117 video = wp.customize( 'header_video' )(); 118 119 return '' !== externalVideo || ( 0 !== video && '' !== video ); 120 } 121 122 // Toggle a body class if a custom header exists. 123 $.each( [ 'external_header_video', 'header_image', 'header_video' ], function( index, settingId ) { 124 wp.customize( settingId, function( setting ) { 125 setting.bind(function() { 126 if ( hasHeaderImage() || ( hasHeaderVideo() && !! settings.isFrontPage ) ) { 127 $( document.body ).addClass( 'has-header-image' ); 128 } else { 129 $( document.body ).removeClass( 'has-header-image' ); 130 } 131 } ); 132 } ); 133 } ); 134 105 135 } )( jQuery ); -
src/wp-content/themes/twentyseventeen/inc/customizer.php
200 200 add_action( 'customize_preview_init', 'twentyseventeen_customize_preview_js' ); 201 201 202 202 /** 203 * Export data for the Twenty Seventeen Customize preview script. 204 */ 205 function twentyseventeen_export_customize_preview_data() { 206 wp_localize_script( 'twentyseventeen-customize-preview', '_twentyseventeenCustomizePreviewSettings', array( 207 'isFrontPage' => twentyseventeen_is_frontpage(), 208 ) ); 209 } 210 add_action( 'wp_enqueue_scripts', 'twentyseventeen_export_customize_preview_data' ); 211 212 /** 203 213 * Load dynamic logic for the customizer controls area. 204 214 */ 205 215 function twentyseventeen_panels_js() {