Commit Graph

31910 Commits

Author SHA1 Message Date
Pascal Birchler
a225165010 Role/Capability: Add support for capability queries in WP_User_Query.
Similar to the existing `role`/`role__in`/`role__not_in` query arguments, this adds support for three new query arguments in `WP_User_Query`:

* `capability` 
* `capability__in`
* `capability__not_in`

These can be used to fetch users with (or without) a specific set of capabilities, for example to get all users
with the capability to edit a certain post type.

Under the hood, this will check all existing roles on the site and perform a `LIKE` query against the `capabilities` user meta field to find:

* all users with a role that has this capability
* all users with the capability being assigned directly

Note: In WordPress, not all capabilities are stored in the database. Capabilities can also be modified using filters like `map_meta_cap`. These new query arguments do NOT work for such capabilities.

The prime use case for capability queries is to get all "authors", i.e. users with the capability to edit a certain post type.

Until now, `'who' => 'authors'` was used for this, which relies on user levels. However, user levels were deprecated a long time ago and thus never added to custom roles. This led to constant frustration due to users with custom roles missing from places like author dropdowns.

This updates any usage of `'who' => 'authors'` in core to use capability queries instead.

Subsequently, `'who' => 'authors'` queries are being **deprecated** in favor of these new query arguments.

Also adds a new `capabilities` parameter (mapping to `capability__in` in `WP_User_Query`) to the REST API users controller.

Also updates `twentyfourteen_list_authors()` in Twenty Fourteen to make use of this new functionality, adding a new `twentyfourteen_list_authors_query_args` filter to make it easier to override this behavior.

Props scribu, lgladdly, boonebgorges, spacedmonkey, peterwilsoncc, SergeyBiryukov, swissspidy.
Fixes #16841.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-27 18:43:57 +00:00
Sergey Biryukov
311cf99866 Docs: Document the usage of some globals in wp-includes/script-loader.php.
Follow-up to [44114], [44262], [49080], [50761], [51471].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51942


git-svn-id: http://core.svn.wordpress.org/trunk@51531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-27 18:21:58 +00:00
Sergey Biryukov
6a5a0062ff Script Loader: Correct the number of arguments passed to the closure in enqueue_block_styles_assets().
This avoids an `Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed` PHP fatal error when registering a block style with the `should_load_separate_core_block_assets` filter enabled.

Follow-up to [51471].

Props aristath, shimon246, jrf, gziolo.
Fixes #54323.
Built from https://develop.svn.wordpress.org/trunk@51941


git-svn-id: http://core.svn.wordpress.org/trunk@51530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-27 17:10:01 +00:00
Sergey Biryukov
156a453ed9 Coding Standards: Rename the $process variable to $processed_response for clarity in WP_Http_Streams::request().
Includes minor code layout fixes for better readability.

Follow-up to [8516], [51826], [51929], [51931].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51940


git-svn-id: http://core.svn.wordpress.org/trunk@51529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-27 15:03:58 +00:00
johnjamesjacoby
7a0a07d691 Admin/HTTP API: add suggested filename support to download_url().
This change allows for external clients to supply a suggested filename via a `Content-Disposition` response header. This filename is processed through `sanitize_file_name()` to ensure it is allowable (on the server, MIME's, etc...) and `validate_file()` to prevent directory traversal.

If the suggested filename fails the above processing/checks, that suggestion is discarded and the standard temporary filename (generated by WordPress) is used.

If no `Content-Disposition` header is found in the response headers, the standard temporary filename continues to be used as per normal.

Included in this change are 6 additional PHPUnit tests with 9 assertions. These tests confirm that valid filename values are correctly saved, and invalid filename values are correctly rejected.

Props cklosows, costdev, dd32, johnjamesjacoby, ocean90, psrpinto.

Fixes #38231.
Built from https://develop.svn.wordpress.org/trunk@51939


git-svn-id: http://core.svn.wordpress.org/trunk@51528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-27 15:00:01 +00:00
Sergey Biryukov
b8e6a3c334 Tests: Some test improvements for clean_dirsize_cache() tests:
* Move the directory being tested to the `data` directory, for consistency with other test data.
* Set the `svn:eol-style` property to `native`, for consistency with other files.
* Correct the test class name in `dummy.txt`.

Follow-up to [51246], [51910], [51911].

See #52241, #53363.
Built from https://develop.svn.wordpress.org/trunk@51938


git-svn-id: http://core.svn.wordpress.org/trunk@51527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-26 02:03:58 +00:00
desrosj
3867e66520 Build/Test Tools: Use the correct workflow name in notifications on workflow_run.
When a workflow is triggered through a `workflow_run` event, the context is not the original workflow. The details about the original workflow are passed through the `github.event` context.

This also moves the conditional check controlling whether the Slack workflow is run into the calling workflows to prevent them from running for pull requests.

Follow up to [51921-51922,51924-51925,51934].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51937


git-svn-id: http://core.svn.wordpress.org/trunk@51526 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-25 20:27:56 +00:00
desrosj
fc06dda73e Build/Test Tools: Restore Slack notifications for older branches.
In [51921], the GitHub Actions workflows were updated to utilize the Slack notifications workflow as a callable one instead of on the `workflow_run` event.

This eliminated the need for an additional “Slack Notifications” workflow run for every completed workflow, but only when other workflows are updated as well. This resulted in notifications from older branches breaking, as the changes in [51921] were not backported.

Instead of backporting the needed changes now (the Slack workflow is still being polished), this commit partially restores the `workflow_run` event for older branches so that notifications will resume.

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51934


git-svn-id: http://core.svn.wordpress.org/trunk@51525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-25 19:30:00 +00:00
Sergey Biryukov
d31f31c579 Coding Standards: Rename $theHeaders variable to $processed_headers in WP_Http_Curl::request().
This fixes a `Variable "$theHeaders" is not in valid snake_case format` WPCS warning.

Follow-up to [8516], [8520], [51826], [51929].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51931


git-svn-id: http://core.svn.wordpress.org/trunk@51524 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-25 16:20:00 +00:00
Peter Wilson
cdf1000cbb Docs: Use sign-up & signup consistently in wp-signup.php.
In the docblocks throughout `wp-signup.php` use sign up for verbs and sign-up for nouns.

Props audrasjb, jeffpaul.
Fixes #54041. See #53399.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51523 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-25 00:23:57 +00:00
Sergey Biryukov
f8f74e7aa5 Coding Standards: Rename the $arrHeaders variable to $processed_headers in WP_Http_Streams::request().
This fixes a `Variable "$arrHeaders" is not in valid snake_case format` WPCS warning.

Follow-up to [8516], [51826].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51929


git-svn-id: http://core.svn.wordpress.org/trunk@51522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-24 19:23:00 +00:00
Sergey Biryukov
50aa2df391 Tests: Add @ticket references for page_on_front canonical tests.
Follow-up to [669/tests], [849/tests], [36238], [47760].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51928


git-svn-id: http://core.svn.wordpress.org/trunk@51521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-23 12:38:01 +00:00
Sergey Biryukov
d468eb17c3 Coding Standards: Escape id attributes in WP_Customize_Control::render_content() and ::print_template().
Follow-up to [30014], [38906].

Props sabbirshouvo.
See #54295.
Built from https://develop.svn.wordpress.org/trunk@51927


git-svn-id: http://core.svn.wordpress.org/trunk@51520 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-22 16:09:59 +00:00
Sergey Biryukov
4152fbfdb2 Coding Standards: Improve escaping in wp_login_form().
* Split long concatenated lines using `sprintf()`. This aims to improve readability and avoid multiple `esc_attr()` calls for the same value.
* Escape the form `name` and `id` attributes.

Follow-up to [12696], [18444], [19033].

Props sabbirshouvo, mukesh27, audrasjb, henry.wright, SergeyBiryukov.
Fixes #54279.
Built from https://develop.svn.wordpress.org/trunk@51926


git-svn-id: http://core.svn.wordpress.org/trunk@51519 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-21 18:19:00 +00:00
desrosj
e791d7f5db Build/Test Tools: Fix syntax for passing secrets to a called workflow.
Follow up to [51923].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51925


git-svn-id: http://core.svn.wordpress.org/trunk@51518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-20 19:51:58 +00:00
desrosj
1d76e9f33c Build/Test Tools: Pass required secrets to the Slack notifications workflow.
Secrets are not available within callable workflows by default. They must be defined within the callable workflow, and passed from the calling workflow.

Follow up to [51921-51922].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51924


git-svn-id: http://core.svn.wordpress.org/trunk@51517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-20 19:26:57 +00:00
Sergey Biryukov
e6ede0c816 Coding Standards: Improve escaping in wp-admin/theme-install.php.
* Rename a duplicate `$feature_name` variable to `$feature_group` for clarity.
* Escape the remaining `$feature_name` variable.

Follow-up to [27636], [35273].

Props sabbirshouvo, sabernhardt, mukesh27, afragen.
Fixes #54277.
Built from https://develop.svn.wordpress.org/trunk@51923


git-svn-id: http://core.svn.wordpress.org/trunk@51516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-20 19:18:01 +00:00
desrosj
b54ec08215 Build/Test Tools: Adjustments as a follow up to [51921].
This adjusts the syntax for using the `github-scripts` action.

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51922


git-svn-id: http://core.svn.wordpress.org/trunk@51515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-20 15:36:58 +00:00
desrosj
0f8c4989b0 Build/Test Tools: Modify the Slack notifications workflow to be a reusable one.
The ability to reuse workflow files within GitHub Action workflows was recently added and allows for less code duplication.

In the context of WordPress Core, this also eliminates the need for an additional “Slack Notifications” workflow to run for every completed workflow.

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51921


git-svn-id: http://core.svn.wordpress.org/trunk@51514 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-20 14:42:02 +00:00
Sergey Biryukov
2c84d63322 Help/About: Don't output empty <span> tags on Credits screen.
If the contributor does not have a title, the empty tags are not necessary.

Follow-up to [17877], [17909], [17942], [18162], [19143], [46709].

Props sayedulsayem, audrasjb, mukesh27.
Fixes #54275.
Built from https://develop.svn.wordpress.org/trunk@51920


git-svn-id: http://core.svn.wordpress.org/trunk@51513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-19 23:09:00 +00:00
hellofromTonya
234877c9c3 Coding Standards: Add public visibility to methods in src directory.
This commit adds the `public` visibility keyword to each method which did not have an explicit visibility keyword.

Why `public`?

With no visibility previously declared, these methods are implicitly `public` and available for use. Changing them to anything else would be a backwards-compatibility break.

Props costdev, jrf.
See #54177.
Built from https://develop.svn.wordpress.org/trunk@51919


git-svn-id: http://core.svn.wordpress.org/trunk@51512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-18 17:52:58 +00:00
Sergey Biryukov
a60032feec Coding Standards: Add a leading zero in the CSS declarations printed by the print_emoji_styles() function.
Follow-up to [31733], [31786].

Props audrasjb, sabernhardt.
Fixes #54284.
Built from https://develop.svn.wordpress.org/trunk@51918


git-svn-id: http://core.svn.wordpress.org/trunk@51511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-18 16:53:57 +00:00
hellofromTonya
db3a05178b Cron: Remove errant false values in cron array when upgrading to 5.9+.
[51916] fixed a bug where `array( `false` )` was added to the cron array when `_get_cron_array()` returned `false`. 

This commit:
* Removes any `false` values from the cron array when upgrading to 5.9+.
* Bumps the database version.

Follow-up to [44917], [51916].

Props peterwilsoncc, jrf.
See #53950.
Built from https://develop.svn.wordpress.org/trunk@51917


git-svn-id: http://core.svn.wordpress.org/trunk@51510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-18 13:30:57 +00:00
hellofromTonya
248c36d748 Cron: Fix malformed cron array in wp_schedule_single_event() when _get_cron_array() returns false.
In `wp_schedule_single_event()`, the cron info array is retrieved via a call to `_get_cron_array()` and straight away cast to an array. But as the documentation for that function (correctly) states, the return type of that function is `array|false`, where `false` is returned for a site where no cron jobs have been scheduled (yet).

In the case that `_get_cron_array()` would return `false`, this would now unintentionally create an array with a single entry with key `0` and as the value `false`.

This is a bug. Fixed now by adding validation to the output of `_get_cron_array()` and initializing `$crons` to an empty array if `false` was returned.

Tests added first to prove the bug (a) was introduced in #44818 [44917] and (b) is now fixed.

Follow-up to [44917].

Props jrf, peterwilsoncc.
Fixes #53950.
Built from https://develop.svn.wordpress.org/trunk@51916


git-svn-id: http://core.svn.wordpress.org/trunk@51509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-18 12:51:58 +00:00
John Blackbourn
00b914db08 REST API: Correct the order of the parameters documented for WP_REST_Server::respond_to_request().
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51508 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-18 11:14:57 +00:00
Sergey Biryukov
cea5785cdb Coding Standards: Consistently escape form action URL in wp-admin/update-core.php.
Follow-up to [10166], [23739], [25806].

Props sabbirshouvo, mukesh27.
Fixes #54278.
Built from https://develop.svn.wordpress.org/trunk@51914


git-svn-id: http://core.svn.wordpress.org/trunk@51507 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-17 20:31:02 +00:00
Sergey Biryukov
8447683474 Docs: Improve documentation for the tax_input parameter of wp_insert_post().
Follow-up to [10222], [13217], [33922].

Props dingo_d.
Fixes #54264.
Built from https://develop.svn.wordpress.org/trunk@51913


git-svn-id: http://core.svn.wordpress.org/trunk@51506 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-16 02:38:58 +00:00
hellofromTonya
4a1cc2c3e2 FileSystem API: Add safeguard for invalid return from get_attached_file() in wp_delete_attachment().
The `get_attached_file()` function is supposed to return the path to the file, but could:
1. Return `false` if the file doesn't exist.
2. Return literally anything else, as a filter is being applied to the value on return.

As the `clean_dirsize_cache()` now has input validation, passing anything but a non-empty string to `clean_dirsize_cache()` will result in a PHP error notice.

This was exposed by the `Tests_Post_GetPostStatus::wpSetUpBeforeClass()` method which started generating unexpected output (the doing it wrong message) during the test run.

While this indicates that there is a flaw in the mocking being done in the test suite, debugging that is outside of the scope of the current patch.

At the same time, as based on the above point, this ''could'' potentially happen in a real-world situation as well, adding additional conditions to the `if` in the `wp_delete_attachment()` function before calling the `clean_dirsize_cache()` function, is warranted.

As there are no tests for the `wp_delete_attachment()` function at all at this time, we're not adding a test specifically for this change for now. This should however be addressed in the future, when tests will be added to cover the `wp_delete_attachment()` function completely. 

Follow-up to [32619], [49212], [51910].

Props jrf, hellofromTonya.
See #52241.
Built from https://develop.svn.wordpress.org/trunk@51912


git-svn-id: http://core.svn.wordpress.org/trunk@51505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-15 22:58:56 +00:00
hellofromTonya
4471c3787c FileSystem API: Fix autovivification deprecation notice in recurse_dirsize().
>PHP natively allows for autovivification (auto-creation of arrays from falsey values). This feature is very useful and used in a lot of PHP projects, especially if the variable is undefined. However, there is a little oddity that allows creating an array from a `false` and `null` value.

The above quote is from the PHP 8.1 RFC and the (accepted) RFC changes the behaviour described above to deprecated auto creation of arrays from `false`. As it is deprecated, it _will_ still work for the time being, but as of PHP 9.0, this will become a Fatal Error, so we may as well fix it now.

The `recurse_dirsize()` function retrieves a transient and places it in the `$directory_cache` variable, but the `get_transient()` function in WP returns `false` when the transient doesn't exist, which subsequently can lead to the above mentioned deprecation notice.

By verifying that the `$directory_cache` variable is an array before assigning to it and initializing it to an empty array, if it's not, we prevent the deprecation notice, as well as harden the function against potentially corrupted transients where this transient would not return the expected array format, but some other variable type.

Includes adding dedicated unit tests for both the PHP 8.1 issue, as well as the hardening against corrupted transients.

Includes some girl-scouting: touching up a parameter description and some code layout.

Refs:
* https://wiki.php.net/rfc/autovivification_false
* https://developer.wordpress.org/reference/functions/get_transient/

Follow-up to [49212], [49744].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51911


git-svn-id: http://core.svn.wordpress.org/trunk@51504 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-15 22:53:58 +00:00
hellofromTonya
82141be0d8 FileSystem API: Fix infinite loop on Windows for clean_dirsize_cache().
When the PHP native `dirname()` function is used on a Windows disk name - i.e. `C:\`-, it will return the same, i.e, it will return `C:\` again.

The `clean_dirsize_cache()` function didn't have guard clause against this, which meant that on Windows based systems and IIS servers, this function would result in WordPress getting stuck into an infinite loop.

The adjustment to the `while` part of the function fix this by checking if the return value of the `dirname()` function call is the same as the original path passed to `dirname()`, which effectively fixes the infinite loop.

A number of other improvements made:

1. Add input validation for the `$path` parameter to guard against invalid variable types being passed into the function.

2. Guard against an empty `$path` parameter, which would result in an infinite loop on both Windows as well as *nix based systems.

In both these cases, a PHP notice will now be thrown.

3. When a non-empty string, which isn't a path would previously be passed, the `dirname()` function would transform that to a `.` and the `.` key in the transient cache would be cleared out.
This was a bug as there is no relation between a non-path string and the root directory of file system.

This bug has been fixed by checking that something could actually be a path and handling received non-empty, non-path input parameters in a special way, i.e only removing the cache key for the passed string and bowing out from further processing.

Unfortunately, no tests can be added to guard against the infinite loop.

For the other fixes, we have added appropriate unit tests. 

Follow-up up [49212], [49616], [49744].

Props jrf, hellofromTonya, raubvogel, sergeybiryukov, codezen8, sjlevy, drosmog, teachlynx, ekojr, bartoszgrzesik, joegasper, janthiel, josephdickson, ocean90, audrasjb.
Fixes #52241.
Built from https://develop.svn.wordpress.org/trunk@51910


git-svn-id: http://core.svn.wordpress.org/trunk@51503 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-15 22:25:01 +00:00
Gary Pendergast
44caec31bd Embeds: Add Wolfram Notebook as a trusted oEmbed provider.
Fixes #53326.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-15 05:04:56 +00:00
Rachel Baker
1f261d083a REST API: Add text-field and textarea-field as available schema formats for string sanitization.
Props ocean90, TimothyBlynJacobs.
Fixes #49960.
Built from https://develop.svn.wordpress.org/trunk@51908


git-svn-id: http://core.svn.wordpress.org/trunk@51501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-15 02:04:56 +00:00
Sergey Biryukov
8b8b5d8ecc Media: Display the unsaved changes dialog in image edit form using jQuery .text() function.
This ensures that HTML entities like non-breaking spaces are properly displayed instead of being encoded.

Props jdy68, sebastienserre, audrasjb, mukesh27, SergeyBiryukov.
Fixes #54232.
Built from https://develop.svn.wordpress.org/trunk@51907


git-svn-id: http://core.svn.wordpress.org/trunk@51500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-15 00:18:56 +00:00
Sergey Biryukov
000a1202ad Docs: Update WP_Date_Query documentation to reflect changes in accepted column names.
Remove outdated list of accepted column name values, add a reference to `WP_Date_Query::validate_column()` and the `date_query_valid_columns` filter instead for a more detailed description.

Follow-up to [25139], [25860], [29933], [29934], [29938], [37477], [51905].

Props dimadin, johnjamesjacoby.
Fixes #54248.
Built from https://develop.svn.wordpress.org/trunk@51906


git-svn-id: http://core.svn.wordpress.org/trunk@51499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-14 18:05:04 +00:00
Sergey Biryukov
b2c8d3bb8c Docs: Update documentation for the date_query_valid_columns filter.
Add a `@since` note for `registered` and `last_updated` as default recognized date query columns. 

Follow-up to [25139], [25860], [29933], [29934], [29938], [37477].

Props dimadin, johnjamesjacoby.
See #54248.
Built from https://develop.svn.wordpress.org/trunk@51905


git-svn-id: http://core.svn.wordpress.org/trunk@51498 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-13 20:00:01 +00:00
hellofromTonya
d2694aa466 Build/Test Tools: Add end-to-end (e2e) tests README.md.
Adds a readme to the `/tests/e2e/` folder to provide (a) instructions of how to run the tests locally and (b) links to documentation.

Follow-up to [45570].

Props isabel_brison, desrosj, justinahinon.
Fixes #53550.
Built from https://develop.svn.wordpress.org/trunk@51904


git-svn-id: http://core.svn.wordpress.org/trunk@51497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-12 18:52:00 +00:00
Sergey Biryukov
1020306fe9 I18N: Add context for some Media Library filter strings:
* Audio
* Video
* Unattached

This allows for more homogeneous translations in languages where keeping a plural form is important.

Follow-up to [6910], [7397], [8901], [9556], [11749], [13100], [12110], [15491], [15578], [22743], [29426], [29625], [34256], [45651], [46437].

Props jdy68, audrasjb, SergeyBiryukov.
Fixes #54238.
Built from https://develop.svn.wordpress.org/trunk@51903


git-svn-id: http://core.svn.wordpress.org/trunk@51496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-12 16:44:01 +00:00
Sergey Biryukov
2030b6e313 Upgrade/Install: Restore or clean up the temporary plugin or theme backup on shutdown.
This allows these actions to run ''after'' the main process, without affecting the update. Actions running on `shutdown` are immune to PHP timeouts, so in case the failure was due to a PHP timeout, we'll still be able to properly restore the previous version.

Follow-up to [51815], [51898], [51899].

Props aristath, peterwilsoncc.
See #54166.
Built from https://develop.svn.wordpress.org/trunk@51902


git-svn-id: http://core.svn.wordpress.org/trunk@51495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-11 15:09:05 +00:00
Sergey Biryukov
130979f91e External Libraries: Revert [51900] for now to investigate test failures.
See #54162.
Built from https://develop.svn.wordpress.org/trunk@51901


git-svn-id: http://core.svn.wordpress.org/trunk@51494 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-10 01:16:57 +00:00
Sergey Biryukov
0c2f44099a External Libraries: Update getID3 to version 1.9.21.
The latest version includes preliminary PHP 8.1 support, as well as a variety of bug fixes.

Release notes: https://github.com/JamesHeinrich/getID3/releases/tag/v1.9.21

A full list of changes in this update can be found on GitHub:
https://github.com/JamesHeinrich/getID3/compare/v1.9.20...v1.9.21

This commit also includes PHPCS adjustments previously made for a passing PHP Compatibility scan.

Follow-up to [47601], [47737], [47902], [48278], [49621], [50714].

Props jrf, SergeyBiryukov.
Fixes #54162.
Built from https://develop.svn.wordpress.org/trunk@51900


git-svn-id: http://core.svn.wordpress.org/trunk@51493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-10 00:13:58 +00:00
Sergey Biryukov
d5887aeec3 Upgrade/Install: Introduce a move_dir() function.
This replaces the `copy_dir()` usage in `WP_Upgrader::install_package()` and aims to avoid PHP timeout issues when installing or updating large plugins on slower systems like Vagrant or the WP Docker test environment.

The new function attempts a native PHP `rename()` function first and falls back to the previous `copy_dir()`.

Follow-up to [51815], [51898].

Props afragen, aristath, peterwilsoncc, galbaras, noisysocks, pbiron.
Fixes #54166. See #51857.
Built from https://develop.svn.wordpress.org/trunk@51899


git-svn-id: http://core.svn.wordpress.org/trunk@51492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-09 03:38:57 +00:00
Sergey Biryukov
0f2d2264b5 Site Health: Use an integer value as a fallback in the available disk space check.
This avoids a few type problems further in the code: boolean divided by a number, or passing `false` to `size_format()` which is documented to accept integers or strings only.

Follow-up to [51815].

Props TobiasBg.
See #51857.
Built from https://develop.svn.wordpress.org/trunk@51898


git-svn-id: http://core.svn.wordpress.org/trunk@51491 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-09 02:50:56 +00:00
Andrew Ozz
aef14e6d1b External Libraries: Update jQuery UI to 1.13.0 final.
Props Clorith, mgol, azaozz.
Fixes #52163.
Built from https://develop.svn.wordpress.org/trunk@51897


git-svn-id: http://core.svn.wordpress.org/trunk@51490 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-08 18:06:00 +00:00
Sergey Biryukov
c477dcda88 Taxonomy: Populate the WP_Terms_List_Table::$items property in ::prepare_items().
This allows the parent `WP_List_Table::has_items()` method to work as expected, and the override in the child class can now be removed. It also makes the class more consistent with other list table classes.

As a result of this change, the "Bulk actions" dropdown is no longer unnecessarily displayed if there are no terms.

Follow-up to [15491], [17025], [17026].

Props mattoakley, swissspidy, audrasjb, SergeyBiryukov.
Fixes #54181.
Built from https://develop.svn.wordpress.org/trunk@51896


git-svn-id: http://core.svn.wordpress.org/trunk@51489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-08 00:38:00 +00:00
Sergey Biryukov
f57070bfd1 Docs: Add a @since note for the new $parent_block parameter of several filters:
* `pre_render_block`
* `render_block_data`
* `render_block_context`

Follow-up to [51894].

See #51612.
Built from https://develop.svn.wordpress.org/trunk@51895


git-svn-id: http://core.svn.wordpress.org/trunk@51488 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-07 13:15:59 +00:00
Andrew Ozz
2dc8f381ca Apply the pre_render_block, render_block_data, and render_block_context filters when rendering inner/nested blocks. Introdices another param to these filters: $parent_block that is the "parent" WP_Block instance for nested blocks and null for top level blocks. Adds unit tests for the filters.
Props noisysocks, gaambo, azaozz.
Fixes #51612.
Built from https://develop.svn.wordpress.org/trunk@51894


git-svn-id: http://core.svn.wordpress.org/trunk@51487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-06 18:49:01 +00:00
Sergey Biryukov
b3d3473ba0 Twenty Twenty-One: Remove duplicate width and height values from social icons.
These values are added dynamically by the `Twenty_Twenty_One_SVG_Icons::get_svg()` method and are not needed in the source array.

Follow-up to [49216].

Props max-dayala, laxman-prajapati, sabernhardt, Presskopp, mukesh27.
Fixes #54208.
Built from https://develop.svn.wordpress.org/trunk@51893


git-svn-id: http://core.svn.wordpress.org/trunk@51486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-06 15:39:05 +00:00
hellofromTonya
84e3375cd7 Permalinks: Move the Nginx documentation link to help sidebar in wp-admin/options-permalink.php.
The "Documentation on Nginx configuration." link is out of place being below the "Save Changes" button on the Settings > Permalinks UI.

This commit relocates the link to join the other support related content links in the help tab's "For more information:" right sidebar area.

Follow-up to [34691], [45674].

Props audrasjb, hellofromTonya, johnjamesjacoby, mukesh27, peterwilsoncc, timlappe.
Fixes #39258.
Built from https://develop.svn.wordpress.org/trunk@51892


git-svn-id: http://core.svn.wordpress.org/trunk@51485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-05 23:11:06 +00:00
Sergey Biryukov
a1c50512d7 Accessibility: Privacy: Use red color for action buttons on the Erase Personal Data screen:
* "Erase Personal Data" button in the Next Steps column.
* "Force Erase Personal Data" row action.

This highlights the destructive nature of those buttons to avoid an accidental erasure, and is consistent with other similar UI elements in the admin, e.g. various "Delete", "Spam", or "Trash" buttons.

Props arena, sabernhardt, carike, azaozz, joedolson, audrasjb, SergeyBiryukov.
Fixes #49603.
Built from https://develop.svn.wordpress.org/trunk@51891


git-svn-id: http://core.svn.wordpress.org/trunk@51484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-05 20:32:05 +00:00
desrosj
dca9c85ff7 Build/Test Tools: Change the patch version used for testing the 5.6 branch of PHP.
This unpins the version of PHP 5.6.20 used when testing the 5.6 branch of PHP.

Using 5.6.20 was an intentional decision in [49162], as that patch version is the oldest version of PHP 5.6 still supported by WordPress. However, as of September 30, 2021, the `5.6.20` image contains a version of OpenSSL with an expired certificate, sometimes resulting in an expired trust chain.

Props Clorith, hellofromTonya, SergeyBiryukov, desrosj.
Merges [51889] to `trunk`.
Fixes #54223.
Built from https://develop.svn.wordpress.org/trunk@51890


git-svn-id: http://core.svn.wordpress.org/trunk@51483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-05 17:34:59 +00:00
hellofromTonya
a64837dfde Coding Standards: Use strict type check for in_array() in register_block_script_handle().
Follow-up to [51501].

Props aristath, sergeybiryukov.
Fixes #54206. See #53359.
Built from https://develop.svn.wordpress.org/trunk@51888


git-svn-id: http://core.svn.wordpress.org/trunk@51481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-05 16:53:00 +00:00
hellofromTonya
3c16cc2cfb Administration: Allow plugin action links row to wrap.
When there are several action links or the text for these links is long, the plugin name column's width extends causing the other columns to shrink in width. This case is a less than desirable user experience.

The plugin name's column has `white-space: nowrap` (on larger screens). This commit changes the `white-space` to `normal`, allowing the plugin action links row to wrap into more than one line.

Follow-up to [41695].

Props ankit-k-gupta, nekojonez, sabernhardt, sergeybiryukov.
Fixes #53275.
Built from https://develop.svn.wordpress.org/trunk@51887


git-svn-id: http://core.svn.wordpress.org/trunk@51480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-05 15:07:05 +00:00
John Blackbourn
cf84fbc988 Docs: Improve various inline documentation for admin bar functions and hooks.
Props audrasjb

See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51479 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-04 20:46:59 +00:00
John Blackbourn
41995176f6 Docs: Miscellaneous inline documentation improvements, including:
* Document the post statuses global as an array of `stdClass` objects
* Document the taxonomies global as an array of `WP_Taxonomy` objects
* Document the return value of the post count functions as `stdClass` objects
* Fix some typos

See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-04 20:44:02 +00:00
Sergey Biryukov
fb5454c94f Build/Test Tools: Update the @wordress/e2e-test-utils package to version 5.4.3.
This is needed in order to use the [7a33cd43a2/packages/e2e-test-utils/src/rest-api.js REST API functions] implemented in a recent version in Core e2e tests.

Props justinahinon.
Fixes #54215.
Built from https://develop.svn.wordpress.org/trunk@51884


git-svn-id: http://core.svn.wordpress.org/trunk@51477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-04 11:46:23 +00:00
Sergey Biryukov
b5f1eb9103 HTTP: Remove the DST Root CA X3 certificate expired on September 30, 2021.
> The currently recommended certificate chain as presented to Let’s Encrypt ACME clients when new certificates are issued contains an intermediate certificate (ISRG Root X1) that is signed by an old DST Root CA X3 certificate that expires on 2021-09-30. In some cases the OpenSSL 1.0.2 version will regard the certificates issued by the Let’s Encrypt CA as having an expired trust chain.
> 
> Most up-to-date CA cert trusted bundles, as provided by operating systems, contain this soon-to-be-expired certificate. The current CA cert bundles also contain an ISRG Root X1 self-signed certificate. This means that clients verifying certificate chains can find the alternative non-expired path to the ISRG Root X1 self-signed certificate in their trust store.
> 
> Unfortunately this does not apply to OpenSSL 1.0.2 which always prefers the untrusted chain and if that chain contains a path that leads to an expired trusted root certificate (DST Root CA X3), it will be selected for the certificate verification and the expiration will be reported.

References:
* [https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ Old Let’s Encrypt Root Certificate Expiration and OpenSSL 1.0.2]
* [https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/ DST Root CA X3 Expiration (September 2021)]

Follow-up to [25224], [25426], [25569], [27307], [30491], [30765], [34283], [35919], [36570], [46094].

Props bradleyt, fierevere.
Fixes #54207. See #50828.
Built from https://develop.svn.wordpress.org/trunk@51883


git-svn-id: http://core.svn.wordpress.org/trunk@51476 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-03 17:51:06 +00:00
TimothyBlynJacobs
bb7a0cf334 REST API: Sort widget types by their id.
Fixes #53303.
Props spacedmonkey.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51475 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-02 21:45:03 +00:00
Sergey Biryukov
e286586eda Twenty Twenty-One: Keep the closing </span> tag in footer links.
When the `link_after` value is emptied to reset any description markup, make sure not to remove the closing tag within footer links.

Follow-up to [49216].

Props sabernhardt, mukesh27.
Fixes #54209.
Built from https://develop.svn.wordpress.org/trunk@51881


git-svn-id: http://core.svn.wordpress.org/trunk@51474 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-02 17:06:00 +00:00
hellofromTonya
b3c6ad3a6b Administration: Enable first and last page buttons in WP_List_Table::pagination().
Previously the first and last page pagination buttons were disabled when on their next or previous page respectively. This commit removes that unnecessary logic to keep these buttons enabled and avoid confusion in the user's navigation workflow. 

New behavior:
- When on page 2, the go to first page `«` button is enabled
- When on the page before the last page, the go to last page `»` button is enabled

Follow-up to [32948], [47219].

Props wp_kc, ronakganatra, knutsp, sabernhardt, Hareesh Pillai, audrasjb, hellofromTonya.
Fixes #42763.
Built from https://develop.svn.wordpress.org/trunk@51880


git-svn-id: http://core.svn.wordpress.org/trunk@51473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-01 18:39:58 +00:00
Sergey Biryukov
3fd3bc0cde Coding Standards: Use strict comparison in wp-includes/class-wp-http-ixr-client.php.
Follow-up to [16064], [16871], [17928].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51879


git-svn-id: http://core.svn.wordpress.org/trunk@51472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-01 15:00:58 +00:00
hellofromTonya
bc217668e2 App Passwords: Remove placeholder from the app password name input field.
In [49294, 49752], the `placeholder` attribute changed to `"WordPress App on My Phone"`. This change causes confusion as the field can be used in a variety of ways and is not limited to a phone.

Given a label exists for each field and clearly identifies its purpose, this commit removes the `placeholder` attribute from the `input` field.

Follow-up to [49109], [49294], [49752].

Props seedsca, audrasjb, joedolson, rehanali.
Fixes #54047.
Built from https://develop.svn.wordpress.org/trunk@51878


git-svn-id: http://core.svn.wordpress.org/trunk@51471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-01 13:49:00 +00:00
Sergey Biryukov
1cad6cfc26 Coding Standards: Use strict comparison in wp-includes/class-http.php.
Follow-up to [10625], [10864], [13274], [29661], [33748], [47508], [47808].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51877


git-svn-id: http://core.svn.wordpress.org/trunk@51470 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-30 14:05:02 +00:00
Sergey Biryukov
fee2d3ed94 Docs: Improve documentation for WP_Admin_Bar methods.
Add some missing descriptions and `@since` tags.

Follow-up to [15671], [19120], [19429], [19501], [19558], [25475], [25478], [25563], [32534], [35157], [40947], [45821], [48826].

Props yagniksangani, hellofromTonya, audrasjb, sabernhardt, mukesh27, rehanali, SergeyBiryukov.
Fixes #54191.
Built from https://develop.svn.wordpress.org/trunk@51876


git-svn-id: http://core.svn.wordpress.org/trunk@51469 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-29 13:39:59 +00:00
Sergey Biryukov
06cea7de84 Twenty Twenty-One: Remove duplicate class name from localized font-family elements.
Follow-up to [46613], [49216], [51874].

Props tmatsuur, aezazshekh.
See #54196.
Built from https://develop.svn.wordpress.org/trunk@51875


git-svn-id: http://core.svn.wordpress.org/trunk@51468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-28 10:02:57 +00:00
Sergey Biryukov
e7cfe2c963 Twenty Twenty: Remove duplicate class name from localized font-family elements.
Follow-up to [46613].

Props tmatsuur, aezazshekh.
Fixes #54196.
Built from https://develop.svn.wordpress.org/trunk@51874


git-svn-id: http://core.svn.wordpress.org/trunk@51467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-28 10:00:59 +00:00
Sergey Biryukov
8c52bfe712 Coding Standards: Remove duplicate assignment from a ternary operator in WP_MS_Sites_List_Table::site_states().
Adjust similar code in `_post_states()` and `_media_states()` for consistency.

Follow-up to:
* [12897], [15491], [32755], [46153], [48424] for `WP_MS_Sites_List_Table::site_states()`.
* [17793], [47775], [49223] for `_media_states()`.
* [9153], [46309] for `_post_states()`.

Props joelcj91, audrasjb, desrosj.
Fixes #38296.
Built from https://develop.svn.wordpress.org/trunk@51873


git-svn-id: http://core.svn.wordpress.org/trunk@51466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-27 00:37:01 +00:00
Sergey Biryukov
e85dab2fa8 Tests: Update the Services_JSON test for PHPUnit 9.5.10/8.5.21+.
Since PHPUnit 9.5.10 and 8.5.21, PHP deprecations are no longer converted to exceptions by default (`convertDeprecationsToExceptions="true"` can be configured to enable this).

Reference: [fac02620f6 Do not convert PHP deprecations to exceptions by default]; [https://github.com/sebastianbergmann/phpunit/blob/9.5.10/ChangeLog-9.5.md#9510---2021-09-25 PHPUnit 9.5.10 changelog].

With this change, the test for the `Services_JSON` compat class started failing:
{{{
There was 1 failure:

1) Tests_Compat_jsonEncodeDecode::test_json_encode_decode
Failed asserting that exception of type "PHPUnit\Framework\Error\Deprecated" is thrown.
}}}

This converts the native PHPUnit `::expectDeprecation()` method call in the test to a set of individual WP-specific `::setExpectedDeprecated()` method calls in order to not depend on PHPUnit behavior that is no longer the default.

Additionally, this commit includes support for catching deprecation notices from `_deprecated_file()` function calls to the `WP_UnitTestCase_Base::expectDeprecated()` method.

Follow-up to [46205], [46625], [48996], [51563], [51852], [51871].

Props jrf, netweb, SergeyBiryukov.
See #54183, #54029, #53363.
Built from https://develop.svn.wordpress.org/trunk@51872


git-svn-id: http://core.svn.wordpress.org/trunk@51465 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-26 03:28:58 +00:00
Sergey Biryukov
d227f83302 Build/Test Tools: Update PHPUnit configuration for PHPUnit 9.5.10/8.5.21+.
Since PHPUnit 9.5.10 and 8.5.21, PHP deprecations are no longer converted to exceptions by default (`convertDeprecationsToExceptions="true"` can be configured to enable this).

Reference: [fac02620f6 Do not convert PHP deprecations to exceptions by default]; [https://github.com/sebastianbergmann/phpunit/blob/9.5.10/ChangeLog-9.5.md#9510---2021-09-25 PHPUnit 9.5.10 changelog].

Let's unpack this:

Previously (PHPUnit < 9.5.10/8.5.21), if PHPUnit would encounter a PHP native deprecation notice, it would:
1. Show a test which causes a deprecation notice to be thrown as **"errored"**,
2. Show the **first** deprecation notice it encountered and
3. PHPUnit would exit with a **non-0 exit code** (2), which will fail a CI build.

As of PHPUnit 9.5.10/8.5.21, if PHPUnit encounters a PHP native deprecation notice, it will no longer do so. Instead PHPUnit will:
1. Show a test which causes a PHP deprecation notice to be thrown as **"risky"**,
2. Show the **all** deprecation notices it encountered and
3. PHPUnit will exit with a **0 exit code**, which will show a CI build as passing.

This commit reverts PHPUnit to the previous behaviour by adding `convertDeprecationsToExceptions="true"` to the PHPUnit configuration. It also adds the other related directives for consistency.

Props jrf, netweb, costdev, SergeyBiryukov.
See #54183.
Built from https://develop.svn.wordpress.org/trunk@51871


git-svn-id: http://core.svn.wordpress.org/trunk@51464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-26 03:12:57 +00:00
Sergey Biryukov
7d3ddd45f6 Tests: Don't skip some Ajax tests on multisite, add them to the ms-excluded group instead.
Follow-up to [46693], [49835].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51870


git-svn-id: http://core.svn.wordpress.org/trunk@51463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-26 00:14:03 +00:00
Sergey Biryukov
0d262c0b50 Tests: Remove unnecessary setUp() and tearDown() methods in multisite tests.
These were originally added in [26252] to suppress database errors on `setUp()` and restore on `tearDown()` for tests that call `wpmu_create_blog()`, blog factory, or installation code that attempts to clear transients.

As the multisite test coverage expanded, these methods ended up being unnecessarily copied into other test classes, where database error suppression is not required.

Follow-up to [26252], [29916], [30286], [33184], [34898], [34899], [34901], [37234], [37477], [37894], [49212], [49616], [51859].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51869


git-svn-id: http://core.svn.wordpress.org/trunk@51462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-25 01:28:57 +00:00
hellofromTonya
9de31fa1ab Build/Test Tools: Remove the PHPUnit container from local Docker environment.
This commit:

* Removes the PHPUnit `wordpressdevelop/phpunit` container as a service to the Docker environment.
* Updates `test:php` (the default way to run tests) to run the Composer PHPUnit package  default.
* Removes the `test:php-composer` script.

There is no longer a need for core to keep the `wordpressdevelop/phpunit` container as a service in `docker-compose.yml`. Removing it will reduce the overhead and bandwidth needed to set up WordPress locally and remove confusion about its use.

Follow-up to [45783-45784], [49099], [49362], [51545], [51736], [51685].

Props johnbillion, hellofromTonya.
Fixes #54112.
Built from https://develop.svn.wordpress.org/trunk@51868


git-svn-id: http://core.svn.wordpress.org/trunk@51461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-24 16:56:00 +00:00
Sergey Biryukov
71d35a918f Tests: Rename classes in phpunit/tests/multisite/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646], [51650], [51651].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51860


git-svn-id: http://core.svn.wordpress.org/trunk@51459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-24 00:46:56 +00:00
Sergey Biryukov
b19cb16e34 Tests: Further improve the tests for avoid_blog_page_permalink_collision():
* Rename the test filename and class to match the name of the function being tested.
* Remove unnecessary `setUp()` and `tearDown()` methods.
* Replace the `only` test group with `post`.

Follow-up to [51855-51857].

See #51147.
Built from https://develop.svn.wordpress.org/trunk@51859


git-svn-id: http://core.svn.wordpress.org/trunk@51458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-24 00:30:56 +00:00
Sergey Biryukov
6341115d9c Tests: Correct the @ticket reference in wp_terms_checklist() tests.
Follow-up to [48880].

See #53363, #51137.
Built from https://develop.svn.wordpress.org/trunk@51858


git-svn-id: http://core.svn.wordpress.org/trunk@51457 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-24 00:13:57 +00:00
hellofromTonya
e2b13ae81b Build/Test Tools: Upgrades Tests_Multisite_MS_Permalink_Collision fixture methods and strict assertion.
Improvements include:

- Upgrades the test fixture methods to the new snake_case methods.
- Reorders the fixture methods for consistency.
- Uses strict assertions of assertSame and assertNotSame.

Follow-up to [51855-51856].

Props hellofromTonya.
See #51147.
Built from https://develop.svn.wordpress.org/trunk@51857


git-svn-id: http://core.svn.wordpress.org/trunk@51456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-23 21:30:57 +00:00
whyisjake
7ce933c695 Coding Standards: Fix the alignment of the array.
Unprops: whyisjake.
See [51855].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-23 20:34:56 +00:00
whyisjake
f2d1e16f50 Posts, Post Types: Don't add a trailing number when there is a unique post parent.
WordPress tries to avoid an issue where slugs might match an existing slug of a page/post. 
If we are in a hierarchical post type, there will be a level, and we can leave it the same.

Props stormrockwell, SergeyBiryukov, terriann, tubys, jeremyfelt, Daschmi, MaximeCulea, knutsp, whyisjake.
Fixes #51147.
See also #44112 and #45260.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51454 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-23 20:27:58 +00:00
Sergey Biryukov
052b00b0c4 Docs: Fix typo in the $clear_working parameter description in WP_Upgrader methods.
Follow-up to [30758], [51527].

Props zenithcity, aezazshekh, pbiron, mukesh27.
Fixes #54163.
Built from https://develop.svn.wordpress.org/trunk@51854


git-svn-id: http://core.svn.wordpress.org/trunk@51453 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-23 14:23:01 +00:00
hellofromTonya
847b7d8690 Code Modernization: Fix "passing null to non-nullable" deprecation in _mb_substr().
The `_mb_substr()` function expects a string for the `$str` parameter, but does not do input validation. This function contains a `preg_match_all()` which also expects a string type for the given subject (i.e. `$str`). 

Passing `null` to this parameter results in `preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated` notice on PHP 8.1.

To maintain the same behaviour as before, a guard clause is added to bail out early when `$str` is passed as `null`. The outcome will, in that case, only ever be an empty string.

Note: this does mean that the `_mb_substr()` function now has a subtle difference in behaviour compared to the PHP native `mb_substr()` function as the latter ''will'' throw the deprecation notice.

The existing tests already cover this issue.

Follow-up to [17621], [36017], [32364].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51853


git-svn-id: http://core.svn.wordpress.org/trunk@51452 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-22 23:34:57 +00:00
hellofromTonya
f52bf291cb Build/Test Tools: Splits and improves compat tests.
Splits the tests in the `tests/phpunit/tests/compat.php` file up into individual test classes for each function being tested.

Improvements to individual test cases:
* Adds `@covers` tags.
* Adds visibility modifiers to all methods.
* Adds function availability test.
* Where relevant, fixes the assertion parameter order.
* Data provider:
   * Where relevant, reworks a test to use a data provider.
   * Where relevant, renames data provider methods to have a more obvious link to the test it applies to.
   * Makes the data provider more readable by adding keys within the data sets.
   * Moves the data provider below its associated tests.
   * Adds/removes data sets in data providers.
* Makes the actual test code more readable by using descriptive variables and multi-line function calls.
* Adds the `$message` parameter to all assertions when a test method contains more than one assertion.

Specifically for the `_mb_substr()` tests:
* Splits the `test_mb_substr_phpcore()` method into two test methods based on the PHP Core test files they are emulating.
* Makes the actual test code within the `test_mb_substr_phpcore_basic()` method more readable by using descriptive variables and multi-line function calls.
* Splits the data used for the second part of the `test_mb_substr_phpcore()` function, now `test_mb_substr_phpcore_input_type_handling()`, off into a separate data provider with named data sets.
* Removes duplicate data sets from the `data_mb_substr_phpcore_input_type_handling()`. 
   * Why? The PHP native tests test against upper/lowercase `false`, `true`, `null` and some other text string single quote/double quote variations. As things were, those differentiations had been undone when the coding standards were put in place, so in effect those weren't being tested anymore. And as this is userland code, there's no point in adding these differentiations back as they will be handled the same by PHP anyway (and that is safeguarded via the PHP native tests).
* Removes the "undefined variable" and "unset variable" test cases as, while those are relevant to the C code in which PHP is written, they are not relevant for testing userland code and will behave the same as the test passing `null`.

Follow-to [25002], [32364], [42228], [42343], [43034], [43036], [43220], [43571], [45607], [47122], [47198], [48937], [48996], [51415], [51563], [51594].

Props jrf, hellofromTonya.
See #39265, #53363.
Built from https://develop.svn.wordpress.org/trunk@51852


git-svn-id: http://core.svn.wordpress.org/trunk@51451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-22 23:06:56 +00:00
John Blackbourn
6e1cc35a98 Docs: Miscellaneous docblock corrections and improvements.
See #52217, #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-22 21:23:00 +00:00
John Blackbourn
07f3c35467 General: Fix code quality issues which were identified by static analysis.
This fixes minor issues that could cause PHP notices under the right conditions, and fixes some general incorrectness.

Props jrf, hellofromTonya for review

See #52217

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


git-svn-id: http://core.svn.wordpress.org/trunk@51449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-22 21:01:00 +00:00
Sergey Biryukov
a016bf3172 Docs: Update description for retrieve_widgets() per the documentation standards.
Follow-up to [51842].

See #53811.
Built from https://develop.svn.wordpress.org/trunk@51849


git-svn-id: http://core.svn.wordpress.org/trunk@51448 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-22 14:11:00 +00:00
Andrew Ozz
25daf03a8e Update and enhance the docs for retrieve_widgets().
Props zieladam, hellofromtonya.
Fixes #53811.
Built from https://develop.svn.wordpress.org/trunk@51842


git-svn-id: http://core.svn.wordpress.org/trunk@51447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-21 22:13:57 +00:00
John Blackbourn
01ff7448d2 Formatting: Pass the block instance as a parameter to the render_block filters.
This allows filters to access properties and methods on the block instance.

Fixes #53596

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


git-svn-id: http://core.svn.wordpress.org/trunk@51446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-21 21:32:57 +00:00
John Blackbourn
ae9eae8f64 Docs: Document some more common names for dynamic hooks and standardise the phrasing used.
Fixes #53581

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


git-svn-id: http://core.svn.wordpress.org/trunk@51444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-21 18:21:00 +00:00
Sergey Biryukov
70f1109c9f Docs: Add @since notes to register_setting() for the deprecated misc and privacy option groups.
Follow-up to [13745], [13746], [13749], [21838], [51827].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51832


git-svn-id: http://core.svn.wordpress.org/trunk@51439 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-21 13:22:01 +00:00
hellofromTonya
eb85900d55 Build/Test Tools: Fix null handling and string type casting in WP_UnitTestCase_Base::assertSameIgnoreEOL().
Basically, the whole `assertSameIgnoreEOL()` assertion was fundamentally flawed. The assertion contends that it checks that the expected and actual values are of the same type and value, but the reality was very different.

* The function uses `map_deep()` to potentially handle all sorts of inputs.
* `map_deep()` handles arrays and objects with special casing, but will call the callback on everything else without further distinction.
* The callback used passes the expected/actual value on to the `str_replace()` function to remove potential new line differences.
* And the `str_replace()` function will - with a non-array input for the `$subject` - always return a string.
* The output of these calls to `map_deep()` will therefore have "normalized" _all properties_ in objects, _all values_ in arrays and _all non-object, non-array values_ to strings.
* And a call to `assertSame()` will therefore NEVER do a proper type check as the type of all input has already, unintentionally, been "normalized" to string.

Aside from this clear flaw in the design of the assertion, PHP 8.1 now exposes a further issue as a `null` value for an object property, an array value or a plain value, will now yield a ` str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated` notice.

To fix both these issues, the fix in this PR ensures that the call to `str_replace()` will now only be made if the input is a text string.
All other values passed to the callback are left in their original type.

This ensures that a proper value AND type comparison can be done as well as prevents the PHP 8.1 deprecation notices.

Ref:
* https://developer.wordpress.org/reference/functions/map_deep/
* https://www.php.net/manual/en/function.str-replace.php

This commit:
- Fixes type-casting of non-string values to `string` (the flawed part of this assertion) by invoking `str_replace()` when the value is of string type.
- Fixes the PHP 8.1 `str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated` deprecation notice.
- Micro-optimization: skips `map_deep()` when actual and/or expected are `null` (no need to process).
- Adjusts the method documentation for both this method and the `assertEqualsIgnoreEOL()` alias method to document that the `$expected` and `$actual` parameters can be of any type.

Follow-up to [48937], [51135], [51478].

Props jrf, hellofromTonya.
See #53363, #53635.
Built from https://develop.svn.wordpress.org/trunk@51831


git-svn-id: http://core.svn.wordpress.org/trunk@51438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-20 19:59:55 +00:00
hellofromTonya
bb4c9b56f3 REST API: Fix autovivification deprecation notice in WP_Test_REST_Widgets_Controller::set_up().
If the `'widget_testwidget'` option does not exist, `false` was returned from `get_option()`. The `set_up()` logic expects an `array()` and assigns values to keys without checking for an array. The automatic creation of an array (autovivification) triggers a `Deprecated: Automatic conversion of false to array is deprecated in` deprecation notice on PHP 8.1.

This commit:
- Fixes the deprecation notice by making the default value an empty array.
- Moves getting the option within the conditional where it's needed.
- Provides a micro-optimization by only getting the options when the conditions are correct for processing.
- Makes the code consistent within the `set_up()` for both `get_option()` instances.

Follow-up to [51029].

Props jrf, hellofromTonya, BinaryKitten.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51830


git-svn-id: http://core.svn.wordpress.org/trunk@51437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-20 18:49:58 +00:00
hellofromTonya
1c55ce2482 Login and Registration: Fix "passing null to non-nullable" deprecation for authorize_application error message.
If there is no URL query in the `$_GET['redirect_to'], `wp_parse_url()` will return `null`. Passing `null` to `parse_str()` results in a PHP 8.1 deprecation notice
{{{
Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated
}}}

This commit:
- Fixes the deprecation notice.
- Skips doing the `parse_str()` when there's no URL query.
- Provides a micro-optimization performance boost.

Follow-up to [49109].

Props jrf, hellofromTonya, BinaryKitten.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51829


git-svn-id: http://core.svn.wordpress.org/trunk@51436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-20 18:22:57 +00:00
hellofromTonya
e2f3071988 Build/Test Tools: Improve Composer update command in bootstrap error messages.
Refines the test bootstrap error message to include the `-W` in the Composer update command.

Why?

To also update the chain of dependencies for the tests' dependencies. 

`composer update` will update the tests' direct dependencies.
 
`composer update -W` will update the dependencies including *their* dependencies, which is the recommended course of action for WP.

Follow-up to [51598], [51811], [51813].

Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51828


git-svn-id: http://core.svn.wordpress.org/trunk@51435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-20 16:44:59 +00:00
johnjamesjacoby
79c59fa78c Docs: Remove deprecated option groups from register_setting() and add_option_update_handler().
* `misc` was deprecated in version 3.0.0.
* `privacy` was deprecated in version 3.5.0.

See #53399.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51434 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-20 16:20:00 +00:00
Sergey Biryukov
64857a2a8e Coding Standards: Rename the $processedHeaders variable to $processed_headers in WP_Http::request().
This fixes a `Variable "$processedHeaders" is not in valid snake_case format` WPCS warning.

Follow-up to [8620], [51823].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51826


git-svn-id: http://core.svn.wordpress.org/trunk@51433 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-20 12:07:00 +00:00
Sergey Biryukov
baa81b67d1 Coding Standards: Rename the $arrURL variable to $parsed_url in WP_Http_Streams::request().
This fixes a `Variable "$arrURL" is not in valid snake_case format` WPCS warning.

Follow-up to [8620], [10509], [25044], [25224], [45667], [51823], [51824].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51825


git-svn-id: http://core.svn.wordpress.org/trunk@51432 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-19 17:00:57 +00:00
Sergey Biryukov
4892fd7bac Coding Standards: Rename the $arrURL variable to $parsed_url in WP_Http_Cookie::__construct().
This fixes a `Variable "$arrURL" is not in valid snake_case format` WPCS warning.

Follow-up to [10509], [25044], [45667], [51823].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51824


git-svn-id: http://core.svn.wordpress.org/trunk@51431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-19 16:59:56 +00:00
Sergey Biryukov
dfbdd86d59 Coding Standards: Rename the $arrURL variable to $parsed_url in WP_Http::request().
This fixes a `Variable "$arrURL" is not in valid snake_case format` WPCS warning.

Follow-up to [10509], [45667].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51823


git-svn-id: http://core.svn.wordpress.org/trunk@51430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-19 16:58:59 +00:00
Sergey Biryukov
01e6d31b3f Coding Standards: Use strict comparison in wp-inclues/class-wp-http-cookie.php.
Follow-up to [10512].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51822


git-svn-id: http://core.svn.wordpress.org/trunk@51429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-18 19:56:04 +00:00
Gary Pendergast
8a5e9b79ed Embeds: Add Pinterest as a trusted oEmbed provider.
Props ayeshrajans, pento.

Fixes #53448.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51428 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-17 03:13:56 +00:00
Sergey Biryukov
8feb26bcfe Twenty Twenty-One: Add missing escaping for the "Secondary menu" label.
Props muhammadfaizanhaidar, teucrium, sabernhardt, mukesh27, SergeyBiryukov.
Fixes #54127.
Built from https://develop.svn.wordpress.org/trunk@51820


git-svn-id: http://core.svn.wordpress.org/trunk@51427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-16 21:32:00 +00:00
jorgefilipecosta
5932bb0f8e Block editor: Cache global stylesheet by theme key.
Global styles are used in a few different contexts (front, editor, customizer, the theme directory). In the last two contexts, it's important that switching themes immediately refreshes the global stylesheet, to avoid situations in which the styles of the previous theme load with the new one. This was brought up at WordPress/gutenberg#34531 (customizer) and at meta.trac.wordpress.org/ticket/5818 (theme directory).
This commit makes sure the stylesheet is regenerated upon switching themes.

Props oandregal, dd32.
See #53175.
Built from https://develop.svn.wordpress.org/trunk@51819


git-svn-id: http://core.svn.wordpress.org/trunk@51426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-16 18:05:00 +00:00
hellofromTonya
4fe5f325ad Options, Meta APIs: Fix "passing null to non-nullable" deprecations to (get|add|update|delete)_option().
In all four of the `get_option()`, `add_option()`, `update_option()` and `delete_option()` functions, the `$option` parameter (i.e. the option name) is passed to the PHP native `trim()` function without prior input validation.

In PHP 8.1, this could lead to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` for each of these functions.

`trim()`:

- expects a text string and is only useful when ''passed'' a text string as no other variable type can contain whitespace.
- will always return a `string`, which means that in practice for any non-string values passed, it would effectively function as a type cast to string.

This commit:
- Adds a check to verify the `$option` name is a scalar before processing it with `trim()`.
- The "type cast" behavior is maintained.
- If the given `$option` name is not a scalar, such as `null`, the fix prevents the PHP 8.1 deprecation notice.
- Tests are added for valid but undesired option names to safeguard against regressions.

This issue is already covered by:
- the existing `Tests_Option_Option::test_bad_option_names()` test group.
- the new `test_valid_but_undesired_option_names()` tests.

Follow-up to [13858], [22633], [23510], [25002], [51817].

Props jrf, hellofromTonya, pbearne.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51818


git-svn-id: http://core.svn.wordpress.org/trunk@51425 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-15 22:19:58 +00:00
hellofromTonya
8dd2206ab1 Build/Test Tools: Reworks Tests_Option_Option::test_bad_option_names() into data provider.
The existing tests were running multiple functions through a `foreach()`. If any test failed, it would bail out and not test against the other scenarios.

This commit:

- Moves the scenarios to a data provider with named data sets, i.e. to ensure all scenarios are run and tested regardless if any fail.
- Splits each function under test into individual test methods.
- Adds a float scenario.
- Adds method visibility modifiers.

Follow-up to [25002].

Props jrf, hellofromTonya, pbearne.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51817


git-svn-id: http://core.svn.wordpress.org/trunk@51424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-15 21:22:58 +00:00
hellofromTonya
4b9a809bd7 Media: Fix $content parameter default value in img_caption_shortcode().
The shortcode content is expected to be a string, not `null`. `do_shortcode()` expects a string for `$content`.

The `img_caption_shortcode()` also expects a string for the `$content` parameter and is expected to return a string for the HTML content to display the caption. 

Prior to this commit:
The default value for the `$content` parameter was set to `null`. If no `$content` was passed, the function:
- could return `null` when the `$atts['width'] < 1` or there was no caption
- else, it invoked `do_shortcode( $content )` passing `null` which on PHP 8.1+ triggers a deprecation notice:
{{{
strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
}}}

This commit:

- Fixes the default `$content` value to align to the expected shortcode content of `string`, not `null`.
- Fixes the PHP 8.1 deprecation notice when `null` was being passed to `do_shortcode()`.
- Changes the assertion in a couple of tests to check for the empty string instead of `null.

Follow-up to [8196], [8925], [8239], [26915], [31530], [42704].

Props jrf, hellofromTonya, azaozz, joedolson.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51816


git-svn-id: http://core.svn.wordpress.org/trunk@51423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-15 19:06:57 +00:00
Sergey Biryukov
dcca93232b 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 temporary backup kept in the `upgrade/temp-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 `temp-backup` directory is writable.
* A check that there is enough disk space available to safely perform updates.

To avoid confusion: The `temp-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.

Props aristath, afragen, pbiron, dd32, poena, TimothyBlynJacobs, audrasjb, mikeschroder, a2hosting, hellofromTonya, KZeni, galbaras, richards1052, Boniu91, mai21, francina, SergeyBiryukov.
See #51857.
Built from https://develop.svn.wordpress.org/trunk@51815


git-svn-id: http://core.svn.wordpress.org/trunk@51422 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-15 18:41:00 +00:00
Sergey Biryukov
a13f7b31cd I18N: Add a translator comment to clarify the "Block HTML" string in the Block widget settings form.
The string refers to HTML code of the block, not an option that blocks HTML.

Follow-up to [50995].

Props Amieiro, NekoJonez, knutsp, johnbillion, namith.jawahar, SergeyBiryukov.
Fixes #54110.
Built from https://develop.svn.wordpress.org/trunk@51814


git-svn-id: http://core.svn.wordpress.org/trunk@51421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-15 11:49:01 +00:00
hellofromTonya
3e3c3541e5 Build/Test Tools: Expect an absolute path in WP_TESTS_PHPUNIT_POLYFILLS_PATH constant.
This commit:
* Removes the use of `realpath()` to prevent issues with WSL and other virtualized filesystems.
* Changes the logic of the Polyfill bootstrap loading to expect an absolute path, rather than a relative path to the root directory of the PHPUnit Polyfills library.
* Adjusts the relevant inline documentation and error messages to expect an absolute path.
* Breaks up error messages into smaller line lengths for readability.

Follow-up to [51598], [51810], [51811], [51812].

Props jrf, schlessera, hellofromTonya, jeherve, lucatume.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51813


git-svn-id: http://core.svn.wordpress.org/trunk@51420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-14 18:53:57 +00:00
hellofromTonya
dde311cae9 Build/Test Tools: Improve messaging when PHPUnit Polyfills do not comply with version requirements.
Previously, two situations were taken in to account:
1. The `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant is defined => just show a message about the version mismatch.
2. The constant is not defined => show a message to run `composer update`. This message is intended for people trying to run the WP Core tests.

This could lead to an unclear situation for people trying to run plugin/theme integration tests without the new `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant being defined.

They could be shown the message to run `composer update` while if they would do so for their local install without adding the Polyfills, the message would still display the next time they would attempt to run the tests.

This commit:
1. Provides more information about the PHPUnit Polyfills version detected vs the version expected.
2. Shows a more specific message to guide users which have the `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant declared.
3. Only shows the message to run `composer update` when the `WP_RUN_CORE_TESTS` constant is declared to prevent confusing people more.

Follow-up to [51598], [51810], [51811].

Props jrf, schlessera, hellofromTonya, jeherve, lucatume.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51812


git-svn-id: http://core.svn.wordpress.org/trunk@51419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-14 18:48:56 +00:00
hellofromTonya
0c8b83a7c2 Build/Test Tools: Improve messaging when PHPUnit Polyfills cannot be found.
Previously, two situations were taken in to account:
1. The `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant is defined => show message specific to that constant not being set correctly.
    This message would typically be shown for plugin/theme integration tests which are already aware of the changes in WP 5.9.
2. The constant is not defined => show a message to run `composer update`.
    This message is intended for people trying to run the WP Core tests.

This left two situations unaccounted for:
- Someone trying to run the WP Core tests, but not having set the `WP_RUN_CORE_TESTS` constant or not having set it to `1`.
- Someone trying to run plugin/theme integration tests without the new `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant being defined as they are not (yet) aware of the changes made in WP 5.9.

The changes made in this commit, are intended to improve the error messages displayed in those situations.

Follow-up to [51598], [51810].

Props jrf, schlessera, hellofromTonya, jeherve, lucatume.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51811


git-svn-id: http://core.svn.wordpress.org/trunk@51418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-14 18:41:56 +00:00
hellofromTonya
130040c54e Build/Test Tools: Make WP_TESTS_PHPUNIT_POLYFILLS_PATH more flexible.
The constant `WP_TESTS_PHPUNIT_POLYFILLS_PATH` is intended to contain the path to the root directory of the PHPUnit Polyfills library without trailing slash.

The code already took into account that the value could potentially include a trailing slash.

Now it will also take into account if it is accidentally set to point to the autoload file instead of the path.

Follow-up to [51598].

Props jrf, schlessera, hellofromTonya, jeherve, lucatume.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51810


git-svn-id: http://core.svn.wordpress.org/trunk@51417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-14 18:33:57 +00:00
Sergey Biryukov
d6cb1e4317 Docs: Update description for the $wp_version global.
In addition to holding the version number, the WordPress version string is used to bust caches and to enable development mode for scripts when running from the `/src` directory.

Follow-up to [803], [2585], [6554], [47230].

Props muhammadfaizanhaidar, azaozz.
Fixes #53413.
Built from https://develop.svn.wordpress.org/trunk@51809


git-svn-id: http://core.svn.wordpress.org/trunk@51416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-14 17:31:59 +00:00
Sergey Biryukov
128975e7ce Twenty Seventeen: Make blog header margin more specific on front page.
This avoids a large gap between title and content when the layout is set to one column.

Props laurelfulford, sabernhardt, hirofumi2012, jainnidhi, mukesh27.
Fixes #43628.
Built from https://develop.svn.wordpress.org/trunk@51808


git-svn-id: http://core.svn.wordpress.org/trunk@51415 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-14 10:19:01 +00:00
Sergey Biryukov
7d6308c3c7 Twenty Eleven: Set a fixed height for search form when header image is added.
This ensures that the search form does not collide with the menu on smaller screens.

Props sabernhardt, fedepia, Soean, lukecavanagh, mukesh27.
Fixes #40398.
Built from https://develop.svn.wordpress.org/trunk@51807


git-svn-id: http://core.svn.wordpress.org/trunk@51414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-13 20:41:56 +00:00
hellofromTonya
e838c96df4 Code Modernization: Fix "passing null to non-nullable" deprecation notice in WP_Comment_Query::get_comment_ids().
The `WP_Comment_Query::get_comment_ids()` method is supposed to handle `null` as a search query, but was throwing a `strlen(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1.

Discovered via and already covered via the pre-existing `Tests_Comment_Query::test_search_null_should_be_ignored()` test method.

Follow-up to [36345], [48275].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51806


git-svn-id: http://core.svn.wordpress.org/trunk@51413 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-13 18:54:59 +00:00
Sergey Biryukov
65ff35bb75 Site Health: Move the Imagick entry higher in the list of recommended PHP extensions.
This better matches its position in the [https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions Hosting Team's handbook] recommendations.

Follow-up to [44986], [46268], [51804].

See #52654.
Built from https://develop.svn.wordpress.org/trunk@51805


git-svn-id: http://core.svn.wordpress.org/trunk@51412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-12 10:09:57 +00:00
Sergey Biryukov
e76b896881 Site Health: Add Intl to the list of recommended PHP extensions.
**Why is the PHP Intl extension important?**

WordPress is a global, international software, with support for a multitude of languages and with infinite combinations. Approximately half of the installations are in a language that is not the default (English), and this leads us to think about localization, transliteration, encoding conversions, calendar operations, collation… in short, everything you have with the different languages and formats that are around the planet. And this is what the [https://www.php.net/manual/en/intro.intl.php PHP Intl extension] provides.

**What do we as the WordPress Community gain from this extension?**

This extension provides a lot of functions for better internationalization support, including but not limited to:
* [https://www.php.net/manual/en/collator.compare.php collator_compare()] to compare Unicode text strings
* [https://www.php.net/manual/en/numberformatter.format.php numfmt_format()] to format a number according to the selected locale
* the [https://www.php.net/manual/en/normalizer.normalize.php normalization] of characters
* the [https://www.php.net/manual/en/messageformatter.formatmessage.php formatting] of messages
* getting the [https://www.php.net/manual/en/intlcalendar.getfirstdayofweek.php first day of the week] according to the locale.


In addition to functionality and ease of development, the extension can also help improve security, with classes like `Spoofchecker` that can tell you [https://www.php.net/manual/en/spoofchecker.areconfusable.php if ‘google.com’, ‘goog1e.com’ can confuse the user], or functions related to Internet domains, both to convert an [https://www.php.net/manual/en/function.idn-to-ascii.php IDN domain to text] and [https://www.php.net/manual/en/function.idn-to-utf8.php text to IDN].

**Hosting Team Recommendation**

Taking into account that WordPress continues to grow, the Hosting Team has considered a good recommendation, but not an obligation, for all hosts that work with WordPress to offer this extension, by default, to all users.

Reference: [https://make.wordpress.org/hosting/2021/05/20/why-hosters-should-install-the-php-intl-extension/ Why hosters should install the PHP-intl extension].

Follow-up to [44986], [46268].

Props zodiac1978, JavierCasares, jrf, Clorith, josklever.
Fixes #52654.
Built from https://develop.svn.wordpress.org/trunk@51804


git-svn-id: http://core.svn.wordpress.org/trunk@51411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-11 18:20:59 +00:00
hellofromTonya
e16eaa4935 Code Modernization: Fix "passing null to non-nullable" deprecation notices in WP_Http::normalize_cookies().
The `Requests_Cookie` class expects valid - non-`null` - attributes to be passed, either as an array or as a `Requests_Utility_CaseInsensitiveDictionary` object.

However, the `WP_Http_Cookie::get_attributes()` explicitly sets the `expires`, `path` and `domain` index keys in an array with values which _may_ be `null`. This will cause `strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated`-like errors when the attributes are passed to the `Requests_Cookie` class.

Note: a `null` value for `path` would generate a similar deprecation notice, but for the `preg_match()` function.

Fixed by using `array_filter()` on the attributes to explicitly filter out `null` values before passing the attributes to `Requests_Cookie`.

Note: I'm choosing to explicitly only filter `null` values. Using `array_filter()` without a callback would filter out all "empty" values, but that may also remove values which are explicitly set to `false` or `0`, which may be valid values.

Fixes two errors in the `external-http` group in the WordPress Core test suite:
{{{
1) Tests_HTTP_Functions::test_get_response_cookies_with_wp_http_cookie_object
strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated

/var/www/src/wp-includes/Requests/Cookie.php:268
/var/www/src/wp-includes/Requests/Cookie.php:237
/var/www/src/wp-includes/Requests/Cookie.php:90
/var/www/src/wp-includes/class-http.php:460
/var/www/src/wp-includes/class-http.php:349
/var/www/src/wp-includes/class-http.php:624
/var/www/src/wp-includes/http.php:162
/var/www/tests/phpunit/tests/http/functions.php:156

2) Tests_HTTP_Functions::test_get_cookie_host_only
strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated

/var/www/src/wp-includes/Requests/Cookie.php:268
/var/www/src/wp-includes/Requests/Cookie.php:237
/var/www/src/wp-includes/Requests/Cookie.php:90
/var/www/src/wp-includes/class-http.php:460
/var/www/tests/phpunit/tests/http/functions.php:235
}}}

Follow-up to [38164], [45135], [51657].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51801


git-svn-id: http://core.svn.wordpress.org/trunk@51408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 17:43:57 +00:00
hellofromTonya
5081870aa8 Tests: Fix "null to non-nullable" deprecation notice in Tests_Admin_IncludesPlugin::test_get_plugin_files_folder().
The `Tests_Admin_IncludesPlugin::_create_plugin()` expects the first parameter to be a text string to be written to a plugin file using `fwrite()`.

Passing null causes a `fwrite(): Passing null to parameter #2 ($data) of type string is deprecated` notice.

Ref: https://www.php.net/manual/en/function.fwrite

Follow-up to [31002]. [41806].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51800


git-svn-id: http://core.svn.wordpress.org/trunk@51407 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 17:27:57 +00:00
hellofromTonya
d345fe2e69 Code Modernization: Fix "passing null to non-nullable" deprecation in wpdb::_real_escape().
The PHP native `mysqli_real_escape_string()` function expects to be passed a string as the second parameter and this is not a nullable parameter.

Passing `null` to it will result in a `mysqli_real_escape_string(): Passing null to parameter #2 ($string) of type string is deprecated` notice on PHP 8.1.

Previously, an input type check was put in place to prevent fatal errors on PHP 8.0 when an array, object or resource was passed. Changeset [48980].

A `null` value was explicitly excluded from that check, even though a `null` value being passed would only ever result in an empty string anyway.

This commit changes the previous input type check to also bow out early for `null` values and to automatically return an empty string for those.

Refs:
- https://www.php.net/manual/en/mysqli.real-escape-string.php
- https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Follow-up to [48980].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51799


git-svn-id: http://core.svn.wordpress.org/trunk@51406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 16:36:57 +00:00
hellofromTonya
62709d3d26 Tests: Add tests for wpdb::_real_escape().
Adds a new dedicated test file.

Adds a test to check that various input types passed to `wpdb::_real_escape()` are handled correctly.

Note: This new test does not test the actual escaping or other logic in the function. Rather, it just and only tests and documents how the function handles various input types.

Props jrf, hellofromTonya.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51798


git-svn-id: http://core.svn.wordpress.org/trunk@51405 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 16:30:57 +00:00
hellofromTonya
1c8de0817f Code Modernization: Fix null to non-nullable deprecations in WP_Meta_Query::get_sql_for_clause().
In the `WP_Meta_Query::get_sql_for_clause()`, the `'value'` index from a meta query array is passed to the PHP native `trim()` function without prior validation.

In PHP 8.1, this could lead to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice.

`trim()` expects a text string and is only useful when ''passed'' a text string as no other variable type can contain whitespace.

Fixed now by verifying that the ''value'' is a string before processing it with `trim()`.

This issue is already covered by the existing `Tests_Meta_Query::test_null_value_sql()` and the `Tests_Meta_Query::test_convert_null_value_to_empty_string()` tests.

Follow-up to [17699], [29887], [29940].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51797


git-svn-id: http://core.svn.wordpress.org/trunk@51404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 16:01:03 +00:00
hellofromTonya
243e75eb41 Code Modernization: Fix null to non-nullable deprecation in term_exists().
The `term_exists()` function expects a string or an integer for the `$term` parameter. It validates for integer, but not for string or `null`.

One of the pre-existing test cases, passed `null` to the function, leading to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1.

Fixed now by doing a cursory check on the variable at the start of the function and bowing out early in case the `$term` is `null`.

The issue was discovered via and is already covered by the `Tests_TermExists::test_term_exists_unknown()` test method.

Follow-up to [15220]. [38716].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51796


git-svn-id: http://core.svn.wordpress.org/trunk@51403 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 15:03:57 +00:00
Sergey Biryukov
018ad6098c Accessibility: Administration: Improve aria-label on network admin Themes screen.
This ensures that the beginning of the label matches the visible link text.

Add a similar label for the plugin URI link on the Plugins screen when the plugin is outside of the directory.

Follow-up to [28673], [28706], [35924].

Props sabernhardt, zeo, audrasjb.
Fixes #24442.
Built from https://develop.svn.wordpress.org/trunk@51795


git-svn-id: http://core.svn.wordpress.org/trunk@51402 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 14:49:00 +00:00
Andrew Ozz
e175db4ae1 External Libraries: Update jQuery UI to 1.13.0-rc2.
The final release is expected at the beginning of October. Updating to rc2 now gives everybody plenty of time to test and report any issues either with UI 1.13.0 or with the WordPress implementation.

Props Clorith, mgol, azaozz.
See #52163.
Built from https://develop.svn.wordpress.org/trunk@51794


git-svn-id: http://core.svn.wordpress.org/trunk@51401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 00:02:59 +00:00
hellofromTonya
b8322a053e Code Modernization: Fix null to non-nullable deprecation in wp_privacy_anonymize_ip().
The `wp_privacy_anonymize_ip()` function expects a string for the `$ip_addr` parameter, but did not do any input validation.

One of the pre-existing test cases, passed `null` to the function, leading to a `substr_count(): Passing null to parameter #1 ($haystack) of type string is deprecated` notice on PHP 8.1.

Fixed now by doing a cursory check on the variable at the start of the function and bowing out early for a number of cases (`null`, `false`, `0`, `''`) which would all result in the same `0.0.0.0` output anyway.

Follow-up [42971].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51793


git-svn-id: http://core.svn.wordpress.org/trunk@51400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 22:56:56 +00:00
hellofromTonya
78b5f27b1e Tests: Add more invalid IP test cases and @covers to Tests_Functions_Anonymization.
Adds a few more invalid IP test cases.

Adds extra `@covers` tag for the two functions which are testing the `wp_privacy_anonymize_ip()` function.

(At class level, the `wp_privacy_anonymize_data()` is set as covered).

Follow-up to [42971].

Props jrf, hellofromTonya.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51792


git-svn-id: http://core.svn.wordpress.org/trunk@51399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 22:44:56 +00:00
hellofromTonya
07139653b9 Widgets: Revert [51705].
While the new name is much better, it doesn't fully tell what will happen when invoked nor does it fully solve the root problems. 

Why? The function is doing too much. And naming is hard.

Props azaozz, desrosj, andraganescu, zieladam, hellofromTonya.
See #53811.
Built from https://develop.svn.wordpress.org/trunk@51791


git-svn-id: http://core.svn.wordpress.org/trunk@51398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 21:40:57 +00:00
hellofromTonya
1d0e1397fd Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Image_Editor::save().
Renames the first parameter in `WP_Image_Editor_GD::save()` to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds @since to clearly specify why the change happened.

Adds parameter descriptions to parent and both child classes. 

Follow-up to [22094], [22619], [30681].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51790


git-svn-id: http://core.svn.wordpress.org/trunk@51397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 20:39:58 +00:00
hellofromTonya
68e0c5e520 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Widget::update().
In each child class, renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds @since to clearly specify why the change happened.

Replaces the original with the variable name with within each method.
Why? The new name is more specific and descriptive, which improves readability.

Follow-up to [10782], [25090], [26556], [40640].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51789


git-svn-id: http://core.svn.wordpress.org/trunk@51396 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 20:13:57 +00:00
hellofromTonya
f2f05f8e04 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Sitemaps_Provider::get_max_num_pages().
In each child class, renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds @since to clearly specify why the change happened.

Reassigns the generic parameter to the original parameter.
Why? Restoring the original name keeps the context intact within the method and makes the code more readable. An inline comment explains why this reassignment is made.

Note: Reassignment is done after the guard clause.
Why? To avoid unnecessary processing and memory should the method bail out.

Follow-up to [48072].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51788


git-svn-id: http://core.svn.wordpress.org/trunk@51395 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 19:42:56 +00:00
hellofromTonya
a4b163a674 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Sitemaps_Provider::get_url_list().
In each child and grandchild class, renames the second parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds @since to clearly specify why the change happened.

Reassigns the generic parameter to the original parameter.
Why? Restoring the original name keeps the context intact within the method and makes the code more readable. An inline comment explains why this reassignment is made.

Follow-up to [48072].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51787


git-svn-id: http://core.svn.wordpress.org/trunk@51394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 19:21:57 +00:00
hellofromTonya
41307cd4e6 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_REST_Controller::prepare_item_for_response().
In each child and grandchild class, renames the first parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [38832], [39011], [39015], [39021], [39024], [39025], [39031], [39036], [43519], [43735], [43739], [43768], [46821], [48173], [48242], [49088], [50995], [51003], [51021].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51786


git-svn-id: http://core.svn.wordpress.org/trunk@51393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 18:36:57 +00:00
hellofromTonya
aaee916444 Code Modernization: Fix parameter name mismatch with parent in WP_Customize_Custom_CSS_Setting::validate().
Renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Adds `@since` to clearly specify why the change happened.

Reassigns the generic parameter to the original parameter.
Why? Restoring the original name keeps the context intact within the method and makes the code more readable. An inline comment explains why this reassignment is made

Follow-up to [37476], [38829], [41376].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51785


git-svn-id: http://core.svn.wordpress.org/trunk@51392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:18:55 +00:00
hellofromTonya
6a19a16872 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Customize_Setting::update().
In each child class: renames the parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [19995], [21037], [21053], [21354], [38829], [51298].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51784


git-svn-id: http://core.svn.wordpress.org/trunk@51391 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 14:48:55 +00:00
hellofromTonya
071c322bf2 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Customize_Setting::sanitize().
In each child class: renames the parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [19995], [32806].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51783


git-svn-id: http://core.svn.wordpress.org/trunk@51390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 14:32:57 +00:00
hellofromTonya
5887edee86 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Upgrader_Skin::error().
In each child class: renames the parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

Follow-up to [11005], [25806], [32655], [38199].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51782


git-svn-id: http://core.svn.wordpress.org/trunk@51389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 13:59:56 +00:00
hellofromTonya
03331f52ff Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in WP_Upgrader_Skin::feedback().
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.

In each child class: renames the parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781


git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 13:48:56 +00:00
hellofromTonya
a395d4c50e Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in Walker::end_el().
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`.

In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51780


git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 13:03:55 +00:00
hellofromTonya
7abc752329 Code Modernization: Fix last parameter name mismatches for parent/child classes in Walker::start_el().
The parent class uses `$current_object_id` while most of the child classes use `$id`. As the parent class' is more descriptive, renaming the last parameter in each of child class.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

- In cases where the original parameter name was too generic or misleading, renamed (when reassigning) to a more descriptive name for use within the method.

Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189], [51739].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51779


git-svn-id: http://core.svn.wordpress.org/trunk@51386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 12:39:59 +00:00
Andrew Ozz
0fcde6de17 Editor: Revert [51748] and [51649]. They intorduced a bug where wp.editor may be replaced with wp.oldEditor in certain cases.
Props desrosj, davidbinda, azaozz.
Fixes #53762.
Built from https://develop.svn.wordpress.org/trunk@51768


git-svn-id: http://core.svn.wordpress.org/trunk@51375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 23:29:58 +00:00
Andrew Ozz
03bbf916a9 Editor: fix the replacement of wp.editor with wp.oldEditor in the inline script outputted when enqueueing the old editor.
Props fullofcaffeine, davidbinda, grantmkin, get_dave, azaozz.
Fixes #53762.
Built from https://develop.svn.wordpress.org/trunk@51748


git-svn-id: http://core.svn.wordpress.org/trunk@51356 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 19:16:02 +00:00
Sergey Biryukov
e1e1d021ea General: Only use _jsonp_wp_die_handler() for JSONP REST API requests.
Props mdawaffe, peterwilsoncc.
Built from https://develop.svn.wordpress.org/trunk@51740


git-svn-id: http://core.svn.wordpress.org/trunk@51348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 17:16:57 +00:00
hellofromTonya
1105ddf965 Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in Walker::start_el().
In the parent class, renames the parameter `$object` to `$data_object`.

Why? `object` is a PHP reserved keyword.

In each child class: renames the corresponding parameter to match the parent's method signature.

Why? 

PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

- in cases where the original parameter name was too generic, renamed (when reassigning) to a more descriptive name for use within the method.

Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51739


git-svn-id: http://core.svn.wordpress.org/trunk@51347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 15:36:59 +00:00
John Blackbourn
25da00ea81 Users: Introduce a meta_input argument for wp_insert_user().
This allows custom user meta values to be provided when creating or updating a user in the same way custom post meta can be provided to `wp_insert_post()` when creating or updating a post.

Also introduces the `insert_custom_user_meta` to filter these values.

Props desrosj, donmhico

Fixes #41950

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


git-svn-id: http://core.svn.wordpress.org/trunk@51346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 21:31:55 +00:00
hellofromTonya
aebe05f6f4 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_List_Table::handle_row_actions().
Matches the method signatures of the parent class and each child class.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

For readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened

- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737


git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 19:24:53 +00:00
John Blackbourn
172541c6f1 Build/Test Tools: Fix CI for running tests on PHP 8.1.
This fixes the CI for PHP 8.1 while retaining the needed improvements for local testing when running `npm run test:php-composer` by:

* Replacing the npm script with the full node command
* Removing the `composer update` command from the `env:install` process

Props BinaryKitten, hellofromTonya

See #53945

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


git-svn-id: http://core.svn.wordpress.org/trunk@51344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 19:23:56 +00:00
hellofromTonya
7d6a70107a Code Modernization: Fix parameter name mismatches for parent/child classes in WP_List_Table::column_cb().
Matches the method signatures of the parent class and each child class.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

For readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened

- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51735


git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 18:19:56 +00:00
hellofromTonya
213ce0c7ea Code Modernization: Improve @since message in WP_List_Table::column_default().
Improves the `@since` message to more clearly specify the reason for this change" for PHP 8 named parameter support.

Follow-up to [51728].

Props jrf.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51734


git-svn-id: http://core.svn.wordpress.org/trunk@51342 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 16:57:58 +00:00
Sergey Biryukov
5a7eca9a0e Docs: Correct documentation for the in_plugin_update_message-{$file} filter.
The `$response` parameter is an object, not an array.

This is a minor inconsistency with the corresponding `in_theme_update_message-{$theme_key}` action for themes, where the `$response` parameter is an array.

For backward compatibility, it is safer not to change the parameter type at this point, but to make sure the documentation is correct.

Follow-up to [11193], [16141], [26540].

Props davidmosterd, audrasjb, SergeyBiryukov.
See #40006.
Built from https://develop.svn.wordpress.org/trunk@51733


git-svn-id: http://core.svn.wordpress.org/trunk@51341 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 12:55:00 +00:00
Sergey Biryukov
de70e2c68b Docs: Correct the post_submitbox_minor_actions hook description.
The action fires after the Save Draft (or Save as Pending) and Preview (or Preview Changes) buttons in the Publish meta box.

The previous description stated that the action fires before the post date/time setting, which was not quite correct, as there are also post status and visibility settings between the action and the date/time setting.

Follow-up to [34895].

Props bedas, audrasjb.
Fixes #54045.
Built from https://develop.svn.wordpress.org/trunk@51732


git-svn-id: http://core.svn.wordpress.org/trunk@51338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-06 13:36:01 +00:00
Sergey Biryukov
c5d96d88a3 Docs: Сlarify that term_id is a valid value for the $field parameter of get_term_by().
As `term_id` is the actual property name of the `WP_Term`, it should appear first and we should make it more clear that `id` and `ID` are aliases.

Follow-up to [6254], [25334], [38677], [47865], [47870].

Props gazchap, audrasjb.
Fixes #54065.
Built from https://develop.svn.wordpress.org/trunk@51731


git-svn-id: http://core.svn.wordpress.org/trunk@51337 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-05 11:06:59 +00:00
Sergey Biryukov
bd3465828e Docs: Fix typo in a comment in WP_Customize_Manager::get_return_url().
Follow-up to [46754].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51730


git-svn-id: http://core.svn.wordpress.org/trunk@51336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-04 00:39:04 +00:00
Sergey Biryukov
15e552e105 Docs: Move @since notes from the safe_style_css filter to the safecss_filter_attr() function.
The filter allows to modify the list of allowed CSS attributes, however support for specific CSS attributes is added to the function rather than the filter.

Follow-up to [37931], [38121], [42880], [44136], [44531], [45242], [45363], [46235], [46793], [50634], [50923].

Props tmatsuur, muhammadfaizanhaidar, sabernhardt.
Fixes #53731.
Built from https://develop.svn.wordpress.org/trunk@51729


git-svn-id: http://core.svn.wordpress.org/trunk@51335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-03 01:37:57 +00:00
hellofromTonya
2c91899724 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_List_Table::column_default().
Matches the method signatures of the parent class and each child class.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

For readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened

- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].

Props jrf, hellofromTonya, @sergeybiryukov, @azaozz, @desrosj, @johnbillion
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51728


git-svn-id: http://core.svn.wordpress.org/trunk@51334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-02 22:26:56 +00:00
ryelle
c11fbdc7ae Coding Standards: Apply coding standards on CSS.
Remove units when the value is zero. Combine redundant values in shorthand declarations.
This was generated with `stylelint --fix` and a custom config (see #53866).

Props ankitmaru, audrasjb, pbiron, ayeshrajans, hareesh-pillai, netweb, mukesh27.
Fixes #53866.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51333 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-02 22:18:00 +00:00
Sergey Biryukov
fcc79f847a Docs: Provide a more accurate description for a few script and style functions.
This should make it clear that the functions only work if the script or style has already been registered.

This affects:
* `wp_localize_script()`
* `wp_set_script_translations()`
* `wp_script_add_data()`
* `wp_style_add_data()`

Follow-up to [7970], [18464], [25594], [31223], [36633], [44169], [44350].

Props audrasjb.
Fixes #54044.
Built from https://develop.svn.wordpress.org/trunk@51726


git-svn-id: http://core.svn.wordpress.org/trunk@51332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-02 08:30:58 +00:00
hellofromTonya
9b3202eafd Tests: Add missing @covers tags for Tests_Admin_wpCommunityEvents.
Adds missing and moves placement of existing @covers tags for consistency.

Follow-up to [40607], [42726], [49145].

Props pbearne, jrf, hellofromTonya.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@51725


git-svn-id: http://core.svn.wordpress.org/trunk@51331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 22:27:57 +00:00
hellofromTonya
380b5563ad Tests: Add missing @covers tags for Tests_Admin_IncludesComment.
Follow-up to [34456], [34460].

Props pbearne, jrf, hellofromTonya.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@51724


git-svn-id: http://core.svn.wordpress.org/trunk@51330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 21:59:56 +00:00
desrosj
c886de61f9 Editor: Update block editor packages for WordPress 5.8.1.
The following packages were updated:
- @wordpress/a11y to `3.1.2`
- @wordpress/annotations to `2.1.6`
- @wordpress/api-fetch to `5.1.2`
- @wordpress/autop to `3.1.2`
- @wordpress/babel-preset-default to `6.2.1`
- @wordpress/blob to `3.1.2`
- @wordpress/block-directory to `2.1.21`
- @wordpress/block-editor to `6.1.14`
- @wordpress/block-library to `3.2.19`
- @wordpress/block-serialization-default-parser to `4.1.2`
- @wordpress/blocks to `9.1.8`
- @wordpress/components to `14.1.11`
- @wordpress/compose to `4.1.6`
- @wordpress/core-data to `3.1.12`
- @wordpress/customize-widgets to `1.0.20`
- @wordpress/data-controls to `2.1.6`
- @wordpress/data to `5.1.6`
- @wordpress/date to `4.1.2`
- @wordpress/deprecated to `3.1.2`
- @wordpress/dom-ready to `3.1.2`
- @wordpress/dom to `3.1.5`
- @wordpress/e2e-test-utils to `5.3.1`
- @wordpress/edit-post to `4.1.21`
- @wordpress/edit-widgets to `2.1.21`
- @wordpress/editor to `10.1.17`
- @wordpress/element to `3.1.2`
- @wordpress/escape-html to `2.1.2`
- @wordpress/format-library to `2.1.14`
- @wordpress/html-entities to `3.1.2`
- @wordpress/i18n to `4.1.2`
- @wordpress/icons to `4.0.3`
- @wordpress/interface to `3.1.12`
- @wordpress/keyboard-shortcuts to `2.1.7`
- @wordpress/keycodes to `3.1.2`
- @wordpress/list-reusable-blocks to `2.1.11`
- @wordpress/media-utils to `2.1.2`
- @wordpress/notices to `3.1.6`
- @wordpress/nux to `4.1.11`
- @wordpress/plugins to `3.1.6`
- @wordpress/primitives to `2.1.2`
- @wordpress/priority-queue to `2.1.2`
- @wordpress/react-i18n to `2.1.2`
- @wordpress/redux-routine to `4.1.2`
- @wordpress/reusable-blocks to `2.1.17`
- @wordpress/rich-text to `4.1.6`
- @wordpress/scripts to `16.1.5`
- @wordpress/server-side-render to `2.1.12`
- @wordpress/shortcode to `3.1.2`
- @wordpress/url to `3.1.2`
- @wordpress/viewport to `3.1.6`
- @wordpress/warning to `2.1.2`
- @wordpress/widgets to `1.1.19`
- @wordpress/wordcount to `3.1.2`

Props oandregal, juanmaguitar, gziolo, jblz, talldanwp, ribaricplusplus, peterwisoncc, youknowriad, paaljoachim, kreppar, ellatrix, aristath, walbo, ajlende, kevin940726, mamaduka, ntsekouras, toro_unit, mkaz, joen, noisysocks, zieladam, andraganescu, antonvlasenko, terraling, dariak, vladytimy, circlecube, desrosj.
Fixes #54052, #52818.
Built from https://develop.svn.wordpress.org/trunk@51719


git-svn-id: http://core.svn.wordpress.org/trunk@51325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 19:08:24 +00:00
desrosj
da38a95d77 Media: Remove documentation detailing specific edge cases in the image_editor_output_format filter.
In [51422], a few specific edge cases were detailed so that developers using the hook were aware of known pitfalls.

These edge cases have been fixed in 5.8.1 through [51653] and [51704], so the documentation is no longer necessary.

Props azaozz, audrasjb.
Fixes #53955.
Built from https://develop.svn.wordpress.org/trunk@51717


git-svn-id: http://core.svn.wordpress.org/trunk@51323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 17:17:58 +00:00
noisysocks
9697e5a63b Customize: Add wp-embed-responsive class to body if using widgets block editor
Appends the wp-embed-responsive class to the body if the widgets block editor is
enabled. This fixes a bug preventing embeds (e.g. YouTube embeds) appearing in
the widgets block editor.

Fixes #53609.
Props walbo, kevin940726.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 07:10:56 +00:00
Sergey Biryukov
049bbe8356 Site Health: Remove MySQL query cache size from the Site Health Info screen.
The query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0.

Reference: [https://dev.mysql.com/doc/refman/5.7/en/query-cache-configuration.html MySQL 5.7 Reference Manual: Query Cache Configuration].

Follow-up to [51522], [51523].

Props johnbillion, zodiac1978.
Fixes #53845.
Built from https://develop.svn.wordpress.org/trunk@51715


git-svn-id: http://core.svn.wordpress.org/trunk@51321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 07:01:56 +00:00
Peter Wilson
33f4f396ef Build: Clean css/dist as part of the webpack build step.
Move the cleaning of the `wp-includes/css/dist` folder from `clean:css` to `clean:webpack-assets` to avoid an order of operations issue in which the files were built shortly before been deleted later in the build process.

Follow up to [51689].

Props netweb, ramonopoly, peterwilsoncc.
Fixes #53719.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 04:00:59 +00:00
desrosj
3dd999bb14 Build/Test Tools: Double escape quotation marks() for Slack “messages”.
This prevents quotation marks from producing invalid JSON errors.

See #52644.
Built from https://develop.svn.wordpress.org/trunk@51709


git-svn-id: http://core.svn.wordpress.org/trunk@51315 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-01 00:26:55 +00:00
hellofromTonya
71977c215d Widgets: Rename and soft deprecate retrieve_widgets().
The original name `retrieve_widgets()` was unclear as it suggested it was a getter, i.e. getting the widgets. This function does more than get: finds orphaned widgets, assigns them to the inactive sidebar, and updates the database.

The new name is `sync_registered_widgets()` which better represents what happens when this function is invoked.

The original `retrieve_widgets()` function is soft deprecated to avoid unnecessary code churn downstream for developers that support more than the latest version of WordPress.

Follow-up to [18630].

Props zieladam, timothyblynjacobs, andraganescu, hellofromTonya.
See #53811.
Built from https://develop.svn.wordpress.org/trunk@51705


git-svn-id: http://core.svn.wordpress.org/trunk@51311 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-31 19:58:58 +00:00
Andrew Ozz
f405add8f0 Media: apply the wp_editor_set_quality filter not only when loading an image in the editor but also when saving an converted image, after the mime-type of the output image has changed.
Props mikeschroder, desrosj, azaozz.
Fixes #53667.
Built from https://develop.svn.wordpress.org/trunk@51704


git-svn-id: http://core.svn.wordpress.org/trunk@51310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-31 18:59:03 +00:00
Andrew Ozz
4112d77597 Media: fix showing of the "Filter Media" filds when replacing an image from the media modal.
Props mhuntdesign, sabernhardt, azaozz.
Fixes #53833.
Built from https://develop.svn.wordpress.org/trunk@51703


git-svn-id: http://core.svn.wordpress.org/trunk@51309 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-31 17:27:57 +00:00
hellofromTonya
46ba4f8b70 Tests: Add missing @covers tags for actions' tests.
Props pbearne, hudson-atwell, jrf, hellofromTonya.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@51702


git-svn-id: http://core.svn.wordpress.org/trunk@51308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-31 17:23:55 +00:00
desrosj
e91f690333 Widgets: Show title and media select fields in Accessibility Mode.
This updates the Custom HTML and Media widgets to display the correct fields when adding or editing a widget when using accessibility mode through the Classic Widgets experience.

Follow up to [49973].

Props mark-k, sabernhardt, alexstine, circlecube, audrasjb.
Fixes #53641.
Built from https://develop.svn.wordpress.org/trunk@51701


git-svn-id: http://core.svn.wordpress.org/trunk@51307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-31 13:51:00 +00:00
Sergey Biryukov
892c8ecbdb Widgets: Pass correct context to get_block_categories() calls.
The `get_block_categories()` function expects either a `WP_Post` or a `WP_Block_Editor_Context` instance as the context argument, not a string.

Follow-up to [50996], [50997].

Props Enchiridion, pbearne, audrasjb.
Fixes #53757.
Built from https://develop.svn.wordpress.org/trunk@51700


git-svn-id: http://core.svn.wordpress.org/trunk@51306 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-31 13:38:58 +00:00
Sergey Biryukov
c73609fe10 Docs: Improve documentation in wp-signup.php.
* Document the `$active_signup` global in `signup_user()`.
* Update some DocBlocks per the documentation standards.
* Expand some function descriptions for clarity.

Follow-up to [37535], [37536], [41200], [43326], [49078], [50828].

Props mt8.biz, sabernhardt, audrasjb, westonruter, jayupadhyay01, mukesh27, SergeyBiryukov.
Fixes #41566.
Built from https://develop.svn.wordpress.org/trunk@51699


git-svn-id: http://core.svn.wordpress.org/trunk@51305 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-31 12:25:00 +00:00
hellofromTonya
4abb89f6c6 Tests: Do whitespace replacement in assertDiscardWhitespace() only when string.
The `assertDiscardWhitespace()` method uses `assertEquals()` under the hood, meaning that in reality any type of actual/expected value should be accepted by the function. Fixed the documentation to reflect that.

At the same time, only strings can contain whitespace differences. So the whitespace replacement should only be done when string values are passed.

This change (a) prevents potential `passing null to non-nullable` errors on PHP 8.1, if either of the inputs would turn out to be `null` and (b) increases tests stability.

Follow-up to [35003], [44902].

Props jrf.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51698


git-svn-id: http://core.svn.wordpress.org/trunk@51304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-30 20:41:59 +00:00
hellofromTonya
702ea22639 Tests: Test custom assertions parameter data type in WP_UnitTestCase_Base.
The following changes improve tests stability.

The `assertEqualFields()` method expects an object and a fields array as inputs and subsequently approaches the received parameters as such, but did not verify whether the received parameters are of the expected types.

Along the same lines, the `assertSameSets()`, `assertEqualSets()`, `assertSameSetsWithIndex()` and the `assertEqualSetsWithIndex()` methods all expect arrays for both the actual as well as the expected values and uses the array function `[k]sort()` on both, but never verified that the received inputs were actually arrays, which could lead to PHP errors on the sorting function calls.

Follow-up to [30687], [42343], [48937], [48939], [51480], [51481].

Props jrf.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51697


git-svn-id: http://core.svn.wordpress.org/trunk@51303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-30 20:19:59 +00:00
hellofromTonya
6b2eccb0e3 Code Modernization: Add input validation to _set_cron_array().
The private `_set_cron_array()` function expects a cron array as the first parameter, but will often be passed the - potentially updated - output of a call to `_get_cron_array()`.

When the `_get_cron_array()` function returns `false`, a "Deprecated: Automatic conversion of false to array is deprecated" warning will be thrown on PHP 8.1.

The input validation resolves the deprecation warning by setting the cron value to an empty array when not given an `array` data type.

Adds a full set of `_set_cron_array()` tests.

Follow-up to [4189], [50152].

Props jrf, hellofromTonya, peterwilsoncc.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51695


git-svn-id: http://core.svn.wordpress.org/trunk@51301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-30 15:20:56 +00:00
desrosj
5090761b4f Coding Standards: Apply some minor alignment fixes.
These are updates caused by running `composer format`.

Follow up to [51501], [51599], [51618], [51653].
See #53359, #50542, #53238, #53668, #53690.
Built from https://develop.svn.wordpress.org/trunk@51693


git-svn-id: http://core.svn.wordpress.org/trunk@51299 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-30 14:09:58 +00:00
Sergey Biryukov
09f22e5b24 External Libraries: Update whatwg-fetch package to version 3.6.2.
This matches the version used in the Gutenberg project.

While WordPress core no longer depends on this polyfill as of [50934], this brings the latest updates of the library to anyone still utilizing it.

For a full list of changes in this update, see the `whatwg-fetch` GitHub:
https://github.com/github/fetch/compare/v3.0.0...v3.6.2

Follow-up to [43719], [50934].

Props hareesh-pillai, rsiddharth, desrosj.
Fixes #53929.
Built from https://develop.svn.wordpress.org/trunk@51692


git-svn-id: http://core.svn.wordpress.org/trunk@51298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-30 13:51:11 +00:00
Peter Wilson
1ac69fa78e Build: Remove css/dist in grunt clean command.
Modify the `grunt clean:css` command to include the folder `wp-includes/css/dist` to ensure legacy files do not remain if the built files are removed/relocated.

Props desrosj, netweb.
Fixes #53719.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51295 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-30 04:35:57 +00:00
Peter Wilson
34d8dd914c Menus: Save display locations for new menus.
Fixes a bug preventing the locations saving when creating a new menu. Introduced in [50938].

Props dlh, andraganescu, mukesh27, desrosj.
Fixes #53877.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51294 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-30 04:12:57 +00:00
Sergey Biryukov
26a276db6f Filesystem API: Make sure to only call fread() on non-empty files in PclZip::privAddFile().
This avoids a fatal error on PHP 8 caused by passing a zero value to `fread()` as the `$length` argument, which must be greater than zero.

This commit also amends the previous solution for similar issues elsewhere in the file to ensure consistent type for string values, instead of changing the type from `string` to `bool` when trying to read from an empty file.

Follow-up to [50355].

Props DavidAnderson, jrf, SergeyBiryukov.
Fixes #54036.
Built from https://develop.svn.wordpress.org/trunk@51686


git-svn-id: http://core.svn.wordpress.org/trunk@51292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-29 01:33:58 +00:00
John Blackbourn
b441808aee Build/Test Tools: Install the Composer package dependencies within the Docker environment as part of the local development environment installation and testing processes.
This makes the use of Composer on the host machine optional when using the Docker environment, which means there is no change to the process for installing, updating, and running the tests since [51559].

Props hellofromTonya, azaozz, netweb, desrosj, jrf, johnbillion

Fixes #53945

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


git-svn-id: http://core.svn.wordpress.org/trunk@51291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-28 21:17:56 +00:00
John Blackbourn
80c7b3cdf3 Administration: Remove a misleading pointer cursor from list items in the admin menu.
This prevents unclickable areas within the menu from appearing clickable.

Props circlecube, kurudrive, ryelle, opurockey

Fixes #51551

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


git-svn-id: http://core.svn.wordpress.org/trunk@51290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-28 13:45:56 +00:00
Sergey Biryukov
42c7a1fad5 Coding Standards: Fix WPCS issue in [51682].
This fixes a "Misleading line break before `'||'`; readers may interpret this as an expression boundary" error.

See #54030.
Built from https://develop.svn.wordpress.org/trunk@51683


git-svn-id: http://core.svn.wordpress.org/trunk@51289 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-28 01:34:56 +00:00
Sergey Biryukov
79b0d3f3e8 Customize: Prevent collapsing expanded panel/section/control when Esc is pressed on a block editor instance.
This ensures that the current panel is not collapsed when hitting `Esc` with the focus on the widget block editor.

Follow-up to [37347], [39120].

Props gwwar, dlh.
Fixes #54030.
Built from https://develop.svn.wordpress.org/trunk@51682


git-svn-id: http://core.svn.wordpress.org/trunk@51288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-28 01:25:59 +00:00
desrosj
ed0e054f34 Build/Test Tools: Preserve text within backticks in Slack notifications.
Props SergeyBiryukov, johnbillion, earnjam.
See #52644.
Built from https://develop.svn.wordpress.org/trunk@51679


git-svn-id: http://core.svn.wordpress.org/trunk@51285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-27 17:35:58 +00:00
Sergey Biryukov
0ae0fbedce Plugins: Display a message on Plugins list table if a plugin requires a higher version of PHP or WordPress.
Installation and activation of incompatible plugins was previously disallowed in [43436] and [44978], but if such a plugin was installed manually, there was nothing on the Plugins screen that would show its compatibility status.

Showing an appropriate notice with a documentation link makes the UI more consistent and improves user experience.

Follow-up to [43436], [44937], [44939], [44978], [45043], [45165], [45546], [47573], [47816], [47819], [48172], [48636], [48637], [48638], [48640], [48652], [48653], [48654], [48660].

Props TacoVerdo, SergeyBiryukov.
Fixes #53990.
Built from https://develop.svn.wordpress.org/trunk@51678


git-svn-id: http://core.svn.wordpress.org/trunk@51284 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-27 15:43:57 +00:00
Mike Schroder
9aeacc728a Customizer: Respect prefers-reduced-motion media query in Customizer animations.
Disables Customizer animations when media query `prefers-reduced-motion: reduce` returns true.

Continues the effort to reduce motion within the WordPress admin panel when users have enabled this feature in their operating system or browser.

It has the additional effect of making the Block Editor's end-to-end tests run faster, as explored initially with a different approach in #53562.

See https://github.com/WordPress/gutenberg/issues/32024 for the related Gutenberg issue.

See https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion for ways to enable this feature on various platforms.

Props kevin940726, isabel_brison, zieladam, youknowriad, desrosj, mamaduka, mikeschroder.
Previously [51389], [50028], [47813].
Fixes #53542.
Built from https://develop.svn.wordpress.org/trunk@51677


git-svn-id: http://core.svn.wordpress.org/trunk@51283 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-27 09:36:57 +00:00
John Blackbourn
b3226d8e62 REST API: Correct the description for the last_updated property in the block-directory endpoint.
This field shows the date in ISO 8601 format.

Fixes #53595

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


git-svn-id: http://core.svn.wordpress.org/trunk@51282 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 19:34:56 +00:00
John Blackbourn
52d6bd3529 Security: Correct the inline docs for the wp_kses_allowed_html filter.
Props peterwilsoncc

Fixes #53597

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


git-svn-id: http://core.svn.wordpress.org/trunk@51281 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 19:28:57 +00:00
desrosj
9bc8352b00 Editor: Ensure block attribute serialization in PHP matches the JavaScript equivalent.
The `serializeAttributes()` function in JavaScript uses `JSON.stringify`, which does not encode slashes and unicode characters by default. This resulted in the PHP serialization through `json_encode()` producing different results.

This also switches from `json_encode()` to `wp_json_encode()` to prevent failures when any non UTF-8 characters are included.

Props kevinfodness, SergeyBiryukov, timothyblynjacobs.
Fixes #53936.
Built from https://develop.svn.wordpress.org/trunk@51674


git-svn-id: http://core.svn.wordpress.org/trunk@51280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 19:10:58 +00:00
desrosj
b6f34e7b44 Build/Test Tools: Use list format when defining environment variables in Docker compose file.
This is the correct formatting detailed in the Docker `compose` documentation examples and helps to avoid ambiguities in the yaml parser when values that may cause warnings.

Props pbrearne, ocean90, johnbillion, desrosj.
Fixes #53820.
Built from https://develop.svn.wordpress.org/trunk@51673


git-svn-id: http://core.svn.wordpress.org/trunk@51279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 18:41:58 +00:00
ryelle
e32d9ec522 Toolbar: Provide a CSS custom property for the admin bar height.
This new custom property, `--wp-admin--admin-bar--height`, reflects the admin bar's height and adjusts responsively on smaller screens. It can be used to offset content to avoid overlapping the admin bar, without needing to copy the media query.

This also removes a workaround only needed for Internet Explorer 6 and below.

Props nico23, sabernhardt.
Fixes #52623.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51278 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 18:24:58 +00:00
desrosj
2ddca7fd4a Build/Test Tools: Remove shell: bash from code coverage workflow.
bash is the default shell for all non-Windows GitHub Action runners, so this is not necessary.

Follow up to [51670].
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51671


git-svn-id: http://core.svn.wordpress.org/trunk@51277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 18:22:57 +00:00
desrosj
59faf7aeb6 Build/Test Tools: Remove shell: bash from PHPUnit test workflow.
bash is the default shell for all non-Windows GitHub Action runners, so this is not necessary.

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51670


git-svn-id: http://core.svn.wordpress.org/trunk@51276 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 18:21:58 +00:00
hellofromTonya
31def8058e Tests: Improve bootstrap error message for when ABSPATH folder does not exist.
The PHPUnit tests are/should generally be run on the `src` directory, so changes just made can be tested. While testing via the `build` directory is also still supported, this is not the default.

This was last changed in [50441], but that commit did not remove/update the error message thrown by the test bootstrap file.

This last change also did not take into account that that change meant that people had to update their own `wp`tests-config.php` file to match the change made in Core and would otherwise still get the outdated error message.

This commit changes the messaging in the test bootstrap file to be more in line with the current reality, while still accounting for the fact that tests can be run from both `src` as well as `build`.

Follow-up to [49569], [50441], [51581].
Props jrf, hellofromTonya.
Built from https://develop.svn.wordpress.org/trunk@51669


git-svn-id: http://core.svn.wordpress.org/trunk@51275 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 17:56:57 +00:00
Sergey Biryukov
1f7f8fb16a Coding Standards: Add missing visibility keywords for wp_filter_object_list() and wp_list_pluck() tests.
Follow-up to [51663-51667].

Props pbearne.
See #53363, #53987.
Built from https://develop.svn.wordpress.org/trunk@51668


git-svn-id: http://core.svn.wordpress.org/trunk@51274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 16:51:57 +00:00
Sergey Biryukov
4810f47fd5 Tests: Move wp_list_sort() tests to their own file.
This matches the name of the function being tested.

Follow-up to [38928], [51663-51666].

See #53363, #53987.
Built from https://develop.svn.wordpress.org/trunk@51667


git-svn-id: http://core.svn.wordpress.org/trunk@51273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 16:30:56 +00:00
Sergey Biryukov
48aa9e7147 Tests: Move wp_list_filter() tests to their own file.
This matches the name of the function being tested.

Follow-up to [38928], [51663-51665].

See #53363, #53987.
Built from https://develop.svn.wordpress.org/trunk@51666


git-svn-id: http://core.svn.wordpress.org/trunk@51272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 16:21:58 +00:00
Sergey Biryukov
5cfd90b427 Tests: Rename the test file and class for wp_filter_object_list() tests.
This matches the name of the function being tested.

Follow-up to [410/tests], [51663], [51664].

See #53363, #53987.
Built from https://develop.svn.wordpress.org/trunk@51665


git-svn-id: http://core.svn.wordpress.org/trunk@51271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 16:09:56 +00:00
Sergey Biryukov
18ef0d4252 Tests: Remove duplicate wp_list_pluck() tests.
The tests were partially duplicated in two separate files, and are now located in their own file.

Follow-up to [431/tests], [28900], [38928], [42527], [51663].

See #53363, #53987.
Built from https://develop.svn.wordpress.org/trunk@51664


git-svn-id: http://core.svn.wordpress.org/trunk@51270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 16:03:57 +00:00
Sergey Biryukov
a9cff26ae7 Tests: Move wp_list_pluck() tests to their own file.
The tests were partially duplicated in two separate files.

Follow-up to [431/tests], [28900], [38928], [42527].

See #53363, #53987.
Built from https://develop.svn.wordpress.org/trunk@51663


git-svn-id: http://core.svn.wordpress.org/trunk@51269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 15:55:57 +00:00
hellofromTonya
ab252fb910 Coding Standards: Fix indentation and remove ignore annotation in wp_privacy_send_personal_data_export_email().
Follow-up to [51129], [51410].

Props jrf, hellofromTonya.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51662


git-svn-id: http://core.svn.wordpress.org/trunk@51268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 14:05:58 +00:00
hellofromTonya
2e9fe3c986 Coding Standards: Make ignore annotation more specific in WP_Site_Health_Auto_Updates::test_vcs_abspath().
Follow-up to [44986].

Props jrf, hellofromTonya.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51661


git-svn-id: http://core.svn.wordpress.org/trunk@51267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 13:59:59 +00:00
hellofromTonya
a91fc400a0 Coding Standards: Remove redundant ignore annotation in populate_options().
Follow-up to [43627], [43628].

Props jrf, hellofromTonya.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51660


git-svn-id: http://core.svn.wordpress.org/trunk@51266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 13:50:59 +00:00
hellofromTonya
90a950783d Coding Standards: Update the config for WordPress.PHP.FileName in PHPCS ruleset.
The WPCS sniff already takes the test classes in the `tests/phpunit/includes` directory into account.

Only the test cases outside of that directory, i.e. in the `tests/phpunit/tests` directory need to be listed here.

Includes alphabetizing the list.

Follow-up to [42346], [45607].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51659


git-svn-id: http://core.svn.wordpress.org/trunk@51265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 13:36:56 +00:00
hellofromTonya
958cd3a964 Coding Standards: Update the config for WordPress.PHP.NoSilencedErrors in PHPCS ruleset.
Follow-up to [45611].

Props jrf, hellofromTonya.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51658


git-svn-id: http://core.svn.wordpress.org/trunk@51264 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 13:20:56 +00:00
hellofromTonya
c7d3e267b8 Coding Standards: Use static closures when not using $this.
When a closure does not use `$this`, it can be made `static` for improved performance.

Static closures are supported in PHP since PHP 5.4. ​

Props jrf, hellofromTonya, swissspidy, SergeyBiryukov.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51657


git-svn-id: http://core.svn.wordpress.org/trunk@51263 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 12:59:02 +00:00
Sergey Biryukov
622985b69c Docs: Add missing @since tag for the $check_signatures parameter of WP_Upgrader::run().
This matches the `WP_Upgrader::download_package()` documentation more closely.

Follow-up to [44954], [45262].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51655


git-svn-id: http://core.svn.wordpress.org/trunk@51261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-25 14:39:59 +00:00
Sergey Biryukov
d529999e5b Docs: Clarify a comment in WP_Upgrader::run().
This matches the `WP_Upgrader::download_package()` documentation more closely.

Follow-up to [11005], [30758], [33685].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51654


git-svn-id: http://core.svn.wordpress.org/trunk@51260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-24 23:10:06 +00:00
Andrew Ozz
94a990de99 Media: Fix wp_unique_filename() to check for name collisions with all alternate file names when an image may be converted after uploading. This includes possible collinions with pre-existing images whose sub-sizes/thumbnails are regenerated.
Props ianmjones, azaozz.
Fixes #53668.
Built from https://develop.svn.wordpress.org/trunk@51653


git-svn-id: http://core.svn.wordpress.org/trunk@51259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-24 20:52:03 +00:00
Sergey Biryukov
e53ffbaf95 Code Modernization: Pass correct default value to http_build_query() in WP_Sitemaps_Provider::get_sitemap_url().
The `WP_Sitemaps_Provider::get_sitemap_url()` method calls the PHP native `http_build_query()` function, the second parameter of which is the ''optional'' `$numeric_prefix` parameter which expects a `string`.

A parameter being optional, however, does not automatically make it nullable.

As of PHP 8.1, passing `null` to a non-nullable PHP native function will generate a deprecation notice.

In this case, this function call yielded a `http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated` notice.

Changing the `null` to an empty string fixes this without a backward compatibility break.

This change is already covered by tests as 14 of the existing tests failed on these function calls when running the tests on PHP 8.1.

References:
* [https://www.php.net/manual/en/function.http-build-query.php PHP Manual: http_build_query()]
* [https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg PHP RFC: Deprecate passing null to non-nullable arguments of internal functions]

Follow-up to [48470].

Props jrf.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51652


git-svn-id: http://core.svn.wordpress.org/trunk@51258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-23 11:44:01 +00:00
Sergey Biryukov
cdf31027d6 Tests: Rename classes in phpunit/tests/feed/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646], [51650].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51651


git-svn-id: http://core.svn.wordpress.org/trunk@51257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-22 10:08:59 +00:00
Sergey Biryukov
eec183cb63 Tests: Rename classes in phpunit/tests/error-protection/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51650


git-svn-id: http://core.svn.wordpress.org/trunk@51256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-21 15:34:01 +00:00
Andrew Ozz
774c8047c5 Editor: Replace the remaining references to wp.editor with wp.oldEditor.
Props zieladam.
Fixes #53762.
Built from https://develop.svn.wordpress.org/trunk@51649


git-svn-id: http://core.svn.wordpress.org/trunk@51255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-21 00:20:00 +00:00
Andrew Ozz
7fc3aae637 REST API: Remove trailing slashes when preloading requests and add unit tests for it.
Props antonvlasenko.
Fixes #51636.
Built from https://develop.svn.wordpress.org/trunk@51648


git-svn-id: http://core.svn.wordpress.org/trunk@51254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-20 23:44:57 +00:00
desrosj
f514f51180 Build/Test Tools: Include the commit short summary in Slack messages.
This gives more context to GitHub Action related Slack messages without the need to click the workflow URL, or unfurl the links (which shows lots of unnecessary information, such as the repository description and image).

Props earnjam.
See #52644.
Built from https://develop.svn.wordpress.org/trunk@51647


git-svn-id: http://core.svn.wordpress.org/trunk@51253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-20 19:00:00 +00:00
Sergey Biryukov
1be5d3e997 Tests: Rename classes in phpunit/tests/editor/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51646


git-svn-id: http://core.svn.wordpress.org/trunk@51252 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-20 16:13:04 +00:00
ryelle
899e4635de Privacy: Add space below page selector.
Sometimes the submit button wraps to a new line, either because the button label translation is long, or there are long page names. When it wraps, there should be space between the select dropdown and the button.

Props audrasjb, mukesh27, guillaumeturpin.
Fixes #53782.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51251 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 20:58:57 +00:00
ryelle
9d2e8c096f Toolbar: Limit the icon transition style to color only.
When transition is `all`, it also applies to the icon size, which can cause a bug in Safari where icons get stuck in the wrong size when resizing the browser window. The only expected animation is on the color property, so the transition can be limited to just `color`.

Props johnjamesjacoby, sabernhardt, SergeyBiryukov, audrasjb.
Fixes #43423.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51250 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 17:24:55 +00:00
Sergey Biryukov
87bd00ac5b Tests: Move loading the WP_Community_Events class to set_up_before_class().
This ensures that the class is loaded once before the first test of the test case class is run, and `require_once()` is not unnecessarily called for each test method individually.

Follow-up to [40607], [51628].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51641


git-svn-id: http://core.svn.wordpress.org/trunk@51247 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 14:00:57 +00:00
Sergey Biryukov
590f56db3b Tests: Rename classes in phpunit/tests/admin/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51639


git-svn-id: http://core.svn.wordpress.org/trunk@51245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 13:09:57 +00:00
Sergey Biryukov
ccbd16fef1 Media: Check the return type of _get_cron_array() in WP_Media_List_Table::prepare_items().
The following warnings could, in very select circumstances, be shown:
{{{
// PHP 8.0 and higher:
Warning: foreach() argument must be of type array|object, bool given

// PHP 5.6 – 7.4
Warning: Invalid argument supplied for foreach()
}}}

In `WP_Media_List_Table::prepare_items()`, the cron info array is retrieved via a call to `_get_cron_array()`, but as the documentation (correctly) states, the return type of that function is `array|false`, where `false` is returned for a virgin site, with no cron jobs scheduled yet.

However, no type check is done on the return value, and the method just blindly continues by using it in a `foreach`.

Fixed by adding validation for the returned value from `_get_cron_array()` and only running the `foreach` when the returned value is an array.

Reference: [https://developer.wordpress.org/reference/functions/_get_cron_array/ WordPress Developer Resources: _get_cron_array()]

Follow-up to [48417].

Props jrf, hellofromTonya, mukesh27.
Fixes #53949.
Built from https://develop.svn.wordpress.org/trunk@51638


git-svn-id: http://core.svn.wordpress.org/trunk@51244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 12:44:57 +00:00
Peter Wilson
cda7c787e8 Customize: Hide native control on background position field.
Hide the browser's native radio button on the custom background position selector in the Customizer and the legacy background screen. This fixes an issue causing both to display.

Props mukesh27, ravipatel, sabernhardt, walbo.
Fixes #53803.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51243 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 02:07:56 +00:00
Sergey Biryukov
27522c6f67 Code Modernization: Silence the deprecation warning for auto_detect_line_endings.
Since PHP 8.1, the `auto_detect_line_endings` setting is deprecated:

> The `auto_detect_line_endings` ini setting modifies the behavior of `file()` and `fgets()` to support an isolated `\r` (as opposed to `\n` or `\r\n`) as a newline character. These newlines were used by “Classic” Mac OS, a system which has been discontinued in 2001, nearly two decades ago. Interoperability with such systems is no longer relevant.

Reference: [https://wiki.php.net/rfc/deprecations_php_8_1#auto_detect_line_endings_ini_setting PHP RFC: Deprecations for PHP 8.1: auto_detect_line_endings ini setting]

> The `auto_detect_line_endings` ini setting has been deprecated. If necessary, handle `\r` line breaks manually instead.

Reference: [1cf4fb739f/UPGRADING (L456-L457) PHP 8.1 Upgrade Notes].

This commit fixes the warning when running tests for the `PO` class:
{{{
Deprecated: auto_detect_line_endings is deprecated in /var/www/src/wp-includes/pomo/po.php on line 16
}}}

While deprecated, the actual `auto_detect_line_endings` functionality has not been removed from PHP (yet) and will still work until PHP 9.0.

For now, we're silencing the deprecation notice as there may still be translation files around which haven't been updated in a long time and which still use the old MacOS standalone `\r` as a line ending.

This should be revisited when PHP 9.0 is in alpha/beta.

Follow-up to [51633].

Props jrf.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51636


git-svn-id: http://core.svn.wordpress.org/trunk@51242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-18 21:58:57 +00:00
Sergey Biryukov
74b515c1ba External Libraries: Restore the phpcs:ignore statements in PHPMailer.
These are necessary for a passing PHP Compatibility scan.

Follow-up to [48045], [51634].

See #53953.
Built from https://develop.svn.wordpress.org/trunk@51635


git-svn-id: http://core.svn.wordpress.org/trunk@51241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-18 14:08:56 +00:00
Sergey Biryukov
fd5aea9246 External Libraries: Upgrade PHPMailer to version 6.5.1.
The latest release includes preliminary PHP 8.1 support, as well as some small bug fixes.

Release notes: https://github.com/PHPMailer/PHPMailer/releases/tag/v6.5.1

For a full list of changes in this update, see the PHPMailer GitHub:
https://github.com/PHPMailer/PHPMailer/compare/v6.5.0...v6.5.1

Follow-up to [50628], [50799], [51169].

Props jrf.
Fixes #53953.
Built from https://develop.svn.wordpress.org/trunk@51634


git-svn-id: http://core.svn.wordpress.org/trunk@51240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-18 13:53:58 +00:00
Sergey Biryukov
0a2c7dc86c Code Modernization: Only set auto_detect_line_endings in PHP < 8.1.
Since PHP 8.1, the `auto_detect_line_endings` setting is deprecated:

> The `auto_detect_line_endings` ini setting modifies the behavior of `file()` and `fgets()` to support an isolated `\r` (as opposed to `\n` or `\r\n`) as a newline character. These newlines were used by “Classic” Mac OS, a system which has been discontinued in 2001, nearly two decades ago. Interoperability with such systems is no longer relevant.

Reference: [https://wiki.php.net/rfc/deprecations_php_8_1#auto_detect_line_endings_ini_setting PHP RFC: Deprecations for PHP 8.1: auto_detect_line_endings ini setting]

> The `auto_detect_line_endings` ini setting has been deprecated. If necessary, handle `\r` line breaks manually instead.

Reference: [1cf4fb739f/UPGRADING (L456-L457) PHP 8.1 Upgrade Notes].

This commit fixes the warning when running tests for the `PO` class:
{{{
Deprecated: auto_detect_line_endings is deprecated in /var/www/src/wp-includes/pomo/po.php on line 16
}}}

Follow-up to [10584], [51628].

See #53635.
Built from https://develop.svn.wordpress.org/trunk@51633


git-svn-id: http://core.svn.wordpress.org/trunk@51239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-18 13:23:56 +00:00
Peter Wilson
43e86e620a Media: Increase number of media items displayed per page.
Increase the number of media items displayed per page from 40 to 80 to improve the experience for users navigating the library on sites with a large quantity of media in the library.

Props AlGala, antpb, hellofromTonya, joedolson, SergeyBiryukov, wb1234.
Fixes #53827.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-18 06:00:59 +00:00
Peter Wilson
c9bf6d13ef Media: Fix layout of media library modal on narrow screens.
Reduces the right margin of the media library modal on small and medium width screens to remove excess white-space. On very narrow screens this was preventing the media icons from displaying.

Props andraganescu, desrosj, joedolson, moch11, mukesh27, sabernhardt, SergeyBiryukov, zieladam.
Fixes #53679.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-18 05:37:57 +00:00
Sergey Biryukov
80548a4039 Code Modernization: Check the return type of parse_url() in ms_cookie_constants().
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

It is entirely possible for the `siteurl` option to not have a "path" component.

In PHP 8.1, this would lead to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice.

Changing the logic around and adding validation for the return type value of `parse_url()` prevents that.

As this function is declaring global constants, adding tests for this change is not really an option without potentially affecting other tests.

Follow-up to [51606], [51622], [51626], [51629].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51630


git-svn-id: http://core.svn.wordpress.org/trunk@51236 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-17 22:08:57 +00:00
Sergey Biryukov
1ee5e68a94 Code Modernization: Check the return type of parse_url() on Plugin/Theme Editor screens.
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

While it is probably unlikely that someone would have a direct link to the plugin/theme editor on their home page or even on someone else's homepage, it is entirely possible for the referrer URL to not have a "path" component.

In PHP 8.1, this would lead to a `basename(): Passing null to parameter #1 ($string) of type string is deprecated` notice.

Changing the logic around and adding validation for the return type value of `parse_url()` prevents that.

Follow-up to [51606], [51622], [51626].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51629


git-svn-id: http://core.svn.wordpress.org/trunk@51235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-17 21:56:58 +00:00
Sergey Biryukov
28e10d9c17 Tests: Move loading the PO class to set_up_before_class().
This ensures that the class is loaded once before the first test of the test case class is run, and `require_once()` is not unnecessarily called for each test method individually.

Follow-up to [1106/tests].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51628


git-svn-id: http://core.svn.wordpress.org/trunk@51234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-17 20:03:00 +00:00
Sergey Biryukov
912c683b49 Tests: Use a better return type check for parse_url() in do_enclose() tests.
Since the `pathinfo()` function accepts a string, checking for that specifically is more consistent with similar checks elsewhere in core.

Follow-up to [51606], [51622], [51626].

See #53635.
Built from https://develop.svn.wordpress.org/trunk@51627


git-svn-id: http://core.svn.wordpress.org/trunk@51233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-17 00:29:03 +00:00
Sergey Biryukov
9f222b708a Code Modernization: Check the return type of parse_url() in download_url().
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

This commit adds three unit tests for `download_url()`:

* The first test is "girl-scouting" to make sure that the code up to the point where the error is expected is tested.
* The second test exposed a PHP 8.1 `basename(): Passing null to parameter #1 ($path) of type string is deprecated` error due to the call to `parse_url()` returning `null` when the component requested does not exist in the passed URL.
* The output of the call to `parse_url()` stored in the `$url_path` variable is used in more places in the function logic. The third test exposes a second PHP 8.1 deprecation notice, this time for `substr(): Passing null to parameter #1 ($string) of type string is deprecated`.

This commit also removes duplicate `parse_url()` calls. Neither `$url` nor `$url_filename` are changed between when they are first received/defined and when they are re-used, so there is no need to repeat the function calls.

Follow-up to [51606], [51622].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51626


git-svn-id: http://core.svn.wordpress.org/trunk@51232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-17 00:16:01 +00:00
Sergey Biryukov
532bd808c9 Code Modernization: Check the input type in validate_file().
This fixes a `preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated` notice on PHP 8.1.

The behavior for `null` and `string` input is covered by the existing `Tests_Functions::test_validate_file()` test.

Effect: Errors down by 238, assertions up by 1920, failures down by 1.

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51625


git-svn-id: http://core.svn.wordpress.org/trunk@51231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-16 22:53:02 +00:00
Sergey Biryukov
8a98b96f36 Code Modernization: Correct handling of null in wp_parse_str().
This fixes `parse_str(): Passing null to parameter #1 ($string) of type string is deprecated` notices on PHP 8.1, without change in behaviour.

Impact: 311 of the pre-existing tests are affected by this issue.

The PHP native `parse_str()` function expects a string, however, based on the failing tests, it is clear there are functions in WordPress which passes a non-string – including `null` – value to the `wp_parse_str()` function, which would subsequently pass it onto the PHP native function without further input validation.

Most notable offender is the `wp_parse_args()` function which special cases arrays and objects, but passes everything else off to `wp_parse_str()`.

Several ways to fix this issue have been explored, including checking the received value with `is_string()` or `is_scalar()` before passing it off to the PHP native `parse_str()` function.

In the end it was decided against these in favor of a string cast as:
* `is_string()` would significantly change the behavior for anything non-string.
* `is_scalar()` up to a point as well, as it does not take objects with a `__toString()` method into account.

Executing a string cast on the received value before passing it on maintains the pre-existing behavior while still preventing the deprecation notice coming from PHP 8.1.

Reference: [https://www.php.net/manual/en/function.parse-str.php PHP Manual: parse_str()]

Follow-up to [5709].

Props jrf, hellofromTonya, lucatume, SergeyBiryukov.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51624


git-svn-id: http://core.svn.wordpress.org/trunk@51230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-16 22:18:02 +00:00
Sergey Biryukov
864d9e9a35 Tests: Rename classes in phpunit/tests/formatting/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493].

See #53363.
Built from https://develop.svn.wordpress.org/trunk@51623


git-svn-id: http://core.svn.wordpress.org/trunk@51229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-16 21:35:07 +00:00
Sergey Biryukov
5ca2a817ab Code Modernization: Check the return type of parse_url() in WP::parse_request().
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

In this case, `parse_url()` is called with the `PHP_URL_PATH` as `$component`. This will return `null` in the majority of cases, as – exсept for subdirectory-based sites – `home_url()` returns a URL without the trailing slash, like `http://example.org`.

The return value of `parse_url()` was subsequently passed to `trim()`, leading to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1.

Fixed by adjusting the logic flow to:
* Only pass the return value of `parse_url()` to follow-on functions if it makes sense, i.e. if it isn't `null`, nor an empty string.
* Preventing calls to `preg_replace()` and `trim()` further down in the function logic flow, when `preg_replace()`/`trim()` would have nothing to do anyhow.

Follow-up to [25617].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51622


git-svn-id: http://core.svn.wordpress.org/trunk@51228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-16 20:17:57 +00:00
Sergey Biryukov
2ac9f0814d Code Modernization: Check the return type of _get_cron_array() in wp_schedule_event().
This fixes a "Deprecated: Automatic conversion of false to array is deprecated" warning on PHP 8.1.

In `wp_schedule_event()`, the cron info array is retrieved via a call to `_get_cron_array()`, but as the documentation (correctly) states, the return type of that function is `array|false`, where `false` is returned for a virgin site, with no cron jobs scheduled yet.

However, no type check is done on the return value, and the `wp_schedule_event()` function just blindly continues by assigning a value to a subkey of the `$crons` "array".

Fixed by adding validation for the returned value from `_get_cron_array()` and initializing an empty array if `false` was returned.

Reference: [https://developer.wordpress.org/reference/functions/_get_cron_array/ WordPress Developer Resources: _get_cron_array()]

Props jrf, hellofromTonya, lucatume, pbearne, iluy, pedromendonca, SergeyBiryukov.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51619


git-svn-id: http://core.svn.wordpress.org/trunk@51225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-16 15:23:57 +00:00
Sergey Biryukov
a19a2ad8b1 Twenty Twenty: Add support for wa.me links in Social menu.
This ensures that `wa.me` links, currently preferred by WhatsApp, have the same icon as `whatsapp.com` links.

Follow-up to [47243], [51617].

Props sabernhardt, macmanx.
Fixes #50542.
Built from https://develop.svn.wordpress.org/trunk@51618


git-svn-id: http://core.svn.wordpress.org/trunk@51224 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-16 12:54:58 +00:00
Sergey Biryukov
d5ac679247 Twenty Seventeen: Add support for wa.me links in Social Links menu.
This ensures that `wa.me` links, currently preferred by WhatsApp, have the same icon as `whatsapp.com` links.

Follow-up to [48027].

Props sabernhardt, carepsules, dkarfa.
Fixes #51946.
Built from https://develop.svn.wordpress.org/trunk@51617


git-svn-id: http://core.svn.wordpress.org/trunk@51223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-16 12:51:01 +00:00
Sergey Biryukov
cf4640b46e Docs: Fix typo in the get_block_editor_settings() description.
Follow-up to [50776].

Props tmatsuur, pbearne.
Fixes #53922.
Built from https://develop.svn.wordpress.org/trunk@51611


git-svn-id: http://core.svn.wordpress.org/trunk@51222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-15 12:45:59 +00:00
Sergey Biryukov
b4ea83c22f Upgrade/Install: Use consistent capitalization for "web host" in setup messages.
Follow-up to [8887], [13163].

Props bradparbs, sabernhardt, mukesh27.
Fixes #53926.
Built from https://develop.svn.wordpress.org/trunk@51610


git-svn-id: http://core.svn.wordpress.org/trunk@51221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-14 12:06:59 +00:00
Sergey Biryukov
6b144ab46a Docs: Correct @since version for the wp_parse_str filter.
The filter was introduced along with the `wp_parse_str()` function in WordPress 2.2.1.

Follow-up to [5709], [8662], [26485].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51609


git-svn-id: http://core.svn.wordpress.org/trunk@51220 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-13 15:50:58 +00:00
Sergey Biryukov
e68985e506 Tests: Add unit tests for the wp_nonce_ays() function.
Update the `wp_die_handler()` method to pass the response into `WPDieException` so that `expectExceptionCode()` calls work as expected.

Follow-up to [1221/tests], [3934], [4009], [12309].

Props pbearne, jrf, mukesh27.
Fixes #53882.
Built from https://develop.svn.wordpress.org/trunk@51608


git-svn-id: http://core.svn.wordpress.org/trunk@51219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-13 14:02:02 +00:00
Sergey Biryukov
a2a8b77806 Docs: Synchronize documentation for wp_get_attachment_image_attributes filter callbacks in bundled themes:
* Twenty Sixteen: Correct the `$attachment` parameter type, use typed array notation.
* Twenty Seventeen: Correct the `$attachment` parameter type, use typed array notation.
* Twenty Nineteen: Correct the `@return` value type, use typed array notation.
* Twenty Twenty-One: Add missing `@return` value description, use typed array notation.

Follow-up to [29836], [47249], [49021], [49597].

Props ankitmaru, mukesh27, SergeyBiryukov.
Fixes #53878.
Built from https://develop.svn.wordpress.org/trunk@51607


git-svn-id: http://core.svn.wordpress.org/trunk@51218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-12 19:30:57 +00:00
Sergey Biryukov
0984eca703 Tests: Use correct comparison in do_enclose() tests.
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

In this case, `parse_url()` is called with the `PHP_URL_PATH` as `$component`, but the returned value is subsequently checked against `false`.

In other words, this condition would previously always result in `true` and would lead to `null` potentially being passed to the PHP native `pathinfo()` function which expects a string.

On PHP 8.1, this would result in a test failure with a `pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated` error.

Reference: [https://www.php.net/manual/en/function.pathinfo.php PHP Manual: pathinfo()]

Follow-up to [46175].

Props jrf.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51606


git-svn-id: http://core.svn.wordpress.org/trunk@51217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-12 17:50:03 +00:00
Sergey Biryukov
e8a395819d Build/Test Tools: Hard deprecate WP_UnitTestCase_Base::checkRequirements().
The `WP_UnitTestCase_Base::checkRequirements()` method calls the `parent::checkRequirements()` method, but this method became `private` in PHPUnit 7.0 via commit  [932238a6a3 sebastianbergmann/phpunit@932238a].

Aside from that, the `TestCase::getAnnotations()` method which is called next is now also removed in PHPUnit 9.5.

WP core does not use the method anymore, and the method only remains to prevent potentially breaking external integration tests relying on the method. However, in effect, the method is not functional anymore in PHPUnit 7.0+.

Follow-up to [893/tests], [894/tests], [896/tests], [918/tests], [30526], [40520], [40564], [43005], [44701], [51559-51577].

Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51605


git-svn-id: http://core.svn.wordpress.org/trunk@51216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-12 10:34:01 +00:00
Sergey Biryukov
9937fea517 Build/Test Tools: Simplify the PHPUnit test workflow.
This removes the previously duplicated set of test runs specifically for PHP 8.1 in favor of combining `if` conditions for individual test runs with the `continue-on-error` option.

Follow-up to [51588].

Props desrosj, swissspidy, jrf.
Fixes #53891.
Built from https://develop.svn.wordpress.org/trunk@51604


git-svn-id: http://core.svn.wordpress.org/trunk@51215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-11 15:43:57 +00:00
Sergey Biryukov
c5c6b7de59 Build/Test Tools: Revert [51602] for now to investigate test failures on PHPUnit < 7.0.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51603


git-svn-id: http://core.svn.wordpress.org/trunk@51214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-11 15:02:58 +00:00
Sergey Biryukov
8f95d5bb91 Build/Test Tools: Hard deprecate WP_UnitTestCase_Base::checkRequirements().
The `WP_UnitTestCase_Base::checkRequirements()` method calls the `parent::checkRequirements()` method, but this method became `private` in PHPUnit 7.0 via commit  [932238a6a3 sebastianbergmann/phpunit@932238a].

Aside from that, the `TestCase::getAnnotations()` method which is called next is now also removed in PHPUnit 9.5.

WP core does not use the method anymore, and the method only remains to prevent potentially breaking external integration tests relying on the method. However, in effect, the method is not functional anymore in PHPUnit 7.0+.

Follow-up to [893/tests], [894/tests], [896/tests], [918/tests], [30526], [40520], [40564], [43005], [44701], [51559-51577].

Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51602


git-svn-id: http://core.svn.wordpress.org/trunk@51213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-11 14:31:57 +00:00
Sergey Biryukov
e2a64f0cd2 Themes: Make sure the theme API response is not an error before operating on it in themes_api().
This fixes a potential bug and avoids PHP warnings when `themes_api( 'query_themes' )` is called and a successful API response is not received.

Follow-up to [42632].

Props pierlo.
Fixes #53913.
Built from https://develop.svn.wordpress.org/trunk@51601


git-svn-id: http://core.svn.wordpress.org/trunk@51212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-11 13:01:56 +00:00