diff options
Diffstat (limited to 'plugins/jetpack/modules/sharedaddy/sharing-sources.php')
-rw-r--r-- | plugins/jetpack/modules/sharedaddy/sharing-sources.php | 93 |
1 files changed, 54 insertions, 39 deletions
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-sources.php b/plugins/jetpack/modules/sharedaddy/sharing-sources.php index 679449e1..6df9b210 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing-sources.php +++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php @@ -367,10 +367,9 @@ abstract class Sharing_Advanced_Source extends Sharing_Source { abstract public function get_options(); } - class Share_Email extends Sharing_Source { public $shortname = 'email'; - public $genericon = '\f410'; + public $icon = '\f410'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -554,7 +553,7 @@ class Share_Email extends Sharing_Source { class Share_Twitter extends Sharing_Source { public $shortname = 'twitter'; - public $genericon = '\f202'; + public $icon = '\f202'; // 'https://dev.twitter.com/rest/reference/get/help/configuration' ( 2015/02/06 ) short_url_length is 22, short_url_length_https is 23 public $short_url_length = 24; @@ -572,7 +571,14 @@ class Share_Twitter extends Sharing_Source { return __( 'Twitter', 'jetpack' ); } - function sharing_twitter_via( $post ) { + /** + * Determine the Twitter 'via' value for a post. + * + * @param WP_Post|int $post Post object or post ID. + * @return string Twitter handle without the preceding @. + **/ + public static function sharing_twitter_via( $post ) { + $post = get_post( $post ); /** * Allow third-party plugins to customize the Twitter username used as "twitter:site" Twitter Card Meta Tag. * @@ -611,7 +617,14 @@ class Share_Twitter extends Sharing_Source { return preg_replace( '/[^\da-z_]+/i', '', $twitter_site_tag_value ); } - public function get_related_accounts( $post ) { + /** + * Determine the 'related' Twitter accounts for a post. + * + * @param WP_Post|int $post Post object or post ID. + * @return string Comma-separated list of Twitter handles. + **/ + public static function get_related_accounts( $post ) { + $post = get_post( $post ); /** * Filter the list of related Twitter accounts added to the Twitter sharing button. * @@ -752,7 +765,7 @@ class Share_Twitter extends Sharing_Source { class Share_Reddit extends Sharing_Source { public $shortname = 'reddit'; - public $genericon = '\f222'; + public $icon = '\f222'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -789,7 +802,7 @@ class Share_Reddit extends Sharing_Source { class Share_LinkedIn extends Sharing_Source { public $shortname = 'linkedin'; - public $genericon = '\f207'; + public $icon = '\f207'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -865,7 +878,7 @@ class Share_LinkedIn extends Sharing_Source { class Share_Facebook extends Sharing_Source { public $shortname = 'facebook'; - public $genericon = '\f204'; + public $icon = '\f204'; private $share_type = 'default'; public function __construct( $id, array $settings ) { @@ -1000,7 +1013,7 @@ class Share_Facebook extends Sharing_Source { class Share_Print extends Sharing_Source { public $shortname = 'print'; - public $genericon = '\f469'; + public $icon = '\f469'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1022,7 +1035,7 @@ class Share_Print extends Sharing_Source { class Share_PressThis extends Sharing_Source { public $shortname = 'pressthis'; - public $genericon = '\f205'; + public $icon = '\f205'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1098,7 +1111,7 @@ class Share_PressThis extends Sharing_Source { class Share_GooglePlus1 extends Sharing_Source { public $shortname = 'googleplus1'; - public $genericon = '\f218'; + public $icon = '\f218'; private $state = false; public function __construct( $id, array $settings ) { @@ -1269,11 +1282,12 @@ class Share_Custom extends Sharing_Advanced_Source { $tagged = ''; if ( $tags ) { + $tagged_raw = array(); foreach ( $tags as $tag ) { - $tagged[] = rawurlencode( $tag->name ); + $tagged_raw[] = rawurlencode( $tag->name ); } - $tagged = implode( ',', $tagged ); + $tagged = implode( ',', $tagged_raw ); } $url = str_replace( '%post_tags%', $tagged, $url ); @@ -1399,7 +1413,7 @@ class Share_Custom extends Sharing_Advanced_Source { class Share_Tumblr extends Sharing_Source { public $shortname = 'tumblr'; - public $genericon = '\f214'; + public $icon = '\f214'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); if ( 'official' == $this->button_style ) { @@ -1447,7 +1461,7 @@ class Share_Tumblr extends Sharing_Source { class Share_Pinterest extends Sharing_Source { public $shortname = 'pinterest'; - public $genericon = '\f209'; + public $icon = '\f209'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1599,7 +1613,7 @@ class Share_Pinterest extends Sharing_Source { class Share_Pocket extends Sharing_Source { public $shortname = 'pocket'; - public $genericon = '\f224'; + public $icon = '\f224'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1699,13 +1713,13 @@ class Jetpack_Share_WhatsApp extends Sharing_Source { } public function get_display( $post ) { - return $this->get_link( 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) ) . ' ' . rawurlencode( $this->get_share_url( $post->ID ) ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ) ); + return $this->get_link( 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) . ' ' . $this->get_share_url( $post->ID ) ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ) ); } } class Share_Skype extends Sharing_Source { public $shortname = 'skype'; - public $genericon = '\f220'; + public $icon = '\f220'; private $share_type = 'default'; public function __construct( $id, array $settings ) { @@ -1720,6 +1734,7 @@ class Share_Skype extends Sharing_Source { } else { $this->smart = false; } + } public function get_name() { @@ -1741,7 +1756,7 @@ class Share_Skype extends Sharing_Source { 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 ); + $this->get_process_request_url( $post->ID ), _x( 'Skype', 'share to', 'jetpack' ), __( 'Click to share on Skype', 'jetpack' ), 'share=skype', 'sharing-skype-' . $post->ID ); } public function process_request( $post, array $post_data ) { @@ -1761,26 +1776,26 @@ class Share_Skype extends Sharing_Source { public function display_footer() { if ( $this->smart ) : - ?> - <script> - (function(r, d, s) { - r.loadSkypeWebSdkAsync = r.loadSkypeWebSdkAsync || function(p) { - var js, sjs = d.getElementsByTagName(s)[0]; - if (d.getElementById(p.id)) { return; } - js = d.createElement(s); - js.id = p.id; - js.src = p.scriptToLoad; - js.onload = p.callback - sjs.parentNode.insertBefore(js, sjs); - }; - var p = { - scriptToLoad: 'https://swx.cdn.skype.com/shared/v/latest/skypewebsdk.js', - id: 'skype_web_sdk' - }; - r.loadSkypeWebSdkAsync(p); - })(window, document, 'script'); - </script> - <?php + ?> + <script> + (function(r, d, s) { + r.loadSkypeWebSdkAsync = r.loadSkypeWebSdkAsync || function(p) { + var js, sjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(p.id)) { return; } + js = d.createElement(s); + js.id = p.id; + js.src = p.scriptToLoad; + js.onload = p.callback + sjs.parentNode.insertBefore(js, sjs); + }; + var p = { + scriptToLoad: 'https://swx.cdn.skype.com/shared/v/latest/skypewebsdk.js', + id: 'skype_web_sdk' + }; + r.loadSkypeWebSdkAsync(p); + })(window, document, 'script'); + </script> + <?php else : $this->js_dialog( $this->shortname, array( 'width' => 305, 'height' => 665 ) ); endif; |