-
Notifications
You must be signed in to change notification settings - Fork 0
/
shortcodes.php
39 lines (32 loc) · 1.21 KB
/
shortcodes.php
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
<?php // CUSTOM SHORTCODES
// Video embed shortcodes
add_shortcode('youtube', 'custom_video_embed');
add_shortcode('vimeo', 'custom_video_embed');
function custom_video_embed($atts, $content = null, $tag){
extract(shortcode_atts(array(
'id' => '',
'width' => '100%',
'height' => '400px'
), $atts, 'video_embed'));
if($id != ''){
$attributes = array("frameborder=\"0\"");
if(!empty($width)) $attributes[] = "width=\"{$width}\"";
if(!empty($height)) $attributes[] = "height=\"{$height}\"";
switch($tag){
case "youtube":
$src = "http://www.youtube-nocookie.com/embed/{$id}";
$attributes[] = "allowfullscreen";
break;
case "vimeo":
$src = "http://player.vimeo.com/video/{$id}?title=0&byline=0&portrait=0";
$attributes[] = "webkitAllowFullScreen";
$attributes[] = "mozallowfullscreen";
$attributes[] = "allowFullScreen";
break;
}
return "<div class=\"embed-wrapper\">\n" .
"<iframe " . implode(" ", $attributes) . " src=\"{$src}\"></iframe>\n" .
"</div>\n";
}
return;
}