Changeset 33653
- Timestamp:
- 08/20/2015 02:18:05 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r33095 r33653 1435 1435 } 1436 1436 1437 $array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 1437 $array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in', 1438 1438 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in', 1439 1439 'author__in', 'author__not_in' ); … … 1452 1452 * @since 4.2.0 Introduced the ability to order by specific clauses of a `$meta_query`, by passing the clause's 1453 1453 * array key to `$orderby`. 1454 * @since 4.3.0 Introduced the `$post_name__in` parameter. 1454 1455 * @access public 1455 1456 * … … 1528 1529 * @type int $posts_per_archive_page The number of posts to query for by archive page. Overrides 1529 1530 * 'posts_per_page' when is_archive(), or is_search() are true. 1531 * @type array $post_name__in An array of post slugs that results must match. 1530 1532 * @type string $s Search keyword. 1531 1533 * @type int $second Second of the minute. Default empty. Accepts numbers 0-60. … … 2604 2606 } 2605 2607 2608 // Parameters related to 'post_name'. 2606 2609 if ( '' != $q['name'] ) { 2607 2610 $q['name'] = sanitize_title_for_query( $q['name'] ); … … 2648 2651 $q['name'] = $q['attachment']; 2649 2652 $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'"; 2650 } 2651 2653 } elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) { 2654 $q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] ); 2655 $where .= " AND $wpdb->posts.post_name IN ('" . implode( "' ,'", $q['post_name__in'] ) . "')"; 2656 } 2652 2657 2653 2658 if ( intval($q['comments_popup']) ) -
trunk/tests/phpunit/tests/post/query.php
r31286 r33653 303 303 $this->assertNotContains( 'ASC', $q5->request ); 304 304 } 305 306 /** 307 * Tests the post_name__in attribute of WP_Query. 308 * 309 * @ticket 33065 310 */ 311 public function test_post_name__in() { 312 $q = new WP_Query(); 313 314 $post_ids[0] = $this->factory->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) ); 315 $post_ids[1] = $this->factory->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) ); 316 $post_ids[2] = $this->factory->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) ); 317 $post_ids[3] = $this->factory->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) ); 318 319 $requested = array( $post_ids[0], $post_ids[3] ); 320 $q->query( array( 321 'post_name__in' => array( 'woo', 'me' ), 322 'fields' => 'ids', 323 ) ); 324 $actual_posts = $q->get_posts(); 325 $this->assertEqualSets( $requested, $actual_posts ); 326 327 $requested = array( $post_ids[1], $post_ids[2] ); 328 $q->query( array( 329 'post_name__in' => array( 'hoo', 'test' ), 330 'fields' => 'ids', 331 ) ); 332 $actual_posts = $q->get_posts(); 333 $this->assertEqualSets( $requested, $actual_posts ); 334 } 305 335 }
Note: See TracChangeset
for help on using the changeset viewer.