@@ 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 | /** |
@@ 409-422 (lines=14) @@ | ||
406 | return $totals; |
|
407 | } |
|
408 | ||
409 | public function get_posts_total() { |
|
410 | $totals = array(); |
|
411 | global $wpdb, $blog_id; |
|
412 | ||
413 | $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 ) ); |
|
414 | ||
415 | if ( !empty( $my_data ) ) |
|
416 | foreach( $my_data as $row ) |
|
417 | $totals[] = new Sharing_Post_Total( $row->id, $row->total ); |
|
418 | ||
419 | usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) ); |
|
420 | ||
421 | return $totals; |
|
422 | } |
|
423 | } |
|
424 | ||
425 | class Sharing_Service_Total { |