summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2019-04-28 17:39:03 -0400
committerYury German <blueknight@gentoo.org>2019-04-28 17:39:03 -0400
commit2ab16973706e120bc344c83be6295b54fd908c57 (patch)
tree358267a52d9542c77c90e3663cea32d13b8cb639 /plugins/jetpack/modules/sharedaddy/sharing-sources.php
parentUpdate twentysixteen 1.7 (diff)
downloadblogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.gz
blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.bz2
blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.zip
Updating packages for 5.1.1
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/sharedaddy/sharing-sources.php')
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-sources.php228
1 files changed, 110 insertions, 118 deletions
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-sources.php b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
index a77a6cbf..4ed1d270 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing-sources.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php
@@ -30,6 +30,10 @@ abstract class Sharing_Source {
}
}
+ public function is_deprecated() {
+ return false;
+ }
+
public function http() {
return is_ssl() ? 'https' : 'http';
}
@@ -263,11 +267,21 @@ abstract class Sharing_Source {
$klasses[] = 'no-icon';
}
+ $is_deprecated = $this->is_deprecated();
+
$link = sprintf(
'<a rel="nofollow" class="%s" href="javascript:void(0)" title="%s"><span>%s</span></a>',
implode( ' ', $klasses ),
- $this->get_name(),
- $text
+ esc_attr(
+ $is_deprecated
+ ? sprintf( __( 'The %1$s service has shut down. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $this->get_name() )
+ : $this->get_name()
+ ),
+ esc_html(
+ $is_deprecated
+ ? sprintf( __( '%1$s has shut down', 'jetpack' ), $this->get_name() )
+ : $text
+ )
);
$smart = ( $this->smart || $force_smart ) ? 'on' : 'off';
@@ -358,6 +372,62 @@ abstract class Sharing_Source {
}
}
+abstract class Deprecated_Sharing_Source extends Sharing_Source {
+ public $button_style = 'text';
+ public $smart = false;
+ protected $open_link_in_new = false;
+ protected $id;
+ protected $deprecated = true;
+
+ final public function __construct( $id, array $settings ) {
+ $this->id = $id;
+
+ if ( isset( $settings['button_style'] ) ) {
+ $this->button_style = $settings['button_style'];
+ }
+ }
+
+ final public function is_deprecated() {
+ return true;
+ }
+
+ final public function get_share_url( $post_id ) {
+ return get_permalink( $post_id );
+ }
+
+ final public function display_preview( $echo = true, $force_smart = false, $button_style = null ) {
+ return parent::display_preview( $echo, false, $button_style );
+ }
+
+ final public function get_total( $post = false ) {
+ return 0;
+ }
+
+ final public function get_posts_total() {
+ return 0;
+ }
+
+ final public function process_request( $post, array $post_data ) {
+ parent::process_request( $post, $post_data );
+ }
+
+ final public function get_display( $post ) {
+ if ( current_user_can( 'manage_options' ) ) {
+ return $this->display_deprecated( $post );
+ }
+
+ return '';
+ }
+
+ public function display_deprecated( $post ) {
+ return $this->get_link(
+ $this->get_share_url( $post->ID ),
+ sprintf( __( '%1$s has shut down', 'jetpack' ), $this->get_name() ),
+ sprintf( __( 'The %1$s service has shut down. This sharing button is not displayed to your visitors and should be removed.', 'jetpack' ), $this->get_name() )
+ );
+ }
+}
+
abstract class Sharing_Advanced_Source extends Sharing_Source {
public function has_advanced_options() {
return true;
@@ -1057,7 +1127,7 @@ class Share_PressThis extends Sharing_Source {
}
public function process_request( $post, array $post_data ) {
- global $current_user, $wp_version;
+ global $current_user;
$primary_blog = (int) get_user_meta( $current_user->ID, 'primary_blog', true );
if ( $primary_blog ) {
@@ -1088,16 +1158,8 @@ class Share_PressThis extends Sharing_Source {
'u' => rawurlencode( $this->get_share_url( $post->ID ) ),
);
- if ( version_compare( $wp_version, '4.9-RC1-42107', '>=' ) ) {
- $args[ 'url-scan-submit' ] = 'Scan';
- $args[ '_wpnonce' ] = wp_create_nonce( 'scan-site' );
-
- } else { // Remove once 4.9 is the minimum.
- $args['t'] = rawurlencode( $this->get_share_title( $post->ID ) );
- if ( isset( $_GET['sel'] ) ) {
- $args['s'] = rawurlencode( $_GET['sel'] );
- }
- }
+ $args[ 'url-scan-submit' ] = 'Scan';
+ $args[ '_wpnonce' ] = wp_create_nonce( 'scan-site' );
$url = $blog->siteurl . '/wp-admin/press-this.php';
$url = add_query_arg( $args, $url );
@@ -1115,110 +1177,11 @@ class Share_PressThis extends Sharing_Source {
}
}
-class Share_GooglePlus1 extends Sharing_Source {
+class Share_GooglePlus1 extends Deprecated_Sharing_Source {
public $shortname = 'googleplus1';
- public $icon = '\f218';
- private $state = false;
-
- public function __construct( $id, array $settings ) {
- parent::__construct( $id, $settings );
-
- if ( 'official' == $this->button_style ) {
- $this->smart = true;
- } else {
- $this->smart = false;
- }
- }
public function get_name() {
- return __( 'Google', 'jetpack' );
- }
-
- public function has_custom_button_style() {
- return $this->smart;
- }
-
- public function get_display( $post ) {
-
- if ( $this->smart ) {
- $share_url = $this->get_share_url( $post->ID );
- return '<div class="googleplus1_button"><div class="g-plus" data-action="share" data-annotation="bubble" data-href="' . esc_url( $share_url ) . '"></div></div>';
- } else {
- return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Google', 'share to', 'jetpack' ), __( 'Click to share on Google+', 'jetpack' ), 'share=google-plus-1', 'sharing-google-' . $post->ID );
- }
- }
-
- public function get_state() {
- return $this->state;
- }
-
- public function process_request( $post, array $post_data ) {
-
- if ( isset( $post_data['state'] ) ) {
- $this->state = $post_data['state'];
- }
- // Record stats
- parent::process_request( $post, $post_data );
-
- // Redirect to Google +'s sharing endpoint
- $url = 'https://plus.google.com/share?url=' . rawurlencode( $this->get_share_url( $post->ID ) );
- wp_redirect( $url );
- die();
- }
-
- public function display_footer() {
- global $post;
-
- if ( $this->smart ) { ?>
- <script>
- function renderGooglePlus1() {
- if ( 'undefined' === typeof gapi ) {
- return;
- }
-
- jQuery( '.g-plus' ).each(function() {
- var $button = jQuery( this );
-
- if ( ! $button.data( 'gplus-rendered' ) ) {
- gapi.plusone.render( this, {
- href: $button.attr( 'data-href' ),
- size: $button.attr( 'data-size' ),
- annotation: $button.attr( 'data-annotation' )
- });
-
- $button.data( 'gplus-rendered', true );
- }
- });
- }
-
- (function() {
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
- po.src = 'https://apis.google.com/js/platform.js';
- po.innerHTML = '{"parsetags": "explicit"}';
- po.onload = renderGooglePlus1;
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
- })();
-
- jQuery( document.body ).on( 'post-load', renderGooglePlus1 );
- </script>
- <?php
- } else {
- $this->js_dialog( 'google-plus-1', array( 'width' => 480, 'height' => 550 ) );
- }
- }
-
- public function get_total( $post = false ) {
- global $wpdb, $blog_id;
-
- $name = strtolower( $this->get_id() );
-
- if ( $post == false ) {
- // get total number of shares for service
- return $wpdb->get_var( $wpdb->prepare( 'SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s', $blog_id, $name ) );
- }
-
- // get total shares for a post
- return $wpdb->get_var( $wpdb->prepare( 'SELECT count FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s', $blog_id, $post->ID, $name ) );
+ return __( 'Google+', 'jetpack' );
}
}
@@ -1440,7 +1403,28 @@ class Share_Tumblr extends Sharing_Source {
$target = '_blank';
}
- return '<a target="' . $target . '" href="https://www.tumblr.com/share/link/?url=' . rawurlencode( $this->get_share_url( $post->ID ) ) . '&name=' . rawurlencode( $this->get_share_title( $post->ID ) ) . '" title="' . __( 'Share on Tumblr', 'jetpack' ) . '" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:62px; height:20px; background:url(\'https://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;">' . __( 'Share on Tumblr', 'jetpack' ) . '</a>';
+ /**
+ * If we are looking at a single post, let Tumblr figure out the post type (text, photo, link, quote, chat, or video)
+ * based on the content available on the page.
+ * If we are not looking at a single post, content from other posts can appear on the page and Tumblr will pick that up.
+ * In this case, we want Tumblr to focus on our current post, so we will limit the post type to link, where we can give Tumblr a link to our post.
+ */
+ if ( ! is_single() ) {
+ $posttype = 'data-posttype="link"';
+ } else {
+ $posttype = '';
+ }
+
+ // Documentation: https://www.tumblr.com/docs/en/share_button
+ return sprintf(
+ '<a class="tumblr-share-button" target="%1$s" href="%2$s" data-title="%3$s" data-content="%4$s" title="%5$s"%6$s>%5$s</a>',
+ $target,
+ 'https://www.tumblr.com/share',
+ $this->get_share_title( $post->ID ),
+ $this->get_share_url( $post->ID ),
+ __( 'Share on Tumblr', 'jetpack' ),
+ $posttype
+ );
} else {
return $this->get_link( $this->get_process_request_url( $post->ID ), _x( 'Tumblr', 'share to', 'jetpack' ), __( 'Click to share on Tumblr', 'jetpack' ), 'share=tumblr' );
}
@@ -1455,10 +1439,10 @@ class Share_Tumblr extends Sharing_Source {
wp_redirect( $url );
die();
}
- // http://www.tumblr.com/share?v=3&u=URL&t=TITLE&s=
+
public function display_footer() {
if ( $this->smart ) {
- ?><script type="text/javascript" src="https://platform.tumblr.com/v1/share.js"></script><?php
+ ?><script id="tumblr-js" type="text/javascript" src="https://assets.tumblr.com/share-button.js"></script><?php
} else {
$this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) );
}
@@ -1719,7 +1703,15 @@ 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 ) . ' ' . $this->get_share_url( $post->ID ) ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ) );
+ 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' );
+ }
+
+ public function process_request( $post, array $post_data ) {
+ // Record stats
+ parent::process_request( $post, $post_data );
+ $url = 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) . ' ' . $this->get_share_url( $post->ID ) );
+ wp_redirect( $url );
+ exit;
}
}