PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.13.1
GiveWP – Donation Plugin and Fundraising Platform v2.13.1
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Tracking / Events / ThemeTracking.php
ThemeTracking.php
59 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Give\Tracking\Events;
3
4 use Give\Tracking\Contracts\TrackEvent;
5 use Give\Tracking\TrackRegisterer;
6 use Give\Tracking\TrackingData\ThemeData;
7 use Give\Tracking\Enum\EventType;
8 use Give\Traits\HasWpTheme;
9 use WP_Upgrader;
10
11 /**
12 * Class ThemeTracking
13 *
14 * This class setup event to send tracked data request when active theme changes.
15 *
16 * @since 2.10.0
17 * @package Give\Tracking\Admin\Events
18 */
19 class ThemeTracking extends TrackEvent {
20 use HasWpTheme;
21
22 /**
23 * @var string
24 */
25 protected $dataClassName = ThemeData::class;
26
27 /**
28 * GivePluginSettingsTracking constructor.
29 *
30 * @param TrackRegisterer $track
31 */
32 public function __construct( TrackRegisterer $track ) {
33 $this->eventType = new EventType( EventType::THEME_SWITCHED );
34 parent::__construct( $track );
35 }
36
37 /**
38 * Theme update tracking handler.
39 *
40 * @since 2.10.0
41 *
42 * @param bool|WP_Upgrader $upgrader
43 * @param array $data
44 */
45 public function themeUpdateTrackingHandler( $upgrader = false, $data = [] ) {
46 // Return if it's not a WordPress core update.
47 if ( ! $upgrader || ! isset( $data['type'] ) || 'theme' !== $data['type'] ) {
48 return;
49 }
50
51 foreach ( $data['themes'] as $theme ) {
52 if ( get_stylesheet() === $theme || get_template() === $theme || $this->isParentTheme( $theme ) ) {
53 $this->trackId = new EventType( EventType::THEME_UPDATED );
54 $this->record();
55 }
56 }
57 }
58 }
59