| @@ 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 | ||
| @@ 450-463 (lines=14) @@ | ||
| 447 | return $totals; | |
| 448 | } | |
| 449 | ||
| 450 | 	public function get_posts_total() { | |
| 451 | $totals = array(); | |
| 452 | global $wpdb, $blog_id; | |
| 453 | ||
| 454 | $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 ) ); | |
| 455 | ||
| 456 | if ( !empty( $my_data ) ) | |
| 457 | foreach( $my_data as $row ) | |
| 458 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); | |
| 459 | ||
| 460 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); | |
| 461 | ||
| 462 | return $totals; | |
| 463 | } | |
| 464 | } | |
| 465 | ||
| 466 | class Sharing_Service_Total { | |