Commit Graph

22060 Commits

Author SHA1 Message Date
Tammie Lister
6ba0e95c88 Post WordPress 6.4 Beta 1 version bump.
Built from https://develop.svn.wordpress.org/trunk@56730


git-svn-id: http://core.svn.wordpress.org/trunk@56242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 20:18:23 +00:00
Tammie Lister
5fee993b2e WordPress 6.4 Beta 1.
Built from https://develop.svn.wordpress.org/trunk@56729


git-svn-id: http://core.svn.wordpress.org/trunk@56241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 19:54:21 +00:00
hellofromTonya
d02e84860f Editor: 2nd package updates for 6.4 Beta 1.
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.
Built from https://develop.svn.wordpress.org/trunk@56728


git-svn-id: http://core.svn.wordpress.org/trunk@56240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 19:11:22 +00:00
Tammie Lister
7df8ec6846 Bundled Themes: Twenty Twenty-Four is now the default theme.
Follow up to [56716].
Props desrosj.

See #59447.

Built from https://develop.svn.wordpress.org/trunk@56727


git-svn-id: http://core.svn.wordpress.org/trunk@56239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 17:33:20 +00:00
desrosj
e814c09465 Twenty Twenty-Four: Fix issue with theme screenshot.
Follow up to [56716] and [56725].

Props karmatosed.
Fixes #59447.
Built from https://develop.svn.wordpress.org/trunk@56726


git-svn-id: http://core.svn.wordpress.org/trunk@56238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 17:15:22 +00:00
desrosj
dd0700e374 General: Define the desired mime-type for WebP files.
Fixes #59463.
Built from https://develop.svn.wordpress.org/trunk@56725


git-svn-id: http://core.svn.wordpress.org/trunk@56237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 17:07:22 +00:00
Bernhard Reiter
dfd85ad690 Templates: Introduce _remove_theme_attribute_from_template_part_block.
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.
Built from https://develop.svn.wordpress.org/trunk@56724


git-svn-id: http://core.svn.wordpress.org/trunk@56236 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 17:01:24 +00:00
Sergey Biryukov
2c11f49301 HTTP API: Deprecate the http_api_transports filter.
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.
Built from https://develop.svn.wordpress.org/trunk@56723


git-svn-id: http://core.svn.wordpress.org/trunk@56235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 16:55:20 +00:00
Bernhard Reiter
c44e5163b6 Templates: Move old theme attr injection function to deprecated.php.
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.
Built from https://develop.svn.wordpress.org/trunk@56722


git-svn-id: http://core.svn.wordpress.org/trunk@56234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 16:49:21 +00:00
desrosj
0543b6216a Twenty Twenty-Four: Fix font and image assets.
This updates the font and image files to include the correct file contents.

Follow up to [56716].

Props onemaggie, karmatosed.
See #59447.
Built from https://develop.svn.wordpress.org/trunk@56721


git-svn-id: http://core.svn.wordpress.org/trunk@56233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 16:46:22 +00:00
costdev
a27059766b Toolbar: Link to Learn WordPress in the WordPress Logo menu.
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.
Built from https://develop.svn.wordpress.org/trunk@56720


git-svn-id: http://core.svn.wordpress.org/trunk@56232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 16:29:20 +00:00
Bernhard Reiter
70e906c26e Templates: Deprecate _inject_theme_attribute_in_block_template_content.
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.
Built from https://develop.svn.wordpress.org/trunk@56719


git-svn-id: http://core.svn.wordpress.org/trunk@56231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 16:19:21 +00:00
Sergey Biryukov
57f2930594 Login and Registration: Add /login.php as an alias for the login page.
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.
Built from https://develop.svn.wordpress.org/trunk@56718


git-svn-id: http://core.svn.wordpress.org/trunk@56230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 16:11:20 +00:00
Felix Arntz
7e1caa5b44 Options, Meta APIs: Fix follow up bug when comparing values for options using the pre_option_{$option} filter.
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.

Built from https://develop.svn.wordpress.org/trunk@56717


git-svn-id: http://core.svn.wordpress.org/trunk@56229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 15:55:18 +00:00
Tammie Lister
7b9c4a9dfe Bundled Themes: Import Twenty Twenty-Four, the new default theme for WordPress 6.4.
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.

Built from https://develop.svn.wordpress.org/trunk@56716


git-svn-id: http://core.svn.wordpress.org/trunk@56228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 15:50:23 +00:00
Adam Silverstein
3092085a60 Revisions: avoid double call to wp_restore_post_revision_meta when restoring post.
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.


Built from https://develop.svn.wordpress.org/trunk@56715


git-svn-id: http://core.svn.wordpress.org/trunk@56227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 15:44:19 +00:00
Adam Silverstein
89a99dba2f Revisions: framework for storing post meta revisions.
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.



Built from https://develop.svn.wordpress.org/trunk@56714


git-svn-id: http://core.svn.wordpress.org/trunk@56226 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 15:32:19 +00:00
Tammie Lister
36f1df7246 Update regenerated build files.
This adds in missed generated build files from commit for [56710].

Props desrosj.
See #59411.

Built from https://develop.svn.wordpress.org/trunk@56713


git-svn-id: http://core.svn.wordpress.org/trunk@56225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 15:27:22 +00:00
costdev
61cef87240 Quick/Bulk Edit: Pre-fill category fields with their status.
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.
Built from https://develop.svn.wordpress.org/trunk@56712


git-svn-id: http://core.svn.wordpress.org/trunk@56224 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 15:05:21 +00:00
hellofromTonya
61003dc0e7 Media: Change link text when attachment pages disabled.
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.
Built from https://develop.svn.wordpress.org/trunk@56711


git-svn-id: http://core.svn.wordpress.org/trunk@56223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 14:45:23 +00:00
Tammie Lister
04f631f232 Update editor related npm packages
The npm packages needed updating for 6.4 to the latest.

Props mikachan, mukesdpanchal27, luisherranz, youknowriad, tellthemachines, gziolo, ockham, michalczaplinski

Fixes #59411


Built from https://develop.svn.wordpress.org/trunk@56710


git-svn-id: http://core.svn.wordpress.org/trunk@56222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 14:23:26 +00:00
Sergey Biryukov
9bf6faff7c Editor: Reduce the use of the _wp_array_get() function to improve performance.
`_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.
Built from https://develop.svn.wordpress.org/trunk@56709


git-svn-id: http://core.svn.wordpress.org/trunk@56221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 13:47:20 +00:00
Pascal Birchler
72460848c9 Sitemaps: do not list users who only authored pages.
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.
Built from https://develop.svn.wordpress.org/trunk@56708


git-svn-id: http://core.svn.wordpress.org/trunk@56220 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 12:42:19 +00:00
hellofromTonya
534f200e48 General: Use wp_kses() in wp_trigger_error().
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.
Built from https://develop.svn.wordpress.org/trunk@56707


git-svn-id: http://core.svn.wordpress.org/trunk@56219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 12:38:19 +00:00
spacedmonkey
d969240845 Editor: Fix deprecation notice in block editor.
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.
Built from https://develop.svn.wordpress.org/trunk@56706


git-svn-id: http://core.svn.wordpress.org/trunk@56218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 12:28:22 +00:00
hellofromTonya
c8aea02b38 General: Use wp_trigger_error() in _doing_it_wrong() and _deprecated_*().
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.
Built from https://develop.svn.wordpress.org/trunk@56705


git-svn-id: http://core.svn.wordpress.org/trunk@56217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 11:51:19 +00:00
Bernhard Reiter
eeefd48208 Blocks: Have get_hooked_blocks() return blocks grouped by position.
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.
Built from https://develop.svn.wordpress.org/trunk@56704


git-svn-id: http://core.svn.wordpress.org/trunk@56216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 11:49:21 +00:00
Bernhard Reiter
2d9b5cb098 HTML API: Add class name utilities has_class() and class_list().
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.
Built from https://develop.svn.wordpress.org/trunk@56703


git-svn-id: http://core.svn.wordpress.org/trunk@56215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 09:17:18 +00:00
Bernhard Reiter
374bcd9b3d HTML API: Add matches_breadcrumbs() method for better querying.
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.
Built from https://develop.svn.wordpress.org/trunk@56702


git-svn-id: http://core.svn.wordpress.org/trunk@56214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 08:20:17 +00:00
gziolo
2481f2de2b Blocks: Add more unit test covering edge cases for Block Hooks
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].


Built from https://develop.svn.wordpress.org/trunk@56701


git-svn-id: http://core.svn.wordpress.org/trunk@56213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 08:09:16 +00:00
isabel_brison
5ce36ff8f5 Editor: remove null coalescing operator from layout.
Replaces uses of null coalescing operator in [56698].

Props dmsnell, mukesh27.
See #59443.

Built from https://develop.svn.wordpress.org/trunk@56700


git-svn-id: http://core.svn.wordpress.org/trunk@56212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 06:55:12 +00:00
gziolo
bab9c206eb Build: Introduce SCRIPT_DEBUG global in webpack processing
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.


Built from https://develop.svn.wordpress.org/trunk@56699


git-svn-id: http://core.svn.wordpress.org/trunk@56211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 06:51:19 +00:00
isabel_brison
3317a134af Editor: make better use of Tag Processor in layout block support.
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.

Built from https://develop.svn.wordpress.org/trunk@56698


git-svn-id: http://core.svn.wordpress.org/trunk@56210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 05:04:22 +00:00
Peter Wilson
109f531fbf Administration: Add event type to Events and News widget.
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.

Built from https://develop.svn.wordpress.org/trunk@56697


git-svn-id: http://core.svn.wordpress.org/trunk@56209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 03:54:20 +00:00
Sergey Biryukov
7fd4a45fca Build/Test Tools: Use the latest PHP version for the coding standards workflow.
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.
Built from https://develop.svn.wordpress.org/trunk@56696


git-svn-id: http://core.svn.wordpress.org/trunk@56208 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 00:48:18 +00:00
Sergey Biryukov
114a672cfa Coding Standards: Upgrade WPCS to version 3.0.0.
This is an important release which makes significant changes to improve the accuracy, performance, stability and maintainability of all sniffs, as well as making WordPressCS much better at handling modern PHP.

WordPressCS 3.0.0 contains breaking changes, both for people using ignore annotations, people maintaining custom rulesets, as well as for sniff developers who maintain a custom PHPCS standard based on WordPressCS.

If you are an end-user or maintain a custom WordPressCS based ruleset, please start by reading the [https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-ruleset-maintainers Upgrade Guide to WordPressCS 3.0.0 for ruleset maintainers] which lists the most important changes and contains a step by step guide for upgrading.

If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WordPressCS sniffs, please read the [https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-Developers-of-external-standards Upgrade Guide to WordPressCS 3.0.0 for Developers].

In all cases, please read the complete changelog carefully before you upgrade.

This commit:
* Updates the Composer dependencies to use the new version, including updating the underlying PHP_CodeSniffer dependency to the new minimum supported version for WPCS.[[BR]] Note: the Composer PHPCS installer plugin is no longer explicitly required as it is now a dependency of WPCS, so the dependency is inherited automatically.
* Updates the ruleset for WPCS 3.0.0. This includes:
 * Raising the memory limit to be on the safe side as WPCS 3.0.0 contains a lot more sniffs.
 * Removing explicit inclusions of extra rules, which have now been added to the `WordPress-Core` ruleset..
 * Updating property names for select sniffs.
 * Updating one exclusion — the `WordPress.CodeAnalysis.AssignmentInCondition` sniff has been (partially) replaced by the `Generic.CodeAnalysis.AssignmentInCondition` sniff.
 * Adding one new exclusion.
* Downgrades one new error to a warning.[[BR]] The `Generic.Files.OneObjectStructurePerFile` sniff enforces that there is only one OO structure declaration per file. At this time, this sniff would yield 29 errors. By downgrading the sniff to a ''warning'', the build can pass and the issues can be fixed in due time. For now, the test directory will be excluded until the issues are fixed (as the test directory CS run does not allow for warnings).
* Updates ignore annotations for WPCS 3.0.0.

Reference: [https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0 WPCS 3.0.0 release notes].

Follow-up to [43571], [44574], [45600], [47927].

Props jrf, jorbin, desrosj.
See #59161.
Built from https://develop.svn.wordpress.org/trunk@56695


git-svn-id: http://core.svn.wordpress.org/trunk@56207 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 00:27:12 +00:00
Sergey Biryukov
46b0f1bba1 Code Modernization: Rename parameters that use reserved keywords in phpunit/tests/media.php.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the `$match` parameter to `$matches` in shortcode image tests.

Note: This is enforced by WPCS 3.0.0.

Follow-up to [56693].

See #58831.
Built from https://develop.svn.wordpress.org/trunk@56694


git-svn-id: http://core.svn.wordpress.org/trunk@56206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 00:25:17 +00:00
Felix Arntz
70e0a22e7d Media: Ensure images within shortcodes are correctly considered for loading optimization attributes.
Prior to this change, images added in shortcodes would be considered separately from all other images within post content, which led to incorrect application of the loading optimization attributes `loading="lazy"` and `fetchpriority="high"`.

This changeset changes the filter priority of `wp_filter_content_tags()` from the default `10` to `12` on the various content filters it is hooked in, in order to run that function after parsing shortcodes. While this may technically be considered a backward compatibility break, substantial research and lack of any relevant usage led to the assessment that the change is acceptable given its benefits.

An additional related fix included is that now the duplicate processing of images is prevented not only for post content blobs (`the_content` filter), but also for widget content blobs (`widget_text_content` and `widget_block_content` filters).

Props joemcgill, mukesh27, costdev, spacedmonkey, flixos90.
Fixes #58853.

Built from https://develop.svn.wordpress.org/trunk@56693


git-svn-id: http://core.svn.wordpress.org/trunk@56205 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 00:13:12 +00:00
Sergey Biryukov
5d91b75895 Coding Standards: Fix a few newly introduced WPCS issues.
Follow-up to [56683], [56689].

See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56692


git-svn-id: http://core.svn.wordpress.org/trunk@56204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 00:09:19 +00:00
costdev
1c79a2c23b Filesystem API: Add missing ZIP file for unzip tests.
In [56689], a ZIP file is needed in `tests/phpunit/data/filesystem/` but wasn't included in the changeset. This produced an error when attempting to create a subdirectory during the tests.

This adds the `tests/phpunit/data/filesystem/archive.zip` file.

Follow-up to [56689].

Props flixos90.
Fixes #37719.
Built from https://develop.svn.wordpress.org/trunk@56691


git-svn-id: http://core.svn.wordpress.org/trunk@56203 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 23:40:17 +00:00
Felix Arntz
8964275967 Media: Rely on wp_get_loading_optimization_attributes() to add decoding="async" to images.
The `wp_get_loading_optimization_attributes()` function was introduced in 6.3, as a single centralized place to control loading optimization attributes for various tags, most importantly images.

This changeset consolidates the `decoding="async"` optimization, which was added in 6.1, to occur solely as part of `wp_get_loading_optimization_attributes()`, removing duplicate code and allowing centralized filtering based on [56651].

As part of the change, the `wp_img_tag_add_decoding_attr()` function has been deprecated. The filter of the same name continues to be maintained for backward compatibility, as before covering only images that are part of a content blob such as post content (`the_content`).

Props pereirinha, mukesh27, joemcgill, flixos90.
Fixes #58892.
See #53232.

Built from https://develop.svn.wordpress.org/trunk@56690


git-svn-id: http://core.svn.wordpress.org/trunk@56202 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 22:38:17 +00:00
costdev
36e754b5c3 Filesystem API: Introduce filters for before/after unzipping archives.
This introduces the following new filters which wrap the process of unzipping an archive:
- `pre_unzip_file` - Filters archive unzipping to allow an override with a custom process.
- `unzip_file` - Filters the result of unzipping an archive.

Both filters pass the following:
- `string $file` - Full path and filename of ZIP archive.
- `string $to` - Full path on the filesystem to extract archive to.
- `string[] $needed_dirs` - A full list of required folders that need to be created.
- `float|false $required_space` - The space required to unzip the file and copy its contents, with a 10% buffer.

Props dfavor, azaozz, oglekler, afragen, costdev.
Fixes #37719.
Built from https://develop.svn.wordpress.org/trunk@56689


git-svn-id: http://core.svn.wordpress.org/trunk@56201 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 22:16:17 +00:00
hellofromTonya
9122ef68e1 Fonts: Get font-family name from 'fontFamily' field.
Instead of getting the name from the optional `'name'` field, the font-family name now comes from the required `'fontFamily'` field.

This change fixes a back-compat (BC) break in how the font-family name is pulled from the incoming font data in the `WP_Font_Face_Resolver`.

Why?

WP Core does not require the `'name'` field in theme.json. For themes that do not declare it, that set of font variations is ignored, thus causing a BC break from how the stopgap code worked (see [53282]).

However, `WP_Theme_JSON` schema does require the `fontFamily` field in each of the `typography.fontFamilies`.

== Other details:

Includes a parser to extract the first entry when a `fontFamily` field has a comma-separated list of font-families, e.g. `Inter, sans-serif`.

References:
* Merge from Gutenberg's PR https://github.com/WordPress/gutenberg/pull/54615.

Follow-up to [56500], [53282].

Props ironprogrammer, hellofromTonya, mmaattiiaass, pbking.
Fixes #59165.
Built from https://develop.svn.wordpress.org/trunk@56688


git-svn-id: http://core.svn.wordpress.org/trunk@56200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 21:29:17 +00:00
Weston Ruter
e7747ce23e Script Loader: Use wp_get_script_tag() and wp_get_inline_script_tag()/wp_print_inline_script_tag() helper functions to output scripts on the frontend and login screen.
Using script tag helper functions allows plugins to employ the `wp_script_attributes` and `wp_inline_script_attributes` filters to inject the `nonce` attribute to apply Content Security Policy (e.g. Strict CSP). Use of helper functions also simplifies logic in `WP_Scripts`.

* Update `wp_get_inline_script_tag()` to wrap inline script in CDATA blocks for XHTML-compatibility when not using HTML5.
* Ensure the `type` attribute is printed first in `wp_get_inline_script_tag()` for back-compat.
* Wrap existing `<script>` tags in output buffering to retain IDE supports.
* In `wp_get_inline_script_tag()`, append the newline to `$javascript` before it is passed into the `wp_inline_script_attributes` filter so that the CSP hash can be computed properly.
* In `the_block_template_skip_link()`, opt to enqueue the inline script rather than print it.
* Add `ext-php` to `composer.json` under `suggest` as previously it was an undeclared dependency for running PHPUnit tests.
* Update tests to rely on `DOMDocument` to compare script markup, normalizing unsemantic differences.

Props westonruter, spacedmonkey, flixos90, 10upsimon, dmsnell, mukesh27, joemcgill, swissspidy, azaozz.
Fixes #58664.
See #39941.

Built from https://develop.svn.wordpress.org/trunk@56687


git-svn-id: http://core.svn.wordpress.org/trunk@56199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 21:05:21 +00:00
desrosj
98a0a6b5e5 Docs: Revert [56679].
`Memoizes` is actually correct in this context.

Unprops desrosj.
See #18298.
Built from https://develop.svn.wordpress.org/trunk@56686


git-svn-id: http://core.svn.wordpress.org/trunk@56198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 20:49:18 +00:00
Bernhard Reiter
061c32d574 HTML API: Remove all duplicate copies of an attribute when removing.
When encountering an HTML tag with duplicate copies of an attribute the tag processor ignores the duplicate values, according to the specification. However, when removing an attribute it must remove all copies of that attribute lest one of the duplicates becomes the primary and it appears as if no attributes were removed.

In this patch we're adding tests that will be used to ensure that all attribute copies are removed from a tag when one is request to be removed.

**Before**

{{{#!php
<?php
$p = new WP_HTML_Tag_Processor( '<br id=one id="two" id='three' id>' );
$p->next_tag();
$p->remove_attribute( 'id' );
$p->get_updated_html();
// <br id="two" id='three' id>
}}}

**After**

{{{#!php
<?php
$p = new WP_HTML_Tag_Processor( '<br id=one id="two" id='three' id>' );
$p->next_tag();
$p->remove_attribute( 'id' );
$p->get_updated_html();
// <br>
}}}

Previously we have been overlooking duplicate attributes since they don't have an impact on what parses into the DOM. However, as one unit test affirmed (asserting the presence of the bug in the tag processor) when removing an attribute where duplicates exist this meant we ended up changing the value of an attribute instead of removing it.

In this patch we're tracking the text spans of the parsed duplicate attributes so that ''if'' we attempt to remove them then we'll have the appropriate information necessary to do so. When an attribute isn't removed we'll simply forget about the tracked duplicates. This involves some overhead for normal operation ''when'' in fact there are duplicate attributes on a tag, but that overhead is minimal in the form of integer pairs of indices for each duplicated attribute.

Props dmsnell, zieladam.
Fixes #58119.
Built from https://develop.svn.wordpress.org/trunk@56684


git-svn-id: http://core.svn.wordpress.org/trunk@56196 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 19:04:19 +00:00
spacedmonkey
66c782f6cd Editor: Introduce get_block_asset_url Utility Function.
This commit introduces a valuable utility function, get_block_asset_url, designed to simplify the retrieval of block asset URLs, such as those for CSS and JavaScript files. This utility eliminates redundancy in both register_block_script_handle and register_block_style_handle. Additionally, `get_block_asset_url` incorporates an early exit mechanism to optimize performance.

This update includes comprehensive unit tests, covering various scenarios, including asset registration from core (wp-includes), themes, child themes, plugins, and mu-plugins.

Props spacedmonkey, joemcgill, flixos90, gziolo.
Fixes #58525.
Built from https://develop.svn.wordpress.org/trunk@56683


git-svn-id: http://core.svn.wordpress.org/trunk@56195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 17:49:19 +00:00
spacedmonkey
72f19abd94 Script Loader: Replace hardcoded output of style tags with calls to wp_add_inline_style.
In this commit, enhancements have been made by replacing manually constructed style tags with calls to `wp_add_inline_style`. Previously, numerous style tags were generated and output directly in the header, resulting in redundant code and bypassing the core's style enqueueing system. This approach made it challenging for third-party developers to manage and control the output of these style tags.

To ensure backward compatibility, the following functions have been deprecated and replaced:

- print_embed_styles
- print_emoji_styles
- wp_admin_bar_header
- _admin_bar_bump_cb

Backward compatibility shims have also been added, ensuring that if these functions were previously unhooked from there actions, they will continue to not output a style tag.

However, for the following functions, conversion to use inline styles was not feasible due to the potential disruption it might cause by changing the style tag IDs, potentially breaking JavaScript functionality for a number of plugins in the repository:

- custom-background
- wp-custom

These changes improve code maintainability and enhance the flexibility and control available to developers when managing style outputs within WordPress core.

Props spacedmonkey, hlunter, westonruter, flixos90.
Fixes #58775.
Built from https://develop.svn.wordpress.org/trunk@56682


git-svn-id: http://core.svn.wordpress.org/trunk@56194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 17:06:34 +00:00
Felix Arntz
bfbcb02444 Options, Meta APIs: Improve logic to avoid unnecessary database writes in update_option().
Prior to this change, a strict comparison between the old and new database value could lead to a false negative, since database values are generally stored as strings. For example, passing an integer to `update_option()` would almost always result in an update given any existing database value for that option would be that number cast to a string.

This changeset adjusts the logic to perform an intentional "loose-y" comparison by casting the values to strings. Extensive coverage previously added in [56648] provides additional confidence that this does not introduce any backward compatibility issues.

Props mukesh27, costdev, spacedmonkey, joemcgill, flixos90, nacin, atimmer, duck_, boonebgorges.
Fixes #22192.

Built from https://develop.svn.wordpress.org/trunk@56681


git-svn-id: http://core.svn.wordpress.org/trunk@56193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 16:25:19 +00:00
Sergey Biryukov
28af9eafb0 Coding Standards: Fix a few newly introduced WPCS issues.
Follow-up to [56570], [56573], [56589], [56604], [56612], [56620], [56629], [56631], [56638], [56642], [56644], [56649].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56680


git-svn-id: http://core.svn.wordpress.org/trunk@56192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 15:36:18 +00:00