Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
CRAP | n/a |
0 / 0 |
|
| Automattic\Jetpack\PremiumAnalytics\register_dashboard_feature_flags | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| Automattic\Jetpack\PremiumAnalytics\is_dashboard_unlocked_for_a11n | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| Automattic\Jetpack\PremiumAnalytics\configure_dashboard_policy | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| Automattic\Jetpack\PremiumAnalytics\inject_dashboard_policy_script_data | n/a |
0 / 0 |
n/a |
0 / 0 |
3 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * Dashboard policy: the dashboard feature flags and the shims older copies of the package call. |
| 4 | * |
| 5 | * @package automattic/jetpack-premium-analytics |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\PremiumAnalytics; |
| 9 | |
| 10 | /** |
| 11 | * Registers the dashboard feature flags: none today. |
| 12 | * |
| 13 | * Kept as the symbol the policy file is guarded on, and for older copies of the package that |
| 14 | * call it. |
| 15 | * |
| 16 | * @return void |
| 17 | */ |
| 18 | function register_dashboard_feature_flags() { |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * No-op kept for older copies of the package, whose dashboard-sections.php calls it after |
| 23 | * skipping its include of this file. |
| 24 | * |
| 25 | * @deprecated 0.10.0 The preview scope it opened is gone. |
| 26 | * |
| 27 | * @return bool |
| 28 | */ |
| 29 | function is_dashboard_unlocked_for_a11n() { |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Kept for older copies of the package, whose class-analytics.php calls it and whose client |
| 35 | * offers adding and removing widgets only while the script data says so. |
| 36 | * |
| 37 | * @deprecated 0.13.0 Adding and removing widgets is always offered. |
| 38 | * |
| 39 | * @return void |
| 40 | */ |
| 41 | function configure_dashboard_policy() { |
| 42 | add_filter( 'jetpack_admin_js_script_data', __NAMESPACE__ . '\\inject_dashboard_policy_script_data', 20 ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Tells an older copy's client that adding and removing widgets is offered. |
| 47 | * |
| 48 | * @deprecated 0.13.0 Adding and removing widgets is always offered. |
| 49 | * |
| 50 | * @param array $data The script data passed by the assets package. |
| 51 | * @return array |
| 52 | */ |
| 53 | function inject_dashboard_policy_script_data( array $data ): array { |
| 54 | if ( ! isset( $data['premium_analytics'] ) || ! is_array( $data['premium_analytics'] ) ) { |
| 55 | $data['premium_analytics'] = array(); |
| 56 | } |
| 57 | |
| 58 | $data['premium_analytics']['dashboard_composition_enabled'] = true; |
| 59 | |
| 60 | return $data; |
| 61 | } |