/**
  * Display widget
  *
  * Display the YouTube widget
  *
  * @since	2.0
  *
  * @uses		generate_youtube_code	Generate the required YouTube code
  *
  * @param	string		$args			Arguments
  * @param	string		$instance		Instance
  */
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     // Output the header
     echo $before_widget;
     // Extract title for heading
     $title = $instance['titles'];
     // Output title, if one exists
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     // Set the correct
     if ($instance['id_type'] == 's') {
         $search = 1;
     } else {
         $search = '';
     }
     if ($instance['id_type'] == 'u') {
         $user = 1;
     } else {
         $user = '';
     }
     // Generate the video and output it
     echo apply_filters('a3_lazy_load_html', vye_generate_youtube_code($instance['id'], '', '', '', '', '', '', $instance['start'], '', '', '', '', $instance['stop'], '', '', '', '', $instance['profile'], $instance['list'], '', '', '', '', '', '', $search, $user, ''));
     // Output the trailer
     echo $after_widget;
 }
Beispiel #2
0
/**
* Embed a YouTube video
*
* Write out XHTML to embed a YouTube video
*
* @since	2.0
*
* @uses		vye_get_parameters			Extract parameters from input
* @uses		vye_get_embed_type			Work out the correct embed type to use
* @uses		vye_set_autohide				Set correct autohide parameter
* @uses		vye_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 = vye_get_parameters($paras, 'width');
    $height = vye_get_parameters($paras, 'height');
    $fullscreen = vye_get_parameters($paras, 'fullscreen');
    $related = vye_get_parameters($paras, 'related');
    $autoplay = vye_get_parameters($paras, 'autoplay');
    $loop = vye_get_parameters($paras, 'loop');
    $start = vye_get_parameters($paras, 'start');
    $info = vye_get_parameters($paras, 'info');
    $annotation = vye_get_parameters($paras, 'annotation');
    $cc = vye_get_parameters($paras, 'cc');
    $link = vye_get_parameters($paras, 'link');
    $react = vye_get_parameters($paras, 'react');
    $stop = vye_get_parameters($paras, 'stop');
    $sweetspot = vye_get_parameters($paras, 'sweetspot');
    $embedplus = vye_get_parameters($paras, 'embedplus');
    $disablekb = vye_get_parameters($paras, 'disablekb');
    $ratio = vye_get_parameters($paras, 'ratio');
    $autohide = vye_get_parameters($paras, 'autohide');
    $controls = vye_get_parameters($paras, 'controls');
    $type = vye_get_parameters($paras, 'type');
    $profile = vye_get_parameters($paras, 'profile');
    $list = vye_get_parameters($paras, 'list');
    $audio = vye_get_parameters($paras, 'audio');
    $template = vye_get_parameters($paras, 'template');
    $hd = vye_get_parameters($paras, 'hd');
    $color = vye_get_parameters($paras, 'color');
    $theme = vye_get_parameters($paras, 'theme');
    $https = vye_get_parameters($paras, 'ssl');
    $dynamic = vye_get_parameters($paras, 'dynamic');
    $search = vye_get_parameters($paras, 'search');
    $user = vye_get_parameters($paras, 'user');
    $vq = vye_get_parameters($paras, 'vq');
    // Get Embed type
    $type = vye_get_embed_type($type, $embedplus);
    // Set up Autohide parameter
    $autohide = vye_set_autohide($autohide);
    echo vye_generate_youtube_code($content, $type, $width, $height, vye_convert($fullscreen), vye_convert($related), vye_convert($autoplay), vye_convert($loop), $start, vye_convert($info), vye_convert_3($annotation), vye_convert($cc), $style, vye_convert($link), vye_convert($react), $stop, vye_convert($sweetspot), vye_convert($disablekb), $ratio, $autohide, $controls, $profile, $list, vye_convert($audio), $template, vye_convert($hd), $color, $theme, vye_convert($https), vye_convert($dynamic), vye_convert($search), vye_convert($user), $vq);
    return;
}
/**
* Filter comments
*
* Filter comments and add YouTube embeds
*
* @since	2.0
*
* @uses		vye_set_general_defaults		Get the general defaults
* @uses		vye_generate_youtube_code	Generate the YouTube embed code
*
* @param    string		$content		The comments content
* @return   string						Content to return
*/
function vye_filter_comments($content)
{
    $options = vye_set_general_defaults();
    if ($options['comments'] == 1) {
        $identifier = 'http://www.youtube.com/watch?v=';
        $search_pos = 0;
        $search = strpos($content, $identifier, $search_pos);
        while ($search !== false) {
            $prefix = substr($content, $search - 1, 1);
            if ($prefix != ']' && $prefix != '"' && $prefix != "'") {
                // Check if link around video. If so, work out how much more needs stripping out
                $anchor_start = 0;
                $anchor_end = 0;
                if ($prefix == ">") {
                    $anchor_pos = strrpos(substr($content, 0, $search), '<a');
                    if ($anchor_pos !== false) {
                        $anchor_start = $search - $anchor_pos;
                        $anchor_end = strpos(substr($content, $search), '</a>') - strlen($identifier) - 11;
                    }
                }
                // Work out video ID and generate code
                $id = substr($content, $search + strlen($identifier), 11);
                $code = vye_generate_youtube_code($id, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $options['comments_profile'], '', '');
                // Now replace the URL with the resultant code
                $first_section = $search - 1 - $anchor_start;
                if ($first_section < 1) {
                    $content = $code . substr($content, $search + strlen($identifier) + 11 + $anchor_end);
                } else {
                    $content = substr($content, 0, $first_section) . $code . substr($content, $search + strlen($identifier) + 11 + $anchor_end);
                }
                $search_pos = $search + strlen($code) - $anchor_start;
            } else {
                $search_pos = $search + strlen($identifier) + 11;
            }
            $search = strpos($content, $identifier, $search_pos - 1);
        }
    }
    return $content;
}
Beispiel #4
0
/**
* Video shortcode
*
* Use shortcode parameters to embed a YouTube video or playlist
*
* @since	2.0
*
* @uses		vye_get_embed_type			Get the embed type
* @uses		vye_set_autohide			Get the autohide parameter
* @uses     vye_set_general_defaults    Set default options
* @uses		vye_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 vye_video_shortcode($paras = '', $content = '', $callback = '', $alt_shortcode = false)
{
    extract(shortcode_atts(array('width' => '', 'height' => '', 'fullscreen' => '', 'related' => '', 'autoplay' => '', 'loop' => '', 'start' => '', 'info' => '', 'annotation' => '', 'cc' => '', 'style' => '', 'stop' => '', 'disablekb' => '', 'ratio' => '', 'autohide' => '', 'controls' => '', 'profile' => '', 'id' => '', 'url' => '', 'rel' => '', 'fs' => '', 'cc_load_policy' => '', 'iv_load_policy' => '', 'showinfo' => '', 'youtubeurl' => '', 'template' => '', 'list' => '', 'color' => '', 'theme' => '', 'ssl' => '', 'height' => '', 'width' => '', 'dynamic' => '', 'h' => '', 'w' => '', 'search' => '', 'user' => '', 'modest' => '', 'playsinline' => '', 'html5' => ''), $paras));
    // If no profile specified and an alternative shortcode used, get that shortcodes default profile
    if ($profile == '' && $alt_shortcode) {
        // Get general options
        $options = vye_set_general_defaults();
        $profile = $options['alt_profile'];
    }
    // 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 (array_key_exists(1, $paras)) {
            if ($paras[1] != '') {
                $width = $paras[1];
            }
        }
        if (array_key_exists(2, $paras)) {
            if ($paras[2] != '') {
                $height = $paras[2];
            }
        }
    }
    // Set up Autohide parameter
    $autohide = vye_set_autohide($autohide);
    // Create YouTube code
    $youtube_code = vye_generate_youtube_code($content, $width, $height, vye_convert($fullscreen), vye_convert($related), vye_convert($autoplay), vye_convert($loop), $start, vye_convert($info), vye_convert_3($annotation), vye_convert($cc), $style, $stop, vye_convert($disablekb), $ratio, $autohide, $controls, $profile, $list, $template, $color, $theme, vye_convert($ssl), vye_convert($dynamic), vye_convert($search), vye_convert($user), vye_convert($modest), vye_convert($playsinline), vye_convert($html5));
    return apply_filters('a3_lazy_load_html', do_shortcode($youtube_code));
}
?>
><?php 
_e('Playlist', 'youtube-embed');
?>
</option>
</select>
<?php 
wp_nonce_field('youtube-embed-profile', 'youtube_embed_profile_nonce', true, true);
?>
<input type="submit" name="Video" class="button-secondary" value="<?php 
_e('Change video', 'youtube-embed');
?>
"/></p>

<p><?php 
if ($video_type == "d") {
    $id = $demo_video;
}
if ($video_type == "3") {
    $id = 'NR5UoBY87GM';
}
if ($video_type == "l") {
    $id = '095393D5B42B2266';
}
echo vye_generate_youtube_code($id, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $profile_no);
?>
</p>

</form></div>

</div>