PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
jetpack / jetpack_vendor / automattic / jetpack-premium-analytics / src / csv-exports.php

csv-exports.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-beta, at jetpack_vendor/automattic/jetpack-premium-analytics/src/csv-exports.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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