Code Duplication    Length = 7-10 lines in 6 locations

modules/sharedaddy/sharing-sources.php 6 locations

@@ 867-876 (lines=10) @@
864
		}
865
	}
866
867
	public function process_request( $post, array $post_data ) {
868
		$reddit_url = $this->http() . '://reddit.com/submit?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&title=' . rawurlencode( $this->get_share_title( $post->ID ) );
869
870
		// Record stats
871
		parent::process_request( $post, $post_data );
872
873
		// Redirect to Reddit
874
		wp_redirect( $reddit_url );
875
		die();
876
	}
877
}
878
879
class Share_LinkedIn extends Sharing_Source {
@@ 1045-1054 (lines=10) @@
1042
		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 );
1043
	}
1044
1045
	public function process_request( $post, array $post_data ) {
1046
		$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 ) );
1047
1048
		// Record stats
1049
		parent::process_request( $post, $post_data );
1050
1051
		// Redirect to Facebook
1052
		wp_redirect( $fb_url );
1053
		die();
1054
	}
1055
1056
	public function display_footer() {
1057
		$this->js_dialog( $this->shortname );
@@ 1425-1433 (lines=9) @@
1422
		}
1423
	}
1424
1425
	public function process_request( $post, array $post_data ) {
1426
		// Record stats
1427
		parent::process_request( $post, $post_data );
1428
1429
		// Redirect to Tumblr's sharing endpoint (a la their bookmarklet)
1430
		$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=';
1431
		wp_redirect( $url );
1432
		die();
1433
	}
1434
1435
	public function display_footer() {
1436
		if ( $this->smart ) {
@@ 1614-1621 (lines=8) @@
1611
		return __( 'Pocket', 'jetpack' );
1612
	}
1613
1614
	public function process_request( $post, array $post_data ) {
1615
		// Record stats
1616
		parent::process_request( $post, $post_data );
1617
1618
		$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 ) ) );
1619
		wp_redirect( $pocket_url );
1620
		exit;
1621
	}
1622
1623
	public function get_display( $post ) {
1624
		if ( $this->smart ) {
@@ 1669-1676 (lines=8) @@
1666
	public function get_name() {
1667
		return __( 'Telegram', 'jetpack' );
1668
	}
1669
	public function process_request( $post, array $post_data ) {
1670
		// Record stats
1671
		parent::process_request( $post, $post_data );
1672
		$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 ) ) );
1673
		wp_redirect( $telegram_url );
1674
		exit;
1675
	}
1676
1677
	public function get_display( $post ) {
1678
		return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Telegram', 'share to', 'jetpack' ), __( 'Click to share on Telegram', 'jetpack' ), 'share=telegram' );
1679
	}
@@ 1701-1707 (lines=7) @@
1698
		return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ), 'share=jetpack-whatsapp' );
1699
	}
1700
1701
	public function process_request( $post, array $post_data ) {
1702
		// Record stats
1703
		parent::process_request( $post, $post_data );
1704
		$url = 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) . ' ' . $this->get_share_url( $post->ID ) );
1705
		wp_redirect( $url );
1706
		exit;
1707
	}
1708
}
1709
1710
class Share_Skype extends Sharing_Source {