当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_audio_shortcode函数代码示例

本文整理汇总了PHP中wp_audio_shortcode函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_audio_shortcode函数的具体用法?PHP wp_audio_shortcode怎么用?PHP wp_audio_shortcode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_audio_shortcode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cap_podcast_player

/**
* We're going to override the_content through a filter.
*/
function cap_podcast_player($id = null, $player_type = 'default')
{
    if (empty($id)) {
        $post_id = get_the_ID();
    } else {
        $post_id = $id;
    }
    $episode_number = get_post_meta($post_id, 'episode_number', true);
    // Get Episode Media Source
    $episode_attachment_id = get_post_meta($post_id, 'episode_file', true);
    $episode_external_file = get_post_meta($post_id, 'external_episode_file', true);
    if (!empty($episode_attachment_id)) {
        $player_src = wp_get_attachment_url($episode_attachment_id);
    } elseif (!empty($episode_external_file)) {
        $player_src = $episode_external_file;
    }
    $attr = array('src' => '' . $player_src . '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata');
    $player = wp_audio_shortcode($attr);
    $download_link = '<small><a href="' . $player_src . '" download="episode' . $episode_number . '.mp3">Download this Episode</a></small>';
    // Get Episode Artwork //
    $episode_artwork_id = get_post_thumbnail_id($post_id);
    $episode_artwork = wp_get_attachment_image_src($episode_artwork_id, 'cap-podcast-thumbnail');
    $episode_artwork_src = $episode_artwork[0];
    if ('default' == $player_type) {
        $episode_title = '
        <div class="episode-info">
            <h4>Episode #' . $episode_number . '</h4>
            <h2>' . get_the_title($post_id) . '</h2>
        </div>
        ';
    } elseif ('large' == $player_type) {
        $post_object = get_post($post_id);
        $episode_title = '
        <a href="' . get_permalink($post_id) . '" class="episode-info">
            <h4>Episode #' . $episode_number . '</h4>
            <h2>' . get_the_title($post_id) . '</h2>
            <span class="description">' . wp_trim_words($post_object->post_content, '60') . '</span>
        </a>
        ';
    } elseif ('mini' == $player_type) {
        $episode_title = '';
    }
    // Construct Markup
    $markup = '
    <div class="episode-header">
        <div class="episode-artwork-container">
            <div class="episode-artwork" style="background-image: url(' . $episode_artwork_src . ');">
                <div id="play-episode" class="maintain-ratio">
                    <span class="dashicons"></span>
                </div>
            </div>
        </div>
        ' . $episode_title . '
    </div>';
    $script = "\n    <script type='text/javascript'>\n    var playerID = jQuery('#episode-" . $episode_number . "-" . $post_id . " audio').attr('id');\n    var player" . $post_id . " = document.getElementById(playerID);\n    jQuery('#episode-" . $episode_number . "-" . $post_id . " #play-episode').click(function(){\n        jQuery('#episode-" . $episode_number . "-" . $post_id . " #play-episode .dashicons').toggleClass('paused');\n    });\n\n    jQuery('#episode-" . $episode_number . "-" . $post_id . " #play-episode').click(function() {\n\n        if ( jQuery('#episode-" . $episode_number . "-" . $post_id . " #play-episode .dashicons').hasClass('paused') ) {\n            player" . $post_id . ".play();\n        }\n\n        if ( !jQuery('#episode-" . $episode_number . "-" . $post_id . " #play-episode .dashicons').hasClass('paused') ) {\n            player" . $post_id . ".pause();\n        }\n\n    });\n    </script>\n    ";
    if (function_exists('cap_podcast_player_colors')) {
        $player .= cap_podcast_player_colors($post_id);
    }
    return '<div id="episode-' . $episode_number . '-' . $post_id . '" class="podcast-player ' . $player_type . '">' . $markup . $player . $download_link . $script . '</div>';
}
开发者ID:amprog,项目名称:cap-podcaster,代码行数:63,代码来源:single-episode-template.php

示例2: test_fix_audio_shortcode

 /**
  * @covers \PressBooks\Sanitize\fix_audio_shortcode
  */
 public function test_fix_audio_shortcode()
 {
     \PressBooks\Sanitize\fix_audio_shortcode();
     $this->assertTrue(has_filter('wp_audio_shortcode'));
     // Verify that style attribute is empty.
     $var = wp_audio_shortcode(array('src' => 'http://foo/audio.mp3'));
     $this->assertContains('style=""', $var);
 }
开发者ID:cumi,项目名称:pressbooks,代码行数:11,代码来源:test-sanitize.php

示例3: get_html

 public function get_html($media)
 {
     if (!$media) {
         return '';
     }
     $html = '';
     $args = array('src' => mpp_get_media_src(), 'loop' => false, 'autoplay' => false);
     return wp_audio_shortcode($args);
 }
开发者ID:baden03,项目名称:mediapress,代码行数:9,代码来源:media-view-audio.php

示例4: 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;
    }
}
开发者ID:TyRichards,项目名称:paradox,代码行数:50,代码来源:functions.php

示例5: front_main

    public static function front_main($data)
    {
        $data->name = __CLASS__;
        ?>
		<div id="module-<?php 
        echo $data->ID;
        ?>
" class="<?php 
        echo $data->name;
        ?>
 front-single-module<?php 
        echo audio_module::FRONT_SAVE == true ? '-save' : '';
        ?>
">
			<?php 
        if ($data->post_title != '' && parent::display_title_on_front($data)) {
            ?>
				<h2 class="module_title"><?php 
            echo $data->post_title;
            ?>
</h2>
			<?php 
        }
        ?>

			<?php 
        if ($data->audio_url != '') {
            ?>
				<div class="audio_player">
					<?php 
            $attr = array('src' => $data->audio_url, 'loop' => checked($data->loop, 'Yes', false) ? 'on' : '', 'autoplay' => checked($data->autoplay, 'Yes', false) ? 'on' : '');
            echo wp_audio_shortcode($attr);
            ?>
				</div>
			<?php 
        }
        ?>
		</div>
	<?php 
    }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:40,代码来源:audio.php

示例6: get_files_array

 /**
  * Return an array of files prepared for output.
  *
  * Processes files by file type and generates unique output for each.
  *
  * Returns array for each file, with the following keys:
  *
  * `file_path` => The file path of the file, with a line break
  * `html` => The file output HTML formatted
  *
  * @since  1.2
  * @todo  Support `playlist` shortcode for playlist of video/audio
  * @usedby gravityview_get_files_array()
  * @param  string $value    Field value passed by Gravity Forms. String of file URL, or serialized string of file URL array
  * @param  string $gv_class Field class to add to the output HTML
  * @return array           Array of file output, with `file_path` and `html` keys (see comments above)
  */
 static function get_files_array($value, $gv_class)
 {
     $gravityview_view = GravityView_View::getInstance();
     extract($gravityview_view->getCurrentField());
     $output_arr = array();
     // Get an array of file paths for the field.
     $file_paths = rgar($field, 'multipleFiles') ? json_decode($value) : array($value);
     // Process each file path
     foreach ($file_paths as $file_path) {
         // If the site is HTTPS, use HTTPS
         if (function_exists('set_url_scheme')) {
             $file_path = set_url_scheme($file_path);
         }
         // This is from Gravity Forms's code
         $file_path = esc_attr(str_replace(" ", "%20", $file_path));
         // If the field is set to link to the single entry, link to it.
         $link = !empty($field_settings['show_as_link']) ? GravityView_API::entry_link($entry, $field) : $file_path;
         // Get file path information
         $file_path_info = pathinfo($file_path);
         $html_format = NULL;
         $disable_lightbox = false;
         $disable_wrapped_link = false;
         // Is this an image?
         $image = new GravityView_Image(array('src' => $file_path, 'class' => 'gv-image gv-field-id-' . $field_settings['id'], 'alt' => $field_settings['label'], 'width' => gravityview_get_context() === 'single' ? NULL : 250));
         $content = $image->html();
         // The new default content is the image, if it exists. If not, use the file name as the content.
         $content = !empty($content) ? $content : $file_path_info['basename'];
         // If pathinfo() gave us the extension of the file, run the switch statement using that.
         $extension = empty($file_path_info['extension']) ? NULL : strtolower($file_path_info['extension']);
         switch (true) {
             // Audio file
             case in_array($extension, wp_get_audio_extensions()):
                 $disable_lightbox = true;
                 if (shortcode_exists('audio')) {
                     $disable_wrapped_link = true;
                     /**
                      * Modify the settings passed to the `wp_video_shortcode()` function
                      *
                      * @since  1.2
                      * @var array
                      */
                     $audio_settings = apply_filters('gravityview_audio_settings', array('src' => $file_path, 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings['id']));
                     /**
                      * Generate the audio shortcode
                      * @link http://codex.wordpress.org/Audio_Shortcode
                      * @link https://developer.wordpress.org/reference/functions/wp_audio_shortcode/
                      */
                     $content = wp_audio_shortcode($audio_settings);
                 }
                 break;
                 // Video file
             // Video file
             case in_array($extension, wp_get_video_extensions()):
                 $disable_lightbox = true;
                 if (shortcode_exists('video')) {
                     $disable_wrapped_link = true;
                     /**
                      * Modify the settings passed to the `wp_video_shortcode()` function
                      *
                      * @since  1.2
                      * @var array
                      */
                     $video_settings = apply_filters('gravityview_video_settings', array('src' => $file_path, 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings['id']));
                     /**
                      * Generate the video shortcode
                      * @link http://codex.wordpress.org/Video_Shortcode
                      * @link https://developer.wordpress.org/reference/functions/wp_video_shortcode/
                      */
                     $content = wp_video_shortcode($video_settings);
                 }
                 break;
                 // PDF
             // PDF
             case $extension === 'pdf':
                 // PDF needs to be displayed in an IFRAME
                 $link = add_query_arg(array('TB_iframe' => 'true'), $link);
                 break;
                 // if not image, do not set the lightbox (@since 1.5.3)
             // if not image, do not set the lightbox (@since 1.5.3)
             case !in_array($extension, array('jpg', 'jpeg', 'jpe', 'gif', 'png')):
                 $disable_lightbox = true;
                 break;
         }
//.........这里部分代码省略.........
开发者ID:psdes,项目名称:GravityView,代码行数:101,代码来源:fileupload.php

示例7: base_print_audio_html

 /**
  * Prints the WP Audio Shortcode to output the HTML for audio
  * @param  int $postid The post ID
  * @return string         The "hmtl" for printing audio elements
  */
 function base_print_audio_html($postid)
 {
     $output = '';
     $posttype = get_post_type($postid);
     $keys = array('post' => array('mp3' => '_zilla_audio_mp3', 'ogg' => '_zilla_audio_ogg'), 'portfolio' => array('mp3' => '_tzp_audio_file_mp3', 'ogg' => '_tzp_audio_file_ogg'));
     // Print an image if needed
     if ($posttype == 'portfolio') {
         $img = get_post_meta($postid, '_tzp_audio_poster_url', true);
         if ($img) {
             $output .= '<img src="' . esc_url_raw($img) . '" alt="' . esc_attr(get_the_title($postid)) . '" />';
         }
     } elseif (has_post_thumbnail($postid)) {
         $size = 'post-thumbnail';
         if (is_singular()) {
             $size = 'full';
         }
         $output .= get_the_post_thumbnail($postid, $size);
     }
     // Build the "shortcode"
     $mp3 = get_post_meta($postid, $keys[$posttype]['mp3'], true);
     $ogg = get_post_meta($postid, $keys[$posttype]['ogg'], true);
     $attr = array();
     if ($mp3) {
         $attr['mp3'] = $mp3;
     }
     if ($ogg) {
         $attr['ogg'] = $ogg;
     }
     $output .= wp_audio_shortcode($attr);
     return $output;
 }
开发者ID:TyRichards,项目名称:paradox,代码行数:36,代码来源:template-tags.php

示例8: powerpressplayer_build_mediaelementaudio

function powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData = array(), $embed = false)
{
    if (!function_exists('wp_audio_shortcode')) {
        // Return the HTML5 audio shortcode instead
        return powerpressplayer_build_html5audio($media_url, $EpisodeData, $embed);
    }
    $player_id = powerpressplayer_get_next_id();
    $autoplay = false;
    // Episode Settings
    if (!empty($EpisodeData['autoplay'])) {
        $autoplay = true;
    }
    $content = '';
    $content .= '<div class="powerpress_player" id="powerpress_player_' . $player_id . '">' . PHP_EOL;
    $attr = array('src' => $media_url, 'loop' => '', 'autoplay' => $autoplay ? 'on' : '', 'preload' => 'none');
    $content .= wp_audio_shortcode($attr);
    $content .= '</div>' . PHP_EOL;
    return $content;
}
开发者ID:briancfeeney,项目名称:portigal,代码行数:19,代码来源:powerpress-player.php

示例9: elseif

             break;
     }
 } elseif ('audio' == $media['type']) {
     switch ($media['audio_type']) {
         case 'embed':
             global $wp_embed;
             if (is_a($wp_embed, 'WP_Embed')) {
                 echo $wp_embed->autoembed($media['audio_embed']);
             } else {
                 echo $media['audio_embed'];
             }
             break;
         case 'hosted':
             // Check if the attachment is an audio
             if (0 === strpos(get_post_mime_type($media['audio_src']), 'audio/')) {
                 echo wp_audio_shortcode(array('src' => wp_get_attachment_url($media['audio_src'])));
             }
             break;
     }
 } else {
     $attachments = array();
     foreach ($media['images'] as $image) {
         if ($attachment = wp_get_attachment_image_src($image, 'full')) {
             $attachments[$image] = $attachment;
         }
     }
     switch ($media['type']) {
         case 'slider':
             echo '<div class="royalSlider rsHelium" data-rs-settings="' . esc_attr(helium_rs_settings($media)) . '">';
             foreach ($attachments as $id => $attachment) {
                 echo wp_get_attachment_image($id, 'full', false, array('class' => 'attachment-full rsImg', 'data-rsw' => $attachment[1], 'data-rsh' => $attachment[2]));
开发者ID:yemingyuen,项目名称:mingsg,代码行数:31,代码来源:entry.php

示例10: elseif

        echo "<li><img src='{$item}' alt='' /></li>";
    }
    echo "</ul>";
} elseif ($format === "video" && (array_key_exists('oembed-url', $tpl_default_settings) || array_key_exists('self-hosted-url', $tpl_default_settings))) {
    echo "<div class='dt-video-wrap'>";
    if (array_key_exists("oembed-url", $tpl_default_settings)) {
        echo wp_oembed_get($tpl_default_settings['oembed-url']);
    } elseif (array_key_exists("self-hosted-url", $tpl_default_settings)) {
        echo wp_video_shortcode(array('src' => $post_meta['self-hosted-url']));
    }
    echo "</div>";
} elseif ($format === "audio" && (array_key_exists('oembed-url', $tpl_default_settings) || array_key_exists('self-hosted-url', $tpl_default_settings))) {
    if (array_key_exists("oembed-url", $tpl_default_settings)) {
        echo wp_oembed_get($tpl_default_settings['oembed-url']);
    } elseif (array_key_exists("self-hosted-url", $tpl_default_settings)) {
        echo wp_audio_shortcode(array('src' => $post_meta['self-hosted-url']));
    }
} elseif (!array_key_exists("disable-featured-image", $tpl_default_settings)) {
    ?>
                  	<a href="<?php 
    the_permalink();
    ?>
" title="<?php 
    printf(esc_attr__('%s'), the_title_attribute('echo=0'));
    ?>
"><?php 
    if (has_post_thumbnail()) {
        the_post_thumbnail("full");
    } elseif ($pholder != "on") {
        ?>
                        	<img src="http://placehold.it/1170x822&text=Image" alt="<?php 
开发者ID:enlacee,项目名称:anb.platicom.com.pe,代码行数:31,代码来源:content-single.php

示例11: getIncidentMediaHtml

 /**
  * Gets the correct HTML embeds/elements for a given media type.
  *
  * @param string $type One of 'video', 'audio', or 'image'
  * @param int $post_id The WP post ID of the attachment media.
  *
  * @return string
  */
 private static function getIncidentMediaHtml($type, $post_id)
 {
     $html = '';
     switch ($type) {
         case 'video':
             $html .= wp_video_shortcode(array('src' => wp_get_attachment_url($post_id)));
             break;
         case 'image':
             $html .= '<a href="' . wp_get_attachment_url($post_id) . '" target="_blank">';
             $html .= wp_get_attachment_image($post_id);
             $html .= '</a>';
             break;
         case 'audio':
         default:
             $html .= wp_audio_shortcode(array('src' => wp_get_attachment_url($post_id)));
             break;
     }
     return $html;
 }
开发者ID:anhquan0412,项目名称:better-angels,代码行数:27,代码来源:class-buoy-alert.php

示例12: the_permalink

	<a href="<?php 
the_permalink();
?>
" title="<?php 
the_title_attribute();
?>
">
		<span class="fui-volume"></span> <?php 
the_title();
?>
	</a>
</h2>
<div class="col-sm-4 col-md-2 col-lg-4">
<?php 
$attr = array('src' => $post->guid, 'loop' => 'off', 'preload' => 'metadata');
echo wp_audio_shortcode($attr);
$post_ancestors = get_post_ancestors($post);
foreach ($post_ancestors as $post_ancestor) {
    $ancestor = get_post($post_ancestor);
    _e('From', 'citypress');
    ?>
: <a href="<?php 
    echo get_permalink($post_ancestor);
    ?>
" title="<?php 
    echo apply_filters('the_title_attribute', $ancestor->post_title);
    ?>
">
	<?php 
    echo apply_filters('the_title', $ancestor->post_title);
    ?>
开发者ID:jimmyandrade,项目名称:citypress-council,代码行数:31,代码来源:loop-page-audio.php

示例13: the_post

    the_post();
    $metadata = wp_get_attachment_metadata();
    ?>
				<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_audio_shortcode(array('src' => wp_get_attachment_url()));
    ?>

						<p><strong><?php 
    _e('URL:', 'odin');
    ?>
</strong> <a href="<?php 
    echo esc_url(wp_get_attachment_url());
    ?>
" title="<?php 
    the_title_attribute();
    ?>
" rel="attachment"><span><?php 
    echo esc_attr(basename(wp_get_attachment_url()));
    ?>
</span></a></p>
开发者ID:rodrigo-brito,项目名称:odin,代码行数:31,代码来源:audio.php

示例14: test_wp_audio_shortcode_attributes

 /**
  * @ticket 35367
  */
 function test_wp_audio_shortcode_attributes()
 {
     $actual = wp_audio_shortcode(array('src' => 'https://example.com/foo.mp3'));
     $this->assertContains('src="https://example.com/foo.mp3', $actual);
     $this->assertNotContains('loop', $actual);
     $this->assertNotContains('autoplay', $actual);
     $this->assertContains('preload="none"', $actual);
     $this->assertContains('class="wp-audio-shortcode"', $actual);
     $this->assertContains('style="width: 100%;"', $actual);
     $actual = wp_audio_shortcode(array('src' => 'https://example.com/foo.mp3', 'loop' => true, 'autoplay' => true, 'preload' => true, 'class' => 'foobar', 'style' => 'padding:0;'));
     $this->assertContains('src="https://example.com/foo.mp3', $actual);
     $this->assertContains('loop="1"', $actual);
     $this->assertContains('autoplay="1"', $actual);
     $this->assertContains('preload="1"', $actual);
     $this->assertContains('class="foobar"', $actual);
     $this->assertContains('style="padding:0;"', $actual);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:20,代码来源:media.php

示例15: pods_audio

/**
 * Output an audio field as a video player.
 *
 * @uses wp_audio_shortcode()
 *
 * @since 2.5
 *
 * @param string|array   $url   Can be a URL of the source file, or a Pods audio field.
 * @param bool|array     $args  Optional. Additional arguments to pass to wp_audio_shortcode
 *
 * @return string
 */
function pods_audio($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;
        }
    }
    $audio_args = array('src' => $url);
    if (is_array($args)) {
        $audio_args = array_merge($audio_args, $args);
    }
    return wp_audio_shortcode($args);
}
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:28,代码来源:media.php


注:本文中的wp_audio_shortcode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。