Ticket #38172: 38172.3.diff
File 38172.3.diff, 12.8 KB (added by , 5 years ago) |
---|
-
src/wp-admin/css/customize-controls.css
552 552 display: block; 553 553 font-style: italic; 554 554 line-height: 18px; 555 margin-top: 0; 555 556 margin-bottom: 5px; 556 557 } 557 558 -
src/wp-content/themes/twentyfourteen/functions.php
409 409 $classes[] = 'group-blog'; 410 410 } 411 411 412 if ( get_header_image() ) {412 if ( get_header_image() || function_exists( 'has_header_video' ) && has_header_video() ) { 413 413 $classes[] = 'header-image'; 414 414 } elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-activate.php', 'wp-signup.php' ) ) ) { 415 415 $classes[] = 'masthead-fixed'; -
src/wp-content/themes/twentyfourteen/header.php
32 32 33 33 <body <?php body_class(); ?>> 34 34 <div id="page" class="hfeed site"> 35 <?php if ( get_header_image() ) : ?> 35 <?php if ( function_exists( 'has_header_video' ) && has_header_video() ) : ?> 36 <div id="site-header"> 37 <?php the_header_video_tag(); ?> 38 </div> 39 <?php elseif ( get_header_image() ) : ?> 36 40 <div id="site-header"> 37 41 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"> 38 42 <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"> -
src/wp-content/themes/twentyfourteen/inc/custom-header.php
40 40 'width' => 1260, 41 41 'height' => 240, 42 42 'flex-height' => true, 43 'video' => true, 43 44 'wp-head-callback' => 'twentyfourteen_header_style', 44 45 'admin-head-callback' => 'twentyfourteen_admin_header_style', 45 46 'admin-preview-callback' => 'twentyfourteen_admin_header_image', -
src/wp-content/themes/twentyfourteen/js/functions.js
103 103 104 104 if ( body.is( '.header-image' ) ) { 105 105 toolbarOffset = body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0; 106 mastheadOffset = $( '# masthead' ).offset().top- toolbarOffset;106 mastheadOffset = $( '#site-header' ).height() - toolbarOffset; 107 107 108 108 _window.on( 'scroll.twentyfourteen', function() { 109 109 if ( _window.scrollTop() > mastheadOffset && mastheadHeight < 49 ) { … … 112 112 body.removeClass( 'masthead-fixed' ); 113 113 } 114 114 } ); 115 116 // Update masthead offset after a selective refresh. 117 if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) { 118 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { 119 mastheadOffset = $( '#site-header' ).height() - toolbarOffset; 120 } ); 121 } 115 122 } 116 123 } 117 124 -
src/wp-content/themes/twentyfourteen/style.css
88 88 video { 89 89 display: inline-block; 90 90 max-width: 100%; 91 height: auto; 91 92 } 92 93 93 94 html { … … 608 609 max-width: 100%; 609 610 } 610 611 612 #wp-custom-header-video video { 613 margin-bottom: -8px; 614 } 615 611 616 p > embed, 612 617 p > iframe, 613 618 p > object, -
src/wp-includes/class-wp-customize-manager.php
2159 2159 2160 2160 /* Custom Header */ 2161 2161 2162 if ( current_theme_supports( 'custom-header', 'video' ) ) { 2163 $title = __( 'Header Visuals' ); 2164 $description = __( 'If you add a video, the image will be used as a fallback while the video loads.' ); 2165 $width = absint( get_theme_support( 'custom-header', 'width' ) ); 2166 $height = absint( get_theme_support( 'custom-header', 'height' ) ); 2167 if ( $width && $height ) { 2168 /* translators: %s: header size in pixels */ 2169 $control_description = sprintf( __( 'Upload your video in <code>.mp4</code> format and minimize its file size for best results. Your theme recommends dimensions of %s pixels.' ), 2170 sprintf( '<strong>%s × %s</strong>', $width, $height ) 2171 ); 2172 } elseif ( $width ) { 2173 /* translators: %s: header width in pixels */ 2174 $control_description = sprintf( __( 'Upload your video in <code>.mp4</code> format and minimize its file size for best results. Your theme recommends a width of %s pixels.' ), 2175 sprintf( '<strong>%s</strong>', $width ) 2176 ); 2177 } else { 2178 /* translators: %s: header height in pixels */ 2179 $control_description = sprintf( __( 'Upload your video in <code>.mp4</code> format and minimize its file size for best results. Your theme recommends a height of %s pixels.' ), 2180 sprintf( '<strong>%s</strong>', $height ) 2181 ); 2182 } 2183 } else { 2184 $title = __( 'Header Image' ); 2185 $description = ''; 2186 $control_description = ''; 2187 } 2188 2162 2189 $this->add_section( 'header_image', array( 2163 'title' => __( 'Header Image' ), 2190 'title' => $title, 2191 'description' => $description, 2164 2192 'theme_supports' => 'custom-header', 2165 2193 'priority' => 60, 2166 2194 ) ); 2167 2195 2196 $this->add_setting( 'header_video', array( 2197 'theme_supports' => array( 'custom-header', 'video' ), 2198 'transport' => 'postMessage', 2199 ) ); 2200 2168 2201 $this->add_setting( new WP_Customize_Filter_Setting( $this, 'header_image', array( 2169 2202 'default' => get_theme_support( 'custom-header', 'default-image' ), 2170 2203 'theme_supports' => 'custom-header', … … 2175 2208 'theme_supports' => 'custom-header', 2176 2209 ) ) ); 2177 2210 2211 $this->add_control( new WP_Customize_Media_Control( $this, 'header_video', array( 2212 'theme_supports' => array( 'custom-header', 'video' ), 2213 'label' => __( 'Header Video' ), 2214 'description' => $control_description, 2215 'section' => 'header_image', 2216 'mime_type' => 'video', 2217 ) ) ); 2218 2178 2219 $this->add_control( new WP_Customize_Header_Image_Control( $this ) ); 2179 2220 2221 $this->selective_refresh->add_partial( 'header_video', array( 2222 'selector' => '#wp-custom-header-video', 2223 'render_callback' => 'get_header_video_tag', 2224 'settings' => array( 'header_video', 'header_image' ), // The image is used as a video fallback here. 2225 ) ); 2226 2180 2227 /* Custom Background */ 2181 2228 2182 2229 $this->add_section( 'background_image', array( -
src/wp-includes/customize/class-wp-customize-header-image-control.php
166 166 $height = absint( get_theme_support( 'custom-header', 'height' ) ); 167 167 ?> 168 168 <div class="customize-control-content"> 169 <p class="customizer-section-intro"> 169 <?php if ( current_theme_supports( 'custom-header', 'video' ) ) { 170 echo '<span class="customize-control-title">' . $this->label . '</span>'; 171 } ?> 172 <p class="customizer-section-intro customize-control-description"> 170 173 <?php 171 if ( $width && $height ) { 174 if ( current_theme_supports( 'custom-header', 'video' ) ) { 175 _e( 'While you can crop images to your liking after clicking <strong>Add new image</strong>, we recommend matching the size of your video.' ); 176 } elseif ( $width && $height ) { 172 177 /* translators: %s: header size in pixels */ 173 178 printf( __( 'While you can crop images to your liking after clicking <strong>Add new image</strong>, your theme recommends a header size of %s pixels.' ), 174 179 sprintf( '<strong>%s × %s</strong>', $width, $height ) -
src/wp-includes/theme.php
1264 1264 'thumbnail_url' => '', 1265 1265 'width' => get_theme_support( 'custom-header', 'width' ), 1266 1266 'height' => get_theme_support( 'custom-header', 'height' ), 1267 'video' => get_theme_support( 'custom-header', 'video' ), 1267 1268 ); 1268 1269 return (object) wp_parse_args( $data, $default ); 1269 1270 } … … 1311 1312 } 1312 1313 1313 1314 /** 1315 * Check whether a header video is set or not. 1316 * 1317 * @since 4.7.0 1318 * 1319 * @see get_header_video_url() 1320 * 1321 * @return bool Whether a header video is set or not. 1322 */ 1323 function has_header_video() { 1324 return (bool) get_header_video_url(); 1325 } 1326 1327 /* Retrieve header video URL for custom header. 1328 * 1329 * @since 4.7.0 1330 * 1331 * @return string|false 1332 */ 1333 function get_header_video_url() { 1334 $id = absint( get_theme_mod( 'header_video' ) ); 1335 1336 if ( ! $id ) { 1337 return false; 1338 } 1339 1340 if ( $id ) { 1341 // We have an attachment ID, need the full URL 1342 $url = wp_get_attachment_url( $id ); 1343 } 1344 1345 return esc_url_raw( set_url_scheme( $url ) ); 1346 } 1347 1348 /** 1349 * Create video tag markup for a custom header video. 1350 * 1351 * @since 4.7.0 1352 * 1353 * @param array $attr Optional. Additional attributes for the image tag. Can be used 1354 * to override the default attributes. Default empty. 1355 * @return string HTML image element markup or empty string on failure. 1356 */ 1357 function get_header_video_tag( $attr = array() ) { 1358 $header = get_custom_header(); 1359 $video = get_header_video_url(); 1360 $image = get_header_image(); 1361 1362 if ( empty( $video ) ) { 1363 if ( is_customize_preview() ) { // If there was a video an it was removed, fall back to an image. 1364 if ( ! empty( $image ) ) { 1365 return get_header_image_tag(); 1366 } 1367 } 1368 return ''; 1369 } 1370 1371 $width = absint( $header->width ); 1372 $height = absint( $header->height ); 1373 1374 $attr = wp_parse_args( 1375 $attr, 1376 array( 1377 'src' => get_header_video_url(), 1378 'width' => $width, 1379 'height' => $height, 1380 'controls' => '', 1381 'autoplay' => '', 1382 'loop' => '', 1383 'muted' => '', 1384 ) 1385 ); 1386 1387 // Use the header image as poster attribute and video fallback. 1388 if ( ! empty( $image ) ) { 1389 $attr['poster'] = $header->url; 1390 $content = get_header_image_tag(); 1391 } else { 1392 $content = __( 'Your browser cannot play this video.' ); 1393 } 1394 1395 $attr = array_map( 'esc_attr', $attr ); 1396 $html = '<video'; 1397 1398 foreach ( $attr as $name => $value ) { 1399 $html .= ' ' . $name . '="' . $value . '"'; 1400 } 1401 1402 $html .= '>' . $content . '</video>'; 1403 1404 /** 1405 * Filters the markup of header videos. 1406 * 1407 * @since 4.7.0 1408 * 1409 * @param string $html The HTML image tag markup being filtered. 1410 * @param object $header The custom header object returned by 'get_custom_header()'. 1411 * @param array $attr Array of the attributes for the image tag. 1412 */ 1413 return apply_filters( 'get_header_video_tag', $html, $header, $attr ); 1414 } 1415 1416 /** 1417 * Display the video markup for a custom header video. 1418 * 1419 * @since 4.7.0 1420 * 1421 * @param array $attr Optional. Attributes for the image markup. Default empty. 1422 */ 1423 function the_header_video_tag( $attr = array() ) { 1424 echo '<div id="wp-custom-header-video">' . get_header_video_tag( $attr ) . '</div>'; 1425 } 1426 1427 /** 1428 * Display header video URL. 1429 * 1430 * @since 4.7.0 1431 */ 1432 function the_header_video_url() { 1433 $video = get_header_video_url(); 1434 if ( $video ) { 1435 echo esc_url( $video ); 1436 } 1437 } 1438 1439 /** 1440 * Display the video and image markup for a custom header. 1441 * 1442 * @since 4.7.0 1443 */ 1444 function the_custom_header() { 1445 $video = get_header_video_url(); 1446 $image = get_header_image(); 1447 1448 if ( ! empty( $video ) ) { 1449 the_header_video_tag(); 1450 } elseif ( is_customize_preview() ) { 1451 echo '<div id="wp-custom-header-video"></div>'; 1452 if ( ! empty( $image ) ) { 1453 the_header_image_tag(); 1454 } 1455 } elseif ( ! empty( $image ) ) { 1456 the_header_image_tag(); 1457 } 1458 } 1459 1460 /** 1314 1461 * Retrieve background image for custom background. 1315 1462 * 1316 1463 * @since 3.0.0 … … 1623 1770 'wp-head-callback' => '', 1624 1771 'admin-head-callback' => '', 1625 1772 'admin-preview-callback' => '', 1773 'video' => false, 1626 1774 ); 1627 1775 1628 1776 $jit = isset( $args[0]['__jit'] ); … … 2082 2230 return; 2083 2231 } 2084 2232 2085 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 2233 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 2086 2234 $GLOBALS['wp_customize'] = new WP_Customize_Manager(); 2087 2235 } 2088 2236