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