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
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
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
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
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
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
`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
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
[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
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
[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
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
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
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
[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
* Takes inspiration from `WP_Post` and adds sanity to comment caching.
* Clarifies when the current global value for `$comment` is returned. The current implementation in `get_comment()` introduces side effects and an occasion stale global value for `$comment` when comment caches are cleaned.
* Strongly-types `@param` docs
* This class is marked `final` for now
Props wonderboymusic, nacin.
See #32619.
Built from https://develop.svn.wordpress.org/trunk@33891
git-svn-id: http://core.svn.wordpress.org/trunk@33860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The new 'submit_button' and 'submit_field' parameters for `comment_form()`
allow developers to modify the markup of the submit button and its wrapper.
These params are accompanied by targeted 'comment_form_submit_button' and
'comment_form_submit_field' filters on the concatenated markup.
Props coffee2code, morpheu5, DrewAPicture, boonebgorges.
Fixes#15015.
Built from https://develop.svn.wordpress.org/trunk@31699
git-svn-id: http://core.svn.wordpress.org/trunk@31680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
To better understand screen reader text, check out https://make.wordpress.org/accessibility/2015/02/09/hiding-text-for-screen-readers-with-wordpress-core/
Screen Reader text improves the user experience for screen reader users. It provides additional context for links, document forms and other pieces of a page that may exist visually, but are lost when looking only at the html of a site. This does change the output of comments_popup_link if you don't pass in values for $zero, $one, $more or $none. Theme authors can and should style <code>.screen-reader-text</code> in ways that are recommended in the above article to hide it visually.
Props joedolson
Fixes#26553
Built from https://develop.svn.wordpress.org/trunk@31388
git-svn-id: http://core.svn.wordpress.org/trunk@31369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Affects DocBlocks for the following core elements:
* Remove HTML tag from parameter description in `comment_form()`
* Remove HTML tag from a summary for the `comment_form_top` hook
* Markdown-indent a code snippet in the description for `get_linkobjectsbyname()`
* Markdown-indent a code snippet and format an unordered list in the description for `get_linkobjects()`
* Backtick-escape some inline code in the description for `clean_pre()`
* Remove HTML tag from the summary for the `rss_tag_pre` hook
* Various formatting fixes in the descriptions for `get_filesystem_method()` and `request_filesystem_credentials()`
Props rarst for the initial patch.
See #30473.
Built from https://develop.svn.wordpress.org/trunk@30538
git-svn-id: http://core.svn.wordpress.org/trunk@30527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Parameters were added to the `get_comment_author`, `comment_author`, `get_comment_author_email`, `author_email`, `comment_email`, `get_comment_author_link`, `get_comment_author_IP`, `get_comment_author_url`, `comment_url`, `get_comment_excerpt`, `comment_excerpt`, `get_comment_ID`, and `get_comment_type` filters.
Fixes#22380.
Built from https://develop.svn.wordpress.org/trunk@30111
git-svn-id: http://core.svn.wordpress.org/trunk@30111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`comments_template()` is used by most themes to display a post's comments. It
shows all comments that have been approved, and also shows all pending comments
by the current visitor (as determined by the comment cookies). However, the
comments API previously had no way of querying for "all comments that are
either approved, or are unapproved but written by foo@example.com". The
workaround was a direct SQL query: uncached, not subject to the same filters as
other comment queries, and just generally icky.
The new `include_unapproved` parameter for `WP_Comment_Query` accepts an array
of user IDs or email addresses. Pending comments associated with users in this
array will be included in query results, regardless of the value of the 'status'
parameter. In `comments_template()`, we leap from direct SQL queries to
`get_comments()` plus `include_unapproved', striving to put right what once
went wrong.
Props boonebgorges, simonwheatley, hardy101, jesin.
Fixes#19623.
Built from https://develop.svn.wordpress.org/trunk@29965
git-svn-id: http://core.svn.wordpress.org/trunk@29712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Various improvements:
* Adds `@see` reference for `wp_list_comments()` in 'wp_list_comments_args' filter docs, added in [28285]
* Various phpDoc tweaks for the 'run_wptexturize' filter docs, added in [28715]
* Sentence and wrapping changes for `is_https_url()`, added in [28894]
* Documents the `$args` parameter for `wp_dropdown_languages()`, added in [29007]
* Adds a period to the parameter description for `_update_posts_count_on_delete()`, added in [28835]
* Documents a global in `is_customize_preview()`, added in [28999]
* phpDoc tweaks, adds an access modifier for `wpdb::esc_like()`, added in [28711]
See #28885.
Built from https://develop.svn.wordpress.org/trunk@29163
git-svn-id: http://core.svn.wordpress.org/trunk@28947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* In `get_comment_reply_link()`, `$link` is set twice before it is used.
* In `Walker_Comment::start_lvl()`, `case 'ul':` is unreachable unless placed before `default:`.
* In `Walker_Comment::end_lvl()`, `case 'ul':` is unreachable unless placed before `default:`.
* In `comment_form()`, `$id` is conditionally set and never used.
See #27882.
Built from https://develop.svn.wordpress.org/trunk@28323
git-svn-id: http://core.svn.wordpress.org/trunk@28151 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This cleanup follows [25567] and brings the docs in-line with standards that at the time had not yet been finalized.
These changes include
* Moving in-line `@see` tags to their own lines
* Using docs-specific variables in hook docs
* Fixing line-wrapping throughout
* Typos and punctuation
* Converting hash notation values to variables per the standard
Fixes#27083. See #20495.
Built from https://develop.svn.wordpress.org/trunk@27156
git-svn-id: http://core.svn.wordpress.org/trunk@27022 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Changes include:
- Existing phpdoc block improvements
- Inclusion of defaults for optional parameters
- Hash-notated argument arrays
- Removal of unnecessary or redundant tagging.
Also standardization of int|WP_Post function parameters.
These changes clear the way toward less redundancy for hook docs in a future ticket.
Still left: Fully documented arguments in `comment_form()` and a pass through Walker_Comment.
See #20495. See #25388.
Built from https://develop.svn.wordpress.org/trunk@25567
git-svn-id: http://core.svn.wordpress.org/trunk@25485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This was originally included for Opera 10, but is not needed as of Opera 11, and current is Opera 15.
props jorbin, markjaquith.
fixes#24475.
git-svn-id: http://core.svn.wordpress.org/trunk@24573 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Make required arguments optional in confirm_blog_signup().
Mark arguments as required in _future_post_hook(), the walker method display_element(), get_author_link() (deprecated), and the WP_Widget constructor.
props rlerdorf.
see #24210.
git-svn-id: http://core.svn.wordpress.org/trunk@24126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* Whitespace cleanup
* Accepts format=html5 which uses some of the HTML5 elements
* Some helpful HTML comments to help untangle the HTML
* Other misc code cleanup
props lancewillett, obenland, georgestephanis. fixes#20088.
git-svn-id: http://core.svn.wordpress.org/trunk@23694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Make the $post argument to get_post() optional, defaulting to the current post in The Loop.
Props nacin
see #21309
git-svn-id: http://core.svn.wordpress.org/trunk@21735 1a063a9b-81f0-0310-95a4-ce76da25c4cd