@@ 41-61 (lines=21) @@ | ||
38 | // noop right now |
|
39 | } |
|
40 | ||
41 | public function post_count( $status = null, $min_id = null, $max_id = null ) { |
|
42 | global $wpdb; |
|
43 | ||
44 | $where = ''; |
|
45 | ||
46 | if ( $status ) { |
|
47 | $where = "post_status = '" . esc_sql( $status ) . "'"; |
|
48 | } else { |
|
49 | $where = '1=1'; |
|
50 | } |
|
51 | ||
52 | if ( null != $min_id ) { |
|
53 | $where .= ' AND ID >= ' . intval( $min_id ); |
|
54 | } |
|
55 | ||
56 | if ( null != $max_id ) { |
|
57 | $where .= ' AND ID <= ' . intval( $max_id ); |
|
58 | } |
|
59 | ||
60 | return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE $where" ); |
|
61 | } |
|
62 | ||
63 | // TODO: actually use max_id/min_id |
|
64 | public function get_posts( $status = null, $min_id = null, $max_id = null ) { |
|
@@ 157-177 (lines=21) @@ | ||
154 | return $this->table_checksum( $wpdb->postmeta, Defaults::$default_post_meta_checksum_columns, 'meta_id', Settings::get_whitelisted_post_meta_sql(), $min_id, $max_id ); |
|
155 | } |
|
156 | ||
157 | public function comment_count( $status = null, $min_id = null, $max_id = null ) { |
|
158 | global $wpdb; |
|
159 | ||
160 | $comment_approved = $this->comment_status_to_approval_value( $status ); |
|
161 | ||
162 | if ( $comment_approved !== false ) { |
|
163 | $where = "comment_approved = '" . esc_sql( $comment_approved ) . "'"; |
|
164 | } else { |
|
165 | $where = '1=1'; |
|
166 | } |
|
167 | ||
168 | if ( $min_id != null ) { |
|
169 | $where .= ' AND comment_ID >= ' . intval( $min_id ); |
|
170 | } |
|
171 | ||
172 | if ( $max_id != null ) { |
|
173 | $where .= ' AND comment_ID <= ' . intval( $max_id ); |
|
174 | } |
|
175 | ||
176 | return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE $where" ); |
|
177 | } |
|
178 | ||
179 | private function comment_status_to_approval_value( $status ) { |
|
180 | switch ( $status ) { |