During work on #59399, it was discovered that ''sibling'' block insertion wasn't likely going to work the way it was planned, which required devising an alternative solution. This new solution requires some changes to `traverse_and_serialize_block(s)`:
- Change the signature of the existing callback such that:
- the return value is a string that will be prepended to the result of the inner block traversal and serialization;
- the function arguments are: a ''reference'' to the current block (so it can be modified inline, which is important e.g. for `theme` attribute insertion), the parent block, and the previous block (instead of the block index and chunk index).
- Add a second callback argument to `traverse_and_serialize_block(s)`, which is called ''after'' the block is traversed and serialized.
- Its function arguments are a reference to the current block, the parent block, and the next block.
Props gziolo.
Fixes#59412. See #59313.
git-svn-id: https://develop.svn.wordpress.org/trunk@56644 602fd350-edb4-49c9-b593-d223f7449a82
Adds lightbox as a valid setting to `WP_Theme_JSON` class and as an image block setting in theme.json.
Props czapla, costdev, desrosj.
Fixes#59393.
git-svn-id: https://develop.svn.wordpress.org/trunk@56643 602fd350-edb4-49c9-b593-d223f7449a82
Following [56635], a fatal error occurred in `load-styles.php` leading to admin styles not working, because of a `has_filter()` call being added to `get_stylesheet_director()` and `get_template_directory()`.
This changeset adds `has_filter()` to `wp-admin/includes/noop.php` to prevent such errors. The lack of loading the function does not cause any unintended side effects itself.
Props iandunn, adamsilverstein.
Fixes#59417.
See #18298.
git-svn-id: https://develop.svn.wordpress.org/trunk@56641 602fd350-edb4-49c9-b593-d223f7449a82
Make the theme details modals in the Customizer and at Appearance > Themes consistent. Change the order of controls so both modals are in the same sequence, center all controls in both desktop and mobile views, and change delete link color to meet color contrast requirements.
Props trishasalas, afercia, melchoyce, karmatosed, cathibosco1, michaelarestad, joedolson, petitphp, mikinc860.
Fixes#59372. See #59371, #40822.
git-svn-id: https://develop.svn.wordpress.org/trunk@56639 602fd350-edb4-49c9-b593-d223f7449a82
Add alt text to the `wp.getMediaItem` method in the XML-RPC API. Allows users to fetch alt text as a first-class member of a media object.
Props thomashorta, joedolson, jivygraphics, stephenerdelyi, mukesh27, whyisjake.
Fixes#58582.
git-svn-id: https://develop.svn.wordpress.org/trunk@56637 602fd350-edb4-49c9-b593-d223f7449a82
Adjust display of user profile labels on small screens so they are consistent with the layout used elsewhere.
Props nandhuraj, costdev, sabernhardt, sarathar, vivekawsm.
Fixes#58493.
git-svn-id: https://develop.svn.wordpress.org/trunk@56636 602fd350-edb4-49c9-b593-d223f7449a82
While generally the functions `get_template_directory()` and `get_stylesheet_directory()` were long recommended to use to get the parent or child theme directory, the `TEMPLATEPATH` and `STYLESHEETPATH` constants were still used in a few places in core, most importantly in template related logic.
The remaining usage was problematic as it prevented testability of certain key components of WordPress core.
This changeset replaces all remaining usage with the corresponding functions and effectively marks these constants as deprecated. It also adds test coverage accordingly and even unlocks some existing, previously commented out test coverage to work as expected.
Performance of the new approach has been benchmarked and shows no notable differences. Yet, given that the current theme directories are not expected to change within a regular WordPress page load, the `get_template_directory()` and `get_stylesheet_directory()` functions were amended with in-memory caching of the result, unless one of the defining values is being filtered.
Props thekt12, spacedmonkey, mukesh27, aaroncampbell, scribu, lloydbudd, cais, chipbennett, toscho, omarabid, CrazyJaco, DrewAPicture, obenland, wonderboymusic, nacin, helen, dd32, chriscct7, SergeyBiryukov, swissspidy, joemcgill, flixos90.
Fixes#18298.
git-svn-id: https://develop.svn.wordpress.org/trunk@56635 602fd350-edb4-49c9-b593-d223f7449a82
In [56618], three functions (`insert_inner_block`, `prepend_inner_block`, and `append_inner_block`) were introduced. They were meant to be used for insertion of hooked blocks; however, it was discovered that the original idea wouldn't work for sibling insertion. Instead, a different approach will be taken (see #59412), and these functions are no longer needed and can thus be removed.
Reverts [56618].
See #59412, #59385, #59313.
git-svn-id: https://develop.svn.wordpress.org/trunk@56634 602fd350-edb4-49c9-b593-d223f7449a82
It is best to always escape the complete value of an attribute, not a partial value, as otherwise the escaping could be (partially) undone when the values are joined together.
While the hardcoded hyphen in this case don't necessarily create that risk, it may change to a value which could be problematic, so making it a habit to escape the value in one go is best practice.
Escaping the complete value also means that a single `esc_attr()` call can be used instead of two.
Follow-up to [14444], [16652], [55616], [56632].
See #58831.
git-svn-id: https://develop.svn.wordpress.org/trunk@56633 602fd350-edb4-49c9-b593-d223f7449a82
This changeset restricts edit term link generation if the user lacks the `edit_term` cap in order to prevent PHP 8.1+ deprecations shown when a user lacks this
capability and `get_edit_term_link()` returns null.
Props thelovekesh, jrf.
Fixes#59336.
git-svn-id: https://develop.svn.wordpress.org/trunk@56631 602fd350-edb4-49c9-b593-d223f7449a82
Changes output of `wp_get_post_content_block_attributes` to return null if Post Content block doesn’t exist or empty array if it has no attributes.
Props flixos90, mukesh27.
Fixes#59358.
git-svn-id: https://develop.svn.wordpress.org/trunk@56629 602fd350-edb4-49c9-b593-d223f7449a82
This introduces classes for the "Log in", "Register" and "Lost your password?" links in the footer of `wp-login.php` forms so that they may be easily targeted for individual styling.
The new classes are:
- `.wp-login-log-in`
- `.wp-login-register`
- `.wp-login-lost-password`
Props wparslan, thomasplevy, rajinsharwar, audrasjb, joedolson, costdev.
Fixes#57590.
git-svn-id: https://develop.svn.wordpress.org/trunk@56628 602fd350-edb4-49c9-b593-d223f7449a82
This updates the `regenerator-runtime` library to version `0.14.0`.
Props rajinsharwar, oglekler.
Fixes#59078.
git-svn-id: https://develop.svn.wordpress.org/trunk@56626 602fd350-edb4-49c9-b593-d223f7449a82
This is a follow-up to [56452] in which a new filter hook was added to `get_available_post_mime_types()` to override a potentially slow query. This renames the previous hook from `get_available_post_mime_types` to `pre_get_available_post_mime_types` for clarity.
Props rcorrales, emrikol, johnbillion, joemcgill, mukesh27.
Fixes#52759.
git-svn-id: https://develop.svn.wordpress.org/trunk@56623 602fd350-edb4-49c9-b593-d223f7449a82
In PHPUnit 10.3.5, 9.6.13 and 8.5.34, the child processes used for process isolation now use temporary files to communicate their result to the parent process.
This caused a failure in some tests that set the `open_basedir` PHP directive to a value that did not include `sys_get_temp_dir()`.
This adds `sys_get_temp_dir()` to the `open_basedir` value set by the tests to ensure that permission is still granted for the temporary directory.
PHPUnit uses `sys_get_temp_dir()`. To ensure the result is the same, Core's `get_temp_dir()` function is not used.
References:
- https://github.com/sebastianbergmann/phpunit/issues/5356
Props desrosj, mukesh27, SergeyBiryukov, costdev.
Fixes#59394.
git-svn-id: https://develop.svn.wordpress.org/trunk@56622 602fd350-edb4-49c9-b593-d223f7449a82
This commit enhances the performance of the get_block_theme_folders function by introducing a new method called get_block_template_folders within the WP_Theme class. Previously, this function suffered from poor performance due to repeated file lookups using file_exists. The new method implements basic caching, storing the result in the theme's cache, similar to how block themes are cached in the block_theme property (see [55236]).
Additionally, this change improves error handling by checking if a theme exists before attempting to look up the file. It also enhances test coverage.
Props spacedmonkey, thekt12, swissspidy, flixos90, costdev, mukesh27.
Fixes#58319.
git-svn-id: https://develop.svn.wordpress.org/trunk@56621 602fd350-edb4-49c9-b593-d223f7449a82
Introduces two new functions `traverse_and_serialize_blocks` and `traverse_and_serialize_block` with the additional `$callback` argument. It is possible to pass parent block, block index, chunk index to the callback argument.
Reverts changes applied to `serialize_blocks` and `serialize_block` in #59327 with [56557].
Props ockham, mukesh27.
See #59313.
git-svn-id: https://develop.svn.wordpress.org/trunk@56620 602fd350-edb4-49c9-b593-d223f7449a82
In [50776], the `filter_set_block_editor_settings_post()` callback was introduced for use in block editor settings tests.
This contained a reference to an `$allowed_block_types` parameter, which doesn't exist.
This changes the reference to `$editor_settings`.
Follow-up to [50776].
Props david.binda, mukesh27, SergeyBiryukov.
Fixes#59391.
git-svn-id: https://develop.svn.wordpress.org/trunk@56619 602fd350-edb4-49c9-b593-d223f7449a82
For #59313, we need to implement functions to insert a given parsed block into another parsed block's inner blocks, and to prepend and append to that array, respectively.
We will use those functions in combination with `traverse_and_serialize_blocks` (see #59327) to implement automatic insertion of hooked blocks into block templates and patterns.
Props gziolo.
Fixes#59385.
git-svn-id: https://develop.svn.wordpress.org/trunk@56618 602fd350-edb4-49c9-b593-d223f7449a82
In [52190], some new instances of the `join()` alias were introduced in the test suite.
Using the canonical function name for PHP functions is strongly recommended, as aliases may be deprecated or removed without (much) warning.
This replaces the new `join()` uses with the canonical `implode()` function name.
Follow-up to [46182], [49193], [49805], [52190].
Props david.binda, mukesh27.
Fixes#59389.
git-svn-id: https://develop.svn.wordpress.org/trunk@56616 602fd350-edb4-49c9-b593-d223f7449a82
Adjusts root padding for synced patterns in the editor to avoid discrepancies with the front end view.
Props aaronrobertshaw, mukesh27.
Fixes #59359.
git-svn-id: https://develop.svn.wordpress.org/trunk@56615 602fd350-edb4-49c9-b593-d223f7449a82
Adds a new background block support with the ability to set a background image on blocks that opt into it.
Props andrewserong, mukesh27.
Fixes#59357.
git-svn-id: https://develop.svn.wordpress.org/trunk@56614 602fd350-edb4-49c9-b593-d223f7449a82
The dimension attributes `width` and `height` should be present on every image in order to avoid layout shifts and be able to leverage WordPress core's image loading optimization functionality.
This changeset adds dimension attributes to the `core/image` blocks used in block patterns in Twenty Twenty-Two, where this is particularly critical as WordPress core cannot backfill the attributes for those images, as their sources are not part of the Media Library.
Props spacedmonkey, thekt12, mukesh27, flixos90.
Fixes#59256.
git-svn-id: https://develop.svn.wordpress.org/trunk@56613 602fd350-edb4-49c9-b593-d223f7449a82
The `wp_get_loading_optimization_attributes()` function, which was introduced in 6.3, based on the now deprecated `wp_get_loading_attr_default()` function introduced in 5.5, relies on a `$context` parameter based on which it may alter its behavior and the attributes returned. So far, it has only supported context values used within WordPress core.
This changeset decouples the behaviors of the function from specific contexts, allowing for more flexibility. Theme and plugin developers will be able to rely on their own context values when rendering images in non-standard ways, rather than being forced to use a core context, to get the loading optimization benefits the function provides.
As part of this change, a `wp_loading_optimization_force_header_contexts` filter is introduced, which allows filtering the map of context values and whether they should be considered header contexts, i.e. i.e. any image having one of these contexts will be assumed to appear above the fold.
Props mukesh27, costdev, flixos90.
Fixes#58894.
git-svn-id: https://develop.svn.wordpress.org/trunk@56612 602fd350-edb4-49c9-b593-d223f7449a82
Some custom post types or taxonomies may not need the Quick Edit functionality, in which case adding hidden fields and rendering the form with the data to edit would be redundant.
This commit introduces two filters for more granular control:
* `quick_edit_enabled_for_post_type`
* `quick_edit_enabled_for_taxonomy`
Follow-up to [8857], [9083], [9098].
Props garyc40, sabernhardt, mukesh27, costdev, oglekler, wyrfel, peterwilsoncc, faguni22, robinwpdeveloper, webcommsat, johnbillion, azaozz, hellofromTonya, GunGeekATX, Jick, mikeschinkel, jane, nacin, helen, wonderboymusic, DrewAPicture, SergeyBiryukov.
Fixes#16502, #19343, #57596.
git-svn-id: https://develop.svn.wordpress.org/trunk@56611 602fd350-edb4-49c9-b593-d223f7449a82
In order to implement Block Hooks (see #59313), we added block_hooks field to the WP_Block_Type class, as well as to block registration related functions. In this follow-up, new helper function gets introduced that is going to compute the list of hooked blocks by other registered blocks for a given block type.
Extracted from https://github.com/WordPress/wordpress-develop/pull/5158 and covered with unit tests.
Props ockham.
Fixes#59383.
git-svn-id: https://develop.svn.wordpress.org/trunk@56610 602fd350-edb4-49c9-b593-d223f7449a82
In the `WP_Hook` class the function `array_keys` was called every time an array of hook priorities was needed. For sites with lots of filters or actions, this would result in thousands of calls to the `array_keys` function, which uses server resources. Instead of recomputing this array every time it is needed, only compute it when filters are added and removed, then store the result as a class property. Improve unit tests to ensure this behaviour is tested.
Props spacedmonkey, bor0, flixos90, hellofromTonya, mukesh27.
Fixes#58458.
git-svn-id: https://develop.svn.wordpress.org/trunk@56609 602fd350-edb4-49c9-b593-d223f7449a82
In [56603], support was added for `aria-live` and `hidden` attributes in `safecss_filter_attr()`.
This adds a `@since` annotation to document this change.
Follow-up to [56603].
Props mukesh27.
See #57791.
git-svn-id: https://develop.svn.wordpress.org/trunk@56608 602fd350-edb4-49c9-b593-d223f7449a82
Adds a new text orientation option to the typography block support, implemented with CSS writing-mode.
Props poena.
Fixes#59306.
git-svn-id: https://develop.svn.wordpress.org/trunk@56605 602fd350-edb4-49c9-b593-d223f7449a82
Adds support for buttons and headings to the colors and elements block supports, allowing button and heading element colors to be changed on individual blocks.
Props aaronrobertshaw.
Fixes#59309.
git-svn-id: https://develop.svn.wordpress.org/trunk@56604 602fd350-edb4-49c9-b593-d223f7449a82
Allow admin notices to be created with additional attributes. Test attributes include `hidden`, `data-*`, and `role="*"` values, which are all in use in various admin notices across core.
This commit adds `aria-live` and `hidden` to the KSES global attributes array to support core usages.
Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599], [56600], [56601], [56602].
Props costdev, joedolson.
See #57791.
git-svn-id: https://develop.svn.wordpress.org/trunk@56603 602fd350-edb4-49c9-b593-d223f7449a82
In a handful of admin notices, a `tabindex` attribute is set so that JS can move focus to the notice `div`. Rather than adding `tabindex` to globally accepted attributes for `wp_kses_post()`, move the assignment of `tabindex` into the JS handlers that display those notices. The attribute is only relevant if JS is running, so there is no reason to add it in the original HTML notice.
Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599], [56600], [56601].
Props costdev, joedolson.
See #57791.
git-svn-id: https://develop.svn.wordpress.org/trunk@56602 602fd350-edb4-49c9-b593-d223f7449a82
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
git-svn-id: https://develop.svn.wordpress.org/trunk@56599 602fd350-edb4-49c9-b593-d223f7449a82
Adds further usages of `wp_admin_notice()` in the root level of `/wp-includes/` on `.error` and `.notice-info`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590].
Props joedolson, costdev.
See #57791.
git-svn-id: https://develop.svn.wordpress.org/trunk@56597 602fd350-edb4-49c9-b593-d223f7449a82
In the get_option function, a cache lookup for the notoptions key is performed, which stores an array of keys for options known not to exist. This optimization prevents repeated database queries when certain options are requested. However, the cache lookup for notoptions was conducted before checking if the requested option exists in the cache. Given that it's more likely that the option does exist, this commit reorders the checks to first verify the option's existence in the cache before confirming its absence. This adjustment reduces redundant queries and also eliminates an unnecessary cache lookup, improving overall performance.
Props spacedmonkey, costdev, flixos90, azaozz.
Fixes#58277.
git-svn-id: https://develop.svn.wordpress.org/trunk@56595 602fd350-edb4-49c9-b593-d223f7449a82
Test files should comply with the naming conventions accepted by PHPUnit, not with the WP naming conventions.
While the `WordPress.File.FileName` sniff makes a best effort to prevent throwing errors for files containing test classes, the recommended manner to deal with test files is to exclude the complete test directory from being subject to this sniff.
This updates the ruleset to follow the recommendation.
Follow-up to [42346], [45607].
Props jrf.
See #59161.
git-svn-id: https://develop.svn.wordpress.org/trunk@56594 602fd350-edb4-49c9-b593-d223f7449a82
This commit:
* Adds section headers to the ruleset file.
* Organizes all directives in their respective sections.
No functional changes.
Props jrf.
See #59161.
git-svn-id: https://develop.svn.wordpress.org/trunk@56593 602fd350-edb4-49c9-b593-d223f7449a82