Make WordPress Core

Ticket #23965: 23965.2.diff

File 23965.2.diff, 3.6 KB (added by wonderboymusic, 12 years ago)
  • wp-admin/js/post-formats.js

    diff --git wp-admin/js/post-formats.js wp-admin/js/post-formats.js
    index 4456c85..73af601 100644
    window.wp = window.wp || {}; 
    1717                        description = $('.post-format-description'),
    1818                        postTitle = $('#title');
    1919
    20                 if ( typeof container === 'undefined' )
    21                         container = $('#post-body-content');
     20                        if ( typeof container === 'undefined' )
     21                                container = $('#post-body-content');
    2222
    2323                parent.slideUp().find('a.active').removeClass('active');
    2424                $this.addClass('active');
    window.wp = window.wp || {}; 
    7777                // Media selection
    7878                $('.wp-format-media-select').click(function (event) {
    7979                        event.preventDefault();
    80                         var $el = $(this), mime,
     80                        var $el = $(this), mime = 'image',
    8181                            $holder = $el.closest('.wp-format-media-holder'),
    8282                            $field = $( '#wp_format_' + $holder.data('format') );
    8383
  • 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 6ef945b..04e5f56 100644
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    23992399        if ( isset( $post->format_content ) )
    24002400                return $post->format_content;
    24012401
     2402        $matched = false;
    24022403        $meta = get_post_format_meta( $post->ID );
    24032404
    24042405        $link_fmt = '%s';
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24252426                $sizes = get_intermediate_image_sizes();
    24262427                $sizes[] = 'full'; // Add original image source.
    24272428
    2428                 $urls = array();
     2429                $urls = array( get_attachment_link( $media->ID ) );
    24292430                foreach ( $sizes as $size ) {
    24302431                        $image = wp_get_attachment_image_src( $media->ID, $size );
    24312432                        if ( $image )
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24432444                        foreach ( $matches as $shortcode ) {
    24442445                                if ( 'caption' === $shortcode[2] ) {
    24452446                                        foreach ( $urls as $url ) {
    2446                                                 if ( strstr( $shortcode[0], $url ) )
     2447                                                if ( strstr( $shortcode[0], $url ) ) {
     2448                                                        if ( ! $matched )
     2449                                                                $matched = do_shortcode( $shortcode[0] );
    24472450                                                        $content = str_replace( $shortcode[0], '', $content, $count );
     2451                                                }
    24482452                                        }
    24492453                                }
    24502454                        }
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24542458                        if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
    24552459                                foreach ( $matches as $match ) {
    24562460                                        foreach ( $urls as $url ) {
    2457                                                 if ( strstr( $match[0], $url ) )
     2461                                                if ( strstr( $match[0], $url ) ) {
     2462                                                        if ( ! $matched )
     2463                                                                $matched = $match[0];
    24582464                                                        $content = str_replace( $match[0], '', $content, $count );
     2465                                                }
    24592466                                        }
    24602467                                }
    24612468                        }
    24622469                }
    24632470
    24642471                $post->split_content = $content;
    2465                 $image = wp_get_attachment_image( $media->ID, $attached_size );
    2466                 $post->format_content = sprintf( $link_fmt, $image );
     2472                if ( ! $matched ) {
     2473                        $image = wp_get_attachment_image( $media->ID, $attached_size );
     2474                        $post->format_content = sprintf( $link_fmt, $image );
     2475                } else {
     2476                        $post->format_content = $matched;
     2477                        if ( ! empty( $meta['url'] ) && false === stripos( $matched, '<a ' ) )
     2478                                $post->format_content = sprintf( $link_fmt, $matched );
     2479                }
    24672480                return $post->format_content;
    24682481        }
    24692482