| @@ 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 | ||
| @@ 497-510 (lines=14) @@ | ||
| 494 | return $totals; |
|
| 495 | } |
|
| 496 | ||
| 497 | public function get_posts_total() { |
|
| 498 | $totals = array(); |
|
| 499 | global $wpdb, $blog_id; |
|
| 500 | ||
| 501 | $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 ) ); |
|
| 502 | ||
| 503 | if ( ! empty( $my_data ) ) { |
|
| 504 | foreach ( $my_data as $row ) { |
|
| 505 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
| 506 | } |
|
| 507 | } |
|
| 508 | ||
| 509 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
| 510 | ||
| 511 | return $totals; |
|
| 512 | } |
|
| 513 | } |
|