Correct an issue where meta values containing characters like quote `”` could not be previewed on published posts. The function `update_metadata` expects data to be slashed.
Also, add a test to confirm that storing JSON data which requires slashing in autosave meta works as expected, and improve naming for a data provider added in [56714].
Follow up to [56714].
Props mukesh27, spacedmonkey.
Fixes#20564.
git-svn-id: https://develop.svn.wordpress.org/trunk@56745 602fd350-edb4-49c9-b593-d223f7449a82
In the context of register_block_script_handle, the get_block_asset_url function may return false when an empty string is provided as the input. This behavior is intended to prevent the generation of invalid URLs. However, when the script loading strategy is set to "defer" while passing false, it triggers a "doing it wrong" message.
This situation becomes problematic, especially for scenarios where the scripts haven't been built yet. In such cases, the realpath call returns an empty string because the file doesn't exist. To address this issue, we now perform a simple check to ensure that the script URI is not empty before applying the "defer" loading strategy. This adjustment prevents unnecessary deferral of loading for scripts with empty URIs.
Follow on from [56683] and [56033].
Props kebbet, mukesh27, swissspidy, westonruter, spacedmonkey.
Fixes#59475
git-svn-id: https://develop.svn.wordpress.org/trunk@56744 602fd350-edb4-49c9-b593-d223f7449a82
This removes ignore annotations which are unnecessary due to the configuration in the `phpcs.xml.dist` ruleset already taking care of this.
Follow-up to [45611], [50146], [50148], [50586], [50822], [56738].
Props jrf.
See #59161.
git-svn-id: https://develop.svn.wordpress.org/trunk@56743 602fd350-edb4-49c9-b593-d223f7449a82
Replace calls to `property_exists` with `instanceof WP_Block_Type` in block related functions. This change not only improves type safety but also enhances performance.
Follow on from [56678] and [56677].
Props gziolo, aristath, aaronrobertshaw, spacedmonkey.
Fixes#59453
git-svn-id: https://develop.svn.wordpress.org/trunk@56742 602fd350-edb4-49c9-b593-d223f7449a82
The `esc_url()` function expects to a string for `$url` parameter. There is no input validation within that function. The function contains a `ltrim()` which also expects a string. Passing `null` to this parameter results in `Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1+.
Tracing the stack back, a `null` is being passed to it within `next_posts()` when `get_next_posts_page_link()` returns `null` (it can return a string or `null`).
On PHP 7.0 to PHP 8.x, an empty string is returned from `esc_url()` when `null` is passed to it. The change in this changeset avoids the deprecation notice by not invoking `esc_url()` when `get_next_posts_page_link()` returns `null` and instead sets the `$output` to an empty string, thus maintain the same behavior as before (minus the deprecation notice).
Adds a test to validate an empty string is returned and the absence of the deprecation (when running on PHP 8.1+).
Follow-up to [11383], [9632].
Props codersantosh, nihar007, hellofromTonya, mukesh27, oglekler, rajinsharwar.
Fixes#59154.
git-svn-id: https://develop.svn.wordpress.org/trunk@56740 602fd350-edb4-49c9-b593-d223f7449a82
Follow-up for [56710]. Brings back the version specified in the `package.json` file.
Props ockham.
See #59411.
git-svn-id: https://develop.svn.wordpress.org/trunk@56739 602fd350-edb4-49c9-b593-d223f7449a82
This removes ignore annotations which are ignoring an error which would not be thrown for that code.
Includes tidying up the format of the ignore annotation:
* Customary one space between the `//` and the start of the comment.
* There should be no spaces in the comma-separated sniff list.
Follow-up to [45607], [47185], [49200], [53152].
Props jrf.
See #59161.
git-svn-id: https://develop.svn.wordpress.org/trunk@56738 602fd350-edb4-49c9-b593-d223f7449a82
Removes enqueuing the `'wp-edit-site'` stylesheet from the iframed assets in `_wp_get_iframed_editor_assets()`.
The global `$pagenow` is also removed as it is no longer used within the function.
References:
* [https://github.com/WordPress/gutenberg/pull/54254 Gutenberg PR 54254]
Props ellatrix, jorgefilipecosta, Mamaduka, mukesh27.
Follow-up to [56047], [53160].
Fixes#59456.
git-svn-id: https://develop.svn.wordpress.org/trunk@56736 602fd350-edb4-49c9-b593-d223f7449a82
Improves the text by removing an empty space at the end of a string within the "Default Data" help tab of the "Erase Personal Data".
Props azharckra, kebbet, krupalpanchal, mukesh27.
Follow-up to [53182].
Fixes#59473.
git-svn-id: https://develop.svn.wordpress.org/trunk@56734 602fd350-edb4-49c9-b593-d223f7449a82
Prior to this changeset, we did not seem to have any unit test coverage for the Patterns registry (`WP_Block_Patterns_Registry`).
With Block Hooks logic recently added ([56649]), it is particularly advisable to add some unit tests to the `get_registered()` and `get_all_registered()` methods to guard hooked block insertion against regressions.
Fixes#59476.
git-svn-id: https://develop.svn.wordpress.org/trunk@56733 602fd350-edb4-49c9-b593-d223f7449a82
Round 2 of package updates for 6.4. Beta 1 which includes disabling the rendering of the Font Library in Core.
The full list of changes are found here 641b696cd6.
Follow-up to [56710], [56713].
Props mikachan, mmaattiiaass, mamaduka, desrosj, ockham, hellofromTonya.
See #59411.
git-svn-id: https://develop.svn.wordpress.org/trunk@56728 602fd350-edb4-49c9-b593-d223f7449a82
Introduce a `_remove_theme_attribute_from_template_part_block()` function that can be used as a callback argument for `traverse_and_serialize_block(s)` on a parsed block tree in order to remove the `theme` attribute from all Template Part blocks found therein, and deprecate `_remove_theme_attribute_in_block_template_content()`.
Counterpart to `_inject_theme_attribute_in_template_part_block` from #59338 (which superseded `_inject_theme_attribute_in_block_template_content`, deprecated in #59452).
Props mukesh27.
Fixes#59460.
git-svn-id: https://develop.svn.wordpress.org/trunk@56724 602fd350-edb4-49c9-b593-d223f7449a82
The filter is only used within the `WP_Http::_get_first_available_transport()` method, which has been marked as deprecated in favor of `\WpOrg\Requests\Requests::get_transport_class()`.
Follow-up to [56655]
Props desrosj, hellofromTonya.
Fixes#58705.
git-svn-id: https://develop.svn.wordpress.org/trunk@56723 602fd350-edb4-49c9-b593-d223f7449a82
Move the now-deprecated function `_inject_theme_attribute_in_block_template_content` from `wp-includes/block-template-utils.php` to `wp-includes/deprecated.php`.
Follow-up [56719].
Props spacedmonkey, davidbaumwald, mukesh27.
See #59452.
git-svn-id: https://develop.svn.wordpress.org/trunk@56722 602fd350-edb4-49c9-b593-d223f7449a82
This updates the font and image files to include the correct file contents.
Follow up to [56716].
Props onemaggie, karmatosed.
See #59447.
git-svn-id: https://develop.svn.wordpress.org/trunk@56721 602fd350-edb4-49c9-b593-d223f7449a82
This aims to make the various resources on learn.wordpress.org more easily available.
Props jeherve, mikinc860, audrasjb, sabernhardt, courane01, devmuhib, dhrumilk, estelaris, hellofromTonya.
Fixes#58820.
git-svn-id: https://develop.svn.wordpress.org/trunk@56720 602fd350-edb4-49c9-b593-d223f7449a82
It can be replaced by passing `_inject_theme_attribute_in_template_part_block` as second argument to `traverse_and_serialize_blocks()`.
Per WordPress 6.4 Beta 1, there aren't going to be any more calls in Core to `_inject_theme_attribute_in_block_template_content()`.
Note that `_inject_theme_attribute_in_block_template_content` has always had `@access private` set in its PHPDoc.
Props gziolo.
Fixes#59452.
git-svn-id: https://develop.svn.wordpress.org/trunk@56719 602fd350-edb4-49c9-b593-d223f7449a82
This aims to make the login process more user-friendly.
Follow-up to [19875], [19880].
Props lancewillett, subrataemfluence, tejwanihemant, ankit-k-gupta, devmuhib, audrasjb, hellofromTonya, joemcgill.
Fixes#40762.
git-svn-id: https://develop.svn.wordpress.org/trunk@56718 602fd350-edb4-49c9-b593-d223f7449a82
This fix is relevant for options such as `gmt_offset` that use a filter to force a specific value regardless of what is stored in the database.
Props mamaduka, flixos90, mukesh27, spacedmonkey.
See #22192.
git-svn-id: https://develop.svn.wordpress.org/trunk@56717 602fd350-edb4-49c9-b593-d223f7449a82
Twenty Twenty-Four is designed to be flexible, versatile and applicable to any website. Its collection of templates and patterns tailor to different needs, such as presenting a business, blogging and writing or showcasing work. A multitude of possibilities open up with just a few adjustments to color and typography.
Twenty Twenty-Four comes with style variations and full page designs to help speed up the site building process, is fully compatible with the site editor, and takes advantage of new design tools introduced in WordPress 6.4.
Twenty-Four karat magic in the air!
Props onemaggie, luminuu, beafialho, chrisdesrochers, amedv, melchoyce, kafleg, jeffikus, poena, robpetrin, hiyascout, audrasjb, huzaifaalmesbah, fabiankaegy, jordesign, vcanales, shailu25, jessplease, juanfra, maneshtimilsina, sabernhardt, richtabor, travel_girl, kishanjasani, sofiashendi, nudge, gnanasekaran, marcelle42, bosskhj, oncecoupled, bijayyadav, barbmiller, devmuhib, lyndauwp, kraftbj, alaminfirdows, littlebigthing, dhamibirendra, jeffpaul, kopila47, rabmalin, aplauche, colorful-tones, khleomix, pbking, esratpopy, scruffian, alexandrebuffet, gpotter, pbwebd, anphira, suprsam, damonsharp, maurodf, soean, kawsaralameven, mhimon, rajinsharwar, labunchemjong, bonkerz, karmacharya50, aristath, mukesh27, mikachan, joedolson, aurooba, afercia, jffng, benimub, joen, tanvirul, jeryj, thelovekesh, mrwweb, nielslange, sergiomdgomes, binsaifullah, hanneslsm, masoudnkh, dhrumilk, dianeco, webmandesign, desrosj.
See #59447.
git-svn-id: https://develop.svn.wordpress.org/trunk@56716 602fd350-edb4-49c9-b593-d223f7449a82
Remove an extra call to `wp_restore_post_revision_meta` - the meta restore action is already hooked to `wp_restore_post_revision`.
Follow up to [56714].
Props: spacedmonkey.
Fixes#20564.
git-svn-id: https://develop.svn.wordpress.org/trunk@56715 602fd350-edb4-49c9-b593-d223f7449a82
Enable the storing of post meta in revisions including autosaves and previews:
Add a new argument `revisions_enabled` to the `register_meta` function which enables storing meta in revisions.
Add a new `wp_post_revision_meta_keys` filter which developers can use to control which meta is revisioned - it passes an array of the meta keys with revisions enabled as well as the post type.
Meta keys with revisions enabled are also stored for autosaves, and are restored when a revision or autosave is restored. In addition, meta values are now stored with the autosave revision used for previews. Changes to meta can now be previewed correctly without overwriting the published meta (see #20299) or passing data as a query variable, as the editor currently does to preview changes to the featured image.
Changes to meta with revisions enabled are considered when determining if a new revision should be created. A new revision is created if the meta value has changed since the last revision.
Revisions are now saved on the `wp_after_insert_post` hook instead of `post_updated`. The `wp_after_insert_post` action is fired after post meta has been saved by the REST API which enables attaching meta to the revision. To ensure backwards compatibility with existing action uses, `wp_save_post_revision_on_insert` function exits early if plugins have removed the previous `do_action( 'post_updated', 'wp_save_post_revision' )` call.
Props: alexkingorg, johnbillion, markjaquith, WraithKenny, kovshenin, azaozz, tv-productions, p51labs, mattheu, mikeschroder, Mamaduka, ellatrix, timothyblynjacobs, jakemgold, bookwyrm, ryanduff, mintindeed, wonderboymusic, sanchothefat, westonruter, spacedmonkey, hellofromTonya, drewapicture, adamsilverstein, swisspiddy.
Fixes#20564, #20299.
git-svn-id: https://develop.svn.wordpress.org/trunk@56714 602fd350-edb4-49c9-b593-d223f7449a82
This pre-fills category fields in the Quick/Bulk Edit form with their current status.
When bulk editing, if only some of the selected items are in a given category, the category's checkbox will display a line to indicate an indeterminate status.
Props pavelevap, scribu, chasedsiedu, helen, joshcanhelp, ubernaut, Cyberchicken, laumindproductscomau, SergeyBiryukov, Marcoevich, tomybyte, thinkluke, virtality-marketing-solutions, Michalooki, dmsnell, itecrs, pannelars, WHSajid, samba45, Mte90, johnbillion, tomluckies, soulseekah, francina, oglekler, ajmcfadyen, mukesh27, costdev.
Fixes#11302.
git-svn-id: https://develop.svn.wordpress.org/trunk@56712 602fd350-edb4-49c9-b593-d223f7449a82
When attachment pages are disabled, change the links from "View Attachment Page" to "View Media File".
Follow-up to [56657], [56658].
Props joedolson, ironprogrammer, oglekler.
Fixes#57913.
git-svn-id: https://develop.svn.wordpress.org/trunk@56711 602fd350-edb4-49c9-b593-d223f7449a82
`_wp_array_get()` is an expensive function, and it's called thousands of times on each page view on the front end. While the function performance was slightly improved in #58376, it is still called more times than it should be.
This commit aims to further optimize its usage:
* In many cases, `_wp_array_get()` can be replaced with a much simpler and faster `isset()` check.
* The `isset()` function is capable of checking nested arrays, so `isset( $foo['a']['b']['c'] )` will return false even if `$foo['a']` is unset, without throwing any errors or warnings.
* When `_wp_array_get()` cannot be directly replaced with `isset()`, it would be good practice to wrap it in an `isset()` function so that `_wp_array_get()` only runs when it needs to.
Original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/51116#51116 Performance improvement: Reduce the use of the _wp_array_get() function]
Follow-up to [55851], [56382].
Props aristath, jrf, spacedmonkey, mukesh27, swissspidy, hellofromTonya.
Fixes#59405.
git-svn-id: https://develop.svn.wordpress.org/trunk@56709 602fd350-edb4-49c9-b593-d223f7449a82
Author archives are only generated for users who created at least one post.
Prevent adding author archives to the XML sitemap for users who only authored pages
as the links would otherwise result in a 404.
Props zodiac1978, huzaifaalmesbah.
Fixes#57816.
git-svn-id: https://develop.svn.wordpress.org/trunk@56708 602fd350-edb4-49c9-b593-d223f7449a82
Uses `wp_kses()` instead of `esc_html()` to allow a list of HTML tags and protocols in the message rather than escaping them.
Why? To retain message readability in the browser and server logs, especially given that Core itself adds HTML to messages in functions, e.g. `_doing_it_wrong()` and each of the `_deprecated_*()` functions.
HTML tags allowed:
* `a href`
* `br`
* `code`
* `em`
* `strong`
Protocols allowed: `http` and `https`.
To inform extenders, it also documents that any other HTML tags or protocols need to be escaped before passing the message to this function to avoid them being stripped from the message.
Follow-up to [56530], [56705].
Props azaozz, costdev, flixos90, hellofromTonya, peterwilsoncc.
Fixes#57686.
git-svn-id: https://develop.svn.wordpress.org/trunk@56707 602fd350-edb4-49c9-b593-d223f7449a82
In [56682], the `print_emoji_styles` function was deprecated and a corresponding deprecation notice was added. In order to maintain backward compatibility, `print_emoji_styles` was retained as a hook into wp_print_styles. This resulted in the appearance of deprecation notices within the block editor. The root of this issue was the manual invocation of the `wp_print_styles` function in block-editor.php. To address this, the `print_emoji_styles` callback was manually removed, `wp_print_styles` was called, and the action was subsequently rehooked, resolving the deprecation notice within the block editor.
Props mamaduka, hellofromtonya, spacedmonkey.
See #58775.
git-svn-id: https://develop.svn.wordpress.org/trunk@56706 602fd350-edb4-49c9-b593-d223f7449a82
Uses `wp_trigger_error()` in `_doing_it_wrong()` and each `_deprecated_*()` function, i.e. instead of `trigger_error()`.
To avoid redundancy, uses `wp_trigger_error()` once. How? Saves each message to `$message` variable and then passes it to `wp_trigger_error()` at the end of the function.
Functions:
* _doing_it_wrong()
* _deprecated_function()
* _deprecated_constructor()
* _deprecated_class()
* _deprecated_file()
* _deprecated_argument()
* _deprecated_hook()
Follow-up to [56530].
Props azaozz, costdev, flixos90, hellofromTonya, peterwilsoncc.
See #57686.
git-svn-id: https://develop.svn.wordpress.org/trunk@56705 602fd350-edb4-49c9-b593-d223f7449a82
All existing calls of `get_hooked_blocks()` in non-test code are currently wrapped in an extra `array_keys()` call. This changeset absorbs that logic into the function and changes the structure of the return value accordingly.
Furthermore, this allows us to remove the extra `$relative_position` argument (introduced in [56673]) from the function again, as the same data can now be simply fetched via array access.
Props gziolo, spacedmonkey, mukesh27.
See #59383.
git-svn-id: https://develop.svn.wordpress.org/trunk@56704 602fd350-edb4-49c9-b593-d223f7449a82
This patch adds two new public methods to the HTML Tag Processor:
- `has_class()` indicates if a matched tag contains a given CSS class name.
- `class_list()` returns a generator to iterate over all the class names in a matched tag.
Included in this patch is a refactoring of the internal logic when matching
a tag to reuse the new `has_class()` function. Previously it was relying on
optimized code in the `matches()` function which performed byte-for-byte
class name comparison. With the change in this patch it will perform class
name matching on the decoded value, which might differ if a class attribute
contains character references.
These methods may be useful for running more complicated queries based
on the presence or absence of CSS class names. The use of these methods
avoids the need to manually decode the class attribute as reported by
`$process->get_attribute( 'class' )`.
Props dmsnell.
Fixes#59209.
git-svn-id: https://develop.svn.wordpress.org/trunk@56703 602fd350-edb4-49c9-b593-d223f7449a82
Inside a `next_tag()` loop it can be challenging to use breadcrumbs because they are only exposed inside the call to `next_tag()` via the `$query` arg.
In this patch a new method, `matches_breadcrumbs()`, is exposed which allows for querying within the `next_tag()` loop for more complicated queries.
This method exposes a wildcard `*` operator to allow matching ''any HTML tag'' that the currently-matched tag is a child or descendant of.
Props dmsnell, westonruter, mukesh27.
Fixes#59400.
git-svn-id: https://develop.svn.wordpress.org/trunk@56702 602fd350-edb4-49c9-b593-d223f7449a82
These two new unit tests document how Block Hooks behave with `first_child` and `last_child` relative positions. The hooked blocks will only get inserted in the case where the parent block has at least one child block present. While it seems like a limitation, in practice, it's hard to think of a case where the template would use a parent block without its children. It's more likely to happen with patterns in general, but in the case of patterns wired with the block theme, it also seems unlikely. The reasoning here is that out of the box, the block theme should produce a fully functional and valid HTML.
Props ockham.
See #59313.
Follow-up [56649].
git-svn-id: https://develop.svn.wordpress.org/trunk@56701 602fd350-edb4-49c9-b593-d223f7449a82
Backports the same changes to the webpack config in the Gutenberg plugin with https://github.com/WordPress/gutenberg/pull/50122.
The `warning` function from `@wordpress/warning` no longer worked correctly with webpack 5. In practice, it no longer called `console.warn`. To fix it, the usage of `process.env.NODE_ENV` check got replaced with another optional global: `SCRIPT_DEBUG`. All the tools used in the Gutenberg, get updated to work with this new constant, including `@wordpress/scripts`. This way, developers are able to guard code that should be run only in development mode. In WordPress core, the same constant needs to be added mostly to ensure that the code behind the check gets completely removed in production mode.
Fixes#59407.
git-svn-id: https://develop.svn.wordpress.org/trunk@56699 602fd350-edb4-49c9-b593-d223f7449a82
Refactors layout support to use a single Tag Processor instance and send one class at a time to `add_class()`.
Props dmsnell, hellofromTonya.
Fixes#59443.
git-svn-id: https://develop.svn.wordpress.org/trunk@56698 602fd350-edb4-49c9-b593-d223f7449a82
Add the event type (WordCamp, Meetup, etc) to the nearby events listing within the Dashboard's Events and News widget.
Props renyot, audrasjb, ankit-k-gupta, oglekler, devmuhib, dhruvishah2203, JeffPaul, anveshika, sarahwilliams889, ajakaroth.
Fixes#58947.
git-svn-id: https://develop.svn.wordpress.org/trunk@56697 602fd350-edb4-49c9-b593-d223f7449a82
PHPCS can now be run on the latest PHP version as all known PHP 8.x compatibility issues (in WPCS) have been fixed.
Follow-up to [49162], [56695].
Props jrf, desrosj.
See #59161.
git-svn-id: https://develop.svn.wordpress.org/trunk@56696 602fd350-edb4-49c9-b593-d223f7449a82