Commit Graph

3526 Commits

Author SHA1 Message Date
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
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