Core class used for querying comments.
Name | Type(s) | Default Value | Summary |
---|---|---|---|
request |
string
|
SQL for database query. | |
meta_query |
object
|
Metadata query container | |
meta_query_clauses |
array
|
Metadata query clauses. | |
sql_clauses |
array
|
SQL query clauses. | |
filtered_where_clause |
string
|
SQL WHERE clause. Stored after the \'comments_clauses' filter is run on the compiled WHERE sub-clauses. |
|
date_query |
object
|
Date query container | |
query_vars |
array
|
Query vars set by the user. | |
query_var_defaults |
array
|
Default values for query vars. | |
comments |
array
|
List of comments located by the query. | |
found_comments |
integer
|
The amount of found comments for the current query. | |
max_num_pages |
integer
|
The number of pages. |
__call( string $name, array $arguments )
Make private/protected methods readable for backward compatibility. Since 4.0.0.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$name
|
string
|
Method to call. |
|
$arguments
|
array
|
Arguments to pass when calling. |
mixed | false
Return value of the callback, false otherwise.
__construct( string | array $query = '' )
Constructor. Since 4.2.0. Since 4.4.0. Since 4.4.0. Since 4.5.0. Since 4.6.0. Since 4.9.0.
Sets up the comment query, based on the query vars passed.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$query
|
string | array
|
{ Optional. Array or query string of comment query parameters. Default empty.
} |
fill_descendants( array<mixed,\WP_Comment> $comments )
Fetch descendants for located comments. Since 4.4.0.
Instead of calling get_children()
separately on each child comment, we do a single set of queries to fetch
the descendant trees for all matched top-level comments.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$comments
|
array<mixed,WP_Comment>
|
Array of top-level comments whose descendants should be filled in. |
array
get_comment_ids( )
Used internally to get a list of comment IDs matching the query vars. Since 4.4.0.
integer | array
A single count of comment IDs if a count query. An array of comment IDs if a full query.
get_comments( )
Get a list of comments matching the query vars. Since 4.2.0.
integer | array
List of comments or number of found comments if $count
argument is true.
get_search_sql( string $string, array $cols )
Used internally to generate an SQL string for searching across multiple columns Since 3.1.0.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$string
|
string
|
||
$cols
|
array
|
string
parse_order( string $order )
Parse an 'order' query variable and cast it to ASC or DESC as necessary. Since 4.2.0.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$order
|
string
|
The 'order' query variable. |
string
The sanitized 'order' query variable.
parse_orderby( string $orderby )
Parse and sanitize 'orderby' keys passed to the comment query. Since 4.2.0.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$orderby
|
string
|
Alias for the field to order by. |
string | false
Value to used in the ORDER clause. False otherwise.
parse_query( string | array $query = '' )
Parse arguments passed to the comment query with default query parameters. Since 4.2.0.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$query
|
string | array
|
WP_Comment_Query arguments. See WP_Comment_Query::__construct() |
query( string | array $query )
Sets up the WordPress query for retrieving comments. Since 3.1.0. Since 4.1.0. Since 4.2.0.
Name | Type(s) | Default Value | Description |
---|---|---|---|
$query
|
string | array
|
Array or URL query string of parameters. |
array | integer
List of comments, or number of comments when 'count' is passed as a query var.
set_found_comments( )
Populates found_comments and max_num_pages properties for the current query if the limit clause was used. Since 4.6.0.