diff --git wp-includes/media.php wp-includes/media.php
index 9b5d6a8..f5c0d68 100644
--- wp-includes/media.php
+++ wp-includes/media.php
@@ -839,41 +839,46 @@ function wp_get_audio_extensions() {
/**
* The Audio shortcode.
*
* This implements the functionality of the Audio Shortcode for displaying
* WordPress mp3s in a post.
*
* @since 3.6.0
*
* @param array $attr Attributes of the shortcode.
* @return string HTML content to display audio.
*/
function wp_audio_shortcode( $attr ) {
$post_id = get_post() ? get_the_ID() : 0;
static $instances = 0;
$instances++;
$audio = null;
$default_types = wp_get_audio_extensions();
- $defaults_atts = array( 'src' => '' );
+ $defaults_atts = array(
+ 'src' => '',
+ 'loop' => '',
+ 'autoplay' => '',
+ 'preload' => 'none'
+ );
foreach ( $default_types as $type )
$defaults_atts[$type] = '';
$atts = shortcode_atts( $defaults_atts, $attr, 'audio' );
extract( $atts );
$primary = false;
if ( ! empty( $src ) ) {
$type = wp_check_filetype( $src );
if ( ! in_array( $type['ext'], $default_types ) )
return sprintf( '%s', esc_url( $src ), esc_html( $src ) );
$primary = true;
array_unshift( $default_types, 'src' );
} else {
foreach ( $default_types as $ext ) {
if ( ! empty( $$ext ) ) {
$type = wp_check_filetype( $$ext );
if ( $type['ext'] === $ext )
$primary = true;
}
@@ -883,45 +888,59 @@ function wp_audio_shortcode( $attr ) {
if ( ! $primary ) {
$audios = get_attached_media( 'audio', $post_id );
if ( empty( $audios ) )
return;
$audio = reset( $audios );
$src = wp_get_attachment_url( $audio->ID );
if ( empty( $src ) )
return;
array_unshift( $default_types, 'src' );
}
$library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' );
if ( 'mediaelement' === $library && did_action( 'init' ) ) {
wp_enqueue_style( 'wp-mediaelement' );
wp_enqueue_script( 'wp-mediaelement' );
}
$atts = array(
- sprintf( 'class="%s"', apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ) ),
- sprintf( 'id="audio-%d-%d"', $post_id, $instances ),
+ 'class' => apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ),
+ 'id' => sprintf( 'audio-%d-%d', $post_id, $instances ),
+ 'loop' => $loop,
+ 'autoplay' => $autoplay,
+ 'preload' => $preload,
);
- $html = sprintf( '