本文整理汇总了PHP中wp_video_shortcode函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_video_shortcode函数的具体用法?PHP wp_video_shortcode怎么用?PHP wp_video_shortcode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_video_shortcode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_the_post_video
/**
* Returns the featured video html, ready to echo.
*
* @since 1.0.0
*
* @param int $post_id
* @param string|array $size
*/
public function get_the_post_video($post_id = null, $size = null)
{
$post_id = null === $post_id ? get_the_ID() : $post_id;
if (!has_post_video($post_id)) {
return '';
}
$meta = get_post_meta($post_id, '_fvp_video', true);
$options = get_option('fvp-settings');
// Extract default and default->general options for easy access.
$defaults = !empty($options['default_args']) ? $options['default_args'] : array();
$general = !empty($defaults['general']) ? $defaults['general'] : array();
// Autoplay option. Suppressed when viewing admin.
$general['autoplay'] = (defined('DOING_AJAX') && DOING_AJAX || !is_admin()) && !empty($general['autoplay']) && $general['autoplay'] ? '1' : null;
// Responsive scaling option. Not used when viewing the admin screen.
$responsive = !empty($options['sizing']['responsive']) && $options['sizing']['responsive'] && (defined('DOING_AJAX') && DOING_AJAX || !is_admin());
// Alignment option
$align = !empty($options['alignment']) ? $options['alignment'] : 'center';
$args = array('id' => !empty($meta['id']) ? $meta['id'] : null, 'provider' => !empty($meta['provider']) ? $meta['provider'] : null);
$provider = $args['provider'];
switch ($provider) {
case 'local':
$img_meta = wp_get_attachment_metadata($meta['id']);
$size = $this->get_size($size, array('width' => !empty($img_meta['width']) ? $img_meta['width'] : null, 'height' => !empty($img_meta['height']) ? $img_meta['height'] : null));
$atts = array('src' => wp_get_attachment_url($meta['id']), 'autoplay' => $general['autoplay'] ? 'on' : null, 'loop' => !empty($general['loop']) ? 'on' : null, 'width' => $responsive ? $size['width'] * 8 : $size['width'], 'height' => $responsive ? $size['height'] * 8 : $size['height']);
$args = array_merge($args, $atts);
$embed = wp_video_shortcode($atts);
$embed = apply_filters('fvp-local', $embed, $args);
break;
case 'raw':
$embed = $meta['full'];
break;
default:
$atts = array_merge($general, $this->get_size($size), !empty($defaults[$provider]) ? $defaults[$provider] : array(), isset($meta['parameters']) ? $meta['parameters'] : array());
$args = array_merge($args, $atts);
$embed = $this->oembed->get_html($meta['full'], $atts, $provider);
$embed = apply_filters('fvp-oembed', $embed, $args);
break;
}
if (empty($embed)) {
return '';
}
$classnames = array('featured-video-plus' => true, 'post-thumbnail' => true, 'fvp-responsive' => $responsive);
$classnames['fvp-' . $provider] = !empty($provider);
$classnames['fvp-' . $align] = !empty($align);
$embed = sprintf("<!-- Featured Video Plus v%s -->\n<div%s>%s</div>\n\n", FVP_VERSION, FVP_HTML::class_names($classnames, true, true), $embed);
return $embed;
}
示例2: while
while (have_posts()) {
the_post();
?>
<article <?php
post_class();
?>
>
<header class="entry-header">
<h1 class="entry-title"><?php
the_title();
?>
</h1>
</header><!-- .entry-header -->
<div class="entry-content entry-attachment">
<?php
echo wp_video_shortcode(array('src' => wp_get_attachment_url()));
?>
<p><strong><?php
_e('URL:', 'odin');
?>
</strong> <a href="<?php
echo wp_get_attachment_url();
?>
" title="<?php
the_title_attribute();
?>
" rel="attachment"><span><?php
echo basename(wp_get_attachment_url());
?>
</span></a></p>
示例3: get_html
public function get_html($media)
{
if (!$media) {
return '';
}
$html = '';
$args = array('src' => mpp_get_media_src($media), 'poster' => mpp_get_media_src('thumbnail', $media));
return wp_video_shortcode($args);
}
示例4: tm_player
function tm_player($player = '', $args = array())
{
if (empty($player) || empty($args['files'])) {
return;
}
$defaults = array('files' => array(), 'poster' => '', 'autoplay' => false);
$args = wp_parse_args($args, $defaults);
extract($args);
/* JWPlayer */
if ($player == 'jwplayer') {
$options = array('file' => trim($files[0]), 'image' => $poster);
$atts = arr2atts($options);
$jwplayer_shortcode = '[jwplayer' . $atts . ']';
echo apply_filters('tm_video_filter', $jwplayer_shortcode);
} elseif ($player == 'flowplayer' && function_exists('flowplayer_content_handle')) {
$atts = array('splash' => $poster);
foreach ($files as $key => $file) {
$att = $key == 0 ? 'src' : 'src' . $key;
$atts[$att] = $file;
}
echo flowplayer_content_handle($atts, '', '');
tm_flowplayer_script();
} elseif ($player == 'videojs' && function_exists('video_shortcode')) {
$atts = array('poster' => $poster);
foreach ($files as $key => $file) {
$att = $key == 0 ? 'src' : 'src' . $key;
if (strpos($file, '.mp4') !== false) {
$atts['mp4'] = $file;
}
if (strpos($file, '.webm') !== false) {
$atts['webm'] = $file;
}
if (strpos($file, '.ogg') !== false) {
$atts['ogg'] = $file;
}
}
echo video_shortcode($atts, '', '');
tm_add_videojs_swf();
} else {
$atts = array();
foreach ($files as $file) {
$file = trim($file);
if (strpos($file, 'youtube.com') !== false) {
$atts['youtube'] = $file;
} else {
$type = wp_check_filetype($file, wp_get_mime_types());
$atts[$type['ext']] = $file;
}
}
echo wp_video_shortcode($atts);
}
}
示例5: tzp_add_portfolio_post_media
/**
* This will add portfolio media content to the start of the content
* Override this functionality in a theme by removing the filter.
*
* @param string $content The content
* @return string The updated content
*/
function tzp_add_portfolio_post_media($content)
{
global $post;
if ($post->post_type == 'portfolio') {
$display_gallery = get_post_meta($post->ID, '_tzp_display_gallery', true);
$display_audio = get_post_meta($post->ID, '_tzp_display_audio', true);
$display_video = get_post_meta($post->ID, '_tzp_display_video', true);
if ($display_gallery || $display_audio || $display_video) {
$output = '<div class="portfolio-media">';
if ($display_gallery) {
$output .= tzp_portfolio_gallery($post->ID);
}
if ($display_audio) {
$poster = get_post_meta($post->ID, '_tzp_audio_poster_url', true);
if ($poster) {
$output .= sprintf('<img src="%1$s" alt="" />', esc_url($poster));
}
$mp3 = get_post_meta($post->ID, '_tzp_audio_file_mp3', true);
$ogg = get_post_meta($post->ID, '_tzp_audio_file_ogg', true);
$attr = array('mp3' => $mp3, 'ogg' => $ogg);
$output .= wp_audio_shortcode($attr);
}
if ($display_video) {
$embed = get_post_meta($post->ID, '_tzp_video_embed', true);
if ($embed) {
$output .= html_entity_decode(esc_html($embed));
} else {
$poster = get_post_meta($post->ID, '_tzp_video_poster_url', true);
$m4v = get_post_meta($post->ID, '_tzp_video_file_m4v', true);
$ogv = get_post_meta($post->ID, '_tzp_video_file_ogv', true);
$mp4 = get_post_meta($post->ID, '_tzp_video_file_mp4', true);
$attr = array('poster' => $poster, 'm4v' => $m4v, 'ogv' => $ogv, 'mp4' => $mp4);
$output .= wp_video_shortcode($attr);
}
}
$output .= '</div>';
return $output . $content;
}
return $content;
} else {
return $content;
}
}
示例6: wp_video_shortcode
</h3>
<?php
echo wp_video_shortcode(array('mp4' => 'https://s.w.org/images/core/4.7/edit-shortcuts-v1.mp4', 'poster' => 'https://s.w.org/images/core/4.7/edit-shortcuts.jpg?v2', 'loop' => true, 'autoplay' => true, 'width' => 2520, 'height' => 1454));
?>
<p><?php
_e('Visible icons appear to show you which parts of your site can be customized while live previewing. Click on a shortcut and get straight to editing. Paired with starter content, getting started with customizing your site is faster than ever.');
?>
</p>
</div>
<div class="col">
<h3><?php
_e('Video Headers');
?>
</h3>
<?php
echo wp_video_shortcode(array('mp4' => 'https://s.w.org/images/core/4.7/header-video-v1.mp4', 'poster' => 'https://s.w.org/images/core/4.7/header-video.jpg?v2', 'loop' => true, 'autoplay' => true, 'width' => 2520, 'height' => 1454));
?>
<p><?php
_e('Sometimes a big atmospheric video as a moving header image is just what you need to showcase your wares; go ahead and try it out with Twenty Seventeen. Need some video inspiration? Try searching for sites with video headers available for download and use.');
?>
</p>
</div>
</div>
<div class="feature-section two-col">
<div class="col">
<h3><?php
_e('Smoother Menu Building');
?>
</h3>
<img src="https://s.w.org/images/core/4.7/nav-menus-760.jpg?v2" srcset="https://s.w.org/images/core/4.7/nav-menus-760.jpg?v2 760w, https://s.w.org/images/core/4.7/nav-menus-280.jpg?v2 280w, https://s.w.org/images/core/4.7/nav-menus-536.jpg?v2 536w, https://s.w.org/images/core/4.7/nav-menus-745.jpg?v2 745w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 781px) calc((100vw - 70px) * .466), (max-width: 959px) calc((100vw - 116px) * .469), (max-width: 1290px) calc((100vw - 240px) * .472), 496px" alt="" />
示例7: switch
</h2>
<?php
if ($video_type_option != '') {
switch ($video_type_option) {
case 'youtubelink':
$clipid = get_post_meta($post->ID, 'video_youtube_link', true);
echo iva_youtube(array('clipid' => $clipid, 'width' => '', 'height' => '600'));
break;
case 'vimeolink':
$clipid = get_post_meta($post->ID, 'video_vimeo_link', true);
echo iva_vimeo(array('clip_id' => $clipid, 'width' => '', 'height' => '600'));
break;
case 'selfvideo':
$clipid = get_post_meta($post->ID, 'video_selfhost_video', true);
echo wp_video_shortcode(array('src' => $clipid, 'autoplay' => '', 'height' => 470, 'width' => empty($content_width) ? 740 : $content_width));
break;
}
}
?>
</div><!-- .custompost_details -->
</div><!-- .custompost_entry -->
<div class="demospace" style="height:20px;"></div>
<?php
the_content();
?>
<?php
示例8: edit_form_image_editor
/**
* Displays the image and editor in the post editor
*
* @since 3.5.0
*/
function edit_form_image_editor($post)
{
$open = isset($_GET['image-editor']);
if ($open) {
require_once ABSPATH . 'wp-admin/includes/image-edit.php';
}
$thumb_url = false;
if ($attachment_id = intval($post->ID)) {
$thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
}
$alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
$att_url = wp_get_attachment_url($post->ID);
?>
<div class="wp_attachment_holder">
<?php
if (wp_attachment_is_image($post->ID)) {
$image_edit_button = '';
if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
$nonce = wp_create_nonce("image_editor-{$post->ID}");
$image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
}
?>
<div class="imgedit-response" id="imgedit-response-<?php
echo $attachment_id;
?>
"></div>
<div<?php
if ($open) {
echo ' style="display:none"';
}
?>
class="wp_attachment_image" id="media-head-<?php
echo $attachment_id;
?>
">
<p id="thumbnail-head-<?php
echo $attachment_id;
?>
"><img class="thumbnail" src="<?php
echo set_url_scheme($thumb_url[0]);
?>
" style="max-width:100%" alt="" /></p>
<p><?php
echo $image_edit_button;
?>
</p>
</div>
<div<?php
if (!$open) {
echo ' style="display:none"';
}
?>
class="image-editor" id="image-editor-<?php
echo $attachment_id;
?>
">
<?php
if ($open) {
wp_image_editor($attachment_id);
}
?>
</div>
<?php
} elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
wp_maybe_generate_attachment_metadata($post);
echo wp_audio_shortcode(array('src' => $att_url));
} elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
wp_maybe_generate_attachment_metadata($post);
$meta = wp_get_attachment_metadata($attachment_id);
$w = !empty($meta['width']) ? min($meta['width'], 640) : 0;
$h = !empty($meta['height']) ? $meta['height'] : 0;
if ($h && $w < $meta['width']) {
$h = round($meta['height'] * $w / $meta['width']);
}
$attr = array('src' => $att_url);
if (!empty($w) && !empty($h)) {
$attr['width'] = $w;
$attr['height'] = $h;
}
$thumb_id = get_post_thumbnail_id($attachment_id);
if (!empty($thumb_id)) {
$attr['poster'] = wp_get_attachment_url($thumb_id);
}
echo wp_video_shortcode($attr);
}
?>
</div>
<div class="wp_attachment_details edit-form-section">
<p>
<label for="attachment_caption"><strong><?php
_e('Caption');
?>
</strong></label><br />
//.........这里部分代码省略.........
示例9: pods_video
/**
* Output a video field as a video player.
*
* @uses wp_video_shortcode()
*
* @since 2.5
*
* @param string|array $url Can be a URL of the source file, or a Pods video field.
* @param bool|array $args Optional. Additional arguments to pass to wp_video_shortcode()
*
* @return string
*/
function pods_video($url, $args = false)
{
if (is_array($url)) {
if (!is_null(pods_v('ID', $url))) {
$id = pods_v('ID', $url);
$url = wp_get_attachment_url($id);
} else {
return;
}
}
$video_args = array('src' => $url);
if (is_array($args)) {
$video_args = array_merge($video_args, $args);
}
return wp_video_shortcode($video_args);
}
示例10: array_pop
// Exit if the file is accessed directly over web
if (!defined('ABSPATH')) {
exit;
}
/**
* List videos attached to activity
*
*/
?>
<div class=" mpp-activity-media-list mpp-activity-video-list mpp-activity-video-player">
<?php
$ids = $media_ids;
//is there only one video attached?
if (count($ids) == 1) {
$ids = array_pop($ids);
$media = mpp_get_media($ids);
$args = array('src' => mpp_get_media_src('', $media), 'poster' => mpp_get_media_src('thumbnail', $media));
//show single video with poster
echo wp_video_shortcode($args);
} else {
//show all videos as playlist
echo wp_playlist_shortcode(array('ids' => $ids, 'type' => 'video'));
}
?>
<script type='text/javascript'>
mpp_mejs_activate(<?php
echo bp_get_activity_id();
?>
);
</script>
</div>
示例11: get_video_player
/**
* Wrapper for wp_oembed_get/wp_video_shortcode
*
* @since 0.1.1
*
* @param array $args Optional. Args are passed to either WP_Embed::shortcode,
* or wp_video_shortcode.
* @return mixed The video player if successful.
*/
public function get_video_player($args = array())
{
global $wp_embed;
$media = empty($this->media) ? $this->init_media() : $this->media;
$video = isset($media['video']) ? $media['video'] : array();
if (!isset($video['type'])) {
return '';
}
$video_url = '';
if ('url' === $video['type']) {
$wp_embed->post_ID = $this->ID;
$video_player = $wp_embed->shortcode($args, $video['value']);
} elseif ('attachment_id' === $video['type']) {
$args['src'] = $video['attachment_url'];
if ($video_player = wp_video_shortcode($args)) {
$video_player = '<div class="gc-video-wrap">' . $video_player . '</div><!-- .gc-video-wrap -->';
}
}
return $video_player;
}
示例12: powerpressplayer_build_mediaelementvideo
function powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData = array(), $embed = false)
{
if (!function_exists('wp_video_shortcode')) {
// Return the HTML5 video shortcode instead
return powerpressplayer_build_html5video($media_url, $EpisodeData, $embed);
}
$player_id = powerpressplayer_get_next_id();
$cover_image = '';
$player_width = '';
$player_height = '';
$autoplay = false;
// Global Settings
$Settings = get_option('powerpress_general');
if (!empty($Settings['player_width'])) {
$player_width = $Settings['player_width'];
}
if (!empty($Settings['player_height'])) {
$player_height = $Settings['player_height'];
}
if (!empty($Settings['poster_image'])) {
$cover_image = $Settings['poster_image'];
}
// Episode Settings
if (!empty($EpisodeData['image'])) {
$cover_image = $EpisodeData['image'];
}
if (!empty($EpisodeData['width'])) {
$player_width = $EpisodeData['width'];
}
if (!empty($EpisodeData['height'])) {
$player_height = $EpisodeData['height'];
}
if (!empty($EpisodeData['autoplay'])) {
$autoplay = true;
}
if ($embed) {
$player_height = '123';
$player_width = '456';
}
$content = '';
$content .= '<div class="powerpress_player" id="powerpress_player_' . $player_id . '">' . PHP_EOL;
$attr = array('src' => $media_url, 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'none');
// , 'width'=>'', 'height'=>'');
if (!empty($player_width)) {
$attr['width'] = $player_width;
}
if (!empty($player_height)) {
$attr['height'] = $player_height;
}
if (!empty($cover_image)) {
$attr['poster'] = $cover_image;
}
if (!empty($autoplay)) {
$attr['autoplay'] = 'on';
}
if (!empty($EpisodeData['webm_src'])) {
$attr['webm'] = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p');
}
$shortcode = wp_video_shortcode($attr);
if ($embed) {
$shortcode = str_replace(array('"123"', '"456"', '456px;'), array('"100%"', '"100%"', '100%;'), $shortcode);
}
$content .= $shortcode;
$content .= '</div>' . PHP_EOL;
return $content;
}
示例13: _e
<h4><?php _e( 'Do more with audio and video' ); ?></h4>
<p><?php _e( 'Images have galleries; now we’ve added simple audio and video playlists, so you can showcase your music and clips.' ); ?></p>
</div>
</div>
</div>
<hr>
<div class="changelog customize">
<div class="feature-section col two-col">
<div>
<?php
echo wp_video_shortcode( array(
'mp4' => '//s.w.org/images/core/3.9/widgets.mp4',
'ogv' => '//s.w.org/images/core/3.9/widgets.ogv',
'webm' => '//s.w.org/images/core/3.9/widgets.webm',
'loop' => true,
'autoplay' => true,
'width' => 499
) );
?>
<h4><?php _e( 'Live widget and header previews' ); ?></h4>
<p><?php _e( 'Add, edit, and rearrange your site’s widgets right in the theme customizer. No “save and surprise” — preview your changes live and only save them when you’re ready.' ); ?></p>
<p><?php _e( 'The improved header image tool also lets you upload, crop, and manage headers while customizing your theme.' ); ?></p>
</div>
<div class="last-feature">
<img src="//s.w.org/images/core/3.9/theme.jpg?0" />
<h4><?php _e( 'Stunning new theme browser' ); ?></h4>
<p><?php _e( 'Looking for a new theme should be easy and fun. Lose yourself in the boundless supply of free WordPress.org themes with the beautiful new theme browser.' ); ?></p>
<?php if ( current_user_can( 'install_themes' ) ) { ?>
<p><a href="<?php echo network_admin_url( 'theme-install.php' ); ?>" class="button button-large button-primary"><?php _e( 'Browse Themes' ); ?></a></p>
<?php } ?>
示例14: the_candidate_video
/**
* Output the candidate video
*/
function the_candidate_video($post = null)
{
$video = get_the_candidate_video($post);
$video = is_ssl() ? str_replace('http:', 'https:', $video) : $video;
$filetype = wp_check_filetype($video);
if (!empty($filetype['ext'])) {
$video_embed = wp_video_shortcode(array('src' => $video));
} else {
$video_embed = wp_oembed_get($video);
}
if ($video_embed) {
echo '<div class="candidate-video">' . $video_embed . '</div>';
}
}
示例15: _e
<hr />
<div class="feature-section col two-col">
<div class="col-1">
<h3><?php _e( 'Focus on your content' ); ?></h3>
<p><?php _e( 'Writing and editing is smoother and more immersive with an editor that expands to fit your content as you write, and keeps the formatting tools available at all times.' ); ?></p>
</div>
<div class="col-2 last-feature">
<div class="about-video about-video-focus">
<?php
echo wp_video_shortcode( array(
'mp4' => '//s.w.org/images/core/4.0/focus.mp4',
'ogv' => '//s.w.org/images/core/4.0/focus.ogv',
'webm' => '//s.w.org/images/core/4.0/focus.webm',
'loop' => true,
'autoplay' => true,
'width' => 500,
'height' => 281
) );
?>
</div>
</div>
</div>
<hr />
<div class="feature-section col two-col">
<div class="col-1">
<img src="//s.w.org/images/core/4.0/plugins.png" />
</div>