function tie_video() { $wp_embed = new WP_Embed(); global $post; $get_meta = get_post_custom($post->ID); if (!empty($get_meta["tie_video_url"][0])) { $video_url = $get_meta["tie_video_url"][0]; $video_url = str_replace('https://', 'http://', $video_url); $video_output = $wp_embed->run_shortcode('[embed width="660" height="380"]' . $video_url . '[/embed]'); if ($video_output == '<a href="' . $video_url . '">' . $video_url . '</a>') { $width = '100%'; $height = '380'; $video_link = @parse_url($video_url); if ($video_link['host'] == 'www.youtube.com' || $video_link['host'] == 'youtube.com') { parse_str(@parse_url($video_url, PHP_URL_QUERY), $my_array_of_vars); $video = $my_array_of_vars['v']; $video_output = '<iframe width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $video . '?rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>'; } elseif ($video_link['host'] == 'www.youtu.be' || $video_link['host'] == 'youtu.be') { $video = substr(@parse_url($video_url, PHP_URL_PATH), 1); $video_output = '<iframe width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $video . '?rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>'; } elseif ($video_link['host'] == 'www.vimeo.com' || $video_link['host'] == 'vimeo.com') { $video = (int) substr(@parse_url($video_url, PHP_URL_PATH), 1); $video_output = '<iframe src="http://player.vimeo.com/video/' . $video . '?wmode=opaque" width="' . $width . '" height="' . $height . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; } elseif ($video_link['host'] == 'www.dailymotion.com' || $video_link['host'] == 'dailymotion.com') { $video = substr(@parse_url($video_url, PHP_URL_PATH), 7); $video_id = strtok($video, '_'); $video_output = '<iframe frameborder="0" width="' . $width . '" height="' . $height . '" src="http://www.dailymotion.com/embed/video/' . $video_id . '"></iframe>'; } } } elseif (!empty($get_meta["tie_embed_code"][0])) { $embed_code = $get_meta["tie_embed_code"][0]; $embed_code = htmlspecialchars_decode($embed_code); $width = 'width="100%"'; $height = 'height="400"'; $embed_code = preg_replace('/width="([3-9][0-9]{2,}|[1-9][0-9]{3,})"/', $width, $embed_code); $video_output = preg_replace('/height="([0-9]*)"/', $height, $embed_code); } if (!empty($video_output)) { echo $video_output; } }
/** * @since 3.6.1 * @return string The generate HTML output. */ public function _replyToProcessShortcode_embed($aAttributes, $sURL, $sShortcode = '') { $sURL = isset($aAttributes['src']) ? $aAttributes['src'] : $sURL; $_sHTML = wp_oembed_get($sURL); // If there was a result, return it if ($_sHTML) { // This filter is documented in wp-includes/class-wp-embed.php return "<div class='video oembed'>" . apply_filters('embed_oembed_html', $_sHTML, $sURL, $aAttributes, 0) . "</div>"; } // If not found, return the link. $_oWPEmbed = new WP_Embed(); return "<div class='video oembed'>" . $_oWPEmbed->maybe_make_link($sURL) . "</div>"; }
/** * Shortcode for displaying the image map * * @since 1.0.0 */ public function shortcode($atts) { wp_enqueue_script($this->plugin_slug . '-plugin-script'); wp_enqueue_style($this->plugin_slug . '-plugin-styles'); $image_args = array('post_type' => $this->cpt->post_type, 'posts_per_page' => 1); $image = new WP_Query($image_args); if ($image->have_posts()) { $image->the_post(); $imageID = get_the_ID(); } wp_reset_query(); $hotspots = get_post_meta($imageID, $this->custom_fields->prefix . 'hotspots', true); $url_hotspots = array(); $urls_only = false; $urls_class = ''; $html = ''; if (empty($hotspots) || empty($hotspots['0']['coordinates'])) { _e('You need to define some clickable areas for your image.', 'drawattention'); echo ' '; echo edit_post_link(__('Edit Image', 'drawattention'), false, false, $imageID); } else { $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($imageID), 'full'); $img_url = $img_src[0]; $img_width = $img_src[1]; $img_height = $img_src[2]; $img_post = get_post($imageID); $settings = get_metadata('post', $imageID, '', false); $layout = !empty($settings[$this->custom_fields->prefix . 'map_layout'][0]) ? $settings[$this->custom_fields->prefix . 'map_layout'][0] : 'left'; $spot_id = 'hotspot-' . $imageID; $bg_color = $settings[$this->custom_fields->prefix . 'map_background_color'][0]; $text_color = $settings[$this->custom_fields->prefix . 'map_text_color'][0]; $title_color = $settings[$this->custom_fields->prefix . 'map_title_color'][0]; $custom_css = "\n\t\t\t\t\t#{$spot_id} .hotspots-placeholder,\n\t\t\t\t\t.featherlight .featherlight-content.lightbox{$imageID} {\n\t\t\t\t\t\tbackground: {$bg_color};\n\t\t\t\t\t\tcolor: {$text_color};\n\t\t\t\t\t}\n\n\t\t\t\t\t#{$spot_id} .hotspot-title,\n\t\t\t\t\t.featherlight .featherlight-content.lightbox{$imageID} .hotspot-title {\n\t\t\t\t\t\tcolor: {$title_color};\n\t\t\t\t\t}"; wp_add_inline_style($this->plugin_slug . '-plugin-styles', $custom_css); $wp_embed = new WP_Embed(); $image_html = ''; $image_html .= '<div class="hotspots-image-container">'; $image_html .= '<img width="' . $img_width . '" height= "' . $img_height . '" src="' . $img_url . '" class="hotspots-image" usemap="#hotspots-image-' . $imageID . '" data-event-trigger="click" data-highlight-color="' . $settings[$this->custom_fields->prefix . 'map_highlight_color'][0] . '" data-highlight-opacity="' . $settings[$this->custom_fields->prefix . 'map_highlight_opacity'][0] . '" data-highlight-border-color="' . $settings[$this->custom_fields->prefix . 'map_border_color'][0] . '" data-highlight-border-width="' . $settings[$this->custom_fields->prefix . 'map_border_width'][0] . '" data-highlight-border-opacity="' . $settings[$this->custom_fields->prefix . 'map_border_opacity'][0] . '"/>'; $image_html .= '</div>'; $info_html = ''; $info_html .= '<div class="hotspots-placeholder" id="content-hotspot-' . $imageID . '">'; $info_html .= '<div class="hotspot-initial">'; $info_html .= '<h2 class="hotspot-title">' . get_the_title($imageID) . '</h2>'; $more_info_html = !empty($settings[$this->custom_fields->prefix . 'map_more_info'][0]) ? wpautop(do_shortcode($wp_embed->run_shortcode($settings[$this->custom_fields->prefix . 'map_more_info'][0]))) : ''; $info_html .= '<div class="hostspot-content">' . $more_info_html . '</div>'; $info_html .= '</div>'; $info_html .= '</div>'; $map_html = ''; $map_html .= '<map name="hotspots-image-' . $imageID . '" class="hotspots-map">'; foreach ($hotspots as $key => $hotspot) { if (empty($hotspot['coordinates'])) { continue; } $target = ''; if (!empty($hotspot['action'])) { $target = $hotspot['action']; } $new_window = ''; $target_window = ''; if (!empty($hotspot['action-url-open-in-window'])) { $new_window = $hotspot['action-url-open-in-window']; $target_window = $new_window == 'on' ? '_new' : ''; } $target_url = ''; if (!empty($hotspot['action-url-url'])) { $target_url = $hotspot['action-url-url']; } $area_class = $target == 'url' ? 'url-area' : 'more-info-area'; $href = $target == 'url' ? $target_url : '#hotspot-' . $key; $coords = $hotspot['coordinates']; if (empty($hotspot['title'])) { $hotspot['title'] = ''; } $map_html .= '<area shape="poly" coords="' . $coords . '" href="' . $href . '" title="' . $hotspot['title'] . '" data-action="' . $target . '" target="' . $target_window . '" class="' . $area_class . '">'; if ($target == 'url') { $url_hotspots[] = $hotspot; } } if (count($hotspots) == count($url_hotspots)) { $urls_only = true; $urls_class = 'links-only'; } $map_html .= '</map>'; $html .= '<div class="hotspots-container ' . $urls_class . ' layout-' . $layout . ' event-click' . '" id="' . $spot_id . '">'; $html .= '<div class="hotspots-interaction">'; if ($urls_only) { $html .= $image_html; } else { $html .= $info_html; $html .= $image_html; } $html .= '</div>'; /* End of interaction div that wraps the text area and image only */ $html .= $map_html; foreach ($hotspots as $key => $hotspot) { $html .= '<div class="hotspot-info" id="hotspot-' . $key . '">'; if (!empty($hotspot['title'])) { $html .= '<h2 class="hotspot-title">' . $hotspot['title'] . '</h2>'; } if (!empty($hotspot['detail_image'])) { $html .= '<div class="hotspot-thumb">'; $html .= wp_get_attachment_image($hotspot['detail_image_id'], apply_filters('da_detail_image_size', 'medium', $hotspot, $img_post, $settings)); $html .= '</div>'; } $description_html = !empty($hotspot['description']) ? wpautop(do_shortcode($wp_embed->run_shortcode($hotspot['description']))) : ''; $html .= '<div class="hotspot-content">' . $description_html . '</div>'; $html .= '</div>'; } $html .= '</div>'; } return $html; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; echo $before_title; echo $title; echo $after_title; $protocol = is_ssl() ? 'https' : 'http'; if (!empty($instance['embed_code'])) { echo $instance['embed_code']; } elseif (!empty($instance['video_url'])) { $wp_embed = new WP_Embed(); $video_url = $instance['video_url']; $video_output = $wp_embed->run_shortcode('[embed width="320" height="180"]' . $video_url . '[/embed]'); if ($video_output == '<a href="' . $video_url . '">' . $video_url . '</a>') { $width = '320'; $height = '180'; $video_link = @parse_url($video_url); if ($video_link['host'] == 'www.youtube.com' || $video_link['host'] == 'youtube.com') { parse_str(@parse_url($video_url, PHP_URL_QUERY), $my_array_of_vars); $video = $my_array_of_vars['v']; $video_output = '<iframe width="' . $width . '" height="' . $height . '" src="' . $protocol . '://www.youtube.com/embed/' . $video . '?rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>'; } elseif ($video_link['host'] == 'www.youtu.be' || $video_link['host'] == 'youtu.be') { $video = substr(@parse_url($video_url, PHP_URL_PATH), 1); $video_output = '<iframe width="' . $width . '" height="' . $height . '" src="' . $protocol . '://www.youtube.com/embed/' . $video . '?rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>'; } elseif ($video_link['host'] == 'www.vimeo.com' || $video_link['host'] == 'vimeo.com') { $video = (int) substr(@parse_url($video_url, PHP_URL_PATH), 1); $video_output = '<iframe src="' . $protocol . '://player.vimeo.com/video/' . $video . '?wmode=opaque" width="' . $width . '" height="' . $height . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; } elseif ($video_link['host'] == 'www.dailymotion.com' || $video_link['host'] == 'dailymotion.com') { $video = substr(@parse_url($video_url, PHP_URL_PATH), 7); $video_id = strtok($video, '_'); $video_output = '<iframe frameborder="0" width="' . $width . '" height="' . $height . '" src="' . $protocol . '://www.dailymotion.com/embed/video/' . $video_id . '"></iframe>'; } } if (!empty($video_output)) { echo $video_output; } } echo $after_widget; }
function tie_video() { $wp_embed = new WP_Embed(); global $post; $get_meta = get_post_custom($post->ID); if (!empty($get_meta["tie_video_url"][0])) { $video_url = $get_meta["tie_video_url"][0]; $protocol = is_ssl() ? 'https' : 'http'; if (!is_ssl()) { $video_url = str_replace('https://', 'http://', $video_url); } $video_output = $wp_embed->run_shortcode('[embed width="660" height="371.25"]' . $video_url . '[/embed]'); if ($video_output == '<a href="' . $video_url . '">' . $video_url . '</a>') { $width = '660'; $height = '371.25'; $video_link = @parse_url($video_url); if ($video_link['host'] == 'www.youtube.com' || $video_link['host'] == 'youtube.com') { parse_str(@parse_url($video_url, PHP_URL_QUERY), $my_array_of_vars); $video = $my_array_of_vars['v']; $video_output = '<iframe width="' . $width . '" height="' . $height . '" src="' . $protocol . '://www.youtube.com/embed/' . $video . '?rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>'; } elseif ($video_link['host'] == 'www.youtu.be' || $video_link['host'] == 'youtu.be') { $video = substr(@parse_url($video_url, PHP_URL_PATH), 1); $video_output = '<iframe width="' . $width . '" height="' . $height . '" src="' . $protocol . '://www.youtube.com/embed/' . $video . '?rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>'; } elseif ($video_link['host'] == 'www.vimeo.com' || $video_link['host'] == 'vimeo.com') { $video = (int) substr(@parse_url($video_url, PHP_URL_PATH), 1); $video_output = '<iframe src="' . $protocol . '://player.vimeo.com/video/' . $video . '?wmode=opaque" width="' . $width . '" height="' . $height . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; } elseif ($video_link['host'] == 'www.dailymotion.com' || $video_link['host'] == 'dailymotion.com') { $video = substr(@parse_url($video_url, PHP_URL_PATH), 7); $video_id = strtok($video, '_'); $video_output = '<iframe frameborder="0" width="' . $width . '" height="' . $height . '" src="' . $protocol . '://www.dailymotion.com/embed/video/' . $video_id . '"></iframe>'; } } } elseif (!empty($get_meta["tie_embed_code"][0])) { $embed_code = $get_meta["tie_embed_code"][0]; $video_output = htmlspecialchars_decode($embed_code); } elseif (!empty($get_meta["tie_video_self"][0])) { $video_self = $get_meta["tie_video_self"][0]; $video_output = do_shortcode('[video width="1280" height="720" mp4="' . $get_meta["tie_video_self"][0] . '"][/video]'); } if (!empty($video_output)) { echo $video_output; } }
function sp_ev_display_gallery($width, $height, $link) { global $wp_query, $post, $features_3_0; ?> <?php // if ( $wp_query->max_num_pages > 1 ) : ?> <!-- see http://core.trac.wordpress.org/ticket/6453 --> <script type="text/javascript"> //<![CDATA[ var tb_pathToImage = "wp-includes/js/thickbox/loadingAnimation.gif"; var tb_closeImage = "wp-includes/js/thickbox/tb-close.png"; //]]> </script> <div id="nav-above" class="navigation"> <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Older videos', 'external-videos')); ?> </div> <div class="nav-next"><?php previous_posts_link(__('Newer videos <span class="meta-nav">→</span>', 'external-videos')); ?> </div> </div><!-- #nav-above --> <?php // endif; ?> <div class="gallerycontainer" style="clear:all;"> <?php while (have_posts()) { the_post(); $thumbnail = get_post_meta(get_the_ID(), 'thumbnail_url'); $thumb = $thumbnail[0]; $videourl = get_post_meta(get_the_ID(), 'video_url'); $video = trim($videourl[0]); $description = get_post_meta(get_the_ID(), 'description'); $desc = $description[0]; $short_title = sp_ev_shorten_text(get_the_title(), 33); $thickbox_title = sp_ev_shorten_text(get_the_title(), 90); // get oEmbed code $oembed = new WP_Embed(); $html = $oembed->shortcode(null, $video); // replace width with 600, height with 360 $html = preg_replace('/width="\\d+"/', 'width="' . $width . '"', $html); $html = preg_replace('/height="\\d+"/', 'height="' . $height . '"', $html); ?> <div style="margin:2px; height:auto; width:auto; float:left;"> <?php // display overlay if requested if ($link == "page") { ?> <a href="<?php the_permalink(); ?> " title="<?php echo $thickbox_title; ?> "> <div style="display:box; width:120px; height:90px;"> <img title="<?php the_title(); ?> " src="<?php echo $thumb; ?> " style="display:inline; margin:0; border:1px solid black; width:120px; height:90px"/> </div> </a> <div style="width:120px; height: 12px; margin-bottom:7px; line-height: 90%"> <small><i><?php echo get_the_time('F j, Y'); ?> </i></small> </div> <div style="width:120px; height: 30px; margin-bottom:20px; line-height: 80%"> <small><?php echo $short_title; ?> </small> </div> <?php // display overlay if requested } else { ?> <a href="#TB_inline?height=500&width=700&inlineId=hiddenModalContent_<?php the_ID(); ?> " title="<?php echo $thickbox_title; ?> " class="thickbox"> <div style="display:box; width:120px; height:90px;"> <img title="<?php the_title(); ?> " src="<?php echo $thumb; ?> " style="display:inline; margin:0; border:1px solid black; width:120px; height:90px"/> </div> </a> <div style="width:120px; height: 12px; margin-bottom:7px; line-height: 90%"> <small><i><?php echo get_the_time('F j, Y'); ?> </i></small> </div> <div style="width:120px; height: 30px; margin-bottom:20px; line-height: 80%"> <small><?php echo $short_title; ?> </small> </div> <!-- Hidden content for the thickbox --> <div id="hiddenModalContent_<?php echo $post->ID; ?> " style="display:none;"> <p align="center" style="margin-bottom:10px;"> <?php echo $html; ?> </p> <div style="margin-bottom:10px;"> <?php if ($post->post_parent > 0) { ?> <a href="<?php echo get_permalink($post->post_parent); ?> "><?php _e('Blog post related to this video', 'external-videos'); ?> </a> <?php } ?> <br /> <?php if ($features_3_0) { ?> <a href="<?php the_permalink(); ?> "><?php _e('Video page', 'external-videos'); ?> </a> <?php } ?> </div> <div style="margin-bottom:10px;"> <?php echo $desc; ?> </div> <div style="text-align: center;"> <input type="submit" id="Login" value="OK" onclick="tb_remove()"/> </div> </div> <?php } ?> </div> <?php } ?> <div style="clear: both;"></div> </div> <?php // if ( $wp_the_query->max_num_pages > 1 ) : ?> <br /> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Older videos', 'external-videos')); ?> </div> <div class="nav-next"><?php previous_posts_link(__('Newer videos <span class="meta-nav">→</span>', 'external-videos')); ?> </div> </div><!-- #nav-below --> <?php // endif; ?> <?php }
?> <?php echo do_shortcode('[video src="' . get_post_meta(get_the_ID(), '_mighty_video-url', true) . '" width="640"]'); ?> <?php } ?> <?php } elseif (get_post_meta(get_the_ID(), '_mighty_video-embed', true)) { ?> <?php $wp_embed = new WP_Embed(); $post_embed = $wp_embed->run_shortcode('[embed width="640"]' . get_post_meta(get_the_ID(), '_mighty_video-embed', true) . '[/embed]'); ?> <?php echo $post_embed; ?> <?php } else { ?> <?php if (has_post_thumbnail()) { ?>
function layers_get_feature_media($attachmentid = NULL, $size = 'medium', $video = NULL, $postid = NULL) { // Return dimensions $image_dimensions = layers_get_image_sizes($size); // Mime Type $mime_type = get_post_mime_type($attachmentid); // Check for an image if (NULL != $attachmentid && '' != $attachmentid) { if (preg_match('/video\\/*/', $mime_type)) { $image_ratio = explode('-', $size); if (count($image_ratio) == 3) { $ratio = $image_ratio[1]; } else { $ratio = 'landscape'; } $use_video = layers_get_html5_video(wp_get_attachment_url($attachmentid), $image_dimensions['width'], $ratio); } else { $use_image = wp_get_attachment_image($attachmentid, $size); } } // Check for a video if (NULL != $video && '' != $video) { $embed_code = '[embed width="' . $image_dimensions['width'] . '" height="' . $image_dimensions['height'] . '"]' . $video . '[/embed]'; $wp_embed = new WP_Embed(); $use_video = $wp_embed->run_shortcode($embed_code); } // Set which element to return if (NULL != $postid && (is_single() && isset($use_video) || !is_single() && !is_page_template('template-blog.php') && isset($use_video) && !isset($use_image))) { $media = $use_video; } else { if (NULL == $postid && isset($use_video)) { $media = $use_video; } else { if (isset($use_image)) { $media = $use_image; } else { return NULL; } } } $media_output = do_action('layers_before_feature_media') . $media . do_action('layers_after_feature_media'); return $media_output; }
<?php $content = $post->post_content; // http://vimeo.com/74209516 OR https $posvideo = strpos($content, "http://vimeo.com/"); $regex = '/https?:\\/\\/vimeo\\.com\\//'; preg_match($regex, $content, $matches, PREG_OFFSET_CAPTURE); $posvideo = $matches[1]; if ($posvideo === false) { } else { $posbreak = strpos($content, "\n"); $rest = substr($content, $posvideo, $posbreak - 1); //echo(".".$rest."."); $content = substr($content, $posbreak); $wp_embed = new WP_Embed(); //$post_embed = $wp_embed->run_shortcode( '[embed width="980"]' . get_post_meta( get_the_ID(), '_mighty_video-embed', true ) . '[/embed]' ); //global $wp_embed; $post_embed = $wp_embed->run_shortcode('[embed]' . $rest . '[/embed]'); echo $post_embed; } ?> </div> <div class="whiteboard clearfix"> <div class="entry-content" itemprop="text"> <?php echo $content;
function layers_get_feature_media($attachmentid = NULL, $size = 'medium', $video = NULL, $postid = NULL) { // Return dimensions $image_dimensions = layers_get_image_sizes($size); // Check for an image if (NULL != $attachmentid && '' != $attachmentid) { $use_image = wp_get_attachment_image($attachmentid, $size); } // Check for a video if (NULL != $video && '' != $video) { $embed_code = '[embed width="' . $image_dimensions['width'] . '" height="' . $image_dimensions['height'] . '"]' . $video . '[/embed]'; $wp_embed = new WP_Embed(); $use_video = $wp_embed->run_shortcode($embed_code); } // Set which element to return if (NULL != $postid && (is_single() && isset($use_video) || !is_single() && !is_page_template('template-blog.php') && isset($use_video) && !isset($use_image))) { $media = $use_video; } else { if (NULL == $postid && isset($use_video)) { $media = $use_video; } else { if (isset($use_image)) { $media = $use_image; } else { return NULL; } } } $media_output = do_action('layers_before_feature_media') . $media . do_action('layers_after_feature_media'); return $media_output; }
/** * Create WP Embed * * Creates the necessary iframe structure for available * sites using the default WP embed shortcode. If a video * address is one of the accepted sites that can use the * URL and oembed, aside from Vimeo and Youtube, this function * will be called. Vimeo and YouTube url's use a custom * function of ale_create_vimeo_player() or ale_create_youtube_player() * * @return string */ function ale_create_wp_embed_player($media_source = '', $width = 640, $height = 360, $allow_autoplay = 1) { $wp_embed = new WP_Embed(); $output = $wp_embed->run_shortcode('[embed width=' . $width . ' height=' . $height . ']' . $media_source . '[/embed]'); return $output; }
function widget($args, $instance) { extract($args); if (!defined('ATW_PRO')) { $instance = atw_check_widget_visibility($instance, $this, $args); if (!$instance) { return; } } $title = isset($instance['title']) ? esc_attr($instance['title']) : false; $title = apply_filters('atw_widget_title', $title); $text = isset($instance['text']) ? $instance['text'] : false; $wpEmbed = new WP_Embed(); $text = $wpEmbed->run_shortcode($text); $text = apply_filters('atw_widget_content', $text, $instance); echo $before_widget; echo "<div class='AdvancedText'>"; $title ? print $before_title . $title . $after_title : null; eval('?>' . $text); echo "</div>"; echo $after_widget . "\n"; }
function get_obox_media($args) { global $blog_id; $defaults = array('postid' => 0, 'width' => 590, 'height' => '', 'href_class' => '', 'wrap' => '', 'wrap_class' => '', 'hide_href' => false, 'exclude_video' => false, 'zc' => 1, 'imglink' => false, 'imgnocontainer' => false, 'resizer' => 'medium', 'imagefallback' => false); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); //Set final HTML to nothing $html = ""; // VIDEO QUERY $embed_code = get_post_meta($postid, "main_video", true); // Regular Embed Code $oembed_link = get_post_meta($postid, "video_link", true); $self_hosted_video = get_post_meta($postid, "video_hosted", true); if ($height == '') { // Height fallback $videoheight = round($width * 0.75, 0); } else { $videoheight = $height; } if ($self_hosted_video != "") { // Self hosted video uses a special function $video = obox_player($postid, $width, $videoheight); } elseif ($oembed_link != "") { // oEmbed Video $embed_code = '[embed width="' . $width . '" height="' . $videoheight . '"]' . $oembed_link . '[/embed]'; $wp_embed = new WP_Embed(); $video = $wp_embed->run_shortcode($embed_code); } elseif ($embed_code != "") { // Regular video embed $video = preg_replace("/(width\\s*=\\s*[\"\\'])[0-9]+([\"\\'])/i", "\$1 {$width} \" wmode=\"transparent\"", $embed_code); $video = preg_replace("/(height\\s*=\\s*[\"\\'])[0-9]+([\"\\'])/i", "\$1 {$videoheight} \$2", $video); } // AUDIO QUERY $soundcloud = get_post_meta($postid, "soundcloud", true); if ($soundcloud != "" && $exclude_video == false) { $audio = $soundcloud; $hide_href = true; } // THUMBNAIL QUERY //Set up which meta value we're using for the post if (!get_option("ocmx_thumbnail_usage")) { $meta = "wordpress"; } elseif (get_option("ocmx_thumbnail_usage") == "none") { return false; } elseif (get_option("ocmx_thumbnail_usage") != "0") { $meta = get_option("ocmx_thumbnail_usage"); } elseif (!get_option("ocmx_thumbnail_custom") !== "") { $meta = get_option("ocmx_thumbnail_custom"); } else { $meta = "other_media"; } //Check for a thumbnail using the meta $meta_thumbnail_url = get_post_meta($postid, $meta, true); //Let's check for the a video thumbnail via oEmbed if ($oembed_link != "" && (strpos($oembed_link, 'vimeo') || strpos($oembed_link, 'yout'))) { $oembed_info = get_post_meta($postid, "oembed_info", true); } if (function_exists("has_post_thumbnail") && has_post_thumbnail($postid)) { // WordPress Thumbnail overrides everything $image = get_the_post_thumbnail($postid, $resizer); } elseif ($oembed_link != "" && $exclude_video == true && !empty($oembed_info)) { // Use oEmbed image if we've got one $image = "<img src=\"" . $oembed_info['thumb_large'] . "\" alt=\"" . $oembed_info['title'] . "\" />"; } elseif ($imagefallback == true) { // Fallback to use the first image in the post, only if specified $attachmentargs = array("post_type" => "attachment", "post_parent" => $postid, "numberposts" => "1", "orderby" => "menu_order", "order" => "ASC"); $attachments = get_posts($attachmentargs); $image = wp_get_attachment_image($attachments[0]->ID, $resizer); } // POST LINK if ($imglink != true) { // Post Permalink $link = get_permalink($postid); } elseif ($meta == "wordpress" && function_exists("has_post_thumbnail") && has_post_thumbnail()) { // Featured image url $link = wp_get_attachment_url(get_post_thumbnail_id($postid), "full"); } else { // Link straight to the post meta url $link = $meta_thumbnail_url; } // ADD THE HREF AND START PUTTING THE HTML TOGETHER if ($href_class != "") { $href_class = "class=\"{$href_class}\""; } if (isset($audio)) { $html = $audio; } elseif (isset($video) && ($exclude_video == false || !isset($image))) { // If we have a video, and we're not prioritizing images $html = $video; } elseif ($hide_href == false && isset($image)) { // If we got an image and we want to link it $html = "<a href=\"{$link}\" {$href_class}>{$image}</a>"; } elseif (isset($image)) { // If we just have an image $html = $image; } // Class for the surrounding divs if ($wrap_class != "") { $class = " class=\"{$wrap_class}\""; } else { $class = ""; } // Add the container to the whole dang thing if ($imgnocontainer == true && isset($image) && (!isset($video) && !$exclude_video)) { $html; } elseif ($html != '' && $wrap != '') { $html = "<{$wrap}" . $class . ">" . $html . "</{$wrap}>"; } return $html; }
function hocwp_setup_theme_woocommerce_product_tabs_callback($key, $tab) { $content = hocwp_get_post_meta($key, get_the_ID()); $content = trim($content); $title = hocwp_get_value_by_key($tab, 'title'); if (empty($content)) { $slug = hocwp_sanitize_html_class($key); $hocwp_product_tab = hocwp_get_post_by_slug($slug, 'hocwp_product_tab'); if (!hocwp_is_post($hocwp_product_tab)) { $hocwp_product_tab = hocwp_get_post_by_column('post_title', $title); } if (hocwp_is_post($hocwp_product_tab)) { $content = $hocwp_product_tab->post_content; $content = trim($content); } } if (!empty($content)) { if (!empty($title)) { echo hocwp_wrap_tag($title, 'h2', 'tab-title'); } echo '<div class="hocwp-product-info">'; $embed = new WP_Embed(); $content = $embed->run_shortcode($content); $content = $embed->autoembed($content); hocwp_the_custom_content($content); echo '</div>'; } }
function __construct($rte) { $this->rte = $rte; parent::__construct(); }
/** * Display the video using * * @param array $args * @param array $instance */ function widget($args, $instance) { $embed = new WP_Embed(); if (!wp_script_is('fitvids')) { wp_enqueue_script('fitvids', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/js/jquery.fitvids.min.js', array('jquery'), POOTLEPAGE_VERSION); } if (!wp_script_is('siteorigin-panels-embedded-video')) { wp_enqueue_script('siteorigin-panels-embedded-video', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/js/embedded-video.min.js', array('jquery', 'fitvids'), POOTLEPAGE_VERSION); } echo $args['before_widget']; ?> <div class="siteorigin-fitvids"><?php echo $embed->run_shortcode('[embed]' . $instance['video'] . '[/embed]'); ?> </div><?php echo $args['after_widget']; }
public function test_maybe_make_link_do_not_link_if_unknown() { $url = 'http://example.com/'; $this->wp_embed->linkifunknown = false; $this->assertEquals($url, $this->wp_embed->maybe_make_link($url)); }
/** * Display the video using * * @param array $args * @param array $instance */ function widget($args, $instance) { $embed = new WP_Embed(); if (!wp_script_is('siteorigin-panels-embedded-video')) { wp_enqueue_script('siteorigin-panels-embedded-video', get_template_directory_uri() . '/extras/panels-lite/widgets/js/embedded-video.js', array('jquery', 'fitvids'), SITEORIGIN_THEME_VERSION); } echo $args['before_widget']; ?> <div class="siteorigin-fitvids"><?php echo $embed->run_shortcode('[embed]' . $instance['video'] . '[/embed]'); ?> </div><?php echo $args['after_widget']; }
if ($student_voice_query->have_posts()) { while ($student_voice_query->have_posts()) { $student_voice_query->the_post(); ?> <div id="modal_home_<?php the_id(); ?> _video" class="reveal-modal large black_bg" data-reveal aria-hidden="true" role="dialog"> <div class="flex-video"></div> <a class="close-reveal-modal" aria-label="Close">×</a> </div> <script> <?php $vid_url = get_the_content(); $embed_vid = "[embed]" . $vid_url . "[/embed]"; $wp_embed = new WP_Embed(); $post_embed = $wp_embed->run_shortcode($embed_vid); ?> var $d = jQuery.noConflict(); $d('a[data-reveal-id="modal_home_<?php the_id(); ?> _video"]').click( function(){ $d('<?php echo $post_embed; ?> ').appendTo('#modal_home_<?php the_id(); ?> _video .flex-video'); });
/** * * * @param null $id * @param null $type */ function focus_post_video($id = null, $type = null) { if (empty($id)) { $id = get_the_ID(); } if (empty($type)) { $type = 'public'; } $video = get_post_meta(get_the_ID(), 'focus_video', true); // Gives child themes a chance to change the video type being displayed $type = apply_filters('focus_video_type', $type, $video, $id); if (empty($video[$type]['type'])) { return; } if (empty($video[$type][$video[$type]['type']])) { return; } switch ($video[$type]['type']) { case 'self': case 'remote': $file = $video[$type]['type'] == 'self' ? wp_get_attachment_url($video[$type]['self']) : esc_url($video[$type]['remote']); ?> <div class="jp-video"> <div class="jp-type-single" id="jp_interface_1"> <div id="jquery_jplayer_1" class="jp-jplayer" data-video="<?php echo esc_attr($file); ?> " <?php do_action('focus_video_selfhosted_attrs'); ?> ></div> <?php do_action('focus_video_play_button'); ?> <div class="jp-gui"> <ul class="jp-controls"> <li><a href="#" class="jp-play" tabindex="1"><?php esc_html_e('play', 'focus'); ?> </a></li> <li><a href="#" class="jp-pause" tabindex="1"><?php esc_html_e('pause', 'focus'); ?> </a></li> <li><a href="#" class="jp-stop" tabindex="1"><?php esc_html_e('stop', 'focus'); ?> </a></li> <li><a href="#" class="jp-full-screen" tabindex="1"><?php esc_html_e('full screen', 'focus'); ?> </a></li> <li><a href="#" class="jp-restore-screen" tabindex="1"><?php esc_html_e('restore screen', 'focus'); ?> </a></li> <li><a href="#" class="jp-mute" tabindex="1"><?php esc_html_e('mute', 'focus'); ?> </a></li> <li><a href="#" class="jp-unmute" tabindex="1"><?php esc_html_e('unmute', 'focus'); ?> </a></li> </ul> <div class="sep jp-controls-sep"></div> <div class="jp-progress"> <div class="jp-seek-bar"> <div class="jp-play-bar"><div class="jp-play-bar-marker"></div></div> </div> </div> <div class="jp-time-info"> <div class="jp-current-time"></div> / <div class="jp-duration"></div> </div> <div class="sep jp-time-sep"></div> <div class="jp-volume-bar"> <div class="jp-volume-bar-value"></div> </div> <div class="sep jp-full-sep"></div> </div> </div> </div> <?php break; case 'external': $embed = new WP_Embed(); $code = $embed->shortcode(array('autoplay' => 1, 'width' => 960), $video[$type]['external']); $code = apply_filters('focus_video_embed_code', $code); echo $code; break; case 'custom': if (!empty($video[$type]['custom'])) { echo apply_filters('focus_video_embed_code', $video[$type]['custom']); } break; } }
<script> <?php $embed_vid2 = "[embed]http://vimeo.com/79193058[/embed]"; $wp_embed2 = new WP_Embed(); $post_embed2 = $wp_embed2->run_shortcode($embed_vid2); ?> var $d = jQuery.noConflict(); $d('a[data-reveal-id="modal_video_two"]').click( function(){ $d('<?php echo $post_embed2; ?> ').appendTo('#modal_video_two .flex-video'); }); <?php $embed_vid3 = "[embed]http://vimeo.com/79241720[/embed]"; $wp_embed3 = new WP_Embed(); $post_embed3 = $wp_embed3->run_shortcode($embed_vid3); $mobile_view = get_template_directory_uri() . '/parts/utl-print.html'; ?> $d('a[data-reveal-id="modal_video_five"]').click( function(){ $d('<?php echo $post_embed3; ?> ').appendTo('#modal_video_five .flex-video'); }); $d('#mobile-switch').click(function(){ $d(".utl-container").empty();; $d(".utl-container").load("<?php echo $mobile_view; ?>
/** * Display the video using * * @param array $args * @param array $instance */ function widget($args, $instance) { $embed = new WP_Embed(); if (!wp_script_is('fitvids')) { wp_enqueue_script('fitvids', SITEORIGIN_PANELS_URI . 'widgets/js/jquery.fitvids.js', array('jquery'), SITEORIGIN_PANELS_VERSION); } if (!wp_script_is('siteorigin-panels-embedded-video')) { wp_enqueue_script('siteorigin-panels-embedded-video', SITEORIGIN_PANELS_URI . 'widgets/js/embedded-video.js', array('jquery', 'fitvids'), SITEORIGIN_PANELS_VERSION); } echo $args['before_widget']; ?> <div class="siteorigin-fitvids"><?php echo $embed->run_shortcode('[embed]' . $instance['video'] . '[/embed]'); ?> </div><?php echo $args['after_widget']; }