From 58b96f9dd52f693c61543b28ff11e41d00e296e4 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 3 Jul 2013 20:19:00 +0000 Subject: [PATCH] Call shortcode functions directly. props kovshenin, fixes #24505. git-svn-id: https://develop.svn.wordpress.org/trunk@24547 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 17 ++++++++++------- wp-includes/media.php | 27 ++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index aa1b21de36..2977bdff13 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -2357,7 +2357,7 @@ function edit_form_image_editor( $post ) { post_mime_type, 'audio/' ) ): - echo do_shortcode( '[audio src="' . $att_url . '"]' ); + echo wp_audio_shortcode( array( 'src' => $att_url ) ); elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ): @@ -2369,12 +2369,15 @@ function edit_form_image_editor( $post ) { if ( $h && $w < $meta['width'] ) $h = round( ( $meta['height'] * $w ) / $meta['width'] ); - $shortcode = sprintf( '[video src="%s"%s%s]', - $att_url, - empty( $meta['width'] ) ? '' : sprintf( ' width="%d"', $w ), - empty( $meta['height'] ) ? '' : sprintf( ' height="%d"', $h ) - ); - echo do_shortcode( $shortcode ); + $attr = array( 'src' => $att_url ); + + if ( ! empty( $meta['width' ] ) ) + $attr['width'] = $w; + + if ( ! empty( $meta['height'] ) ) + $attr['height'] = $h; + + echo wp_video_shortcode( $attr ); endif; ?> diff --git a/wp-includes/media.php b/wp-includes/media.php index e63e5bb421..50ef8c5e87 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -2070,7 +2070,16 @@ function get_the_post_format_media( $type, &$post = null, $limit = 0 ) { $embed = reset( $embeds ); if ( 0 === strpos( $embed, 'http' ) ) { if ( strstr( $embed, home_url() ) ) { - $post->format_content[ $cache_key ] = do_shortcode( sprintf( '[%s src="%s"]', $type, $embed ) ); + + $format_content = ''; + $attr = array( 'src' => $embed ); + + if ( 'audio' == $type ) + $format_content = wp_audio_shortcode( $attr ); + elseif ( 'video' == $type ) + $format_content = wp_video_shortcode( $attr ); + + $post->format_content[ $cache_key ] = $format_content; } else { $post->format_content[ $cache_key ] = $wp_embed->autoembed( $embed ); } @@ -2084,8 +2093,16 @@ function get_the_post_format_media( $type, &$post = null, $limit = 0 ) { if ( ! empty( $medias ) ) { $media = reset( $medias ); $url = wp_get_attachment_url( $media->ID ); - $shortcode = sprintf( '[%s src="%s"]', $type, $url ); - $post->format_content[ $cache_key ] = do_shortcode( $shortcode ); + + $format_content = ''; + $attr = array( 'src' => $url ); + + if ( 'audio' == $type ) + $format_content = wp_audio_shortcode( $attr ); + elseif ( 'video' == $type ) + $format_content = wp_video_shortcode( $attr ); + + $post->format_content[ $cache_key ] = $format_content; return $post->format_content[ $cache_key ]; } @@ -2164,7 +2181,7 @@ function get_content_images( $content, $html = true, $limit = 0 ) { if ( 'caption' === $shortcode[2] ) { $captions[] = $shortcode[0]; if ( $html ) - $tags[] = do_shortcode( $shortcode[0] ); + $tags[] = do_shortcode_tag( $shortcode ); } if ( $limit > 0 && count( $tags ) >= $limit ) @@ -2410,7 +2427,7 @@ function get_the_post_format_image( $attached_size = 'full', &$post = null ) { foreach ( $urls as $url ) { if ( strstr( $shortcode[0], $url ) ) { if ( ! $matched ) - $matched = do_shortcode( $shortcode[0] ); + $matched = do_shortcode_tag( $shortcode ); // $content = str_replace( $shortcode[0], '', $content, $count ); } }