PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / trunk
WCPOS – Point of Sale (POS) plugin for WooCommerce vtrunk
1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 1.9.13 1.9.12 1.9.11 1.9.10 All 159 releases
woocommerce-pos / includes / Admin / Analytics.php

Analytics.php in WCPOS – Point of Sale (POS) plugin for WooCommerce trunk, at includes/Admin/Analytics.php

64 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Analytics.
4 *
5 * @package WCPOS\WooCommercePOS
6 */
7
8 namespace WCPOS\WooCommercePOS\Admin;
9
10 use const WCPOS\WooCommercePOS\PLUGIN_NAME;
11 use const WCPOS\WooCommercePOS\PLUGIN_URL;
12 use const WCPOS\WooCommercePOS\TRANSLATION_VERSION;
13 use const WCPOS\WooCommercePOS\VERSION;
14
15 /**
16 * Analytics class.
17 */
18 class Analytics {
19
20 /**
21 * Constructor.
22 */
23 public function __construct() {
24 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
25 add_action( 'admin_head', array( $this, 'analytics_css' ) );
26 }
27
28 /**
29 * Add CSS to the admin head
30 */
31 public function analytics_css() {
32 echo '<style>.woocommerce-pos-upgrade-notice { margin: 0 0 24px 0; }</style>';
33 }
34
35 /**
36 * Enqueue analytics assets.
37 */
38 public function enqueue_assets() {
39 $is_development = isset( $_ENV['DEVELOPMENT'] )
40 && wp_validate_boolean( sanitize_text_field( wp_unslash( $_ENV['DEVELOPMENT'] ) ) );
41 $dir = $is_development ? 'build' : 'assets';
42
43 // Inject translation version for i18next.
44 wp_add_inline_script(
45 'wp-hooks',
46 'window.wcpos = window.wcpos || {}; window.wcpos.translationVersion = "' . esc_js( TRANSLATION_VERSION ) . '";',
47 'before'
48 );
49
50 wp_enqueue_script(
51 PLUGIN_NAME . '-analytics',
52 PLUGIN_URL . $dir . '/js/analytics.js',
53 array(
54 'wp-hooks',
55 'wc-components',
56 ),
57 VERSION,
58 true
59 );
60
61 wp_add_inline_script( PLUGIN_NAME . '-analytics', Menu::get_posthog_inline_script(), 'before' );
62 }
63 }
64