|
17 | 17 | use WP_REST_Request; |
18 | 18 | use WP_REST_Server; |
19 | 19 |
|
| 20 | +require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
20 | 21 | require_once __DIR__ . '/../../src/dashboard-sections.php'; |
21 | 22 | require_once __DIR__ . '/../../src/default-dashboard-sections.php'; |
22 | 23 | require_once __DIR__ . '/traits/trait-analytics-capabilities.php'; |
@@ -1440,13 +1441,33 @@ public function test_section_script_data_keeps_the_other_premium_analytics_keys( |
1440 | 1441 | array( |
1441 | 1442 | 'has_videopress' => true, |
1442 | 1443 | 'can_view_stats' => true, |
| 1444 | + 'classic_stats_url' => null, |
1443 | 1445 | 'sections' => array( 'traffic', 'insights', 'subscribers' ), |
1444 | 1446 | 'plan_date_limited_sections' => array( 'traffic' ), |
1445 | 1447 | ), |
1446 | 1448 | $data['premium_analytics'] |
1447 | 1449 | ); |
1448 | 1450 | } |
1449 | 1451 |
|
| 1452 | + /** |
| 1453 | + * Switching the dashboard off lands on classic Stats, so the client is told where that page |
| 1454 | + * is, also when the Jetpack plugin registers it under its own menu rather than top-level. |
| 1455 | + */ |
| 1456 | + public function test_section_script_data_carries_the_classic_stats_page_url() { |
| 1457 | + $this->assertNull( inject_dashboard_sections_script_data( array() )['premium_analytics']['classic_stats_url'] ); |
| 1458 | + |
| 1459 | + $GLOBALS['_parent_pages']['jetpack'] = false; |
| 1460 | + $GLOBALS['_parent_pages']['stats'] = 'jetpack'; |
| 1461 | + try { |
| 1462 | + $this->assertSame( |
| 1463 | + admin_url( 'admin.php?page=stats' ), |
| 1464 | + inject_dashboard_sections_script_data( array() )['premium_analytics']['classic_stats_url'] |
| 1465 | + ); |
| 1466 | + } finally { |
| 1467 | + unset( $GLOBALS['_parent_pages']['jetpack'], $GLOBALS['_parent_pages']['stats'] ); |
| 1468 | + } |
| 1469 | + } |
| 1470 | + |
1450 | 1471 | /** |
1451 | 1472 | * The sections route drops the Subscribers tab once it is unavailable. |
1452 | 1473 | */ |
|
0 commit comments