|
@@ 61-81 (lines=21) @@
|
| 58 |
|
return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->term_relationships" ); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
public function post_count( $status = null, $min_id = null, $max_id = null ) { |
| 62 |
|
global $wpdb; |
| 63 |
|
|
| 64 |
|
$where = ''; |
| 65 |
|
|
| 66 |
|
if ( $status ) { |
| 67 |
|
$where = "post_status = '" . esc_sql( $status ) . "'"; |
| 68 |
|
} else { |
| 69 |
|
$where = '1=1'; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
if ( null != $min_id ) { |
| 73 |
|
$where .= ' AND ID >= ' . intval( $min_id ); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
if ( null != $max_id ) { |
| 77 |
|
$where .= ' AND ID <= ' . intval( $max_id ); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE $where" ); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
// TODO: actually use max_id/min_id |
| 84 |
|
public function get_posts( $status = null, $min_id = null, $max_id = null ) { |
|
@@ 177-197 (lines=21) @@
|
| 174 |
|
return $this->table_checksum( $wpdb->postmeta, Defaults::$default_post_meta_checksum_columns, 'meta_id', Settings::get_whitelisted_post_meta_sql(), $min_id, $max_id ); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
public function comment_count( $status = null, $min_id = null, $max_id = null ) { |
| 178 |
|
global $wpdb; |
| 179 |
|
|
| 180 |
|
$comment_approved = $this->comment_status_to_approval_value( $status ); |
| 181 |
|
|
| 182 |
|
if ( $comment_approved !== false ) { |
| 183 |
|
$where = "comment_approved = '" . esc_sql( $comment_approved ) . "'"; |
| 184 |
|
} else { |
| 185 |
|
$where = '1=1'; |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
if ( $min_id != null ) { |
| 189 |
|
$where .= ' AND comment_ID >= ' . intval( $min_id ); |
| 190 |
|
} |
| 191 |
|
|
| 192 |
|
if ( $max_id != null ) { |
| 193 |
|
$where .= ' AND comment_ID <= ' . intval( $max_id ); |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE $where" ); |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
private function comment_status_to_approval_value( $status ) { |
| 200 |
|
switch ( $status ) { |