WordPress.org

Make WordPress Core

Ticket #24009: 24009.6.diff

File 24009.6.diff, 6.5 KB (added by markjaquith, 5 years ago)
  • wp-admin/edit-form-advanced.php

    if ( post_type_supports( $post_type, 'post-formats' ) && apply_filters( 'show_po 
    172172                        'description' => __( 'Use the editor to compose a status update. What’s new?' )
    173173                ),
    174174                'quote' => array (
    175                         'description' => __( 'Copy a quotation into the box below. Add a source and URL if you have them.' )
     175                        'description' => __( 'Add a source and URL if you have them. Use the editor to compose the quote.' )
    176176                ),
    177177                'aside' => array (
    178178                        'description' => __( 'Use the editor to share a quick thought or side topic.' )
  • wp-admin/includes/post-formats.php

    $format_meta = get_post_format_meta( $post_ID ); 
    1010        <input type="hidden" name="post_format" id="post_format" value="<?php echo esc_attr( $post_format ); ?>" />
    1111
    1212        <div class="field wp-format-quote">
    13                 <label for="wp_format_quote"><?php _e( 'Quote' ); ?></label>
    14                 <textarea id="wp_format_quote" name="_format_quote" class="widefat"><?php echo esc_textarea( $format_meta['quote'] ); ?></textarea>
    15         </div>
    16 
    17         <div class="field wp-format-quote">
    1813                <label for="wp_format_quote_source"><?php _e( 'Quote source' ); ?></label>
    1914                <input type="text" id="wp_format_quote_source" name="_format_quote_source_name" value="<?php echo esc_attr( $format_meta['quote_source_name'] ); ?>" class="widefat" />
    2015        </div>
  • wp-includes/post-formats.php

    function post_formats_compat( $content, $id = 0 ) { 
    399399                        break;
    400400
    401401                case 'quote':
    402                         if ( ! empty( $meta['quote'] ) && ! stristr( $content, $meta['quote'] ) ) {
    403                                 $quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $meta['quote'] ) );
    404                                 if ( ! empty( $meta['quote_source_name'] ) ) {
    405                                         $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] );
    406                                         $quote .= sprintf( '<figcaption class="quote-caption">%s</figcaption>', $source );
    407                                 }
    408                                 $format_output .= sprintf( '<figure class="quote">%s</figure>', $quote );
    409                         }
     402                        $quote = get_the_post_format_quote( $post );
     403
     404                        // Replace the existing quote in-place.
     405                        if ( ! empty( $quote ) )
     406                                get_content_quote( $content, true, $quote );
    410407                        break;
    411408
    412409                case 'video':
    function the_post_format_chat() { 
    680677}
    681678
    682679/**
     680 * Get the first <blockquote> from the $content string passed by reference.
     681 *
     682 * If $content does not have a blockquote, assume the whole string
     683 * is the quote.
     684 *
     685 * @since 3.6.0
     686 *
     687 * @param string $content A string which might contain chat data, passed by reference.
     688 * @param bool $remove (optional) Whether to remove the quote from the content.
     689 * @param string $replace (optional) Content to replace the quote content with if $remove is set to true.
     690 * @return string The quote content.
     691 */
     692function get_content_quote( &$content, $remove = false, $replace = '' ) {
     693        if ( empty( $content ) )
     694                return '';
     695
     696        $matches = array();
     697        if ( ! preg_match( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', $content, $matches ) ) {
     698                $quote = $content;
     699                if ( $remove || ! empty( $replace ) )
     700                        $content = $replace;
     701                return $quote;
     702        }
     703
     704        if ( $remove || ! empty( $replace ) )
     705                $content = preg_replace( '/<blockquote[^>]*>(.+?)<\/blockquote>/is', addcslashes( $replace, '\\$' ), $content, 1 );
     706
     707        return $matches[1];
     708}
     709
     710/**
     711 * Get a quote from the post content and set split_content for future use.
     712 *
     713 * @since 3.6.0
     714 *
     715 * @uses get_content_quote()
     716 *
     717 * @param object $post (optional) A reference to the post object, falls back to get_post().
     718 * @return string The quote html.
     719 */
     720function get_the_post_format_quote( &$post = null ) {
     721        if ( empty( $post ) )
     722                $post = get_post();
     723
     724        if ( empty( $post ) )
     725                return '';
     726
     727        $content = $post->post_content;
     728        $quote = get_content_quote( $content, true );
     729        $post->split_content = $content;
     730
     731        if ( ! empty( $quote ) )
     732                $quote = sprintf( '<blockquote>%s</blockquote>', wpautop( $quote ) );
     733
     734        $meta = get_post_format_meta( $post->ID );
     735
     736        if ( ! empty( $meta['quote_source_name'] ) ) {
     737                $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '<a href="%s">%s</a>', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] );
     738                $quote .= sprintf( '<figcaption class="quote-caption">%s</figcaption>', $source );
     739        }
     740
     741        if ( ! empty( $quote ) )
     742                $quote = sprintf( '<figure class="quote">%s</figure>', $quote );
     743
     744        return $quote;
     745}
     746
     747/**
     748 * Outputs the post format quote.
     749 *
     750 * @since 3.6.0
     751 */
     752function the_post_format_quote() {
     753        echo get_the_post_format_quote();
     754}
     755
     756/**
    683757 * Extract a URL from passed content, if possible
    684758 * Checks for a URL on the first line of the content or the first encountered href attribute.
    685759 *
  • wp-includes/query.php

    function setup_postdata($post) { 
    36943694                $more = 1;
    36953695        $split_content = $content = $post->post_content;
    36963696        $format = get_post_format( $post );
    3697         if ( $format && in_array( $format, array( 'image', 'audio', 'video' ) ) ) {
     3697        if ( $format && in_array( $format, array( 'image', 'audio', 'video', 'quote' ) ) ) {
    36983698                switch ( $format ) {
    36993699                case 'image':
    37003700                        get_the_post_format_image( 'full', $post );
    function setup_postdata($post) { 
    37113711                        if ( isset( $post->split_content ) )
    37123712                                $split_content = $post->split_content;
    37133713                        break;
     3714                case 'quote':
     3715                        get_the_post_format_quote( $post );
     3716                        if ( isset( $post->split_content ) )
     3717                                $split_content = $post->split_content;
     3718                        break;
    37143719                }
    37153720        }
    37163721
  • wp-includes/revision.php

    function _wp_post_revision_meta_keys() { 
    7272                '_format_link_url',
    7373                '_format_quote_source_url',
    7474                '_format_quote_source_name',
    75                 '_format_quote',
    7675                '_format_image',
    7776                '_format_gallery',
    7877                '_format_audio_embed',