From 0744769334a5c4dd695129dc89613a4117867903 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Thu, 17 Dec 2015 13:07:03 +0100 Subject: [PATCH] Sharing: add new Skype sharing button Fixes #3170 --- modules/sharedaddy/sharing-service.php | 1 + modules/sharedaddy/sharing-sources.php | 85 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/modules/sharedaddy/sharing-service.php b/modules/sharedaddy/sharing-service.php index 8b72e1c1cfa91..0ddfd027d4eb2 100644 --- a/modules/sharedaddy/sharing-service.php +++ b/modules/sharedaddy/sharing-service.php @@ -55,6 +55,7 @@ public function get_all_services( $include_custom = true ) { 'tumblr' => 'Share_Tumblr', 'pinterest' => 'Share_Pinterest', 'pocket' => 'Share_Pocket', + 'skype' => 'Share_Skype', ); if ( $include_custom ) { diff --git a/modules/sharedaddy/sharing-sources.php b/modules/sharedaddy/sharing-sources.php index 1dcaa5a164852..1fd152cc071ef 100644 --- a/modules/sharedaddy/sharing-sources.php +++ b/modules/sharedaddy/sharing-sources.php @@ -1601,3 +1601,88 @@ function jetpack_sharing_pocket_init() { } } + +class Share_Skype extends Sharing_Source { + public $shortname = 'skype'; + public $genericon = '\f220'; + private $share_type = 'default'; + + public function __construct( $id, array $settings ) { + parent::__construct( $id, $settings ); + + if ( isset( $settings['share_type'] ) ) + $this->share_type = $settings['share_type']; + + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; + } + + public function get_name() { + return __( 'Skype', 'jetpack' ); + } + + public function display_header() { + } + + public function get_display( $post ) { + if ( $this->smart ) { + $skype_share_html = sprintf( + '
', + esc_attr( $this->get_share_url( $post->ID ) ), + 'en-US' + ); + return $skype_share_html; + } + + /** This filter is already documented in modules/sharedaddy/sharing-sources.php */ + if ( apply_filters( 'jetpack_register_post_for_share_counts', true, $post->ID, 'skype' ) ) { + sharing_register_post_for_share_counts( $post->ID ); + } + return $this->get_link( + $this->get_process_request_url( $post->ID ), _x( 'Skype', 'share to', 'jetpack' ), __( 'Share on Skype', 'jetpack' ), 'share=skype', 'sharing-skype-' . $post->ID ); + } + + public function process_request( $post, array $post_data ) { + $skype_url = sprintf( + 'https://web.skype.com/share?url=%1$s&lang=%2$s=&source=jetpack', + rawurlencode( $this->get_share_url( $post->ID ) ), + 'en-US' + ); + + // Record stats + parent::process_request( $post, $post_data ); + + // Redirect to Skype + wp_redirect( $skype_url ); + die(); + } + + public function display_footer() { + if ( $this->smart ) : + ?> + + js_dialog( $this->shortname, array( 'width' => 305, 'height' => 665 ) ); + endif; + } +}