<!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>[57020] branches/6.4/tests/phpunit/tests: Themes: Skip wrapping block template for singular content with a main query loop when the template was injected from outside the current theme.</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 { white-space: pre-line; 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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/57020">57020</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/57020","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>flixos90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-10-27 18:34:11 +0000 (Fri, 27 Oct 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Themes: Skip wrapping block template for singular content with a main query loop when the template was injected from outside the current theme.
As a follow up to <a href="https://core.trac.wordpress.org/changeset/56507">[56507]</a>, this fixes a bug that could occur for instance when plugins hijack the block template detection process to inject their own block template with entirely custom logic.
Props afragen, hellofromTonya, costdev, mukesh27, huzaifaalmesbah, flixos90.
Merges <a href="https://core.trac.wordpress.org/changeset/57019">[57019]</a> to the 6.4 branch.
Fixes <a href="https://core.trac.wordpress.org/ticket/59736">#59736</a>.
See <a href="https://core.trac.wordpress.org/ticket/58154">#58154</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches64srcwpincludesblocktemplatephp">branches/6.4/src/wp-includes/block-template.php</a></li>
<li><a href="#branches64testsphpunittestsblocktemplatephp">branches/6.4/tests/phpunit/tests/block-template.php</a></li>
<li><a href="#branches64testsphpunittestsmediaphp">branches/6.4/tests/phpunit/tests/media.php</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#branches64">branches/6.4/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/6.4
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/6.4 2023-10-27 18:16:05 UTC (rev 57019)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/6.4 2023-10-27 18:34:11 UTC (rev 57020)
</ins><a id="branches64"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/6.4</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/5.0:43681-43682,43684-43688,43719-43720,43723,43726-43727,43729-43731,43734-43744,43747,43751-43754,43758,43760-43765,43767-43770,43772,43774-43781,43783,43785,43790-43806,43808-43821,43825,43828,43830-43834,43836-43843,43846-43863,43867-43889,43891-43894,43897-43905,43908-43909,43911-43929,43931-43942,43946-43947,43949-43956,43959-43964,43967-43969,43988,43994,44014,44017,44047,44183,44185,44187-44206,44208-44213,44231-44232,44235,44248,44284,44287-44288
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.5:49373-49379,49381
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/5.8:51889
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:56974,56978,56984,56987,56990-56992,56996,56999,57003,57009,57012-57013
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:56974,56978,56984,56987,56990-56992,56996,56999,57003,57009,57012-57013,57019
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches64srcwpincludesblocktemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/6.4/src/wp-includes/block-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.4/src/wp-includes/block-template.php 2023-10-27 18:16:05 UTC (rev 57019)
+++ branches/6.4/src/wp-includes/block-template.php 2023-10-27 18:34:11 UTC (rev 57020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -208,6 +208,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.8.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @global string $_wp_current_template_id
</ins><span class="cx" style="display: block; padding: 0 10px"> * @global string $_wp_current_template_content
</span><span class="cx" style="display: block; padding: 0 10px"> * @global WP_Embed $wp_embed
</span><span class="cx" style="display: block; padding: 0 10px"> * @global WP_Query $wp_query
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,7 +216,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string Block template markup.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_the_block_template_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $_wp_current_template_content, $wp_embed, $wp_query;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content, $wp_embed, $wp_query;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $_wp_current_template_content ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_user_logged_in() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,8 +243,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Even if the block template contained a `core/query` and `core/post-template` block referencing the main query
</span><span class="cx" style="display: block; padding: 0 10px"> * loop, it would not cause errors since it would use a cloned instance and go through the same loop of a single
</span><span class="cx" style="display: block; padding: 0 10px"> * post, within the actual main query loop.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * This special logic should be skipped if the current template does not come from the current theme, in which case
+ * it has been injected by a plugin by hijacking the block template loader mechanism. In that case, entirely custom
+ * logic may be applied which is unpredictable and therefore safer to omit this special handling on.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_singular() && 1 === $wp_query->post_count && have_posts() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (
+ $_wp_current_template_id &&
+ str_starts_with( $_wp_current_template_id, get_stylesheet() . '//' ) &&
+ is_singular() &&
+ 1 === $wp_query->post_count &&
+ have_posts()
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> while ( have_posts() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> the_post();
</span><span class="cx" style="display: block; padding: 0 10px"> $content = do_blocks( $content );
</span></span></pre></div>
<a id="branches64testsphpunittestsblocktemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/6.4/tests/phpunit/tests/block-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.4/tests/phpunit/tests/block-template.php 2023-10-27 18:16:05 UTC (rev 57019)
+++ branches/6.4/tests/phpunit/tests/block-template.php 2023-10-27 18:34:11 UTC (rev 57020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -19,8 +19,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function tear_down() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $_wp_current_template_content;
- unset( $_wp_current_template_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content;
+ unset( $_wp_current_template_id, $_wp_current_template_content );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> parent::tear_down();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,10 +193,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * since there is only a single post in the main query loop in such cases anyway.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58154
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ticket 59736
</ins><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_the_block_template_html
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_the_block_template_html_enforces_singular_query_loop() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $_wp_current_template_content, $wp_query, $wp_the_query;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Register test block to log `in_the_loop()` results.
</span><span class="cx" style="display: block; padding: 0 10px"> $in_the_loop_logs = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,6 +208,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_query = new WP_Query( array( 'p' => $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_the_query = $wp_query;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Force a template ID that is for the current stylesheet.
+ $_wp_current_template_id = get_stylesheet() . '//single';
</ins><span class="cx" style="display: block; padding: 0 10px"> // Use block template that just renders post title and the above test block.
</span><span class="cx" style="display: block; padding: 0 10px"> $_wp_current_template_content = '<!-- wp:post-title /--><!-- wp:test/in-the-loop-logger /-->';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,7 +230,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_the_block_template_html
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_the_block_template_html_does_not_generally_enforce_loop() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $_wp_current_template_content, $wp_query, $wp_the_query;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Register test block to log `in_the_loop()` results.
</span><span class="cx" style="display: block; padding: 0 10px"> $in_the_loop_logs = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -248,6 +251,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_the_query = $wp_query;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Force a template ID that is for the current stylesheet.
+ $_wp_current_template_id = get_stylesheet() . '//home';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * Use block template that renders the above test block, followed by a main query loop.
</span><span class="cx" style="display: block; padding: 0 10px"> * `get_the_block_template_html()` should not start the loop, but the `core/query` and `core/post-template`
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -277,6 +283,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Tests that `get_the_block_template_html()` does not start the main query loop when on a template that is not from the current theme.
+ *
+ * @ticket 58154
+ * @ticket 59736
+ * @covers ::get_the_block_template_html
+ */
+ public function test_get_the_block_template_html_skips_singular_query_loop_when_non_theme_template() {
+ global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query;
+
+ // Register test block to log `in_the_loop()` results.
+ $in_the_loop_logs = array();
+ $this->register_in_the_loop_logger_block( $in_the_loop_logs );
+
+ // Set main query to single post.
+ $post_id = self::factory()->post->create( array( 'post_title' => 'A single post' ) );
+ $wp_query = new WP_Query( array( 'p' => $post_id ) );
+ $wp_the_query = $wp_query;
+
+ // Force a template ID that is not for the current stylesheet.
+ $_wp_current_template_id = 'some-plugin-slug//single';
+ // Use block template that just renders post title and the above test block.
+ $_wp_current_template_content = '<!-- wp:post-title /--><!-- wp:test/in-the-loop-logger /-->';
+
+ $output = get_the_block_template_html();
+ $this->unregister_in_the_loop_logger_block();
+ $this->assertSame( array( false ), $in_the_loop_logs, 'Main query loop was triggered despite a custom block template outside the current theme being used' );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58319
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::get_block_theme_folders
</span></span></pre></div>
<a id="branches64testsphpunittestsmediaphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/6.4/tests/phpunit/tests/media.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/6.4/tests/phpunit/tests/media.php 2023-10-27 18:16:05 UTC (rev 57019)
+++ branches/6.4/tests/phpunit/tests/media.php 2023-10-27 18:34:11 UTC (rev 57020)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -79,6 +79,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Ensures that the static content media count, fetchpriority element flag and related filter are reset between tests.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function tear_down() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content;
+ unset( $_wp_current_template_id, $_wp_current_template_content );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> parent::tear_down();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->reset_content_media_count();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3972,7 +3975,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_get_loading_optimization_attributes
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_filter_content_tags_does_not_lazy_load_first_image_in_block_theme() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $_wp_current_template_content, $wp_query, $wp_the_query, $post;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query, $post;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Do not add srcset, sizes, or decoding attributes as they are irrelevant for this test.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wp_img_tag_add_srcset_and_sizes_attr', '__return_false' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4001,6 +4004,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_the_query = $wp_query;
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( self::$post_ids['publish'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Force a template ID that is for the current stylesheet.
+ $_wp_current_template_id = get_stylesheet() . '//single';
</ins><span class="cx" style="display: block; padding: 0 10px"> $_wp_current_template_content = '<!-- wp:post-content /-->';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $html = get_the_block_template_html();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4020,7 +4025,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_get_loading_optimization_attributes
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_filter_content_tags_does_not_lazy_load_first_featured_image_in_block_theme() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $_wp_current_template_content, $wp_query, $wp_the_query, $post;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content, $wp_query, $wp_the_query, $post;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Do not add srcset, sizes, or decoding attributes as they are irrelevant for this test.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wp_img_tag_add_srcset_and_sizes_attr', '__return_false' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4069,6 +4074,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_the_query = $wp_query;
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( self::$post_ids['publish'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Force a template ID that is for the current stylesheet.
+ $_wp_current_template_id = get_stylesheet() . '//single';
</ins><span class="cx" style="display: block; padding: 0 10px"> $_wp_current_template_content = '<!-- wp:post-featured-image /--> <!-- wp:post-content /-->';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $html = get_the_block_template_html();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4087,7 +4094,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_get_loading_optimization_attributes
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_filter_content_tags_does_not_lazy_load_images_in_header() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $_wp_current_template_content;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $_wp_current_template_id, $_wp_current_template_content;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Do not add srcset, sizes, or decoding attributes as they are irrelevant for this test.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wp_img_tag_add_srcset_and_sizes_attr', '__return_false' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4122,6 +4129,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_post_terms( $footer_post_id, WP_TEMPLATE_PART_AREA_FOOTER, 'wp_template_part_area' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_post_terms( $footer_post_id, get_stylesheet(), 'wp_theme' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Force a template ID that is for the current stylesheet.
+ $_wp_current_template_id = get_stylesheet() . '//single';
</ins><span class="cx" style="display: block; padding: 0 10px"> $_wp_current_template_content = '<!-- wp:template-part {"slug":"header","theme":"' . get_stylesheet() . '","tagName":"header"} /--><!-- wp:template-part {"slug":"footer","theme":"' . get_stylesheet() . '","tagName":"footer"} /-->';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Header image should not be lazy-loaded, footer image should be lazy-loaded.
</span></span></pre>
</div>
</div>
</body>
</html>