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 );
@@ 1433-1441 (lines=9) @@
1430
		}
1431
	}
1432
1433
	public function process_request( $post, array $post_data ) {
1434
		// Record stats
1435
		parent::process_request( $post, $post_data );
1436
1437
		// Redirect to Tumblr's sharing endpoint (a la their bookmarklet)
1438
		$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=';
1439
		wp_redirect( $url );
1440
		die();
1441
	}
1442
1443
	public function display_footer() {
1444
		if ( $this->smart ) {
@@ 1622-1629 (lines=8) @@
1619
		return __( 'Pocket', 'jetpack' );
1620
	}
1621
1622
	public function process_request( $post, array $post_data ) {
1623
		// Record stats
1624
		parent::process_request( $post, $post_data );
1625
1626
		$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 ) ) );
1627
		wp_redirect( $pocket_url );
1628
		exit;
1629
	}
1630
1631
	public function get_display( $post ) {
1632
		if ( $this->smart ) {
@@ 1677-1684 (lines=8) @@
1674
	public function get_name() {
1675
		return __( 'Telegram', 'jetpack' );
1676
	}
1677
	public function process_request( $post, array $post_data ) {
1678
		// Record stats
1679
		parent::process_request( $post, $post_data );
1680
		$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 ) ) );
1681
		wp_redirect( $telegram_url );
1682
		exit;
1683
	}
1684
1685
	public function get_display( $post ) {
1686
		return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Telegram', 'share to', 'jetpack' ), __( 'Click to share on Telegram', 'jetpack' ), 'share=telegram' );
1687
	}
@@ 1709-1715 (lines=7) @@
1706
		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' );
1707
	}
1708
1709
	public function process_request( $post, array $post_data ) {
1710
		// Record stats
1711
		parent::process_request( $post, $post_data );
1712
		$url = 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) . ' ' . $this->get_share_url( $post->ID ) );
1713
		wp_redirect( $url );
1714
		exit;
1715
	}
1716
}
1717
1718
class Share_Skype extends Sharing_Source {