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