| 495 | | if ( 'comment' == $this->query_vars['type'] ) { |
| 496 | | $where .= " AND comment_type = ''"; |
| 497 | | } elseif( 'pings' == $this->query_vars['type'] ) { |
| 498 | | $where .= ' AND comment_type IN ("pingback", "trackback")'; |
| 499 | | } elseif ( ! empty( $this->query_vars['type'] ) ) { |
| 500 | | $where .= $wpdb->prepare( ' AND comment_type = %s', $this->query_vars['type'] ); |
| | 504 | // Array of comment types |
| | 505 | $comment_types = ( ! is_array( $this->query_vars['type'] ) ) ? array( $this->query_vars['type'] ) : $this->query_vars['type'] ; |
| | 506 | // Merge in __in array of comment types |
| | 507 | $comment_types = array_merge( $comment_types, (array) $this->query_vars['type__in'] ); |
| | 508 | $query_types = array(); |
| | 509 | foreach ( $comment_types as $type ) { |
| | 510 | if ( is_array( $type ) ) { |
| | 511 | // A multi-dimensional array of comments types is unsupported. |
| | 512 | continue; |
| | 513 | } |
| | 514 | switch ( $type ) { |
| | 515 | case '': // explicit '' means all comments for backwards compatibility. |
| | 516 | break; |
| | 517 | case 'comment': |
| | 518 | case 'comments': // alias |
| | 519 | $query_types[] = "''"; |
| | 520 | break; |
| | 521 | case 'pings': |
| | 522 | $query_types[] = "'pingback'"; |
| | 523 | $query_types[] = "'trackback'"; |
| | 524 | break; |
| | 525 | default: |
| | 526 | $query_types[] = $wpdb->prepare( '%s', $type ); |
| | 527 | break; |
| | 528 | } |
| | 531 | // Query based on comment type |
| | 532 | if ( ! empty( $query_types ) ) { |
| | 533 | $where .= ' AND comment_type IN ( ' . implode( ', ', $query_types ) . ' )'; |
| | 534 | } |
| | 535 | |
| | 536 | // Array of comment types to exclude |
| | 537 | $excluded_comment_types = ( ! is_array( $this->query_vars['type__not_in'] ) ) ? array( $this->query_vars['type__not_in'] ) : $this->query_vars['type__not_in'] ; |
| | 538 | $excluded_query_types = array(); |
| | 539 | foreach ( $excluded_comment_types as $type ) { |
| | 540 | if ( is_array( $type ) ) { |
| | 541 | // A multi-dimensional array of comments types is unsupported. |
| | 542 | continue; |
| | 543 | } |
| | 544 | switch ( $type ) { |
| | 545 | case '': // explicit '' means all comments for backwards compatibility. |
| | 546 | break; |
| | 547 | case 'comment': |
| | 548 | case 'comments': // alias |
| | 549 | $excluded_query_types[] = "''"; |
| | 550 | break; |
| | 551 | case 'pings': |
| | 552 | $excluded_query_types[] = "'pingback'"; |
| | 553 | $excluded_query_types[] = "'trackback'"; |
| | 554 | break; |
| | 555 | default: |
| | 556 | $excluded_query_types[] = $wpdb->prepare( '%s', $type ); |
| | 557 | break; |
| | 558 | } |
| | 559 | } |
| | 560 | |
| | 561 | // Query based on comment type |
| | 562 | if ( ! empty( $excluded_query_types ) ) { |
| | 563 | $where .= ' AND comment_type NOT IN ( ' . implode( ', ', $excluded_query_types ) . ' )'; |
| | 564 | } |
| | 565 | |