Make WordPress Core

Ticket #23965: 23965.diff

File 23965.diff, 6.1 KB (added by wonderboymusic, 12 years ago)
  • wp-admin/includes/post-formats.php

    diff --git wp-admin/includes/post-formats.php wp-admin/includes/post-formats.php
    index 0364f5d..9524a75 100644
    $format_meta = get_post_format_meta( $post_ID ); 
    7676                                _e( 'Video URL' );
    7777                ?></label>
    7878                <textarea id="wp_format_video" type="text" name="_wp_format_video" class="widefat"><?php esc_html_e( $format_meta['video'] ); ?></textarea>
    79                 <div data-format="video" class="wp-format-media-holder hide-if-no-js<?php if ( ! $image ) echo ' empty'; ?>">
     79                <div data-format="video" class="wp-format-media-holder hide-if-no-js<?php if ( ! $show_video_preview ) echo ' empty'; ?>">
    8080                        <a href="#" class="wp-format-media-select"
    8181                                data-choose="<?php esc_attr_e( 'Choose a Video' ); ?>"
    8282                                data-update="<?php esc_attr_e( 'Select Video' ); ?>">
    $format_meta = get_post_format_meta( $post_ID ); 
    114114                        else
    115115                                _e( 'Audio URL' );
    116116                ?></label>
    117                 <textarea id="wp_format_audio" name="_wp_format_audio" class="widefat"><?php esc_html_e( $format_meta['audio'] );
    118 ?></textarea>
    119                 <div data-format="audio" class="wp-format-media-holder hide-if-no-js<?php if ( empty( $format_meta['audio'] ) ) echo ' empty'; ?>">
     117                <textarea id="wp_format_audio" name="_wp_format_audio" class="widefat"><?php esc_html_e( $format_meta['audio'] ); ?></textarea>
     118                <div data-format="audio" class="wp-format-media-holder hide-if-no-js<?php if ( ! $show_audio_preview ) echo ' empty'; ?>">
    120119                        <a href="#" class="wp-format-media-select" data-choose="<?php esc_attr_e( 'Choose Audio' ); ?>" data-update="<?php esc_attr_e( 'Select Audio' ); ?>">
    121120                                <?php _e( 'Select Audio From Media Library' ) ?>
    122121                        </a>
  • wp-admin/js/post-formats.js

    diff --git wp-admin/js/post-formats.js wp-admin/js/post-formats.js
    index 62c75f6..589bfba 100644
    window.wp = window.wp || {}; 
    1919                                format = $this.data('wp-format'),
    2020                                description = $('.post-format-description');
    2121
    22                 if ( typeof container === 'undefined' )
    23                         container = $('#post-body-content');
     22                        if ( typeof container === 'undefined' )
     23                                container = $('#post-body-content');
    2424
    2525                        // Already on this post format. Bail.
    2626                        if ( format === postFormats.currentPostFormat )
    window.wp = window.wp || {}; 
    6868                // Media selection
    6969                $('.wp-format-media-select').click(function (event) {
    7070                        event.preventDefault();
    71                         var $el = $(this), $holder, $field, mime = 'image', menu = '',
     71                        var $el = $(this), $holder, $field, mime = 'image',
    7272                            $holder = $el.closest('.wp-format-media-holder'),
    7373                            $field = $( '#wp_format_' + $holder.data('format') );
    7474
    window.wp = window.wp || {}; 
    8282                        }
    8383
    8484                        // If the media frame already exists, reopen it.
    85                         if ( mediaFrame && lastMimeType === mime && lastMenu === menu ) {
     85                        if ( mediaFrame && lastMimeType === mime ) {
    8686                                mediaFrame.open();
    8787                                return;
    8888                        }
    8989
    9090                        lastMimeType = mime;
    91                         lastMenu = menu;
    9291
    9392                        // Create the media frame.
    9493                        mediaFrame = wp.media.frames.formatMedia = wp.media({
    9594                                // Set the title of the modal.
    9695                                title: $el.data('choose'),
    9796
    98                                 // Set the menu sidebar of the modal, if applicable
    99                                 toolbar: menu,
    100 
    10197                                // Tell the modal to show only items matching the current mime type.
    10298                                library: {
    10399                                        type: mime
  • 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 25fa507..c3cd50d 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 ) { 
    24152416                $media = reset( $medias );
    24162417                $sizes = get_intermediate_image_sizes();
    24172418
    2418                 $urls = array();
     2419                $urls = array( get_attachment_link( $media->ID ) );
    24192420                foreach ( $sizes as $size ) {
    24202421                        $image = wp_get_attachment_image_src( $media->ID, $size );
    2421                         if ( $image ) {
     2422                        if ( $image )
    24222423                                $urls[] = reset( $image );
    2423                                 $urls[] = get_attachment_link( $media->ID );
    2424                         }
    24252424                }
    24262425
    24272426                $count = 1;
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24322431                        foreach ( $matches as $shortcode ) {
    24332432                                if ( 'caption' === $shortcode[2] ) {
    24342433                                        foreach ( $urls as $url ) {
    2435                                                 if ( strstr( $shortcode[0], $url ) )
     2434                                                if ( strstr( $shortcode[0], $url ) ) {
     2435                                                        if ( ! $matched )
     2436                                                                $matched = do_shortcode( $shortcode[0] );
    24362437                                                        $content = str_replace( $shortcode[0], '', $content, $count );
     2438                                                }
    24372439                                        }
    24382440                                }
    24392441                        }
    function get_the_post_format_image( $attached_size = 'full', &$post = null ) { 
    24432445                        if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) {
    24442446                                foreach ( $matches as $match ) {
    24452447                                        foreach ( $urls as $url ) {
    2446                                                 if ( strstr( $match[0], $url ) )
     2448                                                if ( strstr( $match[0], $url ) ) {
     2449                                                        if ( ! $matched )
     2450                                                                $matched = $match[0];
    24472451                                                        $content = str_replace( $match[0], '', $content, $count );
     2452                                                }
    24482453                                        }
    24492454                                }
    24502455                        }
    24512456                }
    24522457
    24532458                $post->split_content = $content;
    2454                 $image = wp_get_attachment_image( $media->ID, $attached_size );
    2455                 $post->format_content = sprintf( $link_fmt, $image );
     2459                if ( ! $matched ) {
     2460                        $image = wp_get_attachment_image( $media->ID, $attached_size );
     2461                        $post->format_content = sprintf( $link_fmt, $image );
     2462                } else {
     2463                        $post->format_content = $matched;
     2464                        if ( ! empty( $meta['url'] ) && false === stripos( $matched, '<a ' ) )
     2465                                $post->format_content = sprintf( $link_fmt, $matched );
     2466                }
    24562467                return $post->format_content;
    24572468        }
    24582469