From 067bbc2b5a4f2354756b3138c9ddb409af8cf75b Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Thu, 9 Feb 2017 11:32:18 +0200 Subject: [PATCH 1/2] Remove unused JS logic Fixes #1223 --- modules/sharedaddy/sharing-sources.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/sharedaddy/sharing-sources.php b/modules/sharedaddy/sharing-sources.php index ec87639d0f855..03a7ba2f68d55 100644 --- a/modules/sharedaddy/sharing-sources.php +++ b/modules/sharedaddy/sharing-sources.php @@ -515,7 +515,6 @@ public function display_footer() { - Date: Thu, 9 Feb 2017 11:47:26 +0200 Subject: [PATCH 2/2] Print inline scripts after WP is done with footer scripts Ensures that dependencies are met. --- modules/sharedaddy/sharing-service.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/sharedaddy/sharing-service.php b/modules/sharedaddy/sharing-service.php index dd0087faf81ad..741d66c303e0f 100644 --- a/modules/sharedaddy/sharing-service.php +++ b/modules/sharedaddy/sharing-service.php @@ -547,7 +547,9 @@ 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 ) { @@ -773,7 +775,12 @@ function sharing_display( $text = '', $echo = false ) { $ver = '20141212'; } wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), $ver ); + + // 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 ); } }