Code Duplication    Length = 14-16 lines in 2 locations

modules/sharedaddy/sharing-service.php 1 location

@@ 486-499 (lines=14) @@
483
		return $totals;
484
	}
485
486
	public function get_posts_total() {
487
		$totals = array();
488
		global $wpdb, $blog_id;
489
490
		$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 ) );
491
492
		if ( ! empty( $my_data ) ) {
493
			foreach ( $my_data as $row ) {
494
				$totals[] = new Sharing_Post_Total( $row->id, $row->total );
495
			}
496
		}
497
498
		usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
499
500
		return $totals;
501
	}
502
}

modules/sharedaddy/sharing-sources.php 1 location

@@ 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