@@ 295-310 (lines=16) @@ | ||
292 | 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 ) ); |
|
293 | } |
|
294 | ||
295 | public function get_posts_total() { |
|
296 | global $wpdb, $blog_id; |
|
297 | ||
298 | $totals = array(); |
|
299 | $name = strtolower( $this->get_id() ); |
|
300 | ||
301 | $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 ) ); |
|
302 | ||
303 | if ( ! empty( $my_data ) ) { |
|
304 | foreach ( $my_data as $row ) { |
|
305 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
306 | } |
|
307 | } |
|
308 | ||
309 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
310 | ||
311 | return $totals; |
|
312 | } |
|
313 |
@@ 418-431 (lines=14) @@ | ||
415 | return $totals; |
|
416 | } |
|
417 | ||
418 | public function get_posts_total() { |
|
419 | $totals = array(); |
|
420 | global $wpdb, $blog_id; |
|
421 | ||
422 | $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 ) ); |
|
423 | ||
424 | if ( !empty( $my_data ) ) |
|
425 | foreach( $my_data as $row ) |
|
426 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
427 | ||
428 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
429 | ||
430 | return $totals; |
|
431 | } |
|
432 | } |
|
433 | ||
434 | class Sharing_Service_Total { |