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 / TrackingData / ThemeData.php

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

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