is_header_video_active()
Checks whether the custom header video is eligible to show on the current page.
Used By: has_custom_header()
Hooks from the function
Return
true|false
. True if the custom header video should be shown. False if not.
Usage
is_header_video_active();
Examples
#1 Let's display the header video
Check if the header video is there and if it should be displayed on the current page. If it's OK, we show the player with the video playing.
// check if there is a header video and it should show on the current page. if( has_header_video() && is_header_video_active() ){ the_custom_header_markup(); // url to video - get_header_video_url() }
As a result, the HTML code of the video player will appear in place of this code, and the necessary scripts for the player will be connected to the page (at the end):
<div id="wp-custom-header" class="wp-custom-header"> <video id="wp-custom-header-video" autoplay="" loop="" width="954" height="1300" src="http://example.com/wp-content/uploads/2017/01/polina.mp4"></video> <button type="button" id="wp-custom-header-video-button" class="wp-custom-header-video-button wp-custom-header-video-play">Pause</button> </div>
Scripts in the footer:
<script type='text/javascript' src='http://example.com/wp-includes/js/wp-custom-header.min.js'></script> <script type='text/javascript' src='http://example.com/wp-includes/js/mediaelement/mediaelement-and-player.min.js'></script> <script type='text/javascript' src='http://example.com/wp-includes/js/mediaelement/wp-mediaelement.min.js'></script>
Changelog
Since 4.7.0 | Introduced. |