Make WordPress Core

Ticket #23965: 23965.3.diff

File 23965.3.diff, 2.7 KB (added by wonderboymusic, 12 years ago)
  • wp-includes/functions.php

    diff --git wp-includes/functions.php wp-includes/functions.php
    index 0afa50b..8d3653e 100644
    function wp_auth_check( $response, $data ) { 
    39853985function get_tag_regex( $tag ) {
    39863986        if ( empty( $tag ) )
    39873987                return;
    3988 
    3989         return sprintf( '(<%1$s[^>]*(?:/?>$|>[\s\S]*?</%1$s>))', tag_escape( $tag ) );
     3988        return sprintf( '(<%1$s[^>]*(?:/?>\s*$|>[\s\S]*?</%1$s>))', tag_escape( $tag ) );
    39903989}
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index bd52867..fbb3b53 100644
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24002400        if ( isset( $post->format_content ) )
    24012401                return $post->format_content;
    24022402
     2403        $matched = false;
    24032404        $meta = get_post_format_meta( $post->ID );
    24042405
    24052406        $link_fmt = '%s';
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24262427                $sizes = get_intermediate_image_sizes();
    24272428                $sizes[] = 'full'; // Add original image source.
    24282429
    2429                 $urls = array();
     2430                $urls = array( get_attachment_link( $media->ID ) );
    24302431                foreach ( $sizes as $size ) {
    24312432                        $image = wp_get_attachment_image_src( $media->ID, $size );
    24322433                        if ( $image )
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24442445                        foreach ( $matches as $shortcode ) {
    24452446                                if ( 'caption' === $shortcode[2] ) {
    24462447                                        foreach ( $urls as $url ) {
    2447                                                 if ( strstr( $shortcode[0], $url ) )
     2448                                                if ( strstr( $shortcode[0], $url ) ) {
     2449                                                        if ( ! $matched )
     2450                                                                $matched = do_shortcode( $shortcode[0] );
    24482451                                                        $content = str_replace( $shortcode[0], '', $content, $count );
     2452                                                }
    24492453                                        }
    24502454                                }
    24512455                        }
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24552459                        if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
    24562460                                foreach ( $matches as $match ) {
    24572461                                        foreach ( $urls as $url ) {
    2458                                                 if ( strstr( $match[0], $url ) )
     2462                                                if ( strstr( $match[0], $url ) ) {
     2463                                                        if ( ! $matched )
     2464                                                                $matched = $match[0];
    24592465                                                        $content = str_replace( $match[0], '', $content, $count );
     2466                                                }
    24602467                                        }
    24612468                                }
    24622469                        }
    24632470                }
    24642471
    24652472                $post->split_content = $content;
    2466                 $image = wp_get_attachment_image( $media->ID, $attached_size );
    2467                 $post->format_content = sprintf( $link_fmt, $image );
     2473                if ( ! $matched ) {
     2474                        $image = wp_get_attachment_image( $media->ID, $attached_size );
     2475                        $post->format_content = sprintf( $link_fmt, $image );
     2476                } else {
     2477                        $post->format_content = $matched;
     2478                        if ( ! empty( $meta['url'] ) && false === stripos( $matched, '<a ' ) )
     2479                                $post->format_content = sprintf( $link_fmt, $matched );
     2480                }
    24682481                return $post->format_content;
    24692482        }
    24702483