@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // Add in our Twig extensions |
84 | 84 | $view->registerTwigExtension(new InstantAnalyticsTwigExtension()); |
85 | 85 | // Install our template hook |
86 | - $view->hook('iaSendPageView', [$this, 'iaSendPageView']); |
|
86 | + $view->hook('iaSendPageView', [ $this, 'iaSendPageView' ]); |
|
87 | 87 | // Determine if Craft Commerce is installed & enabled |
88 | 88 | self::$commercePlugin = Craft::$app->getPlugins()->getPlugin('commerce'); |
89 | 89 | // Determine if SEOmatic is installed & enabled |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | Event::on( |
93 | 93 | CraftVariable::class, |
94 | 94 | CraftVariable::EVENT_INIT, |
95 | - function (Event $event) { |
|
95 | + function(Event $event) { |
|
96 | 96 | /** @var CraftVariable $variable */ |
97 | 97 | $variable = $event->sender; |
98 | 98 | $variable->set('instantAnalytics', InstantAnalyticsVariable::class); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | Event::on( |
104 | 104 | Plugins::class, |
105 | 105 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
106 | - function (PluginEvent $event) { |
|
106 | + function(PluginEvent $event) { |
|
107 | 107 | if ($event->plugin === $this) { |
108 | 108 | $request = Craft::$app->getRequest(); |
109 | 109 | if (($request->isCpRequest) && (!$request->isConsoleRequest)) { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | Event::on( |
120 | 120 | View::class, |
121 | 121 | View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE, |
122 | - function (TemplateEvent $event) { |
|
122 | + function(TemplateEvent $event) { |
|
123 | 123 | self::$currentTemplate = $event->template; |
124 | 124 | } |
125 | 125 | ); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | Event::on( |
128 | 128 | View::class, |
129 | 129 | View::EVENT_AFTER_RENDER_PAGE_TEMPLATE, |
130 | - function (TemplateEvent $event) { |
|
130 | + function(TemplateEvent $event) { |
|
131 | 131 | $settings = InstantAnalytics::$plugin->getSettings(); |
132 | 132 | if ($settings->autoSendPageView) { |
133 | 133 | $this->sendPageView(); |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | Event::on( |
139 | 139 | UrlManager::class, |
140 | 140 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
141 | - function (RegisterUrlRulesEvent $event) { |
|
142 | - $event->rules['instantanalytics/pageViewTrack/<filename:[-\w\.*]+>?'] = |
|
141 | + function(RegisterUrlRulesEvent $event) { |
|
142 | + $event->rules[ 'instantanalytics/pageViewTrack/<filename:[-\w\.*]+>?' ] = |
|
143 | 143 | 'instant-analytics/track/track-page-view-url'; |
144 | - $event->rules['instantanalytics/eventTrack/<filename:[-\w\.*]+>?'] = |
|
144 | + $event->rules[ 'instantanalytics/eventTrack/<filename:[-\w\.*]+>?' ] = |
|
145 | 145 | 'instant-analytics/track/track-event-url'; |
146 | 146 | } |
147 | 147 | ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | Craft::t( |
156 | 156 | 'instant-analytics', |
157 | 157 | '{name} plugin loaded', |
158 | - ['name' => $this->name] |
|
158 | + [ 'name' => $this->name ] |
|
159 | 159 | ), |
160 | 160 | __METHOD__ |
161 | 161 | ); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function settingsHtml() |
168 | 168 | { |
169 | - $commerceFields = []; |
|
169 | + $commerceFields = [ ]; |
|
170 | 170 | |
171 | 171 | if (self::$commercePlugin) { |
172 | 172 | // TODO: pending Commerce for Craft 3 |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | private function getPullFieldsFromLayoutId(int $layoutId) |
214 | 214 | { |
215 | - $result = ['' => "none"]; |
|
215 | + $result = [ '' => "none" ]; |
|
216 | 216 | $fieldLayout = Craft::$app->getFields()->getLayoutById($layoutId); |
217 | 217 | $fieldLayoutFields = $fieldLayout->getFields(); |
218 | 218 | foreach ($fieldLayoutFields as $fieldLayoutField) { |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | case "RedactorI": |
224 | 224 | case "PreparseField_Preparse": |
225 | 225 | case "Categories": |
226 | - $result[$field->handle] = $field->name; |
|
226 | + $result[ $field->handle ] = $field->name; |
|
227 | 227 | break; |
228 | 228 | |
229 | 229 | case "Tags": |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $request = Craft::$app->getRequest(); |
272 | 272 | if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest()) { |
273 | 273 | // If SEOmatic is installed, set the page title from it |
274 | - if (self::$seomaticPlugin && isset($context['seomaticMeta'])) { |
|
274 | + if (self::$seomaticPlugin && isset($context[ 'seomaticMeta' ])) { |
|
275 | 275 | // TODO: fix for SEOmatic |
276 | 276 | /* |
277 | 277 | $seomaticMeta = $context['seomaticMeta']; |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | // Check the $_SERVER[] super-global exclusions |
268 | 268 | if (isset($settings->serverExcludes) && is_array($settings->serverExcludes)) { |
269 | 269 | foreach ($settings->serverExcludes as $match => $matchArray) { |
270 | - if (isset($_SERVER[$match])) { |
|
270 | + if (isset($_SERVER[ $match ])) { |
|
271 | 271 | foreach ($matchArray as $matchItem) { |
272 | - if (preg_match($matchItem, $_SERVER[$match])) { |
|
272 | + if (preg_match($matchItem, $_SERVER[ $match ])) { |
|
273 | 273 | if ($settings->logExcludedAnalytics) { |
274 | 274 | Craft::info( |
275 | 275 | "Analytics excluded for: " . $requestIp . " due to: `serverExcludes`", |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | // We want to send just a path to GA for page views |
352 | 352 | if (UrlHelper::isAbsoluteUrl($url)) { |
353 | 353 | $urlParts = parse_url($url); |
354 | - if (isset($urlParts['path'])) { |
|
355 | - $url = $urlParts['path']; |
|
354 | + if (isset($urlParts[ 'path' ])) { |
|
355 | + $url = $urlParts[ 'path' ]; |
|
356 | 356 | } else { |
357 | 357 | $url = "/"; |
358 | 358 | } |
359 | - if (isset($urlParts['query'])) { |
|
360 | - $url = $url."?".$urlParts['query']; |
|
359 | + if (isset($urlParts[ 'query' ])) { |
|
360 | + $url = $url . "?" . $urlParts[ 'query' ]; |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | private function getGclid() |
472 | 472 | { |
473 | 473 | $gclid = ""; |
474 | - if (isset($_GET['gclid'])) { |
|
475 | - $gclid = $_GET['gclid']; |
|
474 | + if (isset($_GET[ 'gclid' ])) { |
|
475 | + $gclid = $_GET[ 'gclid' ]; |
|
476 | 476 | if (!empty($gclid)) { |
477 | 477 | setcookie("gclid", $gclid, time() + (10 * 365 * 24 * 60 * 60), "/"); |
478 | 478 | } |
@@ -489,12 +489,12 @@ discard block |
||
489 | 489 | */ |
490 | 490 | private function gaParseCookie() |
491 | 491 | { |
492 | - if (isset($_COOKIE['_ga'])) { |
|
493 | - $parts = preg_split('[\.]', $_COOKIE["_ga"], 4); |
|
492 | + if (isset($_COOKIE[ '_ga' ])) { |
|
493 | + $parts = preg_split('[\.]', $_COOKIE[ "_ga" ], 4); |
|
494 | 494 | $cid = implode(array_slice($parts, 2), '.'); |
495 | 495 | } else { |
496 | - if (isset($_COOKIE['_ia']) && $_COOKIE['_ia'] != '') { |
|
497 | - $cid = $_COOKIE['_ia']; |
|
496 | + if (isset($_COOKIE[ '_ia' ]) && $_COOKIE[ '_ia' ] != '') { |
|
497 | + $cid = $_COOKIE[ '_ia' ]; |
|
498 | 498 | } else { |
499 | 499 | $cid = $this->gaGenUUID(); |
500 | 500 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function getGlobals() |
47 | 47 | { |
48 | - $globals = []; |
|
48 | + $globals = [ ]; |
|
49 | 49 | $view = Craft::$app->getView(); |
50 | 50 | if ($view->getIsRenderingPageTemplate()) { |
51 | 51 | $request = Craft::$app->getRequest(); |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | public function getFilters() |
67 | 67 | { |
68 | 68 | return [ |
69 | - new \Twig_SimpleFilter('pageViewAnalytics', [$this, 'pageViewAnalytics']), |
|
70 | - new \Twig_SimpleFilter('eventAnalytics', [$this, 'eventAnalytics']), |
|
71 | - new \Twig_SimpleFilter('pageViewTrackingUrl', [$this, 'pageViewTrackingUrl']), |
|
72 | - new \Twig_SimpleFilter('eventTrackingUrl', [$this, 'eventTrackingUrl']), |
|
69 | + new \Twig_SimpleFilter('pageViewAnalytics', [ $this, 'pageViewAnalytics' ]), |
|
70 | + new \Twig_SimpleFilter('eventAnalytics', [ $this, 'eventAnalytics' ]), |
|
71 | + new \Twig_SimpleFilter('pageViewTrackingUrl', [ $this, 'pageViewTrackingUrl' ]), |
|
72 | + new \Twig_SimpleFilter('eventTrackingUrl', [ $this, 'eventTrackingUrl' ]), |
|
73 | 73 | ]; |
74 | 74 | } |
75 | 75 | |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | public function getFunctions() |
80 | 80 | { |
81 | 81 | return [ |
82 | - new \Twig_SimpleFunction('pageViewAnalytics', [$this, 'pageViewAnalytics']), |
|
83 | - new \Twig_SimpleFunction('eventAnalytics', [$this, 'eventAnalytics']), |
|
84 | - new \Twig_SimpleFunction('pageViewTrackingUrl', [$this, 'pageViewTrackingUrl']), |
|
85 | - new \Twig_SimpleFunction('eventTrackingUrl', [$this, 'eventTrackingUrl']), |
|
82 | + new \Twig_SimpleFunction('pageViewAnalytics', [ $this, 'pageViewAnalytics' ]), |
|
83 | + new \Twig_SimpleFunction('eventAnalytics', [ $this, 'eventAnalytics' ]), |
|
84 | + new \Twig_SimpleFunction('pageViewTrackingUrl', [ $this, 'pageViewTrackingUrl' ]), |
|
85 | + new \Twig_SimpleFunction('eventTrackingUrl', [ $this, 'eventTrackingUrl' ]), |
|
86 | 86 | ]; |
87 | 87 | } |
88 | 88 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @inheritdoc |
29 | 29 | */ |
30 | - public function __construct($isSsl = false, $isDisabled = false, array $options = []) |
|
30 | + public function __construct($isSsl = false, $isDisabled = false, array $options = [ ]) |
|
31 | 31 | { |
32 | 32 | /** @var Settings $settings */ |
33 | 33 | $settings = InstantAnalytics::$plugin->getSettings(); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | /** @var Settings $settings */ |
60 | 60 | $settings = InstantAnalytics::$plugin->getSettings(); |
61 | - $requestIp = $_SERVER['REMOTE_ADDR']; |
|
61 | + $requestIp = $_SERVER[ 'REMOTE_ADDR' ]; |
|
62 | 62 | if ($this->shouldSendAnalytics) { |
63 | 63 | try { |
64 | 64 | Craft::info( |