diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 533880419e..4a9ac7b2da 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -172,7 +172,7 @@ if ( post_type_supports( $post_type, 'post-formats' ) && apply_filters( 'show_po 'description' => __( 'Use the editor to compose a status update. What’s new?' ) ), 'quote' => array ( - 'description' => __( 'Copy a quotation into the box below. Add a source and URL if you have them.' ) + 'description' => __( 'Add a source and URL if you have them. Use the editor to compose the quote.' ) ), 'aside' => array ( 'description' => __( 'Use the editor to share a quick thought or side topic.' ) diff --git a/wp-admin/includes/post-formats.php b/wp-admin/includes/post-formats.php index 630444689d..ac4c749fc3 100644 --- a/wp-admin/includes/post-formats.php +++ b/wp-admin/includes/post-formats.php @@ -9,11 +9,6 @@ $format_meta = get_post_format_meta( $post_ID ); -
- - -
-
diff --git a/wp-includes/post-formats.php b/wp-includes/post-formats.php index ff59b65031..7039c3d209 100644 --- a/wp-includes/post-formats.php +++ b/wp-includes/post-formats.php @@ -399,14 +399,11 @@ function post_formats_compat( $content, $id = 0 ) { break; case 'quote': - if ( ! empty( $meta['quote'] ) && ! stristr( $content, $meta['quote'] ) ) { - $quote = sprintf( '
%s
', wpautop( $meta['quote'] ) ); - if ( ! empty( $meta['quote_source_name'] ) ) { - $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '%s', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] ); - $quote .= sprintf( '
%s
', $source ); - } - $format_output .= sprintf( '
%s
', $quote ); - } + $quote = get_the_post_format_quote( $post ); + + // Replace the existing quote in-place. + if ( ! empty( $quote ) ) + get_content_quote( $content, true, $quote ); break; case 'video': @@ -679,6 +676,83 @@ function the_post_format_chat() { echo $output; } +/** + * Get the first
from the $content string passed by reference. + * + * If $content does not have a blockquote, assume the whole string + * is the quote. + * + * @since 3.6.0 + * + * @param string $content A string which might contain chat data, passed by reference. + * @param bool $remove (optional) Whether to remove the quote from the content. + * @param string $replace (optional) Content to replace the quote content with if $remove is set to true. + * @return string The quote content. + */ +function get_content_quote( &$content, $remove = false, $replace = '' ) { + if ( empty( $content ) ) + return ''; + + $matches = array(); + if ( ! preg_match( '/]*>(.+?)<\/blockquote>/is', $content, $matches ) ) { + $quote = $content; + if ( $remove || ! empty( $replace ) ) + $content = $replace; + return $quote; + } + + if ( $remove || ! empty( $replace ) ) + $content = preg_replace( '/]*>(.+?)<\/blockquote>/is', addcslashes( $replace, '\\$' ), $content, 1 ); + + return $matches[1]; +} + +/** + * Get a quote from the post content and set split_content for future use. + * + * @since 3.6.0 + * + * @uses get_content_quote() + * + * @param object $post (optional) A reference to the post object, falls back to get_post(). + * @return string The quote html. + */ +function get_the_post_format_quote( &$post = null ) { + if ( empty( $post ) ) + $post = get_post(); + + if ( empty( $post ) ) + return ''; + + $content = $post->post_content; + $quote = get_content_quote( $content, true ); + $post->split_content = $content; + + if ( ! empty( $quote ) ) + $quote = sprintf( '
%s
', wpautop( $quote ) ); + + $meta = get_post_format_meta( $post->ID ); + + if ( ! empty( $meta['quote_source_name'] ) ) { + $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '%s', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] ); + $quote .= sprintf( '
%s
', $source ); + } + + if ( ! empty( $quote ) ) + $quote = sprintf( '
%s
', $quote ); + + return $quote; +} + +/** + * Outputs the post format quote. + * + * @since 3.6.0 + */ +function the_post_format_quote() { + echo get_the_post_format_quote(); +} + /** * Extract a URL from passed content, if possible * Checks for a URL on the first line of the content or the first encountered href attribute. diff --git a/wp-includes/query.php b/wp-includes/query.php index 3b41af4c77..40159da62d 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -3694,7 +3694,7 @@ function setup_postdata($post) { $more = 1; $split_content = $content = $post->post_content; $format = get_post_format( $post ); - if ( $format && in_array( $format, array( 'image', 'audio', 'video' ) ) ) { + if ( $format && in_array( $format, array( 'image', 'audio', 'video', 'quote' ) ) ) { switch ( $format ) { case 'image': get_the_post_format_image( 'full', $post ); @@ -3711,6 +3711,11 @@ function setup_postdata($post) { if ( isset( $post->split_content ) ) $split_content = $post->split_content; break; + case 'quote': + get_the_post_format_quote( $post ); + if ( isset( $post->split_content ) ) + $split_content = $post->split_content; + break; } } diff --git a/wp-includes/revision.php b/wp-includes/revision.php index 439f81ea74..eb2a9c33e3 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -72,7 +72,6 @@ function _wp_post_revision_meta_keys() { '_format_link_url', '_format_quote_source_url', '_format_quote_source_name', - '_format_quote', '_format_image', '_format_gallery', '_format_audio_embed',