| 1 |
<?php |
| 2 |
require '/wordpress/wp-load.php'; |
| 3 |
|
| 4 |
// Two cover blocks back-to-back so a single page exercises both branches of |
| 5 |
// findOpaqueBackground's cover-handling path: |
| 6 |
// |
| 7 |
// 1. Image-only cover (dim-0, no overlay color) — the `__background` span has |
| 8 |
// `has-background-dim-0` → CSS opacity 0. The fix's fallback kicks in: |
| 9 |
// host gets `rgba(0, 0, 0, 0.5)`. |
| 10 |
// |
| 11 |
// 2. Cover with an opaque overlay span (dim-90, overlayColor: background) — |
| 12 |
// the span resolves to rgb(255,255,255) at opacity 0.9. The fix reads it |
| 13 |
// and emits host `rgba(255, 255, 255, 0.9)`. |
| 14 |
// |
| 15 |
// findOpaqueBackground doesn't look at the cover image, so a 1×1 transparent |
| 16 |
// gif data URI is enough for the image-only cover to have its <img>. |
| 17 |
$tinyImage = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; |
| 18 |
|
| 19 |
$content = |
| 20 |
"<!-- wp:cover {\"url\":\"$tinyImage\",\"dimRatio\":0,\"isUserOverlayColor\":true,\"minHeight\":260,\"minHeightUnit\":\"px\"} -->\n" |
| 21 |
. "<div class=\"wp-block-cover\" style=\"min-height:260px\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-dim-0 has-background-dim\"></span><img class=\"wp-block-cover__image-background\" alt=\"\" src=\"$tinyImage\" data-object-fit=\"cover\"/><div class=\"wp-block-cover__inner-container\">" |
| 22 |
. "<!-- wp:heading {\"level\":2,\"className\":\"image-only-heading\"} -->\n" |
| 23 |
. "<h2 class=\"wp-block-heading image-only-heading\">Image only heading</h2>\n" |
| 24 |
. "<!-- /wp:heading -->\n" |
| 25 |
. "</div></div>\n" |
| 26 |
. "<!-- /wp:cover -->\n" |
| 27 |
|
| 28 |
. "<!-- wp:cover {\"dimRatio\":90,\"overlayColor\":\"background\",\"isUserOverlayColor\":true,\"minHeight\":260,\"minHeightUnit\":\"px\"} -->\n" |
| 29 |
. "<div class=\"wp-block-cover\" style=\"min-height:260px\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-background-color has-background-dim-90 has-background-dim\"></span><div class=\"wp-block-cover__inner-container\">" |
| 30 |
. "<!-- wp:heading {\"level\":2,\"className\":\"overlay-heading\"} -->\n" |
| 31 |
. "<h2 class=\"wp-block-heading overlay-heading\">Overlay heading</h2>\n" |
| 32 |
. "<!-- /wp:heading -->\n" |
| 33 |
. "</div></div>\n" |
| 34 |
. "<!-- /wp:cover -->\n"; |
| 35 |
|
| 36 |
$pageId = wp_insert_post([ |
| 37 |
'post_type' => 'page', |
| 38 |
'post_status' => 'publish', |
| 39 |
'post_title' => 'Cover Overflow Test Home', |
| 40 |
'post_content' => $content, |
| 41 |
]); |
| 42 |
|
| 43 |
update_option('show_on_front', 'page'); |
| 44 |
update_option('page_on_front', $pageId); |
| 45 |
|