Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Jetpack_Premium_Analytics
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 init_cookie_consent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Primary class file for the Jetpack Premium Analytics plugin.
4 *
5 * @package automattic/jetpack-premium-analytics-plugin
6 */
7
8if ( ! defined( 'ABSPATH' ) ) {
9    exit( 0 );
10}
11
12use Automattic\Jetpack\CookieConsent\Cookie_Consent;
13use Automattic\Jetpack\PremiumAnalytics\Analytics;
14
15/**
16 * Class Jetpack_Premium_Analytics
17 *
18 * Thin wrapper that initializes the premium-analytics package.
19 *
20 * @phan-constructor-used-for-side-effects
21 */
22class Jetpack_Premium_Analytics {
23
24    /**
25     * Constructor.
26     */
27    public function __construct() {
28        // No menu_title: the package supplies its own translated label. Passing one here would
29        // mean translating it on plugins_loaded, too early for the textdomain to be loaded.
30        Analytics::init();
31
32        // Priority 0 leaves time for Cookie Consent to register its own default-priority
33        // init callbacks when the development config filter enables the package.
34        add_action( 'init', array( __CLASS__, 'init_cookie_consent' ), 0 );
35    }
36
37    /**
38     * Initialize Cookie Consent once WordPress translations can load safely.
39     *
40     * @return void
41     */
42    public static function init_cookie_consent() {
43        // Ships disabled: the banner is planned for a later release. The package stays wired up
44        // so the `jetpack_cookie_consent_config` filter can switch it back on for development.
45        Cookie_Consent::init( array( 'enabled' => false ) );
46    }
47}