Completed
Push — componentlibrary ( 67a692...eed31d )
by Doğa
01:48
created

functions.php ➔ init()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Flynt\Components\FeatureGoogleAnalytics;
4
5
require_once __DIR__ . '/GoogleAnalytics.php';
6
7
use Flynt\Components\FeatureGoogleAnalytics\GoogleAnalytics;
8
use Flynt\Utils\Options;
9
10
add_action('init', 'Flynt\Components\FeatureGoogleAnalytics\init');
11
12
function init()
13
{
14
    $googleAnalyticsOptions = Options::get('globalOptions', 'feature', 'GoogleAnalytics');
15
    if ($googleAnalyticsOptions) {
16
        new GoogleAnalytics($googleAnalyticsOptions);
17
    }
18
}
19
20
Options::addGlobal('GoogleAnalytics', [
21
    [
22
        'name' => 'gaId',
23
        'label' => 'Google Analytics ID',
24
        'type' => 'text',
25
        'maxlength' => 20,
26
        'prepend' => '',
27
        'append' => '',
28
        'placeholder' => 'XX-XXXXXXXX-X',
29
        'instructions' => 'You can enter \'debug\' to activate debug mode. It will only log to console and overwrite all other settings.'
30
    ],
31
    [
32
        'name' => 'anonymizeIp',
33
        'label' => 'Anonymize IP',
34
        'type' => 'true_false',
35
        'ui' => 'no',
36
        'ui_on_text' => '',
37
        'ui_off_text' => '',
38
        'message' => ''
39
    ],
40
    [
41
        'name' => 'skippedUserRoles',
42
        'label' => 'Skipped User Roles',
43
        'type' => 'checkbox',
44
        'choices' => [
45
            'administrator' => 'Administrator',
46
            'editor' => 'Editor',
47
            'author' => 'Author',
48
            'contributor' => 'Contributor',
49
            'subscriber' => 'Subscriber'
50
        ],
51
        'toggle' => 'All',
52
        'allow_custom' => 0,
53
        'save_custom' => 0,
54
        'layout' => 'vertical'
55
    ],
56
    [
57
        'name' => 'skippedIps',
58
        'label' => 'Skipped IPs',
59
        'type' => 'textarea',
60
        'maxlength' => 500,
61
        'placeholder' => 'Separate IP addresses with commas'
62
    ]
63
]);
64