Commit Graph

2279 Commits

Author SHA1 Message Date
Weston Ruter bf07e57e4b Customize: Ensure that `WP_Customize_Manager::save_changeset_post()` returns `setting_validities` even for supplied values that are unchanged from values in changeset.
Check setting existence and authorization via `WP_Customize_Manager::validate_setting_values()` even for `null` values to account for custom params being added to settings, preventing failures from being silently ignored.

See #38705, #30937.
Fixes #38865.


git-svn-id: https://develop.svn.wordpress.org/trunk@39320 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-19 22:38:40 +00:00
Weston Ruter 68b9b45548 Customize: Ensure `WP_Customize_Setting::value()` returns previewed value for custom types utilizing the `customize_value_{$id_base}` filter.
Fixes #38864.


git-svn-id: https://develop.svn.wordpress.org/trunk@39318 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-19 05:59:12 +00:00
Rachel Baker aa4af7839e REST API: On Comment create, limit the ability to set the `author_ip` value directly.
Users without the moderate_comments capability can no longer set the `author_ip` property directly, and instead receive a `WP_Error` if they attempt to do so. Otherwise, the `author_ip property` is populated from `$_SERVER['REMOTE_ADDR']` if present and a valid IP value. Finally, fallback to 127.0.0.1 as a last resort.

Props dd32, rachelbaker, joehoyle.
Fixes #38819.

git-svn-id: https://develop.svn.wordpress.org/trunk@39302 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 21:12:03 +00:00
Joe Hoyle ba5a196d9e REST API: Change “ipv4” types to “ip” to support ipv6.
Stop presuming IP address are IPv4, instead make the type “ip” to be agnostic of IP version. This fixes requests with ipv6 addresses for comments in core.

Props dd32, schlessera, danielbachhuber.
Fixes #38818.

git-svn-id: https://develop.svn.wordpress.org/trunk@39296 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 19:32:03 +00:00
Joe Hoyle db07183b6f REST API: Check read permissions on posts when viewing comments.
With a few tests for getting / creating comments to reflect core behaviour.

Props timmyc.

git-svn-id: https://develop.svn.wordpress.org/trunk@39295 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 19:06:26 +00:00
Rachel Baker 2916ca534c REST API: Add test case for `users/me` endpoint that the `context` param defaults to `view`.
Props danielbachhuber.
See #38842.

git-svn-id: https://develop.svn.wordpress.org/trunk@39293 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 18:58:25 +00:00
Rachel Baker 7552367e7a REST API: Remove the `karma` property and query parameter from the Comments endpoints.
WordPress has not used the `karma` property internally for the past 8 years. There is no need to expose it in the REST API endpoints. Sites that use `karma` can include it using the `register_rest_field()` function.

Props dd32, danielbachhuber.
Fixes #38821.

git-svn-id: https://develop.svn.wordpress.org/trunk@39292 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 18:52:19 +00:00
Rachel Baker f553ad6277 REST API: On comment create, return an error if the `type` property is set to anything other than `comment`.
Of the default comment_types, only comments are expected to be created via the REST API endpoint. Comments do not have registered types the way that Posts do, so we do not have a method to accurately check permissions for arbitrary comment types.

Props dd32, boonebgorges, rachelbaker.
Fixes #38820.

git-svn-id: https://develop.svn.wordpress.org/trunk@39290 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 18:36:10 +00:00
Rachel Baker 659822098a REST API: Allow `parent` property to be explicitly set to `0` when creating or updating a Post.
Props lucasstark, danielbachhuber.
Fixes #38852.

git-svn-id: https://develop.svn.wordpress.org/trunk@39289 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 18:11:49 +00:00
Rachel Baker ff38fc46e4 REST API: On comment create, return an error if the `post` parameter does not relate to a valid WP_Post object.
Return a `WP_Error` object for attempts to create a comment without an empty or invalid `post` ID.

Props dd32, jnylen0, rachelbaker.
Fixes #38816.

git-svn-id: https://develop.svn.wordpress.org/trunk@39288 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 16:55:03 +00:00
Rachel Baker cceb9a6053 REST API: On comment create, fallback to the `user_agent` header value.
If a user-agent is not explicitly provided in the `author_user_agent` parameter, fallback to the `user_agent` value in the request header.

Props dd32, jnylen0, rachelbaker.
Fixes #38817.

git-svn-id: https://develop.svn.wordpress.org/trunk@39287 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-18 16:21:27 +00:00
Sergey Biryukov f493ebb369 Taxonomy: Prevent `wp_list_categories()` from producing not well-nested output if `hide_title_if_empty` is true.
Props chesio.
Fixes #38839. See #33460.

git-svn-id: https://develop.svn.wordpress.org/trunk@39280 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-17 18:01:13 +00:00
Weston Ruter a3b66814a7 Customize: Add unit tests for importing theme starter content.
Props welcher, westonruter.
See #38114, #38533, #38615.
Fixes #38540.


git-svn-id: https://develop.svn.wordpress.org/trunk@39276 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-17 08:17:57 +00:00
Gary Pendergast 365241878f Database: Add support for `LIKE`-escaped tables in `::get_table_from_query()`.
The `SHOW TABLES LIKE` query can be used to search for tables that match a pattern, `wp\_123\_%`, for example. While this isn't the name of an actual table, the `wp_123_` prefix can be used by database drop-ins to direct the query correctly. This change removes the escaping and `%` modifier, to provide this usable prefix.

Props andy, pento.
Fixes #38751.



git-svn-id: https://develop.svn.wordpress.org/trunk@39275 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-17 04:20:22 +00:00
Boone Gorges 206a330d72 Comments: Query used to fill comment descendants should reset 'offset' and 'number' params.
Descendant queries should not inherit the 'offset' and 'number'
parameters of the parent query, or descendants will be missed.

Previously: [38497].

See #37696.

git-svn-id: https://develop.svn.wordpress.org/trunk@39274 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-17 03:02:40 +00:00
Sergey Biryukov a9b4305084 Tests: Add a missing `$message` argument for `assertEquals()` in [39265].
See #23626.

git-svn-id: https://develop.svn.wordpress.org/trunk@39267 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-16 13:42:03 +00:00
Sergey Biryukov 701b2d23f2 Tests: Use `assertEquals()`' native functionality for delta comparison in `test_wp_convert_bytes_to_hr()`.
See #23626.

git-svn-id: https://develop.svn.wordpress.org/trunk@39265 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-16 13:14:44 +00:00
Peter Wilson 55fd899391 Themes: Remove front page restriction from video header functions.
Adds a callback for determining when video headers should be displayed in themes supporting custom headers. By default, video headers are only displayed on the front page of a site.

Theme authors may set a custom callback by passing `'video-active-callback' => 'mytheme_video_active_callback'` as an argument. The default callback is `is_front_page()`.

This introduces the new function `is_header_video_active()` - returns `true` on pages that should display video headers. The return value can be filtered using the new filter of the same name.

Props flixos90, bradyvercher, peterwilsoncc, joemcgill.
Fixes #38738.


git-svn-id: https://develop.svn.wordpress.org/trunk@39240 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-15 07:15:20 +00:00
Peter Wilson f62112fa16 Posts, Post Types: Improve sanitisation of templates' post types.
Prevents post type templates ignoring post types due to invalid characters. Each entry in the `Template Post Type` comment is run through `sanitize_key()` to match the sanitisation used by `register_post_type()`.

Fixes #38766.


git-svn-id: https://develop.svn.wordpress.org/trunk@39236 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-15 03:36:13 +00:00
Joe Hoyle 58169b04fa REST API: Validate and Sanitize registered meta based off the schema.
With the addition of Array support in our schema validation functions, it's now possible to use these in the meta validation and sanitization steps. Also, this increases the test coverage of using registered via meta the API significantly.

Fixes #38531.
Props rachelbaker, tharsheblows.


git-svn-id: https://develop.svn.wordpress.org/trunk@39222 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-14 16:35:35 +00:00
Ryan McCue ecb1e33d0d REST API: Improve validation for usernames and passwords.
Also improves the slashing of user data in the REST API to avoid data loss.

Props jnylen0.
Fixes #38739.


git-svn-id: https://develop.svn.wordpress.org/trunk@39219 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-14 07:12:31 +00:00
Weston Ruter c68c1c8ec7 Customize: Improve extensibility of Custom CSS.
* Add `customize_value_custom_css` filter to `WP_Customize_Custom_CSS::value()` method.
* Introduce `customize_update_custom_css_post_content_args` filter in `WP_Customize_Custom_CSS::update()` method.
* Make clear that `wp_get_custom_css()` and `wp_get_custom_css` filter are specifically for obtaining the value to render/display. Eliminate use of `wp_get_custom_css()` when getting the setting value. Use the underlying `post_value` directly when `is_previewed`.
* Move anonymous functions handing JS previewing for `custom_logo`, `custom_css`, and `background` into named functions on the `wp.customize.settingPreviewHandlers` to allow plugins to override/extend preview logic.
* Update `_custom_background_cb` to always print a `style` tag wen in the customizer preview, and update background preview logic to replace existing style element instead of appending a new style to the head so that background changes don't unexpectedly override any Custom CSS in the preview's stylesheet cascade.

Props westonruter, georgestephanis.
See #22058.
Fixes #38672.


git-svn-id: https://develop.svn.wordpress.org/trunk@39209 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-13 02:42:04 +00:00
Joe Hoyle 08c7dddc41 REST API: Allow updating a comment without the content present.
For all resources in the REST API, sending partial updates is supported. This fixes needing to _always_ specify comment content.

Props jnylen.
Fixes #38720.


git-svn-id: https://develop.svn.wordpress.org/trunk@39196 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-10 03:34:30 +00:00
Joe Hoyle 5309ebbbaa REST API: Fix test for unfiltered_html under multisite.
See #38726.


git-svn-id: https://develop.svn.wordpress.org/trunk@39193 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-10 02:47:48 +00:00
Joe Hoyle c67401baf1 REST API: Add `rest_base` to response objects of `wp/v2/taxonomies` and `wp/v2/types`
Though we have the `_links.collection` available, having this value can be useful to know post type / taxonomy urls if you need to build them another way.

Props youknowriad, jnylen0.
Fixes #38607.


git-svn-id: https://develop.svn.wordpress.org/trunk@39191 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-10 02:20:09 +00:00
Joe Hoyle ec2ffb45c1 REST API: `unfiltered_html` and slashing: terms.
Follow-up to #38609 and #38704; handle slashes correctly for taxonomy terms.

Props westonruter, jnylen0.
Fixes #38726, see #38609.


git-svn-id: https://develop.svn.wordpress.org/trunk@39190 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-10 02:09:40 +00:00
John Blackbourn 09e332c301 Build/Test Tools: Re-use a bunch of fixtures in test classes for user and XMLRPC tests.
Shaves a couple of seconds off of the tests.

See #30017, #38716


git-svn-id: https://develop.svn.wordpress.org/trunk@39189 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-10 01:53:08 +00:00
Weston Ruter 5fb093bfe6 Customize: Split out `custom_css` query logic from `wp_get_custom_css()` into a re-usable `wp_get_custom_css_post()` function to also be used when updating.
Props georgestephanis, westonruter.
See #38672, #35395.


git-svn-id: https://develop.svn.wordpress.org/trunk@39185 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 20:42:22 +00:00
Ryan McCue 446dc73042 REST API: Include template in all post type schemas.
[38951] added templates to all post types, but didn't add them to the schema.

Props swissspidy.
Fixes #38698.


git-svn-id: https://develop.svn.wordpress.org/trunk@39182 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 07:12:01 +00:00
Weston Ruter 8a0c502703 Customize: Store modifying user ID with setting change written into changeset and restore current user when setting is being saved.
Restoring the current user context when saving a setting ensures filters apply as expected, such as Kses. When a user is not associated with a given setting change, continue to override `capability` to be `exist` when saving. Skip overwriting setting values in a changeset that have not changed, facilitating concurrent editing and amending a changeset by a user with fewer privileges.

See #30937.
Fixes #38705.


git-svn-id: https://develop.svn.wordpress.org/trunk@39181 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 07:02:53 +00:00
Weston Ruter 865f3633f4 Customize: Prevent `post_content` and `post_name` from being modified when trashing `customize_changeset` posts.
See #30937.
Fixes #38719.


git-svn-id: https://develop.svn.wordpress.org/trunk@39180 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 05:44:14 +00:00
Ryan McCue c20af6e31f Roles/Capabilities: Add meta-caps for comment, term, and user meta.
Additionally, use these meta-caps in the REST API endpoints.

Previously, register_meta()'s auth_callback had no effect for non-post meta. This introduces `{add,edit,delete}_{comment,term,user}_meta` meta-caps to match the existing post meta capabilities. These are currently only used in the REST API.

Props tharsheblows, boonebgorges.
Fixes #38303, fixes #38412.


git-svn-id: https://develop.svn.wordpress.org/trunk@39179 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 03:41:07 +00:00
Weston Ruter cebc30dd67 Customize: Rename remaining instances `unfiltered_css` meta capability to `edit_css` in unit tests.
Amends [39175].
See #38672, #35395.


git-svn-id: https://develop.svn.wordpress.org/trunk@39178 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 01:47:50 +00:00
Ryan McCue cd5572b67a REST API: Fire correct hooks when creating users on multiste.
`add_user_to_blog()` is now called, ensuring the correct hooks are called, along with setting the primary blog and clearing relevant caches.

Props jeremyfelt.
Fixes #38526.


git-svn-id: https://develop.svn.wordpress.org/trunk@39177 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 01:34:56 +00:00
Weston Ruter b20cda2d4b Customize: Rename `unfiltered_css` meta capability to `edit_css`; add `revisions` support to `custom_css` post type.
Props lukecavanagh, georgestephanis, westonruter.
See #38672, #35395.


git-svn-id: https://develop.svn.wordpress.org/trunk@39175 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 01:11:49 +00:00
John Blackbourn 61fa0a69d6 Build/Test Tools: Utilise `assertWPError()` and `assertNotWPError()` in more places.
See #38716


git-svn-id: https://develop.svn.wordpress.org/trunk@39174 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-09 00:01:42 +00:00
John Blackbourn 5ab2a22a38 Build/Test Tools: Utilise `assertFileExists()` and `assertFileNotExists()` in more places.
See #38716


git-svn-id: https://develop.svn.wordpress.org/trunk@39173 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 23:49:11 +00:00
John Blackbourn 52a834a6d8 Themes: Re-use fixtures in the `wp_get_document_title()` tests.
See #38716


git-svn-id: https://develop.svn.wordpress.org/trunk@39172 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 23:31:45 +00:00
Aaron Jorbin 5cb18b6c38 Posts, Post Types: Fix themes tests broken in [39168]
[39168] introduced a new theme to the tests, but it wasn't taken into account in Tests_Theme_ThemeDir::test_theme_list.

See #38696.



git-svn-id: https://develop.svn.wordpress.org/trunk@39170 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 23:22:23 +00:00
Pascal Birchler 21e874e00a I18N: Add ability to change user's locale back to site's locale.
Previously there was no way to remove the user locale setting again, even though that might be desirable.

This adds a new 'Site Default' option to the user-specific language setting by introducing a new `show_site_locale_default` argument to `wp_dropdown_languages()`.

Props ocean90.
See #29783.
Fixes #38632.

git-svn-id: https://develop.svn.wordpress.org/trunk@39169 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 23:00:38 +00:00
Pascal Birchler 5f610350e1 Posts, Post Types: Fix post type templates with child themes.
After [38951] added support for post type templates beyond pages, this fixes an issue where an empty meta box would be shown when using child themes.

Fixes #38696.

git-svn-id: https://develop.svn.wordpress.org/trunk@39168 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 22:40:28 +00:00
Pascal Birchler 4b3e128140 Date/Time: Improve `date_i18n()` timezone tests.
This uses a timezone without DST for the tests covering `date_i18n()`.

Fixes #37910.

git-svn-id: https://develop.svn.wordpress.org/trunk@39167 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 22:31:51 +00:00
Joe Hoyle 6fd4d6e0ea REST API: Remove rest_get_post filter and `get_post` abstraction.
This filter was originally introduced in https://github.com/WP-API/WP-API/pull/2535 to support Customizer Changesets (née Transactions). This is a super broad filter and doesn't really fit with the design of the API, nor is it (arguably) the right level to do this.

Props rmccue.
Fixes #38701.


git-svn-id: https://develop.svn.wordpress.org/trunk@39161 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 13:08:49 +00:00
Ryan McCue 2eca6870b9 REST API: Remove more emoji from tests.
More from [39156].

See #38609.


git-svn-id: https://develop.svn.wordpress.org/trunk@39160 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 07:38:40 +00:00
Ryan McCue 0bbeaf7b15 REST API: Embiggen the test email address.
We no longer want a@b.c to be valid, so let's make it a@b.co instead.

Props dd32.
See #38506.


git-svn-id: https://develop.svn.wordpress.org/trunk@39159 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 06:45:26 +00:00
Ryan McCue 08efd7b636 REST API: Require 6 characters for comment email addresses.
The regular comments API requires 6 characters rather than 3, so we need to match this.

Props mangeshp, dd32.
Fixes #38506.


git-svn-id: https://develop.svn.wordpress.org/trunk@39158 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 06:41:57 +00:00
Ryan McCue e74994b2f4 REST API: Respect unfiltered_html for HTML comment fields.
Same as [39155], but for comments, natch.

Props jnylen0.
Fixes #38704, see #38609.


git-svn-id: https://develop.svn.wordpress.org/trunk@39157 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 06:35:51 +00:00
Ryan McCue 2212d62d83 REST API: Remove ship emoji from slashing tests.
Introduced in [39155], but not necessary for the slashing tests. These fail on 5.3, which encodes the emoji as HTML entities.

Props dd32.
See #38609.


git-svn-id: https://develop.svn.wordpress.org/trunk@39156 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 06:25:36 +00:00
Ryan McCue 074d204c12 REST API: Respect unfiltered_html for HTML post fields.
This necessitates a change to our slashing code as well. Ah slashing, the cause of, and solution to, all of life's problems.

Props jnylen0.
Fixes #38609.


git-svn-id: https://develop.svn.wordpress.org/trunk@39155 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 05:54:22 +00:00
Ryan McCue f6e433b250 REST API: Change attachment caption & description to objects.
Just like excerpt and content for regular posts, these have transformations applied that can make the content significantly different from the raw value.

Props jnylen0.
Fixes #38679.


git-svn-id: https://develop.svn.wordpress.org/trunk@39154 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 04:28:47 +00:00