Commit Graph

3455 Commits

Author SHA1 Message Date
Sergey Biryukov 3a229d0b47 Comments: Ensure that inserting a comment with an empty type results in correct `comment` type.
Add unit tests for `wp_handle_comment_submission()` and `wp_insert_comment()` receiving an empty type.

Follow-up to [47597].

Props ocean90, imath.
Fixes #49236.

git-svn-id: https://develop.svn.wordpress.org/trunk@47626 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-26 13:42:03 +00:00
Sergey Biryukov 46aad811be Embeds: Fix incorrect usage of `get_home_url()` in oEmbed tests.
Switch to `home_url()` for consistency with other tests and to avoid confusion.

Props david.binda.
Fixes #49988.

git-svn-id: https://develop.svn.wordpress.org/trunk@47615 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-23 18:39:32 +00:00
Sergey Biryukov 5d5e3439e4 Users: Change "Your Profile" and "My Profile" links in admin menu and toolbar to just "Profile" for consistency.
Props donmhico, bcworkz, seanchayes, mikeschroder, garrett-eclipse, akhileshsabharwal, ScottSmith, nacin, jenmylo, afercia, swissspidy, felix-edelmann, helen, melchoyce, karmatosed.
Fixes #26769.

git-svn-id: https://develop.svn.wordpress.org/trunk@47600 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-20 08:37:31 +00:00
Sergey Biryukov d5a7a3a45d Comments: Use `comment` instead of an empty string for the `comment_type` DB field value in comments table.
This is the first step to bring support for custom comment types into WordPress.

Add a scheduled upgrade routine to update the type value for existing comments, in batches of 100 at a time.

Props imath, aaroncampbell, jeremyfelt, dshanske.
Fixes #49236.

git-svn-id: https://develop.svn.wordpress.org/trunk@47597 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-17 19:33:52 +00:00
K. Adam White 3abe80eea1 REST API: Handle parameter types consistently within set_param().
A request has multiple parameter types, including "query" and "json." Updating a parameter could previously modify a key's value in the wrong parameter type, leading to confusing and self-contradictory response objects.

Props mnelson4, TimothyBlynJacobs, vagios, jnylen0.
Fixes #40838.


git-svn-id: https://develop.svn.wordpress.org/trunk@47559 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-09 19:28:58 +00:00
Andrew Ozz 7b5d78f82f Media: Enable lazy-loading of images by automatically adding the new `loading="lazy"` attribute to image tags on the front-end.
- Introduces `wp_lazy_loading_enabled()`, `wp_filter_content_tags()`, `wp_img_tag_add_loading_attr()`, and `wp_img_tag_add_srcset_and_sizes_attr()` functions.
- Introduces `wp_lazy_loading_enabled`, `wp_img_tag_add_loading_attr`, and `wp_img_tag_add_srcset_and_sizes_attr` filters.

Props flixos90, addyosmani, mor10, swissspidy, pierlo, westonruter, spacedmonkey, mikeschroder, jonoaldersonwp, peterwilsoncc, narwen, jeffpaul, OptimizingMatters, futtta, mukeshpanchal27, azaozz.

Fixes #44427.

git-svn-id: https://develop.svn.wordpress.org/trunk@47554 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-08 00:53:18 +00:00
Sergey Biryukov d8f5ce0ae5 Tests: Remove `test_post_thumbnails_types_true()`.
The test incorrectly describes the behavior of `current_theme_supports( 'post-thumbnails' )` and only passes by accident.

Follow-up to [30148].

Fixes #49801.

git-svn-id: https://develop.svn.wordpress.org/trunk@47548 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-04 00:25:36 +00:00
K. Adam White b5117e1ad5 REST API: Fix revisions controller get_item permission check.
r45812 incorrectly introduced a delete_post permissions check into the get_item method, breaking some plugins which requested revisions when generating previews.

Props sorenbronsted, yohannp, TimothyBlynJacobs.
Fixes #49645.


git-svn-id: https://develop.svn.wordpress.org/trunk@47547 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-03 19:38:15 +00:00
John Blackbourn fe18be23fd Comments: Ensure all elements in the array returned by `get_comment_count()` are integers.
Previously elements would be a mixture of strings and integers depending on their numeric value.

Props progremzion, m.usama.masood

Fixes #48093

git-svn-id: https://develop.svn.wordpress.org/trunk@47526 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-28 20:42:31 +00:00
K. Adam White bef2746334 REST API: Fix _fields filtering of registered rest fields.
Use rest_is_field_included when determining which additional fields to include to permit filtering by nested field properties.

Props Dudo, kadamwhite, TimothyBlynJacobs.
Fixes #49648.


git-svn-id: https://develop.svn.wordpress.org/trunk@47511 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-26 17:50:39 +00:00
Sergey Biryukov 8e3d204e04 Docs: Update inline comment in `Tests_DB::test_locale_floats()`.
See #49572.

git-svn-id: https://develop.svn.wordpress.org/trunk@47498 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-24 01:05:31 +00:00
Andrew Ozz 679fbbc422 Build/Test Tools: Fix PHPUnit bootstrap to install WP from `/build` when tests are run with `npm run test`, `grunt test`, `grunt` then `phpunit`, etc.
Fixes #49663.

git-svn-id: https://develop.svn.wordpress.org/trunk@47496 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-24 00:18:29 +00:00
Sergey Biryukov 31dd2e70f0 General: Trim the input data in `maybe_unserialize()`, for consistency with `is_serialized()`.
Props pbearne, mikeschroder.
Fixes #36416.

git-svn-id: https://develop.svn.wordpress.org/trunk@47454 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-13 21:12:01 +00:00
SergeyBiryukov 5ac6156507 Tests: Extract `is_serialized()` test cases into data providers; reuse them for `maybe_serialize()` and `maybe_unserialize()` tests.
Props pbearne, mikeschroder, SergeyBiryukov.
See #36416.

git-svn-id: https://develop.svn.wordpress.org/trunk@47452 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-13 20:39:02 +00:00
Sergey Biryukov ed9d5c383f Database: Introduce `wpdb::db_server_info()` to retrieve full MySQL server information string as supplied by `mysqli_get_server_info()`.
This complements `wpdb::db_version()`, which only returns a numeric version string and strips any additional information, e.g. vendor name.

Props clarinetlord, birgire, webaware, pento.
Fixes #40037. See #27703.

git-svn-id: https://develop.svn.wordpress.org/trunk@47451 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-12 15:53:01 +00:00
Timothy Jacobs 60edf36394 REST API: Introduce "hex-color" JSON Schema format.
Props spacedmonkey, chrisvanpatten.
Fixes #49270.


git-svn-id: https://develop.svn.wordpress.org/trunk@47450 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-12 02:40:29 +00:00
Sergey Biryukov b6ac7c4f87 Tests: Remove unnecessary use of `wpdb_exposed_methods_for_testing` in `test_utf8mb3_post_saves_with_emoji()`.
Props clarinetlord.
Fixes #39998.

git-svn-id: https://develop.svn.wordpress.org/trunk@47431 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-05 11:53:34 +00:00
Jorge Costa ac4de42983 Scripts: Use core-js url as polyfill for window.URL.
URL polyfill from the polyfill-library library is not spec-conformant, in a way which negatively impacts its usability for pending revisions to the block editor. Specifically, there were revisions to the implementation of the wp-url script to detect URL validity by relying on thrown errors from the URL constructor, but this specific behavior is not implemented in this version of the polyfill.
There was another issue in r47238, which is that the test used to check whether the polyfill should be included is not accurate. This commit uses a different check and fixes the issue.

Props aduth.
Fixes: #49360.

git-svn-id: https://develop.svn.wordpress.org/trunk@47416 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-03 16:53:32 +00:00
Sergey Biryukov 98003a7546 Tests: Add a unit test to ensure the "Supported Versions" section of GitHub Security Policy always includes the latest stable branch.
See #48667, #48521.

git-svn-id: https://develop.svn.wordpress.org/trunk@47403 602fd350-edb4-49c9-b593-d223f7449a82
2020-03-02 01:11:29 +00:00
Sergey Biryukov bc5a7e9506 Build/Test Tools: Remove redundant `Tests_Post_Types::register_post_type()` helper method, use `register_post_type()` directly.
Props gh640, varunshanbhag.
Fixes #49365.

git-svn-id: https://develop.svn.wordpress.org/trunk@47381 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-26 13:16:10 +00:00
Sergey Biryukov a6b80a326a Comments: Restore the fourth parameter of `comments_number()` as `$post_id`, for consistency with `get_comments_number_text()`.
The parameter was previously used as the number of comments, marked as deprecated in [5101].

Given that it's been deprecated for the last 13 years, it should be safe to undeprecate and repurpose it for a cleaner function signature, instead of adding a fifth parameter.

Follow-up to [47276].

Fixes #48772.

git-svn-id: https://develop.svn.wordpress.org/trunk@47366 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-25 17:32:34 +00:00
K. Adam White 4e0062e5be REST API: Correctly infer empty objects passed via query parameters.
Permit passing an empty object as the string "?obj=". The type of the passed empty argument is inferred from the registered schema.

Props TimothyBlynJacobs, steffanhalv, schlessera, dd32.
Fixes #42961.


git-svn-id: https://develop.svn.wordpress.org/trunk@47362 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-25 15:32:27 +00:00
K. Adam White b5190458fe REST API: Permit access to the themes controller if user can edit any post type.
Check a more exhaustive list of post type editing caps beyond "edit_post" to ensure custom user roles with access to to specific post types may still use block editor functionality depending on theme features.

Props miyauchi, TimothyBlynJacobs.
Fixes #46723.


git-svn-id: https://develop.svn.wordpress.org/trunk@47361 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-25 15:18:19 +00:00
K. Adam White a0ac0ff13d REST API: Apply all relevant block rendering filters when rendering block previews.
Several filters were introduced to the render_block method since the initial implementation of the block-renderer/ endpoints, causing the output of those endpoints to diverge from the rendered content of blocks on the frontend.

Props kadamwhite, TimothyBlynJacobs, miinasikk.
Fixes #49387.


git-svn-id: https://develop.svn.wordpress.org/trunk@47360 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-25 15:03:57 +00:00
Sergey Biryukov 317e1c076c Posts, Post Types: Ensure `delete_posts` is included in default post type capabilities regardless of `map_meta_cap` value.
This resolves PHP notices in a few places in core where this capability is checked.

Props Mte90, johnbillion, dipesh.kakadiya, jipmoors, bamadesigner, dd32, johnjamesjacoby, xedin.unknown, flixos90, SergeyBiryukov.
Fixes #30991.

git-svn-id: https://develop.svn.wordpress.org/trunk@47357 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-25 12:48:11 +00:00
K. Adam White 4e18f78ced REST API: Fix namespace shadowing issue in route matching logic.
Following [47260] a namespace such as "test-ns" prevents any namespace such as "test-ns/v1" from being found when matching routes.
While not best practice, this was an unintentional back-compat break; this patch restores the original behavior.

Props david.binda, TimothyBlynJacobs.
Fixes #48530.



git-svn-id: https://develop.svn.wordpress.org/trunk@47351 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-24 18:05:12 +00:00
Sergey Biryukov 8837ebd1f6 Build/Test Tools: Remove unused `::assertPostHasTerms()` method from `tests/term.php`.
The associated test was removed in [30241].

See #49485.

git-svn-id: https://develop.svn.wordpress.org/trunk@47341 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-21 17:03:12 +00:00
Timothy Jacobs 8a62f46beb REST API: Don't assume all item schemas have properties.
All schema types, not just objects, are permitted as the base type of a resource. A future patch could add validation support for those types, but this fix only prevents a PHP warning from being issued.

Props dhavalkasvala, johnwatkins0, birgire.
Fixes #48785.


git-svn-id: https://develop.svn.wordpress.org/trunk@47328 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-20 16:56:17 +00:00
Timothy Jacobs be371a7431 REST API: Fix links format in OPTIONS requests for non-variable routes.
Props nsundberg, johnwatkins0, birgire.
Fixes #49149.


git-svn-id: https://develop.svn.wordpress.org/trunk@47326 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-20 00:53:43 +00:00
Timothy Jacobs 727faabe98 REST API: Warn if registering array settings without an items schema.
The documentation for register_setting has also been clarified to include all of the supported types and the flexibility of the show_in_rest parameter.

Fixes #42875.
Props perrywagle, dshanske, kadamwhite.


git-svn-id: https://develop.svn.wordpress.org/trunk@47325 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-19 22:54:03 +00:00
Sergey Biryukov e4dda92bc5 Tests: Correct assertions in `test_site_dates_are_gmt()`.
`assertSame()` doesn't have the `$delta` parameter, only `assertEquals()` does.

Follow-up to [47313].

See #40364.

git-svn-id: https://develop.svn.wordpress.org/trunk@47318 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-19 04:38:39 +00:00
Sergey Biryukov 2d73050eda Posts, Post Types: Discard `tags_input` parameter in `wp_update_post()` if it's the same as existing post tags.
This ensures that `wp_update_post()` does not unintentionally modify post tags if the post has several tags with the same name but different slugs.

Tags should only be modified if `tags_input` parameter was explicitly provided, and is different from the existing tags.

Props kaggdesign, SergeyBiryukov.
Fixes #45121.

git-svn-id: https://develop.svn.wordpress.org/trunk@47317 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-19 03:50:38 +00:00
Sergey Biryukov 8de22575cd Tests: Use delta comparison in `test_site_dates_are_gmt()` to avoid race conditions.
See #40364.

git-svn-id: https://develop.svn.wordpress.org/trunk@47313 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-19 02:41:53 +00:00
Sergey Biryukov 2213eb37c4 Tests: Remove an irrelevant `tags_input` property assertion from `test_get_page_template_property()`.
This appears to be a copy/paste from the `test_get_tags_input_property()` test above.

See #45121.

git-svn-id: https://develop.svn.wordpress.org/trunk@47311 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-19 01:03:37 +00:00
Sergey Biryukov d4cc38581b Tests: Rename `$d` variable in some date/time tests to `$format` for clarity.
Follow-up to [47287].

See #49222.

git-svn-id: https://develop.svn.wordpress.org/trunk@47288 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-14 00:11:00 +00:00
Sergey Biryukov f97a60c9b7 Privacy: Revert [47269] for now to address side effects on Multisite installations.
See #44176.

git-svn-id: https://develop.svn.wordpress.org/trunk@47280 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 21:46:54 +00:00
Sergey Biryukov 1106d82f93 Privacy: Introduce filters for the headers of all the privacy-related e-mails:
* `wp_privacy_personal_data_email_headers`
* `user_request_confirmed_email_headers`
* `user_erasure_complete_email_headers`
* `user_request_action_email_headers`

Props xkon, garrett-eclipse, zaffarn, desrosj.
Fixes #44501.

git-svn-id: https://develop.svn.wordpress.org/trunk@47279 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 21:41:26 +00:00
Sergey Biryukov b8e935b2f2 Privacy: Add a table of contents to Personal Data Export report for easier navigation.
Props xkon, garrett-eclipse, birgire, karmatosed.
Fixes #46894.

git-svn-id: https://develop.svn.wordpress.org/trunk@47278 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 21:26:25 +00:00
Sergey Biryukov 4020493d45 Comments: Add a `$post_id` parameter to `get_comments_number_text()` and `comments_number()`.
This allow for using these functions outside of the loop.

Props donmhico, garrett-eclipse, Hinjiriyo, imath.
Fixes #48772.

git-svn-id: https://develop.svn.wordpress.org/trunk@47276 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 20:39:12 +00:00
Sergey Biryukov 0ad4121c91 Privacy: Introduce `wp_privacy_additional_user_data` filter to make it easier to include additional user meta in a personal data export.
Props pbiron, xkon, garrett-eclipse, azaozz.
Fixes #47509.

git-svn-id: https://develop.svn.wordpress.org/trunk@47270 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 18:57:51 +00:00
Sergey Biryukov 0911aecf36 Privacy: Un-map privacy capabilities to make them available to be assigned for custom roles:
* `erase_others_personal_data`
* `export_others_personal_data`
* `manage_privacy_options`

Previously mapped to `manage_options` or `manage_network` (on Multisite), these are now added to the Administrator role separately.

Additionally, `manage_privacy_options` is added to the Editor role.

Props garrett-eclipse, xkon, pbiron, desrosj, johnbillion, flixos90, juliobox, lakenh, Ov3rfly, ianatkins.
Fixes #44176.

git-svn-id: https://develop.svn.wordpress.org/trunk@47269 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 18:34:08 +00:00
K. Adam White b6dcb779ed REST API: Introduce rest_{$this->post_type}_item_schema filter to enable manipulation of schema values.
register_rest_field can be used to add properties to a schema, but no mechanism existed to alter existing properties like "content".
Running the schema through this filter lets plugins append additional sub-properties to existing schema definitions.

Props luisherranz, TimothyBlynJacobs, swissspidy, westonruter, kadamwhite.
Fixes #47779.



git-svn-id: https://develop.svn.wordpress.org/trunk@47265 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 16:26:56 +00:00
K. Adam White 886a02686b REST API: Allow meta to be set when creating a new media record via REST.
Props TimothyBlynJacobs, apermo.
Fixes #44567.


git-svn-id: https://develop.svn.wordpress.org/trunk@47261 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 03:37:17 +00:00
K. Adam White fc434a0c77 REST API: Match REST API routes on namespace before performing regex checks.
Rule out groups of API endpoints by simple namespace string comparison to reduce the number of regex checks necessary when matching a route.

Props TimothyBlynJacobs.
Fixes #48530.


git-svn-id: https://develop.svn.wordpress.org/trunk@47260 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 03:20:05 +00:00
K. Adam White d06637f9b5 REST API: List all core theme feature support details in /themes endpoint response.
Fully list which first-party core theme features are supported in the /themes endpoint response. This brings the REST API themes controller's response more in line with the output of get_theme_support().

Props adamboro, apieschel, koke, spacedmonkey, TimothyBlynJacobs.
See #49037.


git-svn-id: https://develop.svn.wordpress.org/trunk@47258 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 01:58:08 +00:00
Sergey Biryukov 49d8c4eff3 Docs: Improve documentation for `tests/phpunit/includes/spy-rest-server.php`.
Props andizer.
Fixes #47567.

git-svn-id: https://develop.svn.wordpress.org/trunk@47253 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-11 00:18:28 +00:00
Jorge Costa f558f5ff37 Block Editor: Update WordPress Packages; Remove navigation block; Add social links block
The following package versions were changed:
@wordpress/annotations: 1.11.0 -> 1.12.0
@wordpress/api-fetch: 3.10.0 -> 3.11.0
@wordpress/block-directory: 1.4.0 -> 1.5.0
@wordpress/block-editor: 3.6.0 -> 3.7.0
@wordpress/block-library: 2.13.0 -> 2.14.0
@wordpress/blocks: 6.11.0 -> 6.12.0
@wordpress/components: 9.1.0 -> 9.2.0
@wordpress/core-data: 2.11.0 -> 2.12.0
@wordpress/data: 4.13.0 -> 4.14.0
@wordpress/data-controls: 1.7.0 -> 1.8.0
@wordpress/e2e-test-utils: 4.2.0 -> 4.3.0
@wordpress/edit-post: 3.12.0 -> 3.13.0
@wordpress/editor: 9.11.0 -> 9.12.0
@wordpress/format-library: 1.13.0 -> 1.14.0
@wordpress/icons: 1.0.0 -> 1.1.0
@wordpress/keyboard-shortcuts: 1.0.0 -> 1.1.0
@wordpress/list-reusable-blocks: 1.12.0 -> 1.13.0
@wordpress/media-utils: 1.6.0 -> 1.7.0
@wordpress/notices: 1.12.0 -> 2.0.0
@wordpress/nux: 3.11.0 -> 3.12.0
@wordpress/plugins: 2.11.0 -> 2.12.0
@wordpress/primitives: 1.0.0 -> 1.1.0
@wordpress/rich-text: 3.11.0 -> 3.12.0
@wordpress/server-side-render: 1.7.0 -> 1.8.0
@wordpress/url: 2.10.0 -> 2.11.0
@wordpress/viewport: 2.12.0 -> 2.13.0
The navigation block inclusion was reverted.
The social links block was included.

Props gziolo, youknowriad, mcsf, noisysocks.
Fixes #49397.

git-svn-id: https://develop.svn.wordpress.org/trunk@47250 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 22:31:13 +00:00
Sergey Biryukov a6a02eaca7 Privacy: Give progress indication for export and erasure.
This adds a progress indicator for "Download Personal Data" and "Erase Personal Data" row actions, which can take a while with a lot of data.

Props garrett-eclipse, allendav, dominic_ks, xkon, karmatosed, birgire.
Fixes #44264.

git-svn-id: https://develop.svn.wordpress.org/trunk@47246 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 20:17:58 +00:00
Sergey Biryukov c0c2fd3f63 Privacy: Rename `wp_get_user_request_data()` to `wp_get_user_request()` for clarity; deprecate the old function.
The function returns an instance of the `WP_User_Request` object itself, not its `$request_data` property.

Follow-up to [44606].

Props garrett-eclipse.
Fixes #46302.

git-svn-id: https://develop.svn.wordpress.org/trunk@47245 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 19:55:51 +00:00
Timothy Jacobs e7399111b4 REST API: Add support for the REDIRECT_HTTP_AUTHORIZATION header.
Previously the REST API did not account for server configurations where the Authorization header must be added using ModRewrite. This caused major DUX issues when trying to use custom authentication mechanisms.

Fixes #47077.
Props dshanske, cklosows.


git-svn-id: https://develop.svn.wordpress.org/trunk@47239 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 16:06:58 +00:00
Andrew Duthie 2c795289c8 Script Loader: Add polyfill for window.URL, window.DOMRect.
Pending block editor revisions for WordPress 5.4 will make use of `window.URL` and `window.DOMRect`. These are not available in Internet Explorer (or pre-Chromium Edge for `DOMRect`) and must be polyfilled to avoid script errors.

The changes make use of the existing polyfill pattern, and existing `polyfill-library` dependency. The dependency is bumped to the latest version, since the previous version did not include the `DOMRect` polyfill.

Props jorgefilipecosta.
Fixes #49360.


git-svn-id: https://develop.svn.wordpress.org/trunk@47238 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 15:15:07 +00:00
Sergey Biryukov 5b0be97e7c Privacy: Include session tokens in Personal Data Export.
Session tokens contain an IP address and user agent.

Props garrett-eclipse, nickylimjj, lakenh, xkon, rconde.
Fixes #45889.

git-svn-id: https://develop.svn.wordpress.org/trunk@47237 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 05:42:52 +00:00
Sergey Biryukov 8fef1b28a9 Privacy: Include `community-events-location` user meta value in Personal Data Export.
The value is used by the WordPress Events and News widget to show relevant WP community events.

The location information may include an IP address, location description, and latitude/longitude coordinates.

Props garrett-eclipse, coreymckrill, xkon.
Fixes #43921.

git-svn-id: https://develop.svn.wordpress.org/trunk@47236 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 05:30:03 +00:00
Sergey Biryukov 023d4b2796 Administration: Capitalize `Trash` consistently in various messages and comments.
When used as a noun referring to the "virtual" place, `Trash` should be capitalized.

Props garrett-eclipse, aandrewdixon, Presskopp.
Fixes #45317.

git-svn-id: https://develop.svn.wordpress.org/trunk@47233 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 04:10:09 +00:00
Timothy Jacobs 98e5dd52de REST API: Introduce selective link embedding.
Previously the _embed flag would embed all embeddable links in a response even if only a subset of the links were necessary. Now, a list of link relations can be passed in the _embed parameter to restrict the list of embedded objects.

Props rheinardkorf, adamsilverstein, jnylen0, cklosows, chrisvanpatten, TimothyBlynJacobs.
Fixes #39696.


git-svn-id: https://develop.svn.wordpress.org/trunk@47224 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-09 20:52:06 +00:00
Sergey Biryukov 2aecc8f3e6 Tests: Add a basic test for `wp()` function.
Props pbearne, donmhico.
Fixes #48844.

git-svn-id: https://develop.svn.wordpress.org/trunk@47212 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-08 05:29:54 +00:00
Sergey Biryukov 3096571047 Tests: Change a few remaining `include_once` statements to `require_once`, for consistency.
See #48082.

git-svn-id: https://develop.svn.wordpress.org/trunk@47200 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-06 21:40:05 +00:00
Jorge Costa 8640eaa96e Block Editor: Update WordPress Packages.
The following package versions were changed:
@wordpress/a11y: 2.6.0 -> 2.7.0
@wordpress/annotations: 1.10.0 -> 1.11.0
@wordpress/api-fetch: 3.9.0 -> 3.10.0
@wordpress/autop: 2.5.1 -> 2.6.0
@wordpress/blob: 2.6.0 -> 2.7.0
@wordpress/block-directory: 1.3.0 -> 1.4.0
@wordpress/block-editor: 3.5.0 -> 3.6.0
@wordpress/block-library: 2.12.0 -> 2.13.0
@wordpress/block-serialization-default-parser: 3.4.1 -> 3.5.0
@wordpress/blocks: 6.10.0 -> 6.11.0
@wordpress/components: 9.0.0 -> 9.1.0
@wordpress/compose: 3.10.0 -> 3.11.0
@wordpress/core-data: 2.10.0 -> 2.11.0
@wordpress/custom-templated-path-webpack-plugin: 1.5.0 -> 1.6.0
@wordpress/data: 4.12.0 -> 4.13.0
@wordpress/data-controls: 1.6.0 -> 1.7.0
@wordpress/date: 3.7.0 -> 3.8.0
@wordpress/dependency-extraction-webpack-plugin: 2.1.0 -> 2.2.0
@wordpress/deprecated: 2.6.1 -> 2.7.0
@wordpress/dom: 2.7.0 -> 2.8.0
@wordpress/dom-ready: 2.6.0 -> 2.7.0
@wordpress/e2e-test-utils: 4.1.0 -> 4.2.0
@wordpress/edit-post: 3.11.0 -> 3.12.0
@wordpress/editor: 9.10.0 -> 9.11.0
@wordpress/element: 2.10.0 -> 2.11.0
@wordpress/escape-html: 1.6.0 -> 1.7.0
@wordpress/format-library: 1.12.0 -> 1.13.0
@wordpress/hooks: 2.6.0 -> 2.7.0
@wordpress/html-entities: 2.5.0 -> 2.6.0
@wordpress/i18n: 3.8.0 -> 3.9.0
@wordpress/is-shallow-equal: 1.7.0 -> 1.8.0
@wordpress/keyboard-shortcuts: 0.2.0 -> 1.0.0
@wordpress/keycodes: 2.8.0 -> 2.9.0
@wordpress/library-export-default-webpack-plugin: 1.5.0 -> 1.6.0
@wordpress/list-reusable-blocks: 1.11.0 -> 1.12.0
@wordpress/media-utils: 1.5.0 -> 1.6.0
@wordpress/notices: 1.11.0 -> 1.12.0
@wordpress/nux: 3.10.0 -> 3.11.0
@wordpress/plugins: 2.10.0 -> 2.11.0
@wordpress/priority-queue: 1.4.0 -> 1.5.0
@wordpress/redux-routine: 3.6.2 -> 3.7.0
@wordpress/rich-text: 3.10.0 -> 3.11.0
@wordpress/scripts: 6.2.0 -> 7.0.0
@wordpress/server-side-render: 1.6.0 -> 1.7.0
@wordpress/shortcode: 2.5.0 -> 2.6.0
@wordpress/token-list: 1.8.0 -> 1.9.0
@wordpress/url: 2.9.0 -> 2.10.0
@wordpress/viewport: 2.11.0 -> 2.12.0
@wordpress/wordcount: 2.6.2 -> 2.7.0
Added these new packages:
@wordpress/warning
@wordpress/primitives
@wordpress/icons
Re-added keyboard-shortcuts to script loader removed by mistake on revision 47198.

Props gziolo, itsjonq, youknowriad, mcsf, andraganescu.
Fixes #49358.

git-svn-id: https://develop.svn.wordpress.org/trunk@47199 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-06 21:01:16 +00:00
Sergey Biryukov e72fff9cef Code Modernization: Replace `dirname( __FILE__ )` calls with `__DIR__` magic constant.
This avoids the performance overhead of the function call every time `dirname( __FILE__ )` was used instead of `__DIR__`.

This commit also includes:

* Removing unnecessary parentheses from `include`/`require` statements. These are language constructs, not function calls.
* Replacing `include` statements for several files with `require_once`, for consistency:
 * `wp-admin/admin-header.php`
 * `wp-admin/admin-footer.php`
 * `wp-includes/version.php`

Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb.
Fixes #48082.

git-svn-id: https://develop.svn.wordpress.org/trunk@47198 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-06 06:31:22 +00:00
Sergey Biryukov 011962fae0 Posts, Post Types: Add default `menu_icon` values for built-in post types.
This allows the icons to be retrieved via `get_post_type_object()`.

Props m.usama.masood, michael.ecklund, SergeyBiryukov.
Fixes #38844.

git-svn-id: https://develop.svn.wordpress.org/trunk@47196 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 22:38:11 +00:00
Sergey Biryukov 56e4630c0e Tests: In `Tests_dbDelta`, only force MyISAM database engine on MySQL versions older than 5.7.
Since MySQL 5.7, InnoDB engine supports `FULLTEXT` indexes, so forcing MyISAM is unnecessary.

Follow-up to [47193], which addressed the issue in `Tests_dbDelta::setUp()`, but missed other tests.

Props xkon, joonasvanhatapio, SergeyBiryukov.
Fixes #49367.

git-svn-id: https://develop.svn.wordpress.org/trunk@47195 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 22:05:50 +00:00
Sergey Biryukov ddf2d5ad06 Tests: In `Tests_dbDelta::setUp()`, only force MyISAM database engine on MySQL versions older than 5.7.
Since MySQL 5.7, InnoDB engine supports `FULLTEXT` indexes, so forcing MyISAM is unnecessary.

Props xkon, joonasvanhatapio, SergeyBiryukov.
Fixes #49367.

git-svn-id: https://develop.svn.wordpress.org/trunk@47193 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 18:19:11 +00:00
Sergey Biryukov e4d8eac50f Taxonomy: In `register_taxonomy()`, return the registered taxonomy object on success, for consistency with `register_post_type()`.
Props krynes, SergeyBiryukov.
Fixes #48558.

git-svn-id: https://develop.svn.wordpress.org/trunk@47186 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 06:24:16 +00:00
Sergey Biryukov 6c00abab9e Coding Standards: Fix WPCS issue in [47184].
See #49344.

git-svn-id: https://develop.svn.wordpress.org/trunk@47185 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 05:01:55 +00:00
Sergey Biryukov 629b9a778a Tests: Allow `dbDelta()` tests to (mostly) run on MySQL 8.0.11+.
* MySQL 8.0.11 changed the `GeometryCollection` data type name to `GeomCollection`, with the latter being the preferred name.
* MySQL 8.0.17 removed support for the display width attribute for integer data types. Previously, default display width of 20 digits was used: `BIGINT(20)`.

The affected tests now check the MySQL server version and use the appropriate data types.

This leaves one unresolved failure on MySQL 8.0.17+ to be addressed in the future, caused by the same `BIGINT` display width discrepancy coming from `wp_get_db_schema()`.

Props kaggdesign, ottok, jeremyfelt, SergeyBiryukov.
Fixes #44384, #49344. See #49364.

git-svn-id: https://develop.svn.wordpress.org/trunk@47184 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 04:28:13 +00:00
Sergey Biryukov b34f289bfd Tests: Allow `wpdb::set_sql_mode()` tests to run on MySQL 8.0.11+.
MySQL 8.0.11 removed support for the `NO_AUTO_CREATE_USER` SQL mode, which was used in as an example of a mode compatible with WordPress.

`NO_AUTO_VALUE_ON_ZERO` is now used in the affected tests instead, which is supported on both MySQL 5.7.x and 8.0.x.

Props kaggdesign, jeremyfelt, afragen.
Fixes #44586. See #49344.

git-svn-id: https://develop.svn.wordpress.org/trunk@47183 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 03:28:33 +00:00
Sergey Biryukov 5e8563eb6b Posts, Post Types: Fail gracefully when checking whether a single post with an unregistered post status should be displayed in `WP_Query::get_posts()`.
If the post status is not registered, assume it's not public, but still allow access to users with edit permissions (same as for a protected post status, e.g. `draft`), so that they could recover orphaned content.

Add unit tests.

Follow-up to [47178].

Props roytanck, SergeyBiryukov.
Fixes #48653.

git-svn-id: https://develop.svn.wordpress.org/trunk@47181 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-05 01:31:38 +00:00
Sergey Biryukov 6f15251aa4 Posts, Post Types: Fail gracefully when checking mapped cap against unregistered post status.
With `map_meta_cap` enabled for a post type, the `read_post` capability for posts with a public status is supposed to be mapped to the post type's `read` capability.

When a post is left in the database after the post status is no longer present, and WP does a `read_post` check against it, a PHP notice was thrown, and the cap check always failed.

As a more graceful fallback, the cap is now mapped onto `edit_others_posts`, which allows highly privileged users to be able to access orphaned content.

A `_doing_it_wrong()` notice is also added, so that developers and site administrators are aware that the cap mapping is failing in the absence of the registered post status.

Follow-up to [34091], which introduced a similar approach to checking mapped caps against an unregistered post type.

Props roytanck, SergeyBiryukov.
Fixes #48653.

git-svn-id: https://develop.svn.wordpress.org/trunk@47178 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-04 22:13:15 +00:00
Jorge Costa 4bcf9be615 Block Editor: Include navigation block server logic.
Core did not include the navigation block PHP files.
This commit fixes the issue referred, and now the navigation block is executed on the frontend. The block still does not work as expected and throws an error during frontend execution. That problem is going to be fixed on the next WordPress package update.
This commit adds the file as it is on the npm package used.

Props gziolo.
Fixes #49348.

git-svn-id: https://develop.svn.wordpress.org/trunk@47176 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-04 20:14:50 +00:00
Sergey Biryukov dd48b7f757 Canonical: When removing trailing punctuation from query string arguments, match the whole query var name.
Props daveslaughter.
Fixes #49347.

git-svn-id: https://develop.svn.wordpress.org/trunk@47169 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-03 00:12:22 +00:00
Sergey Biryukov 63a53c730f Tests: Adjust XML-RPC unit tests for [47160].
Follow-up to [47162].

See #40096.

git-svn-id: https://develop.svn.wordpress.org/trunk@47163 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-02 04:07:50 +00:00
Sergey Biryukov d5572e9f11 Tests: Adjust XML-RPC unit tests for [47160].
See #40096.

git-svn-id: https://develop.svn.wordpress.org/trunk@47162 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-02 03:30:37 +00:00
Sergey Biryukov fd3083e3f5 Post Thumbnails: Make sure `get_post_thumbnail_id()` returns an integer, to match the documented return value.
This makes the function more consistent with `get_the_ID()` or `wp_get_post_parent_id()`, both returning an integer.

Props 0v3rth3d4wn.
Fixes #40096.

git-svn-id: https://develop.svn.wordpress.org/trunk@47160 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-02 03:06:31 +00:00
Sergey Biryukov 54c6311c96 Accessibility: Text Changes: Use sentence case for the word `Error` in various error messages, instead of all caps.
Using all caps should be avoided for better readability and because screen readers may pronounce all-caps words as abbreviations.

Props afercia, ryokuhi, sabernhardt, garrett-eclipse.
See #47656, #43037, #42945.

git-svn-id: https://develop.svn.wordpress.org/trunk@47156 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-01 21:36:44 +00:00
Sergey Biryukov 097f272455 Tests: Update the expected message in `test_with_draft_post()`.
Follow-up to [47154].

See #42945.

git-svn-id: https://develop.svn.wordpress.org/trunk@47155 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-01 21:11:08 +00:00
Sergey Biryukov b894d8665a Privacy: Introduce a JSON file into the personal data export.
The produced ZIP archive will now include an `export.json` file along with the current `index.html`.

Props xkon.
Fixes #49029. See #46424.

git-svn-id: https://develop.svn.wordpress.org/trunk@47146 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-31 01:34:17 +00:00
Sergey Biryukov 7192a8f562 Privacy: Remove user's email address from personal data export filename.
Use `wp_unique_filename()` to avoid potential collisions instead.

Props xkon, garrett-eclipse, donmhico, Ov3rfly, Clorith, allendav.
Fixes #44197.

git-svn-id: https://develop.svn.wordpress.org/trunk@47144 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-31 00:56:29 +00:00
Sergey Biryukov ac6409a479 HTTP API: Add some basic tests for `wp_remote_fopen()`.
Props pbearne, donmhico.
Fixes #48845.

git-svn-id: https://develop.svn.wordpress.org/trunk@47142 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-31 00:20:47 +00:00
Sergey Biryukov 8ba94ecf5d Tests: Rename `wpValidateBoolean.php` for consistency with other files.
See #30238.

git-svn-id: https://develop.svn.wordpress.org/trunk@47141 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-31 00:14:07 +00:00
K. Adam White 547a08ee03 REST API: Reuse previously-generated embedded objects when building collection response.
Store each generated embedded object in a temporary cache when querying for linked resources so that repeated links to the same resource do not trigger repeated queries or processing.

Props TimothyBlynJacobs.
Fixes #48838.



git-svn-id: https://develop.svn.wordpress.org/trunk@47138 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-30 20:20:30 +00:00
Sergey Biryukov cfc3b57488 Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-29 00:43:23 +00:00
Sergey Biryukov bd2cd572aa Docs: Improve DocBlocks in `phpunit/includes/object-cache.php` per the documentation standards.
See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47121 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-29 00:36:17 +00:00
Sergey Biryukov 48110faf25 Coding Standards: Disable WPCS warnings for `date_default_timezone_set()` and `current_time( 'timestamp' )` calls in Date/Time tests.
These calls are intentional and required for the tests.

See #49222.

git-svn-id: https://develop.svn.wordpress.org/trunk@47118 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-28 00:51:42 +00:00
Sergey Biryukov d5e20d8ab5 Comments: Add `In reply to: %s` parent comment link to new comment email notifications.
This information was previously available on the Moderate Comment screen in the admin, but was missing from moderation emails.

Props imath, danieltj, andraganescu, galbaras, SergeyBiryukov.
Fixes #43805. See #43429.

git-svn-id: https://develop.svn.wordpress.org/trunk@47114 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-27 04:31:48 +00:00
Sergey Biryukov af39b30e28 Date/Time: In `wp_maybe_decline_date()`, add support for a range of days, e.g. `February 21–23`.
A potential use case is displaying multi-day events in the WordPress Events and News dashboard widget.

See #47798, #48934.

git-svn-id: https://develop.svn.wordpress.org/trunk@47098 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-21 23:46:36 +00:00
Sergey Biryukov 8660569e82 Date/Time: Add some basic tests for `current_time()`.
Props pbearne, talldanwp, SergeyBiryukov.
Fixes #34378.

git-svn-id: https://develop.svn.wordpress.org/trunk@47081 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-17 02:50:39 +00:00
Sergey Biryukov 0ead760ec6 Tests: Replace `date()` with `gmdate()` in `WP_Test_REST_Posts_Controller` tests.
Follow-up to [45424], [46252].

See #46438, #44491, #39953.

git-svn-id: https://develop.svn.wordpress.org/trunk@47080 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-17 02:02:41 +00:00
Sergey Biryukov a2978bac70 Tests: Update the `wp_maybe_decline_date()` tests for [47078].
See #48934.

git-svn-id: https://develop.svn.wordpress.org/trunk@47079 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-17 01:14:24 +00:00
Sergey Biryukov 5bef137806 Date/Time: Pass the date format to `wp_maybe_decline_date()`.
This ensures that the function has enough context to determine the necessity of replacing the month name with the correct form in locales that require it.

Props SergeyBiryukov, Rarst.
Fixes #48934.

git-svn-id: https://develop.svn.wordpress.org/trunk@47078 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-17 01:10:57 +00:00
Sergey Biryukov 93b2d5ecc0 Tests: Revert [47076], this should have been committed with the related changes to the function.
git-svn-id: https://develop.svn.wordpress.org/trunk@47077 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-17 01:08:28 +00:00
SergeyBiryukov abfca60342 Tests: Move `wp_maybe_decline_date()` tests to the `date` directory.
See #48934.

git-svn-id: https://develop.svn.wordpress.org/trunk@47076 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-17 00:54:02 +00:00
Sergey Biryukov 2daa4b6c82 Tests: In `Tests_Site_Health`, create a `WP_Site_Health` instance before clearing the cron array, as the constructor schedules its own task now.
See #47606.

git-svn-id: https://develop.svn.wordpress.org/trunk@47064 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-12 14:16:57 +00:00
Sergey Biryukov cd5b7df8b8 Docs: Improve documentation for `tests/phpunit/includes/testcase-ajax.php`.
Props andizer, SergeyBiryukov.
Fixes #47568.

git-svn-id: https://develop.svn.wordpress.org/trunk@47041 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-05 15:31:10 +00:00
K. Adam White 746502eaa9 REST API: Issue doing_it_wrong if a taxonomy's specified rest_base is already in use by a different resource.
Props fgiannar, TimothyBlynJacobs, kingkool68, SergeyBiryukov.
Fixes #48401.



git-svn-id: https://develop.svn.wordpress.org/trunk@47037 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-03 19:22:32 +00:00
K. Adam White 172e0b01c6 REST API: Short-circuit comment controller permissions check if commented-upon post type does not exist.
Props imani3011, dragosh635, subrataemfluence, timothyblynjacobs.
Fixes #42238.



git-svn-id: https://develop.svn.wordpress.org/trunk@47036 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-03 18:42:09 +00:00
Sergey Biryukov ef6973b7f0 Bootstrap/Load: Make handling the `/favicon.ico` requests more flexible.
Previously, `wp_favicon_request()` was introduced in [13205] to avoid a performance hit of serving a full 404 page on every favicon request.

While working as intended, that implementation did not provide a way for theme or plugin authors to manage the behavior of favicon requests.

This changeset implements the following logic (only applied if WordPress is installed in the root directory):

* If there is a Site Icon set in Customizer, redirect `/favicon.ico` requests to that icon.
* Otherwise, use the WordPress logo as a default icon.
* If a physical `/favicon.ico` file exists, do nothing, let the server handle the request.

Handling `/favicon.ico` is now more consistent with handling `/robots.txt` requests.

New functions and hooks:

* Introduce `is_favicon()` conditional tag to complement `is_robots()`.
* Introduce `do_favicon` action to complement `do_robots` and use it in template loader.
* Introduce `do_favicon()` function, hooked to the above action by default, to complement `do_robots()`.
* Introduce `do_faviconico` action to complement `do_robotstxt`, for plugins to override the default behavior.
* Mark `wp_favicon_request()` as deprecated in favor of `do_favicon()`.

Props jonoaldersonwp, birgire, joostdevalk, mukesh27, SergeyBiryukov.
Fixes #47398.

git-svn-id: https://develop.svn.wordpress.org/trunk@47018 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-28 21:18:03 +00:00
Sergey Biryukov 85c7a64791 Docs: Improve `@return` description for `wp_update_comment()` and `WP_UnitTest_Factory_For_Comment::update_object()`.
See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47017 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-27 00:28:39 +00:00
Sergey Biryukov 079580a6b7 Tests: Set `network_id` instead of `site_id` in `WP_UnitTest_Factory_For_Blog` defaults.
Follow-up to [47011], [47013].

See #47195.

git-svn-id: https://develop.svn.wordpress.org/trunk@47014 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-26 00:25:20 +00:00
Sergey Biryukov 93eeb8f1d7 Tests: Update legacy arguments passed to `WP_UnitTest_Factory_For_Blog::create_object()`.
This converts the arguments originally meant for `wpmu_create_blog()` to the ones used by `wp_insert_site()`.

Follow-up to [47011].

Fixes #47195.

git-svn-id: https://develop.svn.wordpress.org/trunk@47013 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-25 21:39:46 +00:00
Sergey Biryukov f8051662b1 Tests: Replace most instances of `wpmu_delete_blog()` not specifically testing that function with `wp_delete_site()`.
Follow-up to [47011].

See #47195.

git-svn-id: https://develop.svn.wordpress.org/trunk@47012 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-25 18:15:13 +00:00
Sergey Biryukov ebe75fb903 Tests: Switch `WP_UnitTest_Factory_For_Blog::create_object()` to use `wp_insert_site()`.
Map some arguments for backward compatibility with `wpmu_create_blog()` previously used there.

Props davidbaumwald, danielbachhuber, jeremyfelt, SergeyBiryukov.
See #47195.

git-svn-id: https://develop.svn.wordpress.org/trunk@47011 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-25 18:10:19 +00:00
Sergey Biryukov dbf6a0ba7c Media: Make sure `attachment_url_to_postid()` performs a case-sensitive search for the uploaded file name.
Previously, the first available match was returned, regardless of the case, which was not always the expected result.

Props archon810, ben.greeley, tristangemus, vsamoletov, SergeyBiryukov.
Fixes #39768.

git-svn-id: https://develop.svn.wordpress.org/trunk@47010 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-25 02:24:38 +00:00
Sergey Biryukov 2c15e0c286 Tests: Don't fail the test in `WP_UnitTestCase_Base::skipOnAutomatedBranches()` if Travis environment variables are unavailable, it prevents from running the test locally.
Follow-up to [47000].

See #49050.

git-svn-id: https://develop.svn.wordpress.org/trunk@47001 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-20 12:13:10 +00:00
Sergey Biryukov d697471bb1 Tests: Correct the check for pull requests in `WP_UnitTestCase_Base::skipOnAutomatedBranches()`.
Mark the test as failed if the environment variables are unavailable.

Fixes #49050.

git-svn-id: https://develop.svn.wordpress.org/trunk@47000 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-20 01:10:23 +00:00
Sergey Biryukov 26cc3cfd19 Tests: Skip external HTTP test for recommended PHP and MySQL versions on 503 errors.
Fixes #49049.

git-svn-id: https://develop.svn.wordpress.org/trunk@46998 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-19 20:27:16 +00:00
Jake Spurlock 2fad299387 Editor: Add unit tests for v5.3.1 block serialization functions
r46896 was intended to have included unit tests for the block serialization functions added as part of the changeset.

Props: @aduth.
Fixes: #49048 



git-svn-id: https://develop.svn.wordpress.org/trunk@46997 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-19 18:48:49 +00:00
Sergey Biryukov 9fe4689f2d Tests: In `test_readme()`, if the HTTP request to `secure.php.net` or `dev.mysql.com` failed, include response code in the error message.
See #40533, #44613.

git-svn-id: https://develop.svn.wordpress.org/trunk@46996 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-19 15:43:33 +00:00
Sergey Biryukov 7cdb642610 Tests: Remove unused cache keys from `data_get_site_caches()`.
Follow-up to [46990].

See #40363.

git-svn-id: https://develop.svn.wordpress.org/trunk@46991 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-18 03:20:59 +00:00
Sergey Biryukov c8ac42b3dd Docs: Improve comments in `tests/formatting/redirect.php` per the documentation standards.
See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@46987 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-18 00:26:23 +00:00
Sergey Biryukov 0d81dcbfb1 Docs: Add `@method` notation for `WP_UnitTest_Factory_For_Term::create_and_get()` for consistency with other factories.
See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@46986 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-18 00:24:03 +00:00
Sergey Biryukov a3e674d4f9 Docs: Various documentation fixes for unit test factories.
See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@46985 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-18 00:17:54 +00:00
Sergey Biryukov 99ddfa0195 Tests: Use delta comparison in `test_should_fall_back_to_last_post_modified()` to avoid race conditions.
See #48957.

git-svn-id: https://develop.svn.wordpress.org/trunk@46981 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-17 21:31:08 +00:00
Sergey Biryukov a4b65bfca8 Date/Time: Ensure that `get_feed_build_date()` correctly handles a modified post object with invalid date.
* Clarify in the documentation that the function returns `false` on failure.
* Consistently pass the return value through the `get_feed_build_date` filter.

Props Rarst, dd32, azaozz, tellyworth.
Fixes #48957.

git-svn-id: https://develop.svn.wordpress.org/trunk@46974 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-17 20:41:09 +00:00
Sergey Biryukov 69ddf953bd Date/Time: Add a unit test for [46968].
See #48145.

git-svn-id: https://develop.svn.wordpress.org/trunk@46969 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-17 14:35:25 +00:00
Andrew Ozz 99ef48a585 Upload: Fix the final file name collision test in `wp_unique_filename()` when uploading a file with upper case extension. Add a unit test to catch that in the future.
Fixes #48975 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@46966 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-16 23:42:34 +00:00
Andrew Ozz 735b3543db Upload:
- Fix PHP warnings in `wp_unique_filename()` when the destination directory is unreadable.
- Run the final name collision test only for files that are saved to the uploads directory.
- Update the unit tests to match.

Props eden159, audrasjb, azaozz.
Fixes #48960 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@46965 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-16 23:22:00 +00:00
Jake Spurlock 7c38cf178a Prevent stored XSS in the block editor.
Prevent escaped unicode characters become unescaped in unsafe HTML during JSON decoding.

Props: aduth, epiqueras, 


git-svn-id: https://develop.svn.wordpress.org/trunk@46896 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-12 18:00:45 +00:00
Jake Spurlock 39a8eacb5f Update `wp_kses_bad_protocol()` to recognize `:` on uri attributes,
`wp_kses_bad_protocol()` makes sure to validate that uri attributes don’t contain invalid/or not allowed protocols. While this works fine in most cases, there’s a risk that by using the colon html5 named entity, one is able to bypass this function.

Props: xknown, nickdaugherty, peterwilsoncc.


git-svn-id: https://develop.svn.wordpress.org/trunk@46895 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-12 17:52:18 +00:00
Jake Spurlock dcab984b1b Prevent stored XSS through wp_targeted_link_rel().
Props: vortfu, whyisjake, peterwilsoncc, xknown,  SergeyBiryukov, flaviozavan.



git-svn-id: https://develop.svn.wordpress.org/trunk@46894 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-12 17:51:35 +00:00
Sergey Biryukov b73180da85 Tests: Docs: Correct `@param` formatting in `SpeedTrapListener` after [35226] and [45607].
See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@46882 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-11 15:46:51 +00:00
Sergey Biryukov c1ab0cc974 Menus: Avoid a PHP warning in `add_submenu_page()` when the same value is passed for both `$parent_slug` and `$menu_slug` parameters.
Props welcher, ispreview, ayeshrajans, NextScripts, adamsilverstein, garrett-eclipse, 123host.
Fixes #48599.

git-svn-id: https://develop.svn.wordpress.org/trunk@46868 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-09 21:01:13 +00:00
Sergey Biryukov bdca31b322 Date/Time: XML-RPC: Сalculate the proper offset for GMT in `wp.newPost`, `wp.editComment`, `mw.newPost`, `mw.editPost` when `post_date` or `comment_date` is set.
Previously, `post_date` or `comment_date` was assumed to be GMT, which is only true if the timezone string for the site matches GMT.

Add unit tests.

Props Rarst, smerriman, justdaiv, wonderboymusic, noyle.
Fixes #30429.

git-svn-id: https://develop.svn.wordpress.org/trunk@46864 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-09 19:54:16 +00:00
Sergey Biryukov 50f01f47e3 Date/Time: When determining whether to decline the month name in `wp_maybe_decline_date()`, take word boundaries into account.
Add more unit tests.

Props Rarst, Clorith, timon33, Xendo, SergeyBiryukov.
Fixes #48606.

git-svn-id: https://develop.svn.wordpress.org/trunk@46862 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-09 18:48:50 +00:00
Sergey Biryukov e76722f70f Tests: Change `group` annotation for `test_unique_filename_with_dimension_like_filename()` to `ticket.
See #42437.

git-svn-id: https://develop.svn.wordpress.org/trunk@46835 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-09 12:16:43 +00:00
Sergey Biryukov de38dfdd47 Tests: Make sure network factory returns an integer ID for created objects, for consistency with other factories and the documented value.
See #48145.

git-svn-id: https://develop.svn.wordpress.org/trunk@46831 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-09 11:29:14 +00:00
Sergey Biryukov 102cb95559 Tests: Pad incrementors used in factories with leading zeros to make sure MySQL sorting works as expected.
Previously, tests could create sequential objects with names like `Term 99`, `Term 100`, which by default would be returned in reverse order when sorted by name alphabetically, causing seemingly random test failures that are extremely hard to debug.

See #48145.

git-svn-id: https://develop.svn.wordpress.org/trunk@46830 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-09 10:39:39 +00:00
Sergey Biryukov 0660804327 Tests: Speed up comment submission unit tests by creating less fixtures and reusing them where possible.
See #30017, #48145.

git-svn-id: https://develop.svn.wordpress.org/trunk@46829 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-08 18:00:23 +00:00
Andrew Ozz 5464dcb2c5 Upload: fix `wp_unique_filename()` to prevent name collisions with existing or future image sub-size file names, and add unit tests.
Props Viper007Bond, pbiron, azaozz.
Fixes #42437.

git-svn-id: https://develop.svn.wordpress.org/trunk@46822 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-06 22:26:19 +00:00
John Blackbourn bcfccc7344 Docs: Correct various docblocks documentation.
See #48303

git-svn-id: https://develop.svn.wordpress.org/trunk@46821 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-06 22:21:07 +00:00
Sergey Biryukov 0c673c2308 Tests: Remove duplicate `test_get_page_by_path_priority()` test.
The test was moved into its own file in [37478], but never removed from its previous location.

See #36711.

git-svn-id: https://develop.svn.wordpress.org/trunk@46819 602fd350-edb4-49c9-b593-d223f7449a82
2019-12-06 17:25:32 +00:00
Sergey Biryukov 4bd7b37ef9 Tests: Merge [24251] from `_wp_filter_build_unique_id()` to `_test_filter_build_unique_id()`, for consistency.
See #47407.

git-svn-id: https://develop.svn.wordpress.org/trunk@46806 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-29 22:15:31 +00:00
Sergey Biryukov 890bd870e8 Docs: Correct `@param` type for the function parameter in `tests_add_filter()` and `_test_filter_build_unique_id()`.
Synchronize documentation for `add_filter()`, `tests_add_filter()`, `_wp_filter_build_unique_id()`, `_test_filter_build_unique_id()`.

Add a note that `$tag` and `$priority` are no longer used in `_wp_filter_build_unique_id()` since [46220], and the function always returns a string now.

Props donmhico, remcotolsma, SergeyBiryukov.
Fixes #47407. See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@46801 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-29 21:40:58 +00:00
Sergey Biryukov e720a9ddc7 Date/Time: Make `get_permalink()` more resilient against PHP timezone changes.
Overriding default PHP timezone with `date_default_timezone_set()`, while not recommended, should not inadvertently result in changing existing permalinks.

Add a unit test.

Props Rarst, steevithak, archon810, maciejmackowiak, Ov3rfly, Cybr, hometowntrailers, scvleon, miette49.
Fixes #48623.

git-svn-id: https://develop.svn.wordpress.org/trunk@46795 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-28 13:40:19 +00:00
Sergey Biryukov 9737e5fdc3 KSES: Add support for gradient backgrounds.
Props jorgefilipecosta.
Fixes #48376.

git-svn-id: https://develop.svn.wordpress.org/trunk@46793 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-28 00:27:21 +00:00
Sergey Biryukov 4159a41cef Tests: Add `feed` group for `get_feed_build_date()` test added in [46756].
See #48675.

git-svn-id: https://develop.svn.wordpress.org/trunk@46785 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-26 16:17:02 +00:00
Sergey Biryukov 6ce8175456 Date/Time: Remove `mysql2date()` usage in `get_feed_build_date()` to ensure the output includes correct timezone offset.
With the changes in [45908], `mysql2date()` works correctly for all local time inputs, but should not be used for UTC time inputs.

Add a unit test.

Props Rarst, lisota.
Fixes #48675.

git-svn-id: https://develop.svn.wordpress.org/trunk@46756 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-21 13:16:50 +00:00
Sergey Biryukov 3b54ab37ed Customize: If the return URL for Close button is a page added to the Appearance menu by a deactivated theme, fall back to the Themes screen.
Props JarretC, Jean-David, SergeyBiryukov.
Fixes #46686.

git-svn-id: https://develop.svn.wordpress.org/trunk@46754 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-20 18:47:08 +00:00
Sergey Biryukov 6c776ea07b Bundled Themes: Update copyright year in `readme.txt`.
Add a unit test to ensure the year stays up to date.

Props dkarfa, SergeyBiryukov.
Fixes #48566.

git-svn-id: https://develop.svn.wordpress.org/trunk@46719 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-12 17:34:05 +00:00
Jake Spurlock 91312ab695 Tests: Fix a typo in an inline comment.
Fix a regression from [46568].

Props david.binda.
See #48312.


git-svn-id: https://develop.svn.wordpress.org/trunk@46707 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-11 18:48:06 +00:00
Sergey Biryukov 1ee0c8e54f Customize: Remove the deprecated `-precomposed` suffix from `apple-touch-icon` link in `wp_site_icon()`.
Props mukto90, khag7.
Fixes #48555.

git-svn-id: https://develop.svn.wordpress.org/trunk@46698 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-11 09:58:17 +00:00
Sergey Biryukov cde71eed52 Docs: In various `@return` tags, list the expected type first, instead of `WP_Error`.
See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@46696 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-11 02:41:15 +00:00
Sergey Biryukov 1b82ea8284 Tests: Don't skip the tests intended for Multisite when running on single site, add them to the `ms-required` group instead.
See #43438.

git-svn-id: https://develop.svn.wordpress.org/trunk@46693 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-10 01:53:17 +00:00
Sergey Biryukov 00aff3a706 Docs: Use 3-digit, x.x.x style semantic versioning for `$version` argument in `do_action_deprecated()` and `apply_filters_deprecated()` calls.
Props jrf.
Fixes #48255.

git-svn-id: https://develop.svn.wordpress.org/trunk@46689 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-09 13:55:43 +00:00
Sergey Biryukov 243d1a2e38 Test: Don't skip the tests intended for single site when running on Multisite, add them to the `ms-excluded` group instead.
See #39776, #45747.

git-svn-id: https://develop.svn.wordpress.org/trunk@46683 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-09 03:44:51 +00:00
Sergey Biryukov fcf86b80b6 Tests: Skip `test_readme()` if the HTTP request to `secure.php.net` or `dev.mysql.com` failed on timeout.
Move `skipTestOnTimeout()` to `WP_UnitTestCase_Base` to avoid duplication.

See #44613.

git-svn-id: https://develop.svn.wordpress.org/trunk@46682 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-09 03:36:19 +00:00
John Blackbourn a216b6d838 Toolbar: Un-deprecate the `WP_Admin_Bar::add_menu()` method.
This is only a wrapper for the `add_node()` method, but it's in widespread use both in core until [46642] and in thousands of plugins and themes. Deprecating it would have made sense when #19647 was originally opened but that's no longer the case.

Props whyisjake

Fixes #19647 


git-svn-id: https://develop.svn.wordpress.org/trunk@46678 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-08 13:17:35 +00:00
Sergey Biryukov 75f82d8bc2 Tests: Properly mark `test_submenu_helpers_priority()` as skipped for multisite, so it's not categorized as "risky".
See #39776.

git-svn-id: https://develop.svn.wordpress.org/trunk@46674 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-06 01:15:11 +00:00
Sergey Biryukov 9c3319de66 Coding Standards: Fix WPCS issues in [46670].
See #48145.

git-svn-id: https://develop.svn.wordpress.org/trunk@46671 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-05 23:17:01 +00:00
John Blackbourn bd2130f367 REST API: Use explicit dates in a post ordering test to avoid indeterminate ordering.
See #48145


git-svn-id: https://develop.svn.wordpress.org/trunk@46670 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-05 22:39:37 +00:00
Sergey Biryukov 4a729f0498 REST API: Speed up pagination unit tests by creating less fixtures and reusing them where possible.
Includes minor documentation and code layout fixes for better readability.

See #30017, #48145.

git-svn-id: https://develop.svn.wordpress.org/trunk@46657 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-05 20:41:12 +00:00