Commit Graph

21317 Commits

Author SHA1 Message Date
Sergey Biryukov
3d1140c898 Coding Standards: Use strict comparison in wp-admin/includes/menu.php.
Includes minor code layout fixes for better readability.

Follow-up to [3536], [4093], [9578], [11092], [18034].

Props aristath, poena, afercia, SergeyBiryukov.
See #57839.
Built from https://develop.svn.wordpress.org/trunk@55873


git-svn-id: http://core.svn.wordpress.org/trunk@55385 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-31 14:53:26 +00:00
John Blackbourn
f3b93e6b3a Media: Correct the fallback value passed to the $mimes parameter of wp_check_filetype_and_ext() from _wp_handle_upload(), and update corresponding documentation.
Previously when the `mimes` element was not specified in the overrides array passed to `_wp_handle_upload()` it resulted in boolean false being passed to this parameter, which is incorrect. The fallback value should be `null`.

Props platonkristinin, pkbhatt

Fixes #58349

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


git-svn-id: http://core.svn.wordpress.org/trunk@55384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-30 19:46:22 +00:00
John Blackbourn
ffd2a5bb95 Cron API: Attempt to raise the PHP memory limit for cron event processing.
Since cron events often consume extra memory by nature, it makes sense to give them the full amount available by default. In practice this means the memory will be increased to `WP_MAX_MEMORY_LIMIT` (which is 256MB by default) during cron event processing if the default memory limit is lower than this value.

The new `cron_memory_limit` filter can be used to adjust this value if necessary.

Note that this change will not by default affect external means of processing cron events, such as the `wp cron` command in WP-CLI, server-level crontab events, or any other cron event processing mechanism that bypasses `wp-cron.php`.

Props iandunn, thakkarhardik

Fixes #56628

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


git-svn-id: http://core.svn.wordpress.org/trunk@55383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-30 18:48:19 +00:00
John Blackbourn
bb9b9d17f4 Docs: Miscellaneous corrections and improvements to docblocks.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-30 17:45:21 +00:00
Sergey Biryukov
37e599fb3e Upgrade/Install: Avoid an extra database query in populate_network().
This moves the query for user ID of the new network's administrator closer to where the value is actually used.

Includes removing unnecessary `get_userdata()` call, as user ID is the only data needed here.

Follow-up to [12756], [35575], [43628].

Props nihar007, sakibmd, mukesh27, costdev, SergeyBiryukov.
Fixes #58423.
Built from https://develop.svn.wordpress.org/trunk@55869


git-svn-id: http://core.svn.wordpress.org/trunk@55381 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-30 14:34:22 +00:00
Sergey Biryukov
6d16bbc088 Docs: Add a @since tag for the pre_wp_setup_nav_menu_item filter.
Includes moving the unit test next to the other `wp_setup_nav_menu_item()` tests and using the `MockAction` class to confirm that the filter runs.

Follow-up to [55867].

Props TobiasBg.
Fixes #56577.
Built from https://develop.svn.wordpress.org/trunk@55868


git-svn-id: http://core.svn.wordpress.org/trunk@55380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-30 14:13:22 +00:00
Andrew Ozz
91b653f5cd Menus: Add a short-circuit filter to wp_setup_nav_menu_item().
Props: davidbinda, ironprogrammer, andizer.
Fixes: #56577.
Built from https://develop.svn.wordpress.org/trunk@55867


git-svn-id: http://core.svn.wordpress.org/trunk@55379 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-30 11:21:26 +00:00
Sergey Biryukov
f4b232f74c Coding Standards: Use strict comparison in wp-admin/includes/schema.php.
Follow-up to [12756], [12862], [12880], [13070], [14485], [17928], [18899], [41348], [43628].

Props faisalahammad, aristath, poena, afercia, SergeyBiryukov.
Fixes #58042, #58047. See #57839.
Built from https://develop.svn.wordpress.org/trunk@55866


git-svn-id: http://core.svn.wordpress.org/trunk@55378 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-29 16:26:22 +00:00
Pascal Birchler
30593b01b4 I18N: Improve _load_textdomain_just_in_time() logic when there are no translation files.
Fixes a performance issue where the JIT logic is invoked for every translation call if the there are no translations in the current locale. With this change, the information is cached by adding `Noop_Translations` instances to the global `$l10n` array. This way, `get_translations_for_domain()` returns earlier, thus avoiding subsequent `_load_textdomain_just_in_time()` calls.

Props swissspidy, johnbillion, ocean90.
Fixes #58321.
Built from https://develop.svn.wordpress.org/trunk@55865


git-svn-id: http://core.svn.wordpress.org/trunk@55377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-29 08:36:23 +00:00
Sergey Biryukov
4581452e2b Users: Make sure bulk actions are only executed with the Apply button, not Change.
The Change button is supposed to perform the “Change role to...” action only, but could unintentionally be used for other bulk actions if the role was not selected.

This commit removes an extra check and ensures the correct error message is displayed in that case:

 Sorry, you are not allowed to give users that role.

Follow-up to [6990], [8691], [9028], [15576], [15642], [34636], [49944].

Props haritpanchal, costdev, ankit-k-gupta, SergeyBiryukov.
Fixes #57952.
Built from https://develop.svn.wordpress.org/trunk@55864


git-svn-id: http://core.svn.wordpress.org/trunk@55376 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-28 11:46:24 +00:00
Sergey Biryukov
ac66d2f01e Themes: Use correct escaping function for aria-label in _navigation_markup().
Follow-up to [46236].

Props sabernhardt, costdev, mukesh27.
Fixes #58387.
Built from https://develop.svn.wordpress.org/trunk@55863


git-svn-id: http://core.svn.wordpress.org/trunk@55375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-27 09:53:25 +00:00
Pascal Birchler
afd88c4ac7 I18N: Refactor determine_locale() for performance and readability.
Refactors the function to avoid unnecessary `get_locale()` calls and slightly improve performance, while keeping it readable.

Adds tests.

Props Cybr, spacedmonkey, swissspidy.
Fixes #58317.
Built from https://develop.svn.wordpress.org/trunk@55862


git-svn-id: http://core.svn.wordpress.org/trunk@55374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-26 17:57:23 +00:00
Weston Ruter
4e30de26c6 Bundled Themes: Remove/disable obsolete IE-specific skip-link-focus-fix.
* Removes script from the `wp_print_footer_scripts` action in Twenty Nineteen, Twenty Twenty, and Twenty Twenty-One.
* Switches enqueue functions to just register the scripts in Twenty Fifteen, Twenty Sixteen, and Twenty Seventeen.
* Rearranges Twenty Seventeen's scripts to connect `twentyseventeenScreenReaderText` with the global script instead of the unused skip link fix.
* Updates scripts in Twenty Fifteen and Twenty Sixteen with code from Twenty Seventeen _to run on Internet Explorer only_. Twenty Sixteen needed to keep an adjustment that offsets the toolbar and border.
* Removes the script from JS files in Twenty Thirteen and Twenty Fourteen and edits their modified dates.

Props sabernhardt, westonruter, joedolson, flixos90, mukesh27.
Fixes #54421.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-26 17:25:23 +00:00
Sergey Biryukov
9296612464 External Libraries: Update jQuery to version 3.7.0.
This release includes bug fixes, a new `.uniqueSort()` method, and a performance improvement for some use cases when using manipulation methods like `.append()`.

References:
* [https://blog.jquery.com/2023/05/11/jquery-3-7-0-released-staying-in-order/ jQuery 3.7.0 release notes]
* [https://github.com/jquery/jquery/compare/3.6.4...3.7.0 Full list of changes in jQuery 3.7.0]

Follow-up to [49101], [50445], [50520], [54202], [55012], [55491].

Props mgol, jorbin, hbhalodia, desrosj, TobiasBg, audrasjb, mukesh27, naeemhaque, nuhel, SergeyBiryukov.
Fixes #58083.
Built from https://develop.svn.wordpress.org/trunk@55860


git-svn-id: http://core.svn.wordpress.org/trunk@55372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-26 11:33:35 +00:00
antpb
d4c39df308 Media: Prevent scaling up of images in the Image Editor.
Previously, when scaling an image larger than the source size in the image edit states the image would silently fail the scaling action. This patch provides an error when someone attempts to scale an image larger than the source size while also disabling the button to initiate the action. 

Props brookedot, joedolson, markoheijnen, mikeschroder, desrosj, Mista-Flo, costdev.
Fixes #26381.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-25 15:17:19 +00:00
audrasjb
1dc049b06c Formatting: Add support for schwa in remove_accents().
This changeset adds support for schwa character. Ə (U+018F) and ə (U+0259) are part of Latin Extended-B and used in 
several languages like Azerbaijani or also in gender neutral Italian.

Props suleymankenar, audrasjb, przemekhernik.
Fixes #57609.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-25 13:14:20 +00:00
Sergey Biryukov
956be813b6 Coding Standards: Improve formatting of some SQL queries for better readability.
This corrects the placement of double quotes around the query and makes sure the alignment is consistent.

Props umeshmcakadi, mukesh27, krupalpanchal, dhrumilk, SergeyBiryukov.
Fixes #58372.
Built from https://develop.svn.wordpress.org/trunk@55857


git-svn-id: http://core.svn.wordpress.org/trunk@55369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-25 12:55:19 +00:00
spacedmonkey
d8c4000c53 Comments: Move wp_queue_comments_for_comment_meta_lazyload function to the correct file.
As of [55855] wp_queue_comments_for_comment_meta_lazyload was deprecated. But deprecate to wp-admin/deprecated.php and not wp-includes/deprecated.php.This is incorrect, as this is a public function and not an admin function. 

Props SergeyBiryukov, spacedmonkey.
See #58301.
Built from https://develop.svn.wordpress.org/trunk@55856


git-svn-id: http://core.svn.wordpress.org/trunk@55368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-25 10:55:19 +00:00
spacedmonkey
3c5d179fc9 Comments: Deprecate wp_queue_comments_for_comment_meta_lazyload function.
As of [55749] wp_queue_comments_for_comment_meta_lazyload is no longer used in core. This commit, deprecates this function. Update docs and tests accordingly.

Props sh4lin, spacedmonkey, costdev, peterwilsoncc.
Fixes #58301.
Built from https://develop.svn.wordpress.org/trunk@55855


git-svn-id: http://core.svn.wordpress.org/trunk@55367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-25 10:31:23 +00:00
spacedmonkey
2cd27b2349 Options, Meta APIs: Change the option can_compress_scripts to be autoloaded.
Ensure that the option `can_compress_scripts` is autoloaded on single sites, as this option is used in all requests. This change saves one database query per page request. 

Props RavanH, spacedmonkey, costdev, azaozz, flixos90.
Fixes #55270.
Built from https://develop.svn.wordpress.org/trunk@55854


git-svn-id: http://core.svn.wordpress.org/trunk@55366 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-24 17:35:18 +00:00
Sergey Biryukov
f93e6ec4e8 Help/About: Reverse the order of conditionals for displaying the "Go to Updates" link.
`isset()` is faster than `current_user_can()`, so should be checked first.

Includes updating code layout for better readability.

Follow-up to [19442], [19524], [28477], [33466], [55848].

See #57839.
Built from https://develop.svn.wordpress.org/trunk@55853


git-svn-id: http://core.svn.wordpress.org/trunk@55365 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-24 10:15:20 +00:00
oandregal
7311e69b59 Loading assets for the editor: Revert [55695].
The changeset [55695] introduced a regression in the order of styles for the editor, causing the styles registered for the block (both editor and front) to be loaded after any other styles enqueued using the `enqueue_block_editor_assets` hook.

Since the original behavior was introduced in WordPress 5.0 changing it breaks the expectations of the ecosystem.

Props ellatrix.
Fixes #58208.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-24 09:24:23 +00:00
Sergey Biryukov
0ecaf73f34 General: Improve performance of the _wp_array_get() function.
When using a block theme, `_wp_array_get()` is the most called function on the front end of a site.

This commit makes a few minor performance optimizations, which add up to a noticeable improvement.

Follow-up to [49135], [49143], [49580].

Props aristath, jrf, afercia, costdev, swissspidy, flixos90, spacedmonkey, mukesh27, samiamnot, SergeyBiryukov.
Fixes #58376.
Built from https://develop.svn.wordpress.org/trunk@55851


git-svn-id: http://core.svn.wordpress.org/trunk@55363 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-23 22:00:21 +00:00
Felix Arntz
8f8114fb06 Media: Fix lazy-loading bug by avoiding to modify content images when creating an excerpt.
The `wp_filter_content_tags()` function, which modifies image tags for example to optimize performance, is hooked into the `the_content` filter by default. When rendering an excerpt for a post that doesn't have a manually provided excerpt, the post content is used to generate the excerpt, handled by the `wp_trim_excerpt()` function.

Prior to this changeset, this led to `wp_filter_content_tags()` being called on the content when generating the excerpt, which is wasteful as all tags are stripped from the excerpt, and it furthermore could result in a lazy-loading bug when the post content contained images, as those images were being counted even though they would never be rendered as part of the excerpt.

This changeset fixes the bug and slightly improves performance for generating an excerpt by temporarily unhooking the `wp_filter_content_tags()` function from the `the_content` filter when using it to generate the excerpt.

Props costdev, flixos90, joemcgill, mukesh27, salvoaranzulla, spacedmonkey, thekt12, westonruter.
Fixes #56588.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-23 18:25:19 +00:00
Sergey Biryukov
03436e6d3a Coding Standards: Use strict comparison in wp-includes/theme-compat/comments.php.
Follow-up to [31941], [41285], [55420].

Props sarequl.
See #57839.
Built from https://develop.svn.wordpress.org/trunk@55849


git-svn-id: http://core.svn.wordpress.org/trunk@55361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-23 15:25:24 +00:00
audrasjb
6c9c6cd6ef Help/About: Remove unwanted space in a link located on about.php.
This fixes a small interface glitch in the `Go to Updates` link located on 
the the About screen.

Props NekoJonez, mukesh27, sumitbagthariya16, ahsannayem.
Fixes #58373.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-22 20:04:22 +00:00
Felix Arntz
c6f9238b77 Media: Conditionally skip lazy-loading on images before the loop to improve LCP performance.
When the logic to exclude images that likely appear above the fold from being lazy-loaded was introduced in WordPress 5.9, initially only images that appear within the main query loop were being considered. However, there is a good chance that images above the fold are rendered before the loop starts, for example in the header template part.

It is particularly common for a theme to display the featured image for a single post in the header. Based on HTTP Archive data from February 2023, the majority of LCP images that are still being lazy-loaded on WordPress sites use the `wp-post-image` class, i.e. are featured images.

This changeset enhances the logic in `wp_get_loading_attr_default()` to not lazy-load images that appear within or after the header template part and before the query loop, using a new `WP_Query::$before_loop` property.

For block themes, this was for the most part already addressed in [55318], however this enhancement implements the solution in a more generally applicable way that brings the improvement to classic themes as well.

Props thekt12, flixos90, spacedmonkey, costdev, zunaid321, mukesh27.
Fixes #58211.
See #53675, #56930.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-22 19:13:21 +00:00
Sergey Biryukov
e182459c6d Administration: Add missing escaping for CSS classes on the body tag in the admin.
Follow-up to [5892], [10823], [10868], [18882], [21014], [22000], [48060].

Propos rafiem, costdev, dd32, audrasjb, westonruter, SergeyBiryukov.
Fixes #58336.
Built from https://develop.svn.wordpress.org/trunk@55846


git-svn-id: http://core.svn.wordpress.org/trunk@55358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-22 14:16:19 +00:00
spacedmonkey
a88a66b0bd Posts, Post Types: Add a new filter for query arguments in get_pages.
In [55569] `get_pages` was converted to use `WP_Query` internally. But for plugins that were extending the `get_pages` filters and filter `WP_Query` query arguments, this could result in a conflict. Add a filter `get_pages_query_args` to allow developers to change arguments passed to `WP_Query` but also have the context of the original arguments passed to the `get_pages` function. 

This change also expands test coverage of `get_pages` to ensure no breakages in the future. 

Props spacedmonkey, westonruter, costdev, flixos90, kenwins, marianne38.
See #12821.
Built from https://develop.svn.wordpress.org/trunk@55845


git-svn-id: http://core.svn.wordpress.org/trunk@55357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-22 10:03:22 +00:00
Sergey Biryukov
fc3f62f4a2 Docs: Improve a few DocBlocks in wp-includes/formatting.php.
This addresses missing hyphens, typos and unnecessarily complex language.

Follow-up to [8540], [8743], [11615], [11907], [28670], [42056].

Props apermo.
Fixes #58316.
Built from https://develop.svn.wordpress.org/trunk@55844


git-svn-id: http://core.svn.wordpress.org/trunk@55356 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-21 10:41:22 +00:00
Sergey Biryukov
cdc9d4766f Docs: Fix a few more typos in DocBlocks.
Follow-up to [39493], [41726], [55823], [55824], [55827].

See #57840.
Built from https://develop.svn.wordpress.org/trunk@55843


git-svn-id: http://core.svn.wordpress.org/trunk@55355 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-20 10:19:23 +00:00
desrosj
2bb3a51695 Editor: Restore shortcode support for block templates.
Follow up to [55761].

Props youknowriad, Clorith, desrosj, antpb, Otto42, johnbillion, jorbin, rmccue, timothyblynjacobs, mikeschroder, peterwilsoncc, audrasjb, matveb, noisysocks, xknown, ehtis, isabel_brison, talldanwp, gziolo, chriscct7, davidbaumwald.
Fixes #58333.
Built from https://develop.svn.wordpress.org/trunk@55828


git-svn-id: http://core.svn.wordpress.org/trunk@55340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-20 03:58:47 +00:00
Sergey Biryukov
046b9afcb7 Docs: Fix a few more typos in DocBlocks and inline comments.
Follow-up to [6779], [10565], [12023], [25224], [27533], [32806], [34777], [45262], [46594], [55823], [55824].

Props Presskopp.
See #57840.
Built from https://develop.svn.wordpress.org/trunk@55827


git-svn-id: http://core.svn.wordpress.org/trunk@55339 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-19 13:27:20 +00:00
spacedmonkey
0670401bae Networks and Sites: Load WP_Metadata_Lazyloader class file if class in meta.php.
In [55818] did a check to see if `WP_Metadata_Lazyloader` class existed and the loaded in the class file if it did not. However, require in wp-settings.php was not removed and resulted in the class being loaded twice. To be safe, only include the class file in meta.php and remove from wp-settings.php file.

Props spacedmonkey, ryelle.
See #58185.
Built from https://develop.svn.wordpress.org/trunk@55826


git-svn-id: http://core.svn.wordpress.org/trunk@55338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-19 12:46:24 +00:00
Felix Arntz
2b28fea7c9 Media: Prevent special images within post content to skew image counts and cause lazy-loading bugs.
In order to skip lazy-loading the first few images on a page, as of WordPress 5.9 there has been logic to count images that are eligible based on certain criteria. One of those groups are images that appear within the content of a post.

This changeset fixes a bug where images created via `get_the_post_thumbnail()` or `wp_get_attachment_image()` that are injected into the post content would skew the count and therefore result in all images to be lazy-loaded, potentially hurting load time performance. This is relevant for example when those functions are called in server-side rendered blocks, or any other filter callbacks hooked into `the_content`.

Props flixos90, antpb, joedolson, spacedmonkey, mukesh27, thekt12, costdev, jrf.
Fixes #58089.
See #53675.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55337 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-18 19:55:23 +00:00
Sergey Biryukov
be4b739a49 Docs: Fix a few more typos in inline comments.
Follow-up to [9117], [11005], [12097], [18632], [26192], [55823].

Props Presskopp.
See #58334, #57840.
Built from https://develop.svn.wordpress.org/trunk@55824


git-svn-id: http://core.svn.wordpress.org/trunk@55336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-18 12:36:24 +00:00
Sergey Biryukov
5f054d2079 Docs: Fix typo in a comment in Bulk_Upgrader_Skin::header() and ::footer().
Follow-up to [13602].

Props kamplugins, costdev, mukesh27, afragen.
Fixes #58334.
Built from https://develop.svn.wordpress.org/trunk@55823


git-svn-id: http://core.svn.wordpress.org/trunk@55335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-18 11:37:27 +00:00
Weston Ruter
4c2394eed5 General: Use static on closures whenever $this is not used to avoid memory leaks.
Props westonruter, jrf, spacedmonkey.
Fixes #58323.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-17 22:46:24 +00:00
Felix Arntz
8db8a24e46 Media: Introduce wp_get_attachment_image_context filter.
Since WordPress 5.9, a "context" value of "wp_get_attachment_image" has been used in the `wp_get_attachment_image()` function to provide context to underlying functions where that is relevant, e.g. `wp_get_loading_attr_default()`. Since that value used to be not customizable, it required a workaround in `get_the_post_thumbnail()` to avoid calling those functions in `wp_get_attachment_image()`, which resulted in unnecessary complexity and was prone to errors.

This changeset introduces a `wp_get_attachment_image_context` filter and leverages it with private filter callback functions that are leveraged by default when `get_the_post_thumbnail()` is called. This avoids the need for the previous workaround and furthermore provides flexibility for other callers of `wp_get_attachment_image()` to provide their own contexts.

Props flixos90, costdev, thekt12, westonruter, spacedmonkey.
Fixes #58212.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55333 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-17 18:31:24 +00:00
Sergey Biryukov
95bcde947f Docs: Correct default value for the $optimize option in Style Engine.
The default value is set to `true` in `WP_Style_Engine_Processor::get_css()`, but was previously documented as `false` in various DocBlocks.

Follow-up to [54156], [55719], [55733], [55819].

See #57840.
Built from https://develop.svn.wordpress.org/trunk@55820


git-svn-id: http://core.svn.wordpress.org/trunk@55332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-17 12:06:19 +00:00
Sergey Biryukov
c14343ba25 Docs: Improve Style Engine DocBlocks per the documentation standards.
Follow-up to [54156], [55719], [55733].

See #57840.
Built from https://develop.svn.wordpress.org/trunk@55819


git-svn-id: http://core.svn.wordpress.org/trunk@55331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-17 11:58:26 +00:00
spacedmonkey
c459098d7b Networks and Sites: Load WP_Metadata_Lazyloader class file if class does not exist.
Follow on from [55747].

As `get_sites` can be called very early in the bootstrap process, like in the sunrise.php file, it means that the `WP_Metadata_Lazyloader` may not have been loaded yet in the wp-settings.php file. Add a simple check to see if the class exists and if it does not exist then load the class file in. 

Props spacedmonkey, peterwilsoncc, dd32.
See #58185.
Built from https://develop.svn.wordpress.org/trunk@55818


git-svn-id: http://core.svn.wordpress.org/trunk@55330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-17 09:44:18 +00:00
spacedmonkey
2949e05862 Editor: Disable lazy loading term meta in get_block_templates.
Pass false to the `lazy_load_term_meta` parameter given to the `WP_Query` found in `get_block_templates`. Template post types only ever have one term assigned to them. So priming term meta, does not help performance as lazy loading term meta is only useful if loading multiple terms. As `get_block_templates` is run multiple times on a block theme request, this saves processing time. 

Props spacedmonkey, andraganescu, ntsekouras, oandregal, westonruter.
Fixes #58230.
Built from https://develop.svn.wordpress.org/trunk@55817


git-svn-id: http://core.svn.wordpress.org/trunk@55329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-17 09:23:24 +00:00
Felix Arntz
1aeba57f4b Media: Increase default for wp_omit_loading_attr_threshold to 3.
The previous default threshold for how many content images to skip lazy-loading on (which was just 1) has proven to be too strict: HTTP Archive data shows that >70% of sites have up to 3 equal-sized images in the initial viewport, each of which could be the LCP image and therefore should not be lazy-loaded. Lazy-loading too many images has adverse effects on load time performance, while increasing the default threshold will not negatively affect load time performance even for sites where a threshold of 1 would be the perfect choice.

The change of default value in this changeset will improve performance for more WordPress sites out of the box. The `wp_omit_loading_attr_threshold` filter can still be used to customize and fine tune the value where needed.

Props thekt12, spacedmonkey, westonruter, flixos90.
Fixes #58213.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 18:52:23 +00:00
audrasjb
d9d303f812 Media: Prevent CSRF setting attachment thumbnails.
Props martinkrcho, paulkevan, peterwilsoncc, xknown, peterwilsoncc.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55276 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 14:27:21 +00:00
audrasjb
d81f522a57 Embeds: Add protocol validation for WordPress Embed code.
Validate that links within auto-discovered embeds are using the `http` or `https` protocols before following links.

Props xknown, dd32, peterwilsoncc.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55275 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 14:25:21 +00:00
audrasjb
f477c00fdc Editor: Ensure block comments are of a valid form.
Ensures that the block delimiter comments are of a valid form: opening with `<!--` and closing with `-->`.

Props xknown, isabel_brison, peterwilsoncc.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 14:23:19 +00:00
audrasjb
6a077b35f1 Editor: Remove shortcode support from block templates.
Props youknowriad, xknown, timothyblynjacobs, matveb.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 14:21:18 +00:00
audrasjb
02a131ec30 I18N: Introduce sanitization function for locale.
Introduce the `sanitize_locale_name()` for sanitizing user input of locales.

Props xknown, timothyblynjacobs, ocean90, peterwilsoncc.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 14:18:20 +00:00
spacedmonkey
b49912434d Taxonomy: Do not prime term meta in wp_get_object_terms.
Passing `update_term_meta_cache` argument value false by default resulting in `get_terms` to not prime the term meta cache in `wp_get_object_terms`. Priming of term meta is not needed in this context. 

Props spacedmonkey, rutviksavsani.
Fixes #57701.
Built from https://develop.svn.wordpress.org/trunk@55759


git-svn-id: http://core.svn.wordpress.org/trunk@55271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 12:31:21 +00:00
audrasjb
a0bcd7d56a Docs: Clarify @param types on get_sample_permalink_html filter.
`$new_title` and `$new_slug` can be null if `get_sample_permalink_html()` 
was called with default parameters, and they are documented as 
`string|null` in the function DocBlock.

Follow-up to [34347].

Props Enchiridion, audrasjb, SergeyBiryukov.
Fixes #58322.
See #33927. --Cette ligne, et les 
suivantes 
ci-dessous, seront ignorées--

M    trunk/src/wp-admin/includes/post.php

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


git-svn-id: http://core.svn.wordpress.org/trunk@55270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-16 05:25:23 +00:00
Sergey Biryukov
fe928b2e9a General: Remove a few is_object() checks followed by instanceof operator.
This is a minor performance enhancement:

* If an object is passed, the call to `is_object()` will be redundant.
* If a non-object is passed, the `instanceof` operator (a variant of `is_a()`) will first [https://github.com/php/php-src/blob/f42992f/Zend/zend_builtin_functions.c#L630-L631 check if it is an object] before doing any further processing.

Therefore, no additional processing cycles should be wasted in both cases.

Follow-up to [6779], [48798], [48905], [49194], [55748].

Props Presskopp, costdev.
Fixes #58309.
Built from https://develop.svn.wordpress.org/trunk@55757


git-svn-id: http://core.svn.wordpress.org/trunk@55269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-15 10:28:23 +00:00
Sergey Biryukov
c26ddc3eae Tests: Remove expectation of a deprecation notice from WP_Posts_List_Table tests.
With `get_the_author()` returning an empty string instead of `null` if called before `$authordata` is set, and no longer causing a PHP 8.1 "null to non-nullable" deprecation notice, there is no need for these tests to ignore the notice.

Follow-up to [51968], [55755].

See #58157.
Built from https://develop.svn.wordpress.org/trunk@55756


git-svn-id: http://core.svn.wordpress.org/trunk@55268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-14 18:45:20 +00:00
Sergey Biryukov
ae3c5a4be6 Code Modernization: Correct fallback return value in get_the_author().
If the `$authordata` global is not set, `get_the_author()` returned `null`, causing a PHP 8.1 "null to non-nullable" deprecation notice in `ent2ncr()` hooked via `the_author` filter:
{{{
str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
}}}

This commit updates `get_the_author()` to return an empty string if called before `$authordata` is set, bringing consistency with a few other similar functions which also return an empty string in this case:

* `get_the_author_meta()`
* `get_the_author_posts_link()`
* `get_the_modified_author()`

Follow-up to [695/tests], [2858], [11138], [12284], [20575], [34677], [44616], [53187].

Props Soean, jrf, sabernhardt, salvoaranzulla, antpb, ebai4, sajjad67, tijmensmit, SergeyBiryukov.
Fixes #58157.
Built from https://develop.svn.wordpress.org/trunk@55755


git-svn-id: http://core.svn.wordpress.org/trunk@55267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-14 17:58:24 +00:00
Sergey Biryukov
8abc201cfe Tests: Split the tests from user/author.php into individual test classes.
This aims to make `get_the_author_*()` tests more discoverable and easier to expand.

Follow-up to [691/tests], [692/tests], [695/tests], [28362], [31098], [34687], [53147], [54717], [54726], [55591].

See #57841.
Built from https://develop.svn.wordpress.org/trunk@55754


git-svn-id: http://core.svn.wordpress.org/trunk@55266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-13 13:35:22 +00:00
John Blackbourn
a714bc03ee Docs: Various corrections and improvements to inline docs and docblocks.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-12 21:35:21 +00:00
Sergey Biryukov
fe6b65c44b Code Modernization: Explicitly declare all properties in Text_Diff_Engine_native.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

There are a number of ways to mitigate this:
* If it is an accidental typo for a declared property: fix the typo.
* For known properties: declare them on the class.
* For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in.
* For unknown ''use'' of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes.

In this case, the properties, as used in the class methods, fall in the “known property” category.

Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].

Follow-up to [53942], [53948], [53949], [53952], [53953], [53954], [53957], [54037].

Props jrf, thomask.
See #58298.
Built from https://develop.svn.wordpress.org/trunk@55752


git-svn-id: http://core.svn.wordpress.org/trunk@55264 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-12 08:51:22 +00:00
audrasjb
0fd73d7a72 Coding Standards: Use esc_url() to escape link URL value in wp-admin/edit-link-form.php.
Props dilipbheda, mukesh27.
Fixes #58282.
See #57839.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55263 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 15:05:22 +00:00
audrasjb
ad55717715 I18N: Replace "Roll back" with "Restore" in user facing strings.
The terms "roll back" and "rolled back" are used in user facing strings since [55720]. These termes are not that clear for novice users and may be difficult to translate in some locales. This changeset replaces "roll back" with "restore" and "rolled back" with "restored" or "not applied" depending of the context of the screen.

Follow-up to [55720].

Props kebbet, costdev, NekoJonez, audrasjb, SergeyBiryukov, davidbaumwald.
Fixes #58282.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55262 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 14:50:20 +00:00
spacedmonkey
fda9000c7b Comments: Always lazily load comment meta.
In [34270] introduced lazy loading of comment meta. However, this was only in the context of `WP_Query`. Other parts of the codebase, like `WP_Comment_Query` did not lazily load comment meta. In this change, calls to `update_meta_cache` are now replaced with `wp_lazyload_comment_meta`, that instead of priming comment meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where comment meta is being primed unnecessarily and never used. Adding everything to the comment meta queue, also means that if comment meta is used, that is all loaded in a single database / cache call.

Follow on from [55671], [55747].

Props spacedmonkey, peterwilsoncc, flixos90, mukesh27.
Fixes #57801.
Built from https://develop.svn.wordpress.org/trunk@55749


git-svn-id: http://core.svn.wordpress.org/trunk@55261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 12:27:22 +00:00
Sergey Biryukov
d35d467c9c Plugins: Remove is_object() check in WP_Hook:build_preinitialized_hooks().
This is a minor performance enhancement:

* If an object is passed, the call to `is_object()` will be redundant.
* If a non-object is passed, the `instanceof` operator (a variant of `is_a()`) will first [https://github.com/php/php-src/blob/f42992f/Zend/zend_builtin_functions.c#L630-L631 check if it is an object] before doing any further processing.

Therefore, no additional processing cycles should be wasted in both cases.

Follow-up to [38571].

Props bor0, johnbillion, davidbaumwald.
Fixes #58290.
Built from https://develop.svn.wordpress.org/trunk@55748


git-svn-id: http://core.svn.wordpress.org/trunk@55260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 11:43:21 +00:00
spacedmonkey
3ac5fd72d0 Networks and Sites: Lazy load site meta.
In [36566] a framework to lazily load metadata was introduced. This supported term and comment meta by default. In this commit, extends support for site ( blog ) meta. Site meta is not heavily used by core and is used by developers to extend multisite. In this change, `_prime_site_caches` and `WP_Site_Query` now call the new function `wp_lazyload_site_meta`. The function `wp_lazyload_site_meta` accepts an array of ids and adds them to the queue of metadata to be lazily loaded. The function `get_blogs_of_user` was updated to now lazily load site meta. 

Follow on from [55671].

Props spacedmonkey, johnjamesjacoby, peterwilsoncc, mukesh27.
Fixes #58185.
Built from https://develop.svn.wordpress.org/trunk@55747


git-svn-id: http://core.svn.wordpress.org/trunk@55259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 11:15:24 +00:00
spacedmonkey
041f2d982f Tests: Partial revert of r55745
Revert package-lock.json changes committed by mistake in [55745].

Props mukesh27.
See #57841.
Built from https://develop.svn.wordpress.org/trunk@55746


git-svn-id: http://core.svn.wordpress.org/trunk@55258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 10:33:20 +00:00
spacedmonkey
19217af74d Tests: Use the function get_num_queries across all unit tests.
Replace use of `$wpdb->num_queries` with a function call to `get_num_queries`. This improves readability and consistency between tests. 

Props SergeyBiryukov, peterwilsoncc, spacedmonkey.
See #57841.
Built from https://develop.svn.wordpress.org/trunk@55745


git-svn-id: http://core.svn.wordpress.org/trunk@55257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 10:07:23 +00:00
oandregal
7119126dc3 Docs: describe return type of _get_block_template_file().
Props: desrosj, mukesh27, costdev, johnbillion.
Fixes #57756.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-11 09:03:26 +00:00
davidbaumwald
fe27bb8d0b Revisions: Add edit link functionality for the wp_template and wp_template_part post types.
In preparation for viewing revisions of templates and template parts in the editor, this set changes adds the `_edit_link` argument when registering the `wp_template` and `wp_template_part` post types.  This commit also updates `get_edit_post_link` to account for the unique edit URLs for these post types.

Finally, this commit also adds new unit tests for the `get_edit_post_link` function, including tests for the `post`, `wp_template`, and `wp_template_part` post types.

Fixes #57709.
Props andraganescu, spacedmonkey, antonvlasenko, youknowriad, ramonopoly, ironprogrammer, annezazu.
Built from https://develop.svn.wordpress.org/trunk@55743


git-svn-id: http://core.svn.wordpress.org/trunk@55255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-10 17:36:21 +00:00
Sergey Biryukov
9e840bbc8d Tests: Move wp_cache_flush_runtime() next to wp_cache_flush().
This matches the function's placement in `wp-includes/cache.php` and brings more consistency.

Follow-up to [52772], [55741].

See #57841.
Built from https://develop.svn.wordpress.org/trunk@55742


git-svn-id: http://core.svn.wordpress.org/trunk@55254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-10 14:02:20 +00:00
spacedmonkey
795758f265 Build/Test Tools: Call wp_cache_flush_runtime in WP_UnitTestCase.
In `WP_UnitTestCase::flush_cache` method, the properties of the global `$wp_object_cache` object were manaully being reset to flush the cache. The function `wp_cache_flush_runtime` was added in [52772] and is designed to reset any class properties to default values. Using `wp_cache_flush_runtime` improve compatibility with third party object caches, as it allows developers to define their own `wp_cache_flush_runtime` function. 

Props rmccue, johnbillion, wonderboymusic, boonebgorges, voldemortensen, dd32, DrewAPicture, tillkruess, spacedmonkey.
Fixes #31463.
Built from https://develop.svn.wordpress.org/trunk@55741


git-svn-id: http://core.svn.wordpress.org/trunk@55253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-10 09:11:24 +00:00
audrasjb
4935678150 Editor: Update block editor packages to the latest patch releases.
This updates the block editor related npm dependencies to their latest patch versions ahead of WordPress 6.2.1 RC1.

Updated packages:
 - @wordpress/annotations@2.26.4
 - @wordpress/block-directory@4.3.12
 - @wordpress/block-editor@11.3.10
 - @wordpress/block-library@8.3.12
 - @wordpress/components@23.3.7
 - @wordpress/customize-widgets@4.3.12
 - @wordpress/edit-post@7.3.12
 - @wordpress/edit-site@5.3.12
 - @wordpress/edit-widgets@5.3.12
 - @wordpress/editor@13.3.10
 - @wordpress/format-library@4.3.10
 - @wordpress/interface@5.3.8
 - @wordpress/list-reusable-blocks@4.3.7
 - @wordpress/preferences@3.3.7
 - @wordpress/reusable-blocks@4.3.10
 - @wordpress/rich-text@6.3.4
 - @wordpress/server-side-render@4.3.7
 - @wordpress/widgets@3.3.10

This changeset includes the following fixes:
- i18n: Add context to labels related to CSS position properties gutenberg#49135
- Comments: Fix 'sprintf requires more than 1 params' error gutenberg#49054
- Fix the site editor loading in multi-site installs gutenberg#49861
- Fix quick inserter going off-screen in some situations gutenberg#49881
- Site Editor: Decode the site title properly gutenberg#49685
- Firefox: fix input rules (React async state issue) gutenberg#48210
- Only show alignment info when parent layout is constrained. gutenberg#49703
- [Inserter]: Fix onHover error on patterns tab in mobile gutenberg#49450
- Fix site editor redirection after creating new template or template part gutenberg#49364

Props mamaduka, audrasjb, wildworks, ocean90, aristath, costdev, hellofromtonya, youknowriad, mdxfr, oandregal, mattwiebe, bph, ndiego, talldanwp, joen, ellatrix, kevin940726, isabel_brison, andrewserong, ntsekouras, welcher.
Fixes #58274.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-09 14:13:25 +00:00
Sergey Biryukov
5e0592d8f4 Docs: Improve HTML API file and class headers per the documentation standards.
Follow-up to [55203], [55304], [55718], [55724], [55727].

See #57840.
Built from https://develop.svn.wordpress.org/trunk@55734


git-svn-id: http://core.svn.wordpress.org/trunk@55246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-09 11:19:21 +00:00
Sergey Biryukov
5da872aa27 Docs: Improve Style Engine file and class headers per the documentation standards.
Follow-up to [54156], [55719].

See #57840.
Built from https://develop.svn.wordpress.org/trunk@55733


git-svn-id: http://core.svn.wordpress.org/trunk@55245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-09 10:37:22 +00:00
John Blackbourn
5ef972680a Docs: A host of corrections and improvements to inline documentation.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-08 22:37:24 +00:00
Sergey Biryukov
2ffb7ef083 Docs: Update code examples formatting in WP_HTML_Tag_Processor documentation.
Per the [https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#description documentation standards], code samples should be created by indenting every line of the code by 4 spaces, with a blank line before and after. This matches the format used by the rest of core.

Follow-up to [55203], [55304], [55718], [55724].

Props juanmaguitar, coffee2code, azaozz, costdev, dmsnell, johnbillion, SergeyBiryukov.
Fixes #58028.
Built from https://develop.svn.wordpress.org/trunk@55727


git-svn-id: http://core.svn.wordpress.org/trunk@55239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-08 17:32:24 +00:00
Sergey Biryukov
f28299d504 Coding Standards: Bring more consistency to PHP 8.0 string function polyfills.
This adjusts `str_contains()` code layout to have an early exit for an empty `$needle`, matching similar fragments in `str_starts_with()` and `str_ends_with()` for better readability.

Follow-up to [52039], [52040].

See #57839.
Built from https://develop.svn.wordpress.org/trunk@55726


git-svn-id: http://core.svn.wordpress.org/trunk@55238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-07 11:44:21 +00:00
Sergey Biryukov
8b53b81183 Docs: Remove @return void from various DocBlocks.
Per the documentation standards, it should not be used outside of the default bundled themes.

Follow-up to [52049], [52051], [53331], [54156], [54214], [55203], [55719].

See #57840.
Built from https://develop.svn.wordpress.org/trunk@55725


git-svn-id: http://core.svn.wordpress.org/trunk@55237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-06 11:40:24 +00:00
Sergey Biryukov
24eb807cbd Docs: Correct the placement of @see tags in WP_HTML_Tag_Processor class.
This moves a reference link in `::get_attribute_names_with_prefix()` below the code example, so that it is correctly displayed in the Developer Resources.

Includes updating some other `@see` tags for consistency as per the documentation standards.

Additionally, the example code for `WP_HTML_Tag_Processor::get_tag()` is updated to show lowercase tag names in the input HTML, so that it does not convey the wrong impression that the uppercase output from `::get_tag()` depends on the case of the input HTML.

Follow-up to [55203].

Props dmsnell, johnbillion, audrasjb, SergeyBiryukov.
Fixes #58254.
Built from https://develop.svn.wordpress.org/trunk@55724


git-svn-id: http://core.svn.wordpress.org/trunk@55236 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-05 12:43:21 +00:00
audrasjb
3911398ec5 HTML API: Restore mistakenly-removed content in documentation.
In [55718] the Unicode replacement character was mistakenly removed. The purpose of including the character was to communicate what it looks like and why the Tag Processor won't insert it into the document.

This changeset brings the character back and adds a small clue to fix the confusion that may lead to its removal.

Follow-up to [55718].

Props dmsnell.
Fixes #58256
See #57840.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-05 10:58:23 +00:00
Bernhard Reiter
f2d315036b HTML API: Adjust coding style to pass Gutenberg linter.
This patch adjusts some minor neutral whitespace that the Gutenberg linting rejects.
There are no code changes otherwise.

Props dmsnell.
Fixes #58250.
Built from https://develop.svn.wordpress.org/trunk@55721


git-svn-id: http://core.svn.wordpress.org/trunk@55233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-04 08:42:22 +00:00
Sergey Biryukov
7e9421e4d0 Upgrade/Install: Create a temporary backup of plugins and themes before updating.
This aims to make the update process more reliable and ensures that if a plugin or theme update fails, the previous version can be safely restored.

* When updating a plugin or theme, the old version is moved to a temporary backup directory:
 * `wp-content/upgrade-temp-backup/plugins/[plugin-slug]` for plugins
 * `wp-content/upgrade-temp-backup/themes/[theme-slug]` for themes.

* If the update fails, then the backup kept in the temporary backup directory is restored to its original location.
* If the update succeeds, the temporary backup is deleted.

To further help troubleshoot plugin and theme updates, two new checks were added to the Site Health screen:
* A check to make sure that the `upgrade-temp-backup` directory is writable.
* A check that there is enough disk space available to safely perform updates.

To avoid confusion: The temporary backup directory will NOT be used to “roll back” a plugin to a previous version after a completed update. This directory will simply contain a transient backup of the previous version of a plugin or theme being updated, and as soon as the update process finishes, the directory will be empty.

Follow-up to [55204], [55220].

Props afragen, costdev, pbiron, azaozz, hellofromTonya, aristath, peterwilsoncc, TJNowell, bronsonquick, Clorith, dd32, poena, TimothyBlynJacobs, audrasjb, mikeschroder, a2hosting, KZeni, galbaras, richards1052, Boniu91, mai21, francina, TobiasBg, desrosj, noisysocks, johnbillion, dlh, chaion07, davidbaumwald, jrf, thisisyeasin, ignatggeorgiev, SergeyBiryukov.
Fixes #51857.
Built from https://develop.svn.wordpress.org/trunk@55720


git-svn-id: http://core.svn.wordpress.org/trunk@55232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-04 02:36:23 +00:00
John Blackbourn
7a343e478e Docs: Correct and improve inline docs relating to the style engine.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 23:57:18 +00:00
John Blackbourn
89cbdce5c3 Docs: Improve formatting of markup in the docs for WP_HTML_Tag_Processor.
Code blocks wrapped inside backtacks don't need to be indented.

See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 23:55:16 +00:00
John Blackbourn
c3e63b8046 Build/Test Tools: Fix the permissions that are granted to the Slack notifications workflow.
Follow-up to [55715].

See #57865

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


git-svn-id: http://core.svn.wordpress.org/trunk@55229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 23:22:17 +00:00
audrasjb
8547f7b820 Help/About: Left-align 6.2 about page subheading.
This changeset removes the `aligncenter` class from `h2` and `is-subheading` items in the WordPress 6.2 About Page, for more consistent alignment. Also, future minor releases will add more left-aligned paragraphs under the "Maintenance Releases" section.

Props shagors, sabernhardt, mukesh27, amin7, costdev, pavanpatil1, audrasjb.
Fixes #57387.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 22:32:19 +00:00
John Blackbourn
5f1d229cbf Build/Test Tools: Restrict the permissions granted to jobs on GitHub Actions
The `permissions` key in a job declares the GitHub permissions that are granted to the token that's used by the job. Restricting the permissions reduces the impact that a vulnerability in the CI system can have.

Props desrosj, johnbillion

See #57865

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


git-svn-id: http://core.svn.wordpress.org/trunk@55227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 22:17:18 +00:00
John Blackbourn
bd393654cc Filesystem API: Correct and improve the return type documentation for the dirlist() method in WP_Filesystem_Base and its extending classes.
Props mat-lipe, szepeviktor, costdev, audrasjb, johnbillion

Fixes #58229
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55226 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 21:30:19 +00:00
audrasjb
12c65b6076 Script Loader: Update jQuery version to 3.6.4 to match the current version.
This changeset updates the jQuery version to 3.6.4 in `script-loader.php` to correcly match the current version used in WordPress.

This was accidentally missed in [55491].

Props nickpap, TobiasBg, dhrumilk.
Fixes #58203.
See #57324.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 21:27:21 +00:00
John Blackbourn
b155956792 Docs: Miscellaneous formatting corrections to inline docs and whitespace.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55224 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 19:46:21 +00:00
John Blackbourn
c83f4cb97a Docs: Corrections and improvements to docblocks for global styles, global settings, theme.json parsing, and shortcodes.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 18:48:22 +00:00
Sergey Biryukov
27c4548f19 General: Restore strpos() check in wp-admin/load-styles.php.
This resolves a fatal error on PHP < 8.0, as `wp-includes/compat.php` is not loaded in this file, so `str_starts_with()` may not be available.

Follow-up to [55703].

Props dd32, flixos90, DigTek.
Fixes #58244. See #58012.
Built from https://develop.svn.wordpress.org/trunk@55710


git-svn-id: http://core.svn.wordpress.org/trunk@55222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 15:46:22 +00:00
Andrea Fercia
6064478fa7 Post Types: Add the view_items label to the wp_block post type.
The `view_items` post type label is used in the Editor, for the `aria-label` of the link to go back to the Posts list. When editing a Reusable block, it fallbacks to 'View Posts'. It should be 'View Reusable blocks'.

Fixes #58209.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 14:08:18 +00:00
Bernhard Reiter
5a32396d8f HTML API: Accumulate shift for internal parsing pointer.
A bug was discovered where where the parser wasn't returning to the
start of the affected tag after making some updates.

In few words, the Tag Processor has not been treating its own internal
pointer `bytes_already_parsed` the same way it treats its bookmarks.
That is, when updates are applied to the input document and then
`get_updated_html()` is called, the internal pointer transfers to
the newly-updated content as if no updates had been applied since
the previous call to `get_updated_html()`.

In this patch we're creating a new "shift accumulator" to account for
all of the updates that accrue before calling `get_updated_html()`.
This accumulated shift will be applied when swapping the input document
with the output buffer, which should result in the pointer pointing to
the same logical spot in the document it did before the udpate.

In effect this patch adds a single workaround for treating the
internal pointer like a bookmark, plus a temporary pointer which points
to the beginning of the current tag when calling `get_updated_html()`.
This will preserve the assumption that updating a document doesn't
move that pointer, or shift which tag is currently matched.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 11:31:18 +00:00
audrasjb
59e90bba48 Docs: Various improvements in Bookmark Administration API function descriptions, as per docblocks standards.
Follow-up to [55704].

See #57840.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 10:03:21 +00:00
audrasjb
66016f2c12 Coding Standards: Remove unnecessary variable escapement in Bookmark Administration API.
This changeset removes an unnecessary `esc_html()` escapement for `link_url`, as `esc_url()` already does the job.

Follow-up to [11383].

Props utsav72640, audrasjb.
Fixes #58239.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 09:58:25 +00:00
Sergey Biryukov
2ec23a82ed Code Modernization: Replace usage of strpos() with str_starts_with().
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).

WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.

While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.

Follow-up to [52039], [52040], [52326].

Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703


git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 15:45:22 +00:00
spacedmonkey
c1facaa4ce Cache API: Add helper function wp_cache_set_last_changed.
Add a helper function called `wp_cache_set_last_changed` to set the last changed value for cache groups. This function has a new action called `wp_cache_set_last_changed`, allowing for developers to cache invalidate when last changed value is changed. 

Props tillkruess, spacedmonkey, peterwilsoncc, mukesh27, johnjamesjacoby. 
Fixes #57905.
Built from https://develop.svn.wordpress.org/trunk@55702


git-svn-id: http://core.svn.wordpress.org/trunk@55214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 11:26:24 +00:00
spacedmonkey
4bdeb57ac5 Taxonomy: Remove redundant call to get_term in wp_queue_posts_for_term_meta_lazyload.
In [55252] the function `wp_queue_posts_for_term_meta_lazyload` was refactored to use `wp_cache_get_multiple`. This refactor included a call to `get_term`. However, calling get_term calls `sanitize_term`, which sanitizes all fields in a term. The full term object is not needed in this context as term meta only needs to the term id, which is already in the function. Saving calls to `sanitize_term` will improve performance of this function. 

Props spacedmonkey, joemcgill, mukesh27. 
Fixes #57966.
Built from https://develop.svn.wordpress.org/trunk@55701


git-svn-id: http://core.svn.wordpress.org/trunk@55213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 10:57:24 +00:00
Sergey Biryukov
fe8c41f574 External Libraries: Update license URL in Text_Diff library.
The former URL used to refer to LGPL 2.1 at the time, but does not redirect to its current location.

Includes updating the `Algorithm::Diff` Perl module URL.

Props jigar-bhanushali, utsav72640.
Fixes #58217.
Built from https://develop.svn.wordpress.org/trunk@55700


git-svn-id: http://core.svn.wordpress.org/trunk@55212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-01 11:06:23 +00:00
Sergey Biryukov
a8390f5f7c Upgrade/Install: Update sodium_compat to v1.20.0.
The latest version of sodium_compat includes a fix for the Poly1305 implementation.

References:
* [https://github.com/paragonie/sodium_compat/releases/tag/v1.20.0 sodium_compat 1.20.0 release notes]
* [https://github.com/paragonie/sodium_compat/compare/v1.19.0...v1.20.0 Full list of changes in sodium_compat 1.20.0]

Follow-up to [49741], [51002], [51591], [52988], [54150], [54310].

Props jrf, costdev, paragoninitiativeenterprises, mukesh27.
Fixes #58224.
Built from https://develop.svn.wordpress.org/trunk@55699


git-svn-id: http://core.svn.wordpress.org/trunk@55211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-30 14:08:23 +00:00
Sergey Biryukov
9954d0a927 Coding Standards: Break out of the inner loop in make_site_theme_from_default().
This more closely matches the previous behavior with multiple `if`/`elseif` statements.

Follow-up to [55688].

See #56982.
Built from https://develop.svn.wordpress.org/trunk@55698


git-svn-id: http://core.svn.wordpress.org/trunk@55210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-29 18:30:23 +00:00
Sergey Biryukov
225fe28e9f Coding Standards: Bring some consistency to REST API revisions initialization.
The autosaves and revisions controllers used to set the same class properties in a slightly different order.

This commit makes the `::__construct()` methods of both classes more consistent to simplify future maintenance.

Follow-up to [46272], [51962].

See #57839.
Built from https://develop.svn.wordpress.org/trunk@55697


git-svn-id: http://core.svn.wordpress.org/trunk@55209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-28 15:06:21 +00:00