Commit Graph

1417 Commits

Author SHA1 Message Date
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 `&` 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