REST
2 weeks ago
Reports
1 week ago
Sync
2 weeks ago
class-analytics.php
2 days ago
class-capabilities.php
2 weeks ago
class-connection-configuration.php
2 weeks ago
class-dashboard-section-registry.php
2 weeks ago
class-dashboard-section.php
2 days ago
class-dashboard-support-routes.php
1 week ago
class-jetpack-stats-tracker.php
2 weeks ago
class-notices.php
2 weeks ago
class-widget-type-registry.php
2 weeks ago
class-widget-type.php
2 weeks ago
class-woocommerce-analytics-tracker.php
2 weeks ago
csv-exports.php
2 weeks ago
dashboard-grammar.php
2 weeks ago
dashboard-layout.php
2 days ago
dashboard-sections.php
2 days ago
rest-namespace.php
2 weeks ago
videopress-availability.php
2 days ago
widget-availability.php
2 days ago
widget-i18n.json
2 weeks ago
widget-modules.php
2 days ago
widget-type-support.php
2 days ago
widget-types.php
2 weeks ago
csv-exports.php
48 lines
| 1 | <?php |
| 2 | /** |
| 3 | * CSV export script-data wiring. |
| 4 | * |
| 5 | * @package automattic/jetpack-premium-analytics |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\PremiumAnalytics; |
| 9 | |
| 10 | /** |
| 11 | * Filter controlling whether CSV export controls are shown. |
| 12 | * |
| 13 | * @var string |
| 14 | */ |
| 15 | const CSV_EXPORTS_ENABLED_FILTER = 'jetpack_premium_analytics_csv_exports_enabled'; |
| 16 | |
| 17 | /** |
| 18 | * Configures CSV export script data. |
| 19 | * |
| 20 | * @return void |
| 21 | */ |
| 22 | function configure_csv_exports() { |
| 23 | add_filter( 'jetpack_admin_js_script_data', __NAMESPACE__ . '\\inject_csv_exports_script_data', 20 ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Injects the CSV export flag into JetpackScriptData. |
| 28 | * |
| 29 | * @param array $data The script data passed by the assets package. |
| 30 | * @return array |
| 31 | */ |
| 32 | function inject_csv_exports_script_data( array $data ): array { |
| 33 | if ( ! isset( $data['premium_analytics'] ) || ! is_array( $data['premium_analytics'] ) ) { |
| 34 | $data['premium_analytics'] = array(); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Filters whether Premium Analytics should show CSV export controls. |
| 39 | * |
| 40 | * CSV exports are enabled by default. Return false to disable them. |
| 41 | * |
| 42 | * @param bool $enabled Whether to show CSV export controls. |
| 43 | */ |
| 44 | $data['premium_analytics']['csv_exports_enabled'] = (bool) apply_filters( CSV_EXPORTS_ENABLED_FILTER, true ); |
| 45 | |
| 46 | return $data; |
| 47 | } |
| 48 |