forked from jaredh159/support
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo.php
More file actions
50 lines (40 loc) · 1.24 KB
/
video.php
File metadata and controls
50 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Template Name: External Video
* The template for displaying custom post type 'video'
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
// Start a new loop
while ( have_posts() ) : the_post();
$key="youtube_id";
$ytid = get_post_meta( $post->ID, $key, true );
echo "<!-- post id: " . $post->ID . " youtube_id: " . $ytid . " -->";
if ( is_single() && $ytid != null ) :
echo
'<div id="ytplayer-' . $post->ID . '"></div>
<script>
// Load the IFrame Player API code asynchronously.
var tag = document.createElement(\'script\');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName(\'script\')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Replace the \'ytplayer\' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player(\'ytplayer-' . $post->ID . '\', {
height: \'390\',
width: \'640\',
videoId: \'' . $ytid . '\'
});
}
</script>';
echo '<div class="video-script script-id-' . $post->ID . '">' .
the_content() .
'</div><!-- .video-script -->';
endif;
endwhile;
?>