[wp-trac] [WordPress Trac] #57630: Site Editor: Template part customization is not saved for certain child themes
WordPress Trac
noreply at wordpress.org
Fri Feb 3 19:47:19 UTC 2023
#57630: Site Editor: Template part customization is not saved for certain child
themes
--------------------------+-----------------------------
Reporter: mreishus | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
== Issue Summary
For some FSE child themes, when using the site editor to make the first
customization of a template part, the edit appears to save but does not
display on the front-end of the site.
The bug applies to editing template parts that do not exist in the child
theme.
== Steps to reproduce
* Clone https://github.com/WordPress/wordpress-develop (Tested using
bd4d4af7849, 2023-02-03, 6.2-alpha-54642-src).
* {{{npm install}}}
* {{{npm run build:dev}}}
* {{{npm run env:start}}}
* {{{npm run env:install}}}
* Download these two themes onto your computer: https://public-
api.wordpress.com/rest/v1/themes/download/twentytwentytwo-wpcom.zip and
https://public-api.wordpress.com/rest/v1/themes/download/twentytwentytwo-
red.zip
* Visit http://localhost:8889/wp-admin/themes.php
* Click add new, then upload theme, then browse. Choose twentytwentytwo-
wpcom-1.2.zip then install. Repeat the process for twentytwentytwo-red-
wpcom-1.0.zip.
* Activate the theme: Twenty Twenty-Two (Red) - WordPress.com.
* Visit http://localhost:8889/wp-admin/site-editor.php
* Click on “WordPress Develop” in the header, then click the block
inserter button (the plus icon).
* Choose blocks -> paragraph to insert a new paragraph block, which should
be to the right of “WordPress Develop”. Select the new block and type
“Hello” in it.
* In the top bar, click save. The sidebar will expand, asking “Are you
ready to save?” and “header” will be checked. Click save again.
* Visit http://localhost:8889/ in a new tab. Expect to see: The new
“hello” paragraph in the header. Actually see: No changes were applied.
== Testing Notes - Certain types of child themes trigger the bug
The bug is related to child themes, but only certain types. Both Twenty
Twenty-Two (Red) - WordPress.com and Geologist are child themes, but only
the former is affected by the bug.
Child themes that have a template part present in both the child theme and
the parent theme (example parts/header.html) has shown to allow template
editing. However, child themes that don’t have a specific template in, but
the parent theme does, will not allow template editing.
== Testing Notes - Bug only occurs when making the first customization to
a non-customized template part
If the header has already been customized, the bug cannot happen: You will
always be able to edit an already customized header.
For example: When following the above directions with a fresh site, I will
not be able to edit the header. After applying the patch below, I will be
able to edit the header.
After one edit is saved, even if I rollback the patch and remove the fix,
I’m still able to apply more edits. The bug will only reappear if I use
the “Clear customizations” for that template part in the site editor.
(Site editor -> Middle Top Bar -> “Browse all templates” -> Template Parts
-> Header -> Three dots menu -> Clear customization).
== Related change
Reverting the change introduced in
https://core.trac.wordpress.org/ticket/55437 fixes the issue:
{{{
diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes
/block-template-utils.php
index acbb7724c5..55ad6e15d0 100644
--- a/src/wp-includes/block-template-utils.php
+++ b/src/wp-includes/block-template-utils.php
@@ -503,7 +503,8 @@ function _build_block_template_result_from_file(
$template_file, $template_type
$template = new WP_Block_Template();
$template->id = $theme . '//' . $template_file['slug'];
- $template->theme = ! empty( $template_file['theme'] ) ?
$template_file['theme'] : $theme;
+ //$template->theme = ! empty( $template_file['theme'] ) ?
$template_file['theme'] : $theme;
+ $template->theme = $theme;
$template->content =
_inject_theme_attribute_in_block_template_content( $template_content );
$template->slug = $template_file['slug'];
$template->source = 'theme';
}}}
However, I cannot determine the exact mechanism why; or how to resolve the
issue in #55437 while also resolving this issue.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57630>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list