Make WordPress Core

Ticket #37937: v2.diff

File v2.diff, 3.8 KB (added by birgire, 8 years ago)

Version #2

  • src/wp-includes/class-wp-site-query.php

     
    134134         *     @type string       $path              Limit results to those affiliated with a given path. Default empty.
    135135         *     @type array        $path__in          Array of paths to include affiliated sites for. Default empty.
    136136         *     @type array        $path__not_in      Array of paths to exclude affiliated sites for. Default empty.
    137          *     @type int          $public            Limit results to public sites. Accepts '1' or '0'. Default empty.
    138          *     @type int          $archived          Limit results to archived sites. Accepts '1' or '0'. Default empty.
    139          *     @type int          $mature            Limit results to mature sites. Accepts '1' or '0'. Default empty.
    140          *     @type int          $spam              Limit results to spam sites. Accepts '1' or '0'. Default empty.
    141          *     @type int          $deleted           Limit results to deleted sites. Accepts '1' or '0'. Default empty.
     137         *     @type mixed        $public            Limit results to public sites. Accepts boolean values. Default null.
     138         *     @type mixed        $archived          Limit results to archived sites. Accepts boolean values. Default null.
     139         *     @type mixed        $mature            Limit results to mature sites. Accepts boolean values. Default null.
     140         *     @type mixed        $spam              Limit results to spam sites. Accepts boolean values. Default null.
     141         *     @type mixed        $deleted           Limit results to deleted sites. Accepts boolean values. Default null.
    142142         *     @type int          $lang_id           Limit results to a language ID. Default empty.
    143143         *     @type array        $lang__in          Array of language IDs to include affiliated sites for. Default empty.
    144144         *     @type array        $lang__not_in      Array of language IDs to exclude affiliated sites for. Default empty.
     
    453453                        $this->sql_clauses['where']['path__not_in'] = "path NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__not_in'] ) ) . "' )";
    454454                }
    455455
    456                 if ( is_numeric( $this->query_vars['archived'] ) ) {
    457                         $archived = absint( $this->query_vars['archived'] );
     456                if ( ! is_null( $this->query_vars['archived'] ) ) {
     457                        $archived = wp_validate_boolean( $this->query_vars['archived'] ) ? 1 : 0;
    458458                        $this->sql_clauses['where']['archived'] = $wpdb->prepare( "archived = %d ", $archived );
    459459                }
    460460
    461                 if ( is_numeric( $this->query_vars['mature'] ) ) {
    462                         $mature = absint( $this->query_vars['mature'] );
     461                if ( ! is_null( $this->query_vars['mature'] ) ) {
     462                        $mature = wp_validate_boolean( $this->query_vars['mature'] ) ? 1 : 0;
    463463                        $this->sql_clauses['where']['mature'] = $wpdb->prepare( "mature = %d ", $mature );
    464464                }
    465465
    466                 if ( is_numeric( $this->query_vars['spam'] ) ) {
    467                         $spam = absint( $this->query_vars['spam'] );
     466                if ( ! is_null( $this->query_vars['spam'] ) ) {
     467                        $spam = wp_validate_boolean( $this->query_vars['spam'] ) ? 1 : 0;
    468468                        $this->sql_clauses['where']['spam'] = $wpdb->prepare( "spam = %d ", $spam );
    469469                }
    470470
    471                 if ( is_numeric( $this->query_vars['deleted'] ) ) {
    472                         $deleted = absint( $this->query_vars['deleted'] );
     471                if ( ! is_null( $this->query_vars['deleted'] ) ) {
     472                        $deleted = wp_validate_boolean( $this->query_vars['deleted'] ) ? 1 : 0;
    473473                        $this->sql_clauses['where']['deleted'] = $wpdb->prepare( "deleted = %d ", $deleted );
    474474                }
    475475
    476                 if ( is_numeric( $this->query_vars['public'] ) ) {
    477                         $public = absint( $this->query_vars['public'] );
     476                if ( ! is_null( $this->query_vars['public'] ) ) {
     477                        $public = wp_validate_boolean( $this->query_vars['public'] ) ? 1 : 0;
    478478                        $this->sql_clauses['where']['public'] = $wpdb->prepare( "public = %d ", $public );
    479479                }
    480480