| 1 |
<?php |
| 2 |
require '/wordpress/wp-load.php'; |
| 3 |
|
| 4 |
// The button + phone CTAs live in a *template part* (the header), not page |
| 5 |
// content, so Quick Edit routes through the template-part load + save path |
| 6 |
// (resolveTarget's PART_ATTR branch → TemplatePartBlockFinder) rather than the |
| 7 |
// post path. The phone is a core/paragraph whose entire text is a single tel: |
| 8 |
// link — the target of the save-time href sync and the link-activation on open. |
| 9 |
// Block themes prefer a DB-resolved wp_template_part over the theme's |
| 10 |
// filesystem part for the same slug + wp_theme term; the base template still |
| 11 |
// invokes it with tagName="header", so role="banner" is preserved for locators. |
| 12 |
$headerContent = "<!-- wp:site-title /-->\n" |
| 13 |
. "<!-- wp:paragraph -->\n" |
| 14 |
. '<p><a href="tel:0123456789">01 23 45 67 89</a></p>' . "\n" |
| 15 |
. "<!-- /wp:paragraph -->\n" |
| 16 |
. "<!-- wp:buttons -->\n" |
| 17 |
. "<div class=\"wp-block-buttons\">\n" |
| 18 |
. "<!-- wp:button -->\n" |
| 19 |
. '<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://example.com/desks">Shop Desks</a></div>' . "\n" |
| 20 |
. "<!-- /wp:button -->\n" |
| 21 |
. "</div>\n" |
| 22 |
. "<!-- /wp:buttons -->"; |
| 23 |
|
| 24 |
$headerPartId = wp_insert_post([ |
| 25 |
'post_type' => 'wp_template_part', |
| 26 |
'post_status' => 'publish', |
| 27 |
'post_name' => 'header', |
| 28 |
'post_title' => 'Header', |
| 29 |
'post_content' => $headerContent, |
| 30 |
]); |
| 31 |
wp_set_object_terms($headerPartId, 'extendable', 'wp_theme'); |
| 32 |
|
| 33 |
// A static front page so `/` is stable. Its content is irrelevant — the CTAs |
| 34 |
// under test live in the header part, which renders on every template (so the |
| 35 |
// default "Hello world!" post at /?p=1 is the site-wide cross-check). |
| 36 |
$frontId = wp_insert_post([ |
| 37 |
'post_type' => 'page', |
| 38 |
'post_status' => 'publish', |
| 39 |
'post_title' => 'Header CTA Home', |
| 40 |
'post_content' => "<!-- wp:heading -->\n" |
| 41 |
. '<h2 class="wp-block-heading">Header CTA home.</h2>' |
| 42 |
. "\n<!-- /wp:heading -->", |
| 43 |
]); |
| 44 |
update_option('show_on_front', 'page'); |
| 45 |
update_option('page_on_front', $frontId); |
| 46 |
|