Code Duplication    Length = 8-10 lines in 5 locations

modules/sharedaddy/sharing-sources.php 5 locations

@@ 755-764 (lines=10) @@
752
			return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Reddit', 'share to', 'jetpack' ), __( 'Click to share on Reddit', 'jetpack' ), 'share=reddit' );
753
	}
754
755
	public function process_request( $post, array $post_data ) {
756
		$reddit_url = $this->http() . '://reddit.com/submit?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&title=' . rawurlencode( $this->get_share_title( $post->ID ) );
757
758
		// Record stats
759
		parent::process_request( $post, $post_data );
760
761
		// Redirect to Reddit
762
		wp_redirect( $reddit_url );
763
		die();
764
	}
765
}
766
767
class Share_LinkedIn extends Sharing_Source {
@@ 931-940 (lines=10) @@
928
		return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Facebook', 'share to', 'jetpack' ), __( 'Click to share on Facebook', 'jetpack' ), 'share=facebook', 'sharing-facebook-' . $post->ID );
929
	}
930
931
	public function process_request( $post, array $post_data ) {
932
		$fb_url = $this->http() . '://www.facebook.com/sharer.php?u=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&t=' . rawurlencode( $this->get_share_title( $post->ID ) );
933
934
		// Record stats
935
		parent::process_request( $post, $post_data );
936
937
		// Redirect to Facebook
938
		wp_redirect( $fb_url );
939
		die();
940
	}
941
942
	public function display_footer() {
943
		$this->js_dialog( $this->shortname );
@@ 1374-1382 (lines=9) @@
1371
		}
1372
	}
1373
1374
	public function process_request( $post, array $post_data ) {
1375
		// Record stats
1376
		parent::process_request( $post, $post_data );
1377
1378
		// Redirect to Tumblr's sharing endpoint (a la their bookmarklet)
1379
		$url = 'https://www.tumblr.com/share?v=3&u=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&t=' . rawurlencode( $this->get_share_title( $post->ID ) ) . '&s=';
1380
		wp_redirect( $url );
1381
		die();
1382
	}
1383
	// http://www.tumblr.com/share?v=3&u=URL&t=TITLE&s=
1384
	public function display_footer() {
1385
		if ( $this->smart ) {
@@ 1559-1566 (lines=8) @@
1556
		return __( 'Pocket', 'jetpack' );
1557
	}
1558
1559
	public function process_request( $post, array $post_data ) {
1560
		// Record stats
1561
		parent::process_request( $post, $post_data );
1562
1563
		$pocket_url = esc_url_raw( 'https://getpocket.com/save/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&title=' . rawurlencode( $this->get_share_title( $post->ID ) ) );
1564
		wp_redirect( $pocket_url );
1565
		exit;
1566
	}
1567
1568
	public function get_display( $post ) {
1569
		if ( $this->smart ) {
@@ 1614-1621 (lines=8) @@
1611
	public function get_name() {
1612
		return __( 'Telegram', 'jetpack' );
1613
	}
1614
	public function process_request( $post, array $post_data ) {
1615
		// Record stats
1616
		parent::process_request( $post, $post_data );
1617
		$telegram_url = esc_url_raw( 'https://telegram.me/share/url?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&text=' . rawurlencode( $this->get_share_title( $post->ID ) ) );
1618
		wp_redirect( $telegram_url );
1619
		exit;
1620
	}
1621
1622
	public function get_display( $post ) {
1623
		return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Telegram', 'share to', 'jetpack' ), __( 'Click to share on Telegram', 'jetpack' ), 'share=telegram' );
1624
	}