WordPress.org

Make WordPress Core

Ticket #20308: privatequeries.20308.diff

File privatequeries.20308.diff, 941 bytes (added by robmiller, 5 years ago)

Add has_password var to WP_Query

  • wp-includes/query.php

    diff --git wp-includes/query.php wp-includes/query.php
    index 443d0bb..02d114f 100644
    class WP_Query { 
    16611661                                $qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
    16621662                }
    16631663
     1664                if ( isset( $qv['has_password'] ) ) {
     1665                        $qv['has_password'] = $qv['has_password'] ? true : false;
     1666                }
     1667
    16641668                if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) )
    16651669                        $this->is_comment_feed = false;
    16661670
    class WP_Query { 
    25112515                        $where .= ')';
    25122516                }
    25132517
     2518                if ( isset( $q['has_password'] ) ) {
     2519                        if ( $q['has_password'] ) {
     2520                                $where .= " AND $wpdb->posts.post_password != ''";
     2521                        } else {
     2522                                $where .= " AND $wpdb->posts.post_password = ''";
     2523                        }
     2524                }
     2525
    25142526                if ( !empty( $this->meta_query->queries ) ) {
    25152527                        $clauses = $this->meta_query->get_sql( 'post', $wpdb->posts, 'ID', $this );
    25162528                        $join .= $clauses['join'];