@@ 42-62 (lines=21) @@ | ||
39 | // noop right now |
|
40 | } |
|
41 | ||
42 | public function post_count( $status = null, $min_id = null, $max_id = null ) { |
|
43 | global $wpdb; |
|
44 | ||
45 | $where = ""; |
|
46 | ||
47 | if ( $status ) { |
|
48 | $where = "post_status = '" . esc_sql( $status ) . "'"; |
|
49 | } else { |
|
50 | $where = "1=1"; |
|
51 | } |
|
52 | ||
53 | if ( $min_id != null ) { |
|
54 | $where .= " AND ID >= " . intval( $min_id ); |
|
55 | } |
|
56 | ||
57 | if ( $max_id != null ) { |
|
58 | $where .= " AND ID <= " . intval( $max_id ); |
|
59 | } |
|
60 | ||
61 | return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE $where" ); |
|
62 | } |
|
63 | ||
64 | public function get_posts( $status = null, $min_id = null, $max_id = null ) { |
|
65 | $args = array( 'orderby' => 'ID', 'posts_per_page' => -1 ); |
|
@@ 168-188 (lines=21) @@ | ||
165 | return $wpdb->get_var( $query ); |
|
166 | } |
|
167 | ||
168 | public function comment_count( $status = null, $min_id = null, $max_id = null ) { |
|
169 | global $wpdb; |
|
170 | ||
171 | $comment_approved = $this->comment_status_to_approval_value( $status ); |
|
172 | ||
173 | if ( $comment_approved !== false ) { |
|
174 | $where = "comment_approved = '" . esc_sql( $comment_approved ) . "'"; |
|
175 | } else { |
|
176 | $where = "1=1"; |
|
177 | } |
|
178 | ||
179 | if ( $min_id != null ) { |
|
180 | $where .= " AND comment_ID >= " . intval( $min_id ); |
|
181 | } |
|
182 | ||
183 | if ( $max_id != null ) { |
|
184 | $where .= " AND comment_ID <= " . intval( $max_id ); |
|
185 | } |
|
186 | ||
187 | return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE $where" ); |
|
188 | } |
|
189 | ||
190 | private function comment_status_to_approval_value( $status ) { |
|
191 | switch ( $status ) { |