-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
266 lines (235 loc) · 6.48 KB
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
/**
* Detect if the website is using a page builder/visual builder
*
* @author Mte90 <[email protected]>
* @license GPL-3.0+
* @copyright 2022
*
*/
class Page_Madness_Detector {
/**
* Plugin list
*
* @var array
*/
public $plugins_slug = array();
/**
* Themes list
*
* @var array
*/
public $themes_slug = array();
/**
* Filters to customize plugins/themes
*/
public function __construct() {
$this->plugins_slug = array(
'elementor' => array( 'detect' => 'elementor', 'version' => 'elementor_version' ),
'elementor-pro' => array( 'detect' => 'elementor_pro', 'version' => 'elementor_pro_version' ),
'js_composer' => array( 'detect' => 'wpbakery', 'version' => 'wpbakery_version' ),
'siteorigin' => array( 'detect' => 'siteorigin', 'version' => 'siteorigin_version' ),
'fl-builder' => array( 'detect' => 'beaverbuilder_lite', 'version' => 'beaverbuilder_lite_version' ),
'fusion' => array( 'detect' => 'fusion', 'version' => 'fusion_version' ),
'oxygen' => array( 'detect' => 'oxygen', 'version' => 'oxygen_version' ),
'bricks' => array( 'detect' => 'bricks', 'version' => 'bricks_version' ),
);
$this->themes_slug = array(
'divi' => array( 'detect' => 'divi', 'version' => 'divi_version' ),
);
$this->plugins_slug = \apply_filters( 'page_madness_detector_add_plugin_detection', $this->plugins_slug );
$this->themes_slug = \apply_filters( 'page_madness_detector_add_theme_detection', $this->themes_slug );
}
/**
* Detect if that page builder is active
*
* @param string $slug The plugin/theme slug/textdomain
* @return bool
*/
public function detect( $slug ) {
if ( isset( $this->plugins_slug[ $slug ] ) ) {
return \call_user_func( $this->plugins_slug[ $slug ]['detect'] );
}
if ( isset( $this->themes_slug[ $slug ] ) ) {
return \call_user_func( $this->themes_slug[ $slug ]['detect'] );
}
return false;
}
/**
* Return the page builder version if found
*
* @param string $slug The plugin/theme slug/textdomain
* @return string|bool
*/
public function version( $slug ) {
if ( isset( $this->plugins_slug[ $slug ] ) ) {
return \call_user_func( $this->plugins_slug[ $slug ]['version'] );
}
if ( isset( $this->themes_slug[ $slug ] ) ) {
return \call_user_func( $this->themes_slug[ $slug ]['version'] );
}
return false;
}
/**
* Detect if there is atleast one of the page builder active
*
* @return bool
*/
public function has_entropy() {
foreach( $this->plugins_slug as $plugin ) {
if ( \call_user_func( array( $this, $plugin['detect'] ) ) ) {
return true;
}
}
foreach( $this->themes_slug as $theme ) {
if ( \call_user_func( array( $this, $theme['detect'] ) ) ) {
return true;
}
}
return false;
}
/**
* Detect if Elementor Free
*
* @return bool
*/
public static function elementor() {
return \defined( 'ELEMENTOR_VERSION' );
}
/**
* Return Elementor Free version
*
* @return string
*/
public static function elementor_version() {
return \defined( 'ELEMENTOR_VERSION' ) && \ELEMENTOR_VERSION;
}
/**
* Detect if Elementor Pro
*
* @return bool
*/
public static function elementor_pro() {
return \defined( 'ELEMENTOR_PRO_VERSION' );
}
/**
* Return Elementor Pro version
*
* @return string
*/
public static function elementor_pro_version() {
return \defined( 'ELEMENTOR_PRO_VERSION' ) && \ELEMENTOR_PRO_VERSION;
}
/**
* Detect if WPBakery
*
* @return bool
*/
public static function wpbakery() {
return \defined( 'WPB_VC_VERSION' );
}
/**
* Return WPBakery version
*
* @return string
*/
public static function wpbakery_version() {
return \defined( 'WPB_VC_VERSION' ) && \WPB_VC_VERSION;
}
/**
* Detect if Page Builder by Siteorigin
*
* @return bool
*/
public static function siteorigin() {
return \defined( 'SITEORIGIN_PANELS_VERSION' );
}
/**
* Return Page Builder by Siteorigin version
*
* @return string
*/
public static function siteorigin_version() {
return \defined( 'SITEORIGIN_PANELS_VERSION' ) && \SITEORIGIN_PANELS_VERSION;
}
/**
* Detect if Beaver Builder
*
* @return bool
*/
public static function beaverbuilder_lite() {
return \defined( 'FL_BUILDER_VERSION' );
}
/**
* Return Beaver Builder version
*
* @return string
*/
public static function beaverbuilder_lite_version() {
return \defined( 'FL_BUILDER_VERSION' ) && \FL_BUILDER_VERSION;
}
/**
* Detect if Fusion Page Builder
*
* @return bool
*/
public static function fusion() {
return \defined( 'FSN_VERSION' );
}
/**
* Return Fusion Page Builder version
*
* @return string
*/
public static function fusion_version() {
return \defined( 'FSN_VERSION' ) && \FSN_VERSION;
}
/**
* Detect if Oxygen Builder
*
* @return bool
*/
public static function oxygen() {
return \defined( 'CT_VERSION' );
}
/**
* Return Oxygen Builder version
*
* @return string
*/
public static function oxygen_version() {
return \defined( 'CT_VERSION' ) && \CT_VERSION;
}
/**
* Detect if Divi
*
* @return bool
*/
public static function divi() {
return \function_exists( 'et_setup_theme' );
}
/**
* Return Divi version
*
* @return string
*/
public static function divi_version() {
return \function_exists( 'et_setup_theme' ) && \et_get_theme_version();
}
/**
* Detect if Bricks
*
* @return bool
*/
public static function bricks() {
return \defined( 'BRICKS_VERSION' );
}
/**
* Return Bricks version
*
* @return string
*/
public static function bricks_version() {
return \defined( 'BRICKS_VERSION' ) && \BRICKS_VERSION;
}
}