Free Tools to Automate Your Site Growth - Version 1.29

Version Description

Download this release

Release Info

Developer marnietave
Plugin Icon 128x128 Free Tools to Automate Your Site Growth
Version 1.29
Comparing to
See all releases

Code changes from version 1.28 to 1.29

Files changed (3) hide show
  1. Readme.txt +8 -2
  2. classes/class_sumome.php +56 -33
  3. sumome.php +1 -1
Readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: SumoMe
3
  Tags: analytics, campaign monitor, click to tweet, contact form, content analytics, convertkit, drip, email form, ExactTarget, exit-intent, Facebook, facebook share, FeedBlitz, floating social buttons, growth, heat map, heatmaps, Hubspot, image sharing, inbound marketing, Inbox First, infusionsoft, landing page, lightbox, links, mailchimp, mailerlite, mailing list, mailjet, MyEmma, MyNewsletterBuilder, newsletter, Ontraport, pardot, popup, sailthru, scroll box, share, share buttons, share image, sharebar, sharing, site traffic, sms, social, social bookmarking, social media buttons, social plugin, social sharing, subscribers, subscription, traffic growth, tweet button, twitter, twitter share, vero, vertical response, welcome mat, WhatCounts, widget, zapier
4
  Requires at least: 3.0.1
5
  Tested up to: 4.9.3
6
- Stable tag: 1.28
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -262,6 +262,9 @@ Why you should encourage Twitter sharing
262
  = 1.28 =
263
  * Updated Sumo script tag. Tested up to the newest Wordpress version.
264
 
 
 
 
265
  == Upgrade Notice ==
266
 
267
  = 1.04 =
@@ -345,4 +348,7 @@ Why you should encourage Twitter sharing
345
  * Tested up to the newest Wordpress version.
346
 
347
  = 1.28 =
348
- * Updated Sumo script tag. Tested up to the newest Wordpress version.
 
 
 
3
  Tags: analytics, campaign monitor, click to tweet, contact form, content analytics, convertkit, drip, email form, ExactTarget, exit-intent, Facebook, facebook share, FeedBlitz, floating social buttons, growth, heat map, heatmaps, Hubspot, image sharing, inbound marketing, Inbox First, infusionsoft, landing page, lightbox, links, mailchimp, mailerlite, mailing list, mailjet, MyEmma, MyNewsletterBuilder, newsletter, Ontraport, pardot, popup, sailthru, scroll box, share, share buttons, share image, sharebar, sharing, site traffic, sms, social, social bookmarking, social media buttons, social plugin, social sharing, subscribers, subscription, traffic growth, tweet button, twitter, twitter share, vero, vertical response, welcome mat, WhatCounts, widget, zapier
4
  Requires at least: 3.0.1
5
  Tested up to: 4.9.3
6
+ Stable tag: 1.29
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
262
  = 1.28 =
263
  * Updated Sumo script tag. Tested up to the newest Wordpress version.
264
 
265
+ = 1.29 =
266
+ * Moved Sumo script tag to the footer.
267
+
268
  == Upgrade Notice ==
269
 
270
  = 1.04 =
348
  * Tested up to the newest Wordpress version.
349
 
350
  = 1.28 =
351
+ * Updated Sumo script tag. Tested up to the newest Wordpress version.
352
+
353
+ = 1.29 =
354
+ * Moved Sumo script tag to the footer.
classes/class_sumome.php CHANGED
@@ -4,8 +4,8 @@ class WP_Plugin_SumoMe {
4
  add_action('wp_ajax_sumome_main', array($this, 'ajax_sumome_main'));
5
  add_action('wp_ajax_sumome_dashboard_welcome', array($this, 'ajax_sumome_dashboard_welcome'));
6
  add_action('wp_ajax_sumome_hide_dashboard_overlay', array($this, 'ajax_sumome_hide_dashboard_overlay'));
7
- add_action('wp_head', array($this, 'append_script_code'));
8
- add_action('admin_head', array($this, 'append_admin_script_code'));
9
  add_action('admin_menu', array($this, 'admin_menu'));
10
  add_action('admin_init', array($this, 'admin_init'));
11
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
@@ -111,38 +111,61 @@ class WP_Plugin_SumoMe {
111
  if ($site_id && in_array($site_id, $blacklist)) return true;
112
  }
113
 
114
-
115
  public function upgrade_manual_sumome_installation() {
116
- $headerFile=get_template_directory()."/header.php";
117
-
118
- if (file_exists($headerFile) && is_writable($headerFile)) {
119
- $header_contents = file_get_contents($headerFile);
120
-
121
- $pattern='/<script\\b[^>]*>(.*?)<\\/script>/i';
122
- preg_match($pattern, $header_contents, $manuallyInsertedScriptTag);
123
-
124
- if ($manuallyInsertedScriptTag) {
125
- $dom = new \DOMDocument('1.0', 'utf-8');
126
- $dom->loadHTML($manuallyInsertedScriptTag[0]);
127
- $nodes = $dom->getElementsByTagName('script');
128
- $manuallyInsertedScriptTagSiteID=$nodes->item(0)->getAttribute('data-sumo-site-id');
129
- }
130
-
131
- if (trim($manuallyInsertedScriptTagSiteID)!="") {
132
-
133
- //save users site ID from the manually inserted tag
134
- update_option('sumome_site_id', $manuallyInsertedScriptTagSiteID);
135
-
136
- $sumomeScriptTag[]='<script src="//load.sumome.com/" data-sumo-site-id="' . esc_attr($manuallyInsertedScriptTagSiteID) . '" async="async"></script>';
137
- $sumomeScriptTag[]='<script src="//load.sumo.com/" data-sumo-site-id="' . esc_attr($manuallyInsertedScriptTagSiteID) . '" async="async"></script>';
138
- $sumomeScriptTag[]="<script async>(function(s,u,m,o,j,v){j=u.createElement(m);v=u.getElementsByTagName(m)[0];j.async=1;j.src=o;j.dataset.sumoSiteId='".esc_attr($manuallyInsertedScriptTagSiteID)."';v.parentNode.insertBefore(j,v)})(window,document,'script','//load.sumo.com/');</script>";
139
- $modified_header = str_replace($sumomeScriptTag,"",$header_contents);
140
-
141
- //make backup of header.php just in case
142
- copy($headerFile,get_template_directory()."/header.bak[".date('Y-m-d_H.i.s')."].php");
143
-
144
- //remove manually inserted SumoMe tag
145
- if (trim($modified_header)) file_put_contents($headerFile,$modified_header);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
147
  }
148
  }
4
  add_action('wp_ajax_sumome_main', array($this, 'ajax_sumome_main'));
5
  add_action('wp_ajax_sumome_dashboard_welcome', array($this, 'ajax_sumome_dashboard_welcome'));
6
  add_action('wp_ajax_sumome_hide_dashboard_overlay', array($this, 'ajax_sumome_hide_dashboard_overlay'));
7
+ add_action('wp_footer', array($this, 'append_script_code'));
8
+ add_action('admin_footer', array($this, 'append_admin_script_code'));
9
  add_action('admin_menu', array($this, 'admin_menu'));
10
  add_action('admin_init', array($this, 'admin_init'));
11
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
111
  if ($site_id && in_array($site_id, $blacklist)) return true;
112
  }
113
 
 
114
  public function upgrade_manual_sumome_installation() {
115
+ $wpThemeFiles=array("header","footer");
116
+ foreach ($wpThemeFiles as $wpThemeFile) {
117
+ $themeFile=get_template_directory()."/".$wpThemeFile.".php";
118
+
119
+ if (file_exists($themeFile) && is_writable($themeFile)) {
120
+ $themeFile_contents = file_get_contents($themeFile);
121
+
122
+ libxml_use_internal_errors(true);
123
+ $pageDom = new \DOMDocument('1.0', 'utf-8');
124
+ $pageDom->loadHTML($themeFile_contents);
125
+ $scripts = $pageDom->getElementsByTagName('script');
126
+
127
+ for ($i = 0; $i < $scripts->length; $i++) {
128
+
129
+ $scriptDoc = new \DOMDocument('1.0', 'utf-8');
130
+ $scriptDoc->appendChild($scriptDoc->importNode($scripts->item($i), true));
131
+ $scriptLine=$scriptDoc->saveHTML();
132
+
133
+ if ($scriptLine) {
134
+ $dom = new \DOMDocument('1.0', 'utf-8');
135
+ $dom->loadHTML($scriptLine);
136
+ $nodes = $dom->getElementsByTagName('script');
137
+
138
+ if (substr_count($scriptLine, 'data-sumo-site-id')>0) {
139
+ $manuallyInsertedScriptTagSiteID=$nodes->item(0)->getAttribute('data-sumo-site-id');
140
+ } else {
141
+ $scriptBreakdown=explode(';', $scriptLine);
142
+
143
+ if ($scriptBreakdown) foreach ($scriptBreakdown as $scriptBreakdownSpec) {
144
+ if (substr_count($scriptBreakdownSpec, 'j.dataset.sumoSiteId')) $siteIDLine=$scriptBreakdownSpec;
145
+ }
146
+ $findSiteID[]="'";
147
+ $findSiteID[]="j.dataset.sumoSiteId=";
148
+ $manuallyInsertedScriptTagSiteID=str_replace($findSiteID,"",$siteIDLine);
149
+ }
150
+ }
151
+ }
152
+
153
+ if (trim($manuallyInsertedScriptTagSiteID)!="") {
154
+
155
+ //save users site ID from the manually inserted tag
156
+ update_option('sumome_site_id', $manuallyInsertedScriptTagSiteID);
157
+
158
+ $sumomeScriptTag[]='<script src="//load.sumome.com/" data-sumo-site-id="' . esc_attr($manuallyInsertedScriptTagSiteID) . '" async="async"></script>';
159
+ $sumomeScriptTag[]='<script src="//load.sumo.com/" data-sumo-site-id="' . esc_attr($manuallyInsertedScriptTagSiteID) . '" async="async"></script>';
160
+ $sumomeScriptTag[]="<script async>(function(s,u,m,o,j,v){j=u.createElement(m);v=u.getElementsByTagName(m)[0];j.async=1;j.src=o;j.dataset.sumoSiteId='".esc_attr($manuallyInsertedScriptTagSiteID)."';v.parentNode.insertBefore(j,v)})(window,document,'script','//load.sumo.com/');</script>";
161
+ $modified_themeFile = str_replace($sumomeScriptTag,"",$themeFile_contents);
162
+
163
+ //make backup of theme file just in case
164
+ copy($themeFile,get_template_directory()."/".$wpThemeFile.".bak[".date('Y-m-d_H.i.s')."].php");
165
+
166
+ //remove manually inserted SumoMe tag
167
+ if (trim($modified_themeFile)) file_put_contents($themeFile,$modified_themeFile);
168
+ }
169
  }
170
  }
171
  }
sumome.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: SumoMe
4
  Plugin URI: https://sumo.com
5
  Description: Free Tools to automate your site growth from Sumo.com
6
- Version: 1.28
7
  Author: SumoMe
8
  Author URI: https://www.Sumo.com
9
  */
3
  Plugin Name: SumoMe
4
  Plugin URI: https://sumo.com
5
  Description: Free Tools to automate your site growth from Sumo.com
6
+ Version: 1.29
7
  Author: SumoMe
8
  Author URI: https://www.Sumo.com
9
  */