Both the `$pre_callback` and `$post_callback` functions that are given as arguments to `traverse_and_serialize_block(s)` receive a reference to the current block as their first argument. However, while any changes that the "pre" callback makes to the block are reflected by the serialized markup, the same wasn't true for the "post" callback: Any changes that it made were only applied ''after'' the block had already been serialized.
This commit changes the behavior such that `$post_callback`'s changes to the current block are also reflected in the serialized markup.
Reviewed by hellofromTonya.
Merges [56970] to the 6.4 branch.
See #59646.
Props gziolo.
Fixes#59669.
Built from https://develop.svn.wordpress.org/branches/6.4@57043
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The callbacks returned by `make_before_block_visitor` and `make_after_block_visitor`, respectively, (which are passed as arguments to `traverse_and_serialize_block(s)`) currently accept three arguments, all of which are block arrays (i.e. with properties `blockName`, `attrs`, etc.):
- A ''reference'' to the block they're currently visiting, `&$block`;
- the block's `$parent_block`; and
- the `$prev`ious block (for `make_before_block_visitor`), or the `$next` block (for `make_after_block_visitor`), respectively.
Those arguments are passed to the "block visitor" callbacks by `traverse_and_serialize_block(s)` during traversal. The block that the callback is currently visiting is passed ''by reference'' to allow modifying it, which is e.g. used to inject the `theme` attribute into Template Part blocks.
One major limitation of Block Hooks is that they currently only work with templates, parts, and patterns that ''don't have any user modifications'' (i.e. that come straight from the corresponding theme files, rather than from the database). For WordPress 6.5, it is planned to change that to make Block Hooks work for templates, parts, and patterns that ''do'' have user modifications: #59646.
This will be implemented by storing an attribute on the "anchor" block. While working on that feature, it was found that the aforementioned callbacks will need to modify not only the currently visited `$block`, but also the `$parent_block` -- i.e. that the latter argument needs to be passed by reference as well. This is consistent with the requirement of adding an attribute to an anchor block, as it's not only the currently visited block that can serve as an anchor block (in the case of `before` or `after` sibling insertion), but also its parent (for `first_child` and `last_child` insertion).
If the `$parent_block` argument were to be changed to become a reference in a later WordPress version, this could be considered a backwards-compatibility breaking change. For this reason, this change is instead proposed for 6.4 already, which is the cycle during which the relevant functions were first introduced. This should have no impact on existing code, since nothing currently relies on `$parent_block` remaining unmodified by the respective callback, nor is anything currently modifying that argument.
Reviewed by hellofromTonya.
Merges [57038] to the 6.4 branch.
Props hellofromTonya.
Fixes#59776.
Built from https://develop.svn.wordpress.org/branches/6.4@57039
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This update includes the following bugfixes:
- Fix: Added a new block pattern for the home template that inherits the page query and fits the design of the home page. (more context on the theme repo: https://github.com/WordPress/twentytwentyfour/pull/706)
- Fix: Rely on parent theme data for block style.
- Fix: Categories for some patterns.
- Fix: Minor labeling issues
Follow-up to [56999], [56951], [56813], [56764], [56716].
Reviewed by flixos90, jorbin.
Merges [57036] to the 6.4 branch.
Props anlino, beafialho, desrosj, devmuhib, didierjm, fabiorubioglio, flixos90, hanneslsm, hellofromTonya, huzaifaalmesbah, ktaron, luminuu, mshowes, onemaggie, phillsav, poena, rajinsharwar, richtabor, shailu25.
Fixes#59770, #59759.
Built from https://develop.svn.wordpress.org/branches/6.4@57037
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When setting an RTL language under Settings → General, some RTL stylesheets were not loaded, with LTR stylesheets being loaded instead, meaning that some blocks were not displayed correctly.
This commit ensures that all appropriate RTL stylesheets are loaded when selecting an RTL language.
Follow-up to [56524].
Reviewed by hellofromTonya.
Merges [57028] to the 6.4 branch.
Props mukesh27, maahrokh, hellofromTonya, joemcgill, huzaifaalmesbah, rajinsharwar, devmuhib, swissspidy.
Fixes#59715.
Built from https://develop.svn.wordpress.org/branches/6.4@57031
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
A collection of fixes for `wp_prime_option_caches()`:
* cache arrays and objects in their serialized form for consistency with `get_option()` and `wp_load_alloptions()`
* prevent repeat database queries for falsey and known non-existent options (notoptions)
Additional tests for `wp_prime_option_caches()` to ensure:
* additional database queries are not made repriming options (known, known-unknown and alloptions)
* cache is primed consistently
* `get_option()` returns a consistent value regardless of how it is primed
* database queries do not contain earlier primed options
* `get_option` does not prime the cache when testing the cache has been successfully primed
Fixes a test for `wp_prime_option_caches_by_group()` to ensure `get_option` does not prime the cache when testing the cache has been successfully primed.
Follow up to [56445],[56990],[57013].
Reviewed by flixos90, hellofromTonya, joemcgill.
Merges [57029] to the 6.4 branch.
Props peterwilsoncc, costdev, flixos90, hellofromTonya, mikeschroder, joemcgill.
Fixes#59738. See #58962.
Built from https://develop.svn.wordpress.org/branches/6.4@57030
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Merges [57018] to 6.4 branch.
Tweaks the 6.4 about pages in a couple of ways:
- Decouples the background from the 6.4 logo so the logo can move for RTL.
- Updates a color to improve color contrast.
- Help prevent overlap of long text strings with 6.4 logo.
- Ensure background isn't dark when no background is used on mobile.
Props nudge, jorbin, afercia, sumitsingh, sabernhardt.
See #59289, #59664.
Backport reviewed by hellofromTonya and joedolson.
Built from https://develop.svn.wordpress.org/branches/6.4@57025
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add a conditional to prevent the `prefers-reduced-motion` `ajaxComplete` listener from observing events not occurring in the plugin installation screen. Improve handling of settings data test.
The listener observing `ajaxComplete` in [56541] was intercepting all `ajaxComplete` events, creating potential for unexpected errors in unrelated functions.
Props bplv, afercia, rudlinkon, hellofromTonya, huzaifaalmesbah, joedolson, jorbin.
Reviewed by jorbin.
Merges [57022] to the 6.4 branch.
Fixes#59689.
Built from https://develop.svn.wordpress.org/branches/6.4@57024
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56535 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes a bug during the database upgrade process where a theme's `functions.php` file may not be loaded, leading to potential exceptions if the theme's pattern files use symbols (classes, functions, constants, etc.) that are declared only when the `functions.php` file is loaded. To do so, a check for `wp_get_active_and_valid_themes()` is added early to `_register_theme_block_patterns()`, which returns early if no active or valid themes are returned.
Props fabiankaegy, rajinsharwar, pbiron, huzaifaalmesbah, hellofromTonya, peterwilsoncc, joemcgill.
Reviewed by hellofromTonya.
Merges [57021] to the 6.4 branch.
Fixes#59723.
Built from https://develop.svn.wordpress.org/branches/6.4@57023
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56534 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As a follow up to [56507], 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 [57019] to the 6.4 branch.
Fixes#59736.
See #58154.
Built from https://develop.svn.wordpress.org/branches/6.4@57020
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Rename the option cache priming functions to more closely follow the naming convention used by other cache priming functions.
* `wp_load_options()` becomes `wp_prime_option_caches()`
* `wp_load_options_by_group()` becomes `wp_prime_option_caches_by_group()`
The unit test files and classes are renamed accordingly.
Unlike the existing cache priming functions, these functions were introduced with the intention of being public so use the `wp_` prefix rather than the `_` prefix used by the functions initially introduced as private functions but since made public.
Follow up to [56445],[56990].
Props flixos90, peterwilsoncc, joemcgill, SergeyBiryukov, desrosj.
Reviewed by flixos90.
Merges [57013] to the 6.4 branch.
Fixes#58962.
Built from https://develop.svn.wordpress.org/branches/6.4@57016
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Merges [57012] to 6.4 branch.
[56834] adjusted the order of activity inside the rest server responses. This lead to the rest_pre_serve_request filter potentially blocking the sending of the no cache headers. This moves that action back to being after the sending of no cache headers has finished to restore the pre 6.3.2 order of these two actions.
Props perrelet, SergeyBiryukov, peterwilsoncc, hellofromTonya.
Fixes#59722.
Built from https://develop.svn.wordpress.org/branches/6.4@57014
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The Customizer live preview broke because of [56635], however the root cause for the bug was a lower-level problem that had been present since WordPress 5.8: The block theme specific functions `_add_default_theme_supports()` and `wp_enable_block_templates()` were being hooked into the `setup_theme` action, which fires too early to initialize theme features. Because of that, theme functionality would be initialized before the current theme setup being completed. In the case of the Customizer, that includes overriding which theme is the current theme entirely, thus leading to an inconsistent experience.
This changeset fixes the bug by moving those two callbacks to the `after_setup_theme` action, which is the appropriate action to initialize theme features.
Props karl94, hellofromTonya, joemcgill, flixos90.
Merges [57009] to the 6.4 branch.
Fixes#59732.
See #18298, #53397, #54597.
Built from https://develop.svn.wordpress.org/branches/6.4@57010
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This update includes updates to patterns to correct color issues and some code quality fixes.
Follow-up to [56951], [56813], [56764], [56716].
Props luminuu, richtabor, onemaggie, kafleg, swissspidy, huzaifaalmesbah, neilorangepeel, shailu25, lada7042, mukesh27, nilovelez, jorbin.
Merges [56999] and [57003] to the 6.4 branch.
Fixes#59711.
Built from https://develop.svn.wordpress.org/branches/6.4@57005
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This clearly separates these functions which are intended to be used by external developers from the existing `_prime_*_caches()` functions which are primarily intended for internal usage. The term "load" is additionally more accessible than "prime".
This changeset renames the above function, as well as the wrapper function `prime_options_by_group()` to `wp_load_options_by_group()`.
Props peterwilsoncc, joemcgill, hellofromTonya, poran766, flixos90.
Merges [56990] to the 6.4 branch.
Fixes#58962.
Built from https://develop.svn.wordpress.org/branches/6.4@57004
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This simplifies the logic within the `slack-notifications` and `failed-workflow` steps in GitHub Action workflows to use the `contains()` function and object filtering.
This makes it simpler to perform the needed checks by removing the need to list out every single dependent job defined in `needs`.
Merges [56660] to the 6.4 branch.
See #58867.
Built from https://develop.svn.wordpress.org/branches/6.4@57000
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Some blocks do not have content. For duotone support, blocks without content still need to run through the `render_duotone_support()` to render their duotone CSS.
This fix makes the duotone compatible with the enhanced pagination (introduced in 6.4.0) by making sure that the CSS is always on the page, even when the posts have no featured image. It also prevents the duotone from interfering with other blocks using `wp_unique_id()`.
References:
* [https://github.com/WordPress/gutenberg/pull/55415 Gutenberg PR 55415]
Follow-up to [56226].
Props cbravobernal, luisherranz, hellofromTonya, isabel_brison, jorbin.
Reviewed by costdev.
Merges [56991] and [56996] to the 6.4 branch.
Fixes#59694.
Built from https://develop.svn.wordpress.org/branches/6.4@56997
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56508 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Make layout support compatible with enhanced pagination by ensuring that generated class names are stable across pagination, even when the number of rendered posts is different.
With the previous implementation of enhanced pagination, the CSS corresponding to each block was not detected. Therefore, for enhanced pagination to work correctly, the CSS of the blocks present in the Post Template must be stable on all pages.
The number of posts rendered by the Query block is always the same, except in the last page, where it can be only a fraction. If any of the blocks rendered by the Post Template used the `wp_unique_id` function, the ID (which is incremental) would have been different than in the previous pages and the class names would have varied.
This is remediated by this changeset by replacing the usage of `wp_unique_id` in the layout support (which is used by the Query block) with an implementation that uses IDs that are incremental only for that block. That way, the generated class names are never affected by the number of times `wp_unique_id` runs.
Props luisherranz, andrewserong, isabel_brison, costdev, mukesh27, cbravobernal, hellofromTonya, jorbin.
Merges [56994] to the 6.4 branch.
Fixes#59681.
Built from https://develop.svn.wordpress.org/branches/6.4@56995
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56506 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The globals introduced in [56635] to cache the current theme directories in memory were not considering switching sites in a multisite network. This changeset addresses the bug including test coverage.
Props codex-m, jeremyfelt, costdev, joemcgill.
Merges [56974] to the 6.4 branch.
Fixes#59677.
See #18298.
Built from https://develop.svn.wordpress.org/branches/6.4@56986
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In [56765], theme block pattern files were cached to a transient as a performance enhancement. However, transients are not easily clearable when caches are flushed on environments not using a persistent cache, which can lead to errors if the theme files are renamed, edited, or moved.
This changes the caching mechanism to use `wp_cache_set()` instead, and caches these values to the global group so they are still persistent on environments using an object cache, and will be cleared by a cache flush.
In addition, the helper `_wp_get_block_patterns` has been moved `WP_Theme::get_block_patterns` for consistency with other block related theme methods and cache helpers for these values, `WP_Theme::get_pattern_cache` and `WP_Theme::set_pattern_cache`, have been made private.
Relevant unit tests updated.
Props afercia, flixos90, mukesh27, joemcgill.
Merges [56978] to the 6.4 branch.
Fixes#59633. See #59591, #59490.
Built from https://develop.svn.wordpress.org/branches/6.4@56979
git-svn-id: http://core.svn.wordpress.org/branches/6.4@56490 1a063a9b-81f0-0310-95a4-ce76da25c4cd
It was found that Template Part blocks were broken in the Site Editor, showing the `Template part has been deleted or is unavailable` message, due to a missing `theme` attribute.
This bug seems to have been introduced by [56896], whose goal was to only inject that attribute into the markup returned by the templates and patterns REST API endpoints but not on the frontend, in order to improve performance. It has been demonstrated locally that reverting that changeset fixes the bug.
Reverts [56896].
Props mmcalister, swisspidy, thelovelist, hellofromTonya, pbiron, Pauthake015, richtabor, nicolefurlan, huzaifaalmesbah, annezazu, kafleg, aegkr, sunitarai, shresthaaman, andraganescu, onemaggie, gziolo.
Fixes#59629.
Built from https://develop.svn.wordpress.org/trunk@56960
git-svn-id: http://core.svn.wordpress.org/trunk@56471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Reverts [56451] to avoid the following issues:
* missing the default `font-size` for anyone who does not use the size control.
* unintentional reduction in citation's `line-height` down to the `--pullquote--line-height` value (1.3 instead of 1.6).
With 6.4 RC1 happening shortly, this revert is necessary to avoid shipping this issues in the release, while giving the time needed to resolve in the next cycle.
Follow-up to [56451].
Props sabernhardt, nicolefurlan.
See #57854.
Built from https://develop.svn.wordpress.org/trunk@56959
git-svn-id: http://core.svn.wordpress.org/trunk@56470 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This adds a global environment variable to the Test old branches workflow to make the supported version more clear and easier to update in the future. This will also make it easier to reference in more places as this workflow grows.
See #58867.
Built from https://develop.svn.wordpress.org/trunk@56955
git-svn-id: http://core.svn.wordpress.org/trunk@56466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `PUPPETEER_SKIP_DOWNLOAD` environment variable is used to prevent Puppeteer from automatically downloading browser binaries.
It was removed in [56926] due to the migration to Playwright. However, because of the QUnit tests, Puppeteer is actually still a dependency.
Until those tests change, we have to keep this environment variable to prevent unnecessary downloads on CI.
Props SergeyBiryukov.
Fixes#59517.
Built from https://develop.svn.wordpress.org/trunk@56954
git-svn-id: http://core.svn.wordpress.org/trunk@56465 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When applying updates to HTML, one step was left out in [56941] which updated the position of the end of the current tag. This made it possible to create bookmarks with null or earlier end positions than their start position. This in turn broke the Directive Processor in Gutenberg during the backport of changes from Core into Gutenberg.
In this commit, after applying updates, the HTML document is now scanned fully to the end of the current tag, updating the internal pointer to its end, so that nothing else will be broken or misaligned.
Follow-up to [56941].
Props dmsnell.
Fixes#59643.
Built from https://develop.svn.wordpress.org/trunk@56953
git-svn-id: http://core.svn.wordpress.org/trunk@56464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The required version was previously set to two different values:
* 4.7 in the theme's `functions.php` file.
* 4.9.6 in theme headers, because of the `the_privacy_policy_link()` function usage in `footer.php`.
However, as `the_privacy_policy_link()` call is wrapped in a `function_exists()` check, it does not affect the requirements in practice.
This commit aims to correct the discrepancy by updating theme headers to match the actual required WP version.
Follow-up to [43808], [43892].
Props poena, kafleg, felipeelia, audrasjb, huzaifaalmesbah, shailu25, nicolefurlan, oglekler.
Fixes#59557.
Built from https://develop.svn.wordpress.org/trunk@56952
git-svn-id: http://core.svn.wordpress.org/trunk@56463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Resyncing changes for TT4 into Core.
Changes include:
* Reformatted all the patterns for readability.
* Bugfixes in the markup and improvements on the string translation functions.
* Renaming of some patterns, making them consistent with the content they show and whether they are simple patterns, full-page patterns or patterns meant to replace templates.
Follow-up to [56813], [56764], [56716].
Props richtabor, onemaggie, luminuu, shailu25, dunhakdis, shivashankerbhatta, dajeema, enodekciw, kafleg, viralsampat, glendaviesnz, beafialho, webmandesign, huzaifaalmesbah, gregfuller, benharri.
Fixes#59640.
Built from https://develop.svn.wordpress.org/trunk@56951
git-svn-id: http://core.svn.wordpress.org/trunk@56462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Also includes updates to the contribute, credits, freedom and privacy pages.
Props luminuu, rmartinezduque, estelaris, jorbin, mukesh27, cbringmann, richtabor, annezazu, nudge, ohia, acirujano, elmastudio, cathibosco1, sereedmedia, markoserb, joen. (Also someone named Allison who I am going to guess is Taylor Alison Swift but has no avatar so I will never know)
Built from https://develop.svn.wordpress.org/trunk@56950
git-svn-id: http://core.svn.wordpress.org/trunk@56461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Prevent the saving of invalid timezone string in to the database on the options pages. If an invalid timezone is submitted it is ignored and the setting remains unchanged.
This prevents a warning or fatal (depending on the PHP version) from being thrown by an invalid timezone setting on the Settings > General page.
Props ankit-k-gupta, costdev, huzaifaalmesbah, mrinal013, nicolefurlan, oglekler.
Fixes#58814.
Built from https://develop.svn.wordpress.org/trunk@56949
git-svn-id: http://core.svn.wordpress.org/trunk@56460 1a063a9b-81f0-0310-95a4-ce76da25c4cd