From f64a09fb2f5cddf570aab8e64793de8034213ec7 Mon Sep 17 00:00:00 2001 From: Nick Gundry Date: Thu, 30 Nov 2017 15:28:49 +0000 Subject: [PATCH] ensure SPM is loaded before the sections are called. --- classes/class-sailthru-horizon.php | 6 +++++- js/tag.js | 14 ++++++++------ views/widget.scout.display.php | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/classes/class-sailthru-horizon.php b/classes/class-sailthru-horizon.php index 1416f40..20ac309 100644 --- a/classes/class-sailthru-horizon.php +++ b/classes/class-sailthru-horizon.php @@ -288,7 +288,11 @@ public function register_plugin_scripts() { ), ); + if ( 'personalize_js_custom' === $options['sailthru_js_type'] ) { + + $params['isCustom'] = true; + // override defaults if ( 'false' === $options['sailthru_js_auto_track_pageview'] ) { $params['options']['autoTrackPageview'] = (bool) false; @@ -305,7 +309,7 @@ public function register_plugin_scripts() { if ( ! is_404() && ! is_preview() && apply_filters( 'sailthru_add_spm_js', true ) ) { wp_enqueue_script( 'personalize_js', '//ak.sail-horizon.com/spm/spm.v1.min.js' ); - wp_register_script( 'tag', plugin_dir_url( __DIR__ ) . 'js/tag.js' ); + wp_register_script( 'tag', plugin_dir_url( __DIR__ ) . 'js/tag.js', array('jquery') ); wp_localize_script( 'tag', 'tag', $params ); wp_enqueue_script( 'tag' ); } diff --git a/js/tag.js b/js/tag.js index d52a820..e481ed9 100644 --- a/js/tag.js +++ b/js/tag.js @@ -1,10 +1,12 @@ if (tag.isCustom) { - Sailthru.init({ - customerId: tag.options.customerId, - isCustom: true, - autoTrackPageview: tag.options.autoTrackPageview, - useStoredTags: tag.options.useStoredTags, - excludeContent: tag.options.excludeContent, + jQuery(function($) { + Sailthru.init({ + customerId: tag.options.customerId, + isCustom: true, + autoTrackPageview: tag.options.autoTrackPageview, + useStoredTags: tag.options.useStoredTags, + excludeContent: tag.options.excludeContent, + }); }); } else { Sailthru.init({ diff --git a/views/widget.scout.display.php b/views/widget.scout.display.php index 6a16ed5..36cc689 100644 --- a/views/widget.scout.display.php +++ b/views/widget.scout.display.php @@ -22,9 +22,9 @@ ?>
-
+