mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-23 14:54:33 +00:00
Blocks: Parse blocks when displaying posts.
Posts containing blocks are now correctly handled when displaying on the front end, including dynamic blocks and nested blocks. Props pento. Merges [43752] to trunk. See #45109. git-svn-id: https://develop.svn.wordpress.org/trunk@44118 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2,13 +2,18 @@
|
||||
|
||||
<!--more-->
|
||||
|
||||
|
||||
<p>First Gutenberg Paragraph</p>
|
||||
|
||||
|
||||
<p>Second Auto Paragraph</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<p>Third Gutenberg Paragraph</p>
|
||||
|
||||
|
||||
<p>Third Auto Paragraph</p>
|
||||
|
||||
<p>[someshortcode]</p>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<div class="wp-block-archives">No archives to show.</div>
|
||||
@@ -0,0 +1 @@
|
||||
<div class="wp-block-archives">No archives to show.</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
<figure class="wp-block-audio alignright">
|
||||
<audio controls="" src="https://media.simplecast.com/episodes/audio/80564/draft-podcast-51-livePublish2.mp3"></audio>
|
||||
</figure>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<div class="wp-block-button aligncenter"><a class="wp-block-button__link" href="https://github.com/WordPress/gutenberg">Help build Gutenberg</a></div>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<ul class="wp-block-categories wp-block-categories-list aligncenter"><li class="cat-item-none">No categories</li></ul>
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
<pre class="wp-block-code"><code>export default function MyButton() {
|
||||
return <Button>Click Me!</Button>;
|
||||
}</code></pre>
|
||||
|
||||
@@ -3,20 +3,38 @@
|
||||
"blockName": "core/column",
|
||||
"attrs": {},
|
||||
"innerBlocks": [
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n<div class=\"wp-block-column\">\n\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/paragraph",
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t<p>Column One, Paragraph One</p>\n\t"
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/paragraph",
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t<p>Column One, Paragraph Two</p>\n\t"
|
||||
}
|
||||
],
|
||||
"innerHTML": "\n<div class=\"wp-block-column\">\n\t\n\t\n</div>\n"
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n</div>\n"
|
||||
}
|
||||
],
|
||||
"innerHTML": ""
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
|
||||
10
tests/phpunit/data/blocks/fixtures/core__column.server.html
Normal file
10
tests/phpunit/data/blocks/fixtures/core__column.server.html
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
<div class="wp-block-column">
|
||||
|
||||
<p>Column One, Paragraph One</p>
|
||||
|
||||
|
||||
<p>Column One, Paragraph Two</p>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -5,46 +5,100 @@
|
||||
"columns": 3
|
||||
},
|
||||
"innerBlocks": [
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n<div class=\"wp-block-columns has-3-columns\">\n\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/column",
|
||||
"attrs": {},
|
||||
"innerBlocks": [
|
||||
{
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t<div class=\"wp-block-column\">\n\t\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/paragraph",
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t\t<p>Column One, Paragraph One</p>\n\t\t"
|
||||
},
|
||||
{
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/paragraph",
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t\t<p>Column One, Paragraph Two</p>\n\t\t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t</div>\n\t"
|
||||
}
|
||||
],
|
||||
"innerHTML": "\n\t<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>\n\t"
|
||||
"innerHTML": ""
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/column",
|
||||
"attrs": {},
|
||||
"innerBlocks": [
|
||||
{
|
||||
"innerBlocks": [
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t<div class=\"wp-block-column\">\n\t\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/paragraph",
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t\t<p>Column Two, Paragraph One</p>\n\t\t"
|
||||
},
|
||||
{
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t\t"
|
||||
},
|
||||
{
|
||||
"blockName": "core/paragraph",
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t\t<p>Column Three, Paragraph One</p>\n\t\t"
|
||||
}
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n\t</div>\n\t"
|
||||
}
|
||||
],
|
||||
"innerHTML": "\n\t<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>\n\t"
|
||||
}
|
||||
"innerHTML": ""
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
"attrs": {},
|
||||
"innerBlocks": [],
|
||||
"innerHTML": "\n</div>\n"
|
||||
}
|
||||
],
|
||||
"innerHTML": "\n<div class=\"wp-block-columns has-3-columns\">\n\t\n\t\n</div>\n"
|
||||
"innerHTML": ""
|
||||
},
|
||||
{
|
||||
"blockName": null,
|
||||
|
||||
24
tests/phpunit/data/blocks/fixtures/core__columns.server.html
Normal file
24
tests/phpunit/data/blocks/fixtures/core__columns.server.html
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
<div class="wp-block-columns has-3-columns">
|
||||
|
||||
<div class="wp-block-column">
|
||||
|
||||
<p>Column One, Paragraph One</p>
|
||||
|
||||
|
||||
<p>Column One, Paragraph Two</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wp-block-column">
|
||||
|
||||
<p>Column Two, Paragraph One</p>
|
||||
|
||||
|
||||
<p>Column Three, Paragraph One</p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
<div class="wp-block-cover-image has-background-dim-40 has-background-dim" style="background-image:url(https://cldup.com/uuUqE_dXzy.jpg)">
|
||||
<p class="wp-block-cover-image-text">Guten Berg!</p>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
<figure class="wp-block-embed">
|
||||
<div class="wp-block-embed__wrapper">
|
||||
https://example.com/
|
||||
</div>
|
||||
<figcaption>Embedded content from an example URL</figcaption>
|
||||
</figure>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<div class="wp-block-file"><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" target="_blank" rel="noreferrer noopener">6546</a><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" class="wp-block-file__button" download="6546">Download</a></div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<div class="wp-block-file"><a href="http://localhost:8888/?attachment_id=176">lkjfijwef</a></div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<div class="wp-block-file"><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" class="wp-block-file__button" download="">Download</a></div>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
Testing freeform block with some
|
||||
<div class="wp-some-class">
|
||||
HTML <span style="color: red;">content</span>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Testing freeform block with some
|
||||
<div class="wp-some-class">
|
||||
HTML <span style="color: red;">content</span>
|
||||
</div>
|
||||
14
tests/phpunit/data/blocks/fixtures/core__gallery.server.html
Normal file
14
tests/phpunit/data/blocks/fixtures/core__gallery.server.html
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
<ul class="wp-block-gallery columns-2 is-cropped">
|
||||
<li class="blocks-gallery-item">
|
||||
<figure>
|
||||
<img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title" />
|
||||
</figure>
|
||||
</li>
|
||||
<li class="blocks-gallery-item">
|
||||
<figure>
|
||||
<img src="http://google.com/hi.png" alt="title" />
|
||||
</figure>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
<ul class="wp-block-gallery columns-1 is-cropped">
|
||||
<li class="blocks-gallery-item">
|
||||
<figure>
|
||||
<img src="https://cldup.com/uuUqE_dXzy.jpg" alt="title" />
|
||||
</figure>
|
||||
</li>
|
||||
<li class="blocks-gallery-item">
|
||||
<figure>
|
||||
<img src="http://google.com/hi.png" alt="title" />
|
||||
</figure>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<h2>The <em>Inserter</em> Tool</h2>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<h2>A picture is worth a thousand words, or so the saying goes</h2>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
<h1>Some HTML code</h1>
|
||||
<marquee>This text will scroll from right to left</marquee>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<figure class="wp-block-image"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="" /></figure>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<figure class="wp-block-image"><a href="http://localhost:8888/?attachment_id=7"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="" /></a></figure>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<div class="wp-block-image"><figure class="aligncenter"><img src="https://cldup.com/YLYhpou2oq.jpg" alt="" /><figcaption>Give it a try. Press the "really wide" button on the image toolbar.</figcaption></figure></div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<figure class="wp-block-image"><a href="https://wordpress.org/"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="" /></a></figure>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<figure class="wp-block-image"><a href="https://cldup.com/uuUqE_dXzy.jpg"><img src="https://cldup.com/uuUqE_dXzy.jpg" alt="" /></a></figure>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<div class="wp-block-latest-comments has-avatars has-dates has-excerpts no-comments">No comments to show.</div>
|
||||
@@ -0,0 +1 @@
|
||||
<ul class="wp-block-latest-posts"></ul>
|
||||
@@ -0,0 +1 @@
|
||||
<ul class="wp-block-latest-posts"></ul>
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<ul><li>Text & Headings</li><li>Images & Videos</li><li>Galleries</li><li>Embeds, like YouTube, Tweets, or other WordPress posts.</li><li>Layout blocks, like Buttons, Hero Images, Separators, etc.</li><li>And <em>Lists</em> like this one of course :)</li></ul>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
<p>Testing missing block with some</p>
|
||||
<div class="wp-some-class">
|
||||
HTML <span style="color: red;">content</span>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<!--more-->
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
<!--more Continue Reading-->
|
||||
<!--noteaser-->
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<!--nextpage-->
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<p style="text-align:right;">... like this one, which is separate from the above and right aligned.</p>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
Unwrapped is <em>still</em> valid.
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<pre class="wp-block-preformatted">Some <em>preformatted</em> text...<br>And more!</pre>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
<figure class="wp-block-pullquote">
|
||||
<blockquote>
|
||||
<p>Testing pullquote block...</p><cite>...with a caption</cite>
|
||||
</blockquote>
|
||||
</figure>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
<figure class="wp-block-pullquote">
|
||||
<blockquote>
|
||||
<p>Paragraph <strong>one</strong></p>
|
||||
<p>Paragraph two</p>
|
||||
<cite>by whomever</cite>
|
||||
</blockquote>
|
||||
</figure>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<blockquote class="wp-block-quote"><p>The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery.</p><cite>Matt Mullenweg, 2017</cite></blockquote>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<blockquote class="wp-block-quote is-style-large"><p>There is no greater agony than bearing an untold story inside you.</p><cite>Maya Angelou</cite></blockquote>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<hr class="wp-block-separator" />
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<p>[gallery ids="238,338"]</p>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<p class="wp-block-subhead">This is a <em>subhead</em>.</p>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<table class="wp-block-table"><thead><tr><th>Version</th><th>Musician</th><th>Date</th></tr></thead><tbody><tr><td><a href="https://wordpress.org/news/2003/05/wordpress-now-available/">.70</a></td><td>No musician chosen.</td><td>May 27, 2003</td></tr><tr><td><a href="https://wordpress.org/news/2004/01/wordpress-10/">1.0</a></td><td>Miles Davis</td><td>January 3, 2004</td></tr><tr><td>Lots of versions skipped, see <a href="https://codex.wordpress.org/WordPress_Versions">the full list</a></td><td>…</td><td>…</td></tr><tr><td><a href="https://wordpress.org/news/2015/12/clifford/">4.4</a></td><td>Clifford Brown</td><td>December 8, 2015</td></tr><tr><td><a href="https://wordpress.org/news/2016/04/coleman/">4.5</a></td><td>Coleman Hawkins</td><td>April 12, 2016</td></tr><tr><td><a href="https://wordpress.org/news/2016/08/pepper/">4.6</a></td><td>Pepper Adams</td><td>August 16, 2016</td></tr><tr><td><a href="https://wordpress.org/news/2016/12/vaughan/">4.7</a></td><td>Sarah Vaughan</td><td>December 6, 2016</td></tr></tbody></table>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
<div class="wp-block-text-columns aligncenter columns-2">
|
||||
<div class="wp-block-column">
|
||||
<p>One</p>
|
||||
</div>
|
||||
<div class="wp-block-column">
|
||||
<p>Two</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<p>This is an old-style text block. Changed to <code>paragraph</code> in #2135.</p>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<pre class="wp-block-verse">A <em>verse</em>…<br>And more!</pre>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
<figure class="wp-block-video"><video controls src="https://awesome-fake.video/file.mp4"></video></figure>
|
||||
|
||||
Reference in New Issue
Block a user