Commit Graph

2552 Commits

Author SHA1 Message Date
John Blackbourn 043d3b54a8 Build/Test tools: Improve the failure message reported by `assertQueryTrue()` so it's a little less cryptic.
Fixes #40411


git-svn-id: https://develop.svn.wordpress.org/trunk@40416 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-11 10:48:00 +00:00
Felix Arntz 1abf42b45e Multisite: Introduce an `upgrade_network` capability.
Prior to this change, a mix of `is_super_admin()` calls and `manage_network` capability checks was used to determine whether the current user could upgrade the network. With this changeset a dedicated capability is introduced that allows more granular handling.

Props dhanendran for the original patch.
Fixes #39205. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40404 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-10 21:10:48 +00:00
Andrew Ozz d37198f240 TinyMCE: update the tests for version 4.5.6. Remove default plugins tests, it is quite pointless to keep repeating them at this point.
See #40305.


git-svn-id: https://develop.svn.wordpress.org/trunk@40399 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-09 23:10:15 +00:00
Joe McGill 04e3680d1c Media: Improve handling of non-image files in wp_get_image_mime.
This prevents non-image fileypes from returning a mime type of
"application/octet-stream" when `exif_imagetype()` returns `false`.

Props blobfolio.
Fixes #40017.


git-svn-id: https://develop.svn.wordpress.org/trunk@40397 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-09 22:43:04 +00:00
John Blackbourn 2a261f0d7c Build/Test tools: Remove occurrences of `create_function()` in unit tests.
Props desrosj

See #37082


git-svn-id: https://develop.svn.wordpress.org/trunk@40392 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-07 13:37:39 +00:00
Felix Arntz 4fbac9b3a7 Multisite: Partially revert [40295].
[40295] removed the restriction of a minimum amount of characters for new site names, which could cause unexpected behavior. That changeset is reverted here with the exception of the removal of the `is_super_admin()` check, which can safely be omitted. A new filter for the minimum site name length will be introduced later to be able to modify that behavior.

See #39676, #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40391 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-07 13:14:36 +00:00
Felix Arntz 3ca0673036 Multisite: Introduce a `setup_network` capability for setting up multisite.
`setup_network` is a new meta capability that brings more granular control over the permissions to setup a multisite environment. In a non-multisite environment it falls back to `manage_options` while in a multisite it falls back to `manage_network_options`. The introduction of this capability furthermore allows replacing an `is_super_admin()` check.

Props ashokkumar24 for the original patch.
Fixes #39206. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40390 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-07 12:52:24 +00:00
James Nylen a7b3612f2a REST API: Allow fetching multiple users at once via the `slug` parameter.
This matches similar changes previously made for posts (#38579) and terms (#40027).

Props curdin, MatheusGimenez.
Fixes #40213.


git-svn-id: https://develop.svn.wordpress.org/trunk@40378 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-05 22:24:24 +00:00
James Nylen 99de5d69d7 REST API: Allow fetching multiple terms at once via the `slug` parameter.
This matches a similar change previously made for posts (#38579) and an upcoming change for users (#40213).

Props wonderboymusic, MatheusGimenez, curdin.
Fixes #40027.


git-svn-id: https://develop.svn.wordpress.org/trunk@40376 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-05 20:24:27 +00:00
flixos90 707bf79a9b Multisite: Add `$network_id` parameter to `get_user_count()`.
The `get_user_count()` function returns the number of active users on a network, which is stored in a `user_count` network option. Since `get_network_option()` supports retrieving options from other networks than the current one, `get_user_count()` can now make use of that feature.

Fixes #37866.


git-svn-id: https://develop.svn.wordpress.org/trunk@40371 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-03 23:31:33 +00:00
flixos90 117f2da3cc Multisite: Support the `$network_id` parameter of `get_blog_count()`.
The `get_blog_count()` function used to support an `$id` parameter for the network ID prior to WordPress 3.1. This parameter has not been used since the introduction of `get_site_option()` and was later deprecated in [25113]. With `get_network_option()` however it is possible to support the parameter again, now properly renamed as `$network_id`.

A unit test has for the parameter has been added as well. Another unit test in the same class was adjusted to work properly with multiple networks existing.

Fixes #37865.


git-svn-id: https://develop.svn.wordpress.org/trunk@40370 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-03 23:13:40 +00:00
Adam Silverstein 926853f3a3 REST API: JS Client - Enable connecting to multiple endpoints.
Enable connecting to multiple wp-api `endpoints`. Calling `wp.api.init` with a new `apiRoot` will parse the new endpoint's schema and store a new set of models and collections. A collection of connected endpoints is stored in `wp.api.endpoints`.

Props lucasstark.
Fixes #39683.



git-svn-id: https://develop.svn.wordpress.org/trunk@40364 602fd350-edb4-49c9-b593-d223f7449a82
2017-04-02 19:40:37 +00:00
Boone Gorges cc1c0639d0 Invalidate term query caches when setting or deleting term relationships.
Prior to 4.7, term relationships - as set by `wp_set_object_terms()` or
`wp_remove_object_terms()` - did not affect the term query cache. The
introduction of the 'object_ids' parameter in 4.7 means that the query
cache must be aware of object-term relationships. As such, the
'last_changed' incrementor is now invalidated when term relationships
are modified.

This bug only reared its head when delaying term counting, because term
counting performs its own term query cache invalidation.

Props mboynes.
Fixes #40306.

git-svn-id: https://develop.svn.wordpress.org/trunk@40353 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-30 16:49:47 +00:00
James Nylen c7f1aeb441 Tests: Remove a couple of invalid error assertions.
A couple of REST API tests had an assertion `assertNotInstanceOf( 'WP_Error', $response );` which will never be true.

Since these assertions are invalid, and also made redundant by the response status check, we can just remove them.

Props dlh.
Fixes #40270.


git-svn-id: https://develop.svn.wordpress.org/trunk@40350 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-29 17:05:41 +00:00
Jeremy Felt 8cc8a221fc Multisite: Remove unused `site-lookup` global cache group.
The `site-lookup` group was introduced in WPMU, but never actually used in WordPress core.

Props johnjamesjacoby.
Fixes #38725.


git-svn-id: https://develop.svn.wordpress.org/trunk@40347 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 21:07:22 +00:00
Jeremy Felt 6790fcb55d Multisite: Respect `$_wp_suspend_cache_invalidation` when clearing network and site caches.
Props johnjamesjacoby.
Fixes #40028.


git-svn-id: https://develop.svn.wordpress.org/trunk@40346 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 19:35:49 +00:00
Jeremy Felt 83002e564e Multisite: Allow falsy properties to be cached in `site-details`.
In previous iterations of `WP_Site`, there was concern that not all properties would be available when storing a site's details in cache. When introduced in [37918], an `ms_loaded` check was added to address this concern. Any properties that are still `false` after `ms_loaded` really are `false` and can be cached as such.

Props flixos90.
Fixes #40247.


git-svn-id: https://develop.svn.wordpress.org/trunk@40344 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 02:31:13 +00:00
Jeremy Felt 308554bd84 Tests: Add missing global cache groups.
Add `useremail`, `userslugs`, `networks`, `sites`, and `site-details` as global cache groups when added with unit tests. This aligns the list with the core default.

Fixes #40283.


git-svn-id: https://develop.svn.wordpress.org/trunk@40343 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 01:45:43 +00:00
Jeremy Felt b36363bb69 Tests: Clarify zero path segment tests for `get_network_by_path()`.
The set of assertions in this data provider intend to test a 0 path segment configuration rather than the use of paths.

Fixes #37217.


git-svn-id: https://develop.svn.wordpress.org/trunk@40342 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-28 01:24:44 +00:00
Jeremy Felt 2f39fe479f Tests: Consolidate logic used to skip API fixture generation.
This checks for `is_multisite()` and the minimum PHP version in the same block and removes two `echo` statements previously used to indicate generation had been skipped.

Fixes #40041.


git-svn-id: https://develop.svn.wordpress.org/trunk@40341 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-27 21:04:06 +00:00
Jeremy Felt ab57ab8e7f Multisite: Add `lang_id` support to `WP_Site_Query`.
Sites can now be queried by `lang_id`, `lang__in`, and `lang__not_in`.

Props ocean90.
Fixes #40196.


git-svn-id: https://develop.svn.wordpress.org/trunk@40340 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-27 19:47:53 +00:00
Jeremy Felt ba254dfa63 Tests: Use utf8mb4 max index length when creating keys.
In [31349], core `varchar` column key lengths were changed from 255 to 191 to support the 767 byte index size limit on standard utf8mb4 MySQL installs. This changes the DB schema tests to match.

Props caseypatrickdriscoll, clarinetlord.
Fixes #35958.


git-svn-id: https://develop.svn.wordpress.org/trunk@40339 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-27 19:33:55 +00:00
westonruter 1e7b157523 Customize: Improve i18n for strings in hidden widget area notices.
Amends [40312].
Props westonruter, ocean90, swissspidy, SergeyBiryukov, michelleweber for copywriting.
See #33567, #33052.
Fixes #39087.


git-svn-id: https://develop.svn.wordpress.org/trunk@40330 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-24 22:02:02 +00:00
Pascal Birchler 54baae39b2 REST API: Use `get_gmt_from_date()` when preparing a draft post for response.
This prevents wrong dates when dealing with DST, see [40115] and [40284].

Props nerrad.
Fixes #40136.

git-svn-id: https://develop.svn.wordpress.org/trunk@40324 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-24 17:31:54 +00:00
Felix Arntz df23b65221 Multisite: Add further unit tests for `get_blog_details()`.
These tests verify that the returned site object is iterable and contains the expected properties.

See #40228, #40180.


git-svn-id: https://develop.svn.wordpress.org/trunk@40317 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-23 17:13:14 +00:00
Weston Ruter 9528740aa3 Customize: Show notice in Widgets panel when there are additional widget areas not rendered in preview.
This extends the existing behavior which only showed a message only when there were no widget areas rendered in the preview. The number of non-rendered widget areas is indicated. Also removes needles deletion of `wp.customize.Widgets.data.l10n` property which hindered plugins.

See #33567, #33052.
Fixes #39087.


git-svn-id: https://develop.svn.wordpress.org/trunk@40312 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-22 19:02:26 +00:00
Rachel Baker bf7d411330 REST API: Confirm the parent post object of an attachment exists in `WP_REST_Posts_Controller::check_read_permission()`.
Avoid a PHP Error when attempting to embed the parent post of an attachment, when the parent post ID is invalid. Instead check if the parent post object exists before checking the read permission for the parent post.

Props GhostToast.
Fixes #39881. 


git-svn-id: https://develop.svn.wordpress.org/trunk@40306 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-20 04:29:50 +00:00
Felix Arntz e6fda09261 Multisite: Handle sites cache invalidation more granularly for option updates.
Previously `update_blog_option()` would trigger an invalidation of that site's entire cache although these changes did not affect the content of these caches. Furthermore changes to the special options `blogname`, `siteurl` and `post_count` should not invalidate the entire cache of that site, but only their respective site details cache. The option `home` now has the same behavior as it also belongs to the site details, but did not invalidate the cache at all previously.

Several new unit tests confirm these changes work as expected.

Fixes #40063.


git-svn-id: https://develop.svn.wordpress.org/trunk@40305 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-19 16:21:38 +00:00
Weston Ruter 83de39a7fb Customize: Trailingslash the home nav menu item URL in starter content.
This prevents an additional 301 redirect when clicking on the nav menu item, and it also prevents a scenario where the auth cookie may not be passed and cause an authentication error when navigating in the customizer.

Props dlh, swissspidy.
Fixes #40112.


git-svn-id: https://develop.svn.wordpress.org/trunk@40300 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-18 03:22:08 +00:00
Pascal Birchler 11d556e42b List Tables: Hide 'Empty Trash' and 'Empty Spam' buttons when view is already empty.
Props ivantedja, Presskopp, printsachen1, Jaydeep Rami, mathieuhays, cazm.
Fixes #38341.

git-svn-id: https://develop.svn.wordpress.org/trunk@40297 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 16:53:08 +00:00
Pascal Birchler e14051c031 Multisite: Ensure first page/post/comment content is not empty when setting up a new site.
This prevents creating page without any content when the options are populated with an empty string.

Props shadyvb.
Fixes #40036.

git-svn-id: https://develop.svn.wordpress.org/trunk@40296 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 15:48:35 +00:00
Felix Arntz eb7a3d1a2f Multisite: Remove restriction of minimum site name length in `wpmu_validate_blog_signup()`.
It is sometimes desirable to support shorter site names than 4 characters, therefore that restriction should be removed. It is still possible to manually enforce it by using the `wpmu_validate_blog_signup` filter.

As a result of this change, another `is_super_admin()` call gets removed which affects the ongoing efforts of working on a network-wide role system.

Props milindmore22.
Fixes #39676. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@40295 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 14:35:08 +00:00
Felix Arntz 169c32723f Multisite: Provide unit tests for `wpmu_validate_blog_signup()`.
See #39676.


git-svn-id: https://develop.svn.wordpress.org/trunk@40294 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-17 14:14:14 +00:00
Boone Gorges 79cfdbd84c Improve querying for terms with falsey names and slugs.
Prior to [38677], `get_term_by()` would always return false if
an empty string were passed as the queried 'name' or 'slug'. The
refactor to use `get_terms()` broke this behavior; inappropriately
imprecise `empty()` checks caused the 'name' or 'slug' clause to be
discarded altogether when fetching terms, resulting in an incorrect
term being returned from the function.

We fix the regression by special-casing truly empty values passed
to `get_term_by()`, and ensuring that `WP_Term_Query` is properly
able to handle `0` and `'0'` term queries.

Props sstoqnov.
Fixes #21760.

git-svn-id: https://develop.svn.wordpress.org/trunk@40293 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-16 02:03:53 +00:00
Boone Gorges 3025ba4c8f Fix the formatting of `$taxonomies` parameter of `'wp_get_object_terms'` filter.
[38667] changed the way that the filter parameters are built. That
changeset didn't fully account for the pre-4.7 format of `$taxonomies`.

Props ig_communitysites.
Fixes #40154.

git-svn-id: https://develop.svn.wordpress.org/trunk@40290 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-14 18:41:26 +00:00
James Nylen b9dd2c01f3 REST API: Fix DST handling in a test.
The time chosen for `test_empty_post_date_gmt_shimmed_using_post_date` falls within US daylight savings time.  This may cause the test to fail depending on whether the current locale has DST.

The fix is to specify a numeric `gmt_offset` rather than a `timezone_string`.

Unprops jnylen0.
Fixes #40136.


git-svn-id: https://develop.svn.wordpress.org/trunk@40284 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-13 15:06:10 +00:00
Boone Gorges 5e74056898 Tests: Use `assertSame()` for `WP_Query` 'orderby' tests.
`assertEqualSets()` ignores order, so isn't much good for testing 'orderby'.

See #38034.

git-svn-id: https://develop.svn.wordpress.org/trunk@40278 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-11 03:07:27 +00:00
Boone Gorges 824c50f8ae Don't run 'get_terms' filter when querying for terms within `get_term_by()`.
Historically, it has been possible to call `get_term_by()` within
a 'get_terms' filter callback. Since `get_term_by()` was refactored
to use `get_terms()` internally [38677], callbacks of this nature
have resulted in infinite loops.

As a workaround, we introduce a 'suppress_filter' option to `get_terms()`,
and use it when calling the function from within `get_term_by()`.

Props ocean90.
See #21760.

git-svn-id: https://develop.svn.wordpress.org/trunk@40275 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-11 02:26:11 +00:00
John Blackbourn f5f7736177 Build/Test tools: Don't override the `wp_set_auth_cookie()` and `wp_clear_auth_cookie()` functions.
Overriding pluggable functions in the test suite is asking for trouble in the future. In addition, it means the test suite can't be guaranteed to behave the same as core.

This instead introduces a `send_auth_cookies` filter which can be hooked in during the test suite to prevent these functions from attempting to send cookie headers to the client.

Fixes #39367


git-svn-id: https://develop.svn.wordpress.org/trunk@40263 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-10 14:32:31 +00:00
Sergey Biryukov 8060823ff3 Canonical: Strip trailing punctuation from permalinks.
Props joostdevalk, lancewillett, SergeyBiryukov.
Fixes #20383.

git-svn-id: https://develop.svn.wordpress.org/trunk@40256 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-09 20:04:17 +00:00
John Blackbourn 74e02a21b8 Build/Test tools: In Travis, skip some tests when not on trunk.
This skips time sensitive tests (copyright year and PHP/MySQL version requirements) when tests are run on branches on Travis.

Props netweb, jorbin

Fixes #39486


git-svn-id: https://develop.svn.wordpress.org/trunk@40241 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-08 00:06:12 +00:00
John Blackbourn 0060ffaa8c Build/Test tools: Revert [40239] due to unrelated changes.
See #39486


git-svn-id: https://develop.svn.wordpress.org/trunk@40240 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-08 00:04:05 +00:00
John Blackbourn 868eba6850 Build/Test tools: In Travis, skip some tests when not on trunk.
This skips time sensitive tests (copyright year and PHP/MySQL version requirements) when tests are run on branches on Travis.

Props netweb, jorbin
Fixes #39486


git-svn-id: https://develop.svn.wordpress.org/trunk@40239 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-08 00:00:47 +00:00
James Nylen 8bbe6a0d50 REST API: Add `gmt_offset` and `timezone_string` to the base `/wp-json` response.
The site's current timezone offset is an important piece of information for any REST API client that needs to manipulate dates.  It has not been previously available.

Expose both the `gmt_offset` (the site's current offset from UTC in hours) and `timezone_string` (which also provides information about daylight savings time) via the "site info" endpoint (the base `/wp-json` response).

Also update the `wp-api-generated.js` fixture file with the changes to the default API responses.

Props sagarkbhatt.
Fixes #39854.


git-svn-id: https://develop.svn.wordpress.org/trunk@40238 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-07 05:47:32 +00:00
James Nylen e79e137c32 WP_Query: Add missing tests for combinations of `orderby` and include parameters.
This commit adds some missing test cases for combinations of `orderby` and other parameters (`post_parent__in` and `post_name__in`).

Followup to [40056] for `orderby` and `post__in`.

The interaction of these parameters is perhaps counterintuitive because `orderby` does not affect the returned results.  This is overall probably the best design, and it's now better tested and documented.

Props fibonaccina.
See #39055.


git-svn-id: https://develop.svn.wordpress.org/trunk@40237 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-07 05:26:51 +00:00
John Blackbourn 154d0d15b7 Build/Test Tools: Call `wp_head()` and `wp_footer()` in the theme used during tests.
See #31550
Fixes #39988


git-svn-id: https://develop.svn.wordpress.org/trunk@40235 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-07 01:33:04 +00:00
Aaron D. Campbell ec30770c50 Strip control characters before validating redirect.
git-svn-id: https://develop.svn.wordpress.org/trunk@40183 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-06 13:37:43 +00:00
Boone Gorges d3e463cb84 Taxonomy: Take 'parent' into account when checking for terms with duplicate names.
Terms with duplicate names are not allowed at the same level of a
taxonomy hierarchy. The name lookup introduced in [34809] did not
properly account for the 'parent' parameter, with the result that
the duplicate-name restriction was tighter than intended (terms
with duplicate names could not be created at different levels of
a single hierarchy).

Props mikejolley.
Fixes #39984.

git-svn-id: https://develop.svn.wordpress.org/trunk@40145 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-03 02:49:13 +00:00
Boone Gorges 8a2341335b Taxonomy: Improve precision of duplicate name checks when inserting terms.
`wp_insert_term()` does not allow for terms with the same name to exist
at the same hierarchy level, unless the second term has a unique slug.
When this logic was refactored in [31792] and [34809], a bug was
introduced whereby it was possible to bypass the no-same-named-sibling
check in cases where the first term had a non-auto-generated slug
(ie, where the name was 'Foo' but the slug something other than 'foo',
such that the second term would get the non-matching slug 'foo').

This changeset fixes this issue by ensuring that the duplicate name
check runs both in cases where there's an actual slug clash *and* in
cases where no explicit `slug` has been provided to `wp_insert_term()`.
The result is a more reliable error condition:
`wp_insert_term( 'Foo' ... )` will always fail if there's a sibling
'Foo', regardless of the sibling's slug.

Props mikejolley.
See #39984.

git-svn-id: https://develop.svn.wordpress.org/trunk@40144 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-03 02:39:09 +00:00
Boone Gorges 735424428c Tests: Starter content tests should use copies of images stored in /tmp.
This ensures that generated thumbnails are kept out of the version-
controlled `DIR_TESTDATA` directory.

Props bor0.
Fixes #40008.

git-svn-id: https://develop.svn.wordpress.org/trunk@40142 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-02 02:25:05 +00:00
Joe McGill 5349b0a08c Media: Skip PDF preview tests when image editor doens't support.
Following [40130] tests fail on environments that don't support PDF
previews because the expected meta data doesn't get written.

See #39875.

git-svn-id: https://develop.svn.wordpress.org/trunk@40131 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 17:50:21 +00:00
Joe McGill 9848a4a466 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, derosj, mikeschroder, joemcgill.
Fixes #39875. See #31050.

git-svn-id: https://develop.svn.wordpress.org/trunk@40130 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 15:38:30 +00:00
John Blackbourn 5ab0154647 Comments: When commenting on a draft post, display a friendly error message if the user can view the post.
This prevents the unhelpful white screen of death when a user who can view the post (eg. preview it) leaves a comment while the post is in draft.

Props sagarprajapati, milindmore22, mayurk, swissspidy
Fixes #39650


git-svn-id: https://develop.svn.wordpress.org/trunk@40128 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-27 00:22:02 +00:00
Joe McGill 5c99d4ae9c Media: Fix unit tests for MIME checks on multisite.
A few of the multisite tests were failing after [40124] because
multisite filters `upload_mimes` with the `check_upload_mimes()`
function to reduce the set of allowed MIME types. This fixes those
errors by skipping the tests for adding additional MIME types and
only tests file types assumed to be allowed.

See #39550.

git-svn-id: https://develop.svn.wordpress.org/trunk@40125 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-26 16:05:25 +00:00
Joe McGill 7684a241b3 Media: Reduce failing uploads following 4.7.1.
[39831] introduced more strict MIME type checking for uploads, which
resulted in unintetionally blocking several filetypes that were
previously valid. This change uses  a more targeted approach to MIME
validation to restore previous behavior for most types.

Props blobfolio, iandunn, ipstenu, markoheijnen, xknown, joemcgill.
Fixes #39550, #39552.

git-svn-id: https://develop.svn.wordpress.org/trunk@40124 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-25 16:07:25 +00:00
Mike Schroder cfe271d254 Media: Reset Exif orientation after rotate in `WP_Image_Editor_Imagick`.
Due to inconsistencies in the way browsers handle Exif orientation data,
if a user manually rotates an image within WordPress, set the Exif orientation to
the default (1) so that the image displays with the same rotation/flip in every browser.

Props sanchothefat, triplejumper12, joemcgill, azaozz, markoheijnen, mikeschroder.
See #14459.
Fixes #37140.

git-svn-id: https://develop.svn.wordpress.org/trunk@40123 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-25 05:25:40 +00:00
James Nylen e5d5f1058e REST API: Fix behavior of `sticky` posts filter when no posts are sticky.
Previously, when getting posts from the API with `sticky=true`, if there were no sticky posts set, the query would return all posts  as if the `sticky` argument was not set.  In this situation, the query should return an empty array instead.

A `sticky=true` query that should return an empty array (in the previous situation, or with `include` and no intersecting post IDs) was also broken in that it would query the post with ID 1.

Finally, this commit significantly improves test coverage for the `sticky` filter argument, including direct testing of the `WHERE` clauses generated by `WP_Query`.

Props ryelle.
Fixes #39947.


git-svn-id: https://develop.svn.wordpress.org/trunk@40122 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-25 05:02:17 +00:00
James Nylen c0ad5e4a50 REST API: Update the client test fixtures after changes to post formats.
This commit updates the `wp-api-generated.js` fixture file after recent changes to the way post formats work in the API.

See #39232.


git-svn-id: https://develop.svn.wordpress.org/trunk@40121 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-25 04:45:52 +00:00
James Nylen 162e1a6f2a REST API: Allow setting post formats even if they are not supported by the theme.
A `post_format` not used by the current theme, but supported by core is not a wrong/broken piece of information.  It's just not used at this point in time.  Therefore we should allow setting and retrieving any of the standard post formats supported in core, even if the current theme doesn't use them.

After this commit, a post's `format` value can survive a round trip through the API, which is a good general design principle for an API.

Props JPry, iseulde, davidakennedy, Drivingralle.
Fixes #39232.


git-svn-id: https://develop.svn.wordpress.org/trunk@40120 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 23:29:04 +00:00
Adam Silverstein ddc4850a04 REST API: JS client - QUnit tests for custom namespace route discovery.
Add QUnit tests for the parsing of custom namespace routes. Add a custom schema fixture based on the `wp-js-widgets` plugin. Test that the client can parse the widget namespace in the schema and correctly construct the expected group of models and collections. Also includes a small unrelated QUnit fix to ensure nav-menu test passes when it is loaded without its tests executing as well as a small jshint fix, adding a missing semicolon since [40107].

Props jnylen0.
Fixes #39561.


git-svn-id: https://develop.svn.wordpress.org/trunk@40109 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-24 18:39:39 +00:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Weston Ruter 7d8b03458c 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.
Amends [35007].
See #32103.
Fixes #36952.


git-svn-id: https://develop.svn.wordpress.org/trunk@40036 602fd350-edb4-49c9-b593-d223f7449a82
2017-02-01 01:39:39 +00:00
Sergey Biryukov 43aed27058 Update/Install: Give context to "Deleted! string to allow for differentiation between theme and plugin translations.
Props swissspidy.
See #39747. See #37290.

git-svn-id: https://develop.svn.wordpress.org/trunk@40035 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-31 09:58:49 +00:00
Sergey Biryukov b732afec11 Update/Install: Give context to some more install/update strings to allow for differentiation between theme and plugin translations.
Fixes #39747. See #37290.

git-svn-id: https://develop.svn.wordpress.org/trunk@40034 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-31 09:26:52 +00:00
Peter Wilson 99a101ff27 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.
See #30210.
Fixes #39157.


git-svn-id: https://develop.svn.wordpress.org/trunk@40030 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-29 23:08:54 +00:00
Boone Gorges 18e09d246e 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.

See #38792, #37738.

git-svn-id: https://develop.svn.wordpress.org/trunk@39992 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 16:52:51 +00:00
Joe Hoyle 0167cea791 REST API: Fix unit tests for posts out of bounds errors
Previously we were assuming pagination headers would be sent when the request for posts is out of bounds. Instead presume it will return an error.

See #39061.

git-svn-id: https://develop.svn.wordpress.org/trunk@39991 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 15:15:07 +00:00
Joe Hoyle 38b400c4d7 REST API: Return an error if the page number is out of bounds.
Return an error from the REST API if a page number larger than the total pages count is requested.

Props morganestes.
Fixes #39061.

git-svn-id: https://develop.svn.wordpress.org/trunk@39967 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 13:52:06 +00:00
Joe Hoyle 0a82ee0a31 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.

See #38792.

git-svn-id: https://develop.svn.wordpress.org/trunk@39954 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-26 13:38:27 +00:00
Felix Arntz cf0ca2645f Multisite: Show menu items in `My Sites > Network Admin` admin bar menu based on more precise capability checks.
Previously the menu items would all be displayed solely based on the `manage_network` capability. This change provides parity with the network admin menu.

Unit tests for the network admin menu functionality of `wp_admin_bar_my_sites_menu()` have been added.

Props chandrapatel.
Fixes #39082.


git-svn-id: https://develop.svn.wordpress.org/trunk@39948 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-24 16:28:30 +00:00
Sergey Biryukov c0926aa662 REST API: Add `group` and description to `WP_Test_REST_Request_Validation`.
Props danielbachhuber.
Fixes #39654.

git-svn-id: https://develop.svn.wordpress.org/trunk@39931 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-20 17:12:59 +00:00
Adam Silverstein 3a449139db Menus: trigger an event when menu items are added or removed.
Fire a `menu-item-added` event after a menu item is added to the DOM. Fire a `menu-removing-item` event before a menu item is removed from the DOM. Enables hooking into and responding to menu changes.

Props welcher, adamsilverstein.
Fixes #31218.


git-svn-id: https://develop.svn.wordpress.org/trunk@39928 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-20 16:14:23 +00:00
Weston Ruter 4e8e97983c 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).

See #38615, #38114.
Fixes #39610.


git-svn-id: https://develop.svn.wordpress.org/trunk@39924 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-19 00:00:24 +00:00
Ryan McCue bbf129c935 REST API: Allow shortcircuiting rest_pre_insert_comment
rest_pre_insert_{post_type} allows returning a WP_Error from the filter to shortcircuit actually creating the object, so it makes sense to do so for comments too.

Props dspilka.
Fixes #39578.


git-svn-id: https://develop.svn.wordpress.org/trunk@39922 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-17 05:17:15 +00:00
Gary Pendergast 16bbc492a5 dbDelta: Ignore index subparts when checking for duplicate indices.
If index lengths change in table definitions, we don't recreate the index - instead, we throw a database error, as `dbDelta()` tries to create a new index with the same name.

It's better to leave the index as is, MySQL doesn't have an efficient process for resizing indices, and dropping/creating is a slow process which we don't want to trigger automatically.

Fixes #34870.



git-svn-id: https://develop.svn.wordpress.org/trunk@39921 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-17 04:00:09 +00:00
Sergey Biryukov 97a4d6c16d Build/Test Tools: Add `assertNotFalse()` method to `WP_UnitTestCase` and use it where appropriate.
Props peterwilsoncc.
Fixes #39219.

git-svn-id: https://develop.svn.wordpress.org/trunk@39919 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-17 03:39:36 +00:00
Sergey Biryukov 550818ac31 Build/Test Tools: Correctly reference function names in `@covers` entries.
Props pbearne.
Fixes #39235.

git-svn-id: https://develop.svn.wordpress.org/trunk@39918 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-17 02:43:25 +00:00
Gary Pendergast 8e3b56fbe3 User Query: Cast `$user_total` as an `int`.
The `$user_total` member of `WP_User_Query`, and corresponding `get_total()` method, have always been documented as returning an `int`. `$user_total`, however, is populated by `$wpdb->get_var()`, which returns 
a string (containing an integer value). Casting the return value from `get_var()` as an `int` rectifies this discrepency.

Props runciters.
Fixes #39297.



git-svn-id: https://develop.svn.wordpress.org/trunk@39915 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-16 23:23:06 +00:00
Andrew Ozz 708c750b2e Tests: `wpautop()` should not add extra `</p>` before `<figcaption>`.
Props pbearne.
See #39307.

git-svn-id: https://develop.svn.wordpress.org/trunk@39914 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-16 17:56:34 +00:00
James Nylen 79589f4195 REST API: Improve test coverage of single user endpoint for public data.
Add test coverage for requests of a single user resource for authors of post types registered as:

- public = true, show_in_rest = true: success without auth.
- public = true, show_in_rest = false: fail without auth.
- public = false, show_in_rest = true: success without auth.
- public = false, show_in_rest = false: fail without auth.

See #38878.
Fixes #39546.


git-svn-id: https://develop.svn.wordpress.org/trunk@39913 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-16 16:21:00 +00:00
Sergey Biryukov 40f076d756 Themes: Add a unit test for `get_theme_feature_list()` to make sure that the list of theme features pulled from the WordPress.org API returns the expected data structure.
Props iandunn.
Fixes #28121.

git-svn-id: https://develop.svn.wordpress.org/trunk@39906 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-15 06:50:00 +00:00
Sergey Biryukov 287e5501ab REST API: Update unit tests to account for the string changes in [39896].
See #39054.

git-svn-id: https://develop.svn.wordpress.org/trunk@39899 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-13 05:14:43 +00:00
Sergey Biryukov 18eab18694 REST API: Improve error messages for number relational validation.
Props jblz.
Fixes #39054.

git-svn-id: https://develop.svn.wordpress.org/trunk@39896 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-13 04:37:03 +00:00
Joe McGill 9b8cc14192 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@39848 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 16:24:30 +00:00
Aaron D. Campbell 35bd561765 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.
See #38878.



git-svn-id: https://develop.svn.wordpress.org/trunk@39843 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-11 14:13:48 +00:00
Weston Ruter de72bafedc Customize: Ensure `theme_mod`-cache of `custom_css` lookup of `-1` short-circuits a `WP_Query` from being made.
Props dlh.
See #35395.
Fixes #39259.


git-svn-id: https://develop.svn.wordpress.org/trunk@39688 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-05 07:12:23 +00:00
boonebgorges 80905ab4b1 Ignore the 'comment_order' setting when determining comment pagination.
[38740] incorrectly introduced logic that changed a comment's page when
'comment_order' was set to 'desc'. This is in violation of the design
of the comment pagination system: a comment's page is designed not to
change when 'comment_order' or 'default_comment_page' are changed.
See #31101.

Props rachelbaker.
Fixes #39280.

git-svn-id: https://develop.svn.wordpress.org/trunk@39663 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-02 19:58:09 +00:00
boonebgorges 3418d831a5 Don't double-escape `terms` payload in `WP_Tax_Query::transform_query()`.
`terms` values are passed through `sanitize_term_field()` with the 'db'
flag, which add slashes. Because `terms` are subsequently run through
`esc_sql()`, these slashes must be removed. See [36348], which added
a similar step to sanitization in `get_terms()`.

Props bcworkz.
Fixes #39315.

git-svn-id: https://develop.svn.wordpress.org/trunk@39662 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-02 19:38:07 +00:00
Rachel Baker 511e4c67dd REST API: Add missing assertions to the view and embed context response data for the Users Controller.
Adds tests for responses where `context != 'edit'` the following properties are not included in the response data:
- `email`
- `locale`
- `registered_date`

Props thepelkus, jnylen0.
Fixes #39399.


git-svn-id: https://develop.svn.wordpress.org/trunk@39660 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-02 18:42:22 +00:00
Rachel Baker fa3f97449e REST API: Add the `supports` property to the Post Type response object.
Includes a new `supports` property in the response object and schema for the `/types` endpoints for users with the `edit_posts` capability for the given post type. The `supports` property returns an object of the features the given post type *supports*.

Props timmydcrawford, tyxla.
Fixes #39033.


git-svn-id: https://develop.svn.wordpress.org/trunk@39647 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-29 17:27:37 +00:00
Rachel Baker 8eda7a0510 REST API: Remove errant annotation from `test_get_items_pagination_headers()` method.
Removes the debugging group notation left in the `WP_Test_REST_Users_Controller` and `WP_Test_REST_Posts_Controller` classes pagination headers method. Introduced in [38832].

Props sanket.parmar.
Fixes #39398.


git-svn-id: https://develop.svn.wordpress.org/trunk@39643 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-27 18:03:52 +00:00
Gary Pendergast f593d8532a Tests: Restore the database connection earlier when switching test groups.
When plugins don't disable the `backupGlobals` PHPUnit option in their own tests, `$wpdb` is backed up and restored between classes of tests. The serialisation process used for this broke the database connection. This previously wasn't a problem, as it was reconnecting before each test.

[38398] introduced some changes that required the connection to be available in `setUpBeforeClass()`, earlier than in was previously reconnecting. This didn't cause warnings in Core, but it did cause warnings for plugins that don't disable the `backupGlobals` option.

The database connection now reconnects in `setUpBeforeClass()`. This change also fixes a few Core tests that weren't calling `parent::setUpBeforeClass()` or `parent::tearDown()` correctly.

Fixes #39327.



git-svn-id: https://develop.svn.wordpress.org/trunk@39626 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-21 04:58:47 +00:00
James Nylen 8bbfc6ef28 REST API: Fix PHP warnings when `get_theme_support( 'post-formats' )` is not an array.
If `add_theme_support( 'post-formats' )` is called with no additional
arguments, then `get_theme_support( 'post-formats' )` returns `true` rather
than an array of supported formats.  Avoid generating PHP warnings in this
situation.

Props dreamon11, ChopinBach.
Fixes #39293.


git-svn-id: https://develop.svn.wordpress.org/trunk@39620 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-20 00:55:04 +00:00
Joe McGill 1f48d453d8 Media: Allow PDF fallbacks filter to process custom sizes.
This fixes an oversight in [39246], which added a hook for filtering
the array of sizes used for PDF thumbnails, but failed to provide a way
for sizes added through `add_image_size()` to be processed.

Props gitlost.
Fixes #39231. See #38594.

git-svn-id: https://develop.svn.wordpress.org/trunk@39617 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 20:29:26 +00:00
Dion Hulse 939e806ef1 Feeds: Do not translate the `lastBuildDate` field in RSS feeds.
Props stevenkword, dd32.
Fixes #39141


git-svn-id: https://develop.svn.wordpress.org/trunk@39613 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 06:38:10 +00:00
John Blackbourn c0bb5e4972 Posts, Post Types: Ensure `is_page_template()` can only return true when viewing a singular post query.
Props natereist, dlh
Fixes #39211


git-svn-id: https://develop.svn.wordpress.org/trunk@39599 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-14 03:42:58 +00:00
James Nylen 2642833293 REST API: Add support for filename search in media endpoint.
In [38625], the functionality to search for attachments by filename was added
via the `posts_clauses` filter and the `_filter_query_attachment_filenames()`
function.  This moves `_filter_query_attachment_filenames()` from
`wp-admin/includes/post.php` to `wp-includes/post.php` so that it can be
applied in the same manner in the REST API media endpoint.

Props jblz, tyxla.
Fixes #39092.


git-svn-id: https://develop.svn.wordpress.org/trunk@39598 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-13 14:08:24 +00:00
James Nylen 03c947c7fd REST API: Allow sending an empty or no-op comment update.
In general, updates that don't actually change anything should succeed.
[39371] added tests for other object types, and this commit fixes empty updates
for comments and adds the missing test.

Fixes #38700.


git-svn-id: https://develop.svn.wordpress.org/trunk@39597 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-13 13:52:49 +00:00
Gary Pendergast 25330a0220 Libraries: Update zxcvbn from version 1.0 to 4.4.1
This includes masses of bug fixes, as well as tweaks to how passwords are scored.

QUnit tests have been updated to reflect tha scoring changes.

Full changelog: https://github.com/dropbox/zxcvbn/compare/v1.0...v4.4.1

Fixes #31647.



git-svn-id: https://develop.svn.wordpress.org/trunk@39596 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-13 11:22:28 +00:00
James Nylen 9bf4440213 REST API: Do not include the `password` argument when getting media items
Currently, `attachment` is the only post type exposed via the REST API that
does not support password protection, but it's possible for other post types to
remove password support.

Fixes #38977.


git-svn-id: https://develop.svn.wordpress.org/trunk@39595 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-13 03:51:01 +00:00
James Nylen 68b6a6197b REST API: Do not error on empty JSON body
It's fairly common for clients to send `Content-Type: application/json` with an
empty body.  While technically not valid JSON, we've historically supported
this behaviour, so it shouldn't cause an error.

Props JPry.
Fixes #39150.


git-svn-id: https://develop.svn.wordpress.org/trunk@39594 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-13 03:33:14 +00:00
Felix Arntz b171b64d3c Tests: Use `wp_delete_user()` during teardown to delete a single site's user.
Fixes failing tests for `get_dashboard_url()`.

Fixes #39065.


git-svn-id: https://develop.svn.wordpress.org/trunk@39590 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 23:17:35 +00:00
Felix Arntz b4317ea053 Multisite: Replace `is_super_admin()` with `manage_network` in `get_dashboard_url()`.
Unit tests for `get_dashboard_url()` have been added.

Props iaaxpage.
Fixes #39065. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@39589 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 22:40:03 +00:00
Felix Arntz 539b85406d Multisite: Handle capability check for removing oneself via `map_meta_cap()`.
Site administrators should not be able to remove themselves from a site. This moves the enforcement of this rule from `wp-admin/users.php` to `remove_user_from_blog()` via the `remove_user` capability, which furthermore allows us to get rid of two additional clauses and their `is_super_admin()` checks in `wp-admin/users.php`. A unit test for the new behavior has been added.

Fixes #39063. See #37616.


git-svn-id: https://develop.svn.wordpress.org/trunk@39588 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 21:41:44 +00:00
Dion Hulse 9e70bab188 Remove the WordPress version number from `readme.html`.
See #35554 


git-svn-id: https://develop.svn.wordpress.org/trunk@39583 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 08:00:24 +00:00
Dion Hulse 24228daabf PDF Images: Avoid a PHP Warning when attempting to process a file without an extension.
Props chandrapatel for initial patch.
Fixes #39195.


git-svn-id: https://develop.svn.wordpress.org/trunk@39580 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 06:18:30 +00:00
Dion Hulse caa1f1f88d Taxonomy: Restore the ability to use string-based `$args` in `wp_get_object_terms()`.
Props tyxla.
Fixes #39215


git-svn-id: https://develop.svn.wordpress.org/trunk@39578 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 05:46:37 +00:00
Peter Wilson 7950b0e306 Options: Prevent unnecessary SQL updates by `update_option`.
Previously an option containing an object would trigger an SQL `UPDATE` on all calls to `update_option`, even if the old and new values were identical. This was due to the old and new values having differing resource IDs.

This change compares the old and new values as serialized data to remove the resource ID from the comparison.

Props salcode, bradyvercher, peterwilsoncc.
Fixes #38903.


git-svn-id: https://develop.svn.wordpress.org/trunk@39564 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-11 21:42:12 +00:00
Rachel Baker 260a88d009 REST API: Allow schema sanitization_callback to be set to null to bypass fallback sanitization functions.
The logic in WP_REST_Request->sanitize_params() added in [39091] did not account for `null` or `false` being the sanitization_callback preventing overriding `rest_parse_request_arg()`. This fixes that oversight, allowing the built in sanitization function to be bypassed. See #38593.

Props kkoppenhaver, rachelbaker, jnylen0.
Fixes #39042.


git-svn-id: https://develop.svn.wordpress.org/trunk@39563 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-11 21:25:40 +00:00
Weston Ruter 1681d96a6d Customize: Deprecate `page_home` nav menu item starter content in favor of `home_link`; replace usage in Twenty Seventeen.
Props celloexpressions, westonruter.
Amends [38991].
See #38615, #38114.
Fixes #39104.


git-svn-id: https://develop.svn.wordpress.org/trunk@39561 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-10 23:38:04 +00:00
Weston Ruter e27098f5bd Customize: Trim whitespace for URLs supplied for `external_header_video` to prevent `esc_url_raw()` from making them invalid.
Props tyxla.
See #38172.
Fixes #39125.


git-svn-id: https://develop.svn.wordpress.org/trunk@39560 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-10 06:59:24 +00:00
Weston Ruter 0369dea1e4 Customize: Prevent single quotes (apostrophes) in `custom_css` values from unexpectedly causing false positives for unbalanced character validation errors.
See #39218, #35395.
Fixes #39198.


git-svn-id: https://develop.svn.wordpress.org/trunk@39559 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-10 06:45:00 +00:00
John Blackbourn d9ac66c910 Build/Test Tools: Remove some more randomness.
See #37371


git-svn-id: https://develop.svn.wordpress.org/trunk@39556 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-10 00:01:30 +00:00
John Blackbourn 6db50cd8b2 Build/Test Tools: Reuse another fixture in the user capability tests.
See #38716


git-svn-id: https://develop.svn.wordpress.org/trunk@39555 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-09 23:35:55 +00:00
John Blackbourn d06bd0172e Build/Test Tools: Remove commented out tests that have existed in an unimplemented state since the dawn of the test infrastructure.
See #38716


git-svn-id: https://develop.svn.wordpress.org/trunk@39554 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-09 23:11:28 +00:00
Boone Gorges 77484a0f4a Taxonomy: Introduce `get_term_parents_list()`.
This new function is a taxonomy-agnostic version of `get_category_parents()`.

Props keesiemeijer, SergeyBiryukov, rafaehlers.
Fixes #17069.

git-svn-id: https://develop.svn.wordpress.org/trunk@39549 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-09 16:09:31 +00:00
Weston Ruter c4bffeb619 Customize: Defer populating `post_name` for `auto-draft` posts in customized state until posts are published.
The ultimate `post_name` is stored in postmeta until the post is published. The `get_page_by_path()` function does not exclude `auto-draft` posts. Revert changes to `wp_unique_post_slug()` from [39411] which excluded `auto-draft` posts.

Props westonruter, dlh for testing, helen for testing.
See #38114, #38928.
Fixes #39078.


git-svn-id: https://develop.svn.wordpress.org/trunk@39506 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-05 19:32:09 +00:00
John Blackbourn 7c02c24e5f Role/Capability: Don't assign the `delete_site` capability to anyone on single site installs.
This capability is not relevant on single site installs; it only applies to deleting a site on a multisite installation.

Fixes #38326


git-svn-id: https://develop.svn.wordpress.org/trunk@39494 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-04 22:06:36 +00:00
James Nylen d2a5f48449 REST API: Treat any falsy value as `false` in 'rest_allow_anonymous_comments'.
Extend the check in 'rest_allow_anonymous_comments' to accept any falsy value
(previously this was an explicit check for `false`).

One possible failure case is that a plugin developer forgets to include a
return value for some code path in their callback for this filter, leading to a
value of `null` which is currently treated like `true`.

Props joehoyle, jnylen0.

Fixes #39010.


git-svn-id: https://develop.svn.wordpress.org/trunk@39487 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-04 19:29:18 +00:00
John Blackbourn 6861a9aac0 Build/Test Tools: Correctly set up the current screen during list table tests so that they don't fail when run individually.
Props desrosj
Fixes #38761


git-svn-id: https://develop.svn.wordpress.org/trunk@39481 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-04 19:03:40 +00:00
Andrew Nacin b16f57240e Build/Test Tools: Specify exact node version in package.json.
Enforce it in the tests.

see #35105.


git-svn-id: https://develop.svn.wordpress.org/trunk@39478 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-04 17:29:26 +00:00
Weston Ruter 06ee519376 Customize: Ensure a `custom_css` post insertion gets an initial post revision.
Props georgestephanis, westonruter.
See #30854, #38672, #35395.
Fixes #39032.


git-svn-id: https://develop.svn.wordpress.org/trunk@39477 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-04 17:28:27 +00:00
Andrew Nacin 4b2cbf6ac3 REST API: Register the admin_email setting in single site only.
See [39470]. This time including unit test changes.

fixes #38990.


git-svn-id: https://develop.svn.wordpress.org/trunk@39471 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-03 05:40:04 +00:00
Gary Pendergast 55e972cab3 REST API: Site URL setting should not be present on multisite installations.
The `siteurl` setting is registered and made available to the REST API. On a multisite installation, this setting is not configurable from the General Settings screen, but due to the above it is configurable from the REST API.

Props peterwilsoncc.
Fixes #39005.



git-svn-id: https://develop.svn.wordpress.org/trunk@39468 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-03 05:15:42 +00:00
Rachel Baker 8c26572c8a REST API: Fix bug where comment author and author email could be an empty string when creating a comment.
If the `require_name_email` option is true, creating a comment with an empty string for the author name or email should not be accepted.  Both values can be an empty string on update.

Props flixos90, hnle, dd32, rachelbaker, jnylen0, ChopinBach, joehoyle, pento.

Fixes #38971.


git-svn-id: https://develop.svn.wordpress.org/trunk@39444 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 22:43:03 +00:00
Rachel Baker 0de150991c REST API: Fix handling of some orderby parameters for the Posts controller.
- `'orderby' => 'include'` requires an array of post_ids via the `include` collection param.
`'orderby' => 'id'` and `'orderby' => 'slug'` need map the correct WP_Query equivalents. 

Props flixos90, hnle, dd32, rachelbaker, joehoyle, pento.

Fixes #38971.


git-svn-id: https://develop.svn.wordpress.org/trunk@39440 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 22:17:36 +00:00
Jeremy Felt 9232ecc9fc REST API: Disable `DELETE` requests for users in multisite.
In wp-admin, users are removed from individual sites rather than deleted. A user can only be deleted from the network admin.

Until support for a `PUT` request that removes a user's site and content associations is available, `DELETE` requests are disabled to avoid possible issues with lost content.

Props jnylen0, rachelbaker.
Fixes #38962.


git-svn-id: https://develop.svn.wordpress.org/trunk@39438 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 22:10:01 +00:00
Rachel Baker a55506974e REST API: Return a `WP_Error` if `meta` property is not an array.
Fixes bug where a PHP Warning is currently thrown if a client sends a request where `meta` is not an array value.

Props timmydcrawford, jnylen0, rachelbaker, pento.
Fixes #38989.

git-svn-id: https://develop.svn.wordpress.org/trunk@39436 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 21:55:09 +00:00
Weston Ruter 511ba69e52 Customize: Fix posts limit query arg for `WP_Query` from incorrect `number` to `posts_per_page`.
Props dlh.
Fixes #39022.


git-svn-id: https://develop.svn.wordpress.org/trunk@39434 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 16:17:03 +00:00
Gary Pendergast 5ff3f14d78 Plugins: Add a `current_priority()` method to `WP_Hook`.
This allows plugins to determine the currently running priority of a filter.

Fixes #39007.



git-svn-id: https://develop.svn.wordpress.org/trunk@39430 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 07:09:33 +00:00