Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
CraigsOverItAll committed Jan 12, 2018
2 parents 631883c + a9c8140 commit 891ba61
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.2.0
## 12-01-2018

1. [](#new)
* Added late loading of GoSquared inline JS (uses templates 'bottom' group for JS)

# v0.1.6
## 19-06-2017

Expand Down
16 changes: 14 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,20 @@ form:
label: PLUGIN_GOSQUARED.GS_IN_ADMIN
default: 0
options:
1: On
0: Off
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
help: PLUGIN_GOSQUARED.GS_IN_ADMIN_HELP

gsLoadLate:
type: toggle
label: PLUGIN_GOSQUARED.GS_LOAD_LATE
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
help: PLUGIN_GOSQUARED.GS_LOAD_LATE_HELP

18 changes: 14 additions & 4 deletions gosquared.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,37 @@ public static function getSubscribedEvents()
*/
public function onAssetsInitialized()
{
// Get our defaults
$runInAdmin = $this->config->get('plugins.gosquared.gsInAdmin') == 0;
$gsn = trim($this->config->get('plugins.gosquared.gsn'));
$loadLate = $this->config->get('plugins.gosquared.gsLoadLate') == 1;

// See if we're set to run in admin
$runInAdmin = $this->config->get('plugins.gosquared.gsInAdmin');
if (!$runInAdmin && $this->isAdmin()) {
return;
}

/**
* Ok, we're ready to go
*/
$gsn = trim($this->config->get('plugins.gosquared.gsn'));
if ($gsn) {
$gsjs = <<<GoSquaredJS
// GoSquared
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
insertBefore(d,q)}(window,document,'script','_gs');
_gs('$gsn');
_gs('$gsn');
// GoSquared End
GoSquaredJS;

$this->grav['assets']->addInlineJs($gsjs);
if (!$loadLate) {
$this->grav['assets']->addInlineJs($gsjs);
} else {
$this->grav['assets']->addInlineJs($gsjs, null, 'bottom');
}
}
}
}
2 changes: 2 additions & 0 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ en:
GSN_HELP: "GoSquared Tracking Code. ( The tracking code is usually of the form GSN-999999-X ) Please note each website in your GoSquared account will have it's own GSN tracking code."
GS_IN_ADMIN: "Track Admin Users"
GS_IN_ADMIN_HELP: "GoSquared can be enabled to track Admin usage as well — generally GRAV admin usage doesn't warrant this feature being turned on."
GS_LOAD_LATE: 'Load late'
GS_LOAD_LATE_HELP: 'If JQuery is NOT loaded in the <head> of your GRAV template you may need to turn \"Load Late\" on. Please note, this feature is reliant on your GRAV template supporting the standard "bottom" group for inline Javascript items.'

0 comments on commit 891ba61

Please sign in to comment.