Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
8.33% |
1 / 12 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Jetpack_Stats_Feature_Flags | |
11.11% |
1 / 9 |
|
50.00% |
1 / 2 |
4.81 | |
0.00% |
0 / 1 |
| register | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| is_classic_page_retired | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Stats feature flags. |
| 4 | * |
| 5 | * @package automattic/jetpack |
| 6 | */ |
| 7 | |
| 8 | use Automattic\Jetpack\Feature_Flags\Feature_Flags; |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit( 0 ); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Registers the flag that retires the classic Stats page in favor of Stats v2. |
| 16 | * |
| 17 | * @since $$next-version$$ |
| 18 | */ |
| 19 | class Jetpack_Stats_Feature_Flags { |
| 20 | |
| 21 | const CLASSIC_PAGE_RETIRED = 'jetpack-stats-classic-page-retired'; |
| 22 | |
| 23 | /** |
| 24 | * Register the flag. |
| 25 | * |
| 26 | * @return void |
| 27 | */ |
| 28 | public static function register() { |
| 29 | Feature_Flags::register( |
| 30 | self::CLASSIC_PAGE_RETIRED, |
| 31 | array( |
| 32 | 'default' => false, |
| 33 | 'description' => 'Turn Stats v2 on for every site and stop registering the classic Stats page; old admin.php?page=stats links open Stats v2.', |
| 34 | 'owner' => 'jetpack-stats', |
| 35 | ) |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Whether the flag asks the classic Stats page to give way to Stats v2; the page stays while Stats v2 is off. |
| 41 | * |
| 42 | * Read on `plugins_loaded`, so a filter forcing it has to be added before that. |
| 43 | * |
| 44 | * @return bool |
| 45 | */ |
| 46 | public static function is_classic_page_retired() { |
| 47 | return Feature_Flags::is_enabled( self::CLASSIC_PAGE_RETIRED ); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | Jetpack_Stats_Feature_Flags::register(); |