Commit Graph

1689 Commits

Author SHA1 Message Date
Weston Ruter fd46fad1c8 Customize: Fix and extend broken ajax unit tests to account for partials being skipped from rendering.
Fixes regression introduced in [36643].

See #35914.


git-svn-id: https://develop.svn.wordpress.org/trunk@36650 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 21:45:51 +00:00
Dominik Schilling (ocean90) 3a836ea224 Styles: Clarify the allowed values for the `$media` parameter of `wp_register_style()`/`wp_enqueue_style()`.
Adds unit test.

Fixes #35921.

git-svn-id: https://develop.svn.wordpress.org/trunk@36649 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 20:40:43 +00:00
Boone Gorges 245e40f384 Query: Search should match `post_excerpt` in addition to title and content.
When ordering search results, exact matches in the post excerpt are weighted
above those in post content, but below those in the post title.

Props swissspidy, sebastian.pisula.
FIxes #35762.

git-svn-id: https://develop.svn.wordpress.org/trunk@36647 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 20:13:22 +00:00
Boone Gorges 193196a552 Make `$taxonomy` parameter optional in `get_edit_term_link()`.
Props nicdford, sc0ttkclark.
Fixes #35922.

git-svn-id: https://develop.svn.wordpress.org/trunk@36646 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 20:06:25 +00:00
Weston Ruter c9b47e9d92 Customize: Skip exporting partials to client and handling rendering requests if user can't modify associated settings.
Introduces `WP_Customize_Partial::check_capabilities()` for parity with `WP_Customize_Control::check_capabilities()`.
 
See #27355.
Fixes #35914.


git-svn-id: https://develop.svn.wordpress.org/trunk@36643 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 18:13:30 +00:00
Pascal Birchler 0e13a57288 Script Loader: Introduce `wp_add_inline_script()`.
This new function can be used to add inline JavaScript before and after enqueued scripts, just like `wp_add_inline_style()` works for CSS.

Props atimmer, abiralneupane, ocean90, swissspidy.
Fixes #14853.

git-svn-id: https://develop.svn.wordpress.org/trunk@36633 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 16:43:41 +00:00
Boone Gorges 0338c8b3a3 Query: Allow a seed value to be passed when using 'rand' `$orderby`.
`WP_Query` allows random ordering; `'orderby' => 'rand'` translates to
`ORDER BY RAND()`. This syntax results in random ordering that is not
consistent from request to request. MySQL supports the passing of a seed value
to random sorts, such as `ORDER BY RAND(3)`, which will return the same
random value each time it's called. `WP_Query` now supports this syntax, by
passing `RAND(3)` (or whatever integer seed value you'd like) as the value
of `'orderby'`.

Props hlashbrooke.
Fixes #35692.

git-svn-id: https://develop.svn.wordpress.org/trunk@36632 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 16:39:50 +00:00
Dominik Schilling (ocean90) 7b1c4151dd L10n: Add test for `wp_dropdown_languages()`.
Props realloc.
Fixes #35294.

git-svn-id: https://develop.svn.wordpress.org/trunk@36631 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 16:27:36 +00:00
Ella Iseulde Van Dorpe 7040b4d932 TinyMCE: inline text patterns
First run.

See #33300.


git-svn-id: https://develop.svn.wordpress.org/trunk@36627 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 08:32:34 +00:00
Boone Gorges 0809037f61 Query: `is_*( $int )` should not falsely match strings starting with "$int".
Another chapter in the Storied Annals of Weird `in_array()` Behavior:
`in_array( 4, array( "4-cool-dudes" ) );` resolves to `true`, such that
`is_page( 4 )` was returning true for posts with the name `'4-cool-dudes'`.

We work around this behavior by ensuring that values passed to the `is_`
methods are cast to strings before the `in_array()` checks. ID checks still
work as expected; see #24674.

Props mikejolley, swissspidy, boonebgorges.
Fixes #35902.

git-svn-id: https://develop.svn.wordpress.org/trunk@36625 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 02:20:28 +00:00
Weston Ruter d14b188c42 Customize: Prevent dropping backslashes from input on general settings and settings for nav menus and some widgets.
Ensures that intentional backslashes (e.g. "\o/") can be used in:

* Site title
* Site description
* Nav menu name
* Custom Menu widget title
* Tag Cloud widget title
* Text widget body if can't `unfiltered_html`

The latter three are also fixed on the widgets admin page.

Fixes #35898.


git-svn-id: https://develop.svn.wordpress.org/trunk@36622 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 01:01:43 +00:00
Dominik Schilling (ocean90) 12cf07c669 Authentication: Allow users to log in using their email address.
Introduces `wp_authenticate_email_password()` which is hooked into `authenticate` after `wp_authenticate_username_password()`.

Props Denis-de-Bernardy, ericlewis, vhomenko, MikeHansenMe, swissspidy, ocean90.
Fixes #9568.

git-svn-id: https://develop.svn.wordpress.org/trunk@36617 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-22 23:14:27 +00:00
Mike Schroder cde3d4c399 Media: Update unit tests after change to default image quality.
Updates unit tests to reflect new default quality setting of '82' after [36615].

See #33642.

git-svn-id: https://develop.svn.wordpress.org/trunk@36616 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-22 23:13:27 +00:00
Boone Gorges 408fb37f2b Allow `get_terms()` to fetch terms regardless of taxonomy.
`get_terms()` has historically required that a taxonomy be specified when
querying terms. This requirement is related to the fact that terms could
formerly be shared between taxonomies, making `$taxonomies` critical for
disambiguation. Since terms can no longer be shared as of 4.4, it'
s desirable to be able to query for terms regardless of what taxonomy they're in.

Because it's now optional to pass taxonomies, it's no longer necessary to have
`$taxonomies` as the first (and required) parameter for `get_terms()`. The new
function signature is `get_terms( $args )`, where 'taxonomy' can (optionally) be
passed as part of the `$args` array. This syntax is more consistent with
functions like `get_users()` and `get_posts()`.

We've maintained backward compatibility by always giving precedence to the old
argument format. If a second parameter is detected, or if it's detected that
the first parameter is a list of taxonomy names rather than an `$args` array,
`get_terms()` will parse the function arguments in the legacy fashion.

Props flixos90, swissspidy, DrewAPicture, boonebgorges.
Fixes #35495.

git-svn-id: https://develop.svn.wordpress.org/trunk@36614 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-22 22:16:37 +00:00
Weston Ruter 56598b5f90 Customize: Prevent PHP notice and JS error caused by widgets and nav menus components if user only has `customize` capability.
Short-circuits components from initializing their hooks needlessly if current user lacks required capability.

Fixes #35895.


git-svn-id: https://develop.svn.wordpress.org/trunk@36611 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-22 05:30:30 +00:00
Weston Ruter bd09cddfc1 Customize: Update unit test for `WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()` to account for slashing if user can't `unfiltered_html`.
Fixes unit tests which broke under multisite config after [36608].

Fixes #35869.


git-svn-id: https://develop.svn.wordpress.org/trunk@36610 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-22 05:09:34 +00:00
Weston Ruter d06329d035 Customize: Fix previewing and updating of nav menu items containing slashed/slashable characters.
Prevents slashes from being added when a user without `unfiltered_html` previews a nav menu item containing an apostrophe or some other slashable character, and prevents the loss of an intentional slash (e.g. "\o/") when saving a nav menu item, regardless of capability.

Fixes #35869.


git-svn-id: https://develop.svn.wordpress.org/trunk@36608 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-22 00:13:53 +00:00
Eric Andrew Lewis c592a7262e Posts: Non-trashed posts should take slug priority over trashed posts.
When determining a unique post slug, trashed posts are taken into account. Previously, new posts would add suffixes to their slugs (e.g. `about-2`) when a post in the trash had the desired slug (e.g. `about`). 

To avoid this behavior, when a post is trashed its slug (i.e. `post_name`) is now suffixed with `-%trashed%`. The post's pre-trash slug is stored as post meta, and if the post is restored from trash, its desired slug is reapplied. 

For existing trashed posts which don't have the `-%trashed%` suffix, the suffix is added when a post with its desired slug is created.

Props ocean90, boonebgorges, ryan, SergeyBiryukov, coffee2code, helen, williamsba1.
See #11863.


git-svn-id: https://develop.svn.wordpress.org/trunk@36607 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-21 21:44:14 +00:00
Dominik Schilling (ocean90) 6e493b1713 Script Loader: Fix missing script output when the groups of dependencies are different.
Aka: Don't lose the grandchild.

Props gitlost, ocean90.
Fixes #35873.

git-svn-id: https://develop.svn.wordpress.org/trunk@36604 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-20 22:10:01 +00:00
Dominik Schilling (ocean90) 5f9d1fa799 Tests: Test that jQuery can be moved into footer after [36550].
Props gitlost.
See #25247.

git-svn-id: https://develop.svn.wordpress.org/trunk@36596 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-20 16:16:35 +00:00
Boone Gorges c43fc5ac2b Tests: Add decorators to PHPMailer mock object.
The new `get_recipient()` and `get_sent()` methods greatly simplify the
syntax required when writing tests for `wp_mail()`.

Props welcher.
Fixes #34161.

git-svn-id: https://develop.svn.wordpress.org/trunk@36594 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-20 03:40:49 +00:00
Andrew Ozz 218c1240b8 TinyMCE: update to 4.3.4. Changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt.
Fixes #35876.

git-svn-id: https://develop.svn.wordpress.org/trunk@36589 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-19 19:18:59 +00:00
Weston Ruter 03360d143d Customize: Add selective refresh framework with implementation for widgets and re-implementation for nav menus.
See https://make.wordpress.org/core/2016/02/16/selective-refresh-in-the-customizer/.

Props westonruter, valendesigns, DrewAPicture, ocean90.
Fixes #27355.


git-svn-id: https://develop.svn.wordpress.org/trunk@36586 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-19 18:40:06 +00:00
Dominik Schilling (ocean90) 2d7150e40d Formatting: Avoid a PHP warning when `wptexturize()` is called with a trailing less-than symbol.
Props westonruter.
Fixes #35864.

git-svn-id: https://develop.svn.wordpress.org/trunk@36578 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-18 20:30:54 +00:00
Dominik Schilling (ocean90) 9f5eb3c604 Add missing test changes for [36573].
See #34755.

git-svn-id: https://develop.svn.wordpress.org/trunk@36574 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-18 17:43:56 +00:00
Boone Gorges 0e9ff07da5 Reintroduce term meta unit test accidentally removed in [36566].
git-svn-id: https://develop.svn.wordpress.org/trunk@36567 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 23:01:05 +00:00
Boone Gorges 28fad09b61 More performance improvements to metadata lazyloading.
Comment and term meta lazyloading for `WP_Query` loops, introduced in 4.4,
depended on filter callback methods belonging to `WP_Query` objects. This meant
storing `WP_Query` objects in the `$wp_filter` global (via `add_filter()`),
requiring that PHP retain the objects in memory, even when the local variables
would typically be expunged during normal garbage collection. In cases where a
large number of `WP_Query` objects were instantiated on a single pageload,
and/or where the contents of the `WP_Query` objects were quite large, serious
performance issues could result.

We skirt this problem by moving metadata lazyloading out of `WP_Query`. The
new `WP_Metadata_Lazyloader` class acts as a lazyload queue. Query instances
register items whose metadata should be lazyloaded - such as post terms, or
comments - and a `WP_Metadata_Lazyloader` method will intercept comment and
term meta requests to perform the cache priming. Since `WP_Metadata_Lazyloader`
instances are far smaller than `WP_Query` (containing only object IDs), and
clean up after themselves far better than the previous `WP_Query` methods (bp
only running their callbacks a single time for a given set of queued objects),
the resource use is decreased dramatically.

See [36525] for an earlier step in this direction.

Props lpawlik, stevegrunwell, boonebgorges.
Fixes #35816.

git-svn-id: https://develop.svn.wordpress.org/trunk@36566 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 22:57:33 +00:00
Andrew Ozz c7936b8785 Improve the performance of `wp_upload_dir()`:
- Cache the output in non-persistent cache.
- Cache the result from `wp_mkdir_p()` in persistent cache (when present).
- Introduce `wp_get_upload_dir()` for use when not uploading files. It is equivalent to `wp_upload_dir()` but does not check for the existence or create the upload directory.
- Change tests to use the non-cached `_wp_upload_dir()`. They change options on the fly (should never be used in production) to simulate different environments.
- Introduce `_upload_dir_no_subdir()` and `_upload_dir_https()` to facilitate testing. These use the proper `upload_dir` filter to simulate different environments.

Props kovshenin, azaozz.
See #34359.

git-svn-id: https://develop.svn.wordpress.org/trunk@36565 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 22:51:01 +00:00
Dominik Schilling (ocean90) bc95fd2884 Tests: Add test for `wp_get_installed_translations()`.
Introduces language files in /tests/phpunit/data/language. Each file includes the header and 5 translations.

Props realloc for initial patch.
Fixes #35284.

git-svn-id: https://develop.svn.wordpress.org/trunk@36563 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 22:01:11 +00:00
Dominik Schilling (ocean90) 548a18059c Tests: Add a test for testing `wp_enqueue_script()` with an alias handle in the footer.
Props kovshenin.
See #35643.

git-svn-id: https://develop.svn.wordpress.org/trunk@36559 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 19:52:42 +00:00
Dominik Schilling (ocean90) 653e0b0827 Tests: Add `Tests_dbDelta::assertTableHasPrimaryKey()`.
Also fix a typo in the name for the compound key.

Props charlestonsw.
Fixes #34877.

git-svn-id: https://develop.svn.wordpress.org/trunk@36552 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 18:54:27 +00:00
Dominik Schilling (ocean90) 59747aa6b9 Script/Style Dependencies: Make sure that inline styles for handles without a source are printed.
This prevents breaking plugins which are adding inline styles to the `wp-admin` handle after [36341].

Props dd32, ocean90.
Fixes #35229.

git-svn-id: https://develop.svn.wordpress.org/trunk@36550 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 17:10:53 +00:00
Dominik Schilling (ocean90) 149686b424 Tests: Indent `test_wp_register_script()` with tabs.
git-svn-id: https://develop.svn.wordpress.org/trunk@36549 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 16:07:01 +00:00
Dominik Schilling (ocean90) de9d091e76 Tests: Indent `test_wp_register_style()` with tabs.
git-svn-id: https://develop.svn.wordpress.org/trunk@36547 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 15:36:20 +00:00
Dominik Schilling (ocean90) 35579fa786 i18n: Prevent `is_textdomain_loaded()` from returning true even if there are no translations for the domain.
In `get_translations_for_domain()` don't fill the global `$l10n` with `NOOP_Translations` instances, return a `NOOP_Translations` instance instead.

Props nacin, jrf.
Fixes #21319.

git-svn-id: https://develop.svn.wordpress.org/trunk@36538 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-16 21:14:45 +00:00
Ryan McCue 10bfe70f06 REST API: Allow explicit HEAD callbacks.
HEAD callbacks can now be registered independently, with the GET
callback still used as a fallback.

Fixes #34841.


git-svn-id: https://develop.svn.wordpress.org/trunk@36535 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-16 05:50:21 +00:00
Ryan McCue d7e7c0b81b REST API: Add support for CURIEs.
CURIEs are Compact URIs, which provide a more usable way to use
custom relations in the API. The `wp` CURIE is registered by default
for `https://api.w.org/` URI relations.

Fixes #34729.
Props joehoyle.


git-svn-id: https://develop.svn.wordpress.org/trunk@36533 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-16 02:18:34 +00:00
Weston Ruter 6dd1dd61a1 Customize: Add a user-friendly way to preview site responsiveness for desktop, tablet, and mobile.
Introduces `WP_Customize_Manager::get_previewable_devices()` with a `customize_previewable_devices` filter to change the default device and which devices are available for previewing. This is a feature that was first pioneered on WordPress.com.

Props celloexpressions, folletto, valendesigns, westonruter, welcher, adamsilverstein, michaelarestad, Fab1en.
Fixes #31195.


git-svn-id: https://develop.svn.wordpress.org/trunk@36532 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-16 01:56:13 +00:00
Ryan McCue 5534474cef REST API: Fix tests from r36529.
See #35329.


git-svn-id: https://develop.svn.wordpress.org/trunk@36531 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-16 01:50:06 +00:00
Ryan McCue b32aaf603e REST API: Add helper function to get server instance.
This allows using rest_do_request() outside of the API itself easily.

Props danielbachhuber, swissspidy.


git-svn-id: https://develop.svn.wordpress.org/trunk@36529 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-16 01:11:31 +00:00
Boone Gorges 7f87a14808 Introduce `publicly_queryable` taxonomy argument.
Taxonomies registered as `publicly_queryable` can be queried as taxonomy
archives.

If not provided explicitly, the value of `publicly_queryable` is inherited
from `public`.

Props Chouby.
Fixes #34491.

git-svn-id: https://develop.svn.wordpress.org/trunk@36525 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-13 03:50:37 +00:00
Boone Gorges 3a0234982c Make sure fixtures have empty `post_content` in search test.
The generator sequence was causing false positives when the search terms
('1' and '0') happened to match the current sequence number (eg,
'Post content 190').

Introduced in [36278].

See #31025.

git-svn-id: https://develop.svn.wordpress.org/trunk@36520 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-12 21:06:41 +00:00
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
Andrew Ozz 1d82f671a3 TinyMCE: update to 4.3.3. Update the QUnit tests and revert back to testing the non-minified files in /src.
Fixes #35539.

git-svn-id: https://develop.svn.wordpress.org/trunk@36352 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-20 04:17:22 +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