Commit Graph

3325 Commits

Author SHA1 Message Date
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
Sergey Biryukov e4813189c3 Build/Test Tools: Reorder `<file>` and `<exclude>` rules in `multisite.xml` to avoid warnings in PHPUnit 7.2+.
Missed in [44702].

See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44704 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 17:19:14 +00:00
Sergey Biryukov 48070a45a9 Build/Test Tools: Correct `WP_Test_REST_Schema_Sanitization::test_type_string()` to check for both `1.1` float and `'1.10'` string explicitly.
Previously, the test only passed due to a bug in PHPUnit 7.1.x and older versions.

Fixes #43218. See #38586.

git-svn-id: https://develop.svn.wordpress.org/trunk@44703 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 16:53:14 +00:00
Sergey Biryukov 001c6498e8 Build/Test Tools: Add support for PHPUnit 7.x.
* Create an abstract `WP_UnitTestCase_Base` class to share between PHPUnit 7.x and older versions.
* Add a speed-trap loader to determine which `SpeedTrapListener` class needs to be loaded for the current PHPUnit version.
* Remove unnecessary `PHPUnit\Util\Test` and `PHPUnit_Util_Getopt` inheritances.
* Update Travis CI config to use PHPUnit 7.x for PHP 7.1, 7.2, and nightly PHP versions.

Props jipmoors, netweb, desrosj, ayeshrajans, soulseekah, SergeyBiryukov.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44701 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 14:10:24 +00:00
Peter Wilson 554ee5b53c Cron: Move logic for finding the next event's timestamp.
Moves the logic for determining when an event will next run from `wp_next_scheduled()` to `wp_get_scheduled_event()`.

This improves the performance of `wp_get_scheduled_event()` by avoiding duplicate function calls and object cache hits.

Props peterwilsoncc.
Fixes #45976.


git-svn-id: https://develop.svn.wordpress.org/trunk@44693 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-23 23:07:39 +00:00
Peter Wilson bb463b5265 Formatting: Prevent `wp_targeted_link_rel()` adding an empty attribute.
Bypass adding a `rel` attribute when the `wp_targeted_link_rel` filter returns an empty string or other falsy result.

Props mcmwebsol, spartank, meatman89fs.
Fixes #45352.


git-svn-id: https://develop.svn.wordpress.org/trunk@44691 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-22 21:54:26 +00:00
Felix Arntz fbe0605156 Bootstrap/Load: Fix fatal error when passing a `WP_Error` to `wp_die()`.
This was introduced in [44466]. Also, this changeset adds tests for `_wp_die_process_input()` so that this never happens again.

Props dd32.
See #45933.


git-svn-id: https://develop.svn.wordpress.org/trunk@44690 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-22 08:51:56 +00:00
Sergey Biryukov 44ce02e28a PHPCS: Fix formatting issues introduced in [44670].
See #44914.

git-svn-id: https://develop.svn.wordpress.org/trunk@44672 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 19:56:47 +00:00
Sergey Biryukov 8fe01c0621 Post Formats: Prevent Bulk Edit from unintentionally changing post format to Standard even if set to "No change".
Correct the logic in [41187].

Props birgire, mukesh27, lanche86.
Fixes #44914. See #41396.

git-svn-id: https://develop.svn.wordpress.org/trunk@44670 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 18:04:55 +00:00
Peter Wilson 7d8ce1e287 Options: Avoid unnecessary DB calls when updating network options.
Adds a `maybe_serialize()` comparison for the old and new values in `update_network_option()` to avoid unnecessary database writes when options contain identical objects.

Props bor0.
Fixes #44956.



git-svn-id: https://develop.svn.wordpress.org/trunk@44662 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 04:26:33 +00:00
Gary Pendergast 9dfde992ee Comments: Show the "awaiting moderation" message when comment cookies are disabled.
The "Your comment is awaiting moderation." message relied upon the comment author cookie being set. However, since it's now possible to opt-out of that cookie, submitting a comment won't show the comment preview when the comment is placed in moderation.

To avoid this issue, we now include a hash in the redirect URL, allowing the site to identify that a preview of the moderated comment should be displayed.

Props imath, tomdxw, birgire, lakenh, azaozz, pento.
Fixes #43857.



git-svn-id: https://develop.svn.wordpress.org/trunk@44659 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 01:33:50 +00:00
Gary Pendergast 19645a4790 Tests: Add tests for the `__return*()` functions.
Props pbearne, mukesh27.
Fixes #46043.



git-svn-id: https://develop.svn.wordpress.org/trunk@44658 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 00:32:33 +00:00
Andrea Fercia 6dde7cd74f Build/Test Tools: Update QUnit index file after [43174].
Updates the last occurrence of "(opens in a new window)" to "(opens in a new tab)".

See #43803.


git-svn-id: https://develop.svn.wordpress.org/trunk@44655 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-19 15:27:11 +00:00
Gary Pendergast 2ec6c8f3d3 Build Tools: Upgrade WPCS to 2.0.0.
A few sniffs have been renamed, this change includes the relevant `phpcs:ignore` comment updates.

Fixes #46002.



git-svn-id: https://develop.svn.wordpress.org/trunk@44645 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-18 02:14:24 +00:00
Gary Pendergast d3ee420c14 Emoji: Upgrade Twemoji to 11.2.0.
This upgrade includes general improvements to the style of a variety of emoji.

Full changelog: https://github.com/twitter/twemoji/compare/v11.0.0...v11.2.0

Props desrosj, pento.
Fixes #45133.



git-svn-id: https://develop.svn.wordpress.org/trunk@44644 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-18 01:41:41 +00:00
Jonathan Desrosiers 3e390cdf9b Tests: Do not include the delimiter parameter in `ucwords()` calls.
This parameter is not supported in PHP < 5.4. Introduced in [44641].

See #44672.

git-svn-id: https://develop.svn.wordpress.org/trunk@44642 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 21:44:30 +00:00
Jonathan Desrosiers 83cfc77500 REST API: Allow a user to change the letter casing of their email.
When a `PUT` request is performed to update a user, a `rest_user_invalid_email` error is incorrectly being returned when the email exists with different letter casing, even if it belongs to the user being updated. `email_exists()` performs a case insensitive lookup, but the conditional statement following that lookup was performing a strict comparison between the new email and the user’s current email.

This changes that comparison to instead compare the user ID returned by `email_exists()` with the user ID being updated. This more closely matches the logic used in `edit_user()` and allows a user to change the letter casing of their email.

Props fuchsws, rachelbaker, desrosj.
Fixes #44672.

git-svn-id: https://develop.svn.wordpress.org/trunk@44641 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 21:24:47 +00:00
Gary Pendergast bcba20dd2b Docs: Fix the last handful of incorrect `@since 5.0.0` docblock tags.
Props peterwilsoncc.
Fixes #45543.



git-svn-id: https://develop.svn.wordpress.org/trunk@44635 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 06:45:58 +00:00
Gary Pendergast 2e63f69564 Tests: Ensure meta keys are cleaned up after each test.
Props jnylen0.
Fixes #46007.



git-svn-id: https://develop.svn.wordpress.org/trunk@44633 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 04:33:42 +00:00
Jonathan Desrosiers 06371823e3 Privacy: Allow column sorting in the privacy request admin tables.
This allows users to sort the export and erase personal data request tables by “Requester” (`post_title`, or user email) and “Requested” (`post_date`, or when the request was created), which can be helpful when sites have many requests present.

Props birgire, ianbelanger, pbiron, desrosj.
Fixes #43405.

git-svn-id: https://develop.svn.wordpress.org/trunk@44628 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-16 17:51:56 +00:00
Gary Pendergast afa551294e Formatting: Add type checking to `_sanitize_text_fields()`.
When a non-string value is passed, return an empty string.

Props Mte90.
Fixes #41450.



git-svn-id: https://develop.svn.wordpress.org/trunk@44618 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-16 06:04:51 +00:00
Gary Pendergast e79bddcb02 Users: Add extra checking to `wp_new_user_notification()`.
Prevent a notification from being sent when an unrecognised value is passed in the `$notify` parameter.

Props cthreelabs, 360zen.
Fixes #44293.



git-svn-id: https://develop.svn.wordpress.org/trunk@44611 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-16 04:26:48 +00:00
Gary Pendergast f418ee12b1 Link Template: In `get_adjacent_post()`, move the sanitisation of `$excluded_terms` earlier.
This is a followup to [42828], ensuring that the `get_{$adjacent}_post_excluded_terms` filter is always passed an array, as expected.

Props soulseekah, zottto.
Fixes #43521.



git-svn-id: https://develop.svn.wordpress.org/trunk@44591 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-15 01:53:02 +00:00
Gary Pendergast 5cdc0e1397 Query: Cache the result when `get_pages()` doesn't find anything in the database.
Props flixos90, soulseekah.
Fixes #43514.



git-svn-id: https://develop.svn.wordpress.org/trunk@44587 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 23:26:20 +00:00
Jonathan Desrosiers dd85c357d8 Tests: Add missing `parent::tearDown()`.
Also, remove a `tearDown()` method that was not serving any purpose.

Fixes #45931.

git-svn-id: https://develop.svn.wordpress.org/trunk@44584 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 21:33:56 +00:00
Gary Pendergast 065e7817c4 Customizer: Fix a coding standards issue introduced in [44580].
See #40020.




git-svn-id: https://develop.svn.wordpress.org/trunk@44582 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 07:22:03 +00:00
Gary Pendergast f5f5da1fff Customizer: Improve browser compatibility of the preview iframe.
When `home` and `siteurl` are different, the customizer preview iframe will be blank in Chrome and Safari, due to their `X-Frame-Options` implementation quirks.

Changing this to `SAMEORIGIN` and adding the `frame-ancestors` Content Security Policy gives the correct behaviour.

Props fullyint.
Fixes #40020.



git-svn-id: https://develop.svn.wordpress.org/trunk@44580 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 06:37:30 +00:00
Gary Pendergast 4550488c99 Widgets: Don't log invalid HTML in the Text Widget.
[41215] supresses these irrelevant error messages from the front end, this removes them from the error log, too.

Props jeherve.
Fixes #43815.



git-svn-id: https://develop.svn.wordpress.org/trunk@44578 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 05:04:12 +00:00
Gary Pendergast e547ecc791 Tests: Add missing `parent::setUp()` calls to all test classes.
Props johnbillion, birgire.
Fixes #37375.



git-svn-id: https://develop.svn.wordpress.org/trunk@44577 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 04:54:01 +00:00
Gary Pendergast a139c8cbf7 Coding Standards: Fix and whitelist variable names.
From the `WordPress.NamingConventions.ValidVariableName` sniff, this commit fixes/whitelists all `NotSnakeCaseMemberVar`, `MemberNotSnakeCase`, and `StringNotSnakeCase` violations. It also fixes a handful of the `NotSnakeCase` violations.

See #45934.



git-svn-id: https://develop.svn.wordpress.org/trunk@44573 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-12 06:05:55 +00:00
Gary Pendergast ff53bd388c Coding Standards: Extract `extract()` from the codebase.
Of the last four instances of `extract()` occurring, three of them are removed by this commit, and the fourth is appropriately documented.

See #45934.



git-svn-id: https://develop.svn.wordpress.org/trunk@44569 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-12 03:19:23 +00:00
Jonathan Desrosiers 34e3de7b7f REST API: Encourage proper usage of `register_rest_route()`.
Calling `register_rest_route()` too early in the loading process has the potential to cause some unintentional problems and pitfalls. Because `register_rest_route()` calls `rest_get_server()` (which creates the `WP_REST_Server` instance), calling the function directly and/or before `rest_api_init` should be discouraged.

For example, if `register_rest_route ()` is called on `init`, the REST API server instance is set up (and all functions added to `rest_api_init` and other related hooks are invoked), even though the current request may not be a REST request. Also, if `register_rest_route()` is called even earlier (say, in an `mu-plugin` file), required endpoints may be missing since normal plugins have not yet been loaded and have not had a chance to register their own action hooks.

This adds a `_doing_it_wrong()` notice the first time `register_rest_route()` is called before `rest_api_init` in a request to encourage best practices for registering REST API routes.

Props kraftbj, desrosj, timothyblynjacobs.
Fixes #45265.

git-svn-id: https://develop.svn.wordpress.org/trunk@44568 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 18:18:41 +00:00
Gary Pendergast 6f0487c2f0 Coding Standards: Ignore the violations of `Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase`.
See #45934.



git-svn-id: https://develop.svn.wordpress.org/trunk@44563 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 06:07:50 +00:00
Gary Pendergast 65f5fcb0fb Coding Standards: Ignore the single WordPress.PHP.RestrictedPHPFunctions.create_function_create_function violation.
This is intentional, for older PHP support.

See #45934.


git-svn-id: https://develop.svn.wordpress.org/trunk@44560 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 03:44:20 +00:00
Gary Pendergast 63fbf4a316 Coding Standards: Remove PHPCS 2.x `@codingStandardsIgnore*` ignore syntax.
Props netweb.
Fixes #42808.



git-svn-id: https://develop.svn.wordpress.org/trunk@44559 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 03:03:08 +00:00
Felix Arntz 6cc9452def General: Fix existing coding standard violations in bookmark tests, as outlined in [44546].
See #43977.


git-svn-id: https://develop.svn.wordpress.org/trunk@44547 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 21:16:49 +00:00
Felix Arntz 08564b5a80 General: Fix problematic string to array parsing.
WordPress has historically often used code like `preg_split( '/[\s,]+/', $var )` to parse a string of comma-separated values into an array. However, this approach was causing an empty string to not be parsed into an empty array as expected, but rather into an array with the empty string as its sole element.

This was among other areas causing problems in the REST API where passing an empty request parameter could cause that request to fail because, instead of it being ignored, that parameter would be compared against the valid values for it, which typically do not include an empty string.

Props david.binda, sstoqnov.
Fixes #43977.


git-svn-id: https://develop.svn.wordpress.org/trunk@44546 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 21:05:50 +00:00
Jonathan Desrosiers 2fe6670aff REST API: Restore use of `wp_ajax_ajax_tag_search()` for tag search.
This solution does not work with custom taxonomies in the current state.

Reverts [42614,42619,42737].

Props danielbachhuber.
See #38922.

git-svn-id: https://develop.svn.wordpress.org/trunk@44537 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:36:40 +00:00
Gary Pendergast 0394aab7a8 Tests: Add support for a `WP_TESTS_SKIP_INSTALL` environment variable.
Defining `WP_TESTS_SKIP_INSTALL=1` when running tests will skip the install step. While this shouldn't be used for full test runs, it's useful for saving time when running small groups of tests.

Props soulseekah.
Fixes #43432.



git-svn-id: https://develop.svn.wordpress.org/trunk@44536 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:18:19 +00:00
Jonathan Desrosiers 0161a5b70f Privacy: Add unit tests for privacy erasure fulfillment notifications.
Adds appropriate unit tests for `_wp_privacy_send_erasure_fulfillment_notification()`.

Props birgire, desrosj.
Fixes #44234.

git-svn-id: https://develop.svn.wordpress.org/trunk@44535 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:06:44 +00:00
Gary Pendergast e88eb4a63f Build/Tests: Allow running unit tests from `src`.
This is a partial recommit of [44509]: it allows running unit tests from `src` (which is useful), but doesn't make it the default (which Travis is having issues with).

See #45863.



git-svn-id: https://develop.svn.wordpress.org/trunk@44534 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:03:25 +00:00
Jonathan Desrosiers 25e9a6d249 Media: Store audio creation date in meta.
In [41746], `wp_get_media_creation_timestamp()` was introduced to read the created timestamp for videos from `getID3` in meta whenever possible. This information is useful separately from the dates on the file itself.

This adds the same support audio files by utilizing `wp_get_media_creation_timestamp()` in `wp_read_audio_metadata()`.

Props blob folio, desrosj.
Fixes #42017.

git-svn-id: https://develop.svn.wordpress.org/trunk@44528 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 01:31:52 +00:00
Felix Arntz ffd2a4bd16 Bootstrap/Load: Fix missing object argument for singular capability checks and support capability tests overlooked in [44524].
See #44458.


git-svn-id: https://develop.svn.wordpress.org/trunk@44525 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 20:43:57 +00:00
Pascal Birchler 1264df85b3 Build/Test Tools: Fix coding standards issues after [44515] and [44514].
See #44494, #43743.


git-svn-id: https://develop.svn.wordpress.org/trunk@44516 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 12:36:43 +00:00
Pascal Birchler a8cb5d247e I18N: Add option to hide en_US locale in `wp_dropdown_languages()`.
Props danieltj for initial patch.
Fixes #44494.


git-svn-id: https://develop.svn.wordpress.org/trunk@44514 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 11:45:02 +00:00
Gary Pendergast 916695bd78 Tests: Revert [44509].
This commit causes Travis to fail.

See #45863.


git-svn-id: https://develop.svn.wordpress.org/trunk@44512 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 11:13:03 +00:00
Gary Pendergast ec7687b1d9 Tests: Improve REST API tests for categories and tags.
Props birgire, SergeyBiryukov.
See #39122.
Fixes #45077.



git-svn-id: https://develop.svn.wordpress.org/trunk@44510 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 10:30:49 +00:00
Gary Pendergast 0137c23f8d Build/Tests: Default to running unit tests from `src`.
This is the actual commit, unlike [44508], which was not.

Props atimmer.
See #44492.
Fixes #45863.


git-svn-id: https://develop.svn.wordpress.org/trunk@44509 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 10:13:13 +00:00
Gary Pendergast 62b4465532 Comments: Add new tests missed in [44499].
Props dshanske, birgire.
Fixes #44033.


git-svn-id: https://develop.svn.wordpress.org/trunk@44502 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 06:19:53 +00:00
Gary Pendergast e5bdc271cb Comments: Add a new `is_avatar_comment_type()` function.
This function splits the `get_avatar_comment_types` filter out of `get_avatar_data()`.

Props dshanske, birgire.
Fixes #44033.



git-svn-id: https://develop.svn.wordpress.org/trunk@44499 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 05:59:49 +00:00
Gary Pendergast ae62335191 Docs: Add docblocks for the PHPUnit factory objects.
Props andizer.
Fixes #44521.


git-svn-id: https://develop.svn.wordpress.org/trunk@44497 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 05:43:14 +00:00
Adam Silverstein f968e9d52f Media: improve the `human_readable_duration` function and tests.
Improve the `human_readable_duration` added in #39667:
* Remove upper limit.
* More resilient handling: remove negative prefix, trim.
* Correct @since to 5.1.0.
* Adds more test cases and improve inline docs.

Props birgire.
Fixes #39667.


git-svn-id: https://develop.svn.wordpress.org/trunk@44481 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 19:55:31 +00:00
Jonathan Desrosiers c7e92e437c Tests: Add missing test cases for `is_serialized_string()`.
Also, reorganize these tests into their own class.

Props pbearne.
Fixes #42870.

git-svn-id: https://develop.svn.wordpress.org/trunk@44478 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 19:04:51 +00:00
Gary Pendergast 07eb075961 Query: Fix some code formatting issues introduced in [44452].
See #38034.



git-svn-id: https://develop.svn.wordpress.org/trunk@44456 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 04:31:56 +00:00
Gary Pendergast a37ee6171e Permalinks: Add a `pre_wp_unique_post_slug` filter.
Returning a non-`null` value on this fillter will cause `wp_unique_post_slug()` to return early with that value, skipping potentially expensive database queries on some sites.

Props coffee2code, javorszky, iCaleb.
Fixes #21112.



git-svn-id: https://develop.svn.wordpress.org/trunk@44454 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 03:46:58 +00:00
Boone Gorges 082c5d1534 Query: Standardize treatment of 'orderby' values `post__in`, `post_parent__in`, and `post_name__in`.
Ordering by `post__in` was introduced in [21776], but the code assumed that
`post__in` would be a comma-separated string listing post IDs. When an array
of post IDs was passed to the `post__in` query var, 'orderby=post__in' was
not respected. This changeset changes this behavior by handling
'orderby=post__in' in the same way as most other values of 'orderby',
which ensures that arrays as well as strings can be properly parsed.

The same treatment is given to the similar `post_name__in` and
`post_parent__in` options of 'orderby', so that most query generation for
orderby clauses happens in the same place, instead of in special cases.

A slight change in the resulting SQL (related to the whitespace around
parentheses and commas) necessitates a change to an existing REST API test
that does a string comparison against the SQL query.

Props mgibbs189, kelvink.
Fixes #38034.

git-svn-id: https://develop.svn.wordpress.org/trunk@44452 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 03:32:04 +00:00
Gary Pendergast 09dd371fc0 REST API: Remove `permalink_structure` from the REST API settings endpoint.
This was ultimately fixed in #45017, so is redunant.

Reverts [42142,42359,42540].
See #41014.



git-svn-id: https://develop.svn.wordpress.org/trunk@44446 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 02:50:05 +00:00
Joe McGill 54fd47e1f1 Upload: Don't run some upload tests on multisite.
This moves several unit tests added in [44438] so they aren't run during multisite tests.

See #45615.


git-svn-id: https://develop.svn.wordpress.org/trunk@44442 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-07 21:41:40 +00:00
Joe McGill 843111a03b PHPCS: Fix formatting issues.
Fixes formatting issues introduced in [44438].

See #45615.


git-svn-id: https://develop.svn.wordpress.org/trunk@44441 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-07 21:08:03 +00:00
Joe McGill 5aa0b178e1 Upload: Add test files for phpunit.
This is a follow up to [44438], which missed adding the test files.

See #45615.


git-svn-id: https://develop.svn.wordpress.org/trunk@44439 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-07 20:52:35 +00:00
Joe McGill 94c8a5d994 Upload: Fix upload failures of common text file types.
This adds some special case handling in 'wp_check_filetype_and_ext()' that prevents some common file types from being blocked based on mismatched MIME checks, which were made more strict in WordPress 5.0.1.

Props Kloon, birgire, tellyworth, joemcgill.
See #45615.


git-svn-id: https://develop.svn.wordpress.org/trunk@44438 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-07 20:47:56 +00:00
Dominik Schilling (ocean90) 690b0cbf83 I18N/Script Loader: Support text domains other than "messages".
The inline JavaScript added by `WP_Scripts::print_translations()` should check whether `locale_data.$text_domain` exists and fall back to `locale_data.messages` otherwise.

Props swissspidy.
See #45441.

git-svn-id: https://develop.svn.wordpress.org/trunk@44403 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-06 16:22:46 +00:00
Jonathan Desrosiers b9c3486f73 REST API: Fix typo when unregistering test post type.
A typo when unregistering a test post type for the `WP_Test_REST_Posts_Controller` class was preventing it from being properly removed. `youseeme` now?

Props rahulsprajapati.
Fixes #45124.

git-svn-id: https://develop.svn.wordpress.org/trunk@44394 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-04 20:57:42 +00:00
Adam Silverstein 4589c03036 Users: Add a `users_pre_query` filter to short circuit WP_User_Query results.
Add a new filter `users_pre_query` - filters the users array before the query takes place. Return a non-null value to bypass WordPress's default user queries. Similar to the `posts_pre_query` filter for WP_Query added in #36687. This filter lets you short circuit the WP_User_Query MySQL query to return your own results.

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

Props tlovett1, birgire, boonebgorges, spacedmonkey.
Fixes #44169.


git-svn-id: https://develop.svn.wordpress.org/trunk@44373 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-29 16:05:50 +00:00
Drew Jaynes 5e3c64657a Docs: Remove references to the now-defunct `$merged_filters` global from two method DocBlocks in `WP_UnitTestCase`.
The `$merged_filters` global was removed in [38571].

Props frank-klein.
Fixes #44496.


git-svn-id: https://develop.svn.wordpress.org/trunk@44327 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-19 07:12:46 +00:00
Jonathan Desrosiers 0f349bd621 I18N: Fix JavaScript translations for subdirectory installations.
Fixes the `load_script_textdomain` function not resolving the md5 hash based on the relative path for WordPress installations in a subdirectory. Also adds a filter to allow sites using CDNs or other alternative asset locations to filter the relative path resolution.

Props akirk, fierevere, swissspidy, mypacecreator, babaevan, tmatsuur, ocean90, herregroen.

Merges [44209] to trunk.

Fixes #45528.

git-svn-id: https://develop.svn.wordpress.org/trunk@44310 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-18 23:09:51 +00:00
Jonathan Desrosiers 06f2b3f5bc Media: Improve verification of MIME file types.
Merges [43988] to trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@44292 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-18 16:34:17 +00:00
Jonathan Desrosiers 5c6cc0f6ce WPDB: Check that `$wpdb->last_result` is countable before counting with it.
`wpdb::get_col()` iterates over `$wpdb->last_result`, which can be a non-countable value, should the preceding query have failed.

Props spacedmonkey, desrosj, pento.

Merges [43934] into trunk.

See #45299.

git-svn-id: https://develop.svn.wordpress.org/trunk@44272 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 18:38:13 +00:00
Jonathan Desrosiers 2ae5bb324d REST API: Preserve unknown, respect `null` in server-side block rendering.
- Skips validation where there is no attribute definition, but keeps the attribute value. Previously, the attribute would be omitted from the attributes passed to `render_callback`. Notably, this resolves an issue where `render_callback` cannot receive a block's `align` and `customClassName` attribute values, since these are defined as a client-side filter.
- Validates `null` as a proper value in its own right. Previously, a client implementation of a block could track `{“attribute":null}` as an explicitly empty value, and the server would wrongly initiate defaulting behavior. The new behavior will now only populate a default value if the attribute is not defined at all, including when unset in its being invalid per the attribute schema. 

Props aduth, noisysocks, youknowriad, danielbachhuber.

Merges [43918] to trunk.

See #45145 for the patch, #45098 for the original ticket.

git-svn-id: https://develop.svn.wordpress.org/trunk@44269 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 17:59:44 +00:00
Jonathan Desrosiers abc29f4cef REST API: Always include `title.raw`/`content.raw` for Blocks in `context=view`.
Demarcations for reusable blocks are always expected to be accessible by clients.

Props noisysocks, youknowriad.

Merges [43917] to trunk.

See #45145 for the patch, #45098 for the original ticket.

git-svn-id: https://develop.svn.wordpress.org/trunk@44268 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 17:21:05 +00:00
Jonathan Desrosiers 572207384b Block Editor: Update `@wordpress` dependencies.
Changes of note:

- Includes the new Annotations API package.
- `wp-polyfill-ecmascript.js` is renamed to `wp-polyfill.js`.
- `strip_dynamic_blocks()` has been removed in favor of `excerpt_remove_blocks()`.
- The PHP block parser is now syncing from the `block-serialization-default-parser` package.
- `do_blocks()` uses the new parser.
- The `do_block` filter has been removed from `do_blocks()`, in favor of a `render_block` filter in `render_block()`.

Also, a little cleanup to `render_block()`. Always normalize `$block['attrs’]` to array in `’render_block’` filter.
Props pento, azaozz.

Merges [43884] and [43888] to trunk.

See #45145, #45190, #45264, #45282.

git-svn-id: https://develop.svn.wordpress.org/trunk@44261 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 04:50:48 +00:00
Sergey Biryukov 0ca5139e70 Tests: Replace use of `$this->server` with `rest_get_server()` in `test_get_additional_field_registration_null_schema()`.
In [42724], `$this->server` was replaced with `rest_get_server()` for better memory recycling.

[43908], from the 5.0 branch, was merged into trunk in [44254] and used the now unavailable `$this->server`.

This updates the new test from the 5.0 branch to use the expected `rest_get_server()`.

See #45220, #41641.

git-svn-id: https://develop.svn.wordpress.org/trunk@44256 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 01:41:10 +00:00
Sergey Biryukov e3e683fc09 Tests: Replace use of `$this->server` with `rest_get_server()` in `test_registered_query_params()`.
In [42724], `$this->server` was replaced with `rest_get_server()` for better memory recycling.

[43897], from the 5.0 branch, was merged into trunk in [44250] and used the now unavailable `$this->server`.

This updates the new test from the 5.0 branch to use the expected `rest_get_server()`.

See #43316, #41641.

git-svn-id: https://develop.svn.wordpress.org/trunk@44255 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 01:24:36 +00:00
Sergey Biryukov d79ec242e4 REST API: Include fields with null schema in `get_fields_for_response()`.
In [43736], we prevented rendering fields when not present in `?_fields=`. However, because `get_fields_for_response()` is dependent on `get_item_schema()`, any custom fields registered with a null schema would be incorrectly excluded from the response. Because the REST API permits a null schema for `register_rest_field()`, those fields should be included in the available fields for a response.

Props danielbachhuber.
Merges [43908] to trunk.
Fixes #45220.

git-svn-id: https://develop.svn.wordpress.org/trunk@44254 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 01:14:17 +00:00
Sergey Biryukov 961bc64adf PHPCS: Fix errors introduced in [44250].
See #43316.

git-svn-id: https://develop.svn.wordpress.org/trunk@44253 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 01:05:03 +00:00
Sergey Biryukov c2390f96a2 REST API: Avoid using 'parent' as path argument name for autosaves.
When 'parent' is set as the path argument name, it gets passed down through to the `create_item()` method and can erroneously reset the 'parent' value on the post itself. Instead, we rename the argument to 'id' and replicate the revision controller's `get_items_permissions_check()` to instead reference 'id'.

Also ensures revision query params (of which there are many) aren't exposed as the query params for autosaves (of which there are two).

Props TimothyBlynJacobs.
Merges [43897] to trunk.
See #43316.

git-svn-id: https://develop.svn.wordpress.org/trunk@44250 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 00:23:55 +00:00
Sergey Biryukov a10598acd0 I18N: Set translations for all WordPress packages scripts.
Calls `wp_set_script_translations` for all packages scripts that have translations. Also correctly sets the domain on the translations.

Props omarreiss, pento, ocean90.
Merges [43878] to trunk.
Fixes #45161.

git-svn-id: https://develop.svn.wordpress.org/trunk@44239 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 22:23:34 +00:00
Jeremy Felt 3bcf9f7e46 Tests: Replace uses of `$this->server` with `rest_get_server()`.
In [42724], `$this->server` was replaced with `rest_get_server()` for better memory recycling.

[43862], from the 5.0 branch, was merged into trunk in [44225] and used the now unavailable `$this->server`.

This updates the new tests from the 5.0 branch to use the expected `rest_get_server()`.

See #45269, #41641.


git-svn-id: https://develop.svn.wordpress.org/trunk@44234 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 18:53:58 +00:00
Jonathan Desrosiers cdaf0b6901 Tests: Update a test that relied on the Hello Dolly plugin version.
[43900] changed the plugin version, causing a unit test failure.

Merges [43902] to trunk.

See #45345.

git-svn-id: https://develop.svn.wordpress.org/trunk@44230 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 04:54:40 +00:00
Jeremy Felt 415f33c904 Formatting: Ensure `wpautop()` isn't run on content generated from blocks.
As `do_blocks()` is run before `wpautop()` in the_content filter, we can remove in a Just In Time fashion, before that filter is run.

After `wpautop()`s original priority has passed, we can re-add it in a Just Too Late fashion, to ensure it's available if `the_content` filter is run multiple times on a page load.

Merges [43879] and [43881] from the 5.0 branch to trunk.

Props pento, nerrad.
Fixes #45290.


git-svn-id: https://develop.svn.wordpress.org/trunk@44226 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 02:22:43 +00:00
Jeremy Felt deab4810d0 REST API: Prevent duplicate firing of `rest(_after)?_insert_attachment` actions.
Merges [43862] from the 5.0 branch to trunk.

Props danielbachhuber, peterwilsoncc.
Fixes #45269.
See #42864.


git-svn-id: https://develop.svn.wordpress.org/trunk@44225 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 02:16:16 +00:00
jeremyfelt 4212d597c5 REST API: Fix array syntax after [43851].
I thought I was writing JavaScript. Alas.

Merges [43852] from the 5.0 branch to trunk.

Props danielbachhuber.
See #45196.


git-svn-id: https://develop.svn.wordpress.org/trunk@44218 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 01:40:02 +00:00
Jeremy Felt de92919e02 REST API: Regenerate fixure schema after introduction of new endpoints.
This fixture schema ensures `wp-api-generated.js` doesn't change when running tests in local dev environments.

Merges [43851] from the 5.0 branch to trunk. `wp-api-generated.js` generated based on current trunk.
Props danielbachhuber.
Fixes #45196.


git-svn-id: https://develop.svn.wordpress.org/trunk@44217 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 01:37:56 +00:00
Anton Timmermans 9c6f855dbf Tests: Fix failing unit tests caused by [43840].
Props pento.
Merges [43841] to trunk.
See #45145.


git-svn-id: https://develop.svn.wordpress.org/trunk@44179 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 11:22:41 +00:00
Gary Pendergast fb2f48d81b Block Editor: Preload `wp/v2/media` with OPTIONS for caps check.
Also introduces a `block_editor_preload_paths` filter for plugins and themes to preload additional data.

Merges [43833] from the 5.0 branch to trunk.

Props imath, mattheu, danielbachhuber.
Fixes #45194.



git-svn-id: https://develop.svn.wordpress.org/trunk@44172 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 06:01:24 +00:00
Gary Pendergast 8d897837aa I18N: Add JavaScript translation support.
Adds the `wp_set_script_translations()` function which registers translations for a JavaScript file. This function takes a handle, domain and optionally a path and ensures JavaScript translation files are loaded if they exist.

Merges [43825,43828,43859,43898] from the 5.0 branch to trunk.

Props herregroen, atimmer, omarreiss, nerrad, swissspidy, ocean90, georgestephanis.
Fixes #45103, #45256.



git-svn-id: https://develop.svn.wordpress.org/trunk@44169 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 05:51:31 +00:00
Jonathan Desrosiers 2e78177467 Nav Menus: Fix a PHP 7.3 error when switching themes.
When switching themes, `wp_map_nav_menu_locations()` is used to ensure nav menus are placed in the relevant menu location. Occasionally, menus are registered to locations with numeric slugs, rather than strings. `wp_map_nav_menu_locations()` assumed it would be the latter, and ran `stripos()` on those numeric slugs. This behavior is deprecated in PHP 7.3.

As this is the last PHP 7.3 error in unit tests, this commit also removes PHP 7.3 from Travis' `allowed_failures` list.

Props pento, desrosj, jorbin.

Merges [43899] to trunk.

See #45018.

git-svn-id: https://develop.svn.wordpress.org/trunk@44167 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 05:15:54 +00:00
Jonathan Desrosiers 89d76b9884 PHP7.3 compatibility: Fix compact throwing notices.
In PHP 7.3, the `compact()` function has been changed to issue an `E_NOTICE` level error if a passed string refers to an unset variable. In previous versions of PHP, this notice was silently skipped. The full RFC can be viewed here: https://wiki.php.net/rfc/compact.

Props jorbin, desrosj.

Merges [43819] and [43832] to trunk.

Fixes #44416.

git-svn-id: https://develop.svn.wordpress.org/trunk@44166 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 05:12:12 +00:00
Gary Pendergast dc6b225023 Build Tools: Update the `@wordpress/*` packages.
Merges [43801,43803] from the 5.0 branch to trunk.

See #45145.



git-svn-id: https://develop.svn.wordpress.org/trunk@44163 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 04:42:55 +00:00
Jonathan Desrosiers 76525a75b7 Styles: Add helper functions for loading block styles.
Blocks are able to register styles that used in the editor and the frontend, or only in the editor. These functions ensure the correct styles are loaded in the correct place.

Props pento.

Merges [43812] to trunk.

See #45065.

git-svn-id: https://develop.svn.wordpress.org/trunk@44157 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:35:55 +00:00
Gary Pendergast 524f5be4c6 KSES: Allow the `download` attribute on `<a>` tags.
To avoid this being a vector for bypassing the filetypes that are allowed to be uploaded, this attribute is only allowed to be added without a value.

Merges [43813] from the 5.0 branch to trunk.

Props kalpshit, arshidkv12, welcher, peterwilsoncc, marina_wp, pento.
Fixes #44724.



git-svn-id: https://develop.svn.wordpress.org/trunk@44156 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:27:55 +00:00
Gary Pendergast 466ec7483a General: Fix some code formatting issues.
A handful of code formatting issues were introduced in recent commits, runs the auto-fixer on them.



git-svn-id: https://develop.svn.wordpress.org/trunk@44155 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:24:35 +00:00
Gary Pendergast f61cfa648c Embeds: Filter HTML response in oEmbed proxy controller.
Adapts the response from `WP_oEmbed_Controller::get_proxy_item()` so that the response is correctly filtered and embeds work properly in JavaSccript editors. Introduces new `get_oembed_response_data_for_url()` function for preparing internal oEmbed responses.

Merges [43810] from the 5.0 branch to trunk.

Props danielbachhuber, imath, swissspidy.
Fixes #45142.



git-svn-id: https://develop.svn.wordpress.org/trunk@44154 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:19:48 +00:00
Jonathan Desrosiers 88de9a1d7c Meta: Allow empty strings to be set by Custom Fields meta box.
Because the REST API allows meta keys to have empty values, the Custom Fields meta box should permit the same behavior.

Props charlestonsw, soulseekah, danielbachhuber.

Merges [43811] to trunk.

Fixes #43559.

git-svn-id: https://develop.svn.wordpress.org/trunk@44153 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:16:56 +00:00
Gary Pendergast c474d190e7 Bundled Themes: Make twentynineteen the default theme.
After [44149], we can now make twentynineteen the default theme. Twentyseventeen has been a great default, but 5.0 and twentynineteen is guten.

Merges [43809,43954] from the 5.0 branch to trunk.

Fixes #45152.
Props jorbin, SergeyBiryukov, pento, mcsf.



git-svn-id: https://develop.svn.wordpress.org/trunk@44151 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:48:14 +00:00
Jeremy Felt 7702b535be REST API: Add endpoints for blocks.
`WP_REST_Block_Renderer_Controller` allows rendering of server-side rendered blocks, whilst `WP_REST_Blocks_Controller` allows retrieving of reusable blocks.

Merges [43805] and [43806] from the 5.0 branch to trunk.

Props desrosj, danielbachhuber, pento, Presskopp, swissspidy.
See #45065, #45098.


git-svn-id: https://develop.svn.wordpress.org/trunk@44150 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:34:28 +00:00
Jeremy Felt 6a84afa33c Blocks: Add the reusable block post type, `wp_block`.
Merges [43804] from the 5.0 branch to trunk.

See #45098.


git-svn-id: https://develop.svn.wordpress.org/trunk@44146 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:14:13 +00:00
Jeremy Felt 82b3fac279 Themes: Introduce responsive embeds support.
Responsive embeds is a way for a theme to opt in to WordPress dynamically scaling the width/height of an embed. When a theme supports responsive embeds, a `wp-embed-responsive` class is added to the `<body>` tag. This information is also presented through the REST API for clients to respect.

Merges [43790] and [43791] from the 5.0 branch to trunk.

Props desrosj, danielbachhuber, ocean90.
Fixes #45125.


git-svn-id: https://develop.svn.wordpress.org/trunk@44138 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:49:46 +00:00
Gary Pendergast 79486d7656 KSES: Allow `url()` to be used in inline CSS.
The cover image block uses the `url()` function in its inline CSS, to show the cover image. KSES didn't allow this, causing the block to not save correctly for Author and Contributor users. As KSES does already check each attribute name against an allowed list, we're able to add an extra check for certain attributes to be able to use the `url()` function, too.

Merges [43781] from the 5.0 branch to core.

Props peterwilsoncc, azaozz, pento, dd32.
Fixes #45067.



git-svn-id: https://develop.svn.wordpress.org/trunk@44136 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 01:40:50 +00:00
Jeremy Felt 2f9a63bf87 REST API: Restore Autosaves controller test for multisite.
PHPUnit 3.6.x requires `exclude` and `file` paths to be relative to the checkout root.

PHPUnit 4.0.0+ requires the paths to be relative to the configuration file.

Merges [43774] from the 5.0 branch to trunk.

See #45131.


git-svn-id: https://develop.svn.wordpress.org/trunk@44128 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 00:57:50 +00:00
Gary Pendergast 63d9540fd8 REST API: Include `block_version` on Post `content` object.
The `block_version` denotes which version of Blocks the `post_content` contains. Introduces new `block_version()` function for versioning Blocks.

Merges [43770] from the 5.0 branch to trunk.

Props danielbachhuber, birgire.
Fixes #43887.


git-svn-id: https://develop.svn.wordpress.org/trunk@44127 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 00:54:51 +00:00
Jonathan Desrosiers 225f191f32 REST API: Introduce Autosaves controller and endpoint.
- Adds `WP_REST_Autosaves_Controller` which extends `WP_REST_Revisions_Controller`.
- Autosaves endpoint is registered for all post types except attachment because even post types without revisions enabled are expected to autosave.
- Because setting the `DOING_AUTOSAVE` constant pollutes the test suite, autosaves tests are run last. We may want to improve upon this later. 

Also, use a truly impossibly high number in User Controller tests. The number `100`, (or `7777` in `trunk`), could be valid in certain test run configurations. The `REST_TESTS_IMPOSSIBLY_HIGH_NUMBER` constant is impossibly high for this very reason.

Finally, Skip Autosaves controller test for multisite. There's a PHP 5.2 edge case where paths calculated differently, possibly caused by differing version of PHPUnit.

Props adamsilverstein, aduth, azaozz, danielbachhuber, rmccue, danielbachhuber.

Merges [43767], [43768], [43769] to trunk.

See #45132, #45131.
Fixes #45128, #43316.

git-svn-id: https://develop.svn.wordpress.org/trunk@44126 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 22:41:47 +00:00
Jonathan Desrosiers 08cc6047d1 REST API: Introduce the `rest_preload_api_request()` function.
This function helps perform multiple REST API requests, for the purpose of preloading data into a page.

Props pento.

Merges [43763] to trunk.

See #45110.

git-svn-id: https://develop.svn.wordpress.org/trunk@44123 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 20:46:19 +00:00
Jonathan Desrosiers ab070e219b Block Editor: Add helper functions for displaying the editor.
`use_block_editor_for_post()` and `use_block_editor_for_post_type()` determine if the block editor should be loaded.

`get_block_categories()` and `get_block_editor_server_block_settings()` provide data be included while the block editor is loading.

Props pento.

Merges [43762] to trunk.

See #45110.

git-svn-id: https://develop.svn.wordpress.org/trunk@44122 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 20:22:06 +00:00
Jonathan Desrosiers 93091fac36 Blocks: Parse blocks when displaying posts.
Posts containing blocks are now correctly handled when displaying on the front end, including dynamic blocks and nested blocks.

Props pento.

Merges [43752] to trunk.

See #45109.

git-svn-id: https://develop.svn.wordpress.org/trunk@44118 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 18:11:10 +00:00
Jonathan Desrosiers f8c9698722 Blocks: Introduce the block parser.
The `WP_Block_Parser` class, and the accompanying `parse_blocks()` helper function, can be used to parse an array of blocks out of a content string.

`WP_Block_Parser` is copied from the `@wordpress/block-serialization-default-parser` package. To ensure it stays in sync with the JavaScript parser, changes should be implemented in the package first, then the package version should be upgraded to include the changes.

Props pento.

Merges [43751] to trunk.

See #45109.

git-svn-id: https://develop.svn.wordpress.org/trunk@44116 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 17:39:59 +00:00
Jonathan Desrosiers 8909554d2e Script loader: Adjust JS packages registration.
Adjusts the packages registration after [43723]:

    Combine the different registration functions into one `wp_default_packages` function. To reach this goal move the prefix logic into a function so it can be called from different locations. Use a static variable there to prevent duplicate inclusion of `version.php`.

    Call this function from the `wp_default_scripts` action by registering it as a default filter.

    Combine some of the logic in `_WP_Editors::print_tinymce_scripts` into `wp_register_tinymce_scripts`. The logic to force an uncompressed TinyMCE script file stays in `_WP_Editors::force_uncompressed_tinymce` because that logic is very specific to the classic editor.

    The script handle `wp-tinymce` is now a dependency of the editor script handle. In combination with the previous item, this makes the classic editor work.

    Adjust the syntax of the script paths to be more consistent with other WordPress code.

    Always use "production" mode for the media files to prevent people from inadvertently committing development files.

Props pento, omarreiss, atimmer.

Merges [43738] into trunk.

Fixes #45065.

git-svn-id: https://develop.svn.wordpress.org/trunk@44115 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 17:26:09 +00:00
Jonathan Desrosiers c05b5d8b61 REST API: Slash existing meta values when comparing with incoming meta upates.
When comparing the old and new values for a meta key being set, ensure both values are sanitized using the same logic so that equal values match.

props boonebgorges, dcavins, MattGeri, pilou69, TimothyBlynJacobs, kadamwhite.

Merges [43740] to trunk.

Fixes #42069.

git-svn-id: https://develop.svn.wordpress.org/trunk@44113 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 16:29:57 +00:00
Gary Pendergast 738609ae9c Blocks: Introduce `register_block_type()`, `unregister_block_type()`, and `get_dynamic_blocks()` functions.
These helper functions allow easy access to the global block registry.

Merges [43743] from the 5.0 branch to trunk.

See #45109.


git-svn-id: https://develop.svn.wordpress.org/trunk@44109 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:53:10 +00:00
Gary Pendergast 9254ae4a72 Blocks: Introduce `WP_Block_Type` and `WP_Block_Type_Registry` classes.
These are the foundational classes allowing blocks to be registered and used throughout WordPress.

This commit also includes the `has_block()` and `has_blocks()` functions, which are required for unit testing these classes.

Merges [43742] from the 5.0 branch to trunk.

Props adamsilverstein, danielbachhuber, desrosj.
Fixes #45097.
See #45109.


git-svn-id: https://develop.svn.wordpress.org/trunk@44108 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:43:29 +00:00
Gary Pendergast 5c9c54239d REST API: Introduce controller for searching across post types.
Introduces a `WP_REST_Search_Controller` class which registers a `/wp/v2/search` endpoint. Search types are handled by extending `WP_REST_Search_Handler`. The default search type is `WP_REST_Post_Search_Handler` but can be filtered by plugins or a theme.

Merges [43739,43741] from the 5.0 branch to trunk.

Props danielbachhuber, flixos90, pento, rmccue, joehoyle.
Fixes #39965.



git-svn-id: https://develop.svn.wordpress.org/trunk@44107 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:37:05 +00:00
Jonathan Desrosiers 8c85f2dfec REST API: Don't add fields to object when not included in `?_fields=`.
In [43087], we improved REST API performance by only rendering the fields specified in the request. Similarly, any fields registered with `register_rest_field()` should only be rendered when included in `?_fields=`.

Props dlh, danielbachhuber.

Merges [43736] to trunk.

Fixes #45099.

git-svn-id: https://develop.svn.wordpress.org/trunk@43986 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-12 20:50:22 +00:00
Jeremy Felt 140a95cf08 REST API: Introduce themes endpoint to expose theme-supports values for the active theme.
In order to correctly render parts of its UI, the new editor needs to be aware of the active theme's post-formats and post-thumbnails support. This data is exposed by querying for the active theme on a new /wp/v2/themes endpoint for sufficiently privileged users.

Merges [43734], [43735] to trunk.

props desrosj.
Fixes #45016.


git-svn-id: https://develop.svn.wordpress.org/trunk@43985 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-12 03:32:21 +00:00
Jeremy Felt 2ad4d85ed5 REST API: Move object type-specific metadata integrations from the wrapper functions to the low-level Meta API functions.
Object type-specific actions that should happen before or after modification of metadata have so far been part of the respective wrapper functions. By using action and filter hooks, this changeset ensures they are always executed, even when calling the lower-level Meta API functions directly, which the REST API does as a prime example.

Merges [43729] to trunk.

Props flixos90, spacedmonkey.
Fixes #44467.


git-svn-id: https://develop.svn.wordpress.org/trunk@43982 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-12 03:02:00 +00:00
Jeremy Felt 1c9f359857 KSES: Allow HTML data-* attributes.
Add global support for HTML attributes prefixed `data-` for authors and contributors, as required by the new editor.

Merges [43727] to trunk.

Props azaozz, peterwilsoncc.
Fixes #33121.


git-svn-id: https://develop.svn.wordpress.org/trunk@43981 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-12 02:38:14 +00:00
Jeremy Felt 894a8e02d2 REST API: Include permalink_template/generated_slug for Posts
In order for clients to present permalink previews, the REST API must share the computed results of get_sample_permalink(). These two values are now exposed as permalink_template and generated_slug for public, viewable post types, but only for context=edit.

Merges [43720] to trunk.

Props danielbachhuber, rahulsprajapati.
Fixes #45017.


git-svn-id: https://develop.svn.wordpress.org/trunk@43980 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-12 02:11:22 +00:00
Jonathan Desrosiers c0e80b028a REST API: Enable users with read_private_posts to query for them.
An authorized request with the read_private_posts capability for a post type should be able to GET /wp/v2/posts for posts of status=private. This query is further sanity-checked by WP_REST_Posts_Controller->check_read_permission(), which is unchanged.

Props rachelbaker, soulseekah, twoelevenjay.

Moves [43694] from the 5.0 branch to trunk.

Fixes #43701.

git-svn-id: https://develop.svn.wordpress.org/trunk@43979 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-11 22:29:36 +00:00
Aaron Jorbin 7f544b912b REST API: Declare unfiltered_html capability in links.
Because user capabilities can be modified at runtime, the REST API needs to expose them in some evaluated but declarative manner for clients to interpret. JSON Hyper Schema targetSchema provides an appropriate paradigm for doing so.

Merges [43682] to trunk.

Props timothyblynjacobs.

Fixes #45014.


git-svn-id: https://develop.svn.wordpress.org/trunk@43974 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-11 04:12:56 +00:00
Aaron Jorbin 891394af73 REST API: Persist attributes for attachment links
In [43437], the link definition implementation caused attachment links to be unexpectedly nested under an attributes key. This changeset restores the prior behavior.

Merges [43681] to trunk.

Props TimothyBlynJacobs, danielbachhuber.
Fixes #44750.


git-svn-id: https://develop.svn.wordpress.org/trunk@43973 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-11 04:00:37 +00:00
Sergey Biryukov e1ff4cd7cd General: Introduce `wp_unique_id()`, a PHP implementation of Underscore's `uniqueId` method.
A static variable contains an integer that is incremented with each call. This number is returned with the optional prefix.
As such the returned value is not universally unique, but it is unique across the life of the PHP process.

Props westonruter, dlh.
See #44883.

git-svn-id: https://develop.svn.wordpress.org/trunk@43658 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-24 20:56:30 +00:00
Felix Arntz c12a0cf4f3 Multisite: Fix coding standard errors after [43654].
See #41333.


git-svn-id: https://develop.svn.wordpress.org/trunk@43655 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-24 15:22:01 +00:00
Felix Arntz 1795dbe25a Multisite: Introduce a site initialization and uninitialization API.
This changeset makes the new CRUD API for sites introduced in [43548] usable for real-world sites. A new function `wp_initialize_site()`, which takes care of creating a site's database tables and populating them with initial values, is hooked into the site insertion process that is initiated when calling `wp_insert_site()`. Similarly, a new function `wp_uninitialize_site()`, which takes care of dropping a site's database tables, is hooked into the site deletion process that is initiated when calling `wp_delete_site()`.

A new function `wp_is_site_initialized()` completes the API, allowing to check whether a site is initialized. Since this function always makes a database request in its default behavior, it should be called with caution. Plugins that would like to use site initialization in special ways can leverage a `pre_wp_is_site_initialized` filter to alter that default behavior.

The separate handling of the site's row in the `wp_blogs` database table and the actual site setup allows for more flexibility in controlling whether or how a site's data is set up. For example, a unit test that only checks data from the site's database table row can unhook the site initialization process to improve performance. At the same time, developers consuming the new sites API only need to know about the CRUD functions, since the initialization and uninitialization processes happen internally.

With this changeset, the foundation for a sites REST API endpoint is fully available. The previously recommended functions `wpmu_create_blog()` and `wpmu_delete_blog()` now call the new respective function internally. Further follow-up work to this includes replacing calls to `wpmu_create_blog()` with `wp_insert_site()`, `update_blog_details()` with `wp_update_site()` and `wpmu_delete_blog()` with `wp_delete_blog()` throughout the codebase.

As a side-effect of this work, the `wpmu_new_blog`, `delete_blog`, and `deleted_blog` actions and the `install_blog()` function have been deprecated.

Fixes #41333. See #40364.


git-svn-id: https://develop.svn.wordpress.org/trunk@43654 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-24 15:08:32 +00:00
Aaron Jorbin 6604782cd9 General: PHP7.3 throws an `E_WARNING` when using continue to target a switch
Applying continue to a switch is equivalent to using break and quite possibly, a continue targeting a higher level control structure is actually intended.

To target the higher level control structure, a numeric argument has to be passed to continue. This fixes two cases in WordPress Core where this is currently happening.

See: https://github.com/php/php-src/pull/3364
See: https://wiki.php.net/rfc/continue_on_switch_deprecation

Props jrf.
Fixes #44543.



git-svn-id: https://develop.svn.wordpress.org/trunk@43653 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-23 22:49:02 +00:00
SergeyBiryukov fb2699f28d Tests: Add missing `public` access modifier to `Tests_REST_Server` methods.
Props andizer.
Fixes #44939.

git-svn-id: https://develop.svn.wordpress.org/trunk@43652 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-23 15:45:02 +00:00
Sergey Biryukov 2724e2d0fe Tests: Restore `restapi` group on `WP_Test_REST_Revisions_Controller`.
See #40510.

git-svn-id: https://develop.svn.wordpress.org/trunk@43647 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-18 03:44:57 +00:00
Felix Arntz ffa16fa771 Upgrade/Install: Properly exclude the `admin/includesSchema.php` tests file for the `WordPress.DB.PreparedSQL.NotPrepared` sniff.
The way this was implemented in [43630] caused the file to be excluded for all sniffs, since PHPCS does not support file-wide ignores of a specific sniff at this point.

Props jrf.
See #44896.


git-svn-id: https://develop.svn.wordpress.org/trunk@43641 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-14 07:54:53 +00:00
Ian Dunn 7d22ba1961 Privacy: Add test for `wp_privacy_export_expiration` filter.
Props desrosj.
See #44233.


git-svn-id: https://develop.svn.wordpress.org/trunk@43640 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-13 17:25:31 +00:00
K. Adam White e29d895ffd REST API: Pass correct ID to `meta->update_value` to permit setting term meta during term creation.
Props joehoyle.
Fixes #44834.



git-svn-id: https://develop.svn.wordpress.org/trunk@43636 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-12 23:55:47 +00:00
Adam Silverstein fd5ba80c5c Media: Improve display and accessibility of meta data in detail view.
* Add a `human_readable_duration` function including tests.
* Add 'pixels' after image width/height.
* Add screen reader text for durations.

Props Presskopp, kiranpotphode, milindmore22, stormrockwell, afercia.
Fixes #39667. 



git-svn-id: https://develop.svn.wordpress.org/trunk@43633 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-08 04:19:40 +00:00
Felix Arntz b33420db6c Upgrade/Install: Fix coding standard errors after [43629].
See #44896.


git-svn-id: https://develop.svn.wordpress.org/trunk@43630 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-05 12:49:29 +00:00
Felix Arntz 46e5c6c91b Upgrade/Install: Introduce `populate_site_meta()`.
Fixes #44896. See #41333.


git-svn-id: https://develop.svn.wordpress.org/trunk@43629 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-05 11:01:36 +00:00
flixos90 88b725e1cb Upgrade/Install: Introduce `populate_network_meta()`, moving logic out of `populate_network()`.
Fixes #44895. See #41333.


git-svn-id: https://develop.svn.wordpress.org/trunk@43628 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-05 10:44:02 +00:00
Felix Arntz f1e1b6299e Upgrade/Install: Add support for an optional `$options` parameter to `populate_options()`.
Fixes #44893. See #41333.


git-svn-id: https://develop.svn.wordpress.org/trunk@43627 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-05 09:38:04 +00:00
Sergey Biryukov 04516c1299 Taxonomy: Make sure `wp_list_categories()` correctly outputs term name of `0`.
Props joyously, SergeyBiryukov.
Fixes #44872.

git-svn-id: https://develop.svn.wordpress.org/trunk@43605 602fd350-edb4-49c9-b593-d223f7449a82
2018-09-02 22:08:05 +00:00
Sergey Biryukov f1862cd98c Date/Time: Make sure `current_time()` always calculates the offset from GMT/UTC.
Previously, UTC context was implied, but could be unreliable due to being affected by plugins.

Props Rarst, rahulsprajapati, marco.marsala.
Fixes #37440.

git-svn-id: https://develop.svn.wordpress.org/trunk@43594 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-30 12:12:55 +00:00
Sergey Biryukov 9364b6ed87 Date/Time: Make `get_the_date()` call `get_post_time()` for consistency with `get_the_time()`.
Props Rarst.
Fixes #44490.

git-svn-id: https://develop.svn.wordpress.org/trunk@43591 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-30 08:49:40 +00:00
Felix Arntz aa5b179247 REST API: Fix failing tests after [43584] and [43585].
See #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43586 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 13:04:07 +00:00
Felix Arntz 65cadaab62 REST API: Fix failing tests after [43584].
See #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43585 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 12:43:50 +00:00
Felix Arntz e5d6ddfeee REST API: Support pagination, order, search and other common query parameters for revisions.
The original REST API revisions controller relied on `wp_get_post_revisions()`, getting all revisions of a post without any possibility to restrict the result. This changeset replaces that function call with a proper `WP_Query` setup, replicating how `wp_get_post_revisions()` works while offering parameters to alter the default behavior.

Props adamsilverstein, birgire, flixos90.
Fixes #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43584 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 12:22:48 +00:00
Gary Pendergast 63acd3caaa Tests: Revert `wp-api-generated.js` change added in [43571].
The fixtures file was accidentally included in [43571], but that caused other tests to fail.

See #39122.



git-svn-id: https://develop.svn.wordpress.org/trunk@43572 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 04:11:48 +00:00
Gary Pendergast a75d153eee Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 01:50:26 +00:00
Sergey Biryukov c5d013bf95 Privacy: Ensure the user request email is sent in the requested user's locale (or the site's default locale if they are not a registered user) when the administrator creating the request uses a different locale.
Props desrosj, Chouby, iandunn, lbenicio, birgire, earnjam, swissspidy, garrett-eclipse.
Fixes #43985.

git-svn-id: https://develop.svn.wordpress.org/trunk@43568 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-13 16:31:31 +00:00
K. Adam White 20ab5ca79e Tests: Improve coverage for REST API term meta registration.
Introduce tests to validate that register_meta and register_term_meta work as expected in WP_REST_Terms_Controller.

props timmydcrawford.
Fixes #39122.


git-svn-id: https://develop.svn.wordpress.org/trunk@43567 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-12 00:05:39 +00:00
Sergey Biryukov 244f435e22 Script/Style Dependencies: Make sure that inline scripts for handles without a source are printed.
See [36550] for `WP_Styles`.

Props bpayton.
Fixes #44551.

git-svn-id: https://develop.svn.wordpress.org/trunk@43565 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-11 17:41:29 +00:00
Sergey Biryukov 3b4b754f2a Tests: Avoid a race condition in `test_date_i18n_handles_shorthand_formats()` by using a delta for comparing timestamps.
See #20973, #38381.

git-svn-id: https://develop.svn.wordpress.org/trunk@43562 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-11 13:28:26 +00:00
Sergey Biryukov 4ce3db3e8d Build/Test Tools: Add documentation for `tests_add_filter()`, `_test_filter_build_unique_id()`, `_delete_all_data()`, `_delete_all_posts()`.
Props andizer.
Fixes #44703.

git-svn-id: https://develop.svn.wordpress.org/trunk@43555 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-02 22:35:10 +00:00
Felix Arntz c29d019762 Multisite: Complete the new CRUD API for managing sites.
New functions `wp_insert_site( $data )`, `wp_update_site( $id, $data )` and `wp_delete_site( $id )` are introduced to manage site rows in the `wp_blogs` table, forming the new CRUD API together with the existing `get_site()` / `get_sites()`. The new API provides various benefits over the previously existing API, fixing several cache invalidation issues and being hook-driven so that normalization and validation of the passed data can be fully customized.

New hooks introduced as part of this are the actions `wp_insert_site`, `wp_update_site`, `wp_delete_site`, `wp_validate_site_data` and the filter `wp_normalize_site_data`.

At this point, `wp_insert_site()` does not handle setting up the site's database tables, and `wp_delete_site()` does not handle dropping the site's database tables, so the two can not yet be used directly as full replacements of `wpmu_create_blog()` and `wpmu_delete_blog()`. Managing the site's database tables will be added via hooks as part of the follow-up ticket #41333.

The existing functions `wpmu_create_blog()`, `update_blog_details()`, and `wpmu_delete_blog()` make use of the respective new counterpart and will be obsolete once #41333 has been completed.

Props flixos90, jeremyfelt, spacedmonkey.
Fixes #40364.


git-svn-id: https://develop.svn.wordpress.org/trunk@43548 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-01 13:05:44 +00:00
Peter Wilson a32ea2d35d Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.

`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.

Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.

Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.

Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.



git-svn-id: https://develop.svn.wordpress.org/trunk@43540 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-27 02:22:50 +00:00
Sergey Biryukov ddc8f803c6 Privacy: Revert [43525].
The commenter cookies checkbox is not legally required, so should be disabled by default.

Fixes #44373.

git-svn-id: https://develop.svn.wordpress.org/trunk@43531 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-24 17:05:56 +00:00
Sergey Biryukov 0f7e947546 REST API: Ensure attachments created with `WP_REST_Attachments_Controller::create_item()` on Windows have a relative path.
Props ocean90, SergeyBiryukov, redcastor.
Fixes #40861.

git-svn-id: https://develop.svn.wordpress.org/trunk@43529 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-24 16:51:09 +00:00
Sergey Biryukov 335b69cedc Privacy: Remove the setting to enable comment cookies consent added in [43469].
This needs some more work to ensure expected behaviour.

See #44373.

git-svn-id: https://develop.svn.wordpress.org/trunk@43525 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-24 12:50:55 +00:00
Sergey Biryukov 8a0aac2ccb Comments: Ensure that themes overriding default `comment_form()` fields still display the cookies consent checkbox.
The `comment_form_default_fields` filter can be used to remove the checkbox.

Props pross, SergeyBiryukov.
Fixes #44126.

git-svn-id: https://develop.svn.wordpress.org/trunk@43518 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-20 00:37:40 +00:00
Sergey Biryukov 2075b3d921 Tests: Introduce `Tests_HTTP_Functions::skipTestOnTimeout()`, mirroring the same `WP_HTTP_UnitTestCase` method.
See #44613.

git-svn-id: https://develop.svn.wordpress.org/trunk@43512 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-19 19:52:41 +00:00
Sergey Biryukov 0ba13ec260 Tests: Use `WP_HTTP_UnitTestCase::skipTestOnTimeout()` in more HTTP tests.
Adjust it to handle more types of timeouts, e.g. "Resolving timed out", "Connection timed out".

See #44613.

git-svn-id: https://develop.svn.wordpress.org/trunk@43511 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-19 19:09:56 +00:00
Sergey Biryukov a1f6ba5477 Privacy: Use the actual Privacy Policy page title in `get_the_privacy_policy_link()`.
Props desrosj, birgire, ianbelanger, Ov3rfly.
Fixes #44192.

git-svn-id: https://develop.svn.wordpress.org/trunk@43506 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-18 11:49:46 +00:00
Sergey Biryukov 9daa08da8e Filesystem API: Skip `https://` test for `wp_is_stream()` if `openssl` extension is not loaded.
See #44533.

git-svn-id: https://develop.svn.wordpress.org/trunk@43503 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-18 09:51:53 +00:00
Sergey Biryukov 6f0218d8bc Filesystem API: Add basic tests for `wp_is_stream()`.
Props JPry.
See #44533.

git-svn-id: https://develop.svn.wordpress.org/trunk@43501 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-18 01:01:28 +00:00
Sergey Biryukov b2d63fd056 Privacy: Add unit tests for `_wp_privacy_send_request_confirmation_notification()`, introduced in [43211].
Props birgire, desrosj, garrett-eclipse.
Fixes #43967.

git-svn-id: https://develop.svn.wordpress.org/trunk@43499 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 22:55:51 +00:00
Andrew Ozz 590d18844b Customize: Do not attempt to count uncountable value.
Props dlh.
Fixes #44104.

git-svn-id: https://develop.svn.wordpress.org/trunk@43480 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 14:37:21 +00:00
Andrew Ozz c1ce7d134b Privacy: Fix tests after [43467].
See #44141.


git-svn-id: https://develop.svn.wordpress.org/trunk@43471 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 09:57:57 +00:00
Andrew Ozz b33deaf1b5 Privacy: Don't replace comment author URL and email with anything.
Props TZ-Media, desrosj, birgire.
Fixes #44141.

git-svn-id: https://develop.svn.wordpress.org/trunk@43467 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 08:59:30 +00:00
Gary Pendergast 66f537e702 REST API: Attachments controller should respect upload limits.
When the REST API is in use on WordPress multisite, the `WP_REST_Attachments_Controller` should respect the "Max upload file size" and "Site upload space" site options.

Props flixos90, danielbachhuber.
Fixes #43751.



git-svn-id: https://develop.svn.wordpress.org/trunk@43462 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 07:21:50 +00:00
Gary Pendergast 4c8daa87bd REST API: Update the test fixture generator following [43439]
As [43439] added data that contains object IDs, it can cause `wp-api-generated.js` to be unnecessarily regenerated.

Regenerating our list of fixtures that need normalising rectifies this.

See #44321.



git-svn-id: https://develop.svn.wordpress.org/trunk@43441 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:45:35 +00:00
Gary Pendergast 46c238ca78 REST API: Tweak permission checks for taxonomy and term endpoints
To match behaviour in the Classic Editor, we need to slightly loosen permissions on taxonomy and term endpoints. This allows users to create terms to assign to a post that they're editing.

Props danielbachhuber.
Fixes #44096.



git-svn-id: https://develop.svn.wordpress.org/trunk@43440 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:23:35 +00:00
Gary Pendergast 585c862faf REST API: Expose revision count and last revision ID on Post response
So that REST API clients can show appropriate UI for a post's revisions, it needs to know how many revisions the post has, and what the latest revision ID is.

Props kadamwhite, danielbachhuber, birgire, TimothyBlynJacobs.
Fixes #44321.



git-svn-id: https://develop.svn.wordpress.org/trunk@43439 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:06:23 +00:00
Gary Pendergast 81d2390d29 REST API: Declare user capabilities using JSON Hyper Schema's "targetSchema".
There are a variety of operations a WordPress user can only perform if they have the correct capabilities. A REST API client should only display UI for one of these operations if the WordPress user can perform the operation.

Rather than requiring REST API clients to calculate whether to display UI based on potentially complicated combinations of user capabilities, `targetSchema` allows us to expose a single flag to show whether the corresponding UI should be displayed.

This change also includes flags on post objects for the following actions:

- `action-publish`: The current user can publish this post.
- `action-sticky`: The current user can make this post sticky, and the post type supports sticking.
- `action-assign-author': The current user can change the author on this post.
- `action-assign-{$taxonomy}`: The current user can assign terms from the "$taxonomy" taxonomy to this post.
- `action-create-{$taxonomy}`: The current user can create terms int the "$taxonomy" taxonomy.

Props TimothyBlynJacobs, danielbachhuber.
Fixes #44287.



git-svn-id: https://develop.svn.wordpress.org/trunk@43437 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-11 06:22:10 +00:00
John Blackbourn f584b5755a Date/Time: Add support for the `c` and `r` shorthand formats in `date_i18n()`.
Props Rarst, pbearne

Fixes #20973


git-svn-id: https://develop.svn.wordpress.org/trunk@43434 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-05 23:10:01 +00:00
Felix Arntz b4d8e87464 Tests: Fix failing test after [43388].
Fixes #44396.


git-svn-id: https://develop.svn.wordpress.org/trunk@43390 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-05 08:52:06 +00:00
Felix Arntz 21190f2eac Date/Time: Fix usage of `$gmt` parameter in `date_i18n()` and clarify its behavior.
The docs for `date_i18n()` and its filter now correctly state that the `$gmt` parameter is only taken into account if no timestamp is provided. Furthermore, a bug with that parameter is fixed, as it is now ensured that the timezone used with it is `UTC`.

Props Rarst.
Fixes #38771.


git-svn-id: https://develop.svn.wordpress.org/trunk@43389 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-04 23:42:59 +00:00
Felix Arntz d448c448ca Date/Time: Add support for `gmt_offset` to `date_i18n()`.
Prior to this change, `date_i18n()` only supported the `timezone_string` option, causing incorrect timezones to appear in formatted dates on sites that still rely on the `gmt_offset` option.

Props Rarst.
Fixes #34835.


git-svn-id: https://develop.svn.wordpress.org/trunk@43387 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-03 15:58:58 +00:00
Felix Arntz d3a198df34 Taxonomy: Introduce `is_taxonomy_viewable()`.
This utility function allows for easy detection whether terms for a taxonomy are considered publicly viewable.

Props andizer.
Fixes #44466.


git-svn-id: https://develop.svn.wordpress.org/trunk@43386 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-03 10:28:39 +00:00
Felix Arntz d399bcce30 Role/Capability: Rename `upgrade_php` capability to more suitable `update_php`.
This brings the name in line with user-facing language and similar names of existing related capabilities. Since the capability has not been part of any WordPress release, it can be renamed without any backward-compatibility implications.

Also missing props benhuberman for [43006].

Fixes #44457.


git-svn-id: https://develop.svn.wordpress.org/trunk@43381 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-26 15:04:26 +00:00
K. Adam White a830dbcab3 REST API: Support meta registration for specific object subtypes.
Introduce an `object_subtype` argument to the args array for `register_meta()` which can be used to limit meta registration to a single subtype (e.g. a custom post type or taxonomy, vs all posts or taxonomies).

Introduce `register_post_meta()` and `register_term_meta()` wrapper methods for `register_meta` to provide a convenient interface for the common case of registering meta for a specific taxonomy or post type. These methods work the way plugin developers have often expected `register_meta` to function, and should be used in place of direct `register_meta` where possible.

Props flixos90, tharsheblows, spacedmonkey.
Fixes #38323.



git-svn-id: https://develop.svn.wordpress.org/trunk@43378 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-21 21:06:50 +00:00
Gary Pendergast cdd9910f01 Emoji: Update Twemoji to version 11.0.
🦹

Props kraftbj,
Fixes #44339.



git-svn-id: https://develop.svn.wordpress.org/trunk@43377 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-20 04:20:32 +00:00
Andrew Ozz acbbd28d0e Privacy: add `esc_html` to assertion in test_wp_comments_personal_data_exporter.
Props mermel, 1naveengiri.
Fixes #44113.

git-svn-id: https://develop.svn.wordpress.org/trunk@43371 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-18 16:09:55 +00:00
John Blackbourn 1e88432e34 Build/Test Tools: Introduce support for a `WP_TESTS_CONFIG_FILE_PATH` constant to override the test suite config file location.
This can be used in phpunit.xml:

{{{
<php>
	<const name="WP_TESTS_CONFIG_FILE_PATH" value="/path/to/wp-tests-config.php" />
</php>
}}}

Props clarinetlord

Fixes #39734


git-svn-id: https://develop.svn.wordpress.org/trunk@43369 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 14:21:18 +00:00
John Blackbourn 5aa5e5c131 I18N: Introduce unit tests for the Japanese language in order to facilitate future improvements.
Props ryotsun

Fixes #43829


git-svn-id: https://develop.svn.wordpress.org/trunk@43359 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 12:44:46 +00:00
Sergey Biryukov 4d5b00da46 Docs: Update `@since` versions in Community Events class added in [42726].
See #41112.

git-svn-id: https://develop.svn.wordpress.org/trunk@43356 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 10:38:27 +00:00
Felix Arntz 07f3c7097e REST API: Improve test coverage by providing tests for term meta.
See #38323.


git-svn-id: https://develop.svn.wordpress.org/trunk@43340 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-11 17:54:19 +00:00
Felix Arntz 9e38c2847e Tests: Improve performance of post meta tests.
See #38323.


git-svn-id: https://develop.svn.wordpress.org/trunk@43339 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-11 16:32:32 +00:00
John Blackbourn 58a71dc610 Build/Test Tools: Allow the unit test framework to be used without the data directory in place.
Fixes #43982

git-svn-id: https://develop.svn.wordpress.org/trunk@43315 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-25 22:42:11 +00:00
Boone Gorges 39fb88f961 Taxonomy: Improve cache handling when querying for terms using `all_with_object_id`.
When a term query using `fields=all_with_object_id` hits the cache, the
cached `stdClass` objects must be converted to `WP_Term` objects. This
was overlooked when `WP_Term_Query` was refactored to support object
queries in [38667].

Props dlh.
Fixes #44221.

git-svn-id: https://develop.svn.wordpress.org/trunk@43313 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-25 01:22:44 +00:00
John Blackbourn f4fbba188d Build/Test Tools: Roses are red, this fixes stuff.
Update the test infrastructure so that third party plugins, themes, and projects that use the core testing framework continue to operate from the `src` directory and do not require a build step.

Props mboynes, danielbachhuber, schlessera

See #43055


git-svn-id: https://develop.svn.wordpress.org/trunk@43311 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-23 17:54:44 +00:00
Gary Pendergast ef37f002ee Once upon a midnight dreary, while I coded, weak and weary,
In many a strange and curious file of forgotten lore—
While I pondered, blaming Nacin, my notifications suddenly awakened,
As of someone quietly DMing;—DMing me, I can’t ignore.
“’Tis some contributor,” I muttered, “DMing me an idea or four—
            Only this and nothing more.”

Ah, distinctly I remember, at WordCamp US, last December;
A mad proposal nearly laid me—down out cold—upon the floor.
Curious, I listened closely;—to a plan I agreed with, mostly—
A way to make our JavaScript—JavaScript which was a chore—
Maintainable, extendable, for the future, is what I saw.
            Guten-ready for evermore.

Open here I switch to Slack, when, with many a patch and hack,
In there stepped Omar, a JavaScript developer hardcore;
Pronouncing all the changes fit; ready now to be commit;
“There’s nothing else for us to do,” DMing me, “It’s done!” he swore—
“No longer random guessing at which file need next be explored—
            Let’s move on, we’re all aboard.”

Moved all together, grouped and managed, in folders all is packaged,
The code had all been cleaned and tidied, important parts moved to the fore,
“Though this change be useful here,” I said, “it is too large, I fear,
We couldn’t manage such a patch, we’ve done nothing like this before—
Tell me where doth go this change, change to make our codebase soar!”
            Quoth Omar, “In WordPress Core.”

Props omarreis for shepherding this significant change.
Props adamsilverstein, aduth, atimmer, dingo_bastard, frank-klein, gziolo, herregroen, jaswrks, jeremyfelt, jipmoors, jorbin, netweb, ocean90, pento, tjnowell, and youknowriad for testing, feedback, discussion, encouragement, commiserations, etc.
I make no apologies for this commit message.
Fixes #43055.



git-svn-id: https://develop.svn.wordpress.org/trunk@43309 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-23 10:04:22 +00:00
iandunn 238504d36f Tests: Add case for `wp_privacy_delete_old_export_files()`.
Props allendav.
See #43546.


git-svn-id: https://develop.svn.wordpress.org/trunk@43292 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-17 16:38:01 +00:00
Ian Dunn 84211ab4b6 Tests: Add case for `wp_privacy_send_personal_data_export_email()`.
Props birgire.
See #43546.


git-svn-id: https://develop.svn.wordpress.org/trunk@43291 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-16 23:53:38 +00:00
Sergey Biryukov 34931cf8c3 General: Skip `test_is_countable_ResourceBundle()` on PHP 5.3 and below.
`ResourceBundle` is only countable in PHP 5.4+, which can be considered an acceptable edge case for WordPress core purposes.

Props jrf, ayeshrajans.
Fixes #43583.

git-svn-id: https://develop.svn.wordpress.org/trunk@43226 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-10 20:15:18 +00:00
Sergey Biryukov 07feb01a80 General: In the `is_countable()` polyfill, if the provided object implements `SimpleXMLElement` or `ResourceBundle`, consider it countable.
Props ayeshrajans, jrf, desrosj.
Fixes #43583.

git-svn-id: https://develop.svn.wordpress.org/trunk@43220 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-10 17:57:38 +00:00
Ian Dunn a583f61558 Privacy: Mark processed requests as completed instead of confirmed.
r43008 refactored the request flow to make several improvements, but accidentally marked `completed` requests as `confirmed`. This commit restores the intended statuses, so that the data and corresponding UI reflect reality.

Props allendav, birgire.
Fixes #43913.


git-svn-id: https://develop.svn.wordpress.org/trunk@43183 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-08 23:28:47 +00:00
Andrew Ozz a7fcbcae89 Privacy: rename `manage_privacy_policy` to `manage_privacy_options`.
Props desrosj.
FIxes #43935.

git-svn-id: https://develop.svn.wordpress.org/trunk@43155 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-03 19:30:49 +00:00
Ian Dunn e4ffde6193 Privacy: Limit Privacy Settings screen to Super Admins in Multisite.
In many common Multisite use cases, the network administrator will want to set a network-wide privacy policy -- via the `privacy_policy_url` filter -- for consistency and convenience. When that's done, the Privacy Settings screen on individual sites becomes unnecessary, and may confuse administrators of those sites when they see that their changes don't have any effect on the policy link in the footer.

Since we can't programatically determine which behavior the network admins would like, the safest default setting is to restrict the ability to super admins, and let them delegate it to individual site owners via a plugin, if they'd like to.

Fixes #43935.


git-svn-id: https://develop.svn.wordpress.org/trunk@43147 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-03 17:24:35 +00:00
Sergey Biryukov 65df92173a Privacy: Correct unit test for `wp_user_personal_data_exporter()` added in [43055].
`user_status` is not considered personal data, so the total number of exported user properties is 11.

See #43547.

git-svn-id: https://develop.svn.wordpress.org/trunk@43116 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-02 04:10:17 +00:00
Gary Pendergast 4ac3f4c13a REST API: Filter responses based on the `_fields` parameter, before data is processed.
Historically, the REST API would generate the entire response object, including running expensive filters, then it would apply the `_fields` parameter, discarding the fields that weren't specificed.

This change causes `_fields` to be applied earlier, so that only requested fields are processed.

Props danielbachhuber.
See #43874.



git-svn-id: https://develop.svn.wordpress.org/trunk@43087 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-02 01:24:30 +00:00
Ian Dunn 1a4e28818f Privacy: Limit export and erasure to super admins on Multisite.
Multisite networks have a variety of use cases, and in many of them single-site administrators are not trusted to take actions that affect the whole network, require making decisions about legal compliance, etc. By default, those actions should require super admin capabilities. Plugins can be used to override that behavior if a particular site's use case calls for it.

Props allendav, jeremyfelt, iandunn.
Fixes #43919.


git-svn-id: https://develop.svn.wordpress.org/trunk@43085 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-02 01:07:00 +00:00
Andrew Ozz 87b81f220c Privacy: improve `wp_privacy_erase_personal_data()`, return boolean values.
Props ericdaams.
See #43602.

git-svn-id: https://develop.svn.wordpress.org/trunk@43061 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-01 19:26:53 +00:00
Andrew Ozz 16bd4bede2 Privacy: add user information to the personal data export file.
Props TZ-Media, desrosj.
See #43547.


git-svn-id: https://develop.svn.wordpress.org/trunk@43055 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-01 13:58:02 +00:00
Peter Wilson e73af26e92 Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:

* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.

Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.



git-svn-id: https://develop.svn.wordpress.org/trunk@43050 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-01 02:04:25 +00:00
Boone Gorges 4c36079299 Taxonomy: Ensure that invalid term objects are discarded in `WP_Term_Query`.
The `get_term()` mapping may result in term objects that are `null` or
`WP_Error` when plugins use `get_term` or a related filter. Since `null`
and error objects are not valid results for a term query, we discard
them.

Props GM_Alex.
See #42691.

git-svn-id: https://develop.svn.wordpress.org/trunk@43049 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-30 21:07:16 +00:00
Sergey Biryukov 451ba4c401 General: Introduce a polyfill for `is_iterable()` function added in PHP 7.1.
Props jrf, schlessera, desrosj.
See #43619.

git-svn-id: https://develop.svn.wordpress.org/trunk@43036 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-30 04:14:30 +00:00
Sergey Biryukov 8edb00171c General: Introduce a polyfill for `is_countable()` function added in PHP 7.3.
Props jrf, ayeshrajans, desrosj.
See #43583.

git-svn-id: https://develop.svn.wordpress.org/trunk@43034 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-30 03:42:46 +00:00
Andrew Ozz 6173287317 Privacy: fix unit tests after [43012].
Props iandunn.
See #43546.

git-svn-id: https://develop.svn.wordpress.org/trunk@43015 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-28 12:10:13 +00:00