controller = $controller; } function get_defaults() { return array( 'videotype' => 'iframe', 'iframe' => '', 'mp4' => '', 'webm' => '', 'poster' => '', 'videowidth' => 480, 'videoheight' => 270, 'keepaspectratio' => 1, 'autoplay' => 0, 'loop' => 0, 'videocss' => 'position:relative;display:block;background-color:#000;overflow:hidden;max-width:100%;margin:0 auto;', 'playbutton' => WONDERPLUGIN_VIDEOEMBED_URL . 'engine/playvideo-64-64-0.png', 'lightbox' => 0, 'lightboxsize' => 1, 'lightboxwidth' => 960, 'lightboxheight' => 540, 'autoopen' => 0, 'autoopendelay' => 1000, 'autoclose' => 0, 'lightboxtitle' => '', 'lightboxgroup' => '', 'lightboxshownavigation' => 0, 'lightboxoptions' => '', 'showimage' => '' ); } function get_boolparams() { return array('lightbox', 'lightboxsize', 'autoopen', 'autoclose', 'lightboxshownavigation', 'autoplay', 'loop', 'keepaspectratio'); } function get_htmlparams() { return array('lightboxtitle'); } function double_escape_html($str) { $str = str_replace('"', '\\"', $str); $str = str_replace('&', '&', $str); $str = str_replace('<', '<', $str); $str = str_replace('>', '>', $str); $str = str_replace('"', '"', $str); return str_replace('&', '&', $str); } function un_double_escape_html($str) { $str = str_replace('&', '&', $str); return str_replace('&', '&', $str); } function un_double_escape_html_for_display($str) { $str = $this->un_double_escape_html($str); return str_replace('"', '"', $str); } function unescape_html_for_edit($str) { $str = str_replace('&', '&', $str); return str_replace('\\"', '"', $str); } function process_wistiaurl($url, $autoplay, $loop) { $glue = (strpos($url, '?') !== false) ? '&' : '?'; if ($autoplay) { $url .= $glue . 'autoPlay=true'; $glue = '&'; } if ($loop) { $url .= $glue . 'endVideoBehavior=loop'; } return $url; } function process_vimeourl($url, $autoplay, $loop) { $id = null; $qs = null; $result = $url; preg_match('/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/', $url, $matches); if (!empty($matches) && !empty($matches[5])) $id = $matches[5]; if (!empty($id)) { $result = 'https://player.vimeo.com/video/' . $id; $query_array = array(); if ($autoplay) $query_array[] = 'autoplay=1'; if ($loop) $query_array[] = 'loop=1'; $parts = parse_url($url); if (isset($parts['query'])) parse_str($parts['query'], $qs); if (!empty($qs)) { foreach( $qs as $key => $value ) $query_array[] = urlencode( $key ) . '=' . urlencode( $value ); } if (!empty($query_array)) $result .= '?' . implode( '&', $query_array ); } return $result; } function process_youtubeurl($url, $autoplay, $loop) { $id = null; $qs = null; $result = $url; $parts = parse_url($url); if (isset($parts['query'])) { parse_str($parts['query'], $qs); if (isset($qs['v'])) $id = $qs['v']; else if (isset($qs['vi'])) $id = $qs['vi']; unset($qs['v']); unset($qs['vi']); } if (empty($id) && isset($parts['path'])) { $path = explode('/', trim($parts['path'], '/')); $id = $path[count($path)-1]; } if (!empty($id)) { $result = 'https://www.youtube.com/embed/' . $id; $query_array = array(); if ($autoplay) $query_array[] = 'autoplay=1'; if ($loop) $query_array[] = 'loop=1&playlist=' . $id; if (!empty($qs)) { foreach( $qs as $key => $value ) $query_array[] = urlencode( $key ) . '=' . urlencode( $value ); } if (!empty($query_array)) $result .= '?' . implode( '&', $query_array ); } return $result; } function process_iframeurl($url, $autoplay, $loop) { if ((strpos(strtolower($url), 'youtube.com') !== false) || (strpos(strtolower($url), 'youtu.be') !== false)) $url = $this->process_youtubeurl($url, $autoplay, $loop); else if (strpos(strtolower($url), 'vimeo.com') !== false) $url = $this->process_vimeourl($url, $autoplay, $loop); else if (strpos(strtolower($url), 'wistia') !== false) $url = $this->process_wistiaurl($url, $autoplay, $loop); return $url; } function lightbox_data_tags($atts) { $content = ' data-autoplay="' . ((!empty($atts['autoplay'])) ? 'true' : 'false') . '"'; if (!empty($atts['loop'])) $content .= ' data-loopvideo="true"'; if (!empty($atts['lightboxsize'])) $content .= ' data-width=' . $atts['lightboxwidth'] . ' data-height=' . $atts['lightboxheight']; if (!empty($atts['autoopen'])) $content .= ' data-autoopen="true" data-autoopendelay=' . $atts['autoopendelay']; if (!empty($atts['autoclose'])) $content .= ' data-autoclose="true"'; if (!empty($atts['lightboxgroup'])) $content .= ' data-group="' . $atts['lightboxgroup'] . '"'; if (!empty($atts['lightboxshownavigation']) && !empty($atts['showimage'])) $content .= ' data-thumbnail="' . $atts['showimage'] . '"'; if (!empty($atts['lightboxtitle'])) $content .= ' title="' . $this->un_double_escape_html($atts['lightboxtitle']) . '"'; if (!empty($atts['lightboxoptions'])) $content .= ' ' . $this->un_double_escape_html_for_display($atts['lightboxoptions']); return $content; } function shortcode_handler($atts) { $content = '
process_iframeurl($atts['iframe'], false, false); $content .= 'lightbox_data_tags($atts); $content .= '>'; if (!empty($atts['showimage'])) $content .= '
'; if (!empty($atts['playbutton'])) $content .= '
'; $content .= '
'; } else { $iframe_url = $this->process_iframeurl($atts['iframe'], (!empty($atts['autoplay']) ? true: false), (!empty($atts['loop']) ? true: false)); $content .= ''; } } else if (!empty($atts['videotype']) && $atts['videotype'] == 'mp4') { if (!empty($atts['lightbox'])) { $content .= 'lightbox_data_tags($atts); $content .= '>'; if (!empty($atts['showimage'])) $content .= '
'; if (!empty($atts['playbutton'])) $content .= '
'; $content .= '
;'; } else { $content .= '
get_defaults()); $videotype = esc_attr( $instance['videotype'] ); $iframe = esc_url( $instance['iframe'] ); $mp4 = esc_url( $instance['mp4'] ); $webm = esc_url( $instance['webm'] ); $poster = esc_url( $instance['poster'] ); $lightbox = esc_attr( $instance['lightbox'] ); $lightboxsize = esc_attr( $instance['lightboxsize'] ); $lightboxwidth = esc_attr( $instance['lightboxwidth'] ); $lightboxheight = esc_attr( $instance['lightboxheight'] ); $autoopen = esc_attr( $instance['autoopen'] ); $autoclose = esc_attr( $instance['autoclose'] ); $autoopendelay = esc_attr( $instance['autoopendelay'] ); $lightboxtitle = esc_attr( $instance['lightboxtitle'] ); $lightboxgroup = esc_attr( $instance['lightboxgroup'] ); $lightboxshownavigation = esc_attr( $instance['lightboxshownavigation'] ); $showimage = esc_url( $instance['showimage'] ); $lightboxoptions = esc_attr( $instance['lightboxoptions'] ); $lightboxtitle = $this->unescape_html_for_edit($lightboxtitle); $videowidth = esc_attr( $instance['videowidth'] ); $videoheight = esc_attr( $instance['videoheight'] ); $keepaspectratio = esc_attr( $instance['keepaspectratio'] ); $autoplay = esc_attr( $instance['autoplay'] ); $loop = esc_attr( $instance['loop'] ); $videocss = esc_attr( $instance['videocss'] ); $playbutton = esc_url( $instance['playbutton'] ); $param_names = array(); foreach($instance as $key => $value) $param_names[$key] = $widget->get_field_name($key); ?>
Video
Lightbox
Options

" > " value="" />

">

" value="" />

" value="" />

" value="" />

>* To play in lightbox, Wonder Lightbox must be installed and activated.

" value="" class="small-text" /> / " value="" class="small-text" />

" value="" />

" value="" class="small-text" />

" value="" class="small-text" /> / " value="" class="small-text" />

    

* Autoplay does not work on mobile and tablets.

" value="" />

" value="" /> OR