本文整理汇总了PHP中wp_oembed_get函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_oembed_get函数的具体用法?PHP wp_oembed_get怎么用?PHP wp_oembed_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_oembed_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
function widget($args, $instance)
{
$title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : '';
$video_url = isset($instance['video_url']) ? $instance['video_url'] : '';
$description = isset($instance['video_description']) ? $instance['video_description'] : '';
// Before widget WP hook
echo $args['before_widget'];
// Show widget title
if ($title) {
echo $args['before_title'] . $title . $args['after_title'];
}
// Show video
if ($video_url) {
echo '<div class="responsive-video-wrap clr">';
echo wp_oembed_get($video_url, array('width' => 270));
echo '</div>';
} else {
esc_html_e('You forgot to enter a video URL.', 'total');
}
// Show video description if field isn't empty
if ($description) {
echo '<div class="wpex-video-widget-description">' . wpex_sanitize_data($description, 'html') . '</div>';
}
// After widget WP hook
echo $args['after_widget'];
}
示例2: widget
/**
* Front-end display of widget
**/
public function widget($args, $instance)
{
global $before_widget, $after_widget, $before_title, $after_title;
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$video_url = $instance['video_url'];
$video_title = $instance['video_title'];
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
$video_embed = wp_oembed_get($video_url);
?>
<div class="widget-body">
<div class="module-body">
<div class="magazilla_featured_video">
<?php
echo '<figure class="magazilla_featured_video_wrapper">' . $video_embed . '</figure>';
?>
</div>
<h4 class="heading"><?php
echo $video_title;
?>
</h4>
</div>
</div>
<?php
echo $after_widget;
}
示例3: handle_get_oembed_by_url
function handle_get_oembed_by_url()
{
$url = $_REQUEST['url'];
$embed_code = wp_oembed_get($url, array('width' => '100%', 'height' => '100%', 'autoplay' => 1));
echo $embed_code;
die;
}
示例4: et_pb_video_get_oembed_thumbnail
function et_pb_video_get_oembed_thumbnail()
{
if (!wp_verify_nonce($_POST['et_admin_load_nonce'], 'et_admin_load_nonce')) {
die(-1);
}
if (!current_user_can('edit_posts')) {
die(-1);
}
$video_url = esc_url($_POST['et_video_url']);
if (false !== wp_oembed_get($video_url)) {
// Get image thumbnail
add_filter('oembed_dataparse', 'et_pb_video_oembed_data_parse', 10, 3);
// Save thumbnail
$image_src = wp_oembed_get($video_url);
// Set back to normal
remove_filter('oembed_dataparse', 'et_pb_video_oembed_data_parse', 10, 3);
if ('' === $image_src) {
die(-1);
}
echo esc_url($image_src);
} else {
die(-1);
}
die;
}
示例5: ut_get_video_player
function ut_get_video_player()
{
/* get video to check */
$video = $_POST['video'];
/* needed variables */
$embed_code = NULL;
/* check if youtube has been used */
preg_match('~(?: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', trim($video), $matches);
if (!empty($matches[1])) {
$embed_code = '<iframe height="315" width="560" src="http://www.youtube.com/embed/' . trim($matches[1]) . '?wmode=transparent&vq=hd720&autoplay=1" wmode="Opaque" allowfullscreen="" frameborder="0"></iframe>';
}
/* no video found so far , try to create a player */
if (empty($embed_code)) {
$video_embed = wp_oembed_get(trim($video));
if (!empty($video_embed)) {
$embed_code = $video_embed;
}
}
/* still no video found , let's try to apply a shortcode */
if (empty($embed_code)) {
$embed_code = do_shortcode(stripslashes($video));
}
echo $embed_code;
die(1);
}
示例6: widget
function widget($args, $instance)
{
extract($args);
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title']);
$content = $instance['content'];
$link = $instance['link'];
$include_border = $instance['include_border'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
if ($title) {
echo $before_title . $title . $after_title;
}
echo '<p>' . do_shortcode($content) . '</p>';
$embed_code = wp_oembed_get($link, array('width' => 247, 'height' => 139));
$inc_border = "";
if ($include_border == 'yes') {
$inc_border = " hb-box-frame";
}
if ($embed_code) {
echo '<div class="fitVids' . $inc_border . '"><span>';
echo $embed_code;
echo '</span></div>';
} else {
echo "[Video Widget Error] Sorry, but the URL you entered is not supported. Check <a href=\"http://codex.wordpress.org/Embeds\">http://codex.wordpress.org/Embeds</a> for more info.";
}
/* After widget (defined by themes). */
echo $after_widget;
}
示例7: ebor_hero_video_popup_shortcode
/**
* The Shortcode
*/
function ebor_hero_video_popup_shortcode($atts, $content = null)
{
extract(shortcode_atts(array('embed' => '', 'image' => ''), $atts));
$output = '
<div class="cta-video imagebg space--lg" data-overlay="4">
<div class="background-image-holder">
' . wp_get_attachment_image($image, 'full') . '
</div>
<div class="container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-offset-1 text-center">
<div class="modal-instance">
<div class="video-play-icon modal-trigger"></div>
<div class="modal-container">
<div class="modal-content bg--dark" data-width="70%" data-height="70%">
' . wp_oembed_get($embed) . '
</div><!--end of modal-content-->
</div><!--end of modal-container-->
</div><!--end of modal instance-->
<div class="wpb_text_column">
' . do_shortcode(htmlspecialchars_decode($content)) . '
</div>
</div>
</div><!--end of row-->
</div><!--end of container-->
</div>
';
return $output;
}
示例8: block
function block($instance)
{
extract($instance);
if ($link) {
echo '<figure class="media-wrapper player portfolio">' . wp_oembed_get(esc_url($link)) . '</figure>';
}
}
示例9: ebor_video_inline_shortcode
/**
* The Shortcode
*/
function ebor_video_inline_shortcode($atts)
{
extract(shortcode_atts(array('layout' => 'local', 'image' => '', 'video' => '', 'mpfour' => '', 'ogv' => '', 'webm' => '', 'embed' => ''), $atts));
if ('local' == $layout) {
$output = '
<div class="video-cover">
<div class="background-image-holder">
' . wp_get_attachment_image($image, 'full') . '
</div>
<div class="video-play-icon"></div>
<video controls>
<source src="' . esc_url($webm) . '" type="video/webm">
<source src="' . esc_url($mpfour) . '" type="video/mp4">
<source src="' . esc_url($ogv) . '" type="video/ogg">
</video>
</div>
';
} elseif ('embed' == $layout) {
$output = '
<div class="video-cover">
<div class="background-image-holder">
' . wp_get_attachment_image($image, 'full') . '
</div>
<div class="video-play-icon "></div>
' . wp_oembed_get($embed, array('height' => '300')) . '
</div>
';
}
return $output;
}
示例10: widget
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
function widget($args, $instance)
{
// Extract args
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$video_url = isset($instance['video_url']) ? $instance['video_url'] : '';
$description = isset($instance['video_description']) ? $instance['video_description'] : '';
// Before widget WP hook
echo $before_widget;
// Show widget title
if ($title) {
echo $before_title . $title . $after_title;
}
// Define video height and width
$video_size = array('width' => 270);
// Show video
if ($video_url) {
echo '<div class="wpex-video-embed clr">' . wp_oembed_get($video_url, $video_size) . '</div>';
} else {
_e('You forgot to enter a video URL.', 'wpex');
}
// Show video description if field isn't empty
if ($description) {
echo '<div class="wpex-video-widget-description">' . $description . '</div>';
}
// After widget WP hook
echo $after_widget;
}
示例11: test_youtube_com_mobile_embed
/**
* Test m.youtube.com embeds
*
* @ticket 32714
*/
function test_youtube_com_mobile_embed()
{
$out = wp_oembed_get('http://m.youtube.com/watch?v=oHg5SJYRHA0');
$this->assertContains('https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out);
$out = wp_oembed_get('https://m.youtube.com/watch?v=oHg5SJYRHA0');
$this->assertContains('https://www.youtube.com/embed/oHg5SJYRHA0?feature=oembed', $out);
}
示例12: video_code
function video_code($videos, $classes = array())
{
if (empty($videos)) {
return;
}
$video_element = '<video class="' . esc_attr(implode(',', $classes)) . '" autoplay loop muted>';
foreach ($videos as $video) {
if (empty($video['file']) && empty($video['url'])) {
continue;
}
if (empty($video['url'])) {
$video_file = wp_get_attachment_url($video['file']);
$video_element .= '<source src="' . sow_esc_url($video_file) . '" type="' . esc_attr($video['format']) . '">';
} else {
$args = '';
if (!empty($video['height'])) {
$args['height'] = $video['height'];
}
echo wp_oembed_get($video['url'], $args);
}
}
if (strpos($video_element, 'source') !== false) {
$video_element .= '</video>';
echo $video_element;
}
}
示例13: ebor_modal_shortcode
/**
* The Shortcode
*/
function ebor_modal_shortcode($atts, $content = null)
{
extract(shortcode_atts(array('image' => false, 'fullscreen' => 'no', 'button_text' => '', 'icon' => '', 'delay' => false, 'align' => 'text-center', 'cookie' => false, 'manual_id' => false, 'video' => '', 'width' => '60', 'height' => '60'), $atts));
if ($delay) {
$delay = 'data-autoshow="' . (int) $delay . '"';
}
if ($video) {
$output = '
<div class="modal-instance modal-video-1">
<div class="' . $align . '">
<a class="btn modal-trigger" href="#">
<span class="btn__text">
► ' . $button_text . '
</span>
</a>
</div>
<div class="modal-container" ' . $delay . '>
<div class="modal-content bg-dark" data-width="' . (int) $width . '%" data-height="' . (int) $height . '%">
' . wp_oembed_get($video) . '
</div><!--end of modal-content-->
</div><!--end of modal-container-->
</div><!--end of modal instance-->
';
} else {
$output = '
<div class="modal-instance">
<div class="' . $align . '">
<a class="btn modal-trigger" href="#">
<span class="btn__text"><i class="' . $icon . '"></i> ' . $button_text . '</span>
</a>
</div>
<div class="modal-container" ' . $delay . '>
';
if ($image) {
$output .= '
<div class="modal-content bg-white imagebg" data-width="' . (int) $width . '%" data-height="' . (int) $height . '%" data-overlay="5">
<div class="background-image-holder">
' . wp_get_attachment_image($image, 'full') . '
</div>
<div class="pos-vertical-center clearfix">
<div class="col-sm-6 col-sm-offset-1">
';
} else {
$output .= '
<div class="modal-content bg--white height--natural">
<div class="form-subscribe-1 boxed boxed--lg bg--white box-shadow-wide">
<div class="subscribe__title text-center">
';
}
$output .= do_shortcode($content) . '
</div>
</div>
</div><!--end of modal-content-->
</div><!--end of modal-container-->
</div><!--end of modal instance-->
';
}
return $output;
}
示例14: ale_featured_video
function ale_featured_video($atts, $content = null)
{
extract(shortcode_atts(array('url' => ''), $atts));
if (!$url) {
return '';
}
return '<p class="video">' . wp_oembed_get($url, array('width' => '900', 'height' => '600')) . '</p>';
}
示例15: st_restaurent_video
function st_restaurent_video($attr = array())
{
if (is_singular('st_restaurent')) {
if ($video = get_post_meta(get_the_ID(), 'video', true)) {
return "<div class='media-responsive'>" . wp_oembed_get($video) . "</div>";
}
}
}