diff --git src/wp-includes/class-wp-comment-query.php src/wp-includes/class-wp-comment-query.php
index e30094d..ac122a6 100644
|
|
|
class WP_Comment_Query { |
| 139 | 139 | * @since 4.4.0 `$parent__in` and `$parent__not_in` were added. |
| 140 | 140 | * @since 4.4.0 Order by `comment__in` was added. `$update_comment_meta_cache`, `$no_found_rows`, |
| 141 | 141 | * `$hierarchical`, and `$update_comment_post_cache` were added. |
| | 142 | * @since 4.5.0 `$author_url` was added. |
| 142 | 143 | * @access public |
| 143 | 144 | * |
| 144 | 145 | * @param string|array $query { |
| 145 | 146 | * Optional. Array or query string of comment query parameters. Default empty. |
| 146 | 147 | * |
| 147 | 148 | * @type string $author_email Comment author email address. Default empty. |
| | 149 | * @type string $author_url Comment author URL. Default empty. |
| 148 | 150 | * @type array $author__in Array of author IDs to include comments for. Default empty. |
| 149 | 151 | * @type array $author__not_in Array of author IDs to exclude comments for. Default empty. |
| 150 | 152 | * @type array $comment__in Array of comment IDs to include. Default empty. |
| … |
… |
class WP_Comment_Query { |
| 245 | 247 | public function __construct( $query = '' ) { |
| 246 | 248 | $this->query_var_defaults = array( |
| 247 | 249 | 'author_email' => '', |
| | 250 | 'author_url' => '', |
| 248 | 251 | 'author__in' => '', |
| 249 | 252 | 'author__not_in' => '', |
| 250 | 253 | 'include_unapproved' => '', |
| … |
… |
class WP_Comment_Query { |
| 670 | 673 | $this->sql_clauses['where']['author_email'] = $wpdb->prepare( 'comment_author_email = %s', $this->query_vars['author_email'] ); |
| 671 | 674 | } |
| 672 | 675 | |
| | 676 | if ( '' !== $this->query_vars['author_url'] ) { |
| | 677 | $this->sql_clauses['where']['author_url'] = $wpdb->prepare( 'comment_author_url = %s', $this->query_vars['author_url'] ); |
| | 678 | } |
| | 679 | |
| 673 | 680 | if ( '' !== $this->query_vars['karma'] ) { |
| 674 | 681 | $this->sql_clauses['where']['karma'] = $wpdb->prepare( 'comment_karma = %d', $this->query_vars['karma'] ); |
| 675 | 682 | } |
diff --git tests/phpunit/tests/comment/query.php tests/phpunit/tests/comment/query.php
index 5d250ea..8163feb 100644
|
|
|
class Tests_Comment_Query extends WP_UnitTestCase { |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
| | 808 | * @ticket 35377 |
| | 809 | */ |
| | 810 | function test_get_comments_by_author_url() { |
| | 811 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); |
| | 812 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); |
| | 813 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar/baz' ) ); |
| | 814 | |
| | 815 | $comments = get_comments( array( |
| | 816 | 'author_url' => 'http://foo.bar', |
| | 817 | ) ); |
| | 818 | |
| | 819 | $this->assertCount( 2, $comments ); |
| | 820 | $this->assertEquals( (string) $c1, $comments[0]->comment_ID ); |
| | 821 | $this->assertEquals( (string) $c2, $comments[1]->comment_ID ); |
| | 822 | } |
| | 823 | |
| | 824 | /** |
| 808 | 825 | * @ticket 28434 |
| 809 | 826 | */ |
| 810 | 827 | function test_fields_ids_query() { |