Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
wpcom_simple_odyssey_stats_load_dashboard_widget
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * Load the Odyssey stats feature on WordPress.com Simple Site.
4 * See https://github.com/Automattic/jetpack/tree/trunk/projects/packages/stats-admin
5 *
6 * @package automattic/jetpack-mu-wpcom
7 */
8
9use Automattic\Jetpack\Stats_Admin\Dashboard as OdysseyStats;
10
11require_once __DIR__ . '/odyssey-stats-replaced.php';
12
13if ( ! wpcom_simple_odyssey_stats_is_replaced() ) {
14    OdysseyStats::init();
15}
16
17// Only register when the loader path is available at include time, matching the
18// original gate so the widget is not loaded on installs where it was not before.
19if ( defined( 'JETPACK_PLUGIN_LOADER_PATH' ) ) {
20    add_action( 'wp_dashboard_setup', 'wpcom_simple_odyssey_stats_load_dashboard_widget' );
21}
22
23if ( ! function_exists( 'wpcom_simple_odyssey_stats_load_dashboard_widget' ) ) {
24    /**
25     * Load the Odyssey stats widget when the WordPress dashboard is assembled.
26     *
27     * Loaded lazily so the widget class is not required on requests that never build
28     * the dashboard, and named so the callback can be unregistered. `init()` is a
29     * static, idempotent entry point, so no instance is needed.
30     *
31     * @return void
32     */
33    function wpcom_simple_odyssey_stats_load_dashboard_widget() {
34        if ( ! defined( 'JETPACK_PLUGIN_LOADER_PATH' ) ) {
35            return;
36        }
37        require_once JETPACK_PLUGIN_LOADER_PATH . '/class-jetpack-stats-dashboard-widget.php';
38        Jetpack_Stats_Dashboard_Widget::init();
39    }
40}