summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/sharedaddy/sharing-service.php')
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-service.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php
index 75a41ad4..f89d8592 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing-service.php
+++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php
@@ -170,8 +170,15 @@ class Sharing_Service {
$enabled = get_option( 'sharing-services' );
$services = $this->get_all_services();
- if ( !is_array( $options ) )
- $options = array( 'global' => $this->get_global_options() );
+ /**
+ * Check if options exist and are well formatted.
+ * This avoids issues on sites with corrupted options.
+ * @see https://github.com/Automattic/jetpack/issues/6121
+ */
+ if ( ! is_array( $options ) || ! isset( $options['button_style'], $options['global'] ) ) {
+ $global_options = $this->get_global_options();
+ $options = array_merge( is_array( $options ) ? $options : array(), $global_options );
+ }
$global = $options['global'];
@@ -541,7 +548,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 ) {
@@ -691,7 +700,7 @@ function sharing_display( $text = '', $echo = false ) {
/**
* Filter the sharing buttons' headline structure.
*
- * @module sharing
+ * @module sharedaddy
*
* @since 4.4.0
*
@@ -767,7 +776,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 );
}
}