Commit Graph

367 Commits

Author SHA1 Message Date
Aaron Jorbin 1972aa2a2a Add grunt prerelease task
An unintended consequence of improving the precommit task is that when it's time to run a release, more tasks need to get run to verify things. This adds a prerelease task to help fix that situation. grunt prerelease should include tasks that verify the code base is ready to be released to the wild and find all the tears on the mausoleum floor and help Blood stain the Colosseum doors.

See #35557

Built from https://develop.svn.wordpress.org/trunk@36930


git-svn-id: http://core.svn.wordpress.org/trunk@36898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-10 05:37:27 +00:00
Sergey Biryukov 5a7a3bb924 I18N: Move the `aria-label` text in `comment_form()` to a separate string for easier translation.
Add translator comments.

Props ramiy.
Fixes #36014.
Built from https://develop.svn.wordpress.org/trunk@36794


git-svn-id: http://core.svn.wordpress.org/trunk@36761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-01 02:14:25 +00:00
Boone Gorges 571e14f897 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.
Built from https://develop.svn.wordpress.org/trunk@36566


git-svn-id: http://core.svn.wordpress.org/trunk@36533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-17 22:58:26 +00:00
Drew Jaynes e41a0998e6 Docs: Add an internal note to the DocBlock for `comment_form_title()` explaining restoration of the `$comment` global.
See [36512]. See #35624.

Built from https://develop.svn.wordpress.org/trunk@36527


git-svn-id: http://core.svn.wordpress.org/trunk@36494 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-13 19:15:28 +00:00
Boone Gorges 1877b8c726 Set the `$comment` global in `comment_form_title()`.
In [33963], `comment_form_title()` was refactored so that it no longer made
reference to the `$comment` global. This broke some functionality within the
comment form, as certain template would no longer be able to access the
"current" comment.

Props d4z_c0nf, WisdmLabs, boonebgorges.
Fixes #35624.
Built from https://develop.svn.wordpress.org/trunk@36512


git-svn-id: http://core.svn.wordpress.org/trunk@36479 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-12 04:10:25 +00:00
Drew Jaynes b45a6228d0 Docs: Add a changelog entry for the introduction of maxlength character limits for the 'author', 'email', and 'url' fields in `comment_form()`.
Introduced in [36272].

See #10377. See #32246.

Built from https://develop.svn.wordpress.org/trunk@36499


git-svn-id: http://core.svn.wordpress.org/trunk@36466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-07 08:05:27 +00:00
Rachel Baker 2573fa7ab8 Comments: Add back `$req` variable in `comments_template()`.
The variables in `comments_template()` should never be assumed to be unused. This function includes the `comments.php` template file from the active theme or falls back to `theme-compat/comments.php`. This is why including a file within a function only brings pain and sorrow.

Reverts r36322.

See #35473.
Built from https://develop.svn.wordpress.org/trunk@36425


git-svn-id: http://core.svn.wordpress.org/trunk@36392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-30 22:13:26 +00:00
Eric Lewis 22467e840f Networks and sites: Replace "blog" usage with "site" in docs.
Multisite functions use the term "blog" to refer to what we now call a "site," e.g. `get_current_blog_id()`. These functions are here to stay because of our commitment to backwards compatibility. What we can do is set the documentation straight.

See #35417.

Built from https://develop.svn.wordpress.org/trunk@36416


git-svn-id: http://core.svn.wordpress.org/trunk@36383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-28 03:35:27 +00:00
Rachel Baker f956379447 Comments: Remove unused `$default_comments_page` variable in `get_comment_link()`.
Left in r34735, fetches the `default_comments_page` option twice since this variable is unused. 

See #34073 and #35511.

Props Latz.
Built from https://develop.svn.wordpress.org/trunk@36343


git-svn-id: http://core.svn.wordpress.org/trunk@36310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-18 16:35:28 +00:00
Boone Gorges d2dabdecf6 Respect custom pagination params when using `wp_list_comments()` in a query loop.
[36157] fixed a problem, introduced in 4.4, that caused custom pagination
parameters passed to `wp_list_comments()`. However, the fix introduced in that
changeset was limited to the `is_singular()` context, so that the bug remained
when `wp_list_comments()` is used within a non-singular `WP_Query` loop. We
fix this by removing the `is_singular()` check and using the more general
`get_the_ID()` to identify the correct post_id to use for the secondary
comment query.

Fixes #35402.
Built from https://develop.svn.wordpress.org/trunk@36324


git-svn-id: http://core.svn.wordpress.org/trunk@36291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-15 19:48:25 +00:00
Pascal Birchler e85f75f23f Comments: Remove unneeded `$req` variable in `comments_template()`.
Props Latz.
Fixes #35473.
Built from https://develop.svn.wordpress.org/trunk@36322


git-svn-id: http://core.svn.wordpress.org/trunk@36289 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-15 19:33:27 +00:00
Boone Gorges 4ac35f5713 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.
Built from https://develop.svn.wordpress.org/trunk@36276


git-svn-id: http://core.svn.wordpress.org/trunk@36243 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-13 03:27:27 +00:00
Boone Gorges 294a164b15 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.
Built from https://develop.svn.wordpress.org/trunk@36275


git-svn-id: http://core.svn.wordpress.org/trunk@36242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-13 03:13:25 +00:00
Rachel Baker 87e7b4455d 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.

Built from https://develop.svn.wordpress.org/trunk@36272


git-svn-id: http://core.svn.wordpress.org/trunk@36239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-13 01:25:26 +00:00
Boone Gorges 2c96c289cf Add missing param to 'comments_template_query_args'.
As introduced in [36235].

Props birgire.
See #34442.
Built from https://develop.svn.wordpress.org/trunk@36256


git-svn-id: http://core.svn.wordpress.org/trunk@36223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-11 02:28:27 +00:00
Boone Gorges 72265e4a98 Introduce `comments_template_query_args` filter.
This new filter gives developers a way to target the arguments used for comment
queries specifically when populating the main comment template.

Props birgire.
Fixes #34442.
Built from https://develop.svn.wordpress.org/trunk@36235


git-svn-id: http://core.svn.wordpress.org/trunk@36202 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-09 04:44:26 +00:00
Boone Gorges 13629bf5d0 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.
Built from https://develop.svn.wordpress.org/trunk@36226


git-svn-id: http://core.svn.wordpress.org/trunk@36193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-08 22:17:26 +00:00
Boone Gorges 31ef230595 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.
Built from https://develop.svn.wordpress.org/trunk@36157


git-svn-id: http://core.svn.wordpress.org/trunk@36123 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-03 02:03:28 +00:00
John Blackbourn 0003a004db Docs: Miscellaneous docblock code quality tweaks.
See #32246

Built from https://develop.svn.wordpress.org/trunk@36074


git-svn-id: http://core.svn.wordpress.org/trunk@36039 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-23 07:53:26 +00:00
Boone Gorges 26caa329f2 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.
Built from https://develop.svn.wordpress.org/trunk@36040


git-svn-id: http://core.svn.wordpress.org/trunk@36005 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-21 03:07:32 +00:00
Boone Gorges 3bc0e35684 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.
Built from https://develop.svn.wordpress.org/trunk@35933


git-svn-id: http://core.svn.wordpress.org/trunk@35897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-14 19:46:46 +00:00
Boone Gorges b6dbe1cea9 Don't use `array_merge()` when building comment children arrays.
`array_merge()` is much slower than building the combined array using a
`foreach` loop. The performance difference was causing a speed regression with
the `get_children()` functionality introduced in 4.4.

Props rogerhub.
Fixes #35025.
Built from https://develop.svn.wordpress.org/trunk@35931


git-svn-id: http://core.svn.wordpress.org/trunk@35895 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-14 19:37:43 +00:00
Drew Jaynes 1ae97a2078 Docs: Update the summary for the `comment_form_fields` hook docs to explicitly mention inclusion of the textarea element as a filterable element.
Previously [35723]

Props bappidgreat.
Fixes #34973.

Built from https://develop.svn.wordpress.org/trunk@35877


git-svn-id: http://core.svn.wordpress.org/trunk@35841 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-12 01:07:27 +00:00
John Blackbourn a027edc277 Comments: The year is 2003. Permalinks are a new thing and everyone's using Blogger. It's a time when opening a modal window in JavaScript to view a section of a website is not a completely weird thing, although many users get annoyed by it. b2 has recently become WordPress, and with it comes a bunch of functionality that will become stale over the next decade, remnants of simpler times.
Twelve years later, after no fewer than three themes have intentionally implemented popup comments in their functionality, before being abandoned for at least the last six years, we've reached a time where we can put this era behind us. A time when we can remove comment popup functionality from WordPress.

If this breaks the internet, I'll eat my hat.

Fixes #28617

Built from https://develop.svn.wordpress.org/trunk@35848


git-svn-id: http://core.svn.wordpress.org/trunk@35812 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-10 03:06:30 +00:00
John Blackbourn ec24d6e001 In a similar vein to [34133], escape the email address and IP address of comment authors to increase defence in depth.
Built from https://develop.svn.wordpress.org/trunk@35748


git-svn-id: http://core.svn.wordpress.org/trunk@35712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-29 02:43:24 +00:00
Sergey Biryukov fd9bd77fe5 Comments: In `comment_form()`, introduce the `comment_form_fields` filter for comment fields, including the textarea.
Correct the docs for `comment_notes_before` and `comment_notes_after` arguments as well as `comment_form_before_fields` and `comment_form_after_fields` actions to better describe the current behaviour.

Fixes #34731.
Built from https://develop.svn.wordpress.org/trunk@35723


git-svn-id: http://core.svn.wordpress.org/trunk@35687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-20 18:56:27 +00:00
Sergey Biryukov b5b3b0b913 Remove `<code>` tag from translatable string in `trackback_url()`.
Add translator commment.

Props ramiy.
Fixes #34573.
Built from https://develop.svn.wordpress.org/trunk@35546


git-svn-id: http://core.svn.wordpress.org/trunk@35510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-05 23:39:25 +00:00
Sergey Biryukov 3caaa702bf Comments: Use `_n()` in `get_comments_number_text()` when setting the default string for multiple comments.
Fixes #34593.
Built from https://develop.svn.wordpress.org/trunk@35536


git-svn-id: http://core.svn.wordpress.org/trunk@35500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-05 15:36:28 +00:00
Boone Gorges 3eab09a694 Don't force comment pagination.
[34561] instituted the policy of forcing pagination for comments. This strategy
was intended to avert problems when 'page_comments' is set to 0 - as it is by
default - and the number of comments on a given post rises into the hundreds or
thousands. By forcing pagination in all cases, we ensured that WordPress would
not time out by processing unwieldy numbers of comments on a given pageload.

The strategy proves problematic, however, because comment permalinks are
generated using the page of the comment. Forcing pagination for posts that
were not previously paginated would change the URL of all comments that do not
appear on the default comment page.

This changeset reintroduces the 'page_comments' setting and its corresponding
checkbox on Settings > Discussion. A number of tests, which were written after
[34561], are modified to work now that 'page_comments' will, once again, be
disabled by default.

See #8071.
Built from https://develop.svn.wordpress.org/trunk@35331


git-svn-id: http://core.svn.wordpress.org/trunk@35297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-21 16:26:42 +00:00
Scott Taylor 00ade45fd1 Docs: some `@global object` vernaculars should be converted to the actual object type.
See #33491.

Built from https://develop.svn.wordpress.org/trunk@35013


git-svn-id: http://core.svn.wordpress.org/trunk@34978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 15:45:25 +00:00
Drew Jaynes 5df204fab4 Template: Introduce a new `class_form` argument in `comment_form()`, allowing customization of the form class attribute.
The static 'comment-form' class was originally added to `comment_form()` in [24525]. This new argument should provide needed flexibility in styling the comment form further.

Props flixos90.
Fixes #34170. See #23851.

Built from https://develop.svn.wordpress.org/trunk@34871


git-svn-id: http://core.svn.wordpress.org/trunk@34836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 17:17:24 +00:00
Boone Gorges ca86a8a404 Remove dead code added to `get_comment_link()` in [34735].
See #34073.
Built from https://develop.svn.wordpress.org/trunk@34792


git-svn-id: http://core.svn.wordpress.org/trunk@34757 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-03 01:27:24 +00:00
Boone Gorges b23fdba5a2 Ensure that comment permalinks reflect pagination.
After [34561], `wp_list_comments()` no longer passed all of a post's comments
to `Walker_Comments`. As a result, calls to `get_comment_link()` occurring
inside the comment loop had insufficient context to determine the proper
'cpage' value to use when generating comment permalinks. This, in turn, caused
comment permalinks to behave erratically.

The current changeset addresses the problem as follows:

* `get_comment_link()` now accepts a 'cpage' parameter. When present, 'cpage' will be used to build the comment permalink - no automatic calculation will take place.
* When called within the main loop, `wp_list_comments()` calculates the proper 'cpage' value for comments in the loop, and passes it down to `get_comment_link()`.
* `cpage` and `comment-page-x` query vars are generally required in comment permalinks (see #34068), but an exception is made when 'default_comment_page=oldest': the bare post permalink will always be the same as `cpage=1`, so `cpage` is excluded in this case.

Props peterwilsoncc for assiduous spreadsheeting.
Fixes #34073.
Built from https://develop.svn.wordpress.org/trunk@34735


git-svn-id: http://core.svn.wordpress.org/trunk@34699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-01 05:13:25 +00:00
Boone Gorges dd9709d179 Simplify pagination logic in `comments_template()`.
[34561] "fixed" the problem of newest-first comments showing fewer than
'per_page' comments on the post permalink when the total number of comments
was not divisible by 'per_page'. See #29462. But this fix caused numerous
other problems. First, comment pages reported by `get_page_of_comment()`
(which expects comment pages to be filled oldest-first) were no longer correct.
Second, and more seriously, the new logic caused comments to be shifted
between pages, making their permalinks non-permanent.

The current changeset reverts the changed behavior. In order to preserve the
performance improvements introduced in [34561], an additional query must be
performed when 'default_comments_page=newest' and 'cpage=0' (ie, you're viewing
the post permalink). A nice side effect of this revert is that we no longer
need the hacks required to determine proper comment pagination, introduced in
[34561].

See #8071. See #34073.
Built from https://develop.svn.wordpress.org/trunk@34729


git-svn-id: http://core.svn.wordpress.org/trunk@34693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-01 03:11:30 +00:00
Boone Gorges 5dcced2d13 Use array hash notation for `get_comment_link()` `$args`.
See #34068, #34073.
Built from https://develop.svn.wordpress.org/trunk@34716


git-svn-id: http://core.svn.wordpress.org/trunk@34680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-30 04:13:25 +00:00
Boone Gorges 654eeb3785 Improve lazyloading of comment meta in `WP_Query` loops.
Lazy-loading logic is moved to a method on `WP_Query`. This makes it possible
for comment feeds to take advantage of metadata lazyloading, in addition to
comments loaded via `comments_template()`.

This new technique parallels the termmeta lazyloading technique introduced in
[34704].

Fixes #34047.
Built from https://develop.svn.wordpress.org/trunk@34711


git-svn-id: http://core.svn.wordpress.org/trunk@34675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-30 01:35:26 +00:00
Boone Gorges f7f4fb01ab Fix comment_order for single page comment threads.
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.
Built from https://develop.svn.wordpress.org/trunk@34669


git-svn-id: http://core.svn.wordpress.org/trunk@34633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-28 19:30:26 +00:00
Scott Taylor fa90b77ba4 Comments: in `WP_Comment::get_children()`, accept an array so that the values for `format`, `status`, `hierarchical`, and `orderby` can be passed, instead of just `format`. The defaults for `get_comments()` include `status = 'all'` and `orderby = ''` - which is no bueno.
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.

Built from https://develop.svn.wordpress.org/trunk@34569


git-svn-id: http://core.svn.wordpress.org/trunk@34533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-26 02:25:26 +00:00
Boone Gorges 18d6b3c8dc Force comment pagination on single posts.
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.
Built from https://develop.svn.wordpress.org/trunk@34561


git-svn-id: http://core.svn.wordpress.org/trunk@34525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 20:40:25 +00:00
Scott Taylor 498b2d7e33 Comments: In `comment_form()`, move the comment textarea to the top for logged-out users when replying, improves keyboard/focus navigation.
Rehabilitate errant tabbing and extra unnecessary `<?php ?>` toggling.

Props afercia, adamsilverstein.
Fixes #29974.

Built from https://develop.svn.wordpress.org/trunk@34525


git-svn-id: http://core.svn.wordpress.org/trunk@34489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 22:00:28 +00:00
Scott Taylor 2c23ca7411 Comments: in `comment_form()`, add args for `cancel_reply_before` and `cancel_reply_after` to eradicate remaining hard-coded HTML bits.
Props MikeHansenMe.
Fixes #23797.


Built from https://develop.svn.wordpress.org/trunk@34523


git-svn-id: http://core.svn.wordpress.org/trunk@34487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 21:33:26 +00:00
Scott Taylor 169db9dbb1 Comments: add a `'comment_excerpt_length'` filter to `get_comment_excerpt()`.
Create the first ever unit tests for `get_comment_excerpt()`.

Props dannydehaan, wonderboymusic.
Fixes #27526.

Built from https://develop.svn.wordpress.org/trunk@34520


git-svn-id: http://core.svn.wordpress.org/trunk@34484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 21:05:25 +00:00
Scott Taylor 595bad9f37 Comments: In `comments_template()`, set `$wp_query->comments_by_type` to empty array if not separating comments. The value becomes stale otherwise. Edge case.
Props jakub.tyrcha.
Fixes #14809.

Built from https://develop.svn.wordpress.org/trunk@34503


git-svn-id: http://core.svn.wordpress.org/trunk@34467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 16:31:24 +00:00
Boone Gorges a034a3394a Bail early when invalid ID is passed to `get_comment_class()`.
This helps to avoid PHP notices later in the function.

Props walterebert, dipesh.kakadiya, DrewAPicture.
Fixes #33947.
Built from https://develop.svn.wordpress.org/trunk@34454


git-svn-id: http://core.svn.wordpress.org/trunk@34418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-23 14:09:26 +00:00
Scott Taylor 1d0774e784 Add `title_reply_before` and `title_reply_after` args to `comment_form()` to allow the "Leave a Reply" heading level to be changed.
Props tyxla.
Fixes #33775.

Built from https://develop.svn.wordpress.org/trunk@34308


git-svn-id: http://core.svn.wordpress.org/trunk@34272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-18 19:18:26 +00:00
Boone Gorges 32887d3dfb Lazy-load comment meta on single post pages.
[34268] introduced cache priming for commentmeta, enabled by default. To
ensure performance on single post pages - where commentmeta is most likely
to cause performance issues - we disable up-front cache-priming. Instead, we
prime commentmeta caches for all comments in the loop the first time
`get_comment_meta()` is called on the page.

Props bradt, dd32, wonderboymusic, boonebgorges.
Fixes #16894.
Built from https://develop.svn.wordpress.org/trunk@34270


git-svn-id: http://core.svn.wordpress.org/trunk@34234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-17 20:01:24 +00:00
Scott Taylor af593128a7 Revert [33925], by-reference array manipulation is breaking comments in some themes.
This implementation is losing its shine.

See #16894.

Built from https://develop.svn.wordpress.org/trunk@34245


git-svn-id: http://core.svn.wordpress.org/trunk@34209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-16 18:14:25 +00:00
Drew Jaynes b1f176582c Docs: Add changelog entries for parameters where `WP_Comment` object support was added in [33961].
See #33638. See #32246.

Built from https://develop.svn.wordpress.org/trunk@34237


git-svn-id: http://core.svn.wordpress.org/trunk@34201 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-16 13:52:25 +00:00
Scott Taylor 4139daea5e Apply the new `'respond_link'` filter in `comments_popup_link()` if `$number` is `0` before outputting the URL.
Props joedolson.
Fixes #29454.

Built from https://develop.svn.wordpress.org/trunk@34216


git-svn-id: http://core.svn.wordpress.org/trunk@34180 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 20:46:35 +00:00
Scott Taylor 41c5bfb493 Comments: `get_comments_link()` should return a link with `#respond` as the hash instead of `#comments` if `get_comments_number()` returns `0`.
Props cgrymala, wonderboymusic.
Fixes #19893.

Built from https://develop.svn.wordpress.org/trunk@34075


git-svn-id: http://core.svn.wordpress.org/trunk@34043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-12 07:36:25 +00:00