Commit Graph

2103 Commits

Author SHA1 Message Date
Joe McGill 142fefb269 Post Thumbnails: Prevent post thumbnail previews from spilling into other images.
After [38118], when previewing a page with a secondary loop, all post
thumbnails would be filtered to display the post thumbnail for the
page being previewed. This ensures `_wp_preview_post_thumbnail_filter()`
is only applied if the `$post_id` of the post meta being filtered is
equal to the post or page being previewed.

Props swisspidy, joemcgill.
Fixes #37697.

git-svn-id: https://develop.svn.wordpress.org/trunk@38433 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-29 12:24:09 +00:00
Dion Hulse e916b9e14c HTTP: Accept non-string values in cookies, fixing a regression since 4.5.
Props swissspidy.
Fixes #37768 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@38430 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-29 02:41:56 +00:00
Dion Hulse 7f2a81061a HTTP: Handle an edgecase within the URI parsing library included in Requests, where if a double slash exists at the start of the path the URL is passed to cURL malformed.
Props flixos90 for initial patch.
Fixes #37733 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@38429 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-29 02:32:48 +00:00
John Blackbourn a03376e798 Security: Trigger a `_doing_it_wrong()` when `check_ajax_referer()` is called without its first parameter. This brings it inline with `check_admin_referer()`.
Fixes #36361


git-svn-id: https://develop.svn.wordpress.org/trunk@38420 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 17:14:52 +00:00
John Blackbourn c786774d21 Themes: Introduce tests for the theme template hierarchy.
See #14310


git-svn-id: https://develop.svn.wordpress.org/trunk@38419 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 16:18:51 +00:00
John Blackbourn 58956ecf2d Permalinks: Correct an invalid peramstructure tag in a test.
Fixes #37858


git-svn-id: https://develop.svn.wordpress.org/trunk@38417 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 12:52:23 +00:00
Pascal Birchler 9701c29b90 Bootstrap: Fix failing external HTTP tests after [38411].
When testing the transports, the transport name needs to be capitalized for the class name to be correct (`WP_Http_Curl` vs. `WP_Http_curl` ).

See #36335.

git-svn-id: https://develop.svn.wordpress.org/trunk@38416 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 10:33:24 +00:00
John Blackbourn 7bb34dc5d9 Query: Add and improve tests for query conditionals on the front page and home page.
See #37851


git-svn-id: https://develop.svn.wordpress.org/trunk@38413 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 02:01:53 +00:00
Scott Taylor 4225e71a6b Bootstrap: after r38409 and r38410, revert r38402 which reverted r38399.
This fixes the paths in `wp-vendor/` that were including `src`. I want to drop this in so we can find out what else will break.

See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38411 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 22:31:11 +00:00
John Blackbourn 551fa31b5a Media: Add a `$wp_error` parameter to `wp_insert_attachment()` to give it parity with `wp_insert_post()`.
Fixes #37813
Props grapplerulrich, mrahmadawais


git-svn-id: https://develop.svn.wordpress.org/trunk@38408 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 17:24:58 +00:00
John Blackbourn f59a3b54c8 Build/Test tools: Ensure the `Tests_Query_Conditionals` tests set up the environment correctly before re-registering initial taxonomies.
Fixes #37851


git-svn-id: https://develop.svn.wordpress.org/trunk@38407 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 17:02:54 +00:00
John Blackbourn 417de45c08 Build/Test Tools: Add support for `is_front_page()` to `assertQueryTrue()` and assert that all the tested conditions are supported by the method.
Fixes #37849


git-svn-id: https://develop.svn.wordpress.org/trunk@38405 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 15:27:35 +00:00
John Blackbourn 52acaaad50 Themes: Remove failing tests introduced in [38390].
See #14310


git-svn-id: https://develop.svn.wordpress.org/trunk@38403 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 14:52:56 +00:00
Dion Hulse e353179ce5 Bootstrap: Revert [38399] as it's broken `/build/` and subsequently core.svn.wordpress.org.
The generated classmaps reference `/src/` files and operates in the assumption that the base directory is one level above `wp-settings.php`, which it isn't after our build processes are run.

See #36335


git-svn-id: https://develop.svn.wordpress.org/trunk@38402 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 14:36:42 +00:00
Peter Wilson b8f88aa597 Unit tests: Enforce $args object in `wp_nav_menu()` & `Walker_Nav_Menu`.
WordPress always* passes $args to filters as an array of arugments. A exception is made in `wp_nav_menu()` and the associated walker where these are passed to filters as an object, this has been the case for seven years (since [13368]).

These new tests enforce the use of an object in these filters to ensure backward compatibility is maintained.

See #24587.


git-svn-id: https://develop.svn.wordpress.org/trunk@38400 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 11:27:17 +00:00
Scott Taylor 388690382c Bootstrap: Autoload classes using a Composer-generated PHP 5.2-compatible Autoloader.
* `wp-admin` and `wp-includes` are scanned for classes to autoload
* Several 3rd-party and Ryan McCue-shaped libraries are excluded when the classmap is generated, see `composer.json`: `autoload.exclude-from-classmap`
* `wp-vendor/autoload_52.php` is included at the top of `wp-settings.php` - no changes need to be made to unit tests to include the autoloader
* An avalanche of `require()` and `require_once()` calls that loaded class files have been removed from the codebase.

The following files have been added to `svn:ignore` - they are not 5.2-compatible and fail during pre-commit:
* src/wp-vendor/autoload.php
* src/wp-vendor/composer/autoload_real.php
* src/wp-vendor/composer/autoload_static.php
* src/wp-vendor/composer/ClassLoader.php

We favor these files instead:
* src/wp-vendor/autoload_52.php
* src/wp-vendor/composer/autoload_real_52.php
* src/wp-vendor/composer/ClassLoader52.php

When new PHP classes are added to the codebase, simply run `composer install` or `composer update` from the project root to update the autoloader.

The future is now.

See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38399 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 09:15:01 +00:00
Scott Taylor 02319efa71 Unit Tests:
* Automatically delete objects that we were created during `wpSetUpBeforeClass` - posts, comments, terms (except 1), and user (except 1)
* The amount of leftover data between tests was breathtaking - use the new function: `_delete_all_data()`
* Commit database transactions for all `TestCase`s, not just those that implement `wpSetUpBeforeClass` and `wpTearDownAfterClass`
* The tests run 10-20 seconds faster now

See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38398 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 08:35:16 +00:00
johnbillion 8139765b1f Themes: Begin introducing unit tests for the expected theme template hierarchy. More to come.
See #14310


git-svn-id: https://develop.svn.wordpress.org/trunk@38390 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 22:19:16 +00:00
Scott Taylor db0e1ed0af Unit Tests: after r38303, replace usage of `global $_wp_additional_image_sizes` with `wp_get_additional_image_sizes()`.
See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38383 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 20:50:24 +00:00
John Blackbourn e795f6da1d Build/Test Tools: Remove many unnecessary calls to `rand_str()` which can, in theory, fail at random. Static strings are much more appropriate.
See #37371


git-svn-id: https://develop.svn.wordpress.org/trunk@38382 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 20:21:30 +00:00
Boone Gorges 6eaa56f3d4 Don't improperly cast IDs when fetching post, user, or term objects.
Blindly casting passed IDs to integers can generate false positives
when the ID is cast to `1`.

Props deeptiboddapati.
Fixes #37738.

git-svn-id: https://develop.svn.wordpress.org/trunk@38381 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 19:08:23 +00:00
John Blackbourn 5e71c349af Role/Capability: Only users who can manage options should be able to trash/delete the page for posts or the front page, as they are the only users who can restore it or subsequently alter the "Front page displays" setting.
Fixes #37580
Props JakePT


git-svn-id: https://develop.svn.wordpress.org/trunk@38378 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 18:22:28 +00:00
Boone Gorges ff0386b5c1 Use shared fixture in `comment_exists()` tests.
Props Frank Klein.
Fixes #37842.

git-svn-id: https://develop.svn.wordpress.org/trunk@38372 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 17:41:51 +00:00
Scott Taylor a02d79cf73 Site Icon: There is no good reason for `class-wp-site-icon.php` to drop a global instance of itself whenever the file is loaded. The lone use of the `global` instance of `WP_Site_Icon` is in an AJAX action that provides virtually no way to override - the file is loaded immediately before the `global` is used.
Let us remove the `$wp_site_icon` global. I will fall on the sword if this comes back to bite us (waiting with bated breath).

See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38355 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-25 19:08:38 +00:00
Scott Taylor 5e1193272f Taxonomy: in `get_terms()`, do not assume that legacy args are being passed when the only params are top-level `meta_*` values. Add keys in `WP_Term_Query::__construct()`.
Adds unit tests.

Props flixos90, boonebgorges.
Fixes #37568.


git-svn-id: https://develop.svn.wordpress.org/trunk@38337 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-23 14:44:19 +00:00
Boone Gorges 74b912705d Tests: Fix incorrect variable name from [38330].
See #37630.

git-svn-id: https://develop.svn.wordpress.org/trunk@38331 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-23 13:48:13 +00:00
Boone Gorges b93e0739a9 Tests: Attachment `create()` method should match signature of other `create()` methods.
Legacy argument format continues to be accepted.

Props bcole808.
See #37630.

git-svn-id: https://develop.svn.wordpress.org/trunk@38330 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-23 13:42:36 +00:00
Scott Taylor e878e8156b Media: fix unit test after [38296].
https://en.wikipedia.org/wiki/Coupling_(computer_programming)#Disadvantages

Fixes #36246.


git-svn-id: https://develop.svn.wordpress.org/trunk@38302 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-22 04:16:29 +00:00
Scott Taylor 081e51d94b Media: use `wp_get_attachment_metadata()` instead of `get_post_meta()` where appropriate.
Adds unit test.

Props JorritSchippers.
Fixes #36246.


git-svn-id: https://develop.svn.wordpress.org/trunk@38296 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-21 06:14:37 +00:00
Boone Gorges 29a5d46701 Allow attachment taxonomies to be fetched as objects.
By adding the `$output` parameter to `get_attachment_taxonomies()`, the
function signature matches that of `get_object_taxonomies()`. The change
also allows for more consistent behavior when passing `output=objects`
to `get_object_taxonomies()` for the 'attachment' object type, since
the `$output` parameter is now passed through the function stack.

Props codemovement.pk.
See #37368.

git-svn-id: https://develop.svn.wordpress.org/trunk@38292 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 17:34:13 +00:00
Boone Gorges 773eb46bf8 Introduce tests for `get_attachment_taxonomies()`.
See #37368.

git-svn-id: https://develop.svn.wordpress.org/trunk@38291 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 17:24:12 +00:00
Boone Gorges 86a2c06f6f Introduce tests for `get_object_taxonomies()`.
See #37368.

git-svn-id: https://develop.svn.wordpress.org/trunk@38290 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 17:00:56 +00:00
Boone Gorges f05beeba8c Query: Non-scalar and negative values for 'p' should always result in a 404.
Previously, the 'p' query var was being run through `absint()`, which
caused unexpected results.

Props Akeif, kouratoras.
Fixes #33372.

git-svn-id: https://develop.svn.wordpress.org/trunk@38288 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 02:31:31 +00:00
Boone Gorges 54b51f1a26 Mail: Don't set Sender field when setting From.
[38058] changed `wp_mail()` so that it used PHPMailer's `setFrom()`
method rather than setting the From and FromName headers directly. See
behavior of setting the `Sender` field. This causes `mail` to be
called with the `-f` flag, which causes outgoing email to fail on some
server environments.

Props Clorith, iandunn, DrewAPicture.
Fixes #37736.

git-svn-id: https://develop.svn.wordpress.org/trunk@38286 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 02:16:54 +00:00
Boone Gorges ba9eda1a9b Tests: Move some utility classes to their own files.
Props Frank Klein.
Fixes #37523.


git-svn-id: https://develop.svn.wordpress.org/trunk@38285 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-19 15:44:37 +00:00
Boone Gorges 5fabc6b769 Add wordpress-importer tests demonstrating slashed data behavior.
See #21007.

git-svn-id: https://develop.svn.wordpress.org/trunk@38283 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-19 13:26:04 +00:00
Scott Taylor 8c68a5c354 Unit Tests: skip checking the value in `Tests_User:test_user_properties` for `db`. Casting to `array` is not the most elegant thing here, and various versions of PHP key protected/private fields differently when objects are cast.
See [38275], #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38278 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-18 19:37:23 +00:00
Boone Gorges 83c7544ef8 In `is_object_in_term()`, return error object rather than caching it.
This change prevents an error object from being stored in the cache,
and prevents notices from being thrown when plucking term IDs to put
into the relationship cache.

See #32044, #36814.

Props rpayne7264.
Fixes #37721.

git-svn-id: https://develop.svn.wordpress.org/trunk@38277 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-18 19:14:52 +00:00
Dominik Schilling dd92169bfe Post Thumbnails: Restore thumbnail support for media files.
* Allow to add/remove a featured image to `attachment:audio` and `attachment:video` post types, see [27657].
* Change conditionals to check for theme OR post type support.
* Add tests for #12922.

Broken in [37658].

Props flixos90, joemcgill, DrewAPicture, wonderboymusic.
See #12922.
Fixes #37658.

git-svn-id: https://develop.svn.wordpress.org/trunk@38263 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-15 19:15:48 +00:00
Dominik Schilling a0aba9dc44 Script Loader: Fix protocol-relative URLs for the `preconnect` relation type.
`wp_resource_hints()` parses the URL for the `preconnect` and `dns-prefetch` relation types to ensure correct values for both. While protocol-relative URLs are supported for `dns-prefetch`, the double slash was lost for `preconnect`.

Props swissspidy, peterwilsoncc.
Props azaozz for review.
Fixes #37652.

git-svn-id: https://develop.svn.wordpress.org/trunk@38255 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-13 18:34:12 +00:00
Aaron Jorbin 17afb9c704 Bootstrap/Load: Revert Plugin Global restoration around `advance-cache.php`.
First added in [37588] and later modified in [38224], the idea was to ensure that filters/actions added before `advance-cache.php` would not disappear if `advance-cache.php` overloaded the filters/actions with code such as `$wp_filter = array()`. This is an edge case and one that there is no documented case of existing.

This restores the behavior from WordPress 4.5 and before. It is strongly encouraged that developers using `advance-cache.php` to use the Plugins API that is available before the loading of `advance-cache.php` rather than directly interacting with any of the globals.

Props azaozz, jorbin, dd32 for review, pento for review, westi for investigation, ipstenu for research.
See #36819.



git-svn-id: https://develop.svn.wordpress.org/trunk@38251 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-13 15:59:03 +00:00
Sergey Biryukov a9717f8ef0 Docs: Replace some more HTTP links with HTTPS.
Props johnpgreen.
Fixes #37622. See #36993.

git-svn-id: https://develop.svn.wordpress.org/trunk@38239 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-10 16:09:54 +00:00
Gary Pendergast 32b55e7e7a Boostrap/Load: Improve forward compatiblity of plugin global backup methods.
[37588] added methods to backup the plugin globals, for ensuring that advanced cache drop-ins don't overwrite hooks that've been added earlier in the load process.

The method for restoring the plugin globals wasn't compatible with the implementation of `WP_Hook` in #17817. `WP_Hook` implements `ArrayAccess`, so `_restore_plugin_globals()` was treating it as an array, and inadvertantly overwriting the `WP_Hook` object with a plain array.

To avoid having to re-write this code as part of #17817, we now use `add_filter()` to restore any hooks that were added by cache drop-ins, which `WP_Hook` correctly supports.

Props pento, jorbin.
See #36819.



git-svn-id: https://develop.svn.wordpress.org/trunk@38223 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-09 01:44:20 +00:00
Aaron Jorbin 7044243aa2 Updates: Improve experience for Bulk Actions when FTP is dismissed.
Before this change, when a bulk update was canceled due dismissing the FTP credentials modal, part of the actions didn't get canceled.  This meant the "There is a new version of…” notices become blank and the updates you had checked became unchecked.  Now, the notices remain and you are essentially returned to the screen you had before. Strings are also updated to improve ARIA usage.

Fixes #37563.
Props ocean90, swissspidy, obenland, afercia.



git-svn-id: https://develop.svn.wordpress.org/trunk@38221 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-09 01:13:08 +00:00
Jeremy Felt 0df4e1f026 Multisite: Use `get_current_blog_id()` in `get_site()` for current site.
The global `$current_blog` is not switched in `switch_to_blog()` and can
not be used to properly retrieve current switched site information.

See #37607.


git-svn-id: https://develop.svn.wordpress.org/trunk@38217 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-08 22:32:47 +00:00
Boone Gorges 0bbd0f3a5f Improve category check in `redirect_canonical()` when permastruct contains category slug.
[37262] changed a check in `redirect_canonical()` so that it checked
categories in the object cache rather than querying the database. However,
the check was based on the identity of `WP_Term` objects, which in
certain cases can be augmented by the main WP query routine, causing
failures of the `in_array()` check. This caused unnecessary redirects
for URLs where `is_single()` is true, but the URL is different from the
post permalink, such as the `embed` endpoint.

`has_term()` also checks the cache, but does not sufer from this bug.

Props cmillerdev.
Fixes #36602.

git-svn-id: https://develop.svn.wordpress.org/trunk@38216 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-08 18:48:53 +00:00
Scott Taylor e5b88bcd8e Taxononmy: add unit that shows that `WP_Term_Query` is broken when the query is read from the cache.
See #37591.


git-svn-id: https://develop.svn.wordpress.org/trunk@38211 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-07 04:42:07 +00:00
Dominik Schilling a02d4c4a16 Update/Install: Replace "error" and "-1" failure messages with a more meaningful one.
* "-1" is an invalid nonce error, show 'An error has occurred. Please reload the page and try again.'.
* "error" means that the connection to the server was lost, show 'Connection lost or the server is busy. Please try again later.'.
* Escape the message in `wp-updates-admin-notice` because the response may include HTML.
* Remove HTML tags in `wp.updates.isValidResponse()` to make PHP's error messages more readable.

Props azaozz for review.
Fixes #37583.

git-svn-id: https://develop.svn.wordpress.org/trunk@38205 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-05 19:27:56 +00:00
Sergey Biryukov 7f106c4f8b Formatting: In `remove_accents()`, correct replacements for:
* Latin small letter n preceded by apostrophe
* Latin capital letter Eng
* Latin small letter Eng

Props gitlost.
Fixes #37564.

git-svn-id: https://develop.svn.wordpress.org/trunk@38193 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-04 13:55:30 +00:00
Boone Gorges fa21c5e675 In `WP_Term_Query`, accept a string value for `taxonomy`.
Props endocreative.
Props ocean90 for review.
Fixes #37545.

git-svn-id: https://develop.svn.wordpress.org/trunk@38181 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-03 13:50:14 +00:00
Dominik Schilling 48078058d7 Script Loader: Ignore deregistered dependencies in `wp_dependencies_unique_hosts()`.
Prevents a PHP warning when a handle of a deregistered dependency is still in the queue.

Fixes #37502.

git-svn-id: https://develop.svn.wordpress.org/trunk@38174 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-31 18:24:21 +00:00
Dominik Schilling af6b1a5388 Plugins: Move capability checks further up in `wp_ajax_update_plugin()` and `wp_ajax_delete_plugin()`.
Add tests for both Ajax handlers.

Props Yorick Koster, swissspidy.
Fixes #37490.

git-svn-id: https://develop.svn.wordpress.org/trunk@38168 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-27 17:42:01 +00:00
Dominik Schilling 24f890045c HTTP API: Normalize cookies before passing them to Requests.
Requests has its own cookie object in form of `Requests_Cookie`. Therefore we have to convert `WP_Http_Cookie` objects to `Requests_Cookie`.
This introduces `WP_Http_Cookie::get_attributes()` to retrieve cookie attributes of a `WP_Http_Cookie` object and `WP_Http::normalize_cookies()` to convert the cookie objects.

Fixes #37437.

git-svn-id: https://develop.svn.wordpress.org/trunk@38164 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-27 15:31:48 +00:00
Andrew Ozz 52ea1c53ac TinyMCE: upgrade to 4.4.1, changelog: https://www.tinymce.com/docs/changelog/#version441-july262016.
See #37427.
Fixes #37476.

git-svn-id: https://develop.svn.wordpress.org/trunk@38155 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-26 21:46:36 +00:00
Sergey Biryukov ccb70aee4b Permalinks: In `get_page_uri()`, don't prepend a parent page slug if it's empty.
Props inderpreet99, SergeyBiryukov.
Fixes #36174.

git-svn-id: https://develop.svn.wordpress.org/trunk@38145 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-23 10:04:20 +00:00
Sergey Biryukov 299802bbb5 Unit Tests: Add a `@ticket` reference for `test_get_page_uri_without_argument()`.
See #26284.

git-svn-id: https://develop.svn.wordpress.org/trunk@38144 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-23 08:54:23 +00:00
Sergey Biryukov 4f23ce8545 Unit Tests: Move `get_page_uri()` tests to `post/getPageUri.php`, added in [37345].
See #26284.

git-svn-id: https://develop.svn.wordpress.org/trunk@38143 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-23 08:52:52 +00:00
Dominik Schilling 63b7f3da1b Script Loader: Use `dns-prefetch` for the Emoji CDN.
* `preconnect` will be potentially pretty heavy on the CDN. With the Unicode 9.0 emoji update, almost all browsers will trigger the `preconnect`.
* `preconnect` only opens one connection, but `s.w.org` is HTTP/1.1, so the browser will use the preconnected connection for the first emoji, then it has to open new connections for subsequent emoji.

Also use the same URL as we use for the `emoji_svg_url` filter. This will print the hint for the correct CDN in case someone uses a custom CDN.

Props peterwilsoncc.
Fixes #37387.

git-svn-id: https://develop.svn.wordpress.org/trunk@38122 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-20 18:18:30 +00:00
Dominik Schilling 44676ab38f Plugins: Improve Ajax search of new plugins.
Fixes a few accessibility issues, restores the "Search Results" tab and the search type selector, and improves compatibility with older browsers.

Props rahulsprajapati, swissspidy, adamsilverstein, ocean90
See #37233.

git-svn-id: https://develop.svn.wordpress.org/trunk@38119 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-20 16:31:50 +00:00
Rachel Baker 2cda326902 Tests: Include the `check_comment` function tests in the comment group.
Adds `@group comment` notation to the `Tests_Comment_CheckComment` class. Introduced in [32519].

Props gma992.
Fixes #37356.

git-svn-id: https://develop.svn.wordpress.org/trunk@38114 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-20 14:06:44 +00:00
Mike Schroder ffb2db0521 Media: Clean up prior image edits if `IMAGE_EDIT_OVERWRITE` is true.
When `IMAGE_EDIT_OVERWRITE` is set to true, edited image files are
supposed to be deleted when an image is restored to the original.

However, when an image was edited more than once, and then restored,
files created during previous edits were left behind.

Fixes this behavior by updating `wp_save_image()` to clean up
leftover images after each edit when `IMAGE_EDIT_OVERWRITE` is true.

Props bradt, chriscct7, joemcgill.
Fixes #32171.

git-svn-id: https://develop.svn.wordpress.org/trunk@38113 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-20 07:34:54 +00:00
Sergey Biryukov 87376166f2 Multisite: Correct default value for `orderby` in `WP_Network_Query::__construct()`.
Add a unit test.

See #32504.

git-svn-id: https://develop.svn.wordpress.org/trunk@38102 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-19 13:09:39 +00:00
Peter Wilson b92c1c58b3 Script Loader: Limit resource hinting to enqueued assets.
Externally hosted script and style dependencies trigger `dns-prefetch` hinting only when enqueued. This removed a bug in which hinting was added on registration.

Renames the function `wp_resource_hints_scripts_styles` to `wp_dependencies_unique_hosts` as the function provides the hosts, not the hinting.

Props swissspidy.
Fixes #37385.


git-svn-id: https://develop.svn.wordpress.org/trunk@38100 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-19 02:34:42 +00:00
Boone Gorges 103da159d5 Taxonomy: Improve back compat of values passed to 'terms_clauses' filter.
Prior to the introduction of `WP_Term_Query`, the 'orderby' clause
passed to the 'terms_clauses' filter was prefixed by `ORDER BY`. After
`WP_Term_Query`, this was not the case; `ORDER BY` was added after the
filter. As such, plugins filtering 'terms_clauses' and returning an
'orderby' clause beginning with `ORDER BY` resulted in invalid syntax
when `WP_Term_Query` prepended a second `ORDER BY` keyword to
the clause.

This changeset rearranges the way the 'orderby' clause is built so that
it will be passed to 'terms_clauses' in the previous format.

Fixes #37378.

git-svn-id: https://develop.svn.wordpress.org/trunk@38099 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-19 02:12:48 +00:00
John Blackbourn 4a39dde8f5 Role/Capability: Introduce capability tests for non-logged-in users.
Fixes #37405


git-svn-id: https://develop.svn.wordpress.org/trunk@38096 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-18 22:38:18 +00:00
Jeremy Felt 4f2008a104 Meta: Remove object subtype handling from `register_meta()`.
Registration is now based solely on object type, which allows the code around this to be simplified significantly.

In the process of making this adjustment:

* `register_meta()`, `unregister_meta_key()`, `get_registered_metadata()`, and `registered_meta_key_exists()` no longer return `WP_Error` objects.
* The recently introduced `wp_object_type_exists()` function and the restriction on object type has been removed.

Note: No guarantee of uniqueness is made across object subtypes. Registered meta keys should be uniquely prefixed to avoid conflict.

Fixes #35658.


git-svn-id: https://develop.svn.wordpress.org/trunk@38095 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-18 21:15:37 +00:00
Gary Pendergast 1ba5469262 Emoji: Update to Unicode 9.0 emoji.
This includes a new test in the emoji loader, to see if the browser supports rendering Unicode 9.0 emoji, as well as an update to `twemoji.js`, to load Unicode 9.0 twemoji images.

The default CDN location for loading Twemoji images has changed, moving to a versioned subdirectory. This allows updates without needing to purge the CDN.

Fixes #37361.



git-svn-id: https://develop.svn.wordpress.org/trunk@38087 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-18 07:34:24 +00:00
Joe McGill a91e769e36 Media: Prevent `image_get_intermediate_size()` from returning cropped images.
When `$size` is passed to `image_get_intermediate_size()` as an array of width
and height values and an exact image size matching those values isn't available,
the function loops through the available attachment sizes and returns the
smallest image larger than the requested dimensions with the same aspect ratio.

The aspect ratio check is skipped for the 'thumbnail' size to provide a fallback
for small sizes when no other image option is available. This resulted in a poor
selection when the size requested was smaller than the 'thumbnail' dimensions
but a larger size matching the requested ratio existed.

This refactors the internals of `image_get_intermediate_size()` to ensure the
'thumbnail' size is only returned as a fallback to small sizes once all other
options have been considered, and makes the control flow easier to follow.

This also introduces a new helper function, `wp_image_matches_ratio()` for
testing whether the aspect ratios of two sets of dimensions match. This function
is also now used in `wp_calculate_image_srcset()` during the selection process.

Props flixos, joemcgill.
Fixes #34384, #34980.

git-svn-id: https://develop.svn.wordpress.org/trunk@38086 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-18 02:13:45 +00:00
Sergey Biryukov 38bcf065df Multisite: Correct default values for `orderby` and `order` in `WP_Site_Query::__construct()`.
Add a unit test.

Props ramiy, SergeyBiryukov.
See #35791.

git-svn-id: https://develop.svn.wordpress.org/trunk@38085 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-17 23:29:11 +00:00
Sergey Biryukov 59f15cdea9 Unit Tests: Account for the string changes in [38077].
See #18218.

git-svn-id: https://develop.svn.wordpress.org/trunk@38078 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-17 16:23:31 +00:00
Dominik Schilling 8756f2912f Import: Enhance accessibility on the Import screen.
* Remove title attributes.
* Show "Install Now" and "Details" links if the importer isn't installed yet.
* Show a "Run Importer" link if the importer is installed. It also handles activation if the plugin isn't activated.
* Add `aria-label` attributes to each link.
* Unify the importer descriptions to make them independent from the plugin state. The API was changed in [meta3690].
* Adjust JavaScript callbacks for ajaxified importer installs.

Props afercia, swissspidy, ocean90.
See #24766.
Fixes #35191.

git-svn-id: https://develop.svn.wordpress.org/trunk@38075 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-17 15:31:29 +00:00
John Blackbourn 6f31511f23 Canonical: Remove a duplicate test data entry.
Fixes #37370


git-svn-id: https://develop.svn.wordpress.org/trunk@38063 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-14 20:50:45 +00:00
Boone Gorges af068cdbe0 Mail: Improve handling of UTF-8 address headers.
Previously, `wp_mail()` implemented Reply-To as a generic header, using
PHPMailer's `addCustomHeader()`. As such, the email address portion of
the header was being incorrectly encoded when the name portion
contained UTF-8 characters. Switching to PHPMailer's more specific
`addReplyTo()` method fixes the issue.

For greater readability, the handling of all address-related headers
(To, CC, BCC, Reply-To) has been standardized.

Props szepe.viktor, iandunn, bpetty, stephenharris.
Fixes #21659.

git-svn-id: https://develop.svn.wordpress.org/trunk@38058 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 18:03:52 +00:00
Dominik Schilling 94c2212de8 Update/Install: Give context to some install/update strings to allow for differentiation between theme and plugin translations.
Props swissspidy, SergeyBiryukov.
Fixes #37290.

git-svn-id: https://develop.svn.wordpress.org/trunk@38057 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 17:31:15 +00:00
Joe McGill 94da293e5f Media: URL encode spaces in `srcset` attributes.
In some cases, images in the media library may contain spaces in
their filenames. This results in an invalid `srcset` attribute,
causing broken images on the front end. This change fixes the issue
by replacing spaces in URLs with URL encoded '%20' characters before
returning the `srcset` string.

Props underdude, joemcgill.
Fixes #36549.

git-svn-id: https://develop.svn.wordpress.org/trunk@38052 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 15:23:27 +00:00
Dominik Schilling a9d1e10161 Remove `svn:executable` property from Requests and some other files.
git-svn-id: https://develop.svn.wordpress.org/trunk@38049 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 14:38:21 +00:00
Rachel Baker 224aecf240 Comments: Include comment_content with html and without in blacklist_keys comparison.
After [38047], also include the comment_content with html in the preg_match against blacklist keys to match urls.

Props ocean90.
Fixes #37208.

git-svn-id: https://develop.svn.wordpress.org/trunk@38048 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 14:04:10 +00:00
Rachel Baker d6eac6593c Comments: Strip html tags from comment content before blacklist_keys comparison.
Use `wp_kses()` to clean comment_content for preg_match against the blacklist_keys. Also includes some initial unit tests for `wp_blacklist_check()`.
Previously, if a blacklisted key was used in comment_content split by an html tag the regex in `wp_blacklist_check()` would not find a match. Example: Where "springfield" was a blacklisted word, if the content of a comment included `spring<i>field</i>" `wp_blacklist_check()` would not return true.

Props cfinke.
Fixes #37208.

git-svn-id: https://develop.svn.wordpress.org/trunk@38047 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 13:47:49 +00:00
Dominik Schilling 9eaab508ab Database: Add unit test to test that a column type change for a table name with a hyphen is working after [37583].
Fixes #31679.

git-svn-id: https://develop.svn.wordpress.org/trunk@38044 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 11:38:29 +00:00
Jeremy Felt da154081f6 Meta: Ensure filters are backwards compatible for pre-4.6 style meta registration.
When using `register_meta()` with the function signature from 4.5 and earlier, the `auth_{$type}_meta_{$key}` and `sanitize_{$type}_meta_{$key}` filters are used. Any calls to `register_meta()` expecting this behavior should continue to work. The new filters, which take advantage of object subtypes, should not be added unless the proper `$args` array is passed.

See #35658.


git-svn-id: https://develop.svn.wordpress.org/trunk@38041 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 04:45:50 +00:00
Jeremy Felt 6830e90949 Meta: Remove filters when meta is unregistered.
If auth and/or sanitize callbacks are specified in the arguments for
`register_meta()`, filters are added to handle these callbacks. These
should be removed when calling `unregister_meta_key()` to avoid
unintentional filtering.

See #35658.


git-svn-id: https://develop.svn.wordpress.org/trunk@38040 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 04:12:41 +00:00
Dominik Schilling a27c61f7c2 Resource Hints: Remove schemes from `dns-prefetch` resource hint outputs.
"wordpress.org", "!http://wordpress.org", and "!https://wordpress.org" should all have the same DNS lookup.
Also, replace `\r\n` with `\n` and ensure that invalid URLs are skipped.

Props niallkennedy, peterwilsoncc.
Fixes #37240.

git-svn-id: https://develop.svn.wordpress.org/trunk@38036 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-12 11:31:58 +00:00
Dominik Schilling e556fec595 Toolbar: Allow 0 as a value for the `tabindex` property of a menu item.
To enhance accessibility for items without a link you can now define `tabindex="0"`, which makes descendant dropdowns accessible.

Props joedolson, afercia, ocean90.
Fixes #32495.

git-svn-id: https://develop.svn.wordpress.org/trunk@38035 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-12 11:18:00 +00:00
Andrew Ozz f11d5ef4d8 TinyMCE: update to 4.4.0, changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt. Includes two bugfixes for #36434.
Fixes #37327.

git-svn-id: https://develop.svn.wordpress.org/trunk@38034 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-12 00:19:47 +00:00
Pascal Birchler 68cff6ac40 Plugins: Improve Ajax search of installed plugins.
Fixes a few accessibility issues, tweaks the design of the search form to match other Ajax search fields and improves compatibility with older browsers.

See #37230.

git-svn-id: https://develop.svn.wordpress.org/trunk@38033 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-11 21:49:30 +00:00
Dominik Schilling a927a48b31 Unit tests: Don't change the `memory_limit` setting during tests.
40M isn't enough and can lead to an "out of memory" error. Change `test_wp_raise_memory_limit()` to test that `wp_raise_memory_limit()` doesn't *lower* the memory limit.

See [38015].
See #32075.

git-svn-id: https://develop.svn.wordpress.org/trunk@38016 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-08 18:16:07 +00:00
Dominik Schilling c68f1ec772 Bootstrap: Enhance core's memory limit handling.
* Don't lower memory limit if the current limit is greater than `WP_MAX_MEMORY_LIMIT`.
* Set `WP_MEMORY_LIMIT` and `WP_MAX_MEMORY_LIMIT` to current limit if the `memory_limit` setting can't be changed at runtime.
* Use `wp_convert_hr_to_bytes()` when parsing the value of the `memory_limit` setting because it can be a shorthand or an integer value.
* Introduce `wp_raise_memory_limit( $context )` to raise the PHP memory limit for memory intensive processes. This DRYs up some logic and includes the existing `admin_memory_limit` and `image_memory_limit` filters. The function can also be used for custom contexts, the `{$context}_memory_limit` filter allows to customize the limit.
* Introduce `wp_is_ini_value_changeable( $setting )` to determine whether a PHP ini value is changeable at runtime.
* Remove a `function_exists( 'memory_get_usage' )` check. Since PHP 5.2.1 support for memory limit is always enabled.

Related commits: [38011-38013]

Props jrf, A5hleyRich, swissspidy, ocean90.
Fixes #32075.

git-svn-id: https://develop.svn.wordpress.org/trunk@38015 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-08 14:36:37 +00:00
Dominik Schilling 629c6e36b5 Bootstrap: Clean up `wp_convert_hr_to_bytes()`.
* Don't return a value higher than `PHP_INT_MAX`.
* Add unit tests.

Props jrf.
See #32075.

git-svn-id: https://develop.svn.wordpress.org/trunk@38013 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-08 12:53:08 +00:00
Boone Gorges f41d3cff7d Tests: Ensure that test for invalid user ID actually uses an invalid user ID.
This prevents false positives when the ID column's incrementor has exceeded the
hardcoded invalid ID.

Fixes #37308.

git-svn-id: https://develop.svn.wordpress.org/trunk@38005 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 16:47:25 +00:00
Boone Gorges 9d34db0590 Comments: Cache results of `SELECT FOUND_ROWS()` query.
When comment IDs are fetched from the cache rather than the database,
the subsequent `SELECT FOUND_ROWS()` query will not return the correct value.
To avoid unnecessary queries, we cache the results of the `found_comments`
query alongside the comment IDs.

Props spacedmonkey.
Fixes #37184.

git-svn-id: https://develop.svn.wordpress.org/trunk@38001 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 14:26:21 +00:00
Sergey Biryukov eff1d5f58e Unit Tests: Add description for `data_get_comments_number_text_declension()`.
See #13651.

git-svn-id: https://develop.svn.wordpress.org/trunk@37997 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 10:44:57 +00:00
Jeremy Felt 4938acf349 Meta: Introduce an initial set of tests for `register_meta()`.
Props sc0ttkclark, ericlewis.
See #35658.


git-svn-id: https://develop.svn.wordpress.org/trunk@37995 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 00:14:40 +00:00
Ryan McCue 194c8d0e33 HTTP API: Switch back to returning an array.
The array-compatibility object we started returning in r37428 unfortunately isn't enough like an array. In particular, `is_array()` checks fail, despite the object implementing ArrayAccess. Mea culpa.

This moves the WP_HTTP_Response object to a new http_response key in the array, and changes the value back to an actual array.

Fixes #37097.
See #33055.


git-svn-id: https://develop.svn.wordpress.org/trunk@37989 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 17:50:44 +00:00
Sergey Biryukov 946e6ac8de I18N: Introduce an on/off switch for locales where comment number needs to be declined.
When enabled, the switch would override the theme's pseudo-plural `'% Comments'` string with a correct form of `_n( '%s Comment', '%s Comments', $number )`.

Historically, `comments_popup_link()` and `get_comments_number_text()` did not support plural forms and used a pseudo-plural style instead, so some locales were forced to come up with workarounds to display the number of comments in their language correctly.

This change should make those functions more i18n-friendly.

Fixes #13651.

git-svn-id: https://develop.svn.wordpress.org/trunk@37987 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 14:45:55 +00:00
Dominik Schilling 0037aa1dd5 Plugins: In `plugin_basename()` sort plugin paths before resolving symlinks.
`arsort()` sorts the paths reverse-alphabetically while preserving the keys. It results in a longer path being listed before a shorter one with the same base directory(ies).

Props jdgrimes, ocean90.
Fixes #28441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37983 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 09:44:58 +00:00
Weston Ruter ad52e49e4f Customize: Ensure that `WP_Customize_Setting::value()` can return a previewed value for aggregated multidimensionals.
Fixes #37294.


git-svn-id: https://develop.svn.wordpress.org/trunk@37982 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 05:58:28 +00:00
Dominik Schilling 8a1fad3178 XML-RPC: Add unit test to verify IXR changes in [37244].
Props aaires.
Fixes #36586.

git-svn-id: https://develop.svn.wordpress.org/trunk@37980 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-05 21:58:41 +00:00
Dominik Schilling e34157ceb8 I18N: Add tests for `wp_maybe_decline_date()`.
Reverts [37718], `$wp_locale` needs to be cloned.

Props SergeyBiryukov.
Fixes #36790.

git-svn-id: https://develop.svn.wordpress.org/trunk@37975 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-05 16:09:01 +00:00
Dominik Schilling c259f4c35d General: Return "O B" when passing 0 to `size_format()`.
Props swissspidy.
Fixes #36635.

git-svn-id: https://develop.svn.wordpress.org/trunk@37962 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-05 10:35:24 +00:00
Dominik Schilling 1ae9f9c733 Unit Tests: Change some `@group` annotations to `@ticket`.
git-svn-id: https://develop.svn.wordpress.org/trunk@37954 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 20:24:52 +00:00
Dominik Schilling 2f90caa574 Nav Menus: In `Walker_Nav_Menu_Edit::start_el()` initialize `$original_title` with `false`.
Prevents displaying "Original:" without a title when adding a menu item without a title.

Props grapplerulrich, swissspidy.
Fixes #36729.

git-svn-id: https://develop.svn.wordpress.org/trunk@37953 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 20:15:48 +00:00
Dominik Schilling bc6e877446 Unit Tests: Remove `@group foo` annotation from `Tests_WP_Resource_Hints::test_dns_prefetch_styles()`.
git-svn-id: https://develop.svn.wordpress.org/trunk@37951 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 19:28:25 +00:00
Dominik Schilling f043ad7e02 Unit Tests: Remove an unused parameter from `Tests_Ajax_DimComment::test_with_bad_id()`.
Prevents a "too few arguments" error in PHP 7.1.0.

Fixes #37271.

git-svn-id: https://develop.svn.wordpress.org/trunk@37950 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 19:07:21 +00:00
Rachel Baker 855c081931 REST API: Reverse order of setting sanitization/validation, validating prior to sanitizing.
Fixes mistake in the current behavior, where the sanitization callback ran before the validation callback. Now the validation callback will run before the sanitization.

Props schlessera, rachelbaker.
See #37247.
Fixes #37192.




git-svn-id: https://develop.svn.wordpress.org/trunk@37943 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-02 23:02:45 +00:00
Weston Ruter c8ebbb3e0d Customize: Reverse order of setting sanitization/validation, validating prior to sanitizing.
Reverses order where sanitization was being applied before validation originally in accordance with REST API logic.

Props westonruter, schlessera.
See #34893.
See #37192.
Fixes #37247.


git-svn-id: https://develop.svn.wordpress.org/trunk@37942 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-02 18:38:07 +00:00
Dominik Schilling (ocean90) 92dd472359 Script Loader: Introduce an API to register resource hints.
Resource hints allow browsers to prefetch specific pages or render them in the background to perform DNS lookups or to begin the connection handshake (DNS, TCP, TLS) in the background.

By default, `wp_resource_hints()` prints hints for "s.w.org" (the WordPress.org CDN) and for all scripts and styles which are enqueued from external hosts.
Use the `wp_resource_hints` filter to add custom domains and URLs for `dns-prefetch`, `preconnect`, `prefetch` or `prerender`.

Props voldemortensen, swissspidy.
Fixes #34292.

git-svn-id: https://develop.svn.wordpress.org/trunk@37920 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 19:35:27 +00:00
Joe McGill 0b4798b2bc Post Thumbnails: Add helper functions for attachment captions.
This adds three new functions for getting/displaying attachment captions:

* `wp_get_attachment_caption` - Retrieves a caption for a specific attachment.
* `get_the_post_thumbnail_caption()` - Returns the post thumbnail caption.
* `the_post_thumbnail_caption()` - Displays the post thumbnail caption.

These are helpful for displaying a caption associated with an image directly
in a template, rather than using the caption shortcode.

This also introduces two new filters:

* `wp_get_attachment_caption` - Filters the value of `wp_get_attachment_caption()`.
* `the_post_thumbnail_caption` - Filters the display of the post thumbnail caption.

`the_post_thumbnail_caption()` is automatically filtered by `wptexturize()`,
`convert_smilies()`, and `convert_chars()` in `wp-includes/default-filters.php`.

Props flixos90, joemcgill.
Fixes #12235.

git-svn-id: https://develop.svn.wordpress.org/trunk@37915 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 17:28:00 +00:00
Dominik Schilling (ocean90) 206380180e Text Changes: Unify permission error messages.
The new format looks like "Sorry, you are not allowed to <action>.". This provides a consistent experience for all error messages related to missing permissions. It also reduces the number of similar strings and allows translators to provide a consistent style in their language.

Props ramiy, Presskopp.
Fixes #34521.

git-svn-id: https://develop.svn.wordpress.org/trunk@37914 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 15:15:40 +00:00
Dominik Schilling (ocean90) a89fdc3935 Plugins: Return the original value in `apply_filters_deprecated()` if no filter is registered for the tag.
Props flixos90.
Fixes #10441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37911 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 13:21:24 +00:00
Andrew Ozz a985e346b1 TinyMCE: update to 4.3.13, changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt.
Fixes #37225.

git-svn-id: https://develop.svn.wordpress.org/trunk@37910 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 13:20:17 +00:00
Dominik Schilling (ocean90) 3d6c1e5ca2 Tests: After [37861] move tests for deprecated filters into `filters.php`.
See #10441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37909 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 13:13:53 +00:00
Dominik Schilling (ocean90) 970b7c43ab HTTP: Add unit tests for `wp_get_http_headers()` and `wp_remote_retrieve_headers()`.
Props borgesbruno, jipmoors.
Fixes #37090.

git-svn-id: https://develop.svn.wordpress.org/trunk@37907 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 12:46:59 +00:00
Rachel Baker 0e6a328782 REST API: Include a refreshed nonce in a `X-WP-Nonce` header when responding to an authenticated request.
Props adamsilverstein, welcher, markjaquith, aidvu.
Fixes #35662.




git-svn-id: https://develop.svn.wordpress.org/trunk@37905 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 03:00:54 +00:00
Rachel Baker 9e9adb0bfe REST API: Include auto-discovery Link header when serving API requests.
The Link header allows clients to verify if a site has made the REST API available, as well as indicating how to access it.

Props danielbachhuber.
Fixes #35580.




git-svn-id: https://develop.svn.wordpress.org/trunk@37903 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 01:56:32 +00:00
Jeremy Felt d277dd8ef1 Multisite: Introduce `WP_Network_Query`.
Provides a consistent way to query `$wpdb->site` for `WP_Network` objects based on domain, path, network ID, and (main) site ID.

Introduces and uses update_network_cache() and _prime_network_caches() to maintain a cached list of WP_Network objects for use in multiple queries.

Props flixos90.
See #32504.


git-svn-id: https://develop.svn.wordpress.org/trunk@37894 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-28 21:26:48 +00:00
Pascal Birchler 41b39bae16 Embeds: Add tests for the `WP_Embed` class.
Fixes #37214. See #34115.

git-svn-id: https://develop.svn.wordpress.org/trunk@37892 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-28 20:30:15 +00:00
Dominik Schilling (ocean90) bded47a1b6 Posts: Introduce `WP_Post_Type` and use it in `register_post_type()` and `unregister_post_type()`.
This changes the global `$wp_post_types` to an array of `WP_Post_Type` objects. `WP_Post_Type` includes methods to handle post type supports, rewrite rules, meta boxes, hooks, and taxonomies.
Each post type argument becomes a property of `WP_Post_Type`.

Props swissspidy, flixos90.
Fixes #36217.

git-svn-id: https://develop.svn.wordpress.org/trunk@37890 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-28 16:40:33 +00:00
Dominik Schilling (ocean90) f147b02783 Nav Menus: Use `WP_Query` for quick searches.
`the_post()` sets the `$in_the_loop` property to true which is unexpected in the admin if you're using filters which should only affect real loops.

Props ruud@joyo.
Fixes #27042.

git-svn-id: https://develop.svn.wordpress.org/trunk@37881 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-27 11:50:31 +00:00
Jeremy Felt 421888d9f4 Multisite: Change `WP_Network` `id` property to an integer.
For consistency and developer sanity.

Props flixos90.
Fixes #37050.


git-svn-id: https://develop.svn.wordpress.org/trunk@37870 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-26 13:22:36 +00:00
Peter Wilson 9ea1a7eb4f Posts: Fix back-compat for filters in get the modified time and date functions after [37738].
When no valid post exists for `get_the_modified_time` or `get_the_modified_date` calls, the result (`false`) is passed through the functions respective filters to maintain back-compat.

Introduces unit tests to ensure filters are applied and for the `get_the_modified_date` function.

Fixes #37059.


git-svn-id: https://develop.svn.wordpress.org/trunk@37866 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-26 11:29:13 +00:00
Boone Gorges c97f234e6f Allow action and filter hooks to be deprecated.
When a filter or action hook is deprecated, the corresponding `apply_filters()`
or `do_action()` calls should be switched out with `apply_filters_deprecated()`
or `do_action_deprecated()`. The latter functions will throw a deprecation
before invoking the original hook.

Props solarissmoke, SergeyBiryukov, DrewAPicture.
Fixes #10441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37861 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-25 19:56:19 +00:00
Boone Gorges 255aaa471e Fix orderby meta handling for `WP_Term_Query`.
In order to allow meta-related values of `orderby` to be handled properly,
the term query's `meta_query` object must run its `get_sql()` method before
`orderby` parsing.

Fixing this bug required addressing another bug in `WP_Meta_Query`, which
caused the table alias index not to be reset when calling `get_sql()`
multiple times on the same object.

Props littler.chicken.
Fixes #37151.

git-svn-id: https://develop.svn.wordpress.org/trunk@37860 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-25 16:22:55 +00:00
Pascal Birchler bdaede85d7 Posts: Add hooks for post sticky status changes.
This adds a new `post_stuck` action that fires when a post is made sticky and a `post_unstuck` action that fires when the sticky flag is removed again.

Props ojrask.
Fixes #35600.

git-svn-id: https://develop.svn.wordpress.org/trunk@37857 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-23 15:51:03 +00:00
Pascal Birchler d0555f9544 I18N: Enable unloading of text domains that have been loaded just in time.
[37415] removed the requirement to call `load_plugin_textdomain()` / `load_theme_textdomain()`. This caused `unload_textdomain()` to not work properly anymore in these cases.

With this change, unloaded text domains need to be explicitly loaded manually if you want to use them again.

Props swissspidy, ocean90.
Fixes #37113. See #34114.

git-svn-id: https://develop.svn.wordpress.org/trunk@37855 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-23 14:47:44 +00:00
Dominik Schilling (ocean90) a35a1a9c75 I18N: Add support for the Catalan flown dot in `remove_accents()`.
Props xavivars, SergeyBiryukov.
Fixes #37086.

git-svn-id: https://develop.svn.wordpress.org/trunk@37853 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-23 13:27:32 +00:00
Joe McGill 93cae978dd Media: Improve handling of extensionless filenames.
This ensures files retain a filename after sanitization.

Fixes 37111.

git-svn-id: https://develop.svn.wordpress.org/trunk@37756 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-21 13:43:59 +00:00
Pascal Birchler 3f050f87c3 Menus: Support nested array variables in POST data when saving menus.
[36510] allowed larger menus to be created in the Edit Menu screen by JSON-encoding the entire form into a single input field. However, it did not correctly handle nested arrays.

This introduces a new `_wp_expand_nav_menu_post_data()` helper function to handle this POST data which uses `array_replace_recursive()` internally. Since the latter is only available on PHP 5.3+, we add a compatibility function to ensure PHP 5.2 support.

Props ericlewis, neverything, swissspidy.
Fixes #36590 for trunk. See #14134.

git-svn-id: https://develop.svn.wordpress.org/trunk@37748 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-19 12:24:23 +00:00
Pascal Birchler d40f2eed2c Permalinks: Validate custom permalink structures.
Custom permalink structures require at least one valid structure tag, e.g. `%postname%`. If none is included, it would leave users with broken permalinks.
Let's make sure this won't happen by validating the permalink structure.

Adds unit tests.

Props rockwell15 for initial patch.
Fixes #35936.

git-svn-id: https://develop.svn.wordpress.org/trunk@37747 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-19 12:01:11 +00:00
Pascal Birchler db843d80ab L10n: Add unit tests for the `override_load_textdomain` filter.
Fixes #36398.

git-svn-id: https://develop.svn.wordpress.org/trunk@37746 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-18 10:09:26 +00:00
Peter Wilson 54f1c097a6 Posts: Add `$post` parameter to modified date and time functions.
Unifies the APIs for getting a post's modified date or time with getting a post's date or time.

Adds the `$post` parameter to the functions `get_the_modified_date` and `get_the_modified_time`.

Adds the `$post` parameter to the filters `get_the_modified_date` and `get_the_modified_time`.

Props Soean, lukecavanagh.
Fixes #37059.


git-svn-id: https://develop.svn.wordpress.org/trunk@37738 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-17 05:11:29 +00:00
Jeremy Felt 96d7eadb0c Multisite: Use `WP_Site_Query` to power `WP_MS_Sites_List_Table`.
`WP_Site_Query` provides for a cleaner `prepare_items()` method. It significantly improves the search experience in the sites list table:

* In a subdomain configuration, domain and path are searched for a provided terms.
* In a subdirectory configuration, path is searched for a provided term.
* The full domain is searched in a subdomain configuration rather than the portion not matching the network's domain.
* Terms are searched as `%term%` by default. Adding `*` in the middle of a term will search `%te%rm%`.

Props flixos90, Fab1en.
Fixes #33185, #24833, #21837, #36675.


git-svn-id: https://develop.svn.wordpress.org/trunk@37736 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-17 00:02:05 +00:00
Jeremy Felt 3d56328372 Multisite: Add search column support to `WP_Site_Query`.
`domain` and/or `path` can be used to specify which column(s) should be searched.

See #35791.


git-svn-id: https://develop.svn.wordpress.org/trunk@37735 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 23:08:30 +00:00
Pascal Birchler 931440e375 Embeds: Enforce a valid post ID when embedding a post from the current site.
Otherwise `wp_filter_pre_oembed_result()` could erroneously return the HTML of the current post instead of the intended result.

Props kraftbj.
See #36767.

git-svn-id: https://develop.svn.wordpress.org/trunk@37729 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 17:17:32 +00:00
Rachel Baker 7a4e523b5e REST API: Include X-Robots-Tag: noindex header in REST API responses to prevent endpoints from being indexed by search engines.
Prevent duplicate content issues with search engines and REST API endpoint response data.

Fixes #36390.
Props m_uysl for the initial patch.

git-svn-id: https://develop.svn.wordpress.org/trunk@37726 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 14:58:28 +00:00
Dominik Schilling (ocean90) 62bd8ecdd7 External Libraries: Update Backbone to version 1.3.3.
Changelog: https://cdn.rawgit.com/jashkenas/backbone/1.3.3/index.html#changelog
Diff: https://github.com/jashkenas/backbone/compare/1.2.3...1.3.3

Includes a unit test to ensure that the minified version doesn't include `sourceMappingURL`.

Props adamsilverstein.
Fixes #37099.

git-svn-id: https://develop.svn.wordpress.org/trunk@37723 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 09:26:06 +00:00
Boone Gorges e1cfb25e79 Query: `set_found_posts()` must run immediately after main query.
If not run immediately after, the `SELECT FOUND_ROWS()` query might refer to
a different query, such as the one used to populate the post cache for a split
query.

Introduced in [37692].

Fixes #36687.

git-svn-id: https://develop.svn.wordpress.org/trunk@37721 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 02:00:02 +00:00
Sergey Biryukov 983d5c94e8 Plugins: Normalize `WP_PLUGIN_DIR` in the test added in [37332], otherwise it fails on Windows.
See #29154.

git-svn-id: https://develop.svn.wordpress.org/trunk@37719 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 18:30:32 +00:00
Sergey Biryukov 25a27bff7d I18N: Revert the test added in [37716], as it causes errors when running the full suite.
See #36790.

git-svn-id: https://develop.svn.wordpress.org/trunk@37718 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 18:04:31 +00:00
Sergey Biryukov 6a5305e0b1 I18N: Add a unit test for `wp_maybe_decline_date()`.
See #36790.

git-svn-id: https://develop.svn.wordpress.org/trunk@37716 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 17:40:23 +00:00
Konstantin Obenland 4dd1d9bef9 Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.

Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.



git-svn-id: https://develop.svn.wordpress.org/trunk@37714 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 16:36:07 +00:00
Rachel Baker 1d115078eb Comments: Do not flag a comment as a duplicate if the `comment_author_email` is provided but not a match.
This reduces the strictness of the duplicate check a little, but does prevent false duplicates for emoji or +1 comments by authors with matching names. The current logic was introduced all the way back in [2894].

Fixes #37093.

git-svn-id: https://develop.svn.wordpress.org/trunk@37713 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 14:50:38 +00:00
Boone Gorges ade41fc2cf Query: After [37692], don't skip `set_found_posts()` when no posts are found.
The 'found_posts' filter must continue to run for plugins manipulating post
results via filter.

Props dd32.
Fixes #36687.

git-svn-id: https://develop.svn.wordpress.org/trunk@37712 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 12:32:25 +00:00
Pascal Birchler 3c34040bf2 Fix tests after [37708].
See #36767.

git-svn-id: https://develop.svn.wordpress.org/trunk@37710 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 11:54:28 +00:00
Pascal Birchler b2671c3880 Embeds: Improve performance when embedding a post from the current site.
When the post being embedded is from the same site, there's no reason to do an HTTP request for it. The data can be fetched directly using `get_oembed_response_data()`.

Fixes #36767 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@37708 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 11:22:52 +00:00
Sergey Biryukov 661f5a477e After [37702], correct the expected result in `test_size_format()`.
See #37037.

git-svn-id: https://develop.svn.wordpress.org/trunk@37705 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-14 22:12:35 +00:00
SergeyBiryukov aea4c0d86a In `size_format()` and `wp_convert_bytes_to_hr()`, replace `kB` with `KB` for consistency with other units.
Props Presskopp, dashaluna.
Fixes #37037.

git-svn-id: https://develop.svn.wordpress.org/trunk@37702 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-14 21:40:02 +00:00
Weston Ruter f26ccf6fac Customize: Update server-sent setting validation notifications as changes are entered.
Send back setting validities with full refreshes and selective refreshes so that invalid settings can have notifications displayed immediately before attempting save, and so that these notifications can be cleared as soon as the input is corrected.

* Splits out JS logic for listing controls into separate methods  `wp.customize.Setting.prototype.findControls()` and `wp.customize.findControlsForSettings()`.
* Adds a `setting` property to the `data` on notifications added to controls that are synced from their settings.
* Adds `selective-refresh-setting-validities` message sent from preview to pane.
* Changes `WP_Customize_Manager::validate_setting_values()` to return when settings are valid as well as invalid.
* Adds `WP_Customize_Manager::prepare_setting_validity_for_js()`.
* Add setting validities to data exported to JS in Customizer Preview and in selective refresh responses.

Fixes #36944.


git-svn-id: https://develop.svn.wordpress.org/trunk@37700 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-14 19:16:54 +00:00
Boone Gorges becae4f492 Query: Allow plugins to supply post results instead of having `WP_Query` fetch them from the database.
Returning a non-null value from the new `posts_pre_query` filter will cause
`WP_Query` to skip its database query, so that posts data can be provided from
elsewhere. This is useful in cases where post data may be mirrored in a
separate location, such as an external search application.

Developers should note that the `WP_Query` properties generally used to
calculate pagination - specifically, `found_posts` and `max_num_pages`, which
are determined by default in `set_found_posts()` - must be provided explicitly
when using the `posts_pre_query` filter; since `WP_Query` will not be
contacting the database, it will have no access to `SELECT FOUND_ROWS()`.
The `WP_Query` instance is passed to `posts_pre_query` by reference, so that
these properties can be set manually if needed.

Props jpdavoutian, tlovett1.
Fixes #36687.

git-svn-id: https://develop.svn.wordpress.org/trunk@37692 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-14 01:59:25 +00:00
Dominik Schilling (ocean90) 979660717e Canonical: Introduce `wp_get_canonical_url()`.
`wp_get_canonical_url()` encapsulates the URL logic of `rel_canonical()` to provide a consistent way to retrieve the canonical URL for a post.
The new filter `get_canonical_url` allows to customize the canonical URL.

Props joostdevalk, jipmoors, DrewAPicture, ocean90.
Fixes #36168.

git-svn-id: https://develop.svn.wordpress.org/trunk@37685 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-11 13:30:23 +00:00
Boone Gorges b9d46425c0 Introduce `term_taxonomy_id` parameter for `WP_Term_Query`.
Allows the fetching of terms based on `term_taxonomy_id`, or an array of
`term_taxonomy_ids`.

Props spacedmonkey.
Fixes #37074.

git-svn-id: https://develop.svn.wordpress.org/trunk@37683 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-11 03:48:03 +00:00