Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
WordAds_Premium_Analytics
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
3.07
0.00% covered (danger)
0.00%
0 / 1
 init
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
3.07
1<?php
2/**
3 * The Ads section of the Premium Analytics dashboard, on sites that run the WordAds module.
4 *
5 * @package automattic/jetpack
6 */
7
8use Automattic\Jetpack\Status\Host;
9use Automattic\Jetpack\WordAds\Analytics_Dashboard;
10
11/**
12 * Hands the Ads section and its widget types to the Premium Analytics dashboard.
13 *
14 * The section, its layout and the widgets live in the jetpack-ads package; this class decides
15 * that a site running the module gets them. On the WordPress.com platform jetpack-mu-wpcom decides,
16 * by plan feature and WordAds being on, and this registrant stays out.
17 *
18 * @since 16.3
19 */
20class WordAds_Premium_Analytics {
21
22    /**
23     * Hook the package's registrants on the dashboard's registry actions.
24     *
25     * @return void
26     */
27    public static function init() {
28        // Simple and Atomic decide by plan feature and WordAds being on, from jetpack-mu-wpcom.
29        if ( ( new Host() )->is_wpcom_platform() ) {
30            return;
31        }
32
33        if ( ! class_exists( Analytics_Dashboard::class ) ) {
34            return;
35        }
36
37        Analytics_Dashboard::init();
38    }
39}