/** * Render the shortcode * @param array $args Shortcode paramters * @param string $content Content between shortcode * @return string HTML output */ function render($args, $content = '') { $defaults = FusionCore_Plugin::set_shortcode_defaults(array('class' => '', 'api_params' => '', 'autoplay' => "false", 'center' => 'no', 'height' => 360, 'id' => '', 'width' => 600), $args); extract($defaults); self::$args = $defaults; if ($autoplay == 'true' || $autoplay == 'yes') { $autoplay = '&autoplay=1'; } else { $autoplay = ''; } $html = sprintf('<div %s><div %s><iframe title="YouTube video player" src="http://www.youtube.com/embed/%s?wmode=transparent%s%s" width="%s" height="%s" frameborder="0" allowfullscreen></iframe></div></div>', FusionCore_Plugin::attributes('youtube-shortcode'), FusionCore_Plugin::attributes('youtube-shortcode-video-sc'), $id, $autoplay, $api_params, $width, $height); return $html; }
/** * Render the shortcode * @param array $args Shortcode paramters * @param string $content Content between shortcode * @return string HTML output */ function render($args, $content = '') { $defaults = FusionCore_Plugin::set_shortcode_defaults(array('class' => '', 'api_params' => '', 'autoplay' => "false", 'center' => 'no', 'height' => 360, 'id' => '', 'width' => 600), $args); extract($defaults); self::$args = $defaults; if (is_ssl()) { $protocol = 'https'; } else { $protocol = 'http'; } // Make sure only the video ID is passed to the iFrame $pattern = '~(?:http|https|)(?::\\/\\/|)(?:www.|)(?:youtu\\.be\\/|youtube\\.com(?:\\/embed\\/|\\/v\\/|\\/watch\\?v=|\\/ytscreeningroom\\?v=|\\/feeds\\/api\\/videos\\/|\\/user\\S*[^\\w\\-\\s]|\\S*[^\\w\\-\\s]))([\\w\\-]{11})[a-z0-9;:@#?&%=+\\/\\$_.-]*~i'; preg_match($pattern, $id, $matches); if (isset($matches[1])) { $id = $matches[1]; } $html = sprintf('<div %s><div %s><iframe title="YouTube video player" src="%s://www.youtube.com/embed/%s?wmode=transparent&autoplay=0%s" width="%s" height="%s" frameborder="0" allowfullscreen></iframe></div></div>', FusionCore_Plugin::attributes('youtube-shortcode'), FusionCore_Plugin::attributes('youtube-shortcode-video-sc'), $protocol, $id, $api_params, $width, $height); return $html; }