Skip to content

Commit

Permalink
Fixed issue with incorrect Sailthru Script setup, moved Sailthru Scri…
Browse files Browse the repository at this point in the history
…pt Tag to head.
  • Loading branch information
nickgundry committed Oct 25, 2017
1 parent 736cbb8 commit 183a1fc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.txt
@@ -1,9 +1,9 @@
=== Sailthru for WordPress ===
Contributors: nickgundry, automattic, irms, zackify, natebot
Contributors: nickgundry, sailthru-wp, automattic, irms, zackify, natebot
Tags: personalization, email,
Requires at least: 3.6
Tested up to: 4.6
Stable tag: 3.0.7
Tested up to: 4.8
Stable tag: 3.0.8

This plugin provides fast and easy integration of the core Sailthru features into your Wordpress site.

Expand Down
4 changes: 3 additions & 1 deletion changelog.md
@@ -1,9 +1,11 @@
# Changelog

## v3.0.8 (2017-10--24)
Fixed a bug with deployment of Sailthru Script Tag where Sailthru functions are not available due to incorrect Setup of Sailthru.init

## v3.0.7 (2017-10--5)
Added support for latest version of Sailthru Script Tag and some big fixes.


## v3.0.6 (2016-07-15)

Version 3.0.6 of the plugin adds support for Sailthru's content API and additional support for our personalization engine JavaScript as well as bug fixes and improvements.
Expand Down
47 changes: 38 additions & 9 deletions classes/class-sailthru-horizon.php
Expand Up @@ -285,7 +285,7 @@ public function register_plugin_scripts() {
$params['sailthru_customer_id'] = $customer_id;

wp_enqueue_script( 'personalize_js', 'https://ak.sail-horizon.com/spm/spm.v1.min.js' );
add_action('wp_footer', array( $this, 'sailthru_client_personalize' ), 10);
add_action('wp_head', array( $this, 'sailthru_client_personalize' ),10);

} else {

Expand Down Expand Up @@ -331,16 +331,45 @@ function sailthru_client_personalize() {
}
}

if( false === apply_filters( 'sailthru_content_api_enable', true ) ) {
$stored_tags = false;
} else {
if ( !$options['sailthru_ignore_personalize_stored_tags'] || !isset( $options['sailthru_ignore_personalize_stored_tags'] ) ) {
$stored_tags = true;
} else {
// default setting
$stored_tags = false;
}
}

// other config options defined by filters.
$auto_track_pageviews = apply_filters( 'sailthru_auto_track__pageviews', true ) ? true: false;
$exclude_content = apply_filters( 'sailthru_exclude_content', true ) ? true: false;


$customer_id = isset( $options['sailthru_customer_id'] ) && ($options['sailthru_customer_id']) ? $options['sailthru_customer_id'] : '';

$js = "<script type=\"text/javascript\">\n";
$js .= "var customerId = '".esc_attr( $customer_id ) ."'\n";
$js .= "var SPM = Sailthru.SPM;\n";
$js .= "SPM.setup(customerId, {\n";
$js .= "autoTrackPageviews: true,\n";
$js .= "useStoredTags: ". esc_attr( $stored_tags ) ."\n";
$js .= "});\n";
$js .= "</script>\n";
$js = '<script type="text/javascript">';
$js .= 'Sailthru.init({';
$js .= 'customerId: '.esc_attr( $customer_id ) .',';
$js .= 'isCustom: true,';


if (false === $stored_tags ) {
$js .= 'useStoredTags: false,';
}

if (false === apply_filters( 'sailthru_track_pageviews', true )) {
$js .= 'autoTrackPageview: false,';
}

if (true === apply_filters( 'sailthru_exclude_content', false )) {
$js .= 'excludeContent: true,';
}

$js = rtrim($js, ',');

$js .= '});</script>';

if ( !is_404() && !is_preview() ) {
echo $js;
Expand Down

0 comments on commit 183a1fc

Please sign in to comment.