Make WordPress Core

Ticket #16854: 16854.diff

File 16854.diff, 3.0 KB (added by wonderboymusic, 12 years ago)
  • wp-includes/query.php

    diff --git a/wp-includes/query.php b/wp-includes/query.php
    index 04286aa..a4c6cc8 100644
    a b class WP_Query { 
    13871387                        , 'tag'
    13881388                        , 'cat'
    13891389                        , 'tag_id'
     1390                        , 'author'
    13901391                        , 'author_name'
    13911392                        , 'feed'
    13921393                        , 'tb'
    class WP_Query { 
    14071408                }
    14081409
    14091410                $array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in',
    1410                         'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in' );
     1411                        'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in',
     1412                        'author__in', 'author__not_in' );
    14111413
    14121414                foreach ( $array_keys as $key ) {
    14131415                        if ( !isset($array[$key]) )
    class WP_Query { 
    14481450                $qv['m'] = absint($qv['m']);
    14491451                $qv['paged'] = absint($qv['paged']);
    14501452                $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers
     1453                $qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // comma separated list of positive or negative integers
    14511454                $qv['pagename'] = trim( $qv['pagename'] );
    14521455                $qv['name'] = trim( $qv['name'] );
    14531456                if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
    class WP_Query { 
    22992302                }
    23002303
    23012304                // Author/user stuff
    2302 
    2303                 if ( empty($q['author']) || ($q['author'] == '0') ) {
    2304                         $whichauthor = '';
    2305                 } else {
    2306                         $q['author'] = (string)urldecode($q['author']);
    2307                         $q['author'] = addslashes_gpc($q['author']);
    2308                         if ( strpos($q['author'], '-') !== false ) {
    2309                                 $eq = '!=';
    2310                                 $andor = 'AND';
    2311                                 $q['author'] = explode('-', $q['author']);
    2312                                 $q['author'] = (string)absint($q['author'][1]);
    2313                         } else {
    2314                                 $eq = '=';
    2315                                 $andor = 'OR';
     2305       
     2306                if ( ! empty( $q['author'] ) && $q['author'] != '0' ) {
     2307                        $q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) );
     2308                        $authors = array_unique( array_map( 'intval', (array) preg_split( '/[,\s]+/', $q['author'] ) ) );
     2309                        foreach ( $authors as $author ) {
     2310                                $key = $author > 0 ? 'author__in' : 'author__not_in';
     2311                                $q[$key][] = abs( $author );
    23162312                        }
    2317                         $author_array = preg_split('/[,\s]+/', $q['author']);
    2318                         $_author_array = array();
    2319                         foreach ( $author_array as $key => $_author )
    2320                                 $_author_array[] = "$wpdb->posts.post_author " . $eq . ' ' . absint($_author);
    2321                         $whichauthor .= ' AND (' . implode(" $andor ", $_author_array) . ')';
    2322                         unset($author_array, $_author_array);
    2323                 }
    2324 
     2313                        $q['author'] = implode( ',', $authors );
     2314                }
     2315               
     2316                if ( ! empty( $q['author__in'] ) ) {
     2317                        $author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
     2318                        $where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
     2319                }
     2320
     2321                if ( ! empty( $q['author__not_in'] ) ) {
     2322                        $author__not_in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__not_in'] ) ) );
     2323                        $where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
     2324                }               
     2325               
    23252326                // Author stuff for nice URLs
    23262327
    23272328                if ( '' != $q['author_name'] ) {