Code Duplication    Length = 14-16 lines in 2 locations

modules/sharedaddy/sharing-service.php 1 location

@@ 497-510 (lines=14) @@
494
		return $totals;
495
	}
496
497
	public function get_posts_total() {
498
		$totals = array();
499
		global $wpdb, $blog_id;
500
501
		$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 ) );
502
503
		if ( ! empty( $my_data ) ) {
504
			foreach ( $my_data as $row ) {
505
				$totals[] = new Sharing_Post_Total( $row->id, $row->total );
506
			}
507
		}
508
509
		usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
510
511
		return $totals;
512
	}
513
}

modules/sharedaddy/sharing-sources.php 1 location

@@ 348-363 (lines=16) @@
345
		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 ) );
346
	}
347
348
	public function get_posts_total() {
349
		global $wpdb, $blog_id;
350
351
		$totals = array();
352
		$name	= strtolower( $this->get_id() );
353
354
		$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 ) );
355
356
		if ( ! empty( $my_data ) ) {
357
			foreach ( $my_data as $row ) {
358
				$totals[] = new Sharing_Post_Total( $row->id, $row->total );
359
			}
360
		}
361
362
		usort( $totals, array( 'Sharing_Post_Total', 'cmp' ) );
363
364
		return $totals;
365
	}
366