Commit Graph

3876 Commits

Author SHA1 Message Date
Sergey Biryukov c77798da22 Tests: Update unit tests to account for lazy-loading being disabled for custom logos by default.
Follow-up to [48870].

See #50933.

git-svn-id: https://develop.svn.wordpress.org/trunk@48874 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-27 01:53:48 +00:00
Peter Wilson bae635f1a0 Sitemaps: Prevent incorrect redirection of paged sitemap requests.
Update `redirect_canonical()` to account for custom pagination and URL format used by sitemaps in order to follow standard practices.

Introduce the function `get_sitemap_url()` to simplify getting the index and provider URLs as needed.

Props jonathanstegall, pbiron, GamerZ, salvoaranzulla, peterwilsoncc.
Fixes #50910.



git-svn-id: https://develop.svn.wordpress.org/trunk@48872 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-27 01:28:24 +00:00
Sergey Biryukov c20372e0aa Tests: Clean up some existing `@covers` tags.
The `()` at the end is unnecessary and disregarded by PHPUnit, so can be removed.

Props jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@48858 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-25 00:57:17 +00:00
Sergey Biryukov a6bb0120ac Tests: Correct a number of malformed `@covers` tags.
As per the documentation of the `@covers` tag, global functions being covered should be prefixed with `::`. Also, the `()` after the function name is redundant.

Follow-up to [39918].

Props jrf.
See #50267.

git-svn-id: https://develop.svn.wordpress.org/trunk@48848 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-23 17:23:52 +00:00
Sergey Biryukov 631f440506 Tests: Update `wp-api-generated.js` to reflect the new "Reusable Blocks" post type label.
Follow-up to [48829].

See #50755.

git-svn-id: https://develop.svn.wordpress.org/trunk@48846 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-23 14:38:40 +00:00
Sergey Biryukov c90037ca47 Tests: Clear any previous term IDs from the metadata lazyloader queue in term meta lazy-loading test.
This fixes random test failures when one of the term IDs from previous tests coincides with the orphan term ID from this test that should not be lazy-loaded.

Follow-up to [34529], [36566].

Fixes #51109.

git-svn-id: https://develop.svn.wordpress.org/trunk@48844 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-23 03:46:41 +00:00
Felix Arntz 0228dd6a5d Taxonomy: Allow for `wp_count_terms( $args )` signature, making passing a taxonomy optional.
This brings `wp_count_terms()` in line with other taxonomy functions such as `get_terms()` which technically no longer require a taxonomy. Similar to the previously modified functions, no deprecation warning is triggered when using the legacy signature.

Fixes #36399.


git-svn-id: https://develop.svn.wordpress.org/trunk@48840 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-21 22:30:06 +00:00
Sergey Biryukov ca5c4cebef Coding Standards: Fix WPCS issue in [48830].
See #51044.

git-svn-id: https://develop.svn.wordpress.org/trunk@48831 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-19 16:33:02 +00:00
Sergey Biryukov 62562f8428 Tests: Update unit tests to account for `comment_agent` and `comment_author_IP` values being passed to the `preprocess_comment` filter.
See #51044.

git-svn-id: https://develop.svn.wordpress.org/trunk@48830 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-19 16:06:27 +00:00
Sergey Biryukov 76c599ced2 Formatting: Make the check for empty text in `wp_trim_excerpt()` more resilient.
This addresses a regression in [47808], which caused excerpts to be generated from post content if an empty string is passed, but not for other values considered empty, e.g. `null` or `false`.

Props riaanlom, laxman-prajapati, SergeyBiryukov.
Fixes #51042.

git-svn-id: https://develop.svn.wordpress.org/trunk@48817 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-18 15:08:19 +00:00
Sergey Biryukov cbaa88cb5a Code Modernization: Introduce `is_gd_image()` to check for PHP 8 `GdImage` object instances.
In PHP 8, the GD extension uses `GdImage` objects instead of resources for its underlying data structures.

This updates the existing `is_resource()` calls for image resources in core to accomodate for `GdImage` instances as well.

Props ayeshrajans, jrf.
Fixes #50833.

git-svn-id: https://develop.svn.wordpress.org/trunk@48798 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-16 13:31:57 +00:00
Timothy Jacobs dddddc47f4 REST API: Add uniqueItems as a permitted endpoint argument JSON Schema keyword.
Support for the `uniqueItems` keyword was added in [48357], but wasn't included in the list of permitted keywords for `WP_REST_Controller::get_endpoint_args_for_item_schema()`. This prevented the keyword from being automatically supported if specified in a controller's item schema.

Fixes #51021.


git-svn-id: https://develop.svn.wordpress.org/trunk@48796 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-15 16:09:56 +00:00
Sergey Biryukov 9c220ffaf7 Code Modernization: Fix PHP 8 deprecation notices for optional function parameters declared before required parameters.
As it already was not possible to pass the required parameters without also passing the optional one anyway, removing the default value for the (not so) optional parameters should not affect backward compatibility.

This change affects three functions in core:

* `get_comment_delimited_block_content()`
* `do_enclose()`
* `_wp_delete_tax_menu_item()`

Props jrf, ayeshrajans, desrosj.
Fixes #50343.

git-svn-id: https://develop.svn.wordpress.org/trunk@48794 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-15 13:38:52 +00:00
Sergey Biryukov 285d176f08 Tests: Consistently unregister custom settings after performing assertions in `WP_Test_REST_Settings_Controller`.
This ensures that those settings don't leak to other tests.

Props david.binda, TimothyBlynJacobs, SergeyBiryukov.
Fixes #50986.

git-svn-id: https://develop.svn.wordpress.org/trunk@48791 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-14 16:33:24 +00:00
Sergey Biryukov f0733600c9 Code Modernization: Change `create_function()` in `phpunit/includes/plural-form-function.php` to closure.
`create_function()` has been deprecated in PHP >= 7.2 and removed in PHP 8.

The only instance left in core was used in a test that was being skipped on PHP >= 7.2. This allows the test to run again.

Follow-up to [41722], [41730].

Props jrf.
Fixes #50899.

git-svn-id: https://develop.svn.wordpress.org/trunk@48790 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-13 12:32:03 +00:00
Sergey Biryukov 1bf0a780b3 Code Modernization: Remove `final` keyword from private methods.
Declaring a `private` method as `final` is an oxymoron, as `private` methods cannot be overloaded anyway.

Using `final private function...` will generate a warning in PHP 8.

Props jrf.
Fixes #50897.

git-svn-id: https://develop.svn.wordpress.org/trunk@48788 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-12 15:03:50 +00:00
Jake Spurlock 6ebff324b2 Themes: Update the `test_theme_supports_custom_logo` to check for the `unlink-homepage-logo` property.
See #37011, [48757].
Props TimothyBlynJacobs, whyisjake.


git-svn-id: https://develop.svn.wordpress.org/trunk@48758 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-07 20:42:04 +00:00
Sergey Biryukov def2425406 Comments: Update comment cache in the upgrade routine for changing the `comment_type` DB field value in comments table.
This ensures that comment object cache is cleared after changing the comment type to `comment` instead of an empty string.

Add a unit test for `_wp_batch_update_comment_type()`.

Follow-up to [47597], [47626], [48225], [48227].

Props imath, westonruter.
Fixes #49236.

git-svn-id: https://develop.svn.wordpress.org/trunk@48748 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-07 14:27:40 +00:00
Sergey Biryukov 58f9000f3e Tests: Correct duplicate array keys in `Tests_Kses::test_wp_filter_post_kses_address()`.
Previously, only the last `style` value was actually tested.

Props ediamin.
Fixes #50860.

git-svn-id: https://develop.svn.wordpress.org/trunk@48744 602fd350-edb4-49c9-b593-d223f7449a82
2020-08-06 13:26:06 +00:00
Sergey Biryukov cded42aa94 Taxonomy: Rename the `default_taxonomy_$taxonomy` option key to `default_term_$taxonomy`.
This better reflects the purpose of the option.

Follow-up to [48356], [48480].

See #43517.

git-svn-id: https://develop.svn.wordpress.org/trunk@48665 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-28 15:40:35 +00:00
Sergey Biryukov 6e66f08ec9 Taxonomy: Ensure the `child_of` argument of `get_terms()` works as expected with `'fields' => 'id=>name'` or `'id=>slug'`.
Props Howdy_McGee, deepaklalwani, planvova.
Fixes #46768.

git-svn-id: https://develop.svn.wordpress.org/trunk@48663 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-28 14:21:54 +00:00
Timothy Jacobs b29101aca0 REST API: Remove assets field from block directory controller.
Gutenberg no longer uses the assets field to fetch the assets for the installed block so this field can be dropped from the endpoint. This allows us to reintroduce it at a later point without needing to worry about backward compatibility.

See #50732.


git-svn-id: https://develop.svn.wordpress.org/trunk@48656 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-28 04:08:56 +00:00
Jake Spurlock 8c9b33c3b6 Mail: PHPMailer swap to use is_email for the default validator.
Prior to the PHPMailer update in 5.5, old version of the PHPMailer was setting the validator to 'auto' resulting in a sophisticated logic for determining what email address validation should be used. But the new version defaults to 'php', possibly leading to rejection of email addresses which were fine prior to the upgrade. Let's use the WordPress core function `is_email()` so that it can be fully pluggable.

Fixes #50720.
Props david.binda, ayeshrajans, Synchro, SergeyBiryukov, whyisjake.


git-svn-id: https://develop.svn.wordpress.org/trunk@48645 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-27 20:17:36 +00:00
Timothy Jacobs 5149a7efd5 REST API: Fix warning when using `set_param()` on a JSON request with no body.
In [47559] the `WP_REST_Request::set_param()` method was adjusted to try and overwrite an existing parameter definition before forcing the value in the first parameter slot. If `set_param()` was called on a request with an `application/json` content type and an empty body, a PHP warning would be issued. This was due to the JSON parameter type not being set to an array when the body is empty.

This commit avoids the warning by adding an `is_array()` check before calling `array_key_exists`. Ideally, `WP_REST_Reuest::parse_json_params()` would set the JSON parameter type to an empty array in this case, but that is too large of a change at this point in the cycle.

Props manooweb.
Fixes #50786.


git-svn-id: https://develop.svn.wordpress.org/trunk@48642 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-27 18:44:14 +00:00
Sergey Biryukov fc62131e31 Tests: Add more fixtures to `get_lastpostdate()` and `get_lastpostmodified()` tests.
Follow-up to [48631].

Props munyagu.
See #47777.

git-svn-id: https://develop.svn.wordpress.org/trunk@48633 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-27 11:15:04 +00:00
Sergey Biryukov 581deff371 Posts, Post Types: Pass the post type to `get_lastpostdate()` in `get_lastpostmodified()`.
This ensures that the correct values are being compared when retrieving the result for custom post types.

Additionally, pass the `$post_type` parameter to `get_lastpostdate` and `get_lastpostmodified` filters.

Props mikaumoto, munyagu, donmhico, johnbillion, SergeyBiryukov.
Fixes #47777.

git-svn-id: https://develop.svn.wordpress.org/trunk@48631 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-27 02:16:46 +00:00
Sergey Biryukov 40dd42c35d REST API: Use a consistent name for the `textdomain` schema property between plugins, themes, and block directory controllers.
Follow-up to [48242].

See #50321, #50776.

git-svn-id: https://develop.svn.wordpress.org/trunk@48627 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-26 21:47:56 +00:00
Sergey Biryukov 6fa3286a1b Pings/Trackbacks: Avoid a PHP notice in `do_enclose()` when encountering a URL without a path in post content.
Props jbouganim, mukesh27, Otto42, SergeyBiryukov.
Fixes #49872.

git-svn-id: https://develop.svn.wordpress.org/trunk@48621 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-26 14:06:03 +00:00
Sergey Biryukov 674e7a2283 Tests: Update `wp_unique_filename()` unit tests to account for `sanitize_file_name()` removing accents.
Follow-up to [48603].

See #22363.

git-svn-id: https://develop.svn.wordpress.org/trunk@48604 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-24 18:17:49 +00:00
Sergey Biryukov c7783dc49a Media: Remove accents in `sanitize_file_name()`.
This brings some consistency with `sanitize_title()` and `sanitize_user()`.

Props tar.gz, NumidWasNotAvailable, juliobox, p_enrique, cristovaov, zodiac1978, mikeschroder, markoheijnen, chriscct7, swissspidy, DrProtocols, pento, gitlost, joemcgill, dustinbolton, programmin, Vayu, MaximeCulea, lucasbustamante, nilovelez, RavanH, audrasjb, SergeyBiryukov.
See #22363.

git-svn-id: https://develop.svn.wordpress.org/trunk@48603 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-24 18:01:48 +00:00
Sergey Biryukov 3ebdc35d36 Media: Filter out a few more special characters in `sanitize_file_name()`.
Props audrasjb.
Fixes #50231.

git-svn-id: https://develop.svn.wordpress.org/trunk@48596 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-24 00:57:26 +00:00
Sergey Biryukov f2d98192de Formatting: Filter out the bullet character in `sanitize_title_with_dashes()`.
Props roytanck, deepaklalwani, veromary.
Fixes #49791.

git-svn-id: https://develop.svn.wordpress.org/trunk@48593 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-24 00:01:32 +00:00
Sergey Biryukov 1ef40b14cd Build/Test Tools: Check if all the required constants are defined before running the test suite.
Follow-up to [47904].

Props azaozz, TimothyBlynJacobs, SergeyBiryukov.
Fixes #50251.

git-svn-id: https://develop.svn.wordpress.org/trunk@48592 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-23 23:26:50 +00:00
Sergey Biryukov b554928e83 Tests: Update the `es_ES` string used in `wp_send_user_request()` tests to match the current translation.
Props a2hosting.
Fixes #50741.

git-svn-id: https://develop.svn.wordpress.org/trunk@48581 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-23 18:21:13 +00:00
John Blackbourn 7d4c77560c Docs: Further corrections and improvements to various inline docblocks.
See #49572

git-svn-id: https://develop.svn.wordpress.org/trunk@48576 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-23 07:37:57 +00:00
Aaron Jorbin cefe2c7f7c General: Update code for readability and inclusion
There are two pieces in here:

1) The update to change blacklist to blocklist is moved to disallowed_list. "Block" has a meaning in our code, and there could be ambiguity between this code and code related to blocks.

2) This improves backwards compatibility for code that was accessing the now deprecated code.

Previously: [48477], [48405], [48400], [48121], [48122], [48124], [48142], [48566]

Props: desrosj, SergeyBiryukov, johnjamesjacoby
Fixes: #50413



git-svn-id: https://develop.svn.wordpress.org/trunk@48575 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-23 03:12:49 +00:00
Jake Spurlock 447d25f090 Media: Add "loading" as an allowed kses image attribute
With loading="lazy" being added to all images in [47554], let's ensure that it passes kses attributes too.

Fixes #50731.
Props TimothyBlynJacobs, peterwilsoncc, azaozz. 



git-svn-id: https://develop.svn.wordpress.org/trunk@48572 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-23 00:42:48 +00:00
Sergey Biryukov f840dabcc6 Widgets: Make sure image widgets with custom image size render captions.
Props kasparsd, JavierCasares, audrasjb.
Fixes #50160.

git-svn-id: https://develop.svn.wordpress.org/trunk@48557 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 23:12:22 +00:00
Timothy Jacobs df8399dce5 REST API: Optimize rest_filter_response_by_context performance.
In [47758] a new function `rest_filter_response_by_context` was introduced to expand the JSON schema features supported by the context filtering mechanism.

This commit improves the performance of that function by eliminating repetitive comparisons and loops. Additionally, it improves multi-type support for object + array types.

Fixes #50700.
Props dlh.


git-svn-id: https://develop.svn.wordpress.org/trunk@48555 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 21:20:22 +00:00
Sergey Biryukov 26362089c5 Sitemaps: Rename `wp_register_sitemap()` to `wp_register_sitemap_provider()`.
Follow-up to [48536], [48540], [48541].

Props pbiron.
Fixes #50724.

git-svn-id: https://develop.svn.wordpress.org/trunk@48553 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 20:13:59 +00:00
Sergey Biryukov 8c7fe179da Sitemaps: Rename `wp_get_sitemaps_providers()` to `wp_get_sitemap_providers()`.
Follow-up to [48536], [48540].

Props pbiron, swissspidy, SergeyBiryukov.
See #50724.

git-svn-id: https://develop.svn.wordpress.org/trunk@48541 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 16:04:35 +00:00
Pascal Birchler 83b94f5cd6 Sitemaps: Rename `wp_get_sitemaps()` to `wp_get_sitemaps_providers()`
Following [48536], rename the function to match the rest of the sitemaps logic.

Also eliminates some dead code after [48523].

Props pbiron.
See #50724. See #50643.

git-svn-id: https://develop.svn.wordpress.org/trunk@48540 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 15:55:21 +00:00
Sergey Biryukov 383540b7c4 Sitemaps: Rename 'sitemap' to 'provider' in `WP_Sitemaps_Registry` class.
This class is for registering sitemap providers, not individual sitemaps.

Props swissspidy.
Fixes #50724.

git-svn-id: https://develop.svn.wordpress.org/trunk@48536 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 15:27:48 +00:00
Pascal Birchler 38cade3b07 Sitemaps: Correctly enforce maximum number of sitemaps in index.
Before this change, the limit of 50k entries was enforced for the number of providers, not the amount of sitemaps all providers add to the index in total.

Props pbiron, swissspidy.
Fixes #50666.

git-svn-id: https://develop.svn.wordpress.org/trunk@48532 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 13:55:45 +00:00
Timothy Jacobs 74cc64d74e REST API: Issue a _doing_it_wrong when registering a route without a permission callback.
The REST API treats routes without a permission_callback as public. Because this happens without any warning to the user, if the permission callback is unintentionally omitted or misspelled, the endpoint can end up being available to the public. Such a scenario has happened multiple times in the wild, and the results can be catostrophic when it occurs.

For REST API routes that are intended to be public, it is recommended to set the permission callback to the `__return_true` built in function.

Fixes #50075.
Props rmccue, sorenbronsted, whyisjake, SergeyBiryukov, TimothyBlynJacobs.


git-svn-id: https://develop.svn.wordpress.org/trunk@48526 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 12:01:10 +00:00
Timothy Jacobs 2daa951685 REST API: Make plugin installation tests more robust on alternate test environments.
The REST API plugin installation tests use the `upgrader_pre_download` filter to avoid downloading the test plugin from WordPress.org. Previously, this would apply to any upgrader, which caused issues if the testing environment required a language update.

Now, the filter only overwrites the file if the `Plugin_Upgrader` is being used which should hopefully prevent the issue.

Props pfefferle, TimothyBlynJacobs.
Fixes #50671.


git-svn-id: https://develop.svn.wordpress.org/trunk@48524 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 01:36:16 +00:00
Jake Spurlock 60d339cfde Sitemaps: Ensure correct HTTP status when sitemaps are disabled
If sitemaps are disabled, previously there would be a rewrite rule for the sitemap endpoint. This endpoint would display the homepage since there was a rewrite rule. Now, Sitemaps are loaded, and the proper HTTP headers are returned.

Fixes #50643.
Props swissspidy, kraftbj, donmhico.



git-svn-id: https://develop.svn.wordpress.org/trunk@48523 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 00:55:20 +00:00
Jake Spurlock 4ba60208d4 Comments: Don't show the filter/pagination actions if there are no comments to list.
It doesn't make sense to be able to filter the comments list table when there are are no (trashed/spam) comments available.

Fixes #40188.
Props swissspidy, Jim_Panse, menakas, akbarhusen429, dinhtungdu, birgire, SergeyBiryukov, davidbaumwald, rebasaurus, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@48521 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-21 00:27:46 +00:00
Sergey Biryukov fa7b1bbb99 Tests: Simplify some assertions in `phpunit/tests/media.php`.
Correct comments per the documentation standards.

Follow-up to [48496].

See #22101.

git-svn-id: https://develop.svn.wordpress.org/trunk@48516 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-20 15:47:37 +00:00
Timothy Jacobs d525642dd1 Meta: Reorder the get_metadata_default() signature to match get_metadata().
The order of parameters in `get_metadata_default()` did not match the signature of `get_metadata()`. This could be confusing for developers who are familiar with the existing metadata API.

Fixes #43941.
Props SergeyBiryukov, spacedmonkey, johnjamesjacoby.


git-svn-id: https://develop.svn.wordpress.org/trunk@48502 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-17 02:57:04 +00:00
Jake Spurlock e7671336a4 Code Formatting: Fix some formatting around `WP_REST_Attachments_Controller` tests.
See #50565.



git-svn-id: https://develop.svn.wordpress.org/trunk@48499 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-16 22:09:35 +00:00
Andrew Ozz 0aab2584a0 REST API: Prevent attachment ID/image source mismatch when editing an image.
Fixes #50565.

git-svn-id: https://develop.svn.wordpress.org/trunk@48498 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-16 21:54:37 +00:00
Jake Spurlock 082cb0ab20 Posts, Post Types: Ensure that all post stati are countable in `wp_count_posts`.
When `wp_count_posts()` is cached, it does so with all statuses defaulted to 0. The problem is however, if this is called before all plugins have registered their desired statuses, they won't have that default.

Fixes #49685.

Props obliviousharmony, SergeyBiryukov.



git-svn-id: https://develop.svn.wordpress.org/trunk@48497 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-16 21:42:48 +00:00
Jake Spurlock ceccb7b3b1 Feeds: Ensure that galleries can be output as a list of links in feeds.
Adjusts the gallery shortcode handler to check for the `link` attribute when outputting to a feed.

Fixes #22101.

Props ifrins, mdgl, SergeyBiryukov, chriscct7, stevenkword, iworks, DrewAPicture, birgire, whyisjake.


git-svn-id: https://develop.svn.wordpress.org/trunk@48496 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-16 21:29:05 +00:00
Sergey Biryukov c843cf19c3 Taxonomy: Make some adjustments to handling default terms for custom taxonomies:
* Move default term assignment from `wp_set_object_terms()` to `wp_insert_post()`.
* Make sure the passed taxonomy list overwrites the existing list if not empty.
* Remove the default term option on `unregister_taxonomy()`.
* Prevent deletion of the default term in `wp_delete_term()`.

Props enrico.sorcinelli, TimothyBlynJacobs.
See #43517.

git-svn-id: https://develop.svn.wordpress.org/trunk@48480 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-14 16:39:44 +00:00
swissspidy 0ee9100e6d Sitemaps: Ensure entry for ‘page’ post type sitemap in index.
If there are no pages and no static homepage, there will still be one sitemap including the homepage URL.

This change ensures that this sitemap is correctly listed in the sitemap index.

Props Chouby, pacifika, elrae.
Fixes #50571.

git-svn-id: https://develop.svn.wordpress.org/trunk@48476 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-14 12:24:02 +00:00
Pascal Birchler efb0b58598 Sitemaps: Exclude post types and taxonomies that are not publicly queryable.
Props Cybr.
Fixes #50607.

git-svn-id: https://develop.svn.wordpress.org/trunk@48474 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-14 11:54:49 +00:00
Pascal Birchler 585f623b4d Sitemaps: Add missing slash when calling `home_url()` for consistency.
Props Chouby.
Fixes #50570.

git-svn-id: https://develop.svn.wordpress.org/trunk@48472 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-14 11:52:43 +00:00
Sergey Biryukov 80fae63d57 Tests: Ignore EOL differences in some tests using multiline string assertions.
Unix vs. Windows EOL style mismatches can cause misleading failures in tests using the heredoc syntax (`<<<`) or multiline strings as the expected result.

Follow-up to [46612], [48443].

See #31432.

git-svn-id: https://develop.svn.wordpress.org/trunk@48466 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-14 01:40:33 +00:00
Sergey Biryukov 022ebde54d Tests: Replace hardcoded `/tmp/` references with `get_temp_dir()`.
This allows more tests to pass on Windows.

Props danielhuesken, DJPaul, christophherr, joemcgill, netweb, davidbaumwald, SergeyBiryukov.
Fixes #40856, #39975.

git-svn-id: https://develop.svn.wordpress.org/trunk@48464 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-14 01:28:17 +00:00
Sergey Biryukov 0ded98ff2c Tests: Copy themes from `tests/phpunit/data` to `wp-content/themes`, instead of creating a symlink.
This allows the theme file tests in `phpunit/tests/link/themeFile.php` to run on Windows without requiring administrative privileges.

Follow-up to [42812], [42819].

Props danielhuesken, christophherr, davidbaumwald, SergeyBiryukov.
See #40856, #39975.

git-svn-id: https://develop.svn.wordpress.org/trunk@48463 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-14 00:32:36 +00:00
Andrew Ozz dd50193d6a Media: Fix `wp_image_file_matches_image_meta()` to also match when the original image URL is used.
Also refreshes and fixes some of the unit tests for media, and replaces test-image-large.png with test-image-large.jpg which is larger to allow testing of `original_image` in the image meta.

Fixes #50628.



git-svn-id: https://develop.svn.wordpress.org/trunk@48454 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-12 21:18:38 +00:00
SergeyBiryukov 9d30b02ed1 Administration: Handle the result of `Plugin_Upgrader::bulk_upgrade()` for a plugin that is already at the latest version in the same way it is handled for themes.
This corrects a fragile check of the result in `wp_ajax_update_plugin()` that depended on the internal array pointer, and brings some consistency with `wp_ajax_update_theme()`.

Follow-up to [37714], [48401].
See #50448.

git-svn-id: https://develop.svn.wordpress.org/trunk@48445 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-12 01:14:01 +00:00
Sergey Biryukov 43c193f58b Tests: Ignore EOL differences in email tests using multiline string assertions.
Unix vs. Windows EOL style mismatches can cause misleading failures in tests using the heredoc syntax (`<<<`) or multiline strings as the expected result.

Follow-up to [46612], [48033].

Props davidbaumwald.
See #31432, #41750.

git-svn-id: https://develop.svn.wordpress.org/trunk@48443 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-11 23:27:51 +00:00
Sergey Biryukov accf884aac Docs: Correct comments in `tests/formatting/WPSlash.php` per the documentation standards.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48442 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-11 22:50:36 +00:00
Sergey Biryukov a9368a89e5 Menus: Simplify the test for `wp_update_nav_menu_item()` with special characters in category name.
The `menu-item-title` value is saved as a `post_title` property, so the resulting property can be checked directly, without a callback.

Follow-up to [48416].

See #48011.

git-svn-id: https://develop.svn.wordpress.org/trunk@48439 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-11 21:46:29 +00:00
Sergey Biryukov d5cfd5c63c Revisions: Restore the return value of `wp_get_post_autosave()` to the documented type of `WP_Post` for backward compatibility.
Follow-up to [48422].

See #34560.

git-svn-id: https://develop.svn.wordpress.org/trunk@48438 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-11 21:13:56 +00:00
Timothy Jacobs 8f39f8ebb7 REST API: Sanitize block renderer attributes.
In [48069] the Block Renderer was changed to register a single route for all dynamic blocks. Validation was dynamically applied based on the requested block, but sanitization was not. This commit adds the same sanitization back to the block attributes.

Props manooweb.
Fixes #50620. See #48079.


git-svn-id: https://develop.svn.wordpress.org/trunk@48437 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-11 20:32:19 +00:00
Sergey Biryukov b4232b7de7 Coding Standards: Use strict type check for `in_array()` in `wp-includes/feed.php`.
Additionally:
* Correct inline comments per the documentation standards.
* Correct the `@ticket` reference in `tests/feed/atom.php`.

Follow-up to [48429].

See #33591.

git-svn-id: https://develop.svn.wordpress.org/trunk@48435 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-11 12:12:46 +00:00
Jake Spurlock 21273c3c49 Formatting: Prevent wp_slash from returning non-strings as strings.
If a bool/float/int is passed into wp_slash it will be coerced into a string.

This changes the behavior to only slash strings. At the same time, handles recursion a little nicer by calling array_map for arrays.

Fixes #42195, #24106.

Props johnbillion, andizer, jrf, ryotasakamoto, SergeyBiryukov, donmhico, TobiasBg, markoheijnen, ryan, nacin, devesine, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@48433 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-11 00:11:57 +00:00
Jake Spurlock 7c1ff0845f Coding Standards: Ensure strict type check.
See [48429], #33591.


git-svn-id: https://develop.svn.wordpress.org/trunk@48431 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-10 23:13:16 +00:00
Jake Spurlock 4337c258dc Feeds: Ensure that enclosures produce valid XML.
Metadata that is stored on newlines has the possibility of missing values, so rather then coercing values, we can check for them and then implicity set the values.

Fixes #33591.
Props jonnybot, stevenkword, vtieu, birgire, SergeyBiryukov, davidbaumwald, rebasaurus, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@48429 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-10 22:21:22 +00:00
Adam Silverstein 4adb926ce8 Revisions: optimize performance when post has large number of revisions.
Improve speed and reduce the memory footprint when loading posts with many revisions.

* Use a direct query in `wp_get_post_autosave` to avoid loading all revisions.
* Query for IDs vs full objects in `register_and_do_post_meta_boxes`.

Props pdfernhout, johnnyb, miqrogroove, ocean90, senatorman, DBrumbaugh10Up, martijn-van-der-kooij, pavelevap, mackensen, mikeyarce, whyisjake.
Fixes #34560.



git-svn-id: https://develop.svn.wordpress.org/trunk@48422 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-10 15:12:00 +00:00
Jake Spurlock 3667d18943 Menus: Ensure that category menus with special characters can be updated.
Slashes and HTML encoding could cause some menus not to be updated.

Fixes #48011.

Props zaheerahmad, achyuthajoy, desrosj, pento, SergeyBiryukov, donmhico, audrasjb, birgire, mikeschroder.



git-svn-id: https://develop.svn.wordpress.org/trunk@48416 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-10 05:58:49 +00:00
Sergey Biryukov 9683101398 Docs: Synchronize and correct documentation for various metadata functions and filters.
Follow-up to [47390], [47611], [48192], [48402].

See #49572, #43941, #45464.

git-svn-id: https://develop.svn.wordpress.org/trunk@48411 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-09 11:24:43 +00:00
Timothy Jacobs 612eeb92a8 REST API, Meta: Introduce support for default metadata values.
The `register_meta()` API now officially supports specifying a default metadata value. When `get_metadata()` is called for a meta key that does not yet exist for the object, this default value will be returned instead of an empty string.

A new function is introduced `get_metadata_raw` to retrieve the raw metadata value from the database, without applying the registered default.

Props spacedmonkey, flixos90, rmccue, kadamwhite, mnelson4, johnbillion, chrisvanpatten, TimothyBlynJacobs.
Fixes #43941.



git-svn-id: https://develop.svn.wordpress.org/trunk@48402 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-07 20:45:55 +00:00
Riad Benguella e16565b2d4 Block Editor: Add a script to run Gutenberg end 2 end tests on Core.
The script is not part of CI yet because the job takes 40mn to run
and it's not useful in all PRs/commits.

Fixes #50469.


git-svn-id: https://develop.svn.wordpress.org/trunk@48382 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-07 16:06:43 +00:00
Sergey Biryukov 4e78b0acd9 Themes: Allow template loading functions to pass additional arguments to the template via the `$args` parameter.
This affects:
* `get_header()`
* `get_footer()`
* `get_sidebar()`
* `get_template_part()`
* `locate_template()`
* `load_template()`

Note: `get_search_form()` already passes additional arguments to the template as of [44956].

Props enrico.sorcinelli, sc0ttkclark, scribu, nacin, wonderboymusic, GeertDD, beatpanda, amaschas, mintindeed, ysalame, caiocrcosta, bigdawggi, julianm, eddiemoya, shawnz, sayedwp, shamai, mboynes, mihai2u, guidobras, Mte90, apedog, stuffradio, overclokk, johnbillion, joyously, afercia, audrasjb, justlevine, SergeyBiryukov.
See #21676.

git-svn-id: https://develop.svn.wordpress.org/trunk@48370 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-07 11:00:21 +00:00
Sergey Biryukov b88a906e5e Docs: Miscellaneous DocBlock corrections.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48365 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-07 09:28:19 +00:00
Timothy Jacobs 41912bcece REST API: Add support for the uniqueItems keyword.
Props sorenbronsted.
Fixes #48821.


git-svn-id: https://develop.svn.wordpress.org/trunk@48357 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-07 03:20:34 +00:00
Jake Spurlock abfd9441b7 Taxonomy: Add support for default terms for custom taxonomies.
The new default_term argument is added to `register_taxonomy()` allowing a user to define the default term `name` and optionally `slug` and `description`. 

Fixes #43517.

Props enrico.sorcinelli, SergeyBiryukov, desrosj, davidbaumwald, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@48356 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-07 00:53:41 +00:00
Sergey Biryukov 708e6de8ea Tests: Temporarily skip PDF tests if they fail due to ImageMagick permission errors.
See #50573.

git-svn-id: https://develop.svn.wordpress.org/trunk@48341 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 18:20:32 +00:00
Sergey Biryukov a45a4f98ef Tests: Add some assertions to PDF tests for better debugging.
Props enrico.sorcinelli.
See #50573.

git-svn-id: https://develop.svn.wordpress.org/trunk@48338 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 16:13:26 +00:00
Sergey Biryukov b82c472f24 Tests: Correct hardcoded "3 months ago" assertion in `tests/rest-api/rest-block-directory-controller.php`.
Now that more than 3 months have passed since 2020-03-23, this was causing test failures.

Follow-up to [48242].

See #50321.

git-svn-id: https://develop.svn.wordpress.org/trunk@48333 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 09:49:07 +00:00
Sergey Biryukov 818de7d83e Coding Standards: Fix WPCS issues in `tests/media.php`.
See #50543.

git-svn-id: https://develop.svn.wordpress.org/trunk@48331 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 09:17:15 +00:00
Sergey Biryukov 13dee8f174 Privacy: Simplify the logic for updating the meta values for personal data export requests from absolute to relative paths.
Follow-up to [48127].

See #44038.

git-svn-id: https://develop.svn.wordpress.org/trunk@48330 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-06 00:32:15 +00:00
Andrew Ozz 27ccafd0e9 Media:
- Introduce `wp_image_file_matches_image_meta()` utility function to check whether the image meta (retrieved by attachment ID) matches an image path or URI. A mismatch may happen in some cases, for example after the posts have been exported from one website and imported in another.
- Add unit tests for the new function.
- Improve `wp_image_src_get_dimensions()` a bit and use the new function to prevent these edge cases.

Fixes #50543.

git-svn-id: https://develop.svn.wordpress.org/trunk@48329 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 23:30:36 +00:00
Sergey Biryukov 530eedb538 Query: Make sure the `found_posts` property of `WP_Query` is always an integer, to match the documented type.
This makes the property consistent with similar properties of other classes:
* `WP_Comment_Query::$found_comments`
* `WP_Network_Query::$found_networks`
* `WP_Site_Query::$found_sites`
* `WP_User_Query::$total_users`

Props birgire, PressLabs.
Fixes #42469.

git-svn-id: https://develop.svn.wordpress.org/trunk@48328 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 21:32:26 +00:00
Sergey Biryukov 5c41e3af90 Docs: Fix typos in comments in `tests/dependencies/jquery.php`.
Props hareesh-pillai.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48325 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 20:27:52 +00:00
Andrew Ozz 1c8ebd5da6 Build/Test Tools: update PHPUnit tests after [48323]. Disable and keep the specific jQuery Migrate dependency tests for use in WP 5.6.
See #37110.

git-svn-id: https://develop.svn.wordpress.org/trunk@48324 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 19:22:24 +00:00
Sergey Biryukov 42d51e4e2e Tests: Remove `ja_JP` locale from `Tests_DB::test_locale_floats()`.
This test is only relevant for locales using a comma as a decimal separator, while `ja_JP` uses a dot.

Props gh640, johnjamesjacoby, SergeyBiryukov.
Fixes #49690.

git-svn-id: https://develop.svn.wordpress.org/trunk@48317 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 12:50:47 +00:00
Dominik Schilling 2a22dcf8a6 Multisite: Delete the signup entry when a user is deleted from the database.
When a user has registered with incorrect data and got the account deleted immediately, it currently wasn't possible to register with the same login or email address again due to the existing signup entry. They had to wait for two days until the entry gets automatically deleted. Now the associated signup entry gets deleted as part of the account deletion.

Fixes #43232.

git-svn-id: https://develop.svn.wordpress.org/trunk@48315 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 11:19:35 +00:00
Sergey Biryukov 34730d2ea0 Post Thumbnails: Change the return value of `get_post_thumbnail_id()` for a non-existing post to `false` instead of an empty string.
This further makes the function more consistent with `get_the_ID()` or `wp_get_post_parent_id()`, both returning `false` for a non-existing post.

Additionally, document that `get_post_thumbnail_id()` returns `0` if the thumbnail image is not set.

Follow-up to [47160].

Props theMikeD, dingo_d, netpassprodsr, SergeyBiryukov.
Fixes #49832. See #40096.

git-svn-id: https://develop.svn.wordpress.org/trunk@48310 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 10:15:40 +00:00
Timothy Jacobs 205eb1abc9 REST API: Make multi-typed schemas more robust.
A multi-type schema is a schema where the `type` keyword is an array of possible types instead of a single type. For instance, `[ 'object', 'string' ]` would allow objects or string values.

In [46249] basic support for these schemas was introduced. The validator would loop over each schema type trying to find a version that matched. This worked for valid values, but for invalid values it provided unhelpful error messages. The sanitizer also had its utility restricted.

In this commit, the validators and sanitizers will first determine the best type of the passed value and then apply the schema with that set type. In the case that a value could match multiple types, the schema of the first matching type will be used.

To maintain backward compatibility, if unsupported schema types are used, the value will always pass validation. A doing it wrong notice is issued in this case.

Fixes #50300.
Props pentatonicfunk, dlh, TimothyBlynJacobs.


git-svn-id: https://develop.svn.wordpress.org/trunk@48306 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-05 00:13:37 +00:00
Timothy Jacobs fe2ceeada4 REST API: Only validate the format keyword if the type is a string.
This allows for using multi-type support with a string that has a format. For backwards compatibility support, the format validation will still apply if the type is not specified, or it is invalid.

Two new doing it wrong notices are issued when omitting a type, or using an invalid type.

Props ryotsun.
Fixes #50189.


git-svn-id: https://develop.svn.wordpress.org/trunk@48300 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-04 19:51:10 +00:00
Timothy Jacobs d241ab3b55 Script Loader: Add id attributes to script assets.
This commit adds a unique ID attribute to script loader generated <script> tags as well as related <script> tags for inline JavaScript, translations, or parameters.

This is a first step in adding support for lazy loading scripts and styles, but for now is only used to assist in debugging generated output.

Props dd32, spacedmonkey.
See #48654.


git-svn-id: https://develop.svn.wordpress.org/trunk@48295 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-04 16:52:49 +00:00
Timothy Jacobs e51a554f5d REST API: Introduce endpoint for editing images.
To facilitate inline image editing in Gutenberg, a new endpoint at wp/v2/media/<id>/edit has been introduced. This is functionally similar to the existing ajax image editor, however the REST API editor creates a new attachment record instead of updating an existing attachment.

Fixes #44405.
Props ajlende, ellatrix, spacedmonkey, azaozz.



git-svn-id: https://develop.svn.wordpress.org/trunk@48291 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-04 04:13:17 +00:00
Sergey Biryukov 3785439c8b Tests: Further fix some issues with indeterminate sort ordering in `Tests_List_Pages`:
* Make sure `test_wp_list_pages_number()` sorts by ID, as there are several pages with the same title.
* Limit `test_wp_list_pages_sort_column()` to one level, as the child page fixtures don't have an author and cannot be reliably sorted by `post_author`.

Follow-up to [48157].

Props afercia.
See #50466.

git-svn-id: https://develop.svn.wordpress.org/trunk@48280 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 18:21:43 +00:00
Greg Ziółkowski 3439a14e57 Editor: Move core blocks registration to init hook
After working on support for register_block_type_args filter in #49615, it became clear that we need to use init action for core blocks to make it possible to use this filter.

Fixes #50263.



git-svn-id: https://develop.svn.wordpress.org/trunk@48279 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 17:20:28 +00:00
Sergey Biryukov c5e620f6ef Docs: Spell "falsey" in a consistent way.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48275 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 11:28:13 +00:00
Timothy Jacobs 6cc0063ba6 REST API: Link to the REST route for the currently queried resource.
This allows for programatically determining the REST version of the current page. The links also aid human discovery of the REST API in general.

Props dshanske, tfrommen, TimothyBlynJacobs.
Fixes #49116.


git-svn-id: https://develop.svn.wordpress.org/trunk@48273 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 05:55:04 +00:00
Felix Arntz 284b92b122 Media: Improve support for opting out of lazy-loading for template images.
With this changeset, in addition to the already present `wp_lazy_loading_enabled` filter, developers can now opt out of lazy-loading template images via `wp_get_attachment_image()` by passing a `loading` attribute with boolean value `false`. This can be used e.g. by theme developers on images which are very likely to be in the initial viewport.

This changeset also improves related test coverage.

Props adamsilverstein, azaozz, joemcgill, johnbillion.
See #50425, #44427.


git-svn-id: https://develop.svn.wordpress.org/trunk@48272 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-02 02:01:28 +00:00
Greg Ziółkowski a425f15dd7 Editor: Support filtering arguments in block type registration
Adds possibility to filter the settings of a block type during its registration.

Props aduth, azaozz.
Fixes #49615.



git-svn-id: https://develop.svn.wordpress.org/trunk@48263 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-01 13:08:11 +00:00
Timothy Jacobs b2cc1dfd70 REST API: Introduce plugin management and block directory endpoints.
These endpoints facilitate the Block Directory Inserter feature in Gutenberg. Users can now install, activate, deactivate, and delete plugins over the REST API. The block directoryendpoint allows searching for available blocks from the WordPress.org block directory.

Props cklee, talldanwp, noisysocks, joen, soean, youknowriad, dufresnesteven, gziolo, dd32, tellyworth, ryelle, spacedmonkey, TimothyBlynJacobs.
Fixes #50321.



git-svn-id: https://develop.svn.wordpress.org/trunk@48242 602fd350-edb4-49c9-b593-d223f7449a82
2020-07-01 04:22:25 +00:00
Felix Arntz 9ab408d9f6 Media: Only add `loading` attribute to `img` tags using double quotes.
Props azaozz.
Fixes #50367.


git-svn-id: https://develop.svn.wordpress.org/trunk@48239 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 20:32:44 +00:00
Felix Arntz d8af0369e3 Media: Introduce `wp_img_tag_add_width_and_height_attr()` to add dimension attributes to images.
Following up on [48170], this changeset moves the new logic to add missing `img` dimension attributes into a separate function that is run first within `wp_filter_content_tags()`. It also adds a utility function `wp_image_src_get_dimensions()` with logic reused from `wp_image_add_srcset_and_sizes()`, and it ensures that `width` and `height` attributes only get added if both of the attributes are missing on the original `img` tag.

This changeset furthermore improves test coverage and separates tests for the different aspects of `img` tag modification.

Props azaozz.
Fixes #50367. See #44427.


git-svn-id: https://develop.svn.wordpress.org/trunk@48237 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 19:28:07 +00:00
Andrea Fercia e85b141183 Fix Privacy tests after [48234].
See #50335.


git-svn-id: https://develop.svn.wordpress.org/trunk@48236 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 14:20:37 +00:00
Sergey Biryukov 90e840f9db Comments: Make `wp_update_comment()` return `false` instead of 0 for an invalid comment or post ID.
This addresses an inconsistency where 0 could mean one of the three scenarios:

* Invalid comment ID.
* Invalid comment post ID.
* No DB rows updated. This is not an error and should not be treated as one.

With this change, `wp_update_comment()` always returns either `false` or a `WP_Error` object on failure, depending on the value of the `$wp_error` parameter.

Follow-up to [48154], [48215], [48216], [48218], [48230].

Props dd32, jnylen0, enrico.sorcinelli.
Fixes #39732. See #38700, #39735.

git-svn-id: https://develop.svn.wordpress.org/trunk@48235 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 14:11:00 +00:00
Sergey Biryukov cc4767cec0 Tests: Place `remove_filter()` calls for `_wp_update_comment_data_filter()` before the assertions, for consistency with other tests.
Follow-up to [48154], [48222].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48231 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 12:27:05 +00:00
Sergey Biryukov 3e1f66bb2e Coding Standards: Add missing visibility keywords to `Tests_Comment` methods.
See #49542.

git-svn-id: https://develop.svn.wordpress.org/trunk@48229 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 11:38:40 +00:00
Sergey Biryukov 7653810aa2 Tests: Remove unnecessary i18n from `_wp_update_comment_data_filter()`.
Follow-up to [48154], [48217].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48228 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 11:34:58 +00:00
Greg Ziółkowski 910de8f689 Editor: Introduce block context
Backports a new block context feature from Gutenberg. The purpose of this feature is to be able to establish values in a block hierarchy which can be consumed by blocks anywhere lower in the same hierarchy. These values can be established either by the framework, or by other blocks which provide these values. See documentation: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-context.md

Props aduth, epiqueras.
Fixes #49927.



git-svn-id: https://develop.svn.wordpress.org/trunk@48224 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 11:02:22 +00:00
Sergey Biryukov 5d0b2a7510 Tests: Remove unnecessary `tearDown()` method in `Tests_Ajax_EditComment`.
Restoring the hook-related globals to their state at `setUp()` is addressed by `WP_UnitTestCase_Base::_restore_hooks()`.

Follow-up to [48154].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48222 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 00:58:07 +00:00
Sergey Biryukov 43977e7689 Docs: Remove `@return void` from some tests, per the documentation standards.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48221 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 00:41:57 +00:00
Sergey Biryukov 6dca33c0b1 Docs: Improve documentation for Ajax comment tests per the documentation standards.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48220 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-30 00:41:30 +00:00
Sergey Biryukov 8b31484919 Tests: Remove unnecessary i18n from `_wp_update_comment_data_filter()`.
Follow-up to [48154].

See #39732.

git-svn-id: https://develop.svn.wordpress.org/trunk@48217 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-29 23:07:09 +00:00
Sergey Biryukov 6a3d4fe520 Customize: Do not allow changesets to be deleted when someone is editing them.
This makes the behavior consistent with that of locked posts, which can't be deleted via the list tables when another user is editing them.

Props dlh.
Fixes #50501.

git-svn-id: https://develop.svn.wordpress.org/trunk@48211 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-29 10:31:12 +00:00
Sergey Biryukov 9f053c58fe Themes: Add a return value to theme functions calling `locate_template()`:
* `get_header()`
* `get_footer()`
* `get_sidebar()`
* `get_template_part()`

These functions now return false if the template file could not be found, to allow for easier debugging.

Props tferry, sphakka, johnbillion, pento, davidbinda, desrosj, birgire, garrett-eclipse, williampatton, davidbaumwald, SergeyBiryukov.
Fixes #40969.

git-svn-id: https://develop.svn.wordpress.org/trunk@48209 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 23:08:57 +00:00
Sergey Biryukov e5e4f0d977 Bootstrap/Load: Make sure `add_magic_quotes()` does not inappropriately recast non-string data types to string.
Props donmhico, jrf, Veraxus, Rarst.
Fixes #48605.

git-svn-id: https://develop.svn.wordpress.org/trunk@48205 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 21:02:18 +00:00
Sergey Biryukov 8d358ca4c7 Docs: Capitalize "ID", when referring to a user ID, term ID, etc. in a more consistent way.
Follow-up to [48104]

See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48200 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 14:07:53 +00:00
Sergey Biryukov b72fcb6a47 Tests: Adjust the test for invalid username in `WP_Test_REST_Users_Controller` to match the new string.
Follow-up to [48195].

See #47003.

git-svn-id: https://develop.svn.wordpress.org/trunk@48196 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-28 07:49:29 +00:00
Sergey Biryukov 506fab2814 Docs: Remove extra spaces from `@ticket` tag in unit tests.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48190 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-27 12:01:30 +00:00
Ella van Durpe 24465974cd Editor: update JavaScript packages
Also update default block categories

Props youknowriad, gziolo, aduth.
Fixes #50420, #50278.



git-svn-id: https://develop.svn.wordpress.org/trunk@48177 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-26 13:31:11 +00:00
Sergey Biryukov 7ce1ba7f98 Tests: Reformat `test_wp_list_pages_discarded_whitespace()` for better readability.
See #50466, #49542.

git-svn-id: https://develop.svn.wordpress.org/trunk@48176 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-26 12:07:52 +00:00
Timothy Jacobs 5b90ea41b5 REST API: Introduce Block Types endpoint.
This endpoint allows a user to retrieve the block type definition for all server-side registered block types.

Props spacedmonkey, aduth, gziolo, ocean90, TimothyBlynJacobs.
Fixes #47620.


git-svn-id: https://develop.svn.wordpress.org/trunk@48173 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-26 00:44:44 +00:00
Timothy Jacobs 9a604011ee Themes: Introduce register_theme_feature API.
Currently themes can declare support for a given feature by using add_theme_support(). This commit adds a register_theme_feature() API that allows plugins and WordPress Core to declare a list of available features that themes can support.

The REST API uses this to expose a theme's supported features if the feature has been registered with "show_in_rest" set to true.

Props kadamwhite, spacedmonkey, williampatton, desrosj, TimothyBlynJacobs.
Fixes #49406.


git-svn-id: https://develop.svn.wordpress.org/trunk@48171 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 22:11:09 +00:00
Felix Arntz 9568134d7b Media: Ensure images have dimensions to reduce layout shift and facilitate lazy-loading.
This changeset ensures that attachment images which are inserted without `width` and `height` attributes still receive them in the frontend, to reduce cumulative layout shift. Adding the dimensions happens as part of the logic for adding `srcset` and `sizes` attributes, which already assume the specific width and height of the respective image.

Images are now only lazy-loaded if they have `width` and `height` attributes present. While missing these attributes itself is what causes layout shifts, lazy-loading such images can make this problem more apparent to the user.

Props adamsilverstein, westonruter.
Fixes #50367. See #44427.


git-svn-id: https://develop.svn.wordpress.org/trunk@48170 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 18:43:25 +00:00
Sergey Biryukov de36eb3326 Canonical: Move trailing slash handling for `robots.txt` and sitemaps to a single condition.
Give the unit test a more descriptive name.

Follow-up to [48153], [48155].

See #48025.

git-svn-id: https://develop.svn.wordpress.org/trunk@48166 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 11:39:23 +00:00
Sergey Biryukov 72c7f2c41c Administration: Correct and simplify the logic for `asc` and `desc` arguments in `WP_List_Table::get_sortable_columns()`.
Setting the initial order didn't work as expected due to reversed logic.

Follow-up to [48151].

See #45089.

git-svn-id: https://develop.svn.wordpress.org/trunk@48165 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 11:33:23 +00:00
Greg Ziółkowski 92585e8df1 Editor: Introduce WP_Block and WP_Block_List classes
Backports functionality added in Gutenberg in the following PRs:
- https://github.com/WordPress/gutenberg/pull/21467
- https://github.com/WordPress/gutenberg/pull/21925
It's a few ideas related to block rendering and the provided block value, which is particularly impactful for work around block context.

Props aduth, TimothyBJacobs, noisysocks, epiqueras, youknowriad, talldanwp, zebulan.
Fixes #49926.



git-svn-id: https://develop.svn.wordpress.org/trunk@48159 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-25 05:14:43 +00:00
Sergey Biryukov 07e3dda9ba Tests: Add a post author to "Parent 1" page fixture in `tests/post/listPages.php`.
This avoids indeterminate ordering in `test_wp_list_pages_sort_column()`.

Fixes #50466.

git-svn-id: https://develop.svn.wordpress.org/trunk@48157 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-24 15:00:43 +00:00
Jake Spurlock 6dba36e4ef Canonical: Add tests for trailing slashes for robots.txt.
See #48025.

Props Toro_Unit, joostdevalk, SergeyBiryukov.


git-svn-id: https://develop.svn.wordpress.org/trunk@48155 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-24 00:05:21 +00:00
Jake Spurlock ec062c08fe Comments: Allow `wp_update_comment()` to return `WP_Error()`.
The `wp_update_comment_data` filter introduced in 4.7 allows comment data to be filtered before it is updated in the database.

The patch aims to handle `WP_Error` as the filter above return value in a similar manner as is done for `wp_new_comment()`.


Fixes #39732.

Props: enricosorcinelli, swissspidy, gkloveweb, jnylen0, jbpaul17, afercia, SergeyBiryukov, audrasjb, imath, davidbaumwald.


git-svn-id: https://develop.svn.wordpress.org/trunk@48154 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-24 00:03:33 +00:00
Jake Spurlock 95b9933e64 Administration: Update `WP_List_Table::get_sortable_columns()` to support `asc` and `desc` arguments.
This makes the API a little more clear, whereas setting `false` used to mean `asc` and `true` meant `desc`, you can now use those directly, while maintaining back-compat.

Fixes #45089.

Props Tkama, SergeyBiryukov, shital-patel, desrosj, birgire, davidbaumwald. 



git-svn-id: https://develop.svn.wordpress.org/trunk@48151 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 23:13:35 +00:00
Greg Ziółkowski 5f6ab44340 Editor: Introduce new API method that register block from `block.json` metadata file
Backports changes added to Gutenberg in:
- https://github.com/WordPress/gutenberg/pull/20794
- https://github.com/WordPress/gutenberg/pull/22519
`register_block_type_from_metadata` function is going to be used to register all blocks on the server using `block.json` metadata files.

Props ocean90, azaozz, aduth, mcsf, jorgefilipecosta, spacedmonkey, nosolosw, swissspidy and noahtallen.
Fixes #50263.



git-svn-id: https://develop.svn.wordpress.org/trunk@48141 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 15:43:19 +00:00
Sergey Biryukov 0a301ec4b5 Docs: Use sentence case for comments in `tests/kses.php`, per the documentation standards.
Follow-up to [48132].

See #49464, #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48139 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 11:09:04 +00:00
Jake Spurlock 8368cc2b44 Embeds: Ensure that classic embed support works in the block editor.
See https://github.com/WordPress/gutenberg/pull/6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. 
 


git-svn-id: https://develop.svn.wordpress.org/trunk@48135 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 06:06:11 +00:00
Jake Spurlock 7b08983ce4 Comments: Ensure the proper comment count and pages for unapproved comments.
Previiously, unapproved comments can alter the comment count, returning incorrect page numbers.

Fixes #8973.

Props GregMulhauser, dd32, ryan, mrmist, hakre, solarissmoke, billerickson, ericlewis, SergeyBiryukov, chriscct7, dossy, lukecavanagh, renggo888, jdorner, matjack1, pento, audrasjb, imath, davidbaumwald, whyisjake.  



git-svn-id: https://develop.svn.wordpress.org/trunk@48133 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 05:22:39 +00:00
Jake Spurlock 888421a924 Formatting: Extend `wp_kses_hair` and `wp_kses_hair_parse` to allow digits and underscores.
Fixes a lot of issues around parsing XML/HTML attributes.

Fixes #49464.

See #34406, #48608.

Props codeforest, zodiac1978, johnpgreen, dlh, ayeshrajans, johnpgreen, rilwis, travisnorthcutt, miqrogroove, chriscct7, whyisjake.


git-svn-id: https://develop.svn.wordpress.org/trunk@48132 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-23 05:05:57 +00:00
Jake Spurlock 800cfa8a82 Privacy: Use relative paths for exported personal data.
Ensures back-compat while moving to paths off of the /exports directory.

Fixes: #44038.

Props: allendav, mrTall, desrosj, garrett-eclipse, cameronamcintyre, nmenescardi, xkon, whyisjake, davidbaumwald.


git-svn-id: https://develop.svn.wordpress.org/trunk@48127 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 22:38:11 +00:00
Jonathan Desrosiers 517c27e297 Docs: Small inline documentation corrections following [48121].
Also, remove the `version` argument from the `wp.deprecated()` call in `password-strength-meter.js`. This argument is for specifying the version a feature will be removed, not when the feature was removed.

Props hareesh-pillai.
Fixes #50413.

git-svn-id: https://develop.svn.wordpress.org/trunk@48124 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 19:07:57 +00:00
Jonathan Desrosiers e26394bb2d General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”

With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).

Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.

Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.

Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.

git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 17:24:34 +00:00
Greg Ziółkowski 9b2b8cad20 Editor: Remove default "layout" block attribute from WP_Block_Type::get_attributes
The merging behavior which assigns the `layout` attribute in `WP_Block_Type` gets removed.

Props aduth, TimothyBlynJacobs.
Fixes #50257.



git-svn-id: https://develop.svn.wordpress.org/trunk@48118 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 12:20:20 +00:00
Greg Ziółkowski 699c8557f9 Blocks: Add context fields to WP_Block_Type
New block context related fields were added as part of https://github.com/WordPress/gutenberg/pull/22686. This changest backports them to WP_Block_Type class.

Props aduth, spacedmonkey, mcsf, epiqueras.
Fixes #47656.  



git-svn-id: https://develop.svn.wordpress.org/trunk@48117 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 10:24:42 +00:00
Andrea Fercia 98d22d5d3d I18N: Restore the "Error:" prefix for error messages.
Partially reverts [48059] as there's no full consensus on the removal of the text prefix. Further actions should be taken to improve consistency and accessibility of the admin notices. Keeps some improvements to the translatable strings from [48059].

Fixes #47656.


git-svn-id: https://develop.svn.wordpress.org/trunk@48115 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-21 13:58:46 +00:00
Sergey Biryukov e8176a19e2 Posts, Post Types: Avoid a PHP warning when `get_the_content()` is called outside of the loop.
This ensures that `$pages` and other globals are only used after they have been set up in `setup_postdata()`.

Follow-up to [44941].

Props tessawatkinsllc, dontdream, spacedmonkey, squarecandy, davidbaumwald, SergeyBiryukov.
Fixes #47824. See #42814.

git-svn-id: https://develop.svn.wordpress.org/trunk@48114 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-21 10:34:35 +00:00
Sergey Biryukov a7264f196d Posts, Post Types: Simplify `test_setup_postdata_loop()`.
The important part here is calling `the_content()` after setting up post data for another post without updating global `$post`.

The `foreach()` loop is not necessary.

Follow-up to [UT1289].

See #47824, #24330.

git-svn-id: https://develop.svn.wordpress.org/trunk@48113 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-21 10:28:52 +00:00
Sergey Biryukov c682da9190 Docs: Use a hyphen with the "non" prefix in a more consistent way.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48106 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-20 12:13:58 +00:00
John Blackbourn 1db25e3d38 Docs: Remove unnecessary variables names from `@return` tags.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@48100 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-19 22:53:54 +00:00
Adam Silverstein a1fd329682 Formatting: new filter `safecss_filter_attr_allow_css` on css parts.
Enables developers to determine whether a section of CSS should be allowed or discarded. By default, the value will be false if the part contains \ ( & } = or comments. Returning true allows the CSS part to be included in the output.

Replaces the `safe_style_disallowed_chars` filter introduced in r47891.

Props azaozz.
Fixes #37134.



git-svn-id: https://develop.svn.wordpress.org/trunk@48086 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-18 20:59:43 +00:00
Pascal Birchler b58973554d Sitemaps: Add XML sitemaps functionality to WordPress.
While web crawlers are able to discover pages from links within the site and from other sites, XML sitemaps supplement this approach by allowing crawlers to quickly and comprehensively identify all URLs included in the sitemap and learn other signals about those URLs using the associated metadata.

See https://make.wordpress.org/core/2020/06/10/merge-announcement-extensible-core-sitemaps/ for more details.

This feature exposes the sitemap index via `/wp-sitemap.xml` and exposes a variety of new filters and hooks for developers to modify the behavior. Users can disable sitemaps completely by turning off search engine visibility in WordPress admin.

This change also introduces a new `esc_xml()` function to escape strings for output in XML, as well as XML support to `wp_kses_normalize_entities()`.

Props Adrian McShane, afragen, adamsilverstein, casiepa, flixos90, garrett-eclipse, joemcgill, kburgoine, kraftbj, milana_cap, pacifika, pbiron, pfefferle, Ruxandra Gradina, swissspidy, szepeviktor, tangrufus, tweetythierry.
Fixes #50117.
See #3670. See #19998.


git-svn-id: https://develop.svn.wordpress.org/trunk@48072 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-17 15:22:49 +00:00
TimothyBlynJacobs 2b42ac5a12 REST API: Only register one block renderer route.
Every block has a different set of attributes. These attributes are specified as a JSON Schema object. Previously, every block registered its own block renderer route using its attributes for the schema. This allowed for the attributes to be validated using the built in endpoint validation rules. It had the unfortunate side effect, however, of creating a large number of nearly identical REST API routes, one for each dynamic block. Each registered route has a performance impact. As the number of server side blocks goes up, this becomes more and more of an issue.

Now, we register a single block renderer route and dynamically validate the attributes based on the selected block.

Fixes #48079.
Props gziolo, TimothyBlynJacobs.


git-svn-id: https://develop.svn.wordpress.org/trunk@48069 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-17 03:20:02 +00:00
Jake Spurlock d17a57a945 Themes: Add additional later escaping to `post_class()` and `body_class()` functions.
Additionally, this adds a few tests to test output.

Fixes #20009.

Props mfields, scribu, azaozz, obenland, dd32, nacin, jrf, jdgrimes, garyj, whyisjake. 
 


git-svn-id: https://develop.svn.wordpress.org/trunk@48060 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-16 16:55:45 +00:00
Andrea Fercia 50ece6d31c I18N: Remove the "Error:" prefix from error messages.
For a number of years, most of the WordPress error messages have been prefixed with "Error:". However, these messages appear in a context where it's already clear an error occurred. Whether it's an error, a warning, or any other classification, that's not so relevant for users. The content of the message is the relevant part. The "Error:" prefix doesn't add great value while it does add unnecessary complexity for the message readability.

Also, revises some of these messages to improve clarity and removes HTML from translatable strings.

Props garrett-eclipse, ramiy, SergeyBiryukov, afercia, sabernhardt, quadthemes, audrasjb. 
See #47003, #43037, #42945, #15887.
Fixes #47656.


git-svn-id: https://develop.svn.wordpress.org/trunk@48059 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-16 15:33:37 +00:00
Jonathan Desrosiers 6334056f65 Build/Test Tools: Prevent double `/`s when including PHPMailer files.
`ABSPATH` includes a trailing slash already.

Follow up of [48033].
Props desrosj.
See #50377, #41750.

git-svn-id: https://develop.svn.wordpress.org/trunk@48058 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-16 13:57:05 +00:00
Jonathan Desrosiers dfcbff2db0 Emoji: Upgrade Twemoji to version 13.0.0.
🥸

Props kraftbj, desrosj, otto42.
Fixes #50148.

git-svn-id: https://develop.svn.wordpress.org/trunk@48048 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-15 18:02:14 +00:00
Sergey Biryukov d9c53241dc Networks and Sites: Don't unnecessarily switch to the current blog in `get_blog_details()`.
Props arpitgshah, djennez, acsnaterse, joostdevalk, SergeyBiryukov.
Fixes #50391.

git-svn-id: https://develop.svn.wordpress.org/trunk@48044 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-15 12:29:13 +00:00
Sergey Biryukov eb06a59f53 Posts, Post Types: Introduce `default_category_post_types` filter.
The filter allows custom post types associated with the `category` taxonomy to opt in to requiring a default category, same as regular posts.

Props enrico.sorcinelli.
Fixes #43516.

git-svn-id: https://develop.svn.wordpress.org/trunk@48043 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-14 21:40:10 +00:00
Jonathan Desrosiers 0933882c6e External Libraries: Upgrade PHPMailer to version 6.1.6.
Now that WordPress Core supports PHP >= 5.6, the PHPMailer library can be updated to the latest version.

The PHPMailer files now reside in a new directory, `wp-includes/PHPMailer`. These files are copied verbatim from the library upstream and will make updating in the future easier. For backwards compatibility, the old files will remain and trigger deprecated file warnings.

The PHPMailer class is also now under the `PHPMailer\PHPMailer\PHPMailer` namespace. The `PHPMailer` class in the global namespace has been aliased for a seamless transition.

This upgrade also clears up a handful of PHP compatibility issues detailed in #49922.

For a full list of changes, see the PHPMailer GitHub: https://github.com/PHPMailer/PHPMailer/compare/v5.2.27...v6.1.6.

Props Synchro, SergeyBiryukov, desrosj, donmhico, ayeshrajans.
Fixes #41750.

git-svn-id: https://develop.svn.wordpress.org/trunk@48033 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-12 15:45:30 +00:00
Jake Spurlock 2efbc51712 Editor: Ensure latest comments can only be viewed from public posts.
Props: poena, xknown. 


git-svn-id: https://develop.svn.wordpress.org/trunk@47984 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-10 19:18:50 +00:00
Jake Spurlock fe83aca573 Embeds: Ensure that the title attribute is set correctly on embeds.
Props xknown.


git-svn-id: https://develop.svn.wordpress.org/trunk@47947 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-10 16:34:18 +00:00
Timothy Jacobs ddf897db05 REST API: Fix updating "multiple" meta keys with non-string values.
Previously, the REST API would end up deleting each row of metadata and recreating it unnecessarily. This was caused by a type mismatch where the metadata API would always return a string value, and the REST API operated on a typed value.

The REST API now applies the same sanitization and type casting for "multiple" meta keys and "single" meta keys.

Fixes #49339.
Props renathoc.


git-svn-id: https://develop.svn.wordpress.org/trunk@47943 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-10 02:20:18 +00:00
Jonathan Desrosiers 45e9cb7066 Coding Standards: Cleans up some PHPCS issues introduced in [47938].
See #20875.

git-svn-id: https://develop.svn.wordpress.org/trunk@47942 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-09 22:40:50 +00:00
Jake Spurlock d4d78e4ae7 Cache API: Introduce `wp_cache_get_multi()`.
Many caching backend have support for multiple gets in a single request. This brings that support to core, with a compatability fallback that will loop over requests if needed.

Fixes: #20875.
Props: nacin, tollmanz, wonderboymusic, ryan, jeremyfelt, spacedmonkey, boonebgorges, dd32, rmccue, ocean90, jipmoors, johnjamesjacoby, tillkruess, donmhico, davidbaumwald, SergeyBiryukov, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@47938 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-09 19:45:27 +00:00
Sergey Biryukov 65f22692bb Networks and Sites: Ensure the site ID in `wp_insert_site()` is still correct after calling `clean_blog_cache()`.
By saving `$wpdb->insert_id` to a variable, we make sure the ID does not change if another database insert is performed on the `clean_site_cache` action.

Props trepmal.
Fixes #50324.

git-svn-id: https://develop.svn.wordpress.org/trunk@47932 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-09 12:39:09 +00:00
Timothy Jacobs f5dde31290 REST API: Support the (min|max)Items JSON Schema keywords.
A future commit will add support for the uniqueItems keyword.

Props sorenbronsted.
See #48821.


git-svn-id: https://develop.svn.wordpress.org/trunk@47923 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-07 22:40:16 +00:00
Timothy Jacobs 4fb1e58c50 REST API: Add additional fields to the themes controller.
When the themes controller was introduced it only returned a theme's supported features. This adds the majority of a theme's header information to the response.

Props ockham, spacedmonkey.
Fixes #49906.


git-svn-id: https://develop.svn.wordpress.org/trunk@47921 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-07 06:44:08 +00:00
Sergey Biryukov d4d709856b Docs: Update the DocBlock for the `wp_media_attach_action` hook per the documentation standards.
Rename the `$att_id` variable to `$attachment_id` for clarity.

Follow-up to [47909].

See #49614.

git-svn-id: https://develop.svn.wordpress.org/trunk@47913 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-05 08:28:42 +00:00
Jake Spurlock e756de59e5 REST API: Ensure that all properties of `get_endpoint_args_for_item_schema` are listed.
* Add new var $valid_schema_properties to match rest_validate_value_from_schema()
* Unit test to ensure all valid properties exists, and non-valid properties are ignored

Fixes: #50301.
Props: pentatonicfunk, TimothyBlynJacobs.



git-svn-id: https://develop.svn.wordpress.org/trunk@47911 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-04 16:41:47 +00:00
Aaron Jorbin 42efaab548 Build/Test: Die with an error if populate_network fails
If you are missing WP_TESTS_EMAIL, populate_network will fail and it can be hard to debug. As populate_network can return a wp_error object, we can detect that and display the error to a user.

See: https://github.com/WordPress/gutenberg/pull/22613
Fixes: #50251
Props: TimothyBlynJacobs


git-svn-id: https://develop.svn.wordpress.org/trunk@47904 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-03 21:02:42 +00:00
Adam Silverstein fa96d59318 Formatting: add a new 'safe_style_disallowed_chars' filter.
Enable developers to change the regex used in `safecss_filter_attr` to limit characters in the parsed CSS.

Props paulschreiber, swissspidy, rmccue, bartekcholewa, miinasikk.
Fixes #37134.



git-svn-id: https://develop.svn.wordpress.org/trunk@47891 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-02 23:44:40 +00:00
Dominik Schilling 2fed7bf581 Build/Test Tools: Avoid an empty "title" heading if no title is set in `_wp_die_handler_exit()` and `_wp_die_handler_txt()`.
Fixes #50297.

git-svn-id: https://develop.svn.wordpress.org/trunk@47882 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-01 20:48:27 +00:00
Dominik Schilling 178eeaf57e Build/Test Tools: Let `WP_UnitTestCase_Base` extend the namespaced version of PHPUnit's test case class.
With the minimum PHP version requirement set to 5.6 we're now able to use namespaces by default. This replaces `PHPUnit_Framework_TestCase` with `PHPUnit\Framework\TestCase` for `WP_UnitTestCase_Base` to solve autocompletion issues with code editors when using more recent PHPUnit versions. `PHPUnit\Framework\TestCase` is available since PHPUnit 5.4 and now the minimum required PHPUnit version.

Fixes #50236.

git-svn-id: https://develop.svn.wordpress.org/trunk@47880 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-01 19:41:50 +00:00
Jake Spurlock 0ad7471880 Canonical: Add the ability to disable `redirect_guess_404_permalink()`.
This also adds a few more filters to make adding redirects easier. Notably:

1. `do_redirect_guess_404_permalink`
2. `pre_redirect_guess_404_permalink`
3. `strict_redirect_guess_404_permalink`

Fixes: #16557.
Props: msafi, nacin, simonwheatley, westi, mboynes, joostdevalk, Lex_Robinson, MikeSchinkel, haukep, paulschreiber, DrewAPicture, ravenswd, esemlabel, stevegibson12, martychc23, DrLightman, jivanpal, neonkowy, laternastudio, apedog, audrasjb, davidbaumwald, Confridin, donmhico, ryotsun. 



git-svn-id: https://develop.svn.wordpress.org/trunk@47878 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-01 18:47:41 +00:00
Dominik Schilling 028299ac79 Editor: Fix code style for constructor arguments added in [47875].
Also revert unintended changes to `WP_Block_Type::__construct()` DocBlock.

See #48529.

git-svn-id: https://develop.svn.wordpress.org/trunk@47876 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-01 16:25:18 +00:00
Greg Ziółkowski 822ca9ebc7 Add fields to WP_Block_Type
As part of #47620 and the RFC for block registeration. Server registered blocks are missing some fields. These changeset includes them.

Props spacedmonkey, aduth.

Fixes #48529.



git-svn-id: https://develop.svn.wordpress.org/trunk@47875 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-01 12:25:34 +00:00
Jake Spurlock 38744d8bd2 Code Standards: Clean up whitespace on the end of a file.
See: #45163.
Props: whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@47866 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-29 23:34:00 +00:00
Jake Spurlock 7b13f5abd8 Taxonomy: Extend `get_term_by` to accept `ID` as a term parameter.
Similar to `get_user_by`, both `ID` and `id` should be able to accepted.

Fixes #45163.
Props emrikol, esoj.
 


git-svn-id: https://develop.svn.wordpress.org/trunk@47865 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-29 22:41:25 +00:00
Dominik Schilling f37a28858d Role/Capability: Use meta caps `edit_post`, `read_post`, and `delete_post` directly.
Rather than consulting the post type object, let `map_meta_cap()` handle that for us.

Props peterwilsoncc, ocean90.
Fixes #50128.
See #23226.

git-svn-id: https://develop.svn.wordpress.org/trunk@47850 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-23 15:22:53 +00:00
Dominik Schilling 584df2a169 Rest API: Ensure `rest_ensure_response()` upgrades `WP_HTTP_Response` to `WP_REST_Response`.
An instance of `WP_HTTP_Response` doesn't ensure that the required methods used in `WP_REST_Server::dispatch()` exist, currently causing a fatal error.

Props ali11007, TimothyBlynJacobs, ocean90.
Fixes #49495.

git-svn-id: https://develop.svn.wordpress.org/trunk@47849 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-23 14:34:38 +00:00
Jake Spurlock 3ab28fd579 REST API: Ensure proper namespacing when registering routes.
The PR will corerce routes that have a leading slash and throwing a `_doing_it_wrong` notice while ensuring a proper namespace.

Fixes #49749.
Props TimothyBlynJacobs, skarabeq, afercia.



git-svn-id: https://develop.svn.wordpress.org/trunk@47842 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-22 20:46:03 +00:00
Peter Wilson 09a6234ed3 KSES: Support the `video` element's `playsinline` attribute.
Allow users without the `unfiltered_html` capability to use the `playsinline` attribute when embedding videos.

Additionally this adds unit tests for passing the video element through kses.

Fixes #50167. See #29826.


git-svn-id: https://develop.svn.wordpress.org/trunk@47837 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-21 04:52:33 +00:00
Timothy Jacobs d8a063eabb REST API: Support the JSON Schema pattern keyword.
Props jason_the_adams, birgire, sorenbronsted.
Fixes #44949.


git-svn-id: https://develop.svn.wordpress.org/trunk@47810 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-16 19:01:49 +00:00
Timothy Jacobs 8b9823f536 REST API: Check required properties are provided when validating an object.
Previously, the WP_REST_Request object validated that top-level properties were defined, but this did not extend to those object's required properties. This adds validation to rest_validate_value_from_schema() directly.

Both the v3 and v4 JSON Schema syntax for required properties is supported.

Props sorenbronsted.
Fixes #48818.


git-svn-id: https://develop.svn.wordpress.org/trunk@47809 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-16 18:41:41 +00:00
Sergey Biryukov 06dbf33561 Tests: Give canonical test fixtures for paginated content more descriptive names.
Follow-up to [47727].

See #28081, #40773, #45337.

git-svn-id: https://develop.svn.wordpress.org/trunk@47781 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-10 20:29:18 +00:00
Sergey Biryukov c395d6fcd9 Coding Standards: Rename some files and classes in `phpunit/tests/functions/` per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

See #49542.

git-svn-id: https://develop.svn.wordpress.org/trunk@47780 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-10 12:07:49 +00:00
Peter Wilson c860753778 Tests: Add unit tests for `_cleanup_header_comment()`.
Props pbearne.
Fixes #38101. See #8497.


git-svn-id: https://develop.svn.wordpress.org/trunk@47779 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-10 05:21:48 +00:00
Sergey Biryukov efb6e805da Administration: Avoid a PHP 7.4 notice in `add_meta_box()` when attempting to re-add a previously removed box.
The logic for skipping previously removed meta boxes with the `core` priority should also apply to the `sorted` priority that is used when the boxes were manually reordered.

Add a unit test.

Props coolmann, franzarmas, SergeyBiryukov.
Fixes #50019.

git-svn-id: https://develop.svn.wordpress.org/trunk@47777 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-09 12:24:31 +00:00
Sergey Biryukov de14ea86bf Canonical: Redirect paged requests for a static page assigned as the "Posts page".
This avoids displaying duplicate content of the home page under different URLs with appended page numbers.

This change only affects the `<!--nextpage-->` pagination (`page` query variable) and not the regular multiple posts pagination (`paged` query variable).

The posts page does not support the `<!--nextpage-->` pagination, so requests for invalid page numbers should be redirected to the page permalink, applying the logic previously implemented for single posts or pages.

Follow-up to [34492], [47727].

Props jeremyfelt, sachit.tandukar, SergeyBiryukov.
Fixes #45337. See #40773, #28081, #11694.

git-svn-id: https://develop.svn.wordpress.org/trunk@47760 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-04 10:40:06 +00:00
Timothy Jacobs 8153d15f09 REST API: Support more JSON Schemas when filtering a response by context.
The array type, multi-types, and the additional properties keyword are now supported. Additionally, the filter recurses to an infinite depth.

Fixes #48819.


git-svn-id: https://develop.svn.wordpress.org/trunk@47758 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-04 02:44:44 +00:00
Timothy Jacobs 9a903f7e73 Tests: Update wp-api-generated.js.
[47755] and [47756] caused a schema change, so the wp-api-generated.js file needs to be updated.


git-svn-id: https://develop.svn.wordpress.org/trunk@47757 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-04 00:26:52 +00:00
Timothy Jacobs 5460e0df1e REST API: Accept POST requests in the block renderer endpoint.
Rendering a block is idempotent, so a GET is the most natural request method. However, the maximum length of URLs prevented blocks with large attributes from being rendered.

Props ryankienstra.
Fixes #49680.


git-svn-id: https://develop.svn.wordpress.org/trunk@47756 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-03 22:56:01 +00:00
Timothy Jacobs ef05acdfaa REST API: Support the uuid JSON Schema format.
This accepts a uuid of any version. A future commit could add support for restricting uuids to a specific version.

Props johnwatkins0.
Fixes #50053.


git-svn-id: https://develop.svn.wordpress.org/trunk@47753 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-03 19:18:40 +00:00
John Blackbourn 4889e7a8d2 Menus: Allow empty taxonomy terms to be surfaced when searching for items.
This brings the behaviour inline with that of browsing terms or using the All Items tab, which correctly shows empty terms.

Props birgire, audrasjb

Fixes #45298

git-svn-id: https://develop.svn.wordpress.org/trunk@47747 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-02 22:34:50 +00:00
Sergey Biryukov af596bcc5b Canonical: Redirect paged requests for non-paginated posts to the post permalink.
This avoids displaying duplicate content of the same post under different URLs and ensures the canonical URL is correct.

Previously, requests for invalid page numbers were only redirected to the post permalink if the post was actually paginated using the `<!--nextpage-->` marker.

Follow-up to [34492].

Props jeremyfelt, prografika, sachit.tandukar, subrataemfluence, hronak, ekatherine, henry.wright, chesio, dd32, SergeyBiryukov.
Fixes #40773. See #45337, #28081, #11694.

git-svn-id: https://develop.svn.wordpress.org/trunk@47727 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-30 12:03:11 +00:00
Sergey Biryukov c61e42db64 Coding Standards: Fix WPCS issues in `tests/formatting/SanitizeFileName.php`.
Follow-up to [47638].

git-svn-id: https://develop.svn.wordpress.org/trunk@47664 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-29 17:23:30 +00:00
Sergey Biryukov 514f7c4cc9 Docs: Correct `@since` versions, remove duplicate comment.
Follow-up to [47633].

git-svn-id: https://develop.svn.wordpress.org/trunk@47663 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-29 17:23:21 +00:00
Jake Spurlock 74d6f9613b Formatting: Expand `sanitize_file_name` to have better support for utf8 characters.
Props: xknown, peterwilsoncc.


git-svn-id: https://develop.svn.wordpress.org/trunk@47638 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-29 15:38:43 +00:00
Jake Spurlock 4354d1fc5c User: Invalidate `user_activation_key` on password update.
Props: sstoqnov, sergeybiryukov.



git-svn-id: https://develop.svn.wordpress.org/trunk@47634 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-29 15:23:37 +00:00
Jake Spurlock cfb690cb8e Customize: Add additional filters to Customizer to prevent JSON corruption.
This solution extends the wp_insert_post_data filter to pass in addition to the slashed/sanitized/processed data, and the slashed/sanitized/unprocessed data, to also pass the initial slashed/unsanitized/unprocessed data which was passed into wp_insert_post(). This then allows plugins to have complete control over how sanitization is performed based on the post type.

Props westonruter, peterwilsoncc, sstoqnov, whyisjake, xknown.
 


git-svn-id: https://develop.svn.wordpress.org/trunk@47633 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-29 15:12:50 +00:00