From 7c0d3ab83a1f8be70be6d7aaa8e8ebb17c8b0dab Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 20 Aug 2015 02:19:25 +0000 Subject: [PATCH] Introduce `post_name__in` parameter for `WP_Query`. Props enshrined. Fixes #33065. Built from https://develop.svn.wordpress.org/trunk@33653 git-svn-id: http://core.svn.wordpress.org/trunk@33620 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 9 +++++++-- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 7cbac9db88..85d7f80139 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1434,7 +1434,7 @@ class WP_Query { $array[$key] = ''; } - $array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', + $array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in', 'author__in', 'author__not_in' ); @@ -1451,6 +1451,7 @@ class WP_Query { * @since 1.5.0 * @since 4.2.0 Introduced the ability to order by specific clauses of a `$meta_query`, by passing the clause's * array key to `$orderby`. + * @since 4.3.0 Introduced the `$post_name__in` parameter. * @access public * * @param string|array $query { @@ -1527,6 +1528,7 @@ class WP_Query { * @type int $posts_per_page The number of posts to query for. Use -1 to request all posts. * @type int $posts_per_archive_page The number of posts to query for by archive page. Overrides * 'posts_per_page' when is_archive(), or is_search() are true. + * @type array $post_name__in An array of post slugs that results must match. * @type string $s Search keyword. * @type int $second Second of the minute. Default empty. Accepts numbers 0-60. * @type array $search_terms Array of search terms. @@ -2603,6 +2605,7 @@ class WP_Query { unset($ptype_obj); } + // Parameters related to 'post_name'. if ( '' != $q['name'] ) { $q['name'] = sanitize_title_for_query( $q['name'] ); $where .= " AND $wpdb->posts.post_name = '" . $q['name'] . "'"; @@ -2647,9 +2650,11 @@ class WP_Query { $q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) ); $q['name'] = $q['attachment']; $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'"; + } elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) { + $q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] ); + $where .= " AND $wpdb->posts.post_name IN ('" . implode( "' ,'", $q['post_name__in'] ) . "')"; } - if ( intval($q['comments_popup']) ) $q['p'] = absint($q['comments_popup']); diff --git a/wp-includes/version.php b/wp-includes/version.php index 88e95ecba3..bdf584384b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-33652'; +$wp_version = '4.4-alpha-33653'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.