Using the same logic that we use to redirect posts when their slug changes, we can provide the same functionality for attachments. Attachment pages are posts, too.
Props swissspdy.
Fixes#34043.
git-svn-id: https://develop.svn.wordpress.org/trunk@34685 602fd350-edb4-49c9-b593-d223f7449a82
`the_author_posts_link()` has in-turn been converted into a wrapper, with most of its logic moved to the new function.
Adds tests for the new function.
Props chipbennett, zrothauser, wonderboymusic, DrewAPicture.
Fixes#30355.
git-svn-id: https://develop.svn.wordpress.org/trunk@34677 602fd350-edb4-49c9-b593-d223f7449a82
Square brackets must be encoded in the path, path parameters, query parameters, and fragment, but must not be encoded in anything up to the domain and port.
Adds a bunch of tests, including square brackets in query parameters, IPv6 URLs, and several other permutations.
See #16859
git-svn-id: https://develop.svn.wordpress.org/trunk@34674 602fd350-edb4-49c9-b593-d223f7449a82
Also fixes unit tests post-[34670]. The test methods have been slightly renamed because it is no longer a button. Hopefully this name will be more future-proof.
see #18306.
git-svn-id: https://develop.svn.wordpress.org/trunk@34671 602fd350-edb4-49c9-b593-d223f7449a82
The old comment pagination logic had a separate block for comment threads that
appeared on a single page. After the refactoring in [34561], all comment
pagination logic is unified.
This change ensures that 'comment_order' is respected in all scenarios.
Fixes#8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34669 602fd350-edb4-49c9-b593-d223f7449a82
Historically, `wp_old_slug_redirect()` has only ever redirected the old slug of posts, it hasn't included URL endpoints, or worked with comment feed URLs. By adding support for these, we ensure a greater range of URLs aren't killed when the slug changes.
Props swissspdy.
Fixes#33920.
git-svn-id: https://develop.svn.wordpress.org/trunk@34659 602fd350-edb4-49c9-b593-d223f7449a82
In [30298] the unit tests default confirguration was modified to exclude external-http tests. This change was never migrated to the multisite XML configuration. The external HTTP code doesn't follow different logic in multisite, so the logic to exclude the tests then ( The external-http tests are very slow, and Wp_Http functionality is fairly isolated ) holds true here as well.
See #33968
git-svn-id: https://develop.svn.wordpress.org/trunk@34656 602fd350-edb4-49c9-b593-d223f7449a82
Previously, we'd run the sanity checks if `is_mysql` was not set to `false`. This caused problems for DB drop-ins that didn't define `is_mysql` at all. Instead, we can just check if `is_mysql` is `empty()`.
Also fix some unit tests that accidently ran correctly because of the strict `false ===` comparison.
Fixes#33501.
git-svn-id: https://develop.svn.wordpress.org/trunk@34655 602fd350-edb4-49c9-b593-d223f7449a82
When `wp_page_menu()` is used as a fallback for `wp_nav_menu()`, the `before` and `after` arguments should be set and output as `<ul>` and `</ul>`, respectively.
See #11095. See [34653].
git-svn-id: https://develop.svn.wordpress.org/trunk@34654 602fd350-edb4-49c9-b593-d223f7449a82
This fixes issues with local HTTPS requests (eg. WP Cron) on OS X where cURL is using SecureTransport instead of OpenSSL.
Fixes#33978
git-svn-id: https://develop.svn.wordpress.org/trunk@34639 602fd350-edb4-49c9-b593-d223f7449a82
When passing a value of 'slug' to `wp_insert_term()` that contains non-ASCII
characters, WordPress converts accented characters to non-accented versions.
(See `sanitize_title()` and `remove_accents()`.) The same conversion happens
when fetching when fetching a term using a slug. In this way, it's possible to
create a term and fetch it using the same accented string, even though the slug
is actually stored with non-accented characters.
See #16282.
git-svn-id: https://develop.svn.wordpress.org/trunk@34628 602fd350-edb4-49c9-b593-d223f7449a82
This change was introduced in [34601]. 0 is a special snowflake. The code treats it as if it should fall back to the default, rather than respecting 0 as 0. Essentially, 0 means 100. WAT? This has been discussed previusly in https://core.trac.wordpress.org/ticket/19538#comment:10. This test should return True right now, but the behavior should be discussed and in the future 0 may mean 0.
See #34037
Props jorbin, boonebgorges
git-svn-id: https://develop.svn.wordpress.org/trunk@34606 602fd350-edb4-49c9-b593-d223f7449a82
This test was added [34577], but shouldn't have been, because the bug it
describes has not been fixed.
See #21292.
git-svn-id: https://develop.svn.wordpress.org/trunk@34604 602fd350-edb4-49c9-b593-d223f7449a82
Travis doesn't properly support SSL on older versions of PHP. Since we don't test for SSL support in all of the tests, this can cause these tests to fail. This changes a URL introduced in [34568]
See #33968
git-svn-id: https://develop.svn.wordpress.org/trunk@34600 602fd350-edb4-49c9-b593-d223f7449a82
[34583] modified comment queries so that all post fields are no longer loaded
by default. Instead, they are loaded only when requested on individual comment
objects. This changeset improves that flow:
* `WP_Comment` magic methods `__isset()` and `__get()` should only load the post when a post field is being requested.
* The new `update_comment_post_cache` argument for `WP_Comment_Query` allows developers to specify that, when comments are queried, all of the posts matching those comments should be loaded into cache with a single DB hit. This parameter defaults to false, since typical comment queries are linked to a single post.
Fixes#27571.
git-svn-id: https://develop.svn.wordpress.org/trunk@34599 602fd350-edb4-49c9-b593-d223f7449a82
Adds (rewrites) unit tests from 4 years ago that we never committed because....
Props wonderboymusic, koke, ericmann, nprasath002.
Fixes#17981.
git-svn-id: https://develop.svn.wordpress.org/trunk@34570 602fd350-edb4-49c9-b593-d223f7449a82
For threaded comments, we need comments to be retrieved within bounds, so logged-out users don't see unmoderated comments on the front end, etc.
Updates unit tests.
See #8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34569 602fd350-edb4-49c9-b593-d223f7449a82
The Menu Customizer feature includes a performance technique whereby the controls for nav menu items are only embedded into the DOM once the containing menu section is expanded. This commit implements the same DOM deferral for widgets but goes a step further than just embedding the controls once the widget area's Customizer section is expanded: it also defers the embedding of the widget control's form until the widget is expanded, at which point the `widget-added` event also fires to allow any additional widget initialization to be done. The deferred DOM embedding can speed up initial load time by 10x or more. This DOM deferral also yields a reduction in overall memory usage in the browser process.
Includes changes to `wp_widget_control()` to facilitate separating out the widget form from the surrounding accordion container; also includes unit tests for this previously-untested function. Also included are initial QUnit tests (finally) for widgets in the Customizer.
Fixes#33901.
git-svn-id: https://develop.svn.wordpress.org/trunk@34563 602fd350-edb4-49c9-b593-d223f7449a82
Previously, the 'page_comments' toggle allowed users to disable comment
pagination. This toggle was only superficial, however. Even with
'page_comments' turned on, `comments_template()` loaded all of a post's
comments into memory, and passed them to `wp_list_comments()` and
`Walker_Comment`, the latter of which produced markup for only the
current page of comments. In other words, it was possible to enable
'page_comments', thereby showing only a subset of a post's comments on a given
page, but all comments continued to be loaded in the background. This technique
scaled poorly. Posts with hundreds or thousands of comments would load slowly,
or not at all, even when the 'comments_per_page' setting was set to a
reasonable number.
Recent changesets have addressed this problem through more efficient tree-
walking, better descendant caching, and more selective queries for top-level
post comments. The current changeset completes the project by addressing the
root issue: that loading a post causes all of its comments to be loaded too.
Here's the breakdown:
* Comment pagination is now forced. Setting 'page_comments' to false leads to evil things when you have many comments. If you want to avoid pagination, set 'comments_per_page' to something high.
* The 'page_comments' setting has been expunged from options-discussion.php, and from places in the codebase where it was referenced. For plugins relying on 'page_comments', we now force the value to `true` with a `pre_option` filter.
* `comments_template()` now queries for an appropriately small number of comments. Usually, this means the `comments_per_page` value.
* To preserve the current (odd) behavior for comment pagination links, some unholy hacks have been inserted into `comments_template()`. The ugliness is insulated in this function for backward compatibility and to minimize collateral damage. A side-effect is that, for certain settings of 'default_comments_page', up to 2x the value of `comments_per_page` might be fetched at a time.
* In support of these changes, a `$format` parameter has been added to `WP_Comment::get_children()`. This param allows you to request a flattened array of comment children, suitable for feeding into `Walker_Comment`.
* `WP_Query` loops are now informed about total available comment counts and comment pages by the `WP_Comment_Query` (`found_comments`, `max_num_pages`), instead of by `Walker_Comment`.
Aside from radical performance improvements in the case of a post with many
comments, this changeset fixes a bug that caused the first page of comments to
be partial (`found_comments` % `comments_per_page`), rather than the last, as
you'd expect.
Props boonebgorges, wonderboymusic.
Fixes#8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34561 602fd350-edb4-49c9-b593-d223f7449a82
* Don't allow comments to be created for posts that have `comment_status` set to `'closed'`
* Set some magic props on `WP_User` to vars before passing them to `wp_xmlrpc_server::escape()`
Props wonderboymusic, jesin.
Fixes#27471.
git-svn-id: https://develop.svn.wordpress.org/trunk@34559 602fd350-edb4-49c9-b593-d223f7449a82
Comments can be threaded. Now your query can be threaded too! Bonus: it's
not totally insane.
* The new `$hierarchical` parameter for `WP_Comment_Query` accepts three values:
* `false` - Default value, and equivalent to current behavior. No descendants are fetched for matched comments.
* `'flat'` - `WP_Comment_Query` will fetch the descendant tree for each comment matched by the query paramaters, and append them to the flat array of comments returned. Use this when you have a separate routine for constructing the tree - for example, when passing a list of comments to a `Walker` object.
* `'threaded'` - `WP_Comment_Query` will fetch the descendant tree for each comment, and return it in a tree structure located in the `children` property of the `WP_Comment` objects.
* `WP_Comment` now has a few utility methods for fetching the descendant tree (`get_children()`), fetching a single direct descendant comment (`get_child()`), and adding anothing `WP_Comment` object as a direct descendant (`add_child()`). Note that `add_child()` only modifies the comment object - it does not touch the database.
Props boonebgorges, wonderboymusic.
See #8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34546 602fd350-edb4-49c9-b593-d223f7449a82
`WP_Comment_Query` will now report the total number of comments matching the
query params (`comments_found`), as well as the total number of pages required
to display these comments (`max_num_pages`). Because `SQL_CALC_FOUND_ROWS`
queries can introduce a lot of overhead in some cases, we disable the feature
by default. Pass `no_found_rows=false` to `WP_Comment_Query` to enable the
count. (We use the negative parameter name 'no_found_rows' for parity with
`WP_Query`.)
Props wonderboymusic, boonebgorges.
See #8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34544 602fd350-edb4-49c9-b593-d223f7449a82