Commit Graph

36321 Commits

Author SHA1 Message Date
James Nylen
4414e3c20a REST API: Shim post_date_gmt for drafts / empty dates in the REST API.
Internally, WordPress uses a special `post_date_gmt` value of `0000-00-00 00:00:00` to indicate that a draft's date is "floating" and should be updated whenever the post is saved.  This makes it much more difficult for API clients to know the correct date of a draft post.

This commit provides a best guess at a `date_gmt` value for draft posts in this situation using the `date` field and the site's current timezone offset.

Props joehoyle.
Fixes #38883.


git-svn-id: https://develop.svn.wordpress.org/trunk@40108 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 18:14:21 +00:00
Adam Silverstein
dbfd852fc2 Themes: enable browser history support in add new theme screen.
Enable history support for the new theme screen, including navigating theme details and closing the details modal. Theme selection is now also bookmark-able, so linking to a URL like `/wp-admin/theme-install.php?theme=twentyseventeen` correctly opens the theme preview.

Props dd32.
Fixes #36613.


git-svn-id: https://develop.svn.wordpress.org/trunk@40107 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 17:47:30 +00:00
Felix Arntz
0f9dd5f88f REST API: Do not allow access to users from a different site in multisite.
It has been unintendedly possible to both view and edit users from a different site than the current site in multisite environments. Moreover, when passing roles to a user in an update request, that user would implicitly be added to the current site.

This changeset removes the incorrect behavior for now in order to be able to provide a proper REST API workflow for managing multisite users in the near future. Related unit tests have been adjusted as well.

Props jnylen0, jeremyfelt, johnjamesjacoby.
Fixes #39701.


git-svn-id: https://develop.svn.wordpress.org/trunk@40106 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-23 22:36:54 +00:00
James Nylen
f366757b55 REST API: Correctly parse body parameters for DELETE requests.
DELETE was inadvertently omitted from the list of non-POST HTTP methods that should be able to accept body parameters.  Parameters passed to DELETE requests as JSON are already parsed correctly; this commit fixes `application/x-www-form-urlencoded` parameters as well.

Props mnelson4.
Fixes #39933.


git-svn-id: https://develop.svn.wordpress.org/trunk@40105 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-23 20:09:11 +00:00
James Nylen
6a23c57ad5 REST API: Ensure that tests pass if extra endpoints are registered.
Many plugins and themes use the WP core test suite to run their unit tests, so the API tests shouldn't fail if there are extra endpoints registered in non-core namespaces.

Props rachelbaker.
Fixes #39264.


git-svn-id: https://develop.svn.wordpress.org/trunk@40104 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-23 15:49:44 +00:00
Sergey Biryukov
109f63fb6b Docs: Update the description of is_singular() and WP_Query::is_singular() to be parsed correctly by developer.wordpress.org.
Props grapplerulrich.
Fixes #39948.

git-svn-id: https://develop.svn.wordpress.org/trunk@40103 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-23 10:29:27 +00:00
Felix Arntz
cf93e7996d Multisite: Use WP_Network_Query in WP_Network::get_by_path().
An additional unit test has been introduced to verify the method works properly when using an external object cache.

Props spacedmonkey, jeremyfelt.
Fixes #37217.


git-svn-id: https://develop.svn.wordpress.org/trunk@40102 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-22 10:41:20 +00:00
James Nylen
83d27ba447 REST API: Fix multiple issues with setting dates of posts and comments.
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
2017-02-21 18:17:32 +00:00
SergeyBiryukov
c31acbfe7e About page: Remove autoplay and loop attributes on "Theme Starter Content", "Edit Shortcuts", and "Video Headers" videos, originally added as a part of [39512].
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
2017-02-20 13:00:19 +00:00
dd32
22a410e1c5 Customize: Update the introduced version in the docs for the get_header_video_url filter to 4.7.3.
See #39512.


git-svn-id: https://develop.svn.wordpress.org/trunk@40086 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-20 06:46:34 +00:00
westonruter
e13e8bab1c Customize: Prevent vertical clipping of thumbnail in header image customizer control.
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
2017-02-20 00:09:37 +00:00
rachelbaker
bf6a689c65 REST API: Include the status property in view context responses from the Posts endpoints.
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
2017-02-19 04:31:12 +00:00
jnylen0
127f243bfe REST API: Skip generating the client test fixtures in multisite mode.
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
2017-02-18 19:29:24 +00:00
adamsilverstein
0d73b031c8 JavaScript: when starting Backbone history, stop if previously started.
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
2017-02-17 21:59:37 +00:00
Adam Silverstein
0efaf5ddc5 REST API: JavaScript client - improve route discovery for custom namespaces.
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
2017-02-17 20:53:57 +00:00
Pascal Birchler
c39fa0ff22 I18N: Update translators comment after [40072].
Props ocean90.
See #39898.

git-svn-id: https://develop.svn.wordpress.org/trunk@40073 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 10:20:38 +00:00
Pascal Birchler
c49b9ea9c2 I18N: Fix broken sprintf() after [40067].
See #39898.

git-svn-id: https://develop.svn.wordpress.org/trunk@40072 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 10:14:12 +00:00
Dion Hulse
82f99ca927 Media: Avoid PHP Warnings in get_post_galleries() when processing empty [gallery] shortcodes and avoid returning the incorrect results when the global $post does not match the provided post ID.
Props dd32, joemcgill, seanchayes.
Fixes #39277, #39304.


git-svn-id: https://develop.svn.wordpress.org/trunk@40070 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 06:45:31 +00:00
Dion Hulse
bfeda161b7 HTTP API: Restore backwards compatibility with the http_api_curl filter - it expects that the handle parameter is passed as a reference, however [39212] missed that.
Props pento.
Fixes #39783.


git-svn-id: https://develop.svn.wordpress.org/trunk@40068 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 05:05:03 +00:00
Sergey Biryukov
332244f7fb I18N: Remove <code> tags from translatable strings in wp-includes/customize/class-wp-customize-custom-css-setting.php.
Fixes #39898.

git-svn-id: https://develop.svn.wordpress.org/trunk@40067 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 02:22:40 +00:00
James Nylen
900c67ed46 REST API: Skip generating the client test fixtures in PHP 5.2 and 5.3.
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
2017-02-17 00:12:49 +00:00
James Nylen
9d96b31b90 REST API: Fix the client test fixture generation in PHP 5.2 and 5.3.
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
2017-02-16 23:29:16 +00:00
Weston Ruter
a01edcf0a6 Customize: Skip intercepting non-HTTP(S) links in customizer preview just as jump links are ignored.
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
2017-02-16 21:20:45 +00:00
James Nylen
392fd09f82 REST API: Cast revision author ID to int.
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
2017-02-16 20:08:23 +00:00
Sergey Biryukov
beb9d91279 Docs: Correct @return value type for wp_nav_menu().
Props chesio.
Fixes #39890.

git-svn-id: https://develop.svn.wordpress.org/trunk@40062 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-16 16:08:36 +00:00
Adam Silverstein
e3d5e1c6c8 REST API: improve test fixture generation, normalizing data.
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
2017-02-15 17:58:14 +00:00
Adam Silverstein
2e0f576156 Media: debounce the media grid search, avoiding duplicate requests.
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
2017-02-15 17:28:54 +00:00
Andrea Fercia
dccf1535a4 Buttons: Fix a few .button-link glitches after [40052].
Removes some stray underlines. Explicitly set the button text to be left aligned.

Props Cheffheid, f.staude, Presskopp.

See #34242.
Fixes #35126, #38712.


git-svn-id: https://develop.svn.wordpress.org/trunk@40059 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-14 18:41:25 +00:00
Adam Silverstein
1879140548 REST API: Add QUnit tests for wp-api.js and PHPUnit fixture generation.
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
2017-02-14 04:22:32 +00:00
John Blackbourn
acf5ca35c8 Themes: Add template type and template candidates as parameters to the {$type}_template filter.
Props mschadegg
Fixes #39525


git-svn-id: https://develop.svn.wordpress.org/trunk@40057 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-12 21:24:16 +00:00
James Nylen
38c3556674 WP_Query: Add tests for the combination of orderby=post__in and order.
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
2017-02-12 18:06:32 +00:00
Weston Ruter
61752051de Customize: Ensure edit shortcuts get re-created for nested partials when a parent partial is refreshed.
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
2017-02-11 03:34:10 +00:00
Sergey Biryukov
dae17ac91a Pings/Trackbacks: Avoid scheduling multiple do_pings events in _publish_post_hook().
Props ethitter.
Fixes #39828.

git-svn-id: https://develop.svn.wordpress.org/trunk@40054 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-10 03:08:28 +00:00
Sergey Biryukov
b4638abeda Docs: Add missing meta_type and meta_compare arguments to WP_Term_Query::__construct() and get_terms() docblocks.
Props 1naveengiri.
Fixes #39825.

git-svn-id: https://develop.svn.wordpress.org/trunk@40053 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-10 02:27:36 +00:00
Andrea Fercia
7487559dfd Buttons: Improve the .button-link CSS class for link-like buttons.
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
2017-02-09 16:46:58 +00:00
Scott Taylor
87364b0586 Media: in wp.media.view.DeleteSelectedPermanentlyButton, move destructive async operations outside of the selection loop.
Fixes #39780.


git-svn-id: https://develop.svn.wordpress.org/trunk@40051 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-08 19:43:58 +00:00
Scott Taylor
baff296dfa Media: in wp.media.view.Toolbar.refresh(), check for a selection before iterating over models.
Props chandrapatel.
Fixes #39511.


git-svn-id: https://develop.svn.wordpress.org/trunk@40050 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-08 19:16:34 +00:00
Pascal Birchler
4004400047 Taxonomy: Disallow overriding the name property when registering a taxonomy.
Props wpfo for initial patch.
Fixes #39308.

git-svn-id: https://develop.svn.wordpress.org/trunk@40049 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-06 19:38:36 +00:00
Sergey Biryukov
8900e2466e Docs: Add a note to retrieve_password_message filter that password reset email will not be sent if the filtered message is empty.
Props sudar.
Fixes #39788.

git-svn-id: https://develop.svn.wordpress.org/trunk@40048 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-06 04:15:22 +00:00
Sergey Biryukov
912059b82f Docs: Use third-person singular verb for rest_avatar_sizes filter description.
See #39130.

git-svn-id: https://develop.svn.wordpress.org/trunk@40047 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-06 02:57:46 +00:00
Sergey Biryukov
d295ea290e Docs: Use third-person singular verb for wp_get_custom_css filter description.
See #39130.

git-svn-id: https://develop.svn.wordpress.org/trunk@40046 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-06 02:56:42 +00:00
Sergey Biryukov
b5ce5759aa Customize: Introduce get_header_video_url filter for the return value of get_header_video_url().
Props sanket.parmar, celloexpressions.
Fixes #39512.

git-svn-id: https://develop.svn.wordpress.org/trunk@40045 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-06 02:51:20 +00:00
Pascal Birchler
acd6d129b9 General: Add tests for wp_parse_slug_list().
Props danielbachhuber.
See #35582.

git-svn-id: https://develop.svn.wordpress.org/trunk@40044 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-05 20:34:12 +00:00
Sergey Biryukov
bdae9cd0fd Docs: Clarify that get_the_category_list() and the_category() display links as an unordered list by default.
See #39130.

git-svn-id: https://develop.svn.wordpress.org/trunk@40043 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-05 15:15:45 +00:00
Sergey Biryukov
d20d535e24 Docs: Clarify that has_excerpt() checks if the post has a custom excerpt, not some generated excerpt.
See #35487.

git-svn-id: https://develop.svn.wordpress.org/trunk@40042 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-05 14:34:16 +00:00
Weston Ruter
647f06c2c1 Customize: Extend auto-draft life of a customize_changeset post whenever modified.
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
2017-02-05 06:38:57 +00:00
Adam Silverstein
4b22b97004 REST API: JavaScript client should use _.extend when merging objects.
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
2017-02-03 21:45:06 +00:00
Sergey Biryukov
0b63252b2d Media: In wp_unique_filename(), use explicit type casting when incrementing $number.
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
2017-02-03 20:57:38 +00:00
SergeyBiryukov
3155c8ac3e REST API: After [38947], improve the wording of the message to clarify that rest_authentication_errors is a filter.
See #38446.

git-svn-id: https://develop.svn.wordpress.org/trunk@40038 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-01 21:31:02 +00:00
James Nylen
6c32c99a97 REST API: Improve posts orderby tests
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
2017-02-01 20:30:17 +00:00