`.
+ * @type string $align Class name that aligns the caption. Default 'alignnone'. Accepts 'alignleft',
+ * 'aligncenter', alignright', 'alignnone'.
+ * @type int $width The width of the caption, in pixels.
+ * @type string $caption The caption text.
+ * @type string $class Additional class name(s) added to the caption container.
* }
* @param string $content Shortcode content.
* @return string HTML content to display the caption.
@@ -1513,7 +1517,7 @@
// New-style shortcode with the caption inside the shortcode with the link and image tags.
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:]+>\s*)?
]+>(?:\s*)?)(.*)#is', $content, $matches ) ) {
- $content = $matches[1];
+ $content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
} elseif ( strpos( $attr['caption'], '<' ) !== false ) {
@@ -1535,23 +1539,45 @@
* @param string $content The image element, possibly wrapped in a hyperlink.
*/
$output = apply_filters( 'img_caption_shortcode', '', $attr, $content );
- if ( $output != '' )
+ if ( $output != '' ) {
return $output;
-
- $atts = shortcode_atts( array(
- 'id' => '',
- 'align' => 'alignnone',
- 'width' => '',
- 'caption' => '',
- 'class' => '',
- ), $attr, 'caption' );
+ }
+
+ $atts = shortcode_atts(
+ array(
+ 'id' => '',
+ 'caption_id' => '',
+ 'align' => 'alignnone',
+ 'width' => '',
+ 'caption' => '',
+ 'class' => '',
+ ),
+ $attr,
+ 'caption'
+ );
$atts['width'] = (int) $atts['width'];
- if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
+ if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) {
return $content;
-
- if ( ! empty( $atts['id'] ) )
- $atts['id'] = 'id="' . esc_attr( sanitize_html_class( $atts['id'] ) ) . '" ';
+ }
+
+ $id = $caption_id = $describedby = '';
+
+ if ( $atts['id'] ) {
+ $atts['id'] = sanitize_html_class( $atts['id'] );
+ $id = 'id="' . esc_attr( $atts['id'] ) . '" ';
+ }
+
+ if ( $atts['caption_id'] ) {
+ $atts['caption_id'] = sanitize_html_class( $atts['caption_id'] );
+ } elseif ( $atts['id'] ) {
+ $atts['caption_id'] = 'caption-' . str_replace( '_', '-', $atts['id'] );
+ }
+
+ if ( $atts['caption_id'] ) {
+ $caption_id = 'id="' . esc_attr( $atts['caption_id'] ) . '" ';
+ $describedby = 'aria-describedby="' . esc_attr( $atts['caption_id'] ) . '" ';
+ }
$class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
@@ -1582,17 +1608,38 @@
}
if ( $html5 ) {
- $html = ''
- . do_shortcode( $content ) . '' . $atts['caption'] . '';
+ $html = sprintf(
+ '%s%s',
+ $id,
+ $describedby,
+ $style,
+ esc_attr( $class ),
+ do_shortcode( $content ),
+ sprintf(
+ '%s',
+ $caption_id,
+ $atts['caption']
+ )
+ );
} else {
- $html = '
";
/**
@@ -1781,7 +1860,7 @@
} else {
$image_output = wp_get_attachment_link( $id, $atts['size'], true, false, false, $attr );
}
- $image_meta = wp_get_attachment_metadata( $id );
+ $image_meta = wp_get_attachment_metadata( $id );
$orientation = '';
if ( isset( $image_meta['height'], $image_meta['width'] ) ) {
@@ -1792,10 +1871,10 @@
<{$icontag} class='gallery-icon {$orientation}'>
$image_output
{$icontag}>";
- if ( $captiontag && trim($attachment->post_excerpt) ) {
+ if ( $captiontag && trim( $attachment->post_excerpt ) ) {
$output .= "
<{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
- " . wptexturize($attachment->post_excerpt) . "
+ " . wptexturize( $attachment->post_excerpt ) . "
{$captiontag}>";
}
$output .= "{$itemtag}>";
@@ -1821,16 +1900,18 @@
* @since 3.9.0
*/
function wp_underscore_playlist_templates() {
-?>
+ ?>
-
-
-
+
+ 'audio',
- 'order' => 'ASC',
- 'orderby' => 'menu_order ID',
- 'id' => $post ? $post->ID : 0,
- 'include' => '',
- 'exclude' => '',
- 'style' => 'light',
- 'tracklist' => true,
- 'tracknumbers' => true,
- 'images' => true,
- 'artists' => true
- ), $attr, 'playlist' );
+ $atts = shortcode_atts(
+ array(
+ 'type' => 'audio',
+ 'order' => 'ASC',
+ 'orderby' => 'menu_order ID',
+ 'id' => $post ? $post->ID : 0,
+ 'include' => '',
+ 'exclude' => '',
+ 'style' => 'light',
+ 'tracklist' => true,
+ 'tracknumbers' => true,
+ 'images' => true,
+ 'artists' => true,
+ ),
+ $attr,
+ 'playlist'
+ );
$id = intval( $atts['id'] );
@@ -1967,28 +2054,28 @@
}
$args = array(
- 'post_status' => 'inherit',
- 'post_type' => 'attachment',
+ 'post_status' => 'inherit',
+ 'post_type' => 'attachment',
'post_mime_type' => $atts['type'],
- 'order' => $atts['order'],
- 'orderby' => $atts['orderby']
+ 'order' => $atts['order'],
+ 'orderby' => $atts['orderby'],
);
if ( ! empty( $atts['include'] ) ) {
$args['include'] = $atts['include'];
- $_attachments = get_posts( $args );
+ $_attachments = get_posts( $args );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
- $attachments[$val->ID] = $_attachments[$key];
+ $attachments[ $val->ID ] = $_attachments[ $key ];
}
} elseif ( ! empty( $atts['exclude'] ) ) {
$args['post_parent'] = $id;
- $args['exclude'] = $atts['exclude'];
- $attachments = get_children( $args );
+ $args['exclude'] = $atts['exclude'];
+ $attachments = get_children( $args );
} else {
$args['post_parent'] = $id;
- $attachments = get_children( $args );
+ $attachments = get_children( $args );
}
if ( empty( $attachments ) ) {
@@ -2005,35 +2092,35 @@
$outer = 22; // default padding and border of wrapper
- $default_width = 640;
+ $default_width = 640;
$default_height = 360;
- $theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer );
+ $theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer );
$theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width );
$data = array(
- 'type' => $atts['type'],
+ 'type' => $atts['type'],
// don't pass strings to JSON, will be truthy in JS
- 'tracklist' => wp_validate_boolean( $atts['tracklist'] ),
+ 'tracklist' => wp_validate_boolean( $atts['tracklist'] ),
'tracknumbers' => wp_validate_boolean( $atts['tracknumbers'] ),
- 'images' => wp_validate_boolean( $atts['images'] ),
- 'artists' => wp_validate_boolean( $atts['artists'] ),
+ 'images' => wp_validate_boolean( $atts['images'] ),
+ 'artists' => wp_validate_boolean( $atts['artists'] ),
);
$tracks = array();
foreach ( $attachments as $attachment ) {
- $url = wp_get_attachment_url( $attachment->ID );
+ $url = wp_get_attachment_url( $attachment->ID );
$ftype = wp_check_filetype( $url, wp_get_mime_types() );
$track = array(
- 'src' => $url,
- 'type' => $ftype['type'],
- 'title' => $attachment->post_title,
- 'caption' => $attachment->post_excerpt,
- 'description' => $attachment->post_content
+ 'src' => $url,
+ 'type' => $ftype['type'],
+ 'title' => $attachment->post_title,
+ 'caption' => $attachment->post_excerpt,
+ 'description' => $attachment->post_content,
);
$track['meta'] = array();
- $meta = wp_get_attachment_metadata( $attachment->ID );
+ $meta = wp_get_attachment_metadata( $attachment->ID );
if ( ! empty( $meta ) ) {
foreach ( wp_get_attachment_id3_keys( $attachment ) as $key => $label ) {
@@ -2044,20 +2131,20 @@
if ( 'video' === $atts['type'] ) {
if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
- $width = $meta['width'];
- $height = $meta['height'];
+ $width = $meta['width'];
+ $height = $meta['height'];
$theme_height = round( ( $height * $theme_width ) / $width );
} else {
- $width = $default_width;
+ $width = $default_width;
$height = $default_height;
}
$track['dimensions'] = array(
'original' => compact( 'width', 'height' ),
- 'resized' => array(
- 'width' => $theme_width,
- 'height' => $theme_height
- )
+ 'resized' => array(
+ 'width' => $theme_width,
+ 'height' => $theme_height,
+ ),
);
}
}
@@ -2066,13 +2153,13 @@
$thumb_id = get_post_thumbnail_id( $attachment->ID );
if ( ! empty( $thumb_id ) ) {
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' );
- $track['image'] = compact( 'src', 'width', 'height' );
+ $track['image'] = compact( 'src', 'width', 'height' );
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
- $track['thumb'] = compact( 'src', 'width', 'height' );
+ $track['thumb'] = compact( 'src', 'width', 'height' );
} else {
- $src = wp_mime_type_icon( $attachment->ID );
- $width = 48;
- $height = 64;
+ $src = wp_mime_type_icon( $attachment->ID );
+ $width = 48;
+ $height = 64;
$track['image'] = compact( 'src', 'width', 'height' );
$track['thumb'] = compact( 'src', 'width', 'height' );
}
@@ -2082,7 +2169,7 @@
}
$data['tracks'] = $tracks;
- $safe_type = esc_attr( $atts['type'] );
+ $safe_type = esc_attr( $atts['type'] );
$safe_style = esc_attr( $atts['style'] );
ob_start();
@@ -2097,26 +2184,35 @@
* @param string $style The 'theme' for the playlist. Core provides 'light' and 'dark'.
*/
do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] );
- } ?>
-
-
+ }
+ ?>
+
+
- < controls="controls" preload="none" width="" controls="controls" preload="none" width="
+
+ "
+ >>
+ endif;
+ ?>
+ >>
-
+
__( 'Artist' ),
- 'album' => __( 'Album' ),
+ 'album' => __( 'Album' ),
);
if ( 'display' === $context ) {
@@ -2182,8 +2278,8 @@
$fields['year'] = __( 'Year' );
$fields['length_formatted'] = _x( 'Length', 'video or audio' );
} elseif ( 'js' === $context ) {
- $fields['bitrate'] = __( 'Bitrate' );
- $fields['bitrate_mode'] = __( 'Bitrate Mode' );
+ $fields['bitrate'] = __( 'Bitrate' );
+ $fields['bitrate_mode'] = __( 'Bitrate Mode' );
}
/**
@@ -2252,10 +2348,10 @@
'autoplay' => '',
'preload' => 'none',
'class' => 'wp-audio-shortcode',
- 'style' => 'width: 100%;'
+ 'style' => 'width: 100%;',
);
foreach ( $default_types as $type ) {
- $defaults_atts[$type] = '';
+ $defaults_atts[ $type ] = '';
}
$atts = shortcode_atts( $defaults_atts, $attr, 'audio' );
@@ -2285,7 +2381,7 @@
return;
}
- $audio = reset( $audios );
+ $audio = reset( $audios );
$atts['src'] = wp_get_attachment_url( $audio->ID );
if ( empty( $atts['src'] ) ) {
return;
@@ -2329,8 +2425,8 @@
// These ones should just be omitted altogether if they are blank
foreach ( array( 'loop', 'autoplay', 'preload' ) as $a ) {
- if ( empty( $html_atts[$a] ) ) {
- unset( $html_atts[$a] );
+ if ( empty( $html_atts[ $a ] ) ) {
+ unset( $html_atts[ $a ] );
}
}
@@ -2346,14 +2442,14 @@
$html .= sprintf( '