1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Flynt\Features\GoogleAnalytics; |
4
|
|
|
|
5
|
|
|
require_once __DIR__ . '/GoogleAnalytics.php'; |
6
|
|
|
|
7
|
|
|
use Flynt\Features\GoogleAnalytics\GoogleAnalytics; |
8
|
|
|
use Flynt\Utils\Feature; |
9
|
|
|
use Flynt\Utils\Asset; |
10
|
|
|
use Flynt\Features\Acf\OptionPages; |
11
|
|
|
|
12
|
|
|
add_action('init', 'Flynt\Features\GoogleAnalytics\init', 100); |
13
|
|
|
|
14
|
|
|
function init() |
15
|
|
|
{ |
16
|
|
|
$googleAnalyticsOptions = OptionPages::get('globalOptions', 'feature', 'GoogleAnalytics'); |
17
|
|
|
$googleAnalyticsOptionsTranslatable = OptionPages::get('translatableOptions', 'feature', 'GoogleAnalytics'); |
|
|
|
|
18
|
|
|
|
19
|
|
|
if ($googleAnalyticsOptions) { |
20
|
|
|
new GoogleAnalytics($googleAnalyticsOptions); |
21
|
|
|
} |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
add_action('wp_enqueue_scripts', function () { |
25
|
|
|
$gaOptions = OptionPages::get('globalOptions', 'feature', 'GoogleAnalytics'); |
26
|
|
|
$gaOptionsTranslatable = OptionPages::get('translatableOptions', 'feature', 'GoogleAnalytics'); |
27
|
|
|
|
28
|
|
|
Asset::enqueue([ |
29
|
|
|
'type' => 'script', |
30
|
|
|
'name' => 'js-cookie', |
31
|
|
|
'path' => 'vendor/js-cookie.js' |
32
|
|
|
]); |
33
|
|
|
|
34
|
|
|
Asset::enqueue([ |
35
|
|
|
'type' => 'script', |
36
|
|
|
'name' => 'Flynt/Features/GoogleAnalytics', |
37
|
|
|
'path' => 'Features/GoogleAnalytics/script.js', |
38
|
|
|
'dependencies' => ['jquery', 'js-cookie'] |
39
|
|
|
]); |
40
|
|
|
|
41
|
|
|
$data = [ |
42
|
|
|
'gaId' => $gaOptions['gaId'], |
43
|
|
|
'confirm' => $gaOptionsTranslatable['optOutConfirm'], |
44
|
|
|
'success' => $gaOptionsTranslatable['optOutSuccess'] |
45
|
|
|
]; |
46
|
|
|
wp_localize_script('Flynt/Features/GoogleAnalytics', 'dataFlyntFeatureGoogleAnalytics', $data); |
47
|
|
|
}, 100); |
48
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.