@@ 310-325 (lines=16) @@ | ||
307 | return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT count FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s', $blog_id, $post->ID, $name ) ); |
|
308 | } |
|
309 | ||
310 | public function get_posts_total() { |
|
311 | global $wpdb, $blog_id; |
|
312 | ||
313 | $totals = array(); |
|
314 | $name = strtolower( $this->get_id() ); |
|
315 | ||
316 | $my_data = $wpdb->get_results( $wpdb->prepare( 'SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d AND share_service = %s GROUP BY post_id ORDER BY count DESC ', $blog_id, $name ) ); |
|
317 | ||
318 | if ( ! empty( $my_data ) ) { |
|
319 | foreach ( $my_data as $row ) { |
|
320 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
321 | } |
|
322 | } |
|
323 | ||
324 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
325 | ||
326 | return $totals; |
|
327 | } |
|
328 |
@@ 485-498 (lines=14) @@ | ||
482 | return $totals; |
|
483 | } |
|
484 | ||
485 | public function get_posts_total() { |
|
486 | $totals = array(); |
|
487 | global $wpdb, $blog_id; |
|
488 | ||
489 | $my_data = $wpdb->get_results( $wpdb->prepare( 'SELECT post_id as id, SUM( count ) as total FROM sharing_stats WHERE blog_id = %d GROUP BY post_id ORDER BY count DESC ', $blog_id ) ); |
|
490 | ||
491 | if ( ! empty( $my_data ) ) { |
|
492 | foreach ( $my_data as $row ) { |
|
493 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
494 | } |
|
495 | } |
|
496 | ||
497 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
498 | ||
499 | return $totals; |
|
500 | } |
|
501 | } |