Introduce $comment_status and $ping_status params for WP_Query.

Props birgire.
Fixes #35601.
Built from https://develop.svn.wordpress.org/trunk@36403


git-svn-id: http://core.svn.wordpress.org/trunk@36370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-01-26 02:56:26 +00:00
parent de9d742b9a
commit de89efc4dc
2 changed files with 12 additions and 1 deletions

View File

@ -1484,6 +1484,7 @@ class WP_Query {
* @since 4.4.0 Introduced `$post_name__in` and `$title` parameters. `$s` was updated to support excluded
* search terms, by prepending a hyphen.
* @since 4.5.0 Removed the `$comments_popup` parameter.
* Introduced the `$comment_status` and `$ping_status` parameters.
* @access public
*
* @param string|array $query {
@ -1500,6 +1501,7 @@ class WP_Query {
* @type array $category__in An array of category IDs (OR in, no children).
* @type array $category__not_in An array of category IDs (NOT in).
* @type string $category_name Use category slug (not name, this or any children).
* @type string $comment_status Comment status.
* @type int $comments_per_page The number of comments to return per page.
* Default 'comments_per_page' option.
* @type array $date_query An associative array of WP_Date_Query arguments.
@ -1545,6 +1547,7 @@ class WP_Query {
* @type int $page_id Page ID.
* @type string $pagename Page slug.
* @type string $perm Show posts if user has the appropriate capability.
* @type string $ping_status Ping status.
* @type array $post__in An array of post IDs to retrieve, sticky posts will be included
* @type string $post_mime_type The mime type of the post. Used for 'attachment' post_type.
* @type array $post__not_in An array of post IDs not to retrieve. Note: a string of comma-
@ -3036,6 +3039,14 @@ class WP_Query {
$where .= sprintf( " AND $wpdb->posts.post_password %s ''", $q['has_password'] ? '!=' : '=' );
}
if ( ! empty( $q['comment_status'] ) ) {
$where .= $wpdb->prepare( " AND $wpdb->posts.comment_status = %s ", $q['comment_status'] );
}
if ( ! empty( $q['ping_status'] ) ) {
$where .= $wpdb->prepare( " AND $wpdb->posts.ping_status = %s ", $q['ping_status'] );
}
if ( 'any' == $post_type ) {
$in_search_post_types = get_post_types( array('exclude_from_search' => false) );
if ( empty( $in_search_post_types ) )

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36402';
$wp_version = '4.5-alpha-36403';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.