Commit Graph

3325 Commits

Author SHA1 Message Date
Sergey Biryukov 91f60afbe5 Date/Time: Use PHP `DateTime` class API in `current_time()`.
Only use the legacy WP timestamp approach (a sum of timestamp and timezone offset) for `timestamp` and `U` formats without the `$gmt` flag.

Otherwise, make sure the function returns correct local time for any format.

Props Rarst, jdgrimes.
Fixes #40653.

git-svn-id: https://develop.svn.wordpress.org/trunk@45856 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 21:05:42 +00:00
Sergey Biryukov f5f2fc379e Coding Standards: Use long array syntax in `Tests_WP_Timezone::timezone_offset_provider()`.
Per https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/, arrays must be declared using long array syntax for clarity.

See #24730.

git-svn-id: https://develop.svn.wordpress.org/trunk@45855 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 21:05:25 +00:00
Sergey Biryukov 904b41e01c Date/Time: Introduce `wp_timezone_string()` and `wp_timezone()` for unified timezone retrieval.
* `wp_timezone_string()` retrieves the timezone from current settings as a string. Uses the `timezone_string` option to get a proper timezone if available, otherwise falls back to an offset.
* `wp_timezone()` retrieves the timezone from current settings as a `DateTimeZone` object. Timezone can be based on a PHP timezone string or a `±HH:MM` offset.

Props Rarst, remcotolsma, johnjamesjacoby, rmccue.
Fixes #24730.

git-svn-id: https://develop.svn.wordpress.org/trunk@45853 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 19:07:03 +00:00
Sergey Biryukov f2b6c12ddb Coding Standards: Fix WPCS violations in [45851].
See #25347.

git-svn-id: https://develop.svn.wordpress.org/trunk@45852 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 16:34:57 +00:00
Sergey Biryukov 896da178e0 Date/Time: In `wp_insert_post()`, when checking the post date to set `future` or `publish` status, use string comparison to work around far future dates (year 2038+) on 32-bit systems.
Props Rarst, nofearinc.
Fixes #25347.

git-svn-id: https://develop.svn.wordpress.org/trunk@45851 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 15:49:32 +00:00
Gary Pendergast 4e0499e5bf Tests: Add an xdebug group for tests that require xdebug.
These tests are now also run as their own part of the Travis build, to ensure performance of other tests isn't affected by the presence of xdebug.

Fixes #40532.



git-svn-id: https://develop.svn.wordpress.org/trunk@45827 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 02:17:50 +00:00
Sergey Biryukov 95c36ce5ba Privacy: Add descriptions for sections in a personal data export file.
Props garrett-eclipse, Venutius, karmatosed.
Fixes #45491.

git-svn-id: https://develop.svn.wordpress.org/trunk@45825 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-18 02:07:00 +00:00
K. Adam White 4bb45c674a Add @ticket annotations for [45812].
Props birgire.
See #43709.



git-svn-id: https://develop.svn.wordpress.org/trunk@45820 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-16 03:32:23 +00:00
K. Adam White 5a98103567 REST API: Add @ticket annotation to test from [45813].
Props birgire.
See #42209.


git-svn-id: https://develop.svn.wordpress.org/trunk@45815 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 23:08:31 +00:00
K. Adam White d65b89c5e4 REST API: Always return post types list in taxonomies endpoint response as an array.
Prevents a non-sequential post type array such as [ 0 => 'post', 2 => 'page' ] from being improperly converted to an object in the taxonomy endpoint's response JSON.

Props TimothyBlynJacobs, birgire, spectacula.
Fixes #42209.


git-svn-id: https://develop.svn.wordpress.org/trunk@45813 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 22:11:07 +00:00
K. Adam White 8f100777e8 REST API: Prevent deletion of post revisions.
Allowing the client to delete revisions breaks the "audit trail" functionality. This is not allowed in WordPress and shouldn't be allowed through the API.
While not recommended, a plugin may opt-in to the previous behavior by setting a custom 'delete_post' capability for the revisions post type.

Props dlh, danielbachhuber, TimothyBlynJacobs, azaozz, kadamwhite.
Fixes #43709.



git-svn-id: https://develop.svn.wordpress.org/trunk@45812 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 22:00:49 +00:00
K. Adam White eb468c4446 REST API: Cache results of get_item_schema on controller instances for performance.
Caches the output of get_item_schema() to avoid redundant recomputation of translatable strings and other computed values. This method is called many times per item in each REST request, and the results of the method should not vary between calls.
Additional schema fields are not cached.

Props kadamwhite, joehoyle, TimothyBlynJacobs.
Fixes #47871.


git-svn-id: https://develop.svn.wordpress.org/trunk@45811 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 21:08:05 +00:00
K. Adam White 80e44e49e2 REST API: Do not send response body if status is 204 or body is null.
Status code 204 should indicate no response body is sent. Previously, a "null" string was sent, which MacOS Safari would try to parse as JSON and thereby fail to complete the request.

Props TimothyBlynJacobs, andizer, matthias.thiel.
Fixes #43691.



git-svn-id: https://develop.svn.wordpress.org/trunk@45809 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 19:55:13 +00:00
K. Adam White 22480c035b REST API: Add test class file incorrectly omitted from [45807].
Props @TimothyBlynJacobs.
See #43392.


git-svn-id: https://develop.svn.wordpress.org/trunk@45808 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 17:20:02 +00:00
K. Adam White c92ef7c441 REST API: Support 'object' and 'array' types in register_meta() schemas.
Extends meta registration to support complex schema values, mirroring the functionality in the settings controller.
Error when trying to modify a meta key containing schema-nonconformant data.

Props @TimothyBlynJacobs, @birgire, @mnelson4, @flixos90.
Fixes #43392.



git-svn-id: https://develop.svn.wordpress.org/trunk@45807 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 17:16:21 +00:00
Peter Wilson 0d2b94a44a Site Health Check: New tests file missed in [45801].
git-svn-id: https://develop.svn.wordpress.org/trunk@45802 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 00:36:38 +00:00
Sergey Biryukov a2a28e4608 Widgets: Allow for short-circuiting widget output in `the_widget()` using the `widget_display_callback` filter, for consistency with output via a registered sidebar.
Props MarcGuay, donmhico.
Fixes #34226.

git-svn-id: https://develop.svn.wordpress.org/trunk@45798 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-14 23:02:25 +00:00
Sergey Biryukov a58eb86d5e Posts, Post Types: In `wp_trim_words()` make sure the `$num_words` parameter is always an integer, as documented, to avoid a PHP warning.
Props donmhico, pikamander2.
Fixes #47867.

git-svn-id: https://develop.svn.wordpress.org/trunk@45796 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-14 17:17:51 +00:00
Sergey Biryukov d4a305292f Users: Make `wp_list_authors()` unit tests more readable.
See #23498.

git-svn-id: https://develop.svn.wordpress.org/trunk@45795 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-14 15:35:19 +00:00
Peter Wilson feb0830c79 Comments: Include post permalink in comment reply link.
Include the post's permalink when generating reply links in `get_comment_reply_link()` to account for comments displayed on index and archive pages.

This reapplies [32786] which was inadvertently reverted in [42360].

Props justinahinon, donmhico.
See #33383.
Fixes #47174.


git-svn-id: https://develop.svn.wordpress.org/trunk@45787 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-13 05:08:14 +00:00
Gary Pendergast 13d356691b Build Tools: Miscellaneous `local-env` improvements.
- Move the functionality for controlling `local-env` out of `package.json`, into JS scripts.
- Merge the `docker-compose` config files, and move it to the root directory. This allows `docker-compose.override.yml` to work for local overrides.
- Fix nginx redirecting to port 80 under some circumstances.
- `npm run env:install` now creates `wp-tests.config.php` for you.
- Cleaned up a bunch of cruft in `.travis.yml`.

See #47767.



git-svn-id: https://develop.svn.wordpress.org/trunk@45783 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-12 08:28:33 +00:00
Gary Pendergast 4271f1aeca Build Tools: Switch all Travis PHPUnit jobs over to Docker-based PHP.
Additionally, there are a handful of related minor changes in this commit:
- `.travis.yml` has been tidied up a little.
- [45745] was incorrectly marking Travis jobs as passed when some PHPUnit runs failed.
- Add the `LOCAL_PHP_MEMCACHED` environment variable, for enabling Memcached.
- Add the `env:pull` NPM script, for refreshing Docker images.

See #47767.


git-svn-id: https://develop.svn.wordpress.org/trunk@45762 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-07 11:54:22 +00:00
Sergey Biryukov 4bbe1ab5a9 Coding Standards: Fix WPCS violation in [45754].
See #46570.

git-svn-id: https://develop.svn.wordpress.org/trunk@45755 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-05 18:09:20 +00:00
Sergey Biryukov fad1821dd7 General: Correctly detect large floats in `is_serialized()`.
Props killerbishop, donmhico, hoythan.
Fixes #46570.

git-svn-id: https://develop.svn.wordpress.org/trunk@45754 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-05 13:54:43 +00:00
Sergey Biryukov 6c78848612 Users: Clean user cache in `check_password_reset_key()` tests.
Props davidbaumwald, spacedmonkey.
See #45845.

git-svn-id: https://develop.svn.wordpress.org/trunk@45717 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 19:53:45 +00:00
Sergey Biryukov f912470ac3 Users: Use `wp_update_user()` in `get_password_reset_key()`.
Props jayswadas, spacedmonkey, donmhico, SergeyBiryukov.
Fixes #45746.

git-svn-id: https://develop.svn.wordpress.org/trunk@45714 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 17:24:20 +00:00
Sergey Biryukov 209a72c35a Coding Standards: Fix WPCS violations after [45708].
See #45747.

git-svn-id: https://develop.svn.wordpress.org/trunk@45709 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 12:02:30 +00:00
Sergey Biryukov 03122ef7e1 Users: Deprecate `update_user_status()` in favor of `wp_update_user()`.
Props spacedmonkey, SergeyBiryukov.
Fixes #45747.

git-svn-id: https://develop.svn.wordpress.org/trunk@45708 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 11:27:28 +00:00
K. Adam White a875f9dae7 REST API: Skip processing fields which are not present in the selected context.
In `WP_REST_Controller::get_fields_for_response()`, exclude fields which are not registered to appear in the request's context.

In conjunction with r45705 this prevents the unnecessary computation of the sample permalink when making a request that is not context=edit.

Props dlh.
Fixes #45605.


git-svn-id: https://develop.svn.wordpress.org/trunk@45706 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-31 20:20:02 +00:00
Dominik Schilling 41dc7c7365 I18N: Following [45688], remove test for removed method.
See #44865.

git-svn-id: https://develop.svn.wordpress.org/trunk@45689 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-27 14:29:28 +00:00
Dominik Schilling 84b977945c I18N: Add support for custom `WP_PLUGIN_URL` in `load_script_textdomain()`.
Plugins may not be on the same host/path as the rest of the content. To support loading translations for this setup check if the script source matches `plugins_url()`.
Also fixes an undefined index notice when a custom content URL has no path.

Props odminstudios, ocean90.
Fixes #46336, #46387.

git-svn-id: https://develop.svn.wordpress.org/trunk@45685 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-27 12:43:56 +00:00
Gary Pendergast 4943b377ce Coding Standards: Move `wp-includes/class-oembed.php` to `wp-includes/class-wp-oembed.php`.
This renames the file containing the `WP_oEmbed` class to conform to the coding standards.

This commit also includes:

- A new `class-oembed.php` that includes the new file, for anyone that may've been including the file directly.
- Replaces references to the old filename with the new filename.

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45663 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-19 04:31:40 +00:00
Sergey Biryukov fd23000b11 Menus: Trim whitespace from custom link URLs.
Props majemedia, SergeyBiryukov.
Fixes #47723.

git-svn-id: https://develop.svn.wordpress.org/trunk@45655 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-17 18:44:56 +00:00
Gary Pendergast 8416a2b410 Coding Standards: Move `wp-admin/custom-header.php` to `wp-admin/includes/class-custom-image-header.php`
This renames the file containing the `Custom_Image_Header` class to conform to the coding standards.

This commit also includes:
- A new `custom-header.php` that includes the new file, for anyone that may've been including the file directly.
- Replaces references to the old filename with the new filename.

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45654 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-17 06:16:27 +00:00
Sergey Biryukov 2ae276c44f Media: Add a unit test for `wp_get_mime_types()`.
Props pbearne.
Fixes #47701.

git-svn-id: https://develop.svn.wordpress.org/trunk@45646 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-16 21:51:45 +00:00
Gary Pendergast 2da7f9f524 Code Modernisation: Fix known instances of array access on data types that can't be accessed as arrays.
PHP 7.4 addes a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.

This change fixes all of these warnings visible in unit tests.

Props jrf.
See #47704.




git-svn-id: https://develop.svn.wordpress.org/trunk@45639 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-15 06:24:08 +00:00
Gary Pendergast c6c78490e2 Coding Standards: Fix the remaining issues in `/tests`.
All PHP files in `/tests` now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs `phpcs` on the `/tests` directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45607 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-08 00:55:20 +00:00
Gary Pendergast 18ec05e23a Coding Standards: Fix all `WordPress.DB.PreparedSQLPlaceholders` issues.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45603 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-05 05:42:57 +00:00
Gary Pendergast 6acb0c6402 Coding Standards: Fix all `WordPress.WhiteSpace.PrecisionAlignment` issues.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45602 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-05 05:20:52 +00:00
Gary Pendergast a00c69458b Formatting: Revert the changes to `wpautop()` in [45585,45587].
See #27350.


git-svn-id: https://develop.svn.wordpress.org/trunk@45589 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 11:21:53 +00:00
Gary Pendergast fe28df65e3 Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `tests`.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45588 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 04:43:01 +00:00
Gary Pendergast 8298f9dad0 Clean up stray `<p>` tags added by `wpautop()` inside block level tags.
`autop()` can sometimes get confused and not clean up stray `<p>` or `</p>` tags inside block level elements, which produces sub-optimal HTML. While browsers can generally handle it, there's no need to make things harder for them if we don't have to.

Props pento, ayubi, pbearne, jond, azaozz, 1994rstefan, dionysous, MikeHansenMe, jorbin, miqrogroove, niallkennedy.
Fixes #27350.




git-svn-id: https://develop.svn.wordpress.org/trunk@45585 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 01:30:15 +00:00
Adam Silverstein b97899a07f Taxonomy: add a new 'terms_pre_query' filter to short circuit WP_Term_Query 'get_terms' queries.
Add a new `terms_pre_query` filter which returns null by default. Return a non-null value to bypass WordPress's default `get_terms` queries.

Props jarocks, boonebgorges, spacedmonkey.
Fixes #41246.



git-svn-id: https://develop.svn.wordpress.org/trunk@45584 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 20:47:21 +00:00
Gary Pendergast ef5a9dfda6 Coding Standards: Fix/ignore the `WordPress.NamingConventions.ValidFunctionName` violations.
See #47632



git-svn-id: https://develop.svn.wordpress.org/trunk@45580 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 08:00:12 +00:00
Gary Pendergast 78e096fe98 Formatting: Trim leading whitespace in `esc_url()`.
Props toszcze.
Fixes #36369.



git-svn-id: https://develop.svn.wordpress.org/trunk@45578 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 03:28:21 +00:00
Gary Pendergast 77f9bf0aeb Formatting: Don't add `<p>` tags inside `<svg>` tags.
Inline `<svg>`s should generally work, as browsers should just ignore `<p>` or `<br/>` tags that shouldn't be inside the `<svg>`. To keep things neat, however, it's better not add them in the first place.

Props jared_smith, nacin, pento.
Fixes #9437.



git-svn-id: https://develop.svn.wordpress.org/trunk@45577 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 03:18:28 +00:00
Riad Benguella ed1233d05f Build/Test Tools: Fix the hello e2e test assertion.
The previous assertion was always valid because we assumed it returned a single object,
while in reality it was returning an array.

Props hideokamoto.
Fixes #47622.


git-svn-id: https://develop.svn.wordpress.org/trunk@45575 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-28 11:33:13 +00:00
Gary Pendergast 77764a5754 Formatting: Add correct `<p>` tags near `<hr>` tags.
It can be tricky to know when `wpautop()` should add `<p>` tags, but one thing we can be certain about is that they really shouldn't be anywhere near `<hr>` tags.

Now they aren't.

Props solarissmoke, MattyRob, pento.
Fixes #14674.



git-svn-id: https://develop.svn.wordpress.org/trunk@45574 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-28 07:15:31 +00:00
Gary Pendergast b9cd66f483 Formatting: Add support for seconds to `human_time_diff()`.
The web has gotten so much faster since `human_time_diff()` was created, we need to be able to measure time differences with much finer granularity. Now, we can.

Props johnjamesjacoby, pento.
Fixes #35655.



git-svn-id: https://develop.svn.wordpress.org/trunk@45573 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-28 06:43:27 +00:00
Riad Benguella 42a8715471 Build/Test Tools: Add the e2e tests setup.
- Adds a local environment based on docker
 - Adds the e2e tests setup
 - Adds a "Hello World" e2e test to serve as a template

Props gziolo, herregroen, mcsf.
Fixes #45165.


git-svn-id: https://develop.svn.wordpress.org/trunk@45570 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-27 11:26:58 +00:00
Gary Pendergast 3202f9f37e Formatting: Don't convert smilies in ignored tags that have attributes.
Smilies in ignored tags are not supposed to be converted to emoji, but this can malfunction if the tag has attributes. For example, the Preformatted block with add a `class` to the `<pre>` tag.

Props pento, jikamens.
Fixes #47489.



git-svn-id: https://develop.svn.wordpress.org/trunk@45569 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-27 02:04:17 +00:00
Sergey Biryukov e283457e45 Date/Time: Add more supported formats to `wp_maybe_decline_date()`.
Props SergeyBiryukov, Rarst.
Fixes #37411.

git-svn-id: https://develop.svn.wordpress.org/trunk@45555 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-20 13:46:20 +00:00
Peter Wilson 66f7cee321 Site health: Introduce `view_site_health_checks` capability.
Introduces the faux primitive capability `view_site_health_checks` available to single site admins and multisite super-admin to view the site health page within the admin.

The capability is mapped to the `install_plugins` capability without being dependent on the file system being writable. This fixes a bug where the feature couldn't be used by sites unable to write to the file system or managed through version control.

The capability is granted on the `user_has_cap` filter.

Props birgire, Clorith, palmiak, peterwilsoncc, spacedmonkey.
Fixes #46957.



git-svn-id: https://develop.svn.wordpress.org/trunk@45507 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-10 07:41:12 +00:00
John Blackbourn 393960b182 I18N: Allow the length of automatically generated excerpts to be localized.
This introduces three new strings that can be used to control the maximum length of automatically generated excerpts for posts, comments, and draft post previews in the dashboard. Optionally combined with the existing word count type control this allows languages which include many multibyte characters to specify more appropriate maximum excerpt lengths.

Props miyauchi, birgire, johnbillion

Fixes #44541


git-svn-id: https://develop.svn.wordpress.org/trunk@45505 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-08 18:41:08 +00:00
Andrea Fercia ffe40885a1 Regenerate the REST API fixtures after [45443].
See #38517.


git-svn-id: https://develop.svn.wordpress.org/trunk@45498 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-07 20:23:46 +00:00
Sergey Biryukov af0c73b10b Build/Test Tools: Add `$current_screen` to the list of globals to unset in `WP_UnitTestCase_Base::go_to()`.
Props mauteri.
Fixes #47439.

git-svn-id: https://develop.svn.wordpress.org/trunk@45486 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-31 14:06:27 +00:00
Andrew Ozz 3337e709ee Fix unit tests after [45456]. The query string is a bit different but the results are the same.
See #45346.

git-svn-id: https://develop.svn.wordpress.org/trunk@45458 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-28 04:18:53 +00:00
John Blackbourn 814aa7149f Build/Test Tools: Remove the dependency on a globally installed Grunt.
The existing `"grunt": "grunt"` script in `package.json` allows for the use of `npm run grunt ...` which uses the local `grunt` binary in the project's `node_modules`.

Fixes #47380


git-svn-id: https://develop.svn.wordpress.org/trunk@45445 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-26 19:34:24 +00:00
Sergey Biryukov 10855438ea Date/Time: Replace all instances of `date()` with `gmdate()`.
Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

`gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.

git-svn-id: https://develop.svn.wordpress.org/trunk@45424 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-26 00:11:37 +00:00
John Blackbourn b64f812a59 Docs: Switch to the more common syntax for variadic function documentation.
See #37402


git-svn-id: https://develop.svn.wordpress.org/trunk@45418 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-25 21:58:18 +00:00
Sergey Biryukov cfd2e38db3 Docs: Remove full stop from ticket number.
See #46402.

git-svn-id: https://develop.svn.wordpress.org/trunk@45409 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-25 12:08:11 +00:00
Sergey Biryukov bda3af14b0 Formatting: Don't run `wp_targeted_link_rel()` on entirely serialized content.
Props birgire, elliotcondon.
Fixes #46402.

git-svn-id: https://develop.svn.wordpress.org/trunk@45408 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-25 12:04:28 +00:00
Sergey Biryukov 2a163fa733 Date/Time: Return early from `the_weekday()` and `the_weekday_date()` if we're not in the loop.
Restore `$previousweekday` global usage in `the_weekday_date()`, so it could still be used simultaneously with `the_date()`.

Partially reverts [45378].
See #47354.

git-svn-id: https://develop.svn.wordpress.org/trunk@45379 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-23 00:37:56 +00:00
Sergey Biryukov 48fb69f013 Date/Time: Bring some consistency to `the_date()` and `the_weekday_date()`:
* Make `the_date()` always apply the the filter and return a value.
* Use `is_new_day()` in `the_weekday_date()`.
* Add a unit test for `the_weekday_date()`.

Fixes #47354.

git-svn-id: https://develop.svn.wordpress.org/trunk@45378 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-22 21:57:29 +00:00
Sergey Biryukov 6491746559 Date/Time: Use strict comparison in `is_new_day()`, add a unit test.
Props pbearne.
Fixes #46627.

git-svn-id: https://develop.svn.wordpress.org/trunk@45375 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-22 17:52:22 +00:00
Jonathan Desrosiers f9e4f60577 General: Add missing unit tests for `wp_array_slice_assoc()`.
Props pbearne, desrosj.
Fixes #46638.

git-svn-id: https://develop.svn.wordpress.org/trunk@45371 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-21 14:47:58 +00:00
Peter Wilson b9e6f18350 KSES: Add `flex` and related long form properties to safe CSS.
Allow `flex`, `flex-grow`, `flex-shrink` and `flex-basis` to be used in inline CSS. As of WordPress 5.3 the block editor is expected to use `flex-basis` inline to set the width in the column block.

Props aduth.
Fixes #47281.
See #37248.



git-svn-id: https://develop.svn.wordpress.org/trunk@45363 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-18 04:33:27 +00:00
Sergey Biryukov a36aa1b078 Formatting: Adjust `wp_targeted_link_rel()` to ensure JSON format is preserved and correct quotes are used when adding the missing `rel` attribute.
Props birgire, TobiasBg, fierevere, audrasjb, SergeyBiryukov.
Fixes #46316, #47244.

git-svn-id: https://develop.svn.wordpress.org/trunk@45348 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-17 12:08:50 +00:00
Alex Shiels 85a90cb244 Upgrade/Install: Don't run signature verify on slow 32-bit systems.
The sodium_compat library can be very slow for certain operations on 32-bit architectures, which can lead to web server timeouts while attempting to verify an update. This adds a runtime speed check to skip signature verification on systems that would otherwise time out. Includes simple unit tests.

Props dd32, paragoninitiativeenterprises.
See #47186.


git-svn-id: https://develop.svn.wordpress.org/trunk@45345 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-17 11:05:45 +00:00
Andrew Ozz 96649a5ad1 Fix `setup_postdata()` to set the (inside the loop) globals before `the_post` action is fired. Follow-up from #42814 and [44941].
Props david.binda, spacedmonkey, boonebgorges, birgire, jorbin, azaozz.
Fixes #47114 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@45285 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-04 20:59:11 +00:00
Gary Pendergast 3491bfc7e5 Media: Revert [44947].
`get_available_post_mime_types()` uses a query that's extremely slow on sites with lots of posts. The original fix can be revisited after those performance issues are tackled.

See #43658.


git-svn-id: https://develop.svn.wordpress.org/trunk@45270 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-26 00:43:50 +00:00
Andrew Ozz 71832fe328 Fix parsing of inner blocks when auto-generating an excerpt. Helps to prevent cases where dynamic inner blocks may cause an infinite loop if trying to auto-generate an excerpt.
Props desrosj, pento, gziolo, azaozz.
Fixes #46133.

git-svn-id: https://develop.svn.wordpress.org/trunk@45265 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-24 21:38:21 +00:00
Andrew Ozz 361333e7e2 Remove the `core/more` block delimiters when splitting post_content on the `<!--more-->` tag.
Fixes:
- Parsing of blocks in the second half of post_content.
- Outputting malformed HTML when `the_content( null, true )` or  `<!--noteaser-->` is used.

Props lukecarbis, garrett-eclipse, birgire.
Fixes #46471.

git-svn-id: https://develop.svn.wordpress.org/trunk@45261 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-24 05:40:01 +00:00
Adam Silverstein 9e3c57c2ff Feeds: improve structure and naming of feed build date helper function.
Simplify overall code structure by passing the required format to the helper function.
Clarify functionality by renaming `get_last_build_date` to `get_feed_build_date`.

Props pento, spacedmonkey.
Fixes #4575.



git-svn-id: https://develop.svn.wordpress.org/trunk@45247 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-18 17:07:07 +00:00
Jonathan Desrosiers d575d70fe9 Administration: Improve the accuracy of `is_block_editor()`.
Currently, there are a number of scenarios where `is_block_editor()` (and `WP_Screen::is_block_editor`) would incorrectly indicate block editor support at different points of the loading process. Most notably, checking `is_block_editor` when hooking into the `current_screen` action will always result in `false`, even when the block editor is being loaded. This is because `is_block_editor` is not set to `true` until `edit-form-blocks.php` is included.

This change adds logic to `WP_Screen` to ensure the accuracy of `is_block_editor` on block editor pages earlier in the load process.

While edit screens will now be accurate 100% of the time from `current_screen` on, there are still a few edge cases where `is_block_editor` could contain an incorrect value when creating a new post.

Because a `WP_Post` object is a required parameter for the `replace_editor` filter and `use_block_editor_for_post()` function, `WP_Screen` will fall back to the value returned by `use_block_editor_for_post_type()` for the post being created. To eliminate these edge cases, the `use_block_editor_for_post_type` filter can be used to return the appropriate boolean value to indicate support.

Props Chouby, desrosj, aduth, johnbillion.
Fixes #46195.

git-svn-id: https://develop.svn.wordpress.org/trunk@45224 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-17 01:55:21 +00:00
Felix Arntz aa377f582d Bootstrap/Load: Allow more than one recovery link to be valid at a time.
While currently a recovery link is only made available via the admin email address, this will be expanded in the future. In order to accomplish that, the mechanisms to store and validate recovery keys must support multiple keys to be valid at the same time.

This changeset adds that support, adding an additional token parameter which is part of a recovery link in addition to the key. A key itself is always associated with a token, so the two are only valid in combination. These associations are stored in a new `recovery_keys` option, which is regularly cleared in a new Cron hook, to prevent potential cluttering from unused recovery keys.

This changeset does not have any user-facing implications otherwise.

Props pbearne, timothyblynjacobs.
Fixes #46595. See #46130.


git-svn-id: https://develop.svn.wordpress.org/trunk@45211 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-16 05:08:16 +00:00
Sergey Biryukov 80817d3209 Bootstrap/Load: After [45016], make sure `wp_die()` does not cause `_doing_it_wrong()` notices if called before `$wp_query` global is set.
Props tmdesigned, TimothyBlynJacobs.
Fixes #46813.

git-svn-id: https://develop.svn.wordpress.org/trunk@45206 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-15 23:48:11 +00:00
John Blackbourn dde307d4c9 Build/Test tools: Add some docs to the test functions.
Props andizer

Fixes #46501


git-svn-id: https://develop.svn.wordpress.org/trunk@45160 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-11 17:29:20 +00:00
Gary Pendergast 6dddce67fc Privacy: Only mark a personal data export as complete when the user downloads it.
An admin may download an export to check that it's all correct, but this action shouldn't mark the request as complete.

Props garrett-eclipse, JoshuaWold, birgire.
Fixes #44644.



git-svn-id: https://develop.svn.wordpress.org/trunk@45148 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-09 00:03:07 +00:00
Gary Pendergast 677c2a447b Media: Update the media bulk action labels for consistency.
Props ianbelanger, garrett-eclipse, afercia, Presskopp.
Fixes #44675.



git-svn-id: https://develop.svn.wordpress.org/trunk@45147 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 23:53:02 +00:00
Gary Pendergast cfebdd3752 Widgets: Add `rel="noopener noreferrer"` to links with `target="_blank"` in the Image widget.
Props audrasjb, welcher, afercia.
Fixes #43280.



git-svn-id: https://develop.svn.wordpress.org/trunk@45144 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 23:22:14 +00:00
Gary Pendergast 5dfdc9b9c4 Widgets: Add `rel="noopener noreferrer"` to links with `target="_blank"` in the Text and HTML widgets.
Props audrasjb, birgire, mukesh27.
Fixes #46421.



git-svn-id: https://develop.svn.wordpress.org/trunk@45143 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 23:17:35 +00:00
Gary Pendergast 466a7443a6 Menus: Add `rel="noopener"` to `target="_blank"` links by default in menus.
This expands upon `rel="noopener"` being previously added to links in the content.

Props audrasjb, welcher.
Fixes #43290.



git-svn-id: https://develop.svn.wordpress.org/trunk@45141 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 23:05:22 +00:00
Gary Pendergast edd6a1f129 Blocks: Allow for nested `the_content` calls within `do_blocks()`.
When `do_blocks()` is run, it sets up some special handling of the `wpautop` filter, as we don't want `wpautop` to run on block content, but we do want it to be available for subsequent runs of `the_content`, which may be happening on non-block content.

As we set this up before rendering dynamic blocks, however, a dynamic block choosing to run `the_content` will cause unintentially structural deficiences in this particular recursive block tower.

Moving this handling to after dynamic blocks are rendered makes our tower lean a little less.

Props aldavigdis, pento.
Fixes #45495.



git-svn-id: https://develop.svn.wordpress.org/trunk@45139 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 06:53:14 +00:00
Gary Pendergast 3652d05fcf HTTP: Add support for the `host-only` flag to `Wp_Http_Cookie`.
Props soulseekah.
Fixes #43231.


git-svn-id: https://develop.svn.wordpress.org/trunk@45135 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 05:31:35 +00:00
Gary Pendergast 11e97aae1e Emoji: Update Twemoji to version 12.0.0.
Props pento, superpoincare.
Fixes #46404, #46805.


git-svn-id: https://develop.svn.wordpress.org/trunk@45134 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 05:21:49 +00:00
Gary Pendergast 65e057daa2 Canonical: Ensure redirect query keys are URL encoded.
This prevents an infinite redirect loop when a request containing URL-encoded characters triggers `is_404()`.

Props soulseekah, wrwrwr0.
Fixes #43745.


git-svn-id: https://develop.svn.wordpress.org/trunk@45133 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 01:09:01 +00:00
Sergey Biryukov f6f02a327f Docs: Remove an empty line between `@param` and `@return` in the tests added in [45101], per documentation coding standards.
See #45029.

git-svn-id: https://develop.svn.wordpress.org/trunk@45103 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-02 22:21:19 +00:00
Sergey Biryukov ffbc0e3b4e Widgets: Make sure changes to media widgets' instance schema via `widget_{$this->id_base}_instance_schema` filter are not overridden by subclasses.
Add unit tests missed in [45100].

Props Toro_Unit, birgire.
See #45029.

git-svn-id: https://develop.svn.wordpress.org/trunk@45101 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-02 22:14:19 +00:00
Sergey Biryukov ee5f858436 PHPCS: Fix WPCS violation in [45088].
See #38168.

git-svn-id: https://develop.svn.wordpress.org/trunk@45090 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-01 16:48:32 +00:00
Sergey Biryukov 28e7acf168 Customize: Only add `custom-background` to `body_class()` if the current theme supports custom background.
Props wido, swissspidy, ocean90, Mte90.
Fixes #38168.

git-svn-id: https://develop.svn.wordpress.org/trunk@45088 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-01 16:17:11 +00:00
Mike Schroder 2a7aedc9e0 Media: Improve and fix rotate/flip image tests
Fix off-by-one error in pixel color checks for rotate and flip image tests.
Change to using PNG with single pixel to ensure that errors are caught in the future, rather than lost in JPEG noise.

Props Fuegas, mikeschroder.
Fixes #46073.

git-svn-id: https://develop.svn.wordpress.org/trunk@45067 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-29 02:48:08 +00:00
John Blackbourn 6e0e4c9cee Options, Meta APIs: Remove an accidental short array syntax in the tests.
See #43561


git-svn-id: https://develop.svn.wordpress.org/trunk@45065 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-28 22:02:10 +00:00
John Blackbourn 8af4ca2f4c Options, Meta APIs: Ensure the `$object_id` parameter passed to the `delete_{$meta_type}_meta` and `deleted_{$meta_type}_meta` filters is always an integer.
Props salcode

Fixes #43561


git-svn-id: https://develop.svn.wordpress.org/trunk@45064 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-28 21:58:45 +00:00
Sergey Biryukov 502784dbd1 PHPCS: Fix WPCS violations in [45062].
See #46056.

git-svn-id: https://develop.svn.wordpress.org/trunk@45063 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-28 21:56:17 +00:00
Sergey Biryukov 87d4d0ae92 Privacy: Ensure the personal data export email is sent in the locale of the user whose data is being exported (or the site's default locale if they are not a registered user) when the administrator fulfilling the request uses a different locale.
Props garrett-eclipse.
Fixes #46056.

git-svn-id: https://develop.svn.wordpress.org/trunk@45062 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-28 21:28:37 +00:00
Sergey Biryukov b957460b7b Privacy: Ensure the privacy data erase fulfillment email is sent in the locale of the user whose data is being erased (or the site's default locale if they are not a registered user) when the administrator fulfilling the request uses a different locale.
Props desrosj, birgire, garrett-eclipse.
Fixes #44721.

git-svn-id: https://develop.svn.wordpress.org/trunk@45039 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-27 19:41:01 +00:00
Andrea Fercia e2aa3c5efe Accessibility: Improve the "Alt text" description.
Moves the word "Describe" within the link.

Amends [44900].
See #41612.


git-svn-id: https://develop.svn.wordpress.org/trunk@45038 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-27 18:46:12 +00:00
John Blackbourn 6a3bab9848 Docs: Correct some documentation typos.
See #46543


git-svn-id: https://develop.svn.wordpress.org/trunk@45035 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-27 17:08:04 +00:00
Sergey Biryukov 7ad9fb7e7c Themes: Remove `itemprop="url"` from `get_custom_logo()` output.
Making incorrect assumptions about microdata used in a theme results in invalid markup.

The attribute can still be added using the `get_custom_logo` or `wp_get_attachment_image_attributes` filter, but it should not be added by default.

Props henry.wright, tfrommen, afercia, markcallen, zodiac1978.
Fixes #37305.

git-svn-id: https://develop.svn.wordpress.org/trunk@45028 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-27 12:15:15 +00:00
Sergey Biryukov 368ea6bfc5 Build/Test Tools: Display an error message with a recommendation to run `grunt build` when trying to run WordPress core tests without the `/build/` directory.
Props davidbaumwald.
Fixes #46593.

git-svn-id: https://develop.svn.wordpress.org/trunk@45020 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-26 23:52:03 +00:00
Adam Silverstein 7793e670b8 Multisite: add new `sites_pre_query` and `networks_pre_query` filters to short circuit WP_Site_Query and WP_Network_Query queries.
Similar to the `posts_pre_query` filter for WP_Query added in #36687. These filters lets you short circuit the queries to return your own results.

Add a new filter `sites_pre_query` - which returns null by default. Return a non-null value to bypass WordPress's default `get_sites` queries.

Developers should note that filtering functions that require pagination information are encouraged to set the `found_sites` property of the `WP_Site_Query` object, passed to the filter by reference. If `WP_Site_Query` does not perform a database query, it will not have enough information to generate these values itself.

Add a new filter `networks_pre_query` - which returns null by default. Return a non-null value to bypass WordPress's default `get_networks` queries.

Developers should note that filtering functions that require pagination information are encouraged to set the `found_networks` property of the `WP_Network_Query` object, passed to the filter by reference. If `WP_Network_Query` does not perform a database query, it will not have enough information to generate these values itself.

Props spacedmonkey.
Fixes #45749.



git-svn-id: https://develop.svn.wordpress.org/trunk@44983 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-22 17:25:38 +00:00
Felix Arntz 4be7a863ff Bootstrap/Load: Fix WPCS violation in a new test following [44973].
See #46130.


git-svn-id: https://develop.svn.wordpress.org/trunk@44974 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-21 21:59:12 +00:00
Felix Arntz 1f3912e9bf Bootstrap/Load: Introduce a recovery mode for fixing fatal errors.
Using the new fatal handler introduced in [44962], an email is sent to the admin when a fatal error occurs. This email includes a secret link to enter recovery mode. When clicked, the link will be validated and on success a cookie will be placed on the client, enabling recovery mode for that user. This functionality is executed early before plugins and themes are loaded, in order to be unaffected by potential fatal errors these might be causing.

When in recovery mode, broken plugins and themes will be paused for that client, so that they are able to access the admin backend despite of these errors. They are notified about the broken extensions and the errors caused, and can then decide whether they would like to temporarily deactivate the extension or fix the problem and resume the extension.

A link in the admin bar allows the client to exit recovery mode.

Props timothyblynjacobs, afragen, flixos90, nerrad, miss_jwo, schlessera, spacedmonkey, swissspidy.
Fixes #46130, #44458.


git-svn-id: https://develop.svn.wordpress.org/trunk@44973 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-21 21:52:07 +00:00
Sergey Biryukov 393738de41 PHPCS: Remove extra spaces added in [44966].
See #44005.

git-svn-id: https://develop.svn.wordpress.org/trunk@44968 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-21 20:19:16 +00:00
Sergey Biryukov 65bd3654cc Privacy: Introduce Privacy Policy page helpers:
* `is_privacy_policy()` template tag
* `privacy-policy.php` template
* `.privacy-policy` body class
* `.menu-item-privacy-policy` menu item class

Props garrett-eclipse, birgire, xkon, Clorith.
Fixes #44005.

git-svn-id: https://develop.svn.wordpress.org/trunk@44966 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-21 19:47:29 +00:00
K. Adam White 49d8c2590c REST API: Avoid undefined-property notice when setting parent term to 0.
Only try to access `term_id` once `$parent_term` is known to be a `WP_Term`.

Props dlh, earnjam.
Fixes #44983.


git-svn-id: https://develop.svn.wordpress.org/trunk@44965 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-21 18:58:50 +00:00
Jonathan Desrosiers 689ba4eec6 Posts, Post Types: Add type parameter to `post_exists()`.
This allows post exists checks scoped to a specific post type.

Props sgarza, birgire, swissspidy.
Fixes #37406.

git-svn-id: https://develop.svn.wordpress.org/trunk@44959 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-21 12:43:48 +00:00
Adam Silverstein e6ec0b2fe0 Build: correct some linting errors.
Fix linting failures after r44948 by running `composer run format`.


git-svn-id: https://develop.svn.wordpress.org/trunk@44951 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 22:05:58 +00:00
adamsilverstein d1de972555 Feeds: ensure build/update date matches current query.
Displaying the correct build date in feeds is as important today as it was twelve years ago when this ticket was opened.

Fix an issue where all feeds in WordPress showed the same date for their last build date (the datapoint is `lastBuildDate`, `updated` or `dc:date` depending on the feed type). 

Introduce a new `get_last_build_date` filter to adjust the date used for `lastBuildDate`. Developers who previously filtered `get_lastcommentmodified` to alter feed dates should use this filter instead.

* `get_last_build_date` extracts the latest post (or comment) in the current WP_Query object.
* In all feed templates, use `get_last_build_date` vs `get_lastpostmodified( 'GMT' );`.

Props stevenkword, spacedmonkey, ryanshoover, mauteri, nacin, jorbin, MikeNGarrett, Denis-de-Bernardy, peaceablewhale.
Fixes #4575.



git-svn-id: https://develop.svn.wordpress.org/trunk@44948 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 20:37:02 +00:00
Adam Silverstein 7d0d69af4a Media: grid view attachment filter drop down - only show available mime types.
In the media library gird view, properly limit the media attachment filter to available mime types, matching the list view.

Props itzmekhokan.
Fixes #43658.


git-svn-id: https://develop.svn.wordpress.org/trunk@44947 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 20:06:22 +00:00
John Blackbourn 4b2a7d4ab6 Build/Test tools: Add support for passing a `WP_Error` object to `wp_die()` during tests.
This brings the functionality inline with `wp_die()` during non-test usage.

Fixes #46460


git-svn-id: https://develop.svn.wordpress.org/trunk@44944 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 18:22:11 +00:00
Jonathan Desrosiers 34251aa2ab Tests: Fix failing tests for privacy export/erase requests when running the `ajax` group for multisite.
Props davidbinda, garrett-eclipse.
Fixes #43438.

git-svn-id: https://develop.svn.wordpress.org/trunk@44943 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 17:40:17 +00:00
Andrea Fercia 7834856fcb Accessibility: Ensure embed iframes have a title attribute.
Screen reader users rely on the iframe title attribute to describe the contents of iframes. A meaningful title attribute allows to quickly identify the iframe content, so users can determine which iframe to enter and explore in detail or skip if desired.
Note: this is the only case where a title attribute is required for compliance with the W3C Web Content Accessibility Guidelines (WCAG).

- checks for oEmbed response of type `video` or `rich`
- checks if they use an iframe
- fetches the title (if any) from the oEmbed response
- adds the title to the embed iframe

Props bamadesigner, TomHarrigan, swissspidy, jrf, afercia.
Fixes #40245.


git-svn-id: https://develop.svn.wordpress.org/trunk@44942 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 17:21:56 +00:00
Boone Gorges 30c21d2031 Posts: Avoid the use of globals in `get_the_content()` and related functions.
This changeset introduces `$post` parameters to `get_the_content()` and
`wp_trim_excerpt()`. When a `$post` object is passed to one of these functions,
the functions will operate on the data from that object, rather than from the
post globals (`$authordata`, `$page`, etc). This ensures that the functions work
in a predictable manner when used outside of the regular post loop.

The global-mismatch problem is surfaced in cases where `get_the_excerpt()` is
called outside of the post loop, on posts that don't have a defined excerpt. In
these cases, the post globals - used to generate a fallback excerpt - may refer
to the incorrect object, resulting in PHP notices or other unpredictable
behavior. See #36934 for a related issue.

Props spacedmonkey, kraftbj, Shital Patel.
Fixes #42814.

git-svn-id: https://develop.svn.wordpress.org/trunk@44941 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 15:48:46 +00:00
K. Adam White 58aad3837f REST API: Ensure "Allow" header is returned for OPTIONS requests.
This changeset ensures `$request->set_url_params()` is called while fulfilling OPTIONS requests, where previously it was skipped because OPTIONS requests short-circuit the logic in `dispatch` which handles this setup for other request methods. Omitting the URL parameters prevented the Allow header from being set.

Props killua99, noisysocks.
Fixes #45753.


git-svn-id: https://develop.svn.wordpress.org/trunk@44933 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-19 03:21:28 +00:00
Andrea Fercia d26542632e Accessibility: Improve the "Hello Dolly" accessibility.
- adds a visually hidden text to give context to the lyrics
- the text is `Quote from Hello Dolly song, by Jerry Herman:`
- adds a `lang` HTML attribute (when the admin language is not English) to better support assistive technologies 
- adds a `dir` HTML attribute to better support the LTR English lyrics with RTL languages 
- CSS adjustments

Props audrasjb, SergeyBiryukov, danieltj, birgire, karmatosed, desrosj, afercia.
Fixes #43632.


git-svn-id: https://develop.svn.wordpress.org/trunk@44929 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-18 17:18:46 +00:00
Sergey Biryukov 6d2f78d9ba Docs: Add missing article in `setExpectedDeprecated()` DocBlock.
See #46543.

git-svn-id: https://develop.svn.wordpress.org/trunk@44923 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-17 13:10:44 +00:00
Sergey Biryukov aaf266db42 Docs: Correct `@param` name in `setExpectedIncorrectUsage()` DocBlock.
Props yoavf.
Fixes #46546.

git-svn-id: https://develop.svn.wordpress.org/trunk@44922 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-17 12:22:10 +00:00
Peter Wilson 13bb9c5ef4 Cron: Ensure identical single events aren't scheduled less than 10min apart.
Improves the logic in `wp_schedule_single_event()` to ensure an identical event is not scheduled within ten minutes.

This moves the logic for checking for identical events to be self contained rather than relying on `wp_next_scheduled()` as this fails to account for events with a past timestamp when wp-cron fails to trigger or for multiple identical events being scheduled already.

Props bodohugobarwich.
Fixes #44818.



git-svn-id: https://develop.svn.wordpress.org/trunk@44917 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-16 06:41:23 +00:00
Sergey Biryukov 7be4aabff6 Coding Standards: Minor code and performance improvements in `phpunit/includes/abstract-testcase.php`.
Props andizer.
Fixes #46500.

git-svn-id: https://develop.svn.wordpress.org/trunk@44916 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 22:13:30 +00:00
Sergey Biryukov 98e2fcf4fc Build/Test Tools: Add missing access modifiers in `phpunit/includes/wp-profiler.php`.
Props andizer.
Fixes #46505.

git-svn-id: https://develop.svn.wordpress.org/trunk@44915 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 21:58:01 +00:00
Jonathan Desrosiers 152e9d2b8f Privacy: Add unit tests for exporting and erasing personal data.
Props birgire, garrett-eclipse, desrosj.
Fixes #43438.

git-svn-id: https://develop.svn.wordpress.org/trunk@44909 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 18:07:09 +00:00
Jonathan Desrosiers b66ae2b4c1 Privacy: Allow new requests to be created after a user’s existing one has been completed.
When dealing with personal data exports and erasure requests, it is important to have a log of all the requests for a specific person. This is often required to confirm when and how many times requests were completed and fulfilled properly. 

This change allows a new request to be created after a previous data request has reached completed status (`request-completed`) instead of requiring admins to delete or re-initiate the existing request. The latter approach removes the historical log of requests for that user when creating a new request.

Full unit tests for the `wp_create_user_request()` function are also included.

Props garrett-eclipse, cc0a, birgire, desrosj.
Fixes #44707.

git-svn-id: https://develop.svn.wordpress.org/trunk@44906 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 16:26:55 +00:00
Sergey Biryukov 04a9083709 PHPCS: Remove extra space added in [44902].
See #46499.

git-svn-id: https://develop.svn.wordpress.org/trunk@44904 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 14:27:07 +00:00
Sergey Biryukov 1bfa9370f7 Build/Test Tools: Add missing access modifiers to factory classes in `phpunit/includes/factory`.
Props andizer.
Fixes #46504.

git-svn-id: https://develop.svn.wordpress.org/trunk@44903 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 12:15:08 +00:00
Sergey Biryukov 981ed3fbc6 Docs: Improve documentation for `phpunit/includes/abstract-testcase.php`.
Props andizer.
Fixes #46499.

git-svn-id: https://develop.svn.wordpress.org/trunk@44902 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 12:01:15 +00:00
Andrea Fercia 026abd4bc6 Accessibility: improve the "URL" and "Alt text" fields in the media modals.
Many users found the attachment URL field confusing: it says "URL" so it may appear like a field meant to paste a URL into.
Also, the Alt text field is the most important one in terms of content, while the Title field needs to be de-emphasized.

- changes the URL field label to "Copy link"
- moves the alt text field to the top as first field 
- avoids to set initial focus on the alt text field 
- adds an explanatory text with a link pointing to the W3C "alt decision tree" tutorial 
- adds `aria-describedby` to target the explanatory text
- adjusts the CSS accordingly
- updates the QUnit index.html file

Props melchoyce, audrasjb, afercia.
Fixes #41612.


git-svn-id: https://develop.svn.wordpress.org/trunk@44900 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 10:42:35 +00:00
Jonathan Desrosiers 1615233fa2 Privacy: Be less restrictive of the HTML tags allowed in user data exports.
Previously, only `a` and `br` tags were allowed in the `value` table cell for each field included in the HTML file generated when a user is exporting their personal data. Instead of relying on a hardcoded list of allowed tags, the `wp_kses()` call in `wp_privacy_generate_personal_data_export_group_html()` will now fallback to the default list of allowed tags (which includes `i`, `strong`, `em`, and other basic HTML formatting tags).

Also, a new context of `personal_data_export` will now be passed to the `wp_kses()` call. As a result, the list of HTML tags and attributes allowed in the export file can now be filtered using the `wp_kses_allowed_html` filter and checking for the `personal_data_export` context.

Fixes #44044.
Props tz-media, desrosj, pento, birgire, garrett-eclipse.

git-svn-id: https://develop.svn.wordpress.org/trunk@44824 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-08 22:04:50 +00:00
Jonathan Desrosiers a71fece6b8 Built/Test Tools: Add missing access modifiers to `abstract-testcase.php`.
Fixes #46384.
Props andizer.

git-svn-id: https://develop.svn.wordpress.org/trunk@44823 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-08 20:51:32 +00:00
Riad Benguella ccfb76d26f Block Editor: Fix unit tests after new blocks addition.
- Regenerate the REST API fixtures.
 - Remove the block registration hooks in the unit tests.

Refs #46429.


git-svn-id: https://develop.svn.wordpress.org/trunk@44812 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-07 11:53:15 +00:00
Jeremy Felt 716eea408b Multisite: Fix code formatting errors from r44805
See #46351.


git-svn-id: https://develop.svn.wordpress.org/trunk@44806 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-07 03:45:26 +00:00
Jeremy Felt 0d707e5da2 Multisite: Ensure `wpmu_new_blog` hook receives expected data in `$meta`.
Restores `public`, `archived`, `mature`, `spam`, `deleted`, `lang_id`, and `WPLANG` to the `$meta` data passed to `wpmu_new_blog`. This hook was deprecated in 5.1.0, but code using it still relies on this data.

Props david.binda, pbiron.
Fixes #46351.


git-svn-id: https://develop.svn.wordpress.org/trunk@44805 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-07 03:33:25 +00:00
Andrea Fercia 951b462ea2 Accessibility: Replace media placeholder clickable divs with buttons.
`<button>` elements are natively interactive, supported by any assistive technology, and must be used instead of non-semantic, non-accessible `<div>` elements.

Also, this change aligns the Media Widgets and the Customizer site icon and site logo controls with the design pattern used in the new Block Editor for similar controls.

Props ramonopoly, welcher, afercia.
Fixes #43151.


git-svn-id: https://develop.svn.wordpress.org/trunk@44796 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-05 17:49:00 +00:00
Jonathan Desrosiers 4a09766cb0 Privacy: Remove two test methods that fail on certain configurations.
The `test_detects_cannot_create_index()` and `tests_detects_cannot_write_html()` test methods are prone to failure under certain configurations, as discovered by the hosts reporting back the test suite results. This removes those two methods until a better approach to testing those scenarios can be created.

Partial revert of [44786].
See #44233.

git-svn-id: https://develop.svn.wordpress.org/trunk@44792 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-04 22:19:05 +00:00
Jonathan Desrosiers d80e627fdf Build/Test Tools: Fix validation error in multisite PHPUnit configuration file.
A PHPUnit configuration file with more than one `<php>` tag causes a validation error in PHPUnit versions 7.x. There are currently 2 in the `tests/phpunit/multisite.xml` file, which appears to be accidentally introduced in [29954].

Fixes #46414.

git-svn-id: https://develop.svn.wordpress.org/trunk@44790 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-04 21:32:02 +00:00
Jonathan Desrosiers 636af9078d Privacy: Add missing unit tests for exporting personal data.
Props allendav, birgire, iandunn, desrosj, garrett-eclipse.
Fixes 44233.

git-svn-id: https://develop.svn.wordpress.org/trunk@44786 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-04 19:35:30 +00:00
Aaron Jorbin e421f262dc Replace usages of basename() with wp_basename() in order to support multibyte filenames
This is focused on the pieces of code that touch media files and the tests that support them. `basename` isn't multibyte compatible out of the box. See http://php.net/basename and https://bugs.php.net/bug.php?id=62119.

See #43170.
Props Viper007Bond.


git-svn-id: https://develop.svn.wordpress.org/trunk@44785 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-01 20:57:26 +00:00
Peter Wilson 41e264fe55 Build: Fix formatting issues introduced in [44740].
See #46218.



git-svn-id: https://develop.svn.wordpress.org/trunk@44744 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-14 00:41:15 +00:00
Peter Wilson 3ec3100195 Build: Remove source map from `jquery.form.min.js`.
Minimize jquery.form.js as part of build process to remove the source map reference. 

Modify source map tests to include all JavaScript files rather than testing Backbone and jQuery only.

Props pento.
Fixes #46218.



git-svn-id: https://develop.svn.wordpress.org/trunk@44740 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-14 00:06:39 +00:00
Gary Pendergast d2f41560d3 Formatting: Loosen the type checking in `_sanitize_text_fields()`.
[44618] added strict type checking to `_sanitize_text_fields()`, which has caused some compat issues with plugins.

We can loosen the type checking to only reject objects and arrays, and cast other types to string.

Props Nick_theGeek, pento.
Fixes #41450.



git-svn-id: https://develop.svn.wordpress.org/trunk@44731 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-07 23:34:22 +00:00
Gary Pendergast 6b2c62eee2 Multisite: After creating a new blog, ensure the blog cache is correctly cleaned up.
Props david.binda, spacedmonkey.
Fixes #46125.



git-svn-id: https://develop.svn.wordpress.org/trunk@44727 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-07 06:03:32 +00:00
Sergey Biryukov 3e19129dc9 Build/Test Tools: Display a message about currently supported PHPUnit branch to avoid fatal errors on later versions.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@44723 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-03 22:40:56 +00:00
Sergey Biryukov 4b8e33fbee Build/Test Tools: Move `WP_UnitTestCase_Base::assertPostConditions()` to a more appropriate place.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44719 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 14:30:42 +00:00
Felix Arntz 0612ea2d38 Bootstrap/Load: Revert fatal error recovery mechanism from 5.1 to polish for 5.2.
Due to the high number of follow-up tickets and associated security concerns, it was decided to reschedule the fatal error recovery feature for WordPress 5.2, in order to address these issues properly. The feature will continue to be developed, with iterations being merged into trunk early in the 5.2 release cycle.

Fixes #46141. See #44458, #45932, #45940, #46038, #46047, #46068.


git-svn-id: https://develop.svn.wordpress.org/trunk@44717 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 11:00:30 +00:00
Sergey Biryukov b9b66b159b Build/Test Tools: Simplify `WP_PHPUnit_Util_Getopt` and update documentation.
Introduced in [918/tests] and updated in [26871], the class is there to make sure that known bugs are not skipped when `phpunit` is called with a `--group` that corresponds to an `@ticket` annotation (such as `phpunit --group 12345`).

Enforcing recognized arguments or correctly formed arguments is not the concern here, so reusing `PHPUnit_Util_Getopt::parseLongOption()` was superfluous.

See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44715 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 00:53:52 +00:00
Peter Wilson 99450a446d Customize: Remove `wp_targeted_link_rel` pre-save filter from change-sets.
The pre-save filters added to links in [43732] could invalidate JSON data when saving Customizer change-sets.

This removes the filters when saving and publishing change-sets.

Props peterwilsoncc, nikeo for testing.
See #45292.



git-svn-id: https://develop.svn.wordpress.org/trunk@44714 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-29 21:28:57 +00:00
Gary Pendergast 9efcfbbf3f Tests: Fix the tests for the `c` and `r` formats in `date_i18n()`.
To test the `date_i18n()` output correctly, the tests added in [43434] need to set a non-UTC timezone.

Props Rarst.
Fixes #20973.



git-svn-id: https://develop.svn.wordpress.org/trunk@44710 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-29 01:19:30 +00:00
Sergey Biryukov 6e80f7cebf Build/Test Tools: Don't throw an exception for unrecognized options in `WP_PHPUnit_Util_Getopt::parseLongOption()`.
The method is only used for two known options: `group` and `exclude-group`, others should be passed to PHPUnit.

Props johnbillion.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44707 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 18:49:22 +00:00
Sergey Biryukov ad71116f38 Coding Standards: Replace spaced indentation sections of `phpunit.xml.dist`, `multisite.xml`, and `build.xml` with tabs.
Props netweb, desrosj.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44705 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 17:20:06 +00:00