Call shortcode functions directly. props kovshenin, fixes #24505.

git-svn-id: https://develop.svn.wordpress.org/trunk@24547 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-07-03 20:19:00 +00:00
parent 8ceb51f88e
commit 58b96f9dd5
2 changed files with 32 additions and 12 deletions

View File

@ -2357,7 +2357,7 @@ function edit_form_image_editor( $post ) {
<?php <?php
elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/' ) ): elseif ( $attachment_id && 0 === strpos( $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/' ) ): 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'] ) if ( $h && $w < $meta['width'] )
$h = round( ( $meta['height'] * $w ) / $meta['width'] ); $h = round( ( $meta['height'] * $w ) / $meta['width'] );
$shortcode = sprintf( '[video src="%s"%s%s]', $attr = array( 'src' => $att_url );
$att_url,
empty( $meta['width'] ) ? '' : sprintf( ' width="%d"', $w ), if ( ! empty( $meta['width' ] ) )
empty( $meta['height'] ) ? '' : sprintf( ' height="%d"', $h ) $attr['width'] = $w;
);
echo do_shortcode( $shortcode ); if ( ! empty( $meta['height'] ) )
$attr['height'] = $h;
echo wp_video_shortcode( $attr );
endif; ?> endif; ?>
</div> </div>

View File

@ -2070,7 +2070,16 @@ function get_the_post_format_media( $type, &$post = null, $limit = 0 ) {
$embed = reset( $embeds ); $embed = reset( $embeds );
if ( 0 === strpos( $embed, 'http' ) ) { if ( 0 === strpos( $embed, 'http' ) ) {
if ( strstr( $embed, home_url() ) ) { 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 { } else {
$post->format_content[ $cache_key ] = $wp_embed->autoembed( $embed ); $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 ) ) { if ( ! empty( $medias ) ) {
$media = reset( $medias ); $media = reset( $medias );
$url = wp_get_attachment_url( $media->ID ); $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 ]; return $post->format_content[ $cache_key ];
} }
@ -2164,7 +2181,7 @@ function get_content_images( $content, $html = true, $limit = 0 ) {
if ( 'caption' === $shortcode[2] ) { if ( 'caption' === $shortcode[2] ) {
$captions[] = $shortcode[0]; $captions[] = $shortcode[0];
if ( $html ) if ( $html )
$tags[] = do_shortcode( $shortcode[0] ); $tags[] = do_shortcode_tag( $shortcode );
} }
if ( $limit > 0 && count( $tags ) >= $limit ) 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 ) { foreach ( $urls as $url ) {
if ( strstr( $shortcode[0], $url ) ) { if ( strstr( $shortcode[0], $url ) ) {
if ( ! $matched ) if ( ! $matched )
$matched = do_shortcode( $shortcode[0] ); $matched = do_shortcode_tag( $shortcode );
// $content = str_replace( $shortcode[0], '', $content, $count ); // $content = str_replace( $shortcode[0], '', $content, $count );
} }
} }