This commit modifies the `rest_get_date_with_gmt` function to correctly parse local and UTC timestamps with or without timezone information.
It also ensures that the REST API can edit the dates of draft posts by setting the `edit_date` flag to `wp_update_post`.
Overall this commit ensures that post and comment dates can be set and updated as expected.
Fixes#39256.
git-svn-id: https://develop.svn.wordpress.org/trunk@40101 602fd350-edb4-49c9-b593-d223f7449a82
For UX and accessibility reasons, it's better to always avoid playing videos automatically.
Props bor0.
Fixes#39560.
git-svn-id: https://develop.svn.wordpress.org/trunk@40089 602fd350-edb4-49c9-b593-d223f7449a82
Removes some method overrides on `wp.customize.HeaderTool.ChoiceView` introduced in [27497].
See #21785.
Props bradyvercher.
Fixes#38559.
git-svn-id: https://develop.svn.wordpress.org/trunk@40082 602fd350-edb4-49c9-b593-d223f7449a82
Previously the status for a Post (or other post_types) was only exposed under the `edit` context, which doesn't really make much sense considering we support querying by post status without authentication. Originally introduced in v2.0 beta 1: 69f617d749 without any explanation in the commit message.
Props dhanendran, jnylen0, rachelbaker.
Fixes#39466.
git-svn-id: https://develop.svn.wordpress.org/trunk@40080 602fd350-edb4-49c9-b593-d223f7449a82
There are a couple of changes to the generated API schemas between single-site and multisite mode - for example, the `url` and `email` settings are not present in the settings endpoint (see #39005).
To avoid unexpected changes to the `wp-api-generated.js` fixture file, skip generating the client test fixtures when running the test suite in multisite mode.
See #39264.
git-svn-id: https://develop.svn.wordpress.org/trunk@40077 602fd350-edb4-49c9-b593-d223f7449a82
Prevent a potential error condition if Backbone history is started by a plugin or theme before core tries to start it.
Props tfrommen.
Fixes#39612.
git-svn-id: https://develop.svn.wordpress.org/trunk@40076 602fd350-edb4-49c9-b593-d223f7449a82
Fix parsing of custom namespace routes. Transform class names, removing dashes and capitalizing each word/route part so a route path of `widgets/recent-posts` becomes a collection with the name `WidgetsRecentPosts`. Correct parent route part when routes are longer than expected, reversing parse direction.
Props westonruter, jazbek.
Fixes#39561.
git-svn-id: https://develop.svn.wordpress.org/trunk@40074 602fd350-edb4-49c9-b593-d223f7449a82
Follow-up to [40065] - `JSON_*` constants are differently unsupported in PHP 5.2 and 5.3, which caused other, more different failures.
Also bring back `JSON_UNESCAPED_SLASHES` because the generated output looks nicer this way.
Fixes#39264.
git-svn-id: https://develop.svn.wordpress.org/trunk@40066 602fd350-edb4-49c9-b593-d223f7449a82
Remove `JSON_UNESCAPED_SLASHES` from the `wp_json_encode` call - this constant is not supported in PHP < 5.4, and we don't polyfill it either.
Also make the PHPUnit test suite correctly exit with a non-zero exit code when `wp-tests-config.php` is not present. This was causing `grunt restapi-jsclient` to incorrectly proceed to its second step even when the first step failed with this error.
Props ocean90.
Fixes#39264.
git-svn-id: https://develop.svn.wordpress.org/trunk@40065 602fd350-edb4-49c9-b593-d223f7449a82
Ensures that links with `javascript:`, `mailto:` and other protocols work as expected in the customizer preview.
Fixes#39797.
git-svn-id: https://develop.svn.wordpress.org/trunk@40064 602fd350-edb4-49c9-b593-d223f7449a82
The `post_author` field is a string internally, but we need to cast it to an integer in the REST API. This was already done for posts, but not for revisions. The field is already declared as an integer in both controllers.
Fixes#39871.
git-svn-id: https://develop.svn.wordpress.org/trunk@40063 602fd350-edb4-49c9-b593-d223f7449a82
Add a data normalization pass when generating data fixtures for the REST API endpoints. Ensures that the `wp-api-generated.js` fixture won't change between test runs. Set more default properties and use fixed values for any properties that can't be easily controlled (object IDs and derivatives like link). Generate the fixture file with JSON_PRETTY_PRINT so that future diffs are easier to follow.
Props jnylen0, netweb.
Fixes#39264.
git-svn-id: https://develop.svn.wordpress.org/trunk@40061 602fd350-edb4-49c9-b593-d223f7449a82
Add a debounce wrapper to the media grid search handler. The search callback is now fired after a 300 ms typing pause.
Remove redundant handlers for 'search' and 'change', preventing multiple/duplicate search callbacks.
Props certainstrings, joemcgill, Kelderic, batmoo.
Fixes#38911.
git-svn-id: https://develop.svn.wordpress.org/trunk@40060 602fd350-edb4-49c9-b593-d223f7449a82
Add QUnit tests: verify that wp-api loads correctly, verify that the expected base models and collections exist and can be instantiated, verify that collections contain the correct models, verify that expected helper functions are in place for each collection.
The QUnit tests rely on two fixture files: `tests/qunit/fixtures/wp-api-generated.js` contains the data response from each core endpoint and is generated by running the PHPUnit `restapi-jsclient` group. `tests/qunit/fixtures/wp-api.js` maps the generated data to endpoint routes, and overrides `Backbone.ajax` to mock the responses for the tests.
Add PHPUnit tests in `tests/phpunit/tests/rest-api/rest-schema-setup.php`. First, verify that the API returns the expected routes via `server->get_routes()`. Then, the `test_build_wp_api_client_fixtures` test goes thru each endpoint and requests it from the API, tests that it returns data, and builds up the data for the mocked QUnit tests, saving the final results to `tests/qunit/fixtures/wp-api-generated.js`.
Add a new grunt task `restapi-jsclient` which runs the phpunit side data generation and the qunit tests together.
Props jnylen0, welcher.
Fixes#39264.
git-svn-id: https://develop.svn.wordpress.org/trunk@40058 602fd350-edb4-49c9-b593-d223f7449a82
This commit adds test cases for the interaction (or more accurately, lack of
interaction) between `orderby=post__in` and the `order` parameter.
Props fibonaccina.
See #39055.
git-svn-id: https://develop.svn.wordpress.org/trunk@40056 602fd350-edb4-49c9-b593-d223f7449a82
Fixes issue where the edit shortcut for a nav menu gets dropped when the containing Custom Menu widget is updated.
See #39101.
Fixes#39353.
git-svn-id: https://develop.svn.wordpress.org/trunk@40055 602fd350-edb4-49c9-b593-d223f7449a82
Updates `.button-link` adding color and underline to make link-like buttons look
like links by default. Introduces `.button-link-delete` as a modifier, stackable
CSS class for red button-links.
Props Cheffheid, afercia.
See #34242.
Fixes#35126.
git-svn-id: https://develop.svn.wordpress.org/trunk@40052 602fd350-edb4-49c9-b593-d223f7449a82
Keep bumping the date for the auto-draft to preserve it from garbage-collection via `wp_delete_auto_drafts()` after 7 days.
See #30937.
Fixes#39713.
git-svn-id: https://develop.svn.wordpress.org/trunk@40041 602fd350-edb4-49c9-b593-d223f7449a82
Correct an issue during the client's dynamic route discovery in `wp.api.utils.decorateFromRoute` where `_.union` potentially failed if used on objects.
Props ketuchetan.
Fixes#39341.
git-svn-id: https://develop.svn.wordpress.org/trunk@40040 602fd350-edb4-49c9-b593-d223f7449a82
This prevents the "non-numeric value encountered" warning in PHP 7.1, caused by trying to increment an empty string on the first loop iteration.
Props drrobotnik for initial patch.
Fixes#39774.
git-svn-id: https://develop.svn.wordpress.org/trunk@40039 602fd350-edb4-49c9-b593-d223f7449a82
This commit adds tests for `orderby=relevance` combined with a search term in the REST API.
It also improves tests for the `orderby` parameter in `WP_REST_Posts_Controller` by looking at the generated SQL query instead of creating a bunch of carefully arranged test objects. This should be much more robust, and we can use this approach in other places (such as #39055).
Fixes#39079.
git-svn-id: https://develop.svn.wordpress.org/trunk@40037 602fd350-edb4-49c9-b593-d223f7449a82
Fixes bad conditions in `WP_Customize_Setting::get_root_value()` and `WP_Customize_Setting::set_root_value()`.
Props dlh.
Amends [35007].
See #32103.
Fixes#36952.
git-svn-id: https://develop.svn.wordpress.org/trunk@40036 602fd350-edb4-49c9-b593-d223f7449a82
The function should fail more gracefully when called in the context
where `get_query_var( 'post_type' )` doesn't represent an actual post
type.
Props technopolitica, dlh.
Fixes#38374.
git-svn-id: https://develop.svn.wordpress.org/trunk@40031 602fd350-edb4-49c9-b593-d223f7449a82
Partial revert of [38929].
This reverts the source code from the commit for #30210 to prevent valid but empty feeds from returning 404 file not found errors for the home and custom feeds.
The tests in the commit that remain applicable are retained.
Props pavelevap for reporting, stevenkword for initial patch.
See #30210.
Fixes#39157.
git-svn-id: https://develop.svn.wordpress.org/trunk@40030 602fd350-edb4-49c9-b593-d223f7449a82