Ticket #1486: 1486.patch

File 1486.patch, 1.4 KB (added by skippy, 7 years ago)
  • template-functions-post.php

     
    300300        if ( !isset($r['sort_order']) ) 
    301301                $r['sort_order'] = 'ASC'; 
    302302 
     303        $authors = ''; 
     304        if (!empty($r['authors'])) { 
     305                $auths = preg_split('/[\s,]+/',$r['authors']); 
     306                if (count($auths)) { 
     307                        foreach ($auths as $auth) { 
     308                                if ( (is_string($auth)) && (! is_int($auth)) ) {  
     309                                        $author_ID = $wpdb->get_var("SELECT ID from $wpdb->users WHERE user_login = '$auth'"); 
     310                                        if (! $author_ID) next; 
     311                                                $auth = $author_ID; 
     312                                } 
     313                                if ('' == $authors) { 
     314                                        $authors .= ' post_author = ' . intval($auth) . ' '; 
     315                                } else { 
     316                                        $authors .= ' OR post_author = ' . intval($auth) . ' '; 
     317                                } 
     318                        } 
     319                        $authors = " AND ($authors) "; 
     320                } 
     321        } 
     322 
    303323        $exclusions = ''; 
    304324        if ( !empty($r['exclude']) ) { 
    305325                $expages = preg_split('/[\s,]+/',$r['exclude']); 
     
    313333        $pages = $wpdb->get_results("SELECT * " . 
    314334                "FROM $wpdb->posts " . 
    315335                "WHERE post_status = 'static' " . 
     336                "$authors " .  
    316337                "$exclusions " . 
    317338                "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']); 
    318339 
     
    341362                $r['title_li'] = __('Pages'); 
    342363        if ( !isset($r['echo']) ) 
    343364                $r['echo'] = 1; 
     365        if ( !isset($r['authors']) ) 
     366                $r['authors'] = ''; 
    344367 
    345368        $output = ''; 
    346369