Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
wpcom_simple_odyssey_stats_is_replaced
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
1<?php
2/**
3 * When Stats v2 takes the Odyssey Stats page's place on WordPress.com Simple.
4 *
5 * @package automattic/jetpack-mu-wpcom
6 */
7
8use Automattic\Jetpack\PremiumAnalytics\Analytics;
9use Automattic\Jetpack\PremiumAnalytics\Classic_Stats;
10
11if ( ! function_exists( 'wpcom_simple_odyssey_stats_is_replaced' ) ) {
12    /**
13     * Whether Stats v2 takes over `admin.php?page=stats`: classic Stats is retired and Stats v2 booted in this request.
14     *
15     * @return bool
16     */
17    function wpcom_simple_odyssey_stats_is_replaced() {
18        // An older Premium Analytics copy predates the retirement flag.
19        if ( ! is_callable( array( Classic_Stats::class, 'is_retired' ) ) ) {
20            return false;
21        }
22
23        return Classic_Stats::is_retired() && Analytics::is_initialized();
24    }
25}