3972 Commits

Author SHA1 Message Date
Felix Arntz
afdb88e9cf Security: Allow short-circuiting the wp_update_https_detection_errors() process.
This changeset introduces a `pre_wp_update_https_detection_errors` filter which can be used to short-circuit the default logic for detecting problems with HTTPS support for the site, by returning a `WP_Error` object.

Props timothyblynjacobs.
See #47577.


git-svn-id: https://develop.svn.wordpress.org/trunk@50075 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-29 19:58:39 +00:00
Felix Arntz
4e0bc3bc93 Security, Site Health: Improve accuracy in messaging about HTTPS support.
Following up on [49904], this changeset focuses mainly on improving the guidance about the current state of HTTPS in Site Health.

* Correct the existing copy to indicate that both the Site Address and the WordPress Address need to be changed to fully switch to HTTPS.
* Link to the respective input fields via anchor links rather than to the overall General Settings screen.
* Show different copy if the site is using HTTPS for the WordPress Address (for example to have only the administration panel in HTTPS), but not for the Site Address.
* Inform the user about potential problems even when the site is already using HTTPS, for example if the SSL certificate was no longer valid.
* Always rely on fresh information for determining HTTPS support issues in Site Health, and therefore change the `https_status` test to become asynchronous.
* Rename the new private `wp_is_owned_html_output()` function to a more appropriate `wp_is_local_html_output()`.

Props adamsilverstein, flixos90, johnjamesjacoby, timothyblynjacobs.
See #47577.


git-svn-id: https://develop.svn.wordpress.org/trunk@50072 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-29 19:09:49 +00:00
Timothy Jacobs
e290a9b557 App Passwords: Introduce introspection endpoint.
This introduces a new endpoint, `wp/v2/users/me/application-passwords/introspect`, that will return details about the App Password being used to authenticate the current request. This allows for an application to disambiguate between multiple installations of their application which would all share the same `app_id`.

Props xkon, peterwilsoncc, TimothyBlynJacobs.
Fixes #52275.


git-svn-id: https://develop.svn.wordpress.org/trunk@50065 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-29 00:05:20 +00:00
Robert Anderson
bc405697b0 Editor: Update @wordpress npm packages
Update @wordpress npm packages to the latest published versions. This means that
the block editor includes functionality that exists in Gutenberg 9.8.

See #52334.
Props isabel_brison.


git-svn-id: https://develop.svn.wordpress.org/trunk@50048 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-28 02:01:50 +00:00
Jake Spurlock
a76f895146 Privacy: Ensure that exported user data reports can't be found with directory listings.
By moving from `.html` to `.php` files, we can prevent directory listings, and ensure that WordPress can load.

Fixes #52299.

Props lucasbustamante, xkon, freewebmentor, SergeyBiryukov, whyisjake. 


git-svn-id: https://develop.svn.wordpress.org/trunk@50037 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-27 23:45:29 +00:00
Timothy Jacobs
e1c98a744b App Passwords: Improve validation and sanitization of the application name.
Application names are now required to be unique and cannot contain solely whitespace characters. Additionally, invalid characters are now stripped from the application name using `sanitize_text_field()`.

Props Boniu91, hellofromTonya, engahmeds3ed, xkon, francina.
Fixes #51941.


git-svn-id: https://develop.svn.wordpress.org/trunk@50030 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-27 19:03:42 +00:00
John Blackbourn
6df02a9ce2 REST API: Introduce modified_before and modified_after query parameters for the posts endpoints.
These parameters work just the same as `before` and `after` except they operate on the post modified date instead of the post published date.

Props claytoncollie, TimothyBlynJacobs, hellofromTonya

Fixes #50617


git-svn-id: https://develop.svn.wordpress.org/trunk@50024 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-26 18:26:13 +00:00
Gary Pendergast
ee4c2cf322 Menus: Fix linting errors introduced in [50013].
Props TimothyBlynJacobs.
Fixes #52189.



git-svn-id: https://develop.svn.wordpress.org/trunk@50014 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-25 06:53:43 +00:00
Gary Pendergast
6840112825 Menus: Make use of wp_resolve_post_date() when updating menu items.
This allows a menu item `post_date` to be set to particular value, rather than only allowing it to be set to "now". In particular, the WordPress Importer can use this to perform faster, more accurate duplicate checks.

Props jmdodd.
Fixes #52189.



git-svn-id: https://develop.svn.wordpress.org/trunk@50013 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-25 01:22:06 +00:00
Gary Pendergast
e2bb95aa50 Posts: Create a new function for resolving the post date.
`wp_insert_post()` has a few checks using `post_date` and `post_date_gmt`, to determine the correct post date. This functionality is now extracted out into a new `wp_resolve_post_date()` function, allowing the checks to be reused elsewhere.

Props jmdodd.
Fixes #52187.



git-svn-id: https://develop.svn.wordpress.org/trunk@50012 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-25 01:06:25 +00:00
Timothy Jacobs
0ceee0f871 REST API: Support type coercion when validating the enum JSON Schema keyword.
Previously, the `enum` keyword was validated by perform a strict equality check. For `string` types this is generally ok, but it prevented using alternative types like `number` when rich type support isn't available.

Now the same level of type coercion/sanitization is applied when validating `enum` as all other validation checks. This means that a value of `"1"` will be accepted for an `enum` of `[ 0, 1 ]`. Additionally, `object` types now properly ignore key order when checking for equality.

Props yakimun.
Fixes #51911.


git-svn-id: https://develop.svn.wordpress.org/trunk@50010 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-24 16:50:39 +00:00
Timothy Jacobs
15c8166424 REST API: Add more specific error codes for schema validation.
Previously, the majority of JSON Schema validation errors returned a generic `rest_invalid_param` error code. In preparation for #46191, where the underlying validation error code will be exposed, this commit adds specific error codes for each failure scenario.

Fixes #52317.


git-svn-id: https://develop.svn.wordpress.org/trunk@50007 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-24 03:57:39 +00:00
Timothy Jacobs
bb395706f4 REST API: Support embedding links in rest_preload_api_request().
Props lpawlik, spacedmonkey.
Fixes #51722.


git-svn-id: https://develop.svn.wordpress.org/trunk@50005 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-23 23:25:40 +00:00
Sergey Biryukov
c145ff4a1a 5.7-alpha-50000 🎉🙌❤️
Thank you for the past
Excited for the future
We are #WordPressStrong!

git-svn-id: https://develop.svn.wordpress.org/trunk@50000 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-21 12:37:39 +00:00
Felix Arntz
176a1f53f0 Robots: Introduce Robots API.
This changeset introduces a filter-based Robots API, providing central control over the `robots` meta tag.

* Introduces `wp_robots()` function which should be called anywhere a `robots` meta tag should be included.
* Introduces `wp_robots` filter which allows adding or modifying directives for the `robots` meta tag. The `wp_robots()` function is entirely filter-based, i.e. if no filter is added to `wp_robots`, no directives will be present, and therefore the entire `robots` meta tag will be omitted.
* Introduces the following `wp_robots` filter functions which replace similar existing functions that were manually rendering a `robots` meta tag:
    * `wp_robots_noindex()` replaces `noindex()`, which has been deprecated.
    * `wp_robots_no_robots()` replaces `wp_no_robots()`, which has been deprecated.
    * `wp_robots_sensitive_page()` replaces `wp_sensitive_page_meta()`, which has been deprecated. Its rendering of the `referrer` meta tag has been moved to another new function `wp_strict_cross_origin_referrer()`.

Migration to the new functions is straightforward. For example, a call to `add_action( 'wp_head', 'wp_no_robots' )` should be replaced with `add_filter( 'wp_robots', 'wp_robots_no_robots' )`.

Plugins and themes that render their own `robots` meta tags are encouraged to switch to rely on the `wp_robots` filter in order to use the central management layer now provided by WordPress core.

Props adamsilverstein, flixos90, timothyblynjacobs, westonruter.
See #51511.


git-svn-id: https://develop.svn.wordpress.org/trunk@49992 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-21 01:35:16 +00:00
Peter Wilson
56939ff70e Media: Ensure get_post_status() returns correct result for attachments.
Prevent `get_post_status()` returning `false` for attachments if the parent post has been deleted. The returned attachment post status is now passed through the `get_post_status` filter.

Add tests for `get_post_status()`.

Props peterwilsoncc, timothyblynjacobs for review.
Fixes #52326.



git-svn-id: https://develop.svn.wordpress.org/trunk@49985 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-20 04:39:24 +00:00
Greg Ziółkowski
f84ebe3fe7 Blocks: Add automatic RTL handlind for block styles registered from metadata
Related Gutenberg issue: https://github.com/WordPress/gutenberg/pull/28274

With this change it is going to be possible to use the same pattern that wp_style_add_data uses for RTL handling. If the block style file with "-rtl.css" is included in addition to the regular style referenced in "block.json" file then it is going to be automatically registered.

Props swisspidy, aristath.
See #52301.



git-svn-id: https://develop.svn.wordpress.org/trunk@49982 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-19 11:48:59 +00:00
Greg Ziółkowski
edd77c0791 Blocks: Add i18n support to register_block_type_from_metadata
Related Gutenberg issue: https://github.com/WordPress/gutenberg/issues/23636.
Related WP-CLI PR: https://github.com/wp-cli/i18n-command/pull/210.
Related documentation proposal: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-metadata.md#internationalization-not-implemented

Adds programatic i18n support to `register_block_type_from_metadata` function for block settings registered from `block.json` file that provides `textdomain` field.


Props swissspidy, ocean90.
Fixes #52301.



git-svn-id: https://develop.svn.wordpress.org/trunk@49981 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-19 11:04:03 +00:00
Peter Wilson
5582e4965c Tests: Remove references to post status public.
Replace invalid post status `public` with the valid status `publish`.

See #51802.



git-svn-id: https://develop.svn.wordpress.org/trunk@49974 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-18 03:26:29 +00:00
SergeyBiryukov
6e98255975 Privacy: Update unit test files missed in [49970].
See #51849.

git-svn-id: https://develop.svn.wordpress.org/trunk@49971 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-17 17:48:01 +00:00
Timothy Jacobs
244e4d4e63 REST API: Allow sending an empty array to delete multi meta keys.
Previously, only `null` was supported.

Fixes #50790.
Props chrisvanpatten.


git-svn-id: https://develop.svn.wordpress.org/trunk@49966 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-17 00:49:39 +00:00
Sergey Biryukov
c8c248e967 Tests: Set up the plugin download in multisite plugin tests to come locally.
This brings consistency between single site and multisite in REST API plugin installation tests.

Previously, multisite tests were unnecessarily downloading the plugin from WordPress.org on each test run, causing external HTTP requests and leading to failures in case of a timeout.

Follow-up to [48242], [49491], [49913].

See #51669.

git-svn-id: https://develop.svn.wordpress.org/trunk@49951 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-09 05:56:04 +00:00
Greg Ziółkowski
bb01f0187c Editor: Support filtering arguments in block type registration from metadata
Adds 2 new hooks in `register_block_type_from_metadata`:

- Named `block_type_metadata` to filter the content of metadata read from `block.json`
- Named `block_type_metadata_settings` to filter the settings object determined from the metadata that is passed to `register_block_type` call

Props swissspidy.
Fixes #52138.



git-svn-id: https://develop.svn.wordpress.org/trunk@49948 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-08 16:43:29 +00:00
John Blackbourn
cf68c90021 Taxonomy: Correct and clarify documentation for the return types of term query functions.
See #51800, #38266


git-svn-id: https://develop.svn.wordpress.org/trunk@49947 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-08 15:22:17 +00:00
Peter Wilson
429c7b8ddc Tests: Increase use of shared fixtures in capability checks.
See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49932 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-04 23:32:49 +00:00
Timothy Jacobs
69cc6e61d0 REST API: Expose all themes in the themes controller.
Previously, only the active theme was made available. This commit allows for all themes to be queried if the user has the `switch_themes` or `manage_network_themes` capabilities.

This commit also no longer exposes the `page`, `per_page`, `search` and `context` query parameters since they are not supported by this controller.

Props spacedmonkey, lpawlik, TimothyBlynJacobs.
Fixes #50152.


git-svn-id: https://develop.svn.wordpress.org/trunk@49925 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-03 21:45:42 +00:00
Timothy Jacobs
ab388522aa REST API: Only include the controller's own taxonomy in it's schema.
Previously, all taxonomies were incorrectly exposed as possible values.

Props johnbillion.
Fixes #51940.


git-svn-id: https://develop.svn.wordpress.org/trunk@49922 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-02 23:47:42 +00:00
Timothy Jacobs
902e3f6b85 App Passwords: Only attempt auth if the username and password are set.
Previously, only the username was checked which caused a PHP warning in some server setups, for instance Shibboleth SSO, where the server only populates the `PHP_AUTH_USER` field.

Props MadtownLems, johnbillion, richard.tape, engahmeds3ed.
Fixes #52003.


git-svn-id: https://develop.svn.wordpress.org/trunk@49919 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-02 21:34:01 +00:00
Sergey Biryukov
fdc6fe26f2 Build/Test Tools: Check if Travis/GitHub Actions environment variables are defined.
This adjusts the logic for determining whether to skip some tests when not in the primary branch, and allows for running these tests locally.

Follow-up to [47000], [47001], [49264], [49267], [49280].

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@49916 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-02 12:19:41 +00:00
Sergey Biryukov
35e4b004f0 Tests: Disable update checks while running REST API plugin installation tests.
This prevents external HTTP requests that are not required for the tests in question and may interfere with the results in case of a timeout.

Follow-up to [48242], [49491].

See #51669.

git-svn-id: https://develop.svn.wordpress.org/trunk@49913 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-30 19:02:03 +00:00
Felix Arntz
e78d988aa2 Security, Site Health: Detect HTTPS support and encourage switching.
This changeset modifies the Site Health panel for HTTPS to provide more accurate recommendations based on whether the environment is already set up for HTTPS.

* Introduces `wp_is_using_https()` to check whether the site is configured to use HTTPS (via its Site Address and WordPress Address).
* Introduces `wp_is_https_supported()` to check whether the environment supports HTTPS. This relies on a cron job which periodically checks support using a loopback request.

Props Clorith, flixos90, miinasikk, westonruter.
Fixes #47577.


git-svn-id: https://develop.svn.wordpress.org/trunk@49904 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 19:11:20 +00:00
Sergey Biryukov
d2c8fae049 Tests: Correct @ticket references in tests/query/invalidQueries.php.
This ensures that running `phpunit --group 48556` works as expected.

Follow-up to [49900].

See #48556.

git-svn-id: https://develop.svn.wordpress.org/trunk@49902 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 15:04:54 +00:00
Peter Wilson
6da93c4588 Query: Add bad path tests with invalid WP_Query parameters.
See #48556.


git-svn-id: https://develop.svn.wordpress.org/trunk@49900 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 03:03:56 +00:00
Peter Wilson
254131d009 Query: Revert post-type specific capability changes.
The modified checks of the `read_private_posts` capability could result in unexpected SQL queries when calling `WP_Query` with invalid parameters.

Reverts [49830], [49832] and [49833].
See #48556.


git-svn-id: https://develop.svn.wordpress.org/trunk@49899 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 03:01:00 +00:00
Sergey Biryukov
96555f949a Tests: Use shared post fixture in comment template tests.
This reinstates [49848], previously reverted in [49849], with the addition of `static` keyword for the `wpSetUpBeforeClass()` method, allowing the tests to pass on PHP 8.

Props peterwilsoncc.
See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@49863 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-22 07:42:23 +00:00
John Blackbourn
7ef5a65f44 XML-RPC: Emit an appropriate HTTP status code when an error is returned in response to an XML-RPC request.
This most notably affects the response when XML-RPC is disabled or when the supplied username and password is incorrect.

Props ericmann

Fixes #48213


git-svn-id: https://develop.svn.wordpress.org/trunk@49862 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 20:21:12 +00:00
John Blackbourn
3202790820 Build/Test Tools: Don't mark the Tests_Cache::test_flush() test as risky when running the test suite with an object cache in place.
See #51802


git-svn-id: https://develop.svn.wordpress.org/trunk@49857 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 17:49:20 +00:00
John Blackbourn
51f9a54c9d XML-RPC: Fix a type error when requesting the menu field of a taxonomy.
Fixes #51493


git-svn-id: https://develop.svn.wordpress.org/trunk@49856 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 17:09:50 +00:00
Greg Ziółkowski
3d43e57237 Blocks: Align with Gutenberg the name of generated asset handle for core blocks
Related Gutenberg PR: https://github.com/WordPress/gutenberg/pull/25220.

It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged.

Props aristath.
See #50328.



git-svn-id: https://develop.svn.wordpress.org/trunk@49850 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 11:37:30 +00:00
Peter Wilson
91a6444e50 Tests: Revert use of shared post fixture in comment template tests.
Removes code throwing a fatal in PHP 8.

Reverts [49848] from trunk.
See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49849 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 03:33:48 +00:00
Peter Wilson
9fa63c38ef Tests: Use shared post fixture in comment template tests.
See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49848 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 03:15:59 +00:00
Peter Wilson
c88cbe35e8 Query: Correct some coding standards after [49843].
See #44183


git-svn-id: https://develop.svn.wordpress.org/trunk@49847 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 02:54:43 +00:00
John Blackbourn
f141418a5f Query: Correct some coding standards after [49843].
See #44183

git-svn-id: https://develop.svn.wordpress.org/trunk@49846 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 00:31:54 +00:00
John Blackbourn
99cfb00d13 Mail: Introduce a pre_wp_mail filter to allow short-circuiting the wp_mail() function without having to override the pluggable function.
Props DvanKooten, swissspidy, SergeyBiryukov, jtsternberg, ericlewis, Mte90, birgire, ayeshrajans

Fixes #35069


git-svn-id: https://develop.svn.wordpress.org/trunk@49844 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-20 15:07:23 +00:00
John Blackbourn
b04671e52f Query: Ensure the author archive title always shows the name of the queried author, regardless of whether there are results.
This brings the behaviour inline with the `<title>` element of the page which always shows the author name.

Props Tkama, subrataemfluence

Fixes #44183


git-svn-id: https://develop.svn.wordpress.org/trunk@49843 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-20 14:35:58 +00:00
Jonathan Desrosiers
3723941a9c Build/Test Tools: Run the Ajax test group for multisite.
This will help catch issues with Ajax related functionality on multisite.

A few tests have also been marked as `skipWithMultisite()` as they require network admin level capabilities when performing the same operations on a multisite install.

Props garrett-eclipse, netweb.
Fixes #46567.

git-svn-id: https://develop.svn.wordpress.org/trunk@49835 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-18 14:38:28 +00:00
Peter Wilson
c0f76faef8 Coding Standards: Minor fixes following [49830].
Fixes the fixes missed in [49832]. They are fixed now.

See #13509, #48968, #48556.


git-svn-id: https://develop.svn.wordpress.org/trunk@49833 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-18 00:26:21 +00:00
Boone Gorges
f7ced48ad8 Query: Respect post-type specific capabilities when querying for multiple post types.
After this change, the relevant `read_private_posts` capability is checked for
each queried post type. This ensures that private posts appear in search and
archive queries for users who have the ability to view those posts.

Props leogermani.

Fixes #13509, #48968, #48556.

git-svn-id: https://develop.svn.wordpress.org/trunk@49830 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-17 16:15:38 +00:00
Felix Arntz
8505c99a1b Media: Enable lazy-loading of iframes by adding the loading="lazy" attribute to iframe tags on the front-end.
* Expands the capabilities of `wp_filter_content_tags()` to add the attribute to iframe tags if enabled.
* Modifies the default behavior of `wp_lazy_loading_enabled()` so that it returns `true` for `iframe` tags.
* Introduces a `wp_iframe_tag_add_loading_attr()` function.
* Introduces a `wp_iframe_tag_add_loading_attr` filter.

Like for images, the attribute is only added to iframes which have both `width` and `height` specified (see related #50367).

Props azaozz, flixos90, westonruter.
Fixes #50756.


git-svn-id: https://develop.svn.wordpress.org/trunk@49808 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-16 21:17:24 +00:00
Ian Dunn
4595dcf7f9 Feed: Merge multiple header values to avoid fatal error.
When SimplePie parses HTTP headers, it combines multiple values for the same header into a comma-separated string. `WP_SimplePie_File` overrides the parsing, but was leaving them as an array instead.

That lead to a fatal error in PHP 8, because other parts of the codebase ended up passing an array to a function that expected a string.

Props david.binda, litemotiv, inc2734, NicolasKulka, hellofromTonya, mbabker, skithund, SergeyBiryukov, desrosj, timothyblynjacobs.
Fixes #51056. See #51956.



git-svn-id: https://develop.svn.wordpress.org/trunk@49803 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-16 00:49:32 +00:00