@@ 488-501 (lines=14) @@ | ||
485 | return $totals; |
|
486 | } |
|
487 | ||
488 | public function get_posts_total() { |
|
489 | $totals = array(); |
|
490 | global $wpdb, $blog_id; |
|
491 | ||
492 | $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 ) ); |
|
493 | ||
494 | if ( ! empty( $my_data ) ) { |
|
495 | foreach ( $my_data as $row ) { |
|
496 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
497 | } |
|
498 | } |
|
499 | ||
500 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
501 | ||
502 | return $totals; |
|
503 | } |
|
504 | } |
@@ 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 |