diff --git a/modules/sharedaddy/sharing-service.php b/modules/sharedaddy/sharing-service.php index f89d8592d568e..a3a3e6d82d02d 100644 --- a/modules/sharedaddy/sharing-service.php +++ b/modules/sharedaddy/sharing-service.php @@ -548,9 +548,6 @@ function sharing_add_footer() { ); wp_localize_script( 'sharing-js', 'sharing_js_options', $sharing_js_options); } -} - -function sharing_add_footer_scripts_inline() { $sharer = new Sharing_Service(); $enabled = $sharer->get_blog_services(); foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) { @@ -779,9 +776,6 @@ function sharing_display( $text = '', $echo = false ) { // Enqueue scripts for the footer add_action( 'wp_footer', 'sharing_add_footer' ); - - // Print inline scripts that depend on jQuery - add_action( 'wp_footer', 'sharing_add_footer_scripts_inline', 25 ); } } diff --git a/modules/sharedaddy/sharing-sources.php b/modules/sharedaddy/sharing-sources.php index 98c49a3eb7000..414602d56847f 100644 --- a/modules/sharedaddy/sharing-sources.php +++ b/modules/sharedaddy/sharing-sources.php @@ -516,8 +516,11 @@ public function display_footer() { - smart ) { - ?> - - js_dialog( $this->shortname, array( 'height' => 350 ) ); } @@ -849,17 +853,18 @@ public function display_footer() { if ( ! $this->smart ) { $this->js_dialog( $this->shortname, array( 'width' => 580, 'height' => 450 ) ); } else { - ?>
- - - "; + + wp_add_inline_script( + 'sharing-js', + sprintf( + '(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = \'https://connect.facebook.net/%1$s/sdk.js#xfbml=1%2$s&version=v2.3\'; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\')); + jQuery( document.body ).on( \'post-load\', function() { + if ( \'undefined\' !== typeof FB ) { + FB.XFBML.parse(); + } + } );', + $locale, + $fb_app_id + ) + ); } } } @@ -1139,39 +1150,39 @@ public function process_request( $post, array $post_data ) { public function display_footer() { global $post; - if ( $this->smart ) { ?> - - js_dialog( 'google-plus-1', array( 'width' => 480, 'height' => 550 ) ); } @@ -1427,7 +1438,11 @@ public function process_request( $post, array $post_data ) { // http://www.tumblr.com/share?v=3&u=URL&t=TITLE&s= public function display_footer() { if ( $this->smart ) { - ?>js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) ); } @@ -1442,7 +1457,7 @@ public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); if ( 'official' == $this->button_style ) { $this->smart = true; - } else { + } else { $this->smart = false; } } @@ -1546,26 +1561,29 @@ public function display_footer() { * @param bool $jetpack_pinit_over True by default, displays the Pin it button when hovering over images. */ $jetpack_pinit_over = apply_filters( 'jetpack_pinit_over_button', true ); - ?> - smart ) : ?> - - get_widget_type() ) : ?> - - smart ) : - ?> - - smart ) { + wp_add_inline_script( + 'sharing-js', + " + // Don't use Pocket's default JS as it we need to force init new Pocket share buttons loaded via JS. + function jetpack_sharing_pocket_init() { + jQuery.getScript( 'https://widgets.getpocket.com/v1/j/btn.js?v=1' ); + } + jQuery( document ).ready( jetpack_sharing_pocket_init ); + jQuery( document.body ).on( 'post-load', jetpack_sharing_pocket_init );" + ); + } else { $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) ); - endif; - + } } } @@ -1749,29 +1766,28 @@ public function process_request( $post, array $post_data ) { } public function display_footer() { - if ( $this->smart ) : - ?> - - smart ) { + wp_add_inline_script( + 'sharing-js', + "(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');" + ); + } else { $this->js_dialog( $this->shortname, array( 'width' => 305, 'height' => 665 ) ); - endif; + } } }