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