<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[24034] trunk: Post Formats: use the content body for the body of the Quote post format.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/24034">24034</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2013-04-18 18:07:58 +0000 (Thu, 18 Apr 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Post Formats: use the content body for the body of the Quote post format.

* Searchable, better editing tools
* Less cluttered Post Format UI

props kovshenin, DrewAPicture. see <a href="http://core.trac.wordpress.org/ticket/24009">#24009</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpadminincludespostformatsphp">trunk/wp-admin/includes/post-formats.php</a></li>
<li><a href="#trunkwpincludespostformatsphp">trunk/wp-includes/post-formats.php</a></li>
<li><a href="#trunkwpincludesqueryphp">trunk/wp-includes/query.php</a></li>
<li><a href="#trunkwpincludesrevisionphp">trunk/wp-includes/revision.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (24033 => 24034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2013-04-18 17:18:19 UTC (rev 24033)
+++ trunk/wp-admin/edit-form-advanced.php        2013-04-18 18:07:58 UTC (rev 24034)
</span><span class="lines">@@ -172,7 +172,7 @@
</span><span class="cx">                         'description' =&gt; __( 'Use the editor to compose a status update. What&amp;#8217;s new?' )
</span><span class="cx">                 ),
</span><span class="cx">                 'quote' =&gt; array (
</span><del>-                        'description' =&gt; __( 'Copy a quotation into the box below. Add a source and URL if you have them.' )
</del><ins>+                        'description' =&gt; __( 'Add a source and URL if you have them. Use the editor to compose the quote.' )
</ins><span class="cx">                 ),
</span><span class="cx">                 'aside' =&gt; array (
</span><span class="cx">                         'description' =&gt; __( 'Use the editor to share a quick thought or side topic.' )
</span></span></pre></div>
<a id="trunkwpadminincludespostformatsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post-formats.php (24033 => 24034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post-formats.php        2013-04-18 17:18:19 UTC (rev 24033)
+++ trunk/wp-admin/includes/post-formats.php        2013-04-18 18:07:58 UTC (rev 24034)
</span><span class="lines">@@ -10,11 +10,6 @@
</span><span class="cx">         &lt;input type=&quot;hidden&quot; name=&quot;post_format&quot; id=&quot;post_format&quot; value=&quot;&lt;?php echo esc_attr( $post_format ); ?&gt;&quot; /&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;field wp-format-quote&quot;&gt;
</span><del>-                &lt;label for=&quot;wp_format_quote&quot;&gt;&lt;?php _e( 'Quote' ); ?&gt;&lt;/label&gt;
-                &lt;textarea id=&quot;wp_format_quote&quot; name=&quot;_format_quote&quot; class=&quot;widefat&quot;&gt;&lt;?php echo esc_textarea( $format_meta['quote'] ); ?&gt;&lt;/textarea&gt;
-        &lt;/div&gt;
-
-        &lt;div class=&quot;field wp-format-quote&quot;&gt;
</del><span class="cx">                 &lt;label for=&quot;wp_format_quote_source&quot;&gt;&lt;?php _e( 'Quote source' ); ?&gt;&lt;/label&gt;
</span><span class="cx">                 &lt;input type=&quot;text&quot; id=&quot;wp_format_quote_source&quot; name=&quot;_format_quote_source_name&quot; value=&quot;&lt;?php echo esc_attr( $format_meta['quote_source_name'] ); ?&gt;&quot; class=&quot;widefat&quot; /&gt;
</span><span class="cx">         &lt;/div&gt;
</span></span></pre></div>
<a id="trunkwpincludespostformatsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-formats.php (24033 => 24034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-formats.php        2013-04-18 17:18:19 UTC (rev 24033)
+++ trunk/wp-includes/post-formats.php        2013-04-18 18:07:58 UTC (rev 24034)
</span><span class="lines">@@ -399,14 +399,11 @@
</span><span class="cx">                         break;
</span><span class="cx"> 
</span><span class="cx">                 case 'quote':
</span><del>-                        if ( ! empty( $meta['quote'] ) &amp;&amp; ! stristr( $content, $meta['quote'] ) ) {
-                                $quote = sprintf( '&lt;blockquote&gt;%s&lt;/blockquote&gt;', wpautop( $meta['quote'] ) );
-                                if ( ! empty( $meta['quote_source_name'] ) ) {
-                                        $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] );
-                                        $quote .= sprintf( '&lt;figcaption class=&quot;quote-caption&quot;&gt;%s&lt;/figcaption&gt;', $source );
-                                }
-                                $format_output .= sprintf( '&lt;figure class=&quot;quote&quot;&gt;%s&lt;/figure&gt;', $quote );
-                        }
</del><ins>+                        $quote = get_the_post_format_quote( $post );
+
+                        // Replace the existing quote in-place.
+                        if ( ! empty( $quote ) )
+                                get_content_quote( $content, true, $quote );
</ins><span class="cx">                         break;
</span><span class="cx"> 
</span><span class="cx">                 case 'video':
</span><span class="lines">@@ -680,6 +677,83 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Get the first &lt;blockquote&gt; 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( &amp;$content, $remove = false, $replace = '' ) {
+        if ( empty( $content ) )
+                return '';
+
+        $matches = array();
+        if ( ! preg_match( '/&lt;blockquote[^&gt;]*&gt;(.+?)&lt;\/blockquote&gt;/is', $content, $matches ) ) {
+                $quote = $content;
+                if ( $remove || ! empty( $replace ) )
+                        $content = $replace;
+                return $quote;
+        }
+
+        if ( $remove || ! empty( $replace ) )
+                $content = preg_replace( '/&lt;blockquote[^&gt;]*&gt;(.+?)&lt;\/blockquote&gt;/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( &amp;$post = null ) {
+        if ( empty( $post ) )
+                $post = get_post();
+
+        if ( empty( $post ) )
+                return '';
+
+        $content = $post-&gt;post_content;
+        $quote = get_content_quote( $content, true );
+        $post-&gt;split_content = $content;
+
+        if ( ! empty( $quote ) )
+                $quote = sprintf( '&lt;blockquote&gt;%s&lt;/blockquote&gt;', wpautop( $quote ) );
+
+        $meta = get_post_format_meta( $post-&gt;ID );
+
+        if ( ! empty( $meta['quote_source_name'] ) ) {
+                $source = ( empty( $meta['quote_source_url'] ) ) ? $meta['quote_source_name'] : sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;', esc_url( $meta['quote_source_url'] ), $meta['quote_source_name'] );
+                $quote .= sprintf( '&lt;figcaption class=&quot;quote-caption&quot;&gt;%s&lt;/figcaption&gt;', $source );
+        }
+
+        if ( ! empty( $quote ) )
+                $quote = sprintf( '&lt;figure class=&quot;quote&quot;&gt;%s&lt;/figure&gt;', $quote );
+
+        return $quote;
+}
+
+/**
+ * Outputs the post format quote.
+ *
+ * @since 3.6.0
+ */
+function the_post_format_quote() {
+        echo get_the_post_format_quote();
+}
+
+/**
</ins><span class="cx">  * Extract a URL from passed content, if possible
</span><span class="cx">  * Checks for a URL on the first line of the content or the first encountered href attribute.
</span><span class="cx">  *
</span></span></pre></div>
<a id="trunkwpincludesqueryphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/query.php (24033 => 24034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/query.php        2013-04-18 17:18:19 UTC (rev 24033)
+++ trunk/wp-includes/query.php        2013-04-18 18:07:58 UTC (rev 24034)
</span><span class="lines">@@ -3694,7 +3694,7 @@
</span><span class="cx">                 $more = 1;
</span><span class="cx">         $split_content = $content = $post-&gt;post_content;
</span><span class="cx">         $format = get_post_format( $post );
</span><del>-        if ( $format &amp;&amp; in_array( $format, array( 'image', 'audio', 'video' ) ) ) {
</del><ins>+        if ( $format &amp;&amp; in_array( $format, array( 'image', 'audio', 'video', 'quote' ) ) ) {
</ins><span class="cx">                 switch ( $format ) {
</span><span class="cx">                 case 'image':
</span><span class="cx">                         get_the_post_format_image( 'full', $post );
</span><span class="lines">@@ -3711,6 +3711,11 @@
</span><span class="cx">                         if ( isset( $post-&gt;split_content ) )
</span><span class="cx">                                 $split_content = $post-&gt;split_content;
</span><span class="cx">                         break;
</span><ins>+                case 'quote':
+                        get_the_post_format_quote( $post );
+                        if ( isset( $post-&gt;split_content ) )
+                                $split_content = $post-&gt;split_content;
+                        break;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesrevisionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/revision.php (24033 => 24034)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/revision.php        2013-04-18 17:18:19 UTC (rev 24033)
+++ trunk/wp-includes/revision.php        2013-04-18 18:07:58 UTC (rev 24034)
</span><span class="lines">@@ -72,7 +72,6 @@
</span><span class="cx">                 '_format_link_url',
</span><span class="cx">                 '_format_quote_source_url',
</span><span class="cx">                 '_format_quote_source_name',
</span><del>-                '_format_quote',
</del><span class="cx">                 '_format_image',
</span><span class="cx">                 '_format_gallery',
</span><span class="cx">                 '_format_audio_embed',
</span></span></pre>
</div>
</div>

</body>
</html>