Commit Graph

2329 Commits

Author SHA1 Message Date
Rachel Baker 7b4f4be327 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.

Merges [39563] to the 4.7  branch.

Props kkoppenhaver, rachelbaker, jnylen0.
Fixes #39042.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39642 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-27 17:48:10 +00:00
Gary Pendergast 82af7aba8d 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.

Merge of [39617] to the 4.7 branch.

Props gitlost.
Fixes #39231. See #38594.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39633 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-21 05:52:54 +00:00
Gary Pendergast 81cc13dd49 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.

Merge of [39620] to the 4.7 branch.

Props dreamon11, ChopinBach.
Fixes #39293.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39630 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-21 05:29:24 +00:00
Gary Pendergast fab33a89e5 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.

Merge of [39598] to the 4.7 branch.

Props jblz, tyxla.
Fixes #39092.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39629 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-21 05:18:24 +00:00
Gary Pendergast 092fa83f60 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.

Merges [39597] to the 4.7 branch.

Props jnylen0.
Fixes #38700.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39628 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-21 05:12:06 +00:00
Gary Pendergast ef084ac427 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.

Merges [39626] to the 4.7 branch.

Fixes #39327.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39627 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-21 05:07:05 +00:00
Dion Hulse 7e49d80783 Feeds: Do not translate the `lastBuildDate` field in RSS feeds.
Props stevenkword.
Partial Merge of [39613] to the 4.7 branch.
Fixes #39141.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39615 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 06:43:48 +00:00
Dion Hulse 2e6ae93cf2 Taxonomy: Restore the ability to use string-based `$args` in `wp_get_object_terms()`.
Props tyxla.
Merges [39578] to the 4.7 branch.
Fixes #39215.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39611 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 05:49:02 +00:00
Dion Hulse 8cbd30e3ce 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.

Props jnylen0.
Merges [39595] to the 4.7 branch.
Fixes #38977.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39610 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 05:45:50 +00:00
Dion Hulse 321599cc46 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, jnylen0.
Merges [39594] to the 4.7 branch.
Fixes #39150.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39609 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 05:42:23 +00:00
Dion Hulse 4d3fb455f5 Posts, Post Types: Ensure `is_page_template()` can only return true when viewing a singular post query.
Props natereist, dlh, johnbillion.
Merges [39599] to the 4.7 branch.
Fixes #39211.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39608 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 05:40:01 +00:00
Dion Hulse c41a10ecb1 PDF Images: Avoid a PHP Warning when attempting to process a file without an extension.
Props chandrapatel for initial patch.
Merges [39580] to the 4.7 branch.
Fixes #39195.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39607 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-16 05:38:41 +00:00
Dion Hulse 46611f6153 De-Emphasise the minor (x.y.Z) version in `readme.html` by including only the major version for the 4.7 branch.
See #35554


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39582 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 07:59:10 +00:00
Dion Hulse 26caea9b90 Customize: Deprecate `page_home` nav menu item starter content in favor of `home_link`; replace usage in Twenty Seventeen.
Props celloexpressions, westonruter.
See #38615, #38114, [38991].
Merges [39561] to the 4.7 branch.
Fixes #39104.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39575 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 02:24:19 +00:00
Dion Hulse 5fa5e22427 Customize: Trim whitespace for URLs supplied for `external_header_video` to prevent `esc_url_raw()` from making them invalid.
Props tyxla.
See #38172.
Merges [39560] to the 4.7 branch.
Fixes #39125.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39573 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 02:05:22 +00:00
Dion Hulse 620d169b35 Customize: Prevent single quotes (apostrophes) in `custom_css` values from unexpectedly causing false positives for unbalanced character validation errors.
Props westonruter.
See #39218, #35395.
Merges [39559] to the 4.7 branch.
Fixes #39198.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39567 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 01:44:26 +00:00
Dion Hulse 0087500d9c 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.
Merges [39487] to the 4.7 branch.
Fixes #39010.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39566 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-12 01:39:13 +00:00
Weston Ruter cee7b15ead 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.
Merges [39506] onto 4.7 branch.
Fixes #39078 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39507 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-05 19:38:16 +00:00
Andrew Nacin afca2c6cf0 Build/Test Tools: Specify exact node version in package.json.
Enforce it in the tests.

Merges [39478] to the 4.7 branch.

see #35105, #38657.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39480 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-04 17:37:38 +00:00
Weston Ruter 98b7307e75 Customize: Ensure a `custom_css` post insertion gets an initial post revision.
Merges [39477] onto 4.7 branch.
Props georgestephanis, westonruter.
Fixes #39032 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39479 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-04 17:31:28 +00:00
Andrew Nacin 3bcc86a908 REST API: Register the admin_email setting in single site only.
Merges [39470] and [39471] to the 4.7 branch.

fixes #38990.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39472 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-03 05:41:52 +00:00
Gary Pendergast 3b3a0f0a68 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.

Merge of [39468] to the 4.7 branch.

Props peterwilsoncc.
Fixes #39005.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39469 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-03 05:17:26 +00:00
Dion Hulse ce83066d30 Revert [38677] from the 4.7 branch.
This avoids fatal errors caused with recursive calling of term functions within the `get_terms` filter.

See #21760.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39454 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-03 04:04:05 +00:00
Rachel Baker 75ce33e358 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.

Merges [39444] into the 4.7 branch.
Props flixos90, hnle, dd32, rachelbaker, jnylen0, ChopinBach, joehoyle, pento.

Fixes #38971 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39446 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 22:45:06 +00:00
Rachel Baker 334635ee5e 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. 

Merges [39440] to the 4.7 branch.

Props flixos90, hnle, dd32, rachelbaker, joehoyle, pento.
Fixes #38971 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39441 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 22:20:27 +00:00
Jeremy Felt fde4185ae4 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.

Merges [34938] onto 4.7 branch.

Props jnylen0, rachelbaker.
Fixes #38962 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39439 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 22:15:32 +00:00
Rachel Baker 8fe31dc36a 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.

Merges [39436] onto 4.7 branch.

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


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39437 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 22:04:06 +00:00
Weston Ruter 73a9c335db Customize: Fix posts limit query arg for `WP_Query` from incorrect `number` to `posts_per_page`.
Merges [39434] onto 4.7 branch.
Props dlh.
Fixes #39022 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39435 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 16:18:43 +00:00
Gary Pendergast 2c8812f524 Plugins: Add a `current_priority()` method to `WP_Hook`.
This allows plugins to determine the currently running priority of a filter.

Merges [39430] to the 4.7 branch.

Fixes #39007.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39431 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 07:10:56 +00:00
Gary Pendergast 05b8b42a10 REST API: Require the reassign parameter when deleting users.
When deleting a user through the WordPress admin, a specific decision is presented - whether to assign all of the user's posts to another user, or to delete all of the posts.

This change requires `reassign` as a parameter in the corresponding REST API endpoint, so that content isn't accidentally lost.

Merges [39426] to the 4.7 branch.

Props jeremyfelt.
Fixes #39000.



git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39427 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 06:58:36 +00:00
Weston Ruter b878b509ed Customize: Reuse existing non-auto-draft posts and existing auto-draft posts in the customized state with matching slugs when applying starter content.
* Updates `wp_unique_post_slug()` to ignore `auto-draft` posts. Prevents publishing multiple posts that have the same slugs from starter content.
* Fixes fatal error when attempting to save an header_image setting from a non-admin context.
* Fixes substituting attachment symbols in options and theme mods.
* Fixes applying starter content for header images and background images.

Merges [39411] to 4.7 branch.
See #38114.
Fixes #38928 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39412 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 00:25:47 +00:00
Weston Ruter a3ed458867 Customize: Reject a changeset update when a non-future date is provided and also ensure that a published changeset always gets set to the current date/time.
* Also moves checks from `customize_save` Ajax handler to the underlying `WP_Customize_Manager::save_changeset_post()` call which plugins may invoke directly.
* Ensures that `customize_save_response` filter is always passed an array, with error code available as `code`.

Props utkarshpatel, westonruter, sayedwp.
Merges [39409] into 4.7 branch.
See #30937.
Fixes #38943 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39410 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-02 00:06:59 +00:00
Rachel Baker 5a55a6b747 REST API: Add test for creating a comment with an invalid post ID.
Props @jnylen0.

Merges [39375] to the 4.7 branch.
Fixes #38991 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39408 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-01 03:42:14 +00:00
Mike Schroder fb1b875797 Media: Fix regression with display of small images in media library.
Fixes a regression in the media library after [38949], which caused
small images (< thumbnail size) to not display within the media library.

Accounts for images that have no intermediate sizes
in `wp_prepare_attachment_for_js()`.

Adds test.

Merges [39396] to the 4.7 branch.

Fixes #38965 for 4.7.
Props joemcgill, clorith, mikeschroder.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39399 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-01 00:28:00 +00:00
Weston Ruter ac62809001 Customize: Fix handling of the nav menu item labels (titles) that match defaults (original titles) and fix the display of item type labels.
* Show default labels for nav menu item as placeholders in a control's label field instead of showing blank.
* Store empty string as label instead of copying default labels.
* Prevent labels for post type archive items from being dropped in preview.
* Also ensure that the item type label is displayed on nav menu item controls for settings that are loaded from an existing changeset.

Amends [38618].
See #38015.
Fixes #38955 for 4.7 branch.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39395 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-30 23:41:50 +00:00
Dominik Schilling (ocean90) 60e9d045e7 Options: Pass the `$passed_default` parameter to the `default_option_{$option}` filter in `add_option()`.
This was missed in [38910].

Merge of [39382] to the 4.7 branch.

Props joehoyle, lucasstark.
See #38176, #38930.

git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39383 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-30 21:31:38 +00:00
Gary Pendergast 99e5de9431 REST API: Add tests for empty or "no-op" updates.
The API should allow updates that don't actually change anything.  This allows clients to, for example, accidentally send the same request twice without encountering unexpected errors.  This currently works for posts, terms, and users, so this commit adds test cases accordingly.

See #38700 for issues preventing this from working for comments.

Merge of [39371] to the 4.7 branch.

Props jnylen0.
See #38975.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39372 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-30 03:27:22 +00:00
Weston Ruter e534c73c34 Customize: Fix logic for previewing the URL for `nav_menu_item` settings for terms and post type archives.
Fixes typo in args passed to `get_term_link()` which caused a fatal error due to this call returning a `WP_Error` which was set to `url`. Also fixes never-satisfiable condition for obtaining post type archive URL. Also ensures that `WP_Error` never leaks through as `url` by setting it to an empty string. Adds missing unit tests.

Amends [38991].
See #38114.
Fixes #38945 for 4.7.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39366 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-27 03:19:32 +00:00
Joe Hoyle a1c2caa4e3 REST API: Special case the “standard” post format to always be allowed.
Fixes #38916.

git-svn-id: https://develop.svn.wordpress.org/trunk@39353 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-24 00:07:50 +00:00
joehoyle 7dc75c29f6 REST API: Allow unsetting a post’s password.
Props danielbachhuber, iseulde.
Fixes #38919.

git-svn-id: https://develop.svn.wordpress.org/trunk@39352 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-23 23:12:05 +00:00
Weston Ruter 8bcbe1a35c Customize: Refactor logic for updating `custom_css` posts by introducing `wp_update_custom_css_post()` function and renaming update filter.
* Moves logic from `WP_Customize_Custom_CSS_Setting::update()` into a re-usable `wp_update_custom_css_post()` function, useful for future REST API endpoint, WP-CLI command, or plugin migrations.
* Renames `customize_update_custom_css_post_content_args` filter to `update_custom_css_data` and improves the naming of the parameters. Instead of passing `post_content` and `post_content_filtered` the filtered array now contains `css` and `preprocessed` respectively. 
* The second context param for the `update_custom_css_data` filter is now an array of the original args passed to `wp_update_custom_css_post()` and there is now no more `$setting` arg since it isn't necessarily being called in the customizer context.

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


git-svn-id: https://develop.svn.wordpress.org/trunk@39350 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-23 17:33:21 +00:00
Joe Hoyle 5d7118d63e REST API: Add support for comments of password-protected posts.
Core requires the post password to view and create comments on password protected posts, so we must support a “password” param on the comments endpoint when fetch comments for a specific post and creating a comment on a password protected post.

Props flixos90, jnylen0.
Fixes #38692.

git-svn-id: https://develop.svn.wordpress.org/trunk@39349 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-23 16:14:08 +00:00
Helen Hou-Sandi f3a59f8632 Theme starter content: Add support for featured images and page templates.
Featured image support means that attachments can now be imported. Media can be sideloaded from within theme or plugin directories. Like other posts, attachments are auto-drafts until customizer changes are published, and are not duplicated when they already exist in the customized state. Attachment IDs can be used for any number of purposes, much like post IDs. Twenty Seventeen now includes 3 images used as featured images to best showcase the multi-section homepage setup.

As featured image IDs are stored in post meta, it also made sense to add support for page templates. Twenty Seventeen does not include any such templates, but the functionality can be quite important for displaying themes to their best effect.

props westonruter, helen, flixos90.
fixes #38615.


git-svn-id: https://develop.svn.wordpress.org/trunk@39346 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-23 09:52:27 +00:00
Joe Hoyle e606bc36c1 REST API: Allow unsetting of page templates in update requests.
Sending a request to update a page with the template property set to an empty string resulted in an error because “” was not a valid value in the enum.

Props lucasstark, swissspidy.
Fixes #38877.

git-svn-id: https://develop.svn.wordpress.org/trunk@39343 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-23 02:46:42 +00:00
Rachel Baker 6028062ade REST API: Set the comment `type` to a readonly property in the schema.
Document the type property as `readonly` and remove the default value. After #38820 it is no longer possible to set the type property on a comment to anything a custom type.

Props jnylen0, rachelbaker.
Fixes #38886.

git-svn-id: https://develop.svn.wordpress.org/trunk@39337 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-21 22:55:33 +00:00
Weston Ruter f21e17dbf0 Customize: Remove iframe-specific behaviors from customize preview when previewing on frontend and not contained inside iframe.
* Strip out `customize_messenger_channel` from preview window URL when not contained in iframe.
* Allow interacting with unpreviewable links and forms when previewing customized state on frontend.

See #30937.
Fixes #38867.


git-svn-id: https://develop.svn.wordpress.org/trunk@39332 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-21 16:55:20 +00:00
Dominik Schilling (ocean90) 257026f7a3 I18N: In `wp_dropdown_languages()` rename the new `show_site_locale_default` argument to `show_option_site_default`.
This makes it consistent with arguments of other `wp_dropdown_*()` functions.

Props SergeyBiryukov.
See #38632.
Fixes #38871.

git-svn-id: https://develop.svn.wordpress.org/trunk@39331 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-21 16:14:01 +00:00
Dominik Schilling (ocean90) e2f67203bb I18N: Add an additional caching layer for `_load_textdomain_just_in_time()`.
Previously, if no translation files exist for a text domain, `_load_textdomain_just_in_time()` went through the entire process each time it was called. This results in an increased call to `get_locale()` and its `locale` filter.
This change splits the logic into `_get_path_to_translation()` and `_get_path_to_translation_from_lang_dir()`. The former, which is used by `_load_textdomain_just_in_time()`, caches the result of the latter. It also removes some non-working code from `WP_Locale_Switcher::load_translations()`.

Props jrf, swissspidy, sharkomatic, ocean90.
Fixes #37997.

git-svn-id: https://develop.svn.wordpress.org/trunk@39330 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-21 16:06:38 +00:00
Ryan McCue 096f23db65 REST API: Correctly map meta keys to field names.
This accidentally assumed $name was the same as $meta_key, which ruined the whole point of $name.

Props tharsheblows, joehoyle.
Fixes #38786.


git-svn-id: https://develop.svn.wordpress.org/trunk@39328 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-21 05:40:46 +00:00
Ryan McCue 4b275bf861 REST API: Disable anonymous commenting by default.
Adding a brand new anonymous comment method is a potential conduit for spam. Since it's still useful functionality, we're now hiding it behind a filter to allow plugins and themes to turn it on if they do want it.

Props helen, rachelbaker, joehoyle.
Fixes #38855.


git-svn-id: https://develop.svn.wordpress.org/trunk@39327 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-21 05:31:07 +00:00