@@ 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 ( null != $min_id ) { |
|
54 | $where .= ' AND ID >= ' . intval( $min_id ); |
|
55 | } |
|
56 | ||
57 | if ( null != $max_id ) { |
|
58 | $where .= ' AND ID <= ' . intval( $max_id ); |
|
59 | } |
|
60 | ||
61 | return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE $where" ); |
|
62 | } |
|
63 | ||
64 | // TODO: actually use max_id/min_id |
|
65 | public function get_posts( $status = null, $min_id = null, $max_id = null ) { |
|
@@ 150-170 (lines=21) @@ | ||
147 | return $this->table_checksum( $wpdb->posts, Jetpack_Sync_Defaults::$default_post_checksum_columns , 'ID', Jetpack_Sync_Defaults::get_blacklisted_post_types_sql(), $min_id, $max_id ); |
|
148 | } |
|
149 | ||
150 | public function comment_count( $status = null, $min_id = null, $max_id = null ) { |
|
151 | global $wpdb; |
|
152 | ||
153 | $comment_approved = $this->comment_status_to_approval_value( $status ); |
|
154 | ||
155 | if ( $comment_approved !== false ) { |
|
156 | $where = "comment_approved = '" . esc_sql( $comment_approved ) . "'"; |
|
157 | } else { |
|
158 | $where = '1=1'; |
|
159 | } |
|
160 | ||
161 | if ( $min_id != null ) { |
|
162 | $where .= ' AND comment_ID >= ' . intval( $min_id ); |
|
163 | } |
|
164 | ||
165 | if ( $max_id != null ) { |
|
166 | $where .= ' AND comment_ID <= ' . intval( $max_id ); |
|
167 | } |
|
168 | ||
169 | return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE $where" ); |
|
170 | } |
|
171 | ||
172 | private function comment_status_to_approval_value( $status ) { |
|
173 | switch ( $status ) { |