Commit Graph

1613 Commits

Author SHA1 Message Date
Aaron Jorbin 0e6951b7aa Improve Automated Feed Tests
Multiple improvements to the RSS2 automated tests along with the addition of Atom tests.
1. General whitespace cleanup (since the rss2 file serves as the base of the atom file).
2. Adds an author and category to the tests.
3. Since the content of the posts is the same, we don't need to test all of the post content.
4. Adds many posts so that the post count can be checked

Props stevenkword
Fixes #35160.



git-svn-id: https://develop.svn.wordpress.org/trunk@36519 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-12 19:02:25 +00:00
Rachel Baker cff37450eb Comments: Unit test for `wp_get_comment_fields_max_lengths().
This adds tests for the comment form field lengths returned by `wp_get_comment_fields_max_lengths()`. Replaces unit test removed in r36514. 

See #10377.

git-svn-id: https://develop.svn.wordpress.org/trunk@36515 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-12 14:17:13 +00:00
Rachel Baker 8718eb2536 Comments: Change `wp_get_comment_column_max_length()` function to `wp_get_comment_fields_max_lengths()` for consolidation and better fallbacks.
Instead of returning a value for each of the related table column lengths, return an array of all of the column lengths used in the comment form.
Better fallback handling, where each field falls back to the expected max_length instead of an arbitrary number.

Props azaozz.

Fixes #10377.

git-svn-id: https://develop.svn.wordpress.org/trunk@36514 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-12 13:54:50 +00:00
Boone Gorges 0ae22e5f4c In `delete_metadata()`, only invalidate cache for affected objects.
The `$delete_all` flag in `delete_metadata()` triggers cache invalidation for
multiple objects. Previously, invalidation took place for all objects matching
the `$meta_key` parameter, regardless of whether `$meta_value` was also set.
This resulted in overly aggressive invalidation.

Props rahal.aboulfeth.
Fixes #35797.

git-svn-id: https://develop.svn.wordpress.org/trunk@36511 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-12 02:46:28 +00:00
Boone Gorges 71060260a1 Don't double-unslash meta key when `update_metadata()` falls back on `add_metadata()`.
Props jdgrimes.
Fixes #35795.

git-svn-id: https://develop.svn.wordpress.org/trunk@36509 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-11 17:34:59 +00:00
Boone Gorges ddc9f3dccb Allow comments to be queried by 'any' `post_type` or `post_status`.
Props kouratoras.
Fixes #35512.

git-svn-id: https://develop.svn.wordpress.org/trunk@36486 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-06 04:50:05 +00:00
Boone Gorges eb8e2fb6ed Allow `get_terms()` results to ordered by metadata.
The `$orderby` parameter of `get_terms()` now accepts the following values,
related to term meta:

* 'meta_value'
* 'meta_value_num'
* the value of the `$meta_key` parameter
* any key from the `$meta_query` array

This brings order-by-meta support for terms in line with post, comment, and
user queries.

As a byproduct of these improvements, `$meta_key` and `$meta_value` parameters
have been introduced to `get_terms()`. They interact with `$meta_query` in the
same way as in `WP_Query` and other query classes.

Props jadpm, eherman24.
Fixes #34996.

git-svn-id: https://develop.svn.wordpress.org/trunk@36485 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-06 04:41:26 +00:00
Boone Gorges 0673904ddf `WP_Query` taxonomy query vars should be set to first of multiple taxonomies.
This provides better parity with `get_queried_object()`, which will return the
first taxonomy/term matched by the current query.

[29891] introduced the abnormal behavior for the 'taxonomy' and 'term'
query vars.

Props Chouby.
Fixes #35619.

git-svn-id: https://develop.svn.wordpress.org/trunk@36484 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-06 03:57:33 +00:00
Boone Gorges 3ed7c823c9 When updating a user, invalidate its 'userslugs' cache.
`user_nicename` can be changed via `wp_update_user()`, so we invalidate just
to be safe.

Props thebrandonallen.
Fixes #35750.

git-svn-id: https://develop.svn.wordpress.org/trunk@36482 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-05 19:02:51 +00:00
Boone Gorges ef99ae21be Comments: Restore the ability to bypass post_id filter using 0 or '0'.
The changes introduced in [36381], while logical and clearly awesome, introduce
the potential for much breakage. Those who want to query for comments with a
null `comment_post_ID` should use `'post_in' => array( 0 )` instead.

Reverts [36381], [36387].
See #35090.


git-svn-id: https://develop.svn.wordpress.org/trunk@36480 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-05 18:49:46 +00:00
Boone Gorges 3ec4faf6e3 Comments: Add 'parent__in' and 'parent__not_in' to query var defaults.
Query var defaults are used to calculate a cache key. The fact that these
params were not listed among the defaults was causing cache keys to be
insufficiently specific.

Props danielbachhuber.
Fixes #35677.

git-svn-id: https://develop.svn.wordpress.org/trunk@36479 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-05 18:35:47 +00:00
Gary Pendergast cdf27d383d Tests: Use the new `wpdb::close()` method for closing the DB connection.
Props markoheijnen.

Fixes #34903.



git-svn-id: https://develop.svn.wordpress.org/trunk@36478 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-05 01:05:47 +00:00
Dominik Schilling (ocean90) ce68dd0ec5 Better validation of the URL used in HTTP redirects.
git-svn-id: https://develop.svn.wordpress.org/trunk@36444 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-02 15:10:09 +00:00
Gary Pendergast 2918cca22c WPDB: Add a `close()` method to `wpdb`, for when the connection needs to be manually closed.
In the event that it was closed prematurely, `wpdb::query()` will re-open the connection automatically.

Fixes #34903.



git-svn-id: https://develop.svn.wordpress.org/trunk@36433 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-02 00:12:28 +00:00
Boone Gorges 7c1854aeb0 Fix set up/tear down of post types in comment query test.
Introduced in [31015].

Props kouratoras.
Fixes #35633.

git-svn-id: https://develop.svn.wordpress.org/trunk@36415 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-27 23:12:07 +00:00
Weston Ruter 304ab7c0e4 Customizer: Export `nonce`, `theme`, and `url` app settings in preview as exported in pane.
* Introduce `WP_Customize_Manager::get_nonces()` to consolidate logic for retrieving nonces.
* Export nonces centrally in `wp.customize.settings.nonce` with each request and update nav menus preview to utilize.
* Send updated nonces to preview upon `nonce-refresh`.
* Request full preview refresh if Nav Menu selective refresh request fails (e.g. due to bad nonce).
* Update nav menus and widgets in Customizer to utilize `customize_refresh_nonces` for exporting nonces and keeping them up to date.

See #27355.
Fixes #35617.


git-svn-id: https://develop.svn.wordpress.org/trunk@36414 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-27 17:54:39 +00:00
Eric Andrew Lewis 8d562e0d04 Build/Test Tools: Move class `WP_UnitTest_Factory` into its own file.
In [36347] we moved all PHP factory classes into their own files except the main class. The main class is now in its own file, and `factory.php` is solely an include manifest for all factory classes.


git-svn-id: https://develop.svn.wordpress.org/trunk@36409 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-27 03:26:15 +00:00
Boone Gorges 746f545f9a Query: Respect 'suppress_filters' when filtering search-related SQL.
Props 5um17.
Fixes #35594.

git-svn-id: https://develop.svn.wordpress.org/trunk@36404 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 03:11:12 +00:00
Boone Gorges 14b6dbebd2 Introduce `$comment_status` and `$ping_status` params for `WP_Query`.
Props birgire.
Fixes #35601.

git-svn-id: https://develop.svn.wordpress.org/trunk@36403 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 02:55:15 +00:00
Boone Gorges af5a3b663f Allow `is_post_type_viewable()` to accept a post type name.
Previously, it accepted only a post type object.

Props spacedmonkey.
Fixes #35609.

git-svn-id: https://develop.svn.wordpress.org/trunk@36402 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 02:36:32 +00:00
Boone Gorges 81d3d79c1f Add tests for `is_post_type_viewable()`.
See #35609.

git-svn-id: https://develop.svn.wordpress.org/trunk@36401 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 02:26:21 +00:00
Boone Gorges dbac8968ed Allow comment query results to be limited to comments with comment_post_ID = 0.
Previously, this was not possible due to an overly broad `empty()` check.

Passing `null`, `false`, or `''` to 'post_id', or omitting 'post_id'
altogether, will continue to return comments regardless of `comment_post_ID`,
as before. Passing `0` or `'0'` will limit results to comments with no
associated post.

Props danielbachhuber.
Fixes #35090.

git-svn-id: https://develop.svn.wordpress.org/trunk@36381 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-22 20:19:49 +00:00
Jeremy Felt 77f8c5fc07 Themes: Enhance filtering options for allowed themes on a network.
* Move the legacy `allowed_themes` filter to `WP_Theme::get_allowed_on_network()`, where it will continue to filter themes allowed on the network.
* Add `network_allowed_themes` filter to `WP_Theme::get_allowed()` and pass `$blog_id` to provide context.
* Add `site_allowed_themes` filter to `WP_Theme::get_allowed_on_site()` and pass `$blog_id` to provide context.

Props pauldewouters, lamosty, michalzuber, dmsnell, johnnypea, rob.
Fixes #28436.


git-svn-id: https://develop.svn.wordpress.org/trunk@36366 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-20 18:28:33 +00:00
Jeremy Felt 18d9640a5a Themes: Add initial tests for the `allowed_themes` filter.
We'll be adjusting the placement of this filter and adding two other related filters, so we should make sure it continues to work as expected after the change.

See #28436.


git-svn-id: https://develop.svn.wordpress.org/trunk@36350 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 23:57:46 +00:00
Boone Gorges 5eee5cfc3c Don't double-escape the 'name' param in `get_terms()`.
[32353] changed the way the 'name' param in `get_terms()` is sanitized, by
running it through `sanitize_term_field( 'name' )` before performing the SQL
query. An unintentional side effect of this change was that the string is
double-escaped: once by `wp_filter_kses()`, and once by `esc_sql()`. The
double-escaping was causing 'name' queries to fail when the param contained
apostrophes or other escaped characters.

Fixes #35493.

git-svn-id: https://develop.svn.wordpress.org/trunk@36348 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 04:09:32 +00:00
Eric Andrew Lewis d36d6cc630 Build/Test Tools: Move PHP factory classes into their own files.
This makes the code easier to browse.

`factory.php` loads the new files, so this is backwards compatible in case `factory.php` is loaded directly for access to one of the classes.

See #35492.


git-svn-id: https://develop.svn.wordpress.org/trunk@36347 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 03:55:19 +00:00
Boone Gorges 7ae3adfb80 Share post fixture in `WP_Comment_Query` tests.
See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@36346 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 03:02:42 +00:00
Boone Gorges 1b8e03bd89 Ignore false values of 'search' in `WP_Comment_Query`.
Props danielbachhuber.
Fixes #35513.

git-svn-id: https://develop.svn.wordpress.org/trunk@36345 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 02:54:28 +00:00
Ella Iseulde Van Dorpe 342d132b37 Fix unit tests after [36336]
git-svn-id: https://develop.svn.wordpress.org/trunk@36337 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-17 23:37:51 +00:00
Pascal Birchler 3541f7b90b Posts: Correctly pass `$post` to `post_password_required()` in `get_the_excerpt()`.
Corrects the relevant test.

Props sebastian.pisula for initial patch.
Fixes #35486.

git-svn-id: https://develop.svn.wordpress.org/trunk@36329 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-16 10:13:27 +00:00
Boone Gorges ac9e991dc8 Respect all post-related filters in `WP_Comment_Query`.
The refactor of `WP_Comment_Query`'s SQL generation in [34542] introduced a bug
that caused only the last post-related filter to be respected in comment
queries. In other words, if querying for comments using params
`post_status=draft&post_author=3`, only the last-processed of these params
would be respected. The current changeset fixes the logic so that these clauses
don't overwrite each other.

Props chriscct7.
Fixes #35478.

git-svn-id: https://develop.svn.wordpress.org/trunk@36326 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 20:09:36 +00:00
Rachel Baker 63e9eb7e5e Comments: Use TEXT column type in fallback for `wp_get_comment_column_max_length()`.
Fixes #10377.


git-svn-id: https://develop.svn.wordpress.org/trunk@36325 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 20:09:08 +00:00
Boone Gorges 4d17d22a47 Populate term cache with proper clone of term objects.
[34999] modified the cache strategy for terms in the context of
`wp_get_object_terms()`. As part of these changes, the `object_id` property of
term objects had to be unset before being cached. To avoid modifying passed-by-
reference terms, `update_term_cache()` attempted to make a copy of the terms
passed to the function; however, it failed to use the `clone` keyword, and thus
only created a reference instead of a copy.

Props berengerzyla.
Fixes #35462.

git-svn-id: https://develop.svn.wordpress.org/trunk@36323 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 19:34:16 +00:00
Pascal Birchler 13e7e78ddd Add tests missed and announced in [36319].
See #27246.

git-svn-id: https://develop.svn.wordpress.org/trunk@36320 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 14:49:54 +00:00
Pascal Birchler 63e442bbb8 Comments: Add a new `pre_wp_update_comment_count_now` filter.
This allows filtering a post's comment count before it is queried and updated in the database.

Props peterwilsoncc for initial patch.
Fixes #35060.

git-svn-id: https://develop.svn.wordpress.org/trunk@36318 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 13:41:35 +00:00
Pascal Birchler a111eafd41 Post Types: Introduce `unregister_post_type()`.
This new function can be used to completely unregister non built-in post types.

Fixes #14761.

git-svn-id: https://develop.svn.wordpress.org/trunk@36316 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 12:19:15 +00:00
Pascal Birchler c7ae3fb3ee Users: Deprecate the `get_currentuserinfo()` pluggable function.
It encourages an ugly pattern like `global $userdata; get_currentuserinfo();` in plugins/themes. `wp_get_current_user()` should be used instead, e.g. `$current_user = wp_get_current_user();`.

Props scribu for initial patch.
Fixes #19615.

git-svn-id: https://develop.svn.wordpress.org/trunk@36311 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 10:15:21 +00:00
Pascal Birchler 44db9bccf4 Taxonomy: Fix unit tests after [36308].
See #34988.

git-svn-id: https://develop.svn.wordpress.org/trunk@36309 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 09:12:18 +00:00
Pascal Birchler d80a3c7ccd Embeds: Allow embedding static front pages and pages having a child page with an `embed` slug.
This makes `embed` a special slug that can't be used for new pages/posts. When `https://example.com/foo/embed/` is an existing page, embeds fall back to `https://example.com/foo/?embed=true`.
Adds unit tests.

Fixes #34971.

git-svn-id: https://develop.svn.wordpress.org/trunk@36307 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 07:55:19 +00:00
John Blackbourn b8b68a6a9e I18N: Introduce tests for `WP_Locale`.
Props realloc, swissspidy
Fixes #34688


git-svn-id: https://develop.svn.wordpress.org/trunk@36292 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 23:49:52 +00:00
Boone Gorges 5a545bbe90 Use `assertEqualSets()` in `comment_author` test.
The previous assertion was too specific, resulting in race conditions.

See #35377.

git-svn-id: https://develop.svn.wordpress.org/trunk@36279 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 04:42:59 +00:00
Boone Gorges 0b564d48df Support searching for `'0'` in `WP_Query`.
Props swissspidy.
See #31025.

git-svn-id: https://develop.svn.wordpress.org/trunk@36278 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 04:36:54 +00:00
Boone Gorges bf2f6f8104 Use the post-filter WHERE clause when querying for comment descendants.
The descendant query in `WP_Comment_Query::fill_descendants()` uses the clauses
of the main `get_comment_ids()` query as a basis, discarding the `parent`,
`parent__in`, and `parent__not_in` clauses. As implemented in WP 4.4 [34546],
the WHERE clause was assembled in such a way that any modifications applied
using the `comments_clauses` filter were not inherited by `fill_descendants()`.
This resulted in descendant queries that did not always properly filter
results, and sometimes contained syntax errors.

The current changeset fixes the problem by using the post-filter WHERE clause
as the basis for the `fill_descendants()` query. This change requires a new
approach for eliminating the unneeded parent-related clauses: instead of
eliminating values in an associative array, we must use regular expressions.

Props boonebgorges, firebird75.
Fixes #35192.

git-svn-id: https://develop.svn.wordpress.org/trunk@36277 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 04:00:36 +00:00
Boone Gorges 1880b466c7 Always respect `$comments` array passed to `wp_list_comments()`.
[36157] fixed a bug whereby `wp_list_comments()` would not properly recognize
custom pagination arguments. See #35175. However, it inadvertently introduced
a bug that caused any `$comments` array explicitly passed to the function to be
ignored, when that array was accompanied by pagination arguments that differ
from those in `$wp_query`. We address this bug by moving the logic introduced
in [36157] inside a block that only fires when no `$comments` array has been
provided to the function.

Props ivankristianto.
Fixes #35356.

git-svn-id: https://develop.svn.wordpress.org/trunk@36276 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 03:26:31 +00:00
Boone Gorges f7d238dfe3 Ignore hierarchy in pagination calculation when comment threading is disabled.
In order to calculate comment pagination when newest comments are displayed
first, `comments_template()` must perform a separate query to determine the
total number of paginating comments available on a post. See [34729], #8071,
pagination calculation - can be defined as a top-level comment, or a comment
with `parent=0`. However, when comment threading is disabled, yet comments
exist in the database that have parents, all comments - even those with a
parent - are "paginating". (This typically happens when comments threading was
once enabled, but has since been turned off.) As such, the total-paginating-
comments query should only be limited to top-level comments when
'thread_comments' is disabled.

Props jmdodd.
Fixes #35419.

git-svn-id: https://develop.svn.wordpress.org/trunk@36275 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 03:12:34 +00:00
Rachel Baker 0e85f45cb4 Comments: Restrict the maximum characters for input fields within the comments template.
Added hardcoded maxlength attributes on the author, author_email, author_url, and comment_field input markup. These can be modified via the comment_form_defaults filter. Added logic in wp_handle_comment_submission() to return a WP_Error when the comment_author, comment_author_url, or comment_content values exceed the max length of their columns. Introduces wp_get_comment_column_max_length() which returns the max column length for a given column name, and is filterable. Unit tests included for the error conditions in wp_handle_comment_submission()

Fixes #10377.

Props westonruter rachelbaker.


git-svn-id: https://develop.svn.wordpress.org/trunk@36272 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 01:24:46 +00:00
Pascal Birchler 3a358c33d3 Introduce `wp_get_raw_referer()` to retrieve unvalidated referer.
For things like redirects `wp_get_referer()` should be used instead.

Props voldemortensen for initial patch.
Fixes #27152.

git-svn-id: https://develop.svn.wordpress.org/trunk@36266 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-12 08:31:10 +00:00
Weston Ruter 2fa620e4c3 Customizer: Prevent erroneously directing user to login screen when closing.
Fixes issue where user gets stuck at login screen after trying to close the app if previously they had to first login to access the Customizer. Prevents `WP_Customize_Manager::get_return_url()` from using `wp-login.php` as a referer.

Props chandrapatel.
See #32637.
Fixes #35355.


git-svn-id: https://develop.svn.wordpress.org/trunk@36261 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-11 18:50:30 +00:00
Pascal Birchler 94992e25ae Rewrite: Ensure `WP_Rewrite::flush_rules()` does not delete the 'rewrite_rules' option.
Instead, the option gets updated to an empty string.
Adds unit tests.

Props SergeyBiryukov, jesin, voldemortensen.
Fixes #29107.

git-svn-id: https://develop.svn.wordpress.org/trunk@36254 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 19:01:13 +00:00
Pascal Birchler 519051b305 Permalinks: Ensure the page hierarchy is correct for sample permalinks.
Fixes #35368.

git-svn-id: https://develop.svn.wordpress.org/trunk@36253 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 18:27:06 +00:00
Boone Gorges 28818255c2 Don't reset index keys when trimming results of term queries.
`array_slice()` must be told to preserve keys when the query results exceed the
limit specified the 'number' parameter, so that `id=>parent` and other
id-indexed return value formats don't get mangled.

Props fantasyworld, wpdelighter.
Fixes #35382.

git-svn-id: https://develop.svn.wordpress.org/trunk@36252 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 04:05:26 +00:00
Boone Gorges e75a1f5ab3 Avoid invalid SQL when building ORDER BY clause using long search strings.
The introduction of negative search terms in 4.4 [34934] introduced the
possibility that the ORDER BY clause of a search query could be assembled in
such a way as to create invalid syntax. The current changeset fixes this by
ensuring that the ORDER BY clause corresponding to the search terms is
excluded when it would otherwise be empty.

Props salvoaranzulla.
Fixes #35361.

git-svn-id: https://develop.svn.wordpress.org/trunk@36251 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 03:25:15 +00:00
John Blackbourn 6681e9701c Taxonomy: More tests for `unregister_taxonomy()`.
See #35227


git-svn-id: https://develop.svn.wordpress.org/trunk@36247 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 23:34:27 +00:00
Pascal Birchler eafbcb3b6e Taxonomy: Introduce `unregister_taxonomy()`.
This new function can be used to completely unregister non built-in taxonomies.

Fixes #35227.

git-svn-id: https://develop.svn.wordpress.org/trunk@36243 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 14:57:22 +00:00
Pascal Birchler d92ead50c8 Ensure `wp_get_referer()` returns `false` when the referrer URL is the current URL.
Adds unit tests.

Fixes #19856.

git-svn-id: https://develop.svn.wordpress.org/trunk@36242 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 14:35:03 +00:00
Pascal Birchler 54134dd49b Media: Fix `wp_audio_shortcode` and `wp_video_shortcode` attributes handling.
Although documented, the `class` and `style` attributes were simply ignored.
Adds unit tests.

Fixes #35367.

git-svn-id: https://develop.svn.wordpress.org/trunk@36240 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 14:17:02 +00:00
Dion Hulse 0e73cc3da4 Tests: Add more paged canonical tests for page_on_front.
See #35344.


git-svn-id: https://develop.svn.wordpress.org/trunk@36238 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 08:08:47 +00:00
Dion Hulse 5f55910b5c Tests: Remove some debug that's slipped in at some point.
git-svn-id: https://develop.svn.wordpress.org/trunk@36236 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 06:11:58 +00:00
Boone Gorges 8dbc62d267 In `comments_template()`, don't run hierarchical queries if comment threading is disabled.
When hierarchical=true, `WP_Comment_Query` will always fetch comments according
to the comment hierarchy, even if 'thread_comments' is disabled for the site.
This can cause problems when comment threading is disabled after threaded
comments have been recorded on the site; comments will no longer be returned in
a strictly chronological order.

We address the issue by refraining from querying hierarchically when comment
threading is disabled.

Props jmdodd.
Fixes #35378.

git-svn-id: https://develop.svn.wordpress.org/trunk@36226 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-08 22:16:11 +00:00
Eric Andrew Lewis 5304745be0 Permalinks: Make `get_post_type_archive_link()` work for the 'post' post type.
Props jjj.
See #19902. 


git-svn-id: https://develop.svn.wordpress.org/trunk@36225 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-08 22:00:48 +00:00
Boone Gorges b5a4504f7e Introduce 'author_url' param to `WP_Comment_Query`.
Props swissspidy.
Fixes #35377.

git-svn-id: https://develop.svn.wordpress.org/trunk@36224 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-08 21:51:50 +00:00
Pascal Birchler 1f47f9c5f5 Tests: Fix unit tests after [36217].
See #35236.

git-svn-id: https://develop.svn.wordpress.org/trunk@36218 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-07 10:16:47 +00:00
Pascal Birchler 79f2e50ca5 Rewrite: Add a `remove_rewrite_tag()` helper function.
It can be used to properly remove registered rewrite tags. Adds unit tests.

Fixes #35236.

git-svn-id: https://develop.svn.wordpress.org/trunk@36217 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-07 09:38:06 +00:00
Boone Gorges e49c8b425c Allow comment agent and author IP to be set via `wp_update_comment()`.
Props adamsilverstein, welcher.
Fixes #35276.

git-svn-id: https://develop.svn.wordpress.org/trunk@36215 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-07 03:54:05 +00:00
Boone Gorges 3a9bc32949 Ensure 'description' is a string in `wp_insert_term()`.
Passing `'description' => null` when creating a term can cause MySQL notices,
as the description column in the terms table does not allow for null values.
We correct this by intepreting a `null` description as an empty string.

Props TimothyBlynJacobs.
Fixes #35321.

git-svn-id: https://develop.svn.wordpress.org/trunk@36214 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-07 03:31:48 +00:00
Dion Hulse 549c4fdd1d Unit Tests: Fix the unit test added in [36181] to include the index in the comparison.
See #35235


git-svn-id: https://develop.svn.wordpress.org/trunk@36183 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-06 08:09:51 +00:00
Pascal Birchler e055e5b80e Rewrite: Add a `remove_permastruct()` helper function.
It can be used to remove permastructs that were added using `add_permastruct()`.

Fixes #35235.

git-svn-id: https://develop.svn.wordpress.org/trunk@36181 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-06 07:39:29 +00:00
Pascal Birchler e50296de48 Query: Add a `WP::remove_query_var()` helper function.
This makes cleaning up public query vars easier.

Fixes #35234.

git-svn-id: https://develop.svn.wordpress.org/trunk@36177 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-05 20:56:10 +00:00
Konstantin Obenland 0d6514b28b Template: Always display the site title on the front page.
Limits using the page title to the blog page when the site has a static front page,
bringing it N’Sync with `wp_title()`.

Props peterwilsoncc.
Fixes #34962.



git-svn-id: https://develop.svn.wordpress.org/trunk@36168 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-04 17:15:31 +00:00
Andrew Nacin 5699c64a56 XML-RPC: Revert [34681] as it broke date handling.
props dossy, hnle, redsweater.
see #35053, #30429 (original ticket).


git-svn-id: https://develop.svn.wordpress.org/trunk@36163 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-03 19:48:07 +00:00
Boone Gorges 23b10789d4 Fix incorrect `@covers` annotation in `get_adjacent_post()` tests.
Introduced in [36077].

Props netweb.
Fixes #35211.

git-svn-id: https://develop.svn.wordpress.org/trunk@36159 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-03 02:43:18 +00:00
Boone Gorges 1b8c0d611a Ensure that non-default pagination values work in `wp_list_comments()`.
Prior to 4.4, it was possible to pass 'page' and 'per_page' values to
`wp_list_comments()` that do not match the corresponding global query vars.
This ability was lost in 4.4 with the refactor of how `comments_template()`
queries for comments; when the main comment query started fetching only the
comments that ought to appear on a page, instead of all of a post's comments,
it became impossible for the comment walker to select comments corresponding to
custom pagination parameters. See #8071.

We restore the previous behavior by (a) detecting when a 'page' or 'per_page'
parameter has been passed to `wp_list_comments()` that does not match the
corresponding query vars (so that the desired comments will not be found in
`$wp_query`), and if so, then (b) querying for all of the post's comments and
passing them to the comment walker for pagination, as was the case before 4.4.

Props boonebgorges, smerriman.
Fixes #35175.

git-svn-id: https://develop.svn.wordpress.org/trunk@36157 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-03 02:02:59 +00:00
Rachel Baker 21a4585cd1 Feeds: Comments on attachments display in the site-wide comments RSS feed.
Individual attachment pages already have their own RSS comment feed, and would be expected to be included in the site-wide comments RSS feed.

Props jbrinley. 
Fixes #15610



git-svn-id: https://develop.svn.wordpress.org/trunk@36138 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-31 17:15:23 +00:00
Sergey Biryukov c04ae32ff9 Widgets: Revert [34465], as it introduced a regression, making the `$index` argument of `dynamic_sidebar()` case-sensitive.
Fixes #34995 for trunk. See #23423.

git-svn-id: https://develop.svn.wordpress.org/trunk@36130 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-31 03:12:36 +00:00
Gary Pendergast a9dcce7060 Redirects: Prevent redirects if a queried object exists.
After [34659], it became possible to cause an incorrect redirect, by changing the slug of a post, then creating a new post with the old slug. The correct behaviour is to prevent redirecting to the old post.

Props dd32, pento.

Fixes #35031 for trunk.



git-svn-id: https://develop.svn.wordpress.org/trunk@36128 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-31 03:00:33 +00:00
Pascal Birchler aae9afe5aa Comments: Don't nofollow links within the site.
Fixes #11360.

git-svn-id: https://develop.svn.wordpress.org/trunk@36125 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-30 23:19:11 +00:00
Andrew Ozz 8686ab4a7a Responsive images: fix the check whether the attachment meta matches the image src to work with http/https and CDNs.
Props webaware, joemcgill, azaozz.
Fixes #35045 and #35102 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@36121 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-30 01:03:11 +00:00
Andrew Ozz f39a799718 Responsive images: add compatibility for versions < 2.7 when the full image path was stored in the metadata. Introduces `_wp_get_attachment_relative_path()` and uses it in `wp_get_attachment_url()`.
Props dd32, SergeyBiryukov.
Fixes #35106 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@36120 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-30 00:05:07 +00:00
Aaron Jorbin d65a4e6498 Ensure only approved comments trigger post author notifications
Posts that are trashed shouldn't trigger post author notifications.  Adds unit tests to enforce this.

Props scottbrownconsulting, peterwilsoncc, swissspidy
Fixes #35006



git-svn-id: https://develop.svn.wordpress.org/trunk@36119 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-29 17:53:23 +00:00
Dion Hulse 18a6a047bd Tests: After [36100] use an object style which is compatible with PHP5 `get_object_vars()`.
See #35058.


git-svn-id: https://develop.svn.wordpress.org/trunk@36117 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-29 05:43:05 +00:00
Gary Pendergast f46c0a637b Tests: When testing the `utf8mb4` charset, ensure that the current MySQL server has `utf8mb4` support.
See #35249.



git-svn-id: https://develop.svn.wordpress.org/trunk@36116 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-29 04:39:02 +00:00
Sergey Biryukov 26d7619306 Import: Add a missing space to `post_exists()`.
The lack of space resulted in SQL error when searching for posts by content.

Props yetAnotherDaniel, johnbillion.
Fixes #35246.

git-svn-id: https://develop.svn.wordpress.org/trunk@36113 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-28 19:06:05 +00:00
John Blackbourn a9b9aa65b9 Themes: Add `singular` to the list of body classes when viewing a single post object.
Adds tests

Fixes #35164
Props danielpataki, johnbillion


git-svn-id: https://develop.svn.wordpress.org/trunk@36112 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-28 17:20:07 +00:00
Andrew Ozz 9b9d310c74 Responsive images: when creating `srcset` do not exclude the image size which is in the `src` attribute even when it is larger than `max_srcset_image_width`.
Props joemcgill.
Fixes #35108 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@36110 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-28 02:28:53 +00:00
Boone Gorges ba1f056a26 Force non-public taxonomies to have a query_var of `false`.
[35333] implemented `public=false` for taxonomies. The implementation prevented
non-public taxonomies from having their archives accessed via query_var during
a normal request. But it didn't prevent non-public taxonomies from registering
their query vars in the `$wp_taxonomies` global. The latter implementation
details causes problems specifically when a taxonomy is registered with
`query_var=true`; for public taxonomies, `register_taxonomy()` translates this
into a query_var equivalent to the taxonomy name, but in the case of non-public
taxonomies, the query_var was set to the boolean itself. The boolean then
causes problems when using non-strict comparison to filter taxonomy objects by
query_var, as when using `get_taxonomies()`.

This changeset addresses the issue by forcing the query_var property of
non-public taxonomies to `false`.

Fixes #35089.

git-svn-id: https://develop.svn.wordpress.org/trunk@36108 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-27 16:40:13 +00:00
Dion Hulse 0ce64dd122 Allow `map_deep()` to work with object properties containing a reference. Restores the previous behaviour of `stripslashes_deep()`.
Props jeff@pyebrook.com, swissspidy.
See #22300, [35252].
Fixes #35058.


git-svn-id: https://develop.svn.wordpress.org/trunk@36100 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-26 05:21:14 +00:00
Dion Hulse 42aeb0af8b Tests: Use the correct URL in some shortcode tests.
git-svn-id: https://develop.svn.wordpress.org/trunk@36099 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-26 04:50:23 +00:00
Dion Hulse a1cd9049d9 Shortcodes: `=` is a reserved character in shortcode names, mark it as such.
This allows for shortcodes such as `[shortcode=attribute]` to work, which while never intentionally supported were widely used in the pre-shortcode days.

Props aaroncampbell.
Fixes #34939 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@36097 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-26 04:45:26 +00:00
Dion Hulse 1d2904bf2a Pages: `get_page_uri()` should return the URI at which the resource being accessed is available at, this may include non-'publish' status posts.
Reverts [34001] and fixes the original issue in #15963 - avoiding a PHP Notice for when the post doesn't exist.

Props tharsheblows.
See #15963.
Fixes #35084.


git-svn-id: https://develop.svn.wordpress.org/trunk@36094 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-26 03:45:28 +00:00
Aaron Jorbin bc01ead655 Help Tab Order should be based on the Priority Argument
[34370] made the order that tabs are returned respect the order they are added, however it broke the respect of priority. By using a ksort instead of a sort, we can restore that default behavior. This adjusts the unit tests so that both order added and priority are tested.

Props meitar,  swissspidy, jorbin
Fixes #35215. See #33941.


git-svn-id: https://develop.svn.wordpress.org/trunk@36089 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-25 22:43:41 +00:00
Konstantin Obenland 1d68393907 Taxonomy: Pass object ids to delete_* actions.
Allows for more targeted updates to affected posts in callbacks.
Disambiguates `$objects` variable and amends unit tests.

Fixes #35213.


git-svn-id: https://develop.svn.wordpress.org/trunk@36080 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-23 23:43:03 +00:00
Boone Gorges fff6412f91 Move excluded_terms filter in `get_adjacent_post()`.
The filter was added in 4.4 [34528] #9571, but in a place where it could not
affect the adjacent post query.

Fixes #35211.

git-svn-id: https://develop.svn.wordpress.org/trunk@36078 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-23 19:56:32 +00:00
Boone Gorges 7d03711fc8 Move `get_adjacent_post()` tests to their own file.
See #35211.


git-svn-id: https://develop.svn.wordpress.org/trunk@36077 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-23 19:38:29 +00:00
Gary Pendergast 0b9d32a614 Embeds: Don't show embed discovery link on a static front page.
There's currently no iframe content being generated for a static front page. Giving out a link to that isn't an ideal user experience.

Props peterwilsoncc.

Fixes #35194 for trunk.



git-svn-id: https://develop.svn.wordpress.org/trunk@36059 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-22 10:49:20 +00:00
Boone Gorges 1bf73525e8 Order terms by 'name' when populating object term cache.
[34217] removed the `ORDER BY` clause from `update_object_term_cache()`, for
improved performance. But this proved to cause problems in cases where users
were expecting the results of `get_the_terms()` to be ordered by 'name'. Let's
revert the change for the time being, and look into more disciplined ordering
in a future release.

Props afercia.
See #28922. Fixes #35180.

git-svn-id: https://develop.svn.wordpress.org/trunk@36056 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-22 01:50:08 +00:00
Gary Pendergast d303221d08 Tests: Use the `default_storage_engine` MySQL option on newer MySQL versions.
In MySQL 5.5.3, `storage_engine` was deprecated in favour of `default_storage_engine`, and subsequently removed in MySQL 5.7. To avoid errors when running tests on MySQL 5.7, we need to switch between the options based on MySQL version.

Props skithund, jeremyfelt.

Fixes #34692.



git-svn-id: https://develop.svn.wordpress.org/trunk@36055 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 22:26:52 +00:00
John Blackbourn ec143694f7 Tests: Prevent role capability pollution in `Tests_Post_GetPostsByAuthorSql::test_user_has_access_only_to_private_posts_for_certain_post_types()`.
git-svn-id: https://develop.svn.wordpress.org/trunk@36050 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 07:15:33 +00:00
John Blackbourn b637e77c5a Tests: Fix all the things.
See #30017, #32394


git-svn-id: https://develop.svn.wordpress.org/trunk@36049 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 07:09:43 +00:00
johnbillion 8b5747a108 Query: Re-initialise any dynamically-added public query vars before running the public query vars test.
See #35115


git-svn-id: https://develop.svn.wordpress.org/trunk@36048 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 06:59:05 +00:00
John Blackbourn 8567d80ade Tests: Shave a second off the user capability tests by reusing its user fixtures.
See #30017, #32394


git-svn-id: https://develop.svn.wordpress.org/trunk@36047 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 06:56:57 +00:00
John Blackbourn da84910c8a Query: Introduce a unit test which will fail when new public query vars are introduced without also updating the test. This adds an extra layer of explicitness to introducing public query vars in order to avoid introducing unintentional clashes with URL query vars that are already in use.
See #35115 


git-svn-id: https://develop.svn.wordpress.org/trunk@36045 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 05:48:24 +00:00
Boone Gorges 817013978d Respect approval status when determining comment page count in `comments_template()`.
Since 4.4, when fetching the first page of comments and the 'newest' comments
are set to display first, `comments_template()` must perform arithmetic to
determine which comments to show. See #8071. This arithmetic requires the
total comment count for the current post, which is calculated with a separate
`WP_Comment_Query`. This secondary comment query did not properly account for
non-approved comment statuses; all unapproved comments should be part of the
comment count for admins, and individual users should have their own
unapproved comments included in the count. As a result, `comments_template()`
was, in some cases, being fooled into thinking that a post had fewer comments
available for pagination than it actually had, which resulted in empty pages
of comments.

We correct this problem by mirroring 'status' and 'include_unapproved' params
of the main comment query within the secondary query used to calculate
pagination.

Fixes #35068.

git-svn-id: https://develop.svn.wordpress.org/trunk@36040 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 03:06:41 +00:00
John Blackbourn 4024cb673a Comments: When a comment is submitted, ensure the `user_ID` element in the array that's passed to the `preprocess_comment` filter gets populated.
Fixes #34997


git-svn-id: https://develop.svn.wordpress.org/trunk@36038 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 02:46:44 +00:00
Gary Pendergast 59b8f0da7c Texturize: Transform `&` into `&#038;` in tag attributes.
[35709] was overly broad, and stopped transforming `&` characters within tag attributes. So that sites aren't generating invalid HTML, we need to restore this functionality, while continuing to not transform `&` within blocked tags.

Fixes #35008 for trunk.



git-svn-id: https://develop.svn.wordpress.org/trunk@36036 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 02:42:30 +00:00
Andrew Ozz 58b7d3e136 Responsive images: fix calculations when determining whether to include particular image file in `srcset`.
Props joemcgill.
Fixes #34955 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@36031 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-20 02:38:34 +00:00
Boone Gorges aa38888d60 Add `current-cat-ancestor` class to ancestor items in `wp_list_categories()`.
Pairs nicely with `current-cat-parent`.

Props jrchamp, swisssipdy, ardathksheyna, wonderboymusic.
Fixes #10676.

git-svn-id: https://develop.svn.wordpress.org/trunk@36008 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-18 18:37:41 +00:00
Boone Gorges 6d9f50febd Ensure that `wp_list_categories()` supports comma-separated lists for 'exclude' and 'exclude_tree'.
[34696] introduced a regression whereby comma-separated values for 'exclude'
and 'exclude_tree' would be handled improperly when merging the two parameters,
resulting in category IDs being incorrectly dropped from the combined array.

Props gblsm, hnle.
Fixes #35156.

git-svn-id: https://develop.svn.wordpress.org/trunk@36005 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-18 18:11:44 +00:00
Boone Gorges fdeed90e77 Ensure `get_terms()` results are unique when using 'meta_query'.
The introduction of 'meta_query' to `get_terms()` in 4.4 made it possible for
`get_terms()` to erroneously return duplicate results. To address the issue,
we add the `DISTINCT` keyword to the SQL query when a 'meta_query' parameter
has been provided.

Props @jadpm.
Fixes #35137.

git-svn-id: https://develop.svn.wordpress.org/trunk@36003 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-18 17:43:46 +00:00
Boone Gorges ad8dc6395c Better focus in tag cloud tests.
We should avoid testing complete markup strings, unless we are specifically
testing for the format of the markup.

Fixes #35138.

git-svn-id: https://develop.svn.wordpress.org/trunk@35988 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-17 17:11:07 +00:00
Boone Gorges 5b2a8ed2a0 More focused test for post_type in tag cloud links.
We should not be testing the entire tag cloud markup, as it leads to collateral
damage wheneven `wp_generate_tag_cloud()` is touched. See [35984].

See #25566, #35138.

git-svn-id: https://develop.svn.wordpress.org/trunk@35987 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-17 16:55:23 +00:00
Boone Gorges 22b0cb2029 Introduce 'tag-link-position-x' class to tag cloud links.
The new class describes the cardinal position of a link in the cloud, allowing
more fine-grained CSS and JS targeting.

Props Mte90, chmac.
Fixes #5172.

git-svn-id: https://develop.svn.wordpress.org/trunk@35984 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-17 16:26:06 +00:00
Sergey Biryukov d727e3b516 KSES: Allow the `reversed` attribute for `<ol>`.
Props lancewillett.
Fixes #35079.

git-svn-id: https://develop.svn.wordpress.org/trunk@35960 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-16 09:53:18 +00:00
Sergey Biryukov 959f377c3e I18N: Add a unit test for `before_last_bar()`.
Props realloc.
Fixes #35073.

git-svn-id: https://develop.svn.wordpress.org/trunk@35959 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-16 08:03:38 +00:00
Dominik Schilling (ocean90) 019f7ec6b5 Revert [35949].
Passing an object to `wp_list_pluck()` throws also a fatal error, see https://3v4l.org/9YsaD.

See #35087.

git-svn-id: https://develop.svn.wordpress.org/trunk@35950 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-15 19:49:43 +00:00
Pascal Birchler 666d0736f4 Ensure `wp_list_pluck()` throws a warning when not being passed an array.
We should not paper over the code and hide warnings from developers by casting values to an array.

See #35087.

git-svn-id: https://develop.svn.wordpress.org/trunk@35949 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-15 18:28:55 +00:00
Boone Gorges 42fe7609c7 Omit `cpage` query var in comment link if comment pagination is disabled.
WP 4.4 changed the way comment pagination is calculated. See #8071. In the
context of `get_comment_link()`, these changes introduced a regression that
causes `cpage` (or its pretty-permalink correlate `comment-page-x`) to appear
in comment links when comment pagination is disabled. The current changeset
fixes the regression.

Fixes #34946.

git-svn-id: https://develop.svn.wordpress.org/trunk@35933 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-14 19:45:45 +00:00
Joe Hoyle a375d93001 REST API: Improve formatting of failed validation errors.
If a validation_callback returns a WP_Error it should give the same response format as if it returned `false`. This makes programmatically reading the validation errors better.

Props bradyvercher for initial patch.
Fixes #35028.


git-svn-id: https://develop.svn.wordpress.org/trunk@35890 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-12 18:22:02 +00:00
johnbillion 3348774d3a Ensure that all the capabilities that any users have are being tested. This ensures that if new capabilities are introduced in the future, tests will be required for them.
See #35024


git-svn-id: https://develop.svn.wordpress.org/trunk@35872 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-11 21:59:01 +00:00
John Blackbourn a7f713f45d Introduce tests for the `unfiltered_upload` capability, which no user should have (unless the `ALLOW_UNFILTERED_UPLOADS` constant is defined).
See #35024


git-svn-id: https://develop.svn.wordpress.org/trunk@35871 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-11 21:54:05 +00:00
John Blackbourn e76be26406 Add assertions for role names as capabilities in the capabilities tests. This ensures the role name is only available as a capability to the corresponding role.
See #35007


git-svn-id: https://develop.svn.wordpress.org/trunk@35863 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-11 11:06:28 +00:00
Boone Gorges 4c1c287413 Be sure to force-delete when cleaning up fixtures in `get_comment_link()` tests.
Introduced in [35857].

Mega-super-anti-props boonebgorges.

git-svn-id: https://develop.svn.wordpress.org/trunk@35858 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-11 02:46:37 +00:00
Boone Gorges 3626449004 Share fixtures in `get_comment_link()` tests.
See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@35857 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-11 02:26:43 +00:00
Rachel Baker d13adcc9bf Comments: Comments don’t need no Post ID when created, so they don’t be needing one to be edited.
In `wp_update_comment()` only check if the given `comment_post_ID` is valid if it isn’t `0`.  This allows comments that were created programmatically via `wp_insert_comment()` without the (optional) `comment_post_ID` parameter to be edited.

Props subharanjan for the initial patch.
Fixes #34954



git-svn-id: https://develop.svn.wordpress.org/trunk@35853 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-10 15:16:51 +00:00
Boone Gorges 52384c2e6b Improve handling for `WP_Error` objects in `get_the_terms()`.
`wp_get_object_terms()` can return a `WP_Error` object. As such, the
`get_the_terms()` cache wrapper should handle them properly. To wit:

* Don't try to map an error object to `get_term()`. Introduced in [35032].
* Don't cache an error object as taxonomy relationships. Introduced in at least [16487], maybe earlier.

Props stephenharris.
Fixes #34723.

git-svn-id: https://develop.svn.wordpress.org/trunk@35850 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-10 03:34:51 +00:00
John Blackbourn ad338fb3d0 Comments: Commit tests missed in [35848].
See #28617


git-svn-id: https://develop.svn.wordpress.org/trunk@35849 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-10 03:15:44 +00:00
John Blackbourn c2f597280b Formatting: Don't make links inside `<script>` and `<style>` tags clickable.
Fixes #30162
Props ninos-ego, adamsilverstein


git-svn-id: https://develop.svn.wordpress.org/trunk@35847 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-09 23:54:24 +00:00
Mike Schroder 5b025834f9 Media: Don't generate responsive image attributes if `src` does not match ID in `wp-image-` class.
We rely on the `wp-image-` class to quickly find an attachment ID to add responsive image attributes.
To avoid incorrect images being displayed, do not add these attributes if the `src` does not match the
meta from the attachment ID in the class.

Props azaozz, kovshenin, joemcgill.
Fixes: #34898.


git-svn-id: https://develop.svn.wordpress.org/trunk@35820 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-07 20:07:37 +00:00
Joe Hoyle 0a2a83056c Prevent unnecessary $wpdb->update() when hierarchical post doesn't have children.
Props danielbachhuber.
Fixes #34896.


git-svn-id: https://develop.svn.wordpress.org/trunk@35817 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-07 17:46:35 +00:00
Weston Ruter f57e09f0fc Customizer: Apply `customize_dynamic_setting_class` and `customize_dynamic_setting_args` filters in calls to `WP_Customize_Manager::add_setting( $id, $args )`.
Ensure that plugin filters apply as expected for any settings registered statically without passing in an explicit class instance to `WP_Customize_Manager::add_setting()`.

Fixes #34597.


git-svn-id: https://develop.svn.wordpress.org/trunk@35810 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-06 23:21:46 +00:00
Eric Andrew Lewis a84227aab7 Posts: Don't modify post_name if it wasn't supplied to `wp_insert_post()`.
Previously when updating a post using wp_insert_post(), post_name was 
regenerated based on post_title every time if post_name was not passed in 
explicitly. This irons out the expectation that properties not passed into the 
function should not be modified.

Props jason_the_adams. 
Fixes #34865.


git-svn-id: https://develop.svn.wordpress.org/trunk@35800 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-06 21:57:59 +00:00
Boone Gorges ded2547b57 Show user_login in Dashboard user dropdowns.
User dropdowns in wp-admin have traditionally shown the users' display names.
However, this causes ambiguity when users share display names. To correct this,
we now show the unique user_login in parentheses after the display name.

The new `display_name_with_login` value for the `show` parameter of
`wp_dropdown_users()` enables this functionality. The default value of `show`
has not been changed, for backward compatibility, but all instances of
`wp_dropdown_users()` in core wp-admin have been switched.

This changeset also reduces some duplicated logic when assembling a user list
when `include_selected` is true.

Props krogsgard, boonebgorges.
Fixes #31251.

git-svn-id: https://develop.svn.wordpress.org/trunk@35790 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-06 20:56:11 +00:00
Konstantin Kovshenin 1aa7dda524 Allow usage of angle brackets in a site title or tagline.
The whole string is escaped with `esc_html()` anyway, so we don't
need to `wp_kses_post()`. This is a better experience for users who
want to use angle brackets in their site title or description.
Does not allow any HTML, adds unit tests.

props BandonRandon, pauldewouters.
fixes #27942.


git-svn-id: https://develop.svn.wordpress.org/trunk@35788 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-06 20:28:26 +00:00
Weston Ruter 1689948965 Customizer: Return added instances for panels, sections, controls, and settings when calling `WP_Customize_Manager::add_*()` methods.
Add missing phpDoc.

Props fusillicode, jubstuff.
Fixes #34596.


git-svn-id: https://develop.svn.wordpress.org/trunk@35781 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-06 18:09:42 +00:00
Scott Taylor f89c25a43d REST API: Core typically sends nocache headers on all auth'ed responses, as in `wp`, `admin-ajax`, etc. Because the REST API infrastructure is hooked in pre-wp, we should be setting this ourselves.
Adds unit tests.

Props joehoyle.
Fixes #34832.


git-svn-id: https://develop.svn.wordpress.org/trunk@35773 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-04 23:35:54 +00:00
Boone Gorges a1f89f4e86 Use 'invalid_username' error code when tripping 'illegal_user_logins'.
This gives us better compatibility with existing errors thrown by
`sanitize_user()`, especially in Multisite, where user_login has more
restrictions on allowed characters.

Props markjaquith.
Fixes #27317.

git-svn-id: https://develop.svn.wordpress.org/trunk@35772 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-04 23:24:56 +00:00
Dominik Schilling (ocean90) ec01033a2d Unit Tests: Implement `addWarning()` method in SpeedTrapListener.
The method was introduced in PHPUnit 5.1.0, released today.

Fixes #34846.

git-svn-id: https://develop.svn.wordpress.org/trunk@35767 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-04 16:40:10 +00:00
Andrew Nacin 12b1cc4410 Embeds: Enforce, via unit tests, the no-ampersand rule for wp-embed.js.
fixes #34698.


git-svn-id: https://develop.svn.wordpress.org/trunk@35762 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-04 05:45:29 +00:00
Mark Jaquith 2ddab3adf8 Route HEAD API requests through the GET callback method
fixes #34837
props danielbachhuber

git-svn-id: https://develop.svn.wordpress.org/trunk@35758 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-03 16:34:00 +00:00
Scott Taylor aad857409b Customize Unit Tests: also `remove_action( 'after_setup_theme', 'twentysixteen_setup' )`. TwentyFifteen is already removed.
See #31550.


git-svn-id: https://develop.svn.wordpress.org/trunk@35754 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-01 20:55:22 +00:00
Scott Taylor 69900349ca Media: don't use `get_media_embedded_in_content()` in `wp_make_content_images_responsive()`.
Adds unit test.

Props azaozz.
Fixes #34807.


git-svn-id: https://develop.svn.wordpress.org/trunk@35753 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-01 20:49:13 +00:00
Scott Taylor c8b7126cbf Unit Tests: fix responsive image unit tests. Correct the logic in video shortcode unit test for width.
Props joemcgill, wonderboymusic.
Fixes #34790.


git-svn-id: https://develop.svn.wordpress.org/trunk@35751 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-01 20:44:54 +00:00
John Blackbourn da2acf666a When a post is scheduled for publication, treat it the same as a published post when calculating the capabilities required to edit or delete it.
Fixes #33694


git-svn-id: https://develop.svn.wordpress.org/trunk@35747 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-29 02:24:15 +00:00
John Blackbourn a8ea7d98b5 Ensure the correct error message is returned when a user attempts to comment on a post to which they do not have access.
Adds more tests.


git-svn-id: https://develop.svn.wordpress.org/trunk@35745 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-28 18:28:54 +00:00
Scott Taylor 663b7f28ff Upgrade: New themes are not automatically installed on upgrade. This can still be explicitly asked for by defining `CORE_UPGRADE_SKIP_NEW_BUNDLED` as `false`.
In `populate_options()`, if the theme specified by `WP_DEFAULT_THEME` doesn't exist, fall back to the latest core default theme. If we can't find a core default theme, `WP_DEFAULT_THEME` is the best we can do. 

Props nacin, jeremyfelt, dd32.
See #34306.


git-svn-id: https://develop.svn.wordpress.org/trunk@35738 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-25 21:44:02 +00:00
Scott Taylor dc167a20e5 Add a unit test for `wp_nav_menu()` with `container => ''`
See #32464.



git-svn-id: https://develop.svn.wordpress.org/trunk@35736 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-25 18:18:37 +00:00
Dominik Schilling (ocean90) d1ec5b6ac3 Passwords: Support the pre-4.3 behavior of `wp_new_user_notification()`.
Hello, it's me again. A pluggable function named `wp_new_user_notification()`. A few months ago, after [33023], I have lost my second parameter `$plaintext_pass`. But thanks to [33620] I got a new one.
Bad idea - It hasn't had the same behavior as my previous parameter.
To solve that the second parameter got deprecated and reintroduced as the third parameter in [34116]. I was happy again, for a short time.
You remember my lost friend `$plaintext_pass`? No? Well, if its value was empty no notification was sent to the user. This behavior was still lost. And that's what this change is about: Don't notify a user if a plugin uses `wp_new_user_notification( $user_id )`.

You're asking if I'm happy now? Dunno, but maybe you have learned something about pluggable functions, have you?

Props danielbachhuber.
Fixes #34377.

git-svn-id: https://develop.svn.wordpress.org/trunk@35735 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-24 23:06:03 +00:00
Dominik Schilling (ocean90) 50c47fa78c HTTP Tests: Use `login.wordpress.org/wp-login.php` in `test_get_response_cookies()`.
The old URL redirects to `login.wordpress.org` because it's the new canonical URL for all logins on wordpress.org.

Fixes #34782.

git-svn-id: https://develop.svn.wordpress.org/trunk@35734 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-24 21:59:23 +00:00
Sergey Biryukov 6f310a775d Users: Move the tests added in [35116] and [35618] to a more appropriate place and give them a better name.
See #28435, #29880.

git-svn-id: https://develop.svn.wordpress.org/trunk@35732 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-23 18:39:20 +00:00
Weston Ruter 89f49aad80 Customize: Ensure that a setting (especially a multidimensional one) can still be previewed when the post value to preview is set after `preview()` is invoked.
* Introduce `customize_post_value_set_{$setting_id}` and `customize_post_value_set` actions which are done when `WP_Customize_Manager::set_post_value()` is called.
* Clear the `preview_applied` flag for aggregated multidimensional settings when a post value is set. This ensures the new value is used instead of a previously-cached previewed value.
* Move `$is_preview` property from subclasses to `WP_Customize_Setting` parent class.
* Deferred preview: Ensure that when `preview()` short-circuits due to not being applicable that it will be called again later when the post value is set.
* Populate post value for updated-widget with the (unsanitized) JS-value in `WP_Customize_Widgets::call_widget_update()` so that value will be properly sanitized when accessed in `WP_Customize_Manager::post_value()`.

Includes unit tests with assertions to check the reported issues and validate the fixes.

Fixes defect introduced in [35007].
See #32103.
Fixes #34738.


git-svn-id: https://develop.svn.wordpress.org/trunk@35724 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-21 02:51:57 +00:00
Gary Pendergast 274bb41c04 Texturize: Only convert `&` to `&#038;` within text nodes.
Previously, `&` would be converted everywhere, which caused problems when it was converted within a `<script>`, for example.

`convert_chars()` is now removed from the `the_content` filter, as it was doing the same job as `wptexturize()`.

KSES correctly handles converting `&` within HTML attributes, so there's no need for `wptexturize()` and `convert_chars()` to do the same job.

Fixes #34698.



git-svn-id: https://develop.svn.wordpress.org/trunk@35709 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-19 23:31:00 +00:00