Commit Graph

36123 Commits

Author SHA1 Message Date
Joe McGill
9cf5b91e9c Media: Keep PDF previews from overwriting files.
Since support for PDF previews were added in [38949], it's possible
that the generated image file could overwrite an existing image file
with the same name. This uses wp_unique_filename() to avoid this
issue and adds a '-pdf' identifier on the end of filenames.

Props gitlost, desrosj, mikeschroder, joemcgill.
Merges [40130] and [40131] to the 4.7 branch.
Fixes #39875. See #31050.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40133 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 19:24:50 +00:00
Joe McGill
2e5f3b41a8 Media: Restore correct upload errors displaying after [37610].
Props codegeass, MatheusGimenez, joemcgill.
Merges [40126] to the 4.7 branch.
Fixes #39516.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40132 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 19:20:58 +00:00
Sergey Biryukov
7182e5b7b4 Plugins: After [38703], adjust the selector for checkbox selection to account for nested tables.
Props afercia, swissspidy, reldev.
Merges [40118] to the 4.7 branch.
Fixes #39739.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40119 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 23:12:51 +00:00
Sergey Biryukov
44c58d1a12 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, adamsilverstein, jnylen0.
Merges [40074] and [40109] to the 4.7 branch.
Fixes #39561.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40117 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 22:47:47 +00:00
Sergey Biryukov
dbf739bbaa 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, adamsilverstein, netweb, ocean90, rachelbaker.
Merges [40058], [40061], [40065], [40066], [40077], and [40104] to the 4.7 branch.
Fixes #39264.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40116 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 22:33:05 +00:00
Sergey Biryukov
9afe01b087 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, jnylen0.
Merges [40108] to the 4.7 branch.
Fixes #38883.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40115 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 22:02:48 +00:00
Sergey Biryukov
9c7ef6a3ad 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.

Props jnylen0.
Merges [40101] to the 4.7 branch.
Fixes #39256.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40114 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 21:58:07 +00:00
Sergey Biryukov
32ccf017de 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.
Merges [40105] to the 4.7 branch.
Fixes #39933.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40113 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 20:56:00 +00:00
Andrew Ozz
fd740182af TinyMCE: preserve empty image alt attributes.
Props afercia.
Merges [40110] to the 4.7 branch.
Fixes #39912.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40112 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 20:51:19 +00:00
Sergey Biryukov
caebbb456e 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.
Merges [40106] to the 4.7 branch.
Fixes #39701.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40111 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 20:45:52 +00:00
Dion Hulse
8d666d2ce1 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, westonruter.
Merges [40082] to the 4.7 branch.
Fixes #38559.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40100 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 07:04:34 +00:00
Dion Hulse
809c9d5b7a 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.

Props westonruter.
Merges [40041] to the 4.7 branch.
See #30937.
Fixes #39713.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40099 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 07:02:14 +00:00
Dion Hulse
bce41a8435 Customize: Allow custom post types to be used in starter content.
Changes `WP_Customize_Nav_Menus::insert_auto_draft_post()` so it can be invoked for a `post_type` that is not registered (yet).

Props westonruter.
Merges [39924] to the 4.7 branch.
See #38615, #38114.
Fixes #39610.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40098 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 07:01:07 +00:00
Dion Hulse
cba5d45c90 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.

Props westonruter.
Merges [40055] to the 4.7 branch.
See #39101.
Fixes #39353.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40097 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 06:58:37 +00:00
Dion Hulse
ce9e48622a 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.

Props westonruter.
Merges [40064] to the 4.7 branch.
Fixes #39797.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40096 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 06:55:18 +00:00
Dion Hulse
9307967ccf Customize: Always enqueue customize-preview stylesheet in the customizer preview to style selective refresh and visual edit shortcuts.
Enqueues the style along with the `customize-preview` script in the manager instead of via the `widgets` and `nav_menus` components, ensuring that the stylesheet is loaded for users who cannot manage widgets or nav menus.

Props dlh, westonruter.
Merges [39951] to the 4.7 branch.
See #27403.
Fixes #39498.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40095 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 06:53:19 +00:00
Dion Hulse
60ca80009a Customize: Trim whitespace from nav menu item titles so that the underlying object's original title appears as input placeholder and in the control's title.
Whitespace is trimmed from titles in PHP when saved in any case, so this aligns the client-side behavior with what happens on the server.

Amends [38618].
Merges [39994] to the 4.7 branch.
See #38015.
Fixes #39600.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40094 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 06:51:47 +00:00
Dion Hulse
bb3ffecc32 Customize: Update customize.php URL with changeset_uuid param the instant a change is made instead of deferring until the changeset update request responds.
Props asalce, westonruter.
Merges [39686] to the 4.7 branch.
Fixes #39227.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40093 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 06:49:39 +00:00
Dion Hulse
dd766aa246 Menus: Prevent notice thrown in class-walker-page.php.
Calling `Walker_Page::walk()` directly was causing an `Undefined index: item_spacing` notice to be thrown, this adds an `isset()` check to prevent it.

Props bhargavbhandari90, peterwilsoncc.
Merges [39949] to the 4.7 branch.
Fixes #39564.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40092 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 03:50:13 +00:00
Dion Hulse
28bcb22f2f Formatting: fix wpautop() to stop adding paragraph tags around <figcaption>.
Props azaozz, pbearne for tests.
Merges [39912], [39914] to the 4.7 branch.
Fixes #39307 for 4.7.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40091 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-21 03:41:42 +00:00
Sergey Biryukov
b34712067e 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.
Merges [40089] to the 4.7 branch.
Fixes #39560.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40090 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-20 13:08:20 +00:00
Dion Hulse
1109726f83 Customize: Ensure root values are accessible in multidimensional custom setting types.
Fixes bad conditions in `WP_Customize_Setting::get_root_value()` and `WP_Customize_Setting::set_root_value()`.

Props dlh, westonruter.
Amends [35007].
Merges [40036] to the 4.7 branch.
See #32103.
Fixes #36952.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40088 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-20 06:49:11 +00:00
Dion Hulse
5a0a298082 Customize: Introduce get_header_video_url filter for the return value of get_header_video_url().
Props sanket.parmar, celloexpressions, SergeyBiryukov.
Merges [40045], [40086] to the 4.7 branch.
Fixes #39512.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40087 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-20 06:47:39 +00:00
Dion Hulse
af53eecf76 Feeds: Prevent empty feeds from returning 404 errors.
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, peterwilsoncc.
See #30210.
Merges [40030] to the 4.7 branch.
Fixes #39157.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40085 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-20 06:37:22 +00:00
Dion Hulse
f6c038da0c 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, adamsilverstein.
Merges [40040] to the 4.7 branch.
Fixes #39341.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40084 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-20 06:34:17 +00:00
Dion Hulse
8531c4e5a6 Taxonomy: Disallow overriding the name property when registering a taxonomy.
Props wpfo for initial patch, swissspidy.
Merges [40049] to the 4.7 branch.
Fixes #39308.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40083 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-20 06:15:07 +00:00
Rachel Baker
72294c9caa 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.
Merges [40080] to the 4.7 branch.
Fixes #39466.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40081 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-19 04:35:28 +00:00
Rachel Baker
3daa063286 REST API: Correctly serve the index with PATH_INFO
When hitting the index, `untrailingslashit()` would make the REST route empty, which would then use the fallback inside WP_REST_Server. This isn't a problem most of the time, but WP_REST_Server contains a fallback to PATH_INFO. Combined with PATH_INFO permalinks, this would give a 404 on the API index, as it attempts to look up a route for "/wp-json/".

Props ccprog.
Merges [39923] to the 4.7 branch.
Fixes #39432.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40079 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-19 03:27:13 +00:00
Rachel Baker
7be9593b68 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.

Props jnylen0.
Merges [40063] to the 4.7 branch.
Fixes #39871.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40078 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-19 03:18:38 +00:00
Sergey Biryukov
c6511562c6 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.
Merges [40039] to the 4.7 branch.
Fixes #39774.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40075 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 21:23:52 +00:00
Dion Hulse
a345f95664 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.
Merges [40070] to the 4.7 branch.
Fixes #39277, #39304.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40071 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 06:46:45 +00:00
Dion Hulse
7759f06d5f 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.
Merges [40068] to the 4.7 branch.
Fixes #39783.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40069 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-17 05:06:23 +00:00
Aaron D. Campbell
51887464fe Post-4.7.2 version bump for 4.7 branch.
git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40018 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 21:57:54 +00:00
Aaron D. Campbell
f36d9405fc Fix version to 4.7.2 not 4.7.3.
git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39997 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 18:19:00 +00:00
Aaron D. Campbell
c0f14f8f06 Bump 4.7 branch to version 4.7.2.
git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39995 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 18:13:02 +00:00
Boone Gorges
4bc40bf97b Revert to pre-4.7 behavior for fetching object instances by id.
This changeset reverts [38381], which caused inconsistencies in the way the
REST API fetches posts and other objects.

Merge of [39992] to the 4.7 branch.

See #38792, #37738.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39993 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 16:56:21 +00:00
John Blackbourn
437de3aec6 Posts, Post Types: When using Excerpt mode on the Posts list table, ensure the excerpt output matches what was manually entered into the Excerpt field.
Merges [39956] to the 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39990 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 15:11:53 +00:00
Dominik Schilling (ocean90)
f8d636aadb Press This: Do not show Categories & Tags UI for users who cannot assign terms to posts anyways.
Merge of [39968] to the 4.7 branch.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39969 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 14:00:03 +00:00
Dominik Schilling (ocean90)
c9cd77ce11 REST API: Unify object access handling for simplicity.
Rather than repeating ourselves, unifying the access into a single method keeps everything tidy. While we're at it, add in additional schema handling for common parameters.

Merge of [39954] to the 4.7 branch.

See #38792.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39957 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 13:46:54 +00:00
Dominik Schilling (ocean90)
3bbc452bd7 Query: Ensure that queries work correctly with post type names with special characters.
Merge of [39952] to the 4.7 branch.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39953 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 13:35:34 +00:00
Aaron D. Campbell
47ce489083 Post-4.7.1 version bump for 4.7 branch.
git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39883 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 21:35:25 +00:00
Aaron D. Campbell
69f767fab8 Only show major version in readme.html for 4.7 branch
git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39871 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 17:45:04 +00:00
Joe McGill
173bfd1a32 Media: Fix exif_imagetype check in wp_get_image_mime
This is a follow up to [39831].

Merges [39850] to the 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39851 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 16:37:51 +00:00
Joe McGill
5e7d198785 Tests: Replace broken codeispoetry.png file.
This also updates the test filename in
`WP_Test_REST_Attachments_Controller::test_create_item_default_filename_title()`
to accurately match the actual file name.

Merges [39848] to the 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39849 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 16:27:17 +00:00
Aaron D. Campbell
ebda9908e5 Bump 4.7 branch to version 4.7.1.
git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39845 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 15:14:11 +00:00
Aaron D. Campbell
8214df823f REST API: Change which users are shown in the users endpoint.
Only show users that have authored a post of a post type that has `show_in_rest` set to true.

Props rachelbaker, jnylen0.
Merges [39843] to 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39844 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 14:48:04 +00:00
Joe McGill
879f152f69 Media: Improve image filetype checking.
This adds a new function `wp_get_image_mime()` which is used by
`wp_check_filetype_and_ext()` to validate image files using
`exif_imagetype()` if available instead of `getimagesize()`.

`getimagesize()` is less performant than `exif_imagetype()` and is
dependent on GD. If `exif_imagetype()` is not available, it falls back to
`getimagesize()` as before.

If `wp_check_filetype_and_ext()` can't validate the filetype, we now return
`false` for ext/MIME values.

Merges [39831] to the 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39832 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 13:11:52 +00:00
Dominik Schilling (ocean90)
d59732bd70 Updates: Translate plugin data on the Updates screen.
Merge of [39808] to the 4.7 branch.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39820 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 11:38:25 +00:00
Dominik Schilling (ocean90)
089f7170b1 Themes: Fix markup for theme name fallbacks.
Merge of [39807] to the 4.7 branch.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39809 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 11:07:57 +00:00
Jeremy Felt
dfa88bd587 Multisite: Use wp_rand() in signup key creation.
Merges [39795] to the 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39796 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 05:30:21 +00:00