PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.6
Elementor Website Builder – more than just a page builder v3.0.6
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / system-info / reporters / theme.php

theme.php in Elementor Website Builder – more than just a page builder 3.0.6, at modules/system-info/reporters/theme.php

258 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\System_Info\Reporters;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor theme report.
10 *
11 * Elementor system report handler class responsible for generating a report for
12 * the theme.
13 *
14 * @since 1.0.0
15 */
16 class Theme extends Base {
17
18 /**
19 * Theme.
20 *
21 * Holds the sites theme object.
22 *
23 * @since 1.0.0
24 * @access private
25 *
26 * @var \WP_Theme WordPress theme object.
27 */
28 private $theme = null;
29
30 /**
31 * Get theme reporter title.
32 *
33 * Retrieve theme reporter title.
34 *
35 * @since 1.0.0
36 * @access public
37 *
38 * @return string Reporter title.
39 */
40 public function get_title() {
41 return 'Theme';
42 }
43
44 /**
45 * Get theme report fields.
46 *
47 * Retrieve the required fields for the theme report.
48 *
49 * @since 1.0.0
50 * @access public
51 *
52 * @return array Required report fields with field ID and field label.
53 */
54 public function get_fields() {
55 $fields = [
56 'name' => 'Name',
57 'version' => 'Version',
58 'author' => 'Author',
59 'is_child_theme' => 'Child Theme',
60 ];
61
62 if ( $this->get_parent_theme() ) {
63 $parent_fields = [
64 'parent_name' => 'Parent Theme Name',
65 'parent_version' => 'Parent Theme Version',
66 'parent_author' => 'Parent Theme Author',
67 ];
68 $fields = array_merge( $fields, $parent_fields );
69 }
70
71 return $fields;
72 }
73
74 /**
75 * Get theme.
76 *
77 * Retrieve the theme.
78 *
79 * @since 1.0.0
80 * @access protected
81 *
82 * @return \WP_Theme WordPress theme object.
83 */
84 protected function _get_theme() {
85 if ( is_null( $this->theme ) ) {
86 $this->theme = wp_get_theme();
87 }
88 return $this->theme;
89 }
90
91 /**
92 * Get parent theme.
93 *
94 * Retrieve the parent theme.
95 *
96 * @since 1.0.0
97 * @access protected
98 *
99 * @return \WP_Theme|false WordPress theme object, or false if the current theme is not a child theme.
100 */
101 protected function get_parent_theme() {
102 return $this->_get_theme()->parent();
103 }
104
105 /**
106 * Get theme name.
107 *
108 * Retrieve the theme name.
109 *
110 * @since 1.0.0
111 * @access public
112 *
113 * @return array {
114 * Report data.
115 *
116 * @type string $value The theme name.
117 * }
118 */
119 public function get_name() {
120 return [
121 'value' => $this->_get_theme()->get( 'Name' ),
122 ];
123 }
124
125 /**
126 * Get theme author.
127 *
128 * Retrieve the theme author.
129 *
130 * @since 1.0.0
131 * @access public
132 *
133 * @return array {
134 * Report data.
135 *
136 * @type string $value The theme author.
137 * }
138 */
139 public function get_author() {
140 return [
141 'value' => $this->_get_theme()->get( 'Author' ),
142 ];
143 }
144
145 /**
146 * Get theme version.
147 *
148 * Retrieve the theme version.
149 *
150 * @since 1.0.0
151 * @access public
152 *
153 * @return array {
154 * Report data.
155 *
156 * @type string $value The theme version.
157 * }
158 */
159 public function get_version() {
160 return [
161 'value' => $this->_get_theme()->get( 'Version' ),
162 ];
163 }
164
165 /**
166 * Is the theme is a child theme.
167 *
168 * Whether the theme is a child theme.
169 *
170 * @since 1.0.0
171 * @access public
172 *
173 * @return array {
174 * Report data.
175 *
176 * @type string $value Yes if the theme is a child theme, No otherwise.
177 * @type string $recommendation Theme source code modification recommendation.
178 * }
179 */
180 public function get_is_child_theme() {
181 $is_child_theme = is_child_theme();
182
183 $result = [
184 'value' => $is_child_theme ? 'Yes' : 'No',
185 ];
186
187 if ( ! $is_child_theme ) {
188 $result['recommendation'] = sprintf(
189 /* translators: %s: Codex URL */
190 _x( 'If you want to modify the source code of your theme, we recommend using a <a href="%s">child theme</a>.', 'System Info', 'elementor' ),
191 'https://go.elementor.com/wordpress-child-themes/'
192 );
193 }
194
195 return $result;
196 }
197
198 /**
199 * Get parent theme version.
200 *
201 * Retrieve the parent theme version.
202 *
203 * @since 1.0.0
204 * @access public
205 *
206 * @return array {
207 * Report data.
208 *
209 * @type string $value The parent theme version.
210 * }
211 */
212 public function get_parent_version() {
213 return [
214 'value' => $this->get_parent_theme()->get( 'Version' ),
215 ];
216 }
217
218 /**
219 * Get parent theme author.
220 *
221 * Retrieve the parent theme author.
222 *
223 * @since 1.0.0
224 * @access public
225 *
226 * @return array {
227 * Report data.
228 *
229 * @type string $value The parent theme author.
230 * }
231 */
232 public function get_parent_author() {
233 return [
234 'value' => $this->get_parent_theme()->get( 'Author' ),
235 ];
236 }
237
238 /**
239 * Get parent theme name.
240 *
241 * Retrieve the parent theme name.
242 *
243 * @since 1.0.0
244 * @access public
245 *
246 * @return array {
247 * Report data.
248 *
249 * @type string $value The parent theme name.
250 * }
251 */
252 public function get_parent_name() {
253 return [
254 'value' => $this->get_parent_theme()->get( 'Name' ),
255 ];
256 }
257 }
258