Advertisement
Guest User

_ck_

a guest
Jul 22nd, 2009
1,609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1.         if ( ! empty($groupby) )
  2.             $groupby = 'GROUP BY ' . $groupby;
  3.         if ( !empty( $orderby ) )
  4.             $orderby = 'ORDER BY ' . $orderby;
  5.         $found_rows = '';
  6.         // if ( !empty($limits) )
  7.         //  $found_rows = 'SQL_CALC_FOUND_ROWS';
  8.  
  9.         // $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
  10.         $request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
  11.         $this->request = apply_filters('posts_request', $request);
  12.  
  13.         $this->posts = $wpdb->get_results($this->request);
  14.         // Raw results filter.  Prior to status checks.
  15.         $this->posts = apply_filters('posts_results', $this->posts);
  16.  
  17.         if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
  18.             $cjoin = apply_filters('comment_feed_join', '');
  19.             $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'");
  20.             $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss');
  21.             $this->comments = $wpdb->get_results($comments_request);
  22.             $this->comment_count = count($this->comments);
  23.         }
  24.  
  25.         if ( !empty($limits) ) {
  26.             // $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' );
  27.             $count="$distinct $fields"; $first=strpos($count,','); if ($first!==false) {$count=substr($count,0,$first-1);}
  28.             $found_posts_query = " SELECT count($count) FROM $wpdb->posts $join WHERE 1=1 $where $groupby";
  29.             $this->found_posts = $wpdb->get_var( $found_posts_query );
  30.             $this->found_posts = apply_filters( 'found_posts', $this->found_posts );
  31.             $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
  32.         }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement