Changeset 29965 for trunk/src/wp-includes/comment.php
- Timestamp:
- 10/19/2014 07:38:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r29935 r29965 260 260 * @since 4.1.0 Introduced 'comment__in', 'comment__not_in', 'post_author__in', 261 261 * 'post_author__not_in', 'author__in', 'author__not_in', 262 * 'post__in', and 'post__not_in' to $query_vars.262 * 'post__in', 'post__not_in', and 'include_unapproved' to $query_vars. 263 263 * 264 264 * @param string|array $query_vars … … 272 272 'author__in' => '', 273 273 'author__not_in' => '', 274 'include_unapproved' => '', 274 275 'fields' => '', 275 276 'ID' => '', … … 334 335 } 335 336 337 // Assemble clauses related to 'comment_approved'. 338 $approved_clauses = array(); 336 339 $status = $this->query_vars['status']; 337 340 if ( 'hold' == $status ) { 338 $approved = "comment_approved = '0'";341 $approved_clauses[] = "comment_approved = '0'"; 339 342 } elseif ( 'approve' == $status ) { 340 $approved = "comment_approved = '1'";343 $approved_clauses[] = "comment_approved = '1'"; 341 344 } elseif ( ! empty( $status ) && 'all' != $status ) { 342 $approved = $wpdb->prepare( "comment_approved = %s", $status );345 $approved_clauses[] = $wpdb->prepare( "comment_approved = %s", $status ); 343 346 } else { 344 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 345 } 347 $approved_clauses[] = "( comment_approved = '0' OR comment_approved = '1' )"; 348 } 349 350 // User IDs or emails whose unapproved comments are included, regardless of $status. 351 if ( ! empty( $this->query_vars['include_unapproved'] ) ) { 352 $include_unapproved = $this->query_vars['include_unapproved']; 353 354 // Accepts arrays or comma-separated strings. 355 if ( ! is_array( $include_unapproved ) ) { 356 $include_unapproved = preg_split( '/[\s,]+/', $include_unapproved ); 357 } 358 359 $unapproved_ids = $unapproved_emails = array(); 360 foreach ( $include_unapproved as $unapproved_identifier ) { 361 // Numeric values are assumed to be user ids. 362 if ( is_numeric( $unapproved_identifier ) ) { 363 $approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier ); 364 365 // Otherwise we match against email addresses. 366 } else { 367 $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier ); 368 } 369 } 370 } 371 372 // Collapse comment_approved clauses into a single OR-separated clause. 373 if ( 1 === count( $approved_clauses ) ) { 374 $approved = $approved_clauses[0]; 375 } else { 376 $approved = '( ' . implode( ' OR ', $approved_clauses ) . ' )'; 377 } 378 346 379 $order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC'; 347 380
Note: See TracChangeset
for help on using the changeset viewer.