PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.6.1
GiveWP – Donation Plugin and Fundraising Platform v3.6.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 / TrackingData / ThemeData.php

ThemeData.php in GiveWP – Donation Plugin and Fundraising Platform 3.6.1, at src/Tracking/TrackingData/ThemeData.php

68 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Tracking\TrackingData;
4
5 use Give\Tracking\Contracts\TrackData;
6 use Give\Traits\HasWpTheme;
7 use WP_Theme;
8
9 /**
10 * Class ThemeData
11 *
12 * Represents the theme data.
13 *
14 * @package Give\Tracking\TrackingData
15 * @since 2.10.0
16 */
17 class ThemeData implements TrackData
18 {
19 use HasWpTheme;
20
21 /**
22 * Returns the collection data.
23 *
24 * @since 2.10.0
25 *
26 * @return array The collection data.
27 */
28 public function get()
29 {
30 $theme = wp_get_theme();
31 $data = $this->formatData($theme);
32
33 if ($this->isChildTheme($theme)) {
34 $parentTheme = wp_get_theme($theme->offsetGet('Template'));
35 $data = array_merge($data, $this->formatData($parentTheme, true));
36 }
37
38 return $data;
39 }
40
41 /**
42 * Format theme data.
43 *
44 * @since 2.10.0
45 *
46 * @param WP_Theme $theme
47 * @param bool $parentTheme
48 *
49 * @return array
50 */
51 private function formatData($theme, $parentTheme = false)
52 {
53 $slugKey = 'theme_slug';
54 $versionKey = 'theme_version';
55
56 if ($parentTheme) {
57 $slugKey = 'parent_theme_slug';
58 $versionKey = 'parent_theme_version';
59 }
60
61 return [
62 $slugKey => $theme->offsetGet('Stylesheet'),
63 $versionKey => $theme->get('Version'),
64 ];
65 }
66 }
67
68