class-wc-admin-setup-wizard-tracking.php
5 years ago
class-wc-coupon-tracking.php
6 years ago
class-wc-coupons-tracking.php
7 months ago
class-wc-extensions-tracking.php
1 year ago
class-wc-importer-tracking.php
3 years ago
class-wc-order-tracking.php
6 years ago
class-wc-orders-tracking.php
1 year ago
class-wc-product-collection-block-tracking.php
7 months ago
class-wc-products-tracking.php
1 month ago
class-wc-settings-tracking.php
11 months ago
class-wc-status-tracking.php
7 months ago
class-wc-theme-tracking.php
1 year ago
class-wc-theme-tracking.php
53 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Theme Tracking |
| 4 | * |
| 5 | * @package WooCommerce\Tracks |
| 6 | */ |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * This class adds actions to track usage of themes on a WooCommerce store. |
| 12 | */ |
| 13 | class WC_Theme_Tracking { |
| 14 | |
| 15 | /** |
| 16 | * Init tracking. |
| 17 | */ |
| 18 | public function init() { |
| 19 | $this->track_initial_theme(); |
| 20 | add_action( 'switch_theme', array( $this, 'track_activated_theme' ) ); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Tracks the sites current theme the first time this code is run, and will only be run once. |
| 25 | */ |
| 26 | public function track_initial_theme() { |
| 27 | $has_been_initially_tracked = get_option( 'wc_has_tracked_default_theme' ); |
| 28 | |
| 29 | if ( $has_been_initially_tracked ) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | $this->track_activated_theme(); |
| 34 | add_option( 'wc_has_tracked_default_theme', 1 ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Send a Tracks event when a theme is activated so that we can track active block themes. |
| 39 | */ |
| 40 | public function track_activated_theme() { |
| 41 | $is_block_theme = wp_is_block_theme(); |
| 42 | $theme_object = wp_get_theme(); |
| 43 | |
| 44 | $properties = array( |
| 45 | 'block_theme' => $is_block_theme, |
| 46 | 'theme_name' => $theme_object->get( 'Name' ), |
| 47 | 'theme_version' => $theme_object->get( 'Version' ), |
| 48 | ); |
| 49 | |
| 50 | WC_Tracks::record_event( 'activated_theme', $properties ); |
| 51 | } |
| 52 | } |
| 53 |