139 * @since 4.4.0 Order by `comment__in` was added. `$update_comment_meta_cache`, `$no_found_rows`, |
139 * @since 4.4.0 Order by `comment__in` was added. `$update_comment_meta_cache`, `$no_found_rows`, |
140 * `$hierarchical`, and `$update_comment_post_cache` were added. |
140 * `$hierarchical`, and `$update_comment_post_cache` were added. |
141 * @since 4.5.0 Introduced the `$author_url` argument. |
141 * @since 4.5.0 Introduced the `$author_url` argument. |
142 * @since 4.6.0 Introduced the `$cache_domain` argument. |
142 * @since 4.6.0 Introduced the `$cache_domain` argument. |
143 * @since 4.9.0 Introduced the `$paged` argument. |
143 * @since 4.9.0 Introduced the `$paged` argument. |
|
144 * @since 5.1.0 Introduced the `$meta_compare_key` argument. |
|
145 * @since 5.3.0 Introduced the `$meta_type_key` argument. |
144 * |
146 * |
145 * @param string|array $query { |
147 * @param string|array $query { |
146 * Optional. Array or query string of comment query parameters. Default empty. |
148 * Optional. Array or query string of comment query parameters. Default empty. |
147 * |
149 * |
148 * @type string $author_email Comment author email address. Default empty. |
150 * @type string $author_email Comment author email address. Default empty. |
149 * @type string $author_url Comment author URL. Default empty. |
151 * @type string $author_url Comment author URL. Default empty. |
150 * @type int[] $author__in Array of author IDs to include comments for. Default empty. |
152 * @type int[] $author__in Array of author IDs to include comments for. Default empty. |
151 * @type int[] $author__not_in Array of author IDs to exclude comments for. Default empty. |
153 * @type int[] $author__not_in Array of author IDs to exclude comments for. Default empty. |
152 * @type int[] $comment__in Array of comment IDs to include. Default empty. |
154 * @type int[] $comment__in Array of comment IDs to include. Default empty. |
153 * @type int[] $comment__not_in Array of comment IDs to exclude. Default empty. |
155 * @type int[] $comment__not_in Array of comment IDs to exclude. Default empty. |
154 * @type bool $count Whether to return a comment count (true) or array of |
156 * @type bool $count Whether to return a comment count (true) or array of |
155 * comment objects (false). Default false. |
157 * comment objects (false). Default false. |
156 * @type array $date_query Date query clauses to limit comments by. See WP_Date_Query. |
158 * @type array $date_query Date query clauses to limit comments by. See WP_Date_Query. |
157 * Default null. |
159 * Default null. |
158 * @type string $fields Comment fields to return. Accepts 'ids' for comment IDs |
160 * @type string $fields Comment fields to return. Accepts 'ids' for comment IDs |
159 * only or empty for all fields. Default empty. |
161 * only or empty for all fields. Default empty. |
160 * @type int $ID Currently unused. |
162 * @type int $ID Currently unused. |
161 * @type array $include_unapproved Array of IDs or email addresses of users whose unapproved |
163 * @type array $include_unapproved Array of IDs or email addresses of users whose unapproved |
162 * comments will be returned by the query regardless of |
164 * comments will be returned by the query regardless of |
163 * `$status`. Default empty. |
165 * `$status`. Default empty. |
164 * @type int $karma Karma score to retrieve matching comments for. |
166 * @type int $karma Karma score to retrieve matching comments for. |
165 * Default empty. |
167 * Default empty. |
166 * @type string $meta_key Include comments with a matching comment meta key. |
168 * @type string|string[] $meta_key Meta key or keys to filter by. |
167 * Default empty. |
169 * @type string|string[] $meta_value Meta value or values to filter by. |
168 * @type string $meta_value Include comments with a matching comment meta value. |
170 * @type string $meta_compare MySQL operator used for comparing the meta value. |
169 * Requires `$meta_key` to be set. Default empty. |
171 * See WP_Meta_Query::__construct for accepted values and default value. |
170 * @type array $meta_query Meta query clauses to limit retrieved comments by. |
172 * @type string $meta_compare_key MySQL operator used for comparing the meta key. |
171 * See WP_Meta_Query. Default empty. |
173 * See WP_Meta_Query::__construct for accepted values and default value. |
172 * @type int $number Maximum number of comments to retrieve. |
174 * @type string $meta_type MySQL data type that the meta_value column will be CAST to for comparisons. |
173 * Default empty (no limit). |
175 * See WP_Meta_Query::__construct for accepted values and default value. |
174 * @type int $paged When used with $number, defines the page of results to return. |
176 * @type string $meta_type_key MySQL data type that the meta_key column will be CAST to for comparisons. |
175 * When used with $offset, $offset takes precedence. Default 1. |
177 * See WP_Meta_Query::__construct for accepted values and default value. |
176 * @type int $offset Number of comments to offset the query. Used to build |
178 * @type array $meta_query An associative array of WP_Meta_Query arguments. |
177 * LIMIT clause. Default 0. |
179 * See WP_Meta_Query::__construct for accepted values. |
178 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. |
180 * @type int $number Maximum number of comments to retrieve. |
179 * Default: true. |
181 * Default empty (no limit). |
180 * @type string|array $orderby Comment status or array of statuses. To use 'meta_value' |
182 * @type int $paged When used with `$number`, defines the page of results to return. |
181 * or 'meta_value_num', `$meta_key` must also be defined. |
183 * When used with `$offset`, `$offset` takes precedence. Default 1. |
182 * To sort by a specific `$meta_query` clause, use that |
184 * @type int $offset Number of comments to offset the query. Used to build |
183 * clause's array key. Accepts 'comment_agent', |
185 * LIMIT clause. Default 0. |
184 * 'comment_approved', 'comment_author', |
186 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. |
185 * 'comment_author_email', 'comment_author_IP', |
187 * Default: true. |
186 * 'comment_author_url', 'comment_content', 'comment_date', |
188 * @type string|array $orderby Comment status or array of statuses. To use 'meta_value' |
187 * 'comment_date_gmt', 'comment_ID', 'comment_karma', |
189 * or 'meta_value_num', `$meta_key` must also be defined. |
188 * 'comment_parent', 'comment_post_ID', 'comment_type', |
190 * To sort by a specific `$meta_query` clause, use that |
189 * 'user_id', 'comment__in', 'meta_value', 'meta_value_num', |
191 * clause's array key. Accepts: |
190 * the value of $meta_key, and the array keys of |
192 * - 'comment_agent' |
191 * `$meta_query`. Also accepts false, an empty array, or |
193 * - 'comment_approved' |
192 * 'none' to disable `ORDER BY` clause. |
194 * - 'comment_author' |
193 * Default: 'comment_date_gmt'. |
195 * - 'comment_author_email' |
194 * @type string $order How to order retrieved comments. Accepts 'ASC', 'DESC'. |
196 * - 'comment_author_IP' |
195 * Default: 'DESC'. |
197 * - 'comment_author_url' |
196 * @type int $parent Parent ID of comment to retrieve children of. |
198 * - 'comment_content' |
197 * Default empty. |
199 * - 'comment_date' |
198 * @type int[] $parent__in Array of parent IDs of comments to retrieve children for. |
200 * - 'comment_date_gmt' |
199 * Default empty. |
201 * - 'comment_ID' |
200 * @type int[] $parent__not_in Array of parent IDs of comments *not* to retrieve |
202 * - 'comment_karma' |
201 * children for. Default empty. |
203 * - 'comment_parent' |
202 * @type int[] $post_author__in Array of author IDs to retrieve comments for. |
204 * - 'comment_post_ID' |
203 * Default empty. |
205 * - 'comment_type' |
204 * @type int[] $post_author__not_in Array of author IDs *not* to retrieve comments for. |
206 * - 'user_id' |
205 * Default empty. |
207 * - 'comment__in' |
206 * @type int $post_ID Currently unused. |
208 * - 'meta_value' |
207 * @type int $post_id Limit results to those affiliated with a given post ID. |
209 * - 'meta_value_num' |
208 * Default 0. |
210 * - The value of `$meta_key` |
209 * @type int[] $post__in Array of post IDs to include affiliated comments for. |
211 * - The array keys of `$meta_query` |
210 * Default empty. |
212 * - false, an empty array, or 'none' to disable `ORDER BY` clause. |
211 * @type int[] $post__not_in Array of post IDs to exclude affiliated comments for. |
213 * Default: 'comment_date_gmt'. |
212 * Default empty. |
214 * @type string $order How to order retrieved comments. Accepts 'ASC', 'DESC'. |
213 * @type int $post_author Post author ID to limit results by. Default empty. |
215 * Default: 'DESC'. |
214 * @type string|array $post_status Post status or array of post statuses to retrieve |
216 * @type int $parent Parent ID of comment to retrieve children of. |
215 * affiliated comments for. Pass 'any' to match any value. |
217 * Default empty. |
216 * Default empty. |
218 * @type int[] $parent__in Array of parent IDs of comments to retrieve children for. |
217 * @type string $post_type Post type or array of post types to retrieve affiliated |
219 * Default empty. |
218 * comments for. Pass 'any' to match any value. Default empty. |
220 * @type int[] $parent__not_in Array of parent IDs of comments *not* to retrieve |
219 * @type string $post_name Post name to retrieve affiliated comments for. |
221 * children for. Default empty. |
220 * Default empty. |
222 * @type int[] $post_author__in Array of author IDs to retrieve comments for. |
221 * @type int $post_parent Post parent ID to retrieve affiliated comments for. |
223 * Default empty. |
222 * Default empty. |
224 * @type int[] $post_author__not_in Array of author IDs *not* to retrieve comments for. |
223 * @type string $search Search term(s) to retrieve matching comments for. |
225 * Default empty. |
224 * Default empty. |
226 * @type int $post_ID Currently unused. |
225 * @type string|array $status Comment statuses to limit results by. Accepts an array |
227 * @type int $post_id Limit results to those affiliated with a given post ID. |
226 * or space/comma-separated list of 'hold' (`comment_status=0`), |
228 * Default 0. |
227 * 'approve' (`comment_status=1`), 'all', or a custom |
229 * @type int[] $post__in Array of post IDs to include affiliated comments for. |
228 * comment status. Default 'all'. |
230 * Default empty. |
229 * @type string|array $type Include comments of a given type, or array of types. |
231 * @type int[] $post__not_in Array of post IDs to exclude affiliated comments for. |
230 * Accepts 'comment', 'pings' (includes 'pingback' and |
232 * Default empty. |
231 * 'trackback'), or any custom type string. Default empty. |
233 * @type int $post_author Post author ID to limit results by. Default empty. |
232 * @type string[] $type__in Include comments from a given array of comment types. |
234 * @type string|string[] $post_status Post status or array of post statuses to retrieve |
233 * Default empty. |
235 * affiliated comments for. Pass 'any' to match any value. |
234 * @type string[] $type__not_in Exclude comments from a given array of comment types. |
236 * Default empty. |
235 * Default empty. |
237 * @type string|string[] $post_type Post type or array of post types to retrieve affiliated |
236 * @type int $user_id Include comments for a specific user ID. Default empty. |
238 * comments for. Pass 'any' to match any value. Default empty. |
237 * @type bool|string $hierarchical Whether to include comment descendants in the results. |
239 * @type string $post_name Post name to retrieve affiliated comments for. |
238 * - 'threaded' returns a tree, with each comment's children |
240 * Default empty. |
239 * stored in a `children` property on the `WP_Comment` object. |
241 * @type int $post_parent Post parent ID to retrieve affiliated comments for. |
240 * - 'flat' returns a flat array of found comments plus |
242 * Default empty. |
241 * their children. |
243 * @type string $search Search term(s) to retrieve matching comments for. |
242 * - Boolean `false` leaves out descendants. |
244 * Default empty. |
243 * The parameter is ignored (forced to `false`) when |
245 * @type string|array $status Comment statuses to limit results by. Accepts an array |
244 * `$fields` is 'ids' or 'counts'. Accepts 'threaded', |
246 * or space/comma-separated list of 'hold' (`comment_status=0`), |
245 * 'flat', or false. Default: false. |
247 * 'approve' (`comment_status=1`), 'all', or a custom |
246 * @type string $cache_domain Unique cache key to be produced when this query is stored in |
248 * comment status. Default 'all'. |
247 * an object cache. Default is 'core'. |
249 * @type string|string[] $type Include comments of a given type, or array of types. |
248 * @type bool $update_comment_meta_cache Whether to prime the metadata cache for found comments. |
250 * Accepts 'comment', 'pings' (includes 'pingback' and |
249 * Default true. |
251 * 'trackback'), or any custom type string. Default empty. |
250 * @type bool $update_comment_post_cache Whether to prime the cache for comment posts. |
252 * @type string[] $type__in Include comments from a given array of comment types. |
251 * Default false. |
253 * Default empty. |
|
254 * @type string[] $type__not_in Exclude comments from a given array of comment types. |
|
255 * Default empty. |
|
256 * @type int $user_id Include comments for a specific user ID. Default empty. |
|
257 * @type bool|string $hierarchical Whether to include comment descendants in the results. |
|
258 * - 'threaded' returns a tree, with each comment's children |
|
259 * stored in a `children` property on the `WP_Comment` object. |
|
260 * - 'flat' returns a flat array of found comments plus |
|
261 * their children. |
|
262 * - Boolean `false` leaves out descendants. |
|
263 * The parameter is ignored (forced to `false`) when |
|
264 * `$fields` is 'ids' or 'counts'. Accepts 'threaded', |
|
265 * 'flat', or false. Default: false. |
|
266 * @type string $cache_domain Unique cache key to be produced when this query is stored in |
|
267 * an object cache. Default is 'core'. |
|
268 * @type bool $update_comment_meta_cache Whether to prime the metadata cache for found comments. |
|
269 * Default true. |
|
270 * @type bool $update_comment_post_cache Whether to prime the cache for comment posts. |
|
271 * Default false. |
252 * } |
272 * } |
253 */ |
273 */ |
254 public function __construct( $query = '' ) { |
274 public function __construct( $query = '' ) { |
255 $this->query_var_defaults = array( |
275 $this->query_var_defaults = array( |
256 'author_email' => '', |
276 'author_email' => '', |