| @@ 284-299 (lines=16) @@ | ||
| 281 | 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 ) ); |
|
| 282 | } |
|
| 283 | ||
| 284 | public function get_posts_total() { |
|
| 285 | global $wpdb, $blog_id; |
|
| 286 | ||
| 287 | $totals = array(); |
|
| 288 | $name = strtolower( $this->get_id() ); |
|
| 289 | ||
| 290 | $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 ) ); |
|
| 291 | ||
| 292 | if ( !empty( $my_data ) ) |
|
| 293 | foreach( $my_data as $row ) |
|
| 294 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
| 295 | ||
| 296 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
| 297 | ||
| 298 | return $totals; |
|
| 299 | } |
|
| 300 | ||
| 301 | public function process_request( $post, array $post_data ) { |
|
| 302 | /** |
|
| @@ 453-466 (lines=14) @@ | ||
| 450 | return $totals; |
|
| 451 | } |
|
| 452 | ||
| 453 | public function get_posts_total() { |
|
| 454 | $totals = array(); |
|
| 455 | global $wpdb, $blog_id; |
|
| 456 | ||
| 457 | $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 ) ); |
|
| 458 | ||
| 459 | if ( !empty( $my_data ) ) |
|
| 460 | foreach( $my_data as $row ) |
|
| 461 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
| 462 | ||
| 463 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
| 464 | ||
| 465 | return $totals; |
|
| 466 | } |
|
| 467 | } |
|
| 468 | ||
| 469 | class Sharing_Service_Total { |
|