@@ 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 |
@@ 437-450 (lines=14) @@ | ||
434 | return $totals; |
|
435 | } |
|
436 | ||
437 | public function get_posts_total() { |
|
438 | $totals = array(); |
|
439 | global $wpdb, $blog_id; |
|
440 | ||
441 | $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 ) ); |
|
442 | ||
443 | if ( !empty( $my_data ) ) |
|
444 | foreach( $my_data as $row ) |
|
445 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
446 | ||
447 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
448 | ||
449 | return $totals; |
|
450 | } |
|
451 | } |
|
452 | ||
453 | class Sharing_Service_Total { |