/** * Embed a YouTube video * * Write out XHTML to embed a YouTube video * * @since 2.0 * * @uses aye_get_parameters Extract parameters from input * @uses aye_get_embed_type Work out the correct embed type to use * @uses aye_set_autohide Set correct autohide parameter * @uses aye_generate_youtube_code Generate the YouTube code * * @param string $content YouTube video ID * @param string $paras List of parameters * @param string $style Optional CSS */ function youtube_video_embed($content, $paras = '', $style = '') { $width = aye_get_parameters($paras, 'width'); $height = aye_get_parameters($paras, 'height'); $fullscreen = aye_get_parameters($paras, 'fullscreen'); $related = aye_get_parameters($paras, 'related'); $autoplay = aye_get_parameters($paras, 'autoplay'); $loop = aye_get_parameters($paras, 'loop'); $start = aye_get_parameters($paras, 'start'); $info = aye_get_parameters($paras, 'info'); $annotation = aye_get_parameters($paras, 'annotation'); $cc = aye_get_parameters($paras, 'cc'); $link = aye_get_parameters($paras, 'link'); $react = aye_get_parameters($paras, 'react'); $stop = aye_get_parameters($paras, 'stop'); $sweetspot = aye_get_parameters($paras, 'sweetspot'); $embedplus = aye_get_parameters($paras, 'embedplus'); $disablekb = aye_get_parameters($paras, 'disablekb'); $ratio = aye_get_parameters($paras, 'ratio'); $autohide = aye_get_parameters($paras, 'autohide'); $controls = aye_get_parameters($paras, 'controls'); $type = aye_get_parameters($paras, 'type'); $profile = aye_get_parameters($paras, 'profile'); $list = aye_get_parameters($paras, 'list'); $audio = aye_get_parameters($paras, 'audio'); $template = aye_get_parameters($paras, 'template'); $hd = aye_get_parameters($paras, 'hd'); $color = aye_get_parameters($paras, 'color'); $theme = aye_get_parameters($paras, 'theme'); $https = aye_get_parameters($paras, 'ssl'); $dynamic = aye_get_parameters($paras, 'dynamic'); $search = aye_get_parameters($paras, 'search'); $user = aye_get_parameters($paras, 'user'); // Get Embed type $type = aye_get_embed_type($type, $embedplus); // Set up Autohide parameter $autohide = aye_set_autohide($autohide); echo aye_generate_youtube_code($content, $type, $width, $height, aye_convert($fullscreen), aye_convert($related), aye_convert($autoplay), aye_convert($loop), $start, aye_convert($info), aye_convert_3($annotation), aye_convert($cc), $style, aye_convert($link), aye_convert($react), $stop, aye_convert($sweetspot), aye_convert($disablekb), $ratio, $autohide, $controls, $profile, $list, aye_convert($audio), $template, aye_convert($hd), $color, $theme, aye_convert($https), aye_convert($dynamic), aye_convert($search), aye_convert($user)); return; }
/** * Video shortcode * * Use shortcode parameters to embed a YouTube video or playlist * * @since 2.0 * * @uses aye_get_embed_type Get the embed type * @uses aye_set_autohide Get the autohide parameter * @uses aye_set_general_defaults Set default options * @uses aye_generate_youtube_code Generate the embed code * * @param string $paras Shortcode parameters * @param string $content Shortcode content * @param string $alt_shortcode The number of the alternative shortcode used * @return string YouTube embed code */ function aye_video_shortcode($paras = '', $content = '', $callback = '', $alt_shortcode = '') { extract(shortcode_atts(array('type' => '', 'width' => '', 'height' => '', 'fullscreen' => '', 'related' => '', 'autoplay' => '', 'loop' => '', 'start' => '', 'info' => '', 'annotation' => '', 'cc' => '', 'style' => '', 'link' => '', 'react' => '', 'stop' => '', 'sweetspot' => '', 'disablekb' => '', 'ratio' => '', 'autohide' => '', 'controls' => '', 'profile' => '', 'embedplus' => '', 'audio' => '', 'id' => '', 'url' => '', 'rel' => '', 'fs' => '', 'cc_load_policy' => '', 'iv_load_policy' => '', 'showinfo' => '', 'youtubeurl' => '', 'template' => '', 'list' => '', 'hd' => '', 'color' => '', 'theme' => '', 'ssl' => '', 'height' => '', 'width' => '', 'dynamic' => '', 'h' => '', 'w' => '', 'search' => '', 'user' => ''), $paras)); // If no profile specified and an alternative shortcode used, get that shortcodes default profile if ($profile == '' && $alt_shortcode != '') { // Profile is now blank or 2 if ($alt_shortcode == '1') { $alt_shortcode = ''; } // Get general options $options = aye_set_general_defaults(); $profile = $options['alt_profile' . $alt_shortcode]; } // If an alternative field is set, use it if ($id != '' && $content == '') { $content = $id; } if ($url != '' && $content == '') { $content = $url; } if ($youtubeurl != '' && $content == '') { $content = $youtubeurl; } if ($h != '' && $height == '') { $height = $h; } if ($w != '' && $width == '') { $width = $w; } if ($rel != '' && $related == '') { $related = $rel; } if ($fs != '' && $fullscreen == '') { $fullscreen = $fs; } if ($cc_load_policy != '' && $cc == '') { $cc = $cc_load_policy; } if ($iv_load_policy != '' && $annotation == '') { $annotation = $iv_load_policy; } if ($showinfo != '' && $info == '') { $info = $showinfo; } // If ID was not passed in the content and the first parameter is set, assume that to be the ID if ($content == '' && $paras[0] != '') { $content = $paras[0]; if (substr($content, 0, 1) == ":" or substr($content, 0, 1) == "=") { $content = substr($content, 1); } if ($paras[1] != '') { $width = $paras[1]; } if ($paras[2] != '') { $height = $paras[2]; } } // Get Embed type $type = aye_get_embed_type($type, $embedplus); // Set up Autohide parameter $autohide = aye_set_autohide($autohide); // Create YouTube code $youtube_code = aye_generate_youtube_code($content, $type, $width, $height, aye_convert($fullscreen), aye_convert($related), aye_convert($autoplay), aye_convert($loop), $start, aye_convert($info), aye_convert_3($annotation), aye_convert($cc), $style, aye_convert($link), aye_convert($react), $stop, aye_convert($sweetspot), aye_convert($disablekb), $ratio, $autohide, $controls, $profile, $list, aye_convert($audio), $template, aye_convert($hd), $color, $theme, aye_convert($ssl), aye_convert($dynamic), aye_convert($search), aye_convert($user)); return do_shortcode($youtube_code); }