PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.8.9
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.8.9
4.11.79 4.11.78 4.11.77 4.11.76 4.11.75 3.20.5 4.11.69 3.20.6 4.11.7 3.20.7 4.11.70 3.20.8 4.11.71 3.20.9 4.11.72 3.21.1 4.11.73 3.21.2 4.11.74 3.21.3 4.11.8 3.21.4 4.11.9 3.21.5 4.2.0 3.21.6 4.2.1 3.3.0 4.2.2 3.3.1 4.2.3 3.3.2 4.2.4 3.3.3 4.2.5 3.3.4 4.2.6 3.3.5 4.2.7 3.3.6 4.2.8 3.3.7 4.2.9 3.3.8 4.3.0 3.3.9 4.3.1 3.4.0 4.3.2 3.4.1 4.3.3 3.4.2 4.3.4 3.4.3 4.3.5 3.4.4 4.3.6 3.4.5 4.3.7 3.4.6 4.3.8 3.4.7 4.3.9 3.4.8 4.4.0 3.4.9 4.4.1 3.5.0 4.4.2 3.5.1 4.4.3 3.5.2 4.4.4 3.5.3 4.4.5 3.5.4 4.4.6 3.5.5 4.4.7 3.5.6 4.4.8 3.5.7 4.4.9 3.5.8 4.5.0 3.5.9 4.5.1 3.6.0 4.5.2 3.6.1 4.5.3 3.6.2 4.5.4 3.6.3 4.5.5 3.6.4 4.5.6 3.6.5 4.5.7 3.6.6 4.5.8 3.6.7 4.5.9 3.6.8 4.6.0 3.6.9 4.6.1 3.7.0 4.7.0 3.7.1 4.7.1 3.7.2 4.7.2 3.7.3 4.7.3 3.7.4 4.7.4 3.7.5 4.7.5 3.7.6 4.7.6 3.7.7 4.7.7 3.7.8 4.7.8 3.7.9 4.7.9 3.8.0 4.8.0 3.8.1 4.8.1 3.8.2 4.8.10 3.8.3 4.8.11 3.8.4 4.8.2 3.8.5 4.8.3 3.8.6 4.8.4 3.8.7 4.8.5 3.8.8 4.8.6 3.8.9 4.8.7 3.9.0 4.8.8 3.9.1 4.8.9 3.9.2 4.9.0 3.9.3 4.9.0-beta1 3.9.4 4.9.0-beta2 3.9.5 4.9.1 3.9.6 4.9.10 3.9.7 4.9.11 3.9.8 4.9.12 3.9.9 4.9.13 4.0.1 4.9.14 4.0.3 4.9.15 4.0.4 4.9.16 4.0.5 4.9.17 4.0.6 4.9.18 4.0.7 4.9.19 4.0.8 4.9.2 4.0.9 4.9.20 4.1.0 4.9.21 4.1.1 4.9.22 4.1.2 4.9.23 4.1.3 4.9.24 trunk 4.1.4 4.9.25 1.0 4.1.5 4.9.26 1.01 4.1.6 4.9.27 1.02 4.1.7 4.9.28 1.03 4.1.8 4.9.29 1.04 4.1.9 4.9.3 1.05 4.10.0 4.9.30 1.06 4.10.1 4.9.31 1.07 4.10.10 4.9.32 1.08 4.10.11 4.9.33 1.09 4.10.12 4.9.34 2.0 4.10.13 4.9.35 2.0.1 4.10.14 4.9.36 2.0.2 4.10.15 4.9.37 2.0.3 4.10.16 4.9.38 2.0.4 4.10.17 4.9.39 2.0.5 4.10.18 4.9.4 2.0.6 4.10.19 4.9.40 2.0.7 4.10.2 4.9.41 2.0.8 4.10.20 4.9.42 2.0.9 4.10.21 4.9.43 2.1.0 4.10.22 4.9.45 2.1.1 4.10.23 4.9.46 2.1.2 4.10.24 4.9.47 2.1.3 4.10.25 4.9.48 2.1.4 4.10.26 4.9.49 2.1.5 4.10.27 4.9.5 2.1.5-beta1 4.10.28 4.9.50 2.1.6 4.10.29 4.9.51 2.1.7 4.10.3 4.9.52 2.1.8 4.10.30 4.9.53 2.1.9 4.10.31 4.9.54 2.2.0 4.10.32 4.9.55 2.2.1 4.10.33 4.9.56 2.2.2 4.10.34 4.9.57 2.2.3 4.10.35 4.9.6 2.2.4 4.10.36 4.9.7 2.2.5 4.10.37 4.9.8 2.2.6 4.10.38 4.9.9 2.2.7 4.10.39 2.2.8 4.10.4 2.2.9 4.10.40 2.3.0 4.10.41 2.3.1 4.10.42 2.3.2 4.10.43 2.3.3 4.10.44 2.3.4 4.10.45 2.3.5 4.10.46 2.3.6 4.10.47 2.3.7 4.10.48 2.3.8 4.10.49 2.3.9 4.10.5 2.4.0 4.10.50 2.4.1 4.10.51 2.5.0 4.10.52 2.5.1 4.10.53 2.5.2 4.10.54 2.5.3 4.10.55 2.5.4 4.10.56 2.5.5 4.10.57 2.5.6 4.10.58 2.5.7 4.10.59 2.5.8 4.10.6 2.5.9 4.10.60 2.6.0 4.10.61 2.6.1 4.10.62 2.6.2 4.10.63 2.6.3 4.10.64 2.6.4 4.10.65 2.6.5 4.10.66 2.6.6 4.10.67 2.6.7 4.10.68 2.6.8 4.10.69 2.6.9 4.10.7 2.7.0 4.10.70 2.7.1 4.10.71 2.7.2 4.10.72 2.7.3 4.10.73 2.7.4 4.10.74 2.7.5 4.10.75 2.7.6 4.10.76 2.7.7 4.10.77 2.7.8 4.10.78 2.7.9 4.10.79 2.8.0 4.10.8 2.8.1 4.10.80 2.8.2 4.10.81 2.8.3 4.10.82 2.8.4 4.10.83 2.8.5 4.10.84 2.8.6 4.10.85 2.8.7 4.10.86 2.8.8 4.10.87 2.8.9 4.10.88 2.9.0 4.10.89 2.9.1 4.10.9 2.9.2 4.10.90 2.9.3 4.11.0 2.9.4 4.11.1 2.9.5 4.11.10 2.9.6 4.11.11 2.9.7 4.11.12 2.9.8 4.11.13 2.9.9 4.11.14 3.0.0 4.11.15 3.0.1 4.11.16 3.0.2 4.11.17 3.0.3 4.11.18 3.0.4 4.11.19 3.0.5 4.11.2 3.0.6 4.11.20 3.0.7 4.11.21 3.0.8 4.11.22 3.0.9 4.11.23 3.1.0 4.11.24 3.1.1 4.11.25 3.1.2 4.11.26 3.1.3 4.11.27 3.1.4 4.11.28 3.1.5 4.11.29 3.1.6 4.11.3 3.1.7 4.11.30 3.1.8 4.11.31 3.1.9 4.11.32 3.10.0 4.11.33 3.10.1 4.11.34 3.10.2 4.11.35 3.10.3 4.11.36 3.10.4 4.11.37 3.10.5 4.11.38 3.10.6 4.11.39 3.10.7 4.11.4 3.10.8 4.11.40 3.10.9 4.11.41 3.11.0 4.11.42 3.11.1 4.11.43 3.11.2 4.11.44 3.11.3 4.11.45 3.11.4 4.11.46 3.11.5 4.11.47 3.11.6 4.11.48 3.11.7 4.11.49 3.11.8 4.11.5 3.11.9 4.11.50 3.12.0 4.11.51 3.12.1 4.11.52 3.12.2 4.11.53 3.12.3 4.11.54 3.2.0 4.11.55 3.2.1 4.11.56 3.2.2 4.11.57 3.2.3 4.11.58 3.2.4 4.11.59 3.2.5 4.11.6 3.2.6 4.11.60 3.2.7 4.11.61 3.2.8 4.11.62 3.2.9 4.11.63 3.20.0 4.11.64 3.20.1 4.11.65 3.20.2 4.11.66 3.20.3 4.11.67 3.20.4 4.11.68
premium-addons-for-elementor / includes / helper-functions.php
premium-addons-for-elementor / includes Last commit date
compatibility 4 years ago controls 4 years ago pa-display-conditions 4 years ago templates 4 years ago acf-helper.php 4 years ago addons-cross-cp.php 4 years ago addons-integration.php 4 years ago class-pa-core.php 4 years ago class-premium-template-tags.php 4 years ago helper-functions.php 4 years ago lang-locale.php 4 years ago module-base.php 4 years ago
helper-functions.php
884 lines
1 <?php
2 /**
3 * PA Helper Functions.
4 */
5
6 namespace PremiumAddons\Includes;
7
8 // Premium Addons Pro Classes.
9 use PremiumAddonsPro\Includes\White_Label\Helper;
10
11 // Elementor Classes.
12 use Elementor\Core\Settings\Manager as SettingsManager;
13 use Elementor\Plugin;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Class Helper_Functions.
21 */
22 class Helper_Functions {
23
24 /**
25 * A list of safe tage for `validate_html_tag` method.
26 */
27 const ALLOWED_HTML_WRAPPER_TAGS = array(
28 'article',
29 'aside',
30 'div',
31 'footer',
32 'h1',
33 'h2',
34 'h3',
35 'h4',
36 'h5',
37 'h6',
38 'header',
39 'main',
40 'nav',
41 'p',
42 'section',
43 'span',
44 );
45
46 /**
47 * Google maps prefixes
48 *
49 * @var google_localize
50 */
51 private static $google_localize = null;
52
53 /**
54 * WP lang prefixes
55 *
56 * @var lang_locales
57 */
58 private static $lang_locales = null;
59
60 /**
61 * Script debug enabled
62 *
63 * @var script_debug
64 */
65 private static $script_debug = null;
66
67 /**
68 * JS scripts directory
69 *
70 * @var js_dir
71 */
72 private static $js_dir = null;
73
74 /**
75 * CSS fiels directory
76 *
77 * @var js_dir
78 */
79 private static $css_dir = null;
80
81 /**
82 * JS Suffix
83 *
84 * @var js_suffix
85 */
86 private static $assets_suffix = null;
87
88 /**
89 * Check if white labeling - Free version author field is set
90 *
91 * @since 1.0.0
92 * @access public
93 *
94 * @return string
95 */
96 public static function author() {
97
98 $author_free = 'Leap13';
99
100 if ( self::check_papro_version() ) {
101
102 $white_label = Helper::get_white_labeling_settings();
103
104 $author_free = $white_label['premium-wht-lbl-name'];
105
106 }
107
108 return '' !== $author_free ? $author_free : 'Leap13';
109 }
110
111 /**
112 * Check if white labeling - Free version name field is set
113 *
114 * @since 1.0.0
115 * @access public
116 *
117 * @return string
118 */
119 public static function name() {
120
121 $name_free = 'Premium Addons for Elementor';
122
123 if ( self::check_papro_version() ) {
124
125 $white_label = Helper::get_white_labeling_settings();
126
127 $name_free = $white_label['premium-wht-lbl-plugin-name'];
128
129 }
130
131 return '' !== $name_free ? $name_free : 'Premium Addons for Elementor';
132 }
133
134 /**
135 * Check if white labeling - Hide row meta option is checked
136 *
137 * @since 1.0.0
138 * @return string
139 */
140 public static function is_hide_row_meta() {
141
142 if ( self::check_papro_version() ) {
143
144 $white_label = Helper::get_white_labeling_settings();
145
146 $hide_meta = $white_label['premium-wht-lbl-row'];
147
148 }
149
150 return isset( $hide_meta ) ? $hide_meta : false;
151 }
152
153 /**
154 * Check if white labeling - Hide plugin logo option is checked
155 *
156 * @since 1.0.0
157 * @access public
158 *
159 * @return string
160 */
161 public static function is_hide_logo() {
162
163 if ( self::check_papro_version() ) {
164
165 if ( isset( get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'] ) ) {
166
167 $hide_logo = get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'];
168
169 }
170 }
171
172 return isset( $hide_logo ) ? $hide_logo : false;
173 }
174
175 /**
176 * Get White Labeling - Widgets Category string
177 *
178 * @since 1.0.0
179 * @access public
180 *
181 * @return string
182 */
183 public static function get_category() {
184
185 $category = __( 'Premium Addons', 'premium-addons-for-elementor' );
186
187 if ( self::check_papro_version() ) {
188
189 $white_label = Helper::get_white_labeling_settings();
190
191 $category = $white_label['premium-wht-lbl-short-name'];
192
193 }
194
195 return '' !== $category ? $category : __( 'Premium Addons', 'premium-addons-for-elementor' );
196
197 }
198
199 /**
200 * Get White Labeling - Widgets Prefix string
201 *
202 * @since 1.0.0
203 * @access public
204 *
205 * @return string
206 */
207 public static function get_prefix() {
208
209 $prefix = __( 'Premium', 'premium-addons-for-elementor' );
210
211 if ( self::check_papro_version() ) {
212
213 $white_label = Helper::get_white_labeling_settings();
214
215 $prefix = $white_label['premium-wht-lbl-prefix'];
216
217 }
218
219 return '' !== $prefix ? $prefix : __( 'Premium', 'premium-addons-for-elementor' );
220 }
221
222 /**
223 * Get White Labeling - Widgets Badge string
224 *
225 * @since 1.0.0
226 * @access public
227 *
228 * @return string
229 */
230 public static function get_badge() {
231
232 $badge = 'PA';
233
234 if ( self::check_papro_version() ) {
235
236 $white_label = Helper::get_white_labeling_settings();
237
238 $badge = $white_label['premium-wht-lbl-badge'];
239
240 }
241
242 return '' !== $badge ? $badge : 'PA';
243 }
244
245 /**
246 * Get Google Maps localization prefixes
247 *
248 * @since 1.0.0
249 * @access public
250 *
251 * @return array
252 */
253 public static function get_google_maps_prefixes() {
254
255 if ( null === self::$google_localize ) {
256
257 self::$google_localize = array(
258 'ar' => __( 'Arabic', 'premium-addons-for-elementor' ),
259 'eu' => __( 'Basque', 'premium-addons-for-elementor' ),
260 'bg' => __( 'Bulgarian', 'premium-addons-for-elementor' ),
261 'bn' => __( 'Bengali', 'premium-addons-for-elementor' ),
262 'ca' => __( 'Catalan', 'premium-addons-for-elementor' ),
263 'cs' => __( 'Czech', 'premium-addons-for-elementor' ),
264 'da' => __( 'Danish', 'premium-addons-for-elementor' ),
265 'de' => __( 'German', 'premium-addons-for-elementor' ),
266 'el' => __( 'Greek', 'premium-addons-for-elementor' ),
267 'en' => __( 'English', 'premium-addons-for-elementor' ),
268 'en-AU' => __( 'English (australian)', 'premium-addons-for-elementor' ),
269 'en-GB' => __( 'English (great britain)', 'premium-addons-for-elementor' ),
270 'es' => __( 'Spanish', 'premium-addons-for-elementor' ),
271 'fa' => __( 'Farsi', 'premium-addons-for-elementor' ),
272 'fi' => __( 'Finnish', 'premium-addons-for-elementor' ),
273 'fil' => __( 'Filipino', 'premium-addons-for-elementor' ),
274 'fr' => __( 'French', 'premium-addons-for-elementor' ),
275 'gl' => __( 'Galician', 'premium-addons-for-elementor' ),
276 'gu' => __( 'Gujarati', 'premium-addons-for-elementor' ),
277 'hi' => __( 'Hindi', 'premium-addons-for-elementor' ),
278 'hr' => __( 'Croatian', 'premium-addons-for-elementor' ),
279 'hu' => __( 'Hungarian', 'premium-addons-for-elementor' ),
280 'id' => __( 'Indonesian', 'premium-addons-for-elementor' ),
281 'it' => __( 'Italian', 'premium-addons-for-elementor' ),
282 'iw' => __( 'Hebrew', 'premium-addons-for-elementor' ),
283 'ja' => __( 'Japanese', 'premium-addons-for-elementor' ),
284 'kn' => __( 'Kannada', 'premium-addons-for-elementor' ),
285 'ko' => __( 'Korean', 'premium-addons-for-elementor' ),
286 'lt' => __( 'Lithuanian', 'premium-addons-for-elementor' ),
287 'lv' => __( 'Latvian', 'premium-addons-for-elementor' ),
288 'ml' => __( 'Malayalam', 'premium-addons-for-elementor' ),
289 'mr' => __( 'Marathi', 'premium-addons-for-elementor' ),
290 'nl' => __( 'Dutch', 'premium-addons-for-elementor' ),
291 'no' => __( 'Norwegian', 'premium-addons-for-elementor' ),
292 'pl' => __( 'Polish', 'premium-addons-for-elementor' ),
293 'pt' => __( 'Portuguese', 'premium-addons-for-elementor' ),
294 'pt-BR' => __( 'Portuguese (brazil)', 'premium-addons-for-elementor' ),
295 'pt-PT' => __( 'Portuguese (portugal)', 'premium-addons-for-elementor' ),
296 'ro' => __( 'Romanian', 'premium-addons-for-elementor' ),
297 'ru' => __( 'Russian', 'premium-addons-for-elementor' ),
298 'sk' => __( 'Slovak', 'premium-addons-for-elementor' ),
299 'sl' => __( 'Slovenian', 'premium-addons-for-elementor' ),
300 'sr' => __( 'Serbian', 'premium-addons-for-elementor' ),
301 'sv' => __( 'Swedish', 'premium-addons-for-elementor' ),
302 'tl' => __( 'Tagalog', 'premium-addons-for-elementor' ),
303 'ta' => __( 'Tamil', 'premium-addons-for-elementor' ),
304 'te' => __( 'Telugu', 'premium-addons-for-elementor' ),
305 'th' => __( 'Thai', 'premium-addons-for-elementor' ),
306 'tr' => __( 'Turkish', 'premium-addons-for-elementor' ),
307 'uk' => __( 'Ukrainian', 'premium-addons-for-elementor' ),
308 'vi' => __( 'Vietnamese', 'premium-addons-for-elementor' ),
309 'zh-CN' => __( 'Chinese (simplified)', 'premium-addons-for-elementor' ),
310 'zh-TW' => __( 'Chinese (traditional)', 'premium-addons-for-elementor' ),
311 );
312 }
313
314 return self::$google_localize;
315
316 }
317
318 /**
319 * Checks if a plugin is installed
320 *
321 * @since 1.0.0
322 * @access public
323 *
324 * @param string $plugin_path plugin path.
325 *
326 * @return boolean
327 */
328 public static function is_plugin_installed( $plugin_path ) {
329
330 require_once ABSPATH . 'wp-admin/includes/plugin.php';
331
332 $plugins = get_plugins();
333
334 return isset( $plugins[ $plugin_path ] );
335 }
336
337 /**
338 * Check Plugin Active
339 *
340 * @since 4.2.5
341 * @access public
342 *
343 * @param string $slug plugin slug.
344 *
345 * @return boolean $is_active plugin active.
346 */
347 public static function check_plugin_active( $slug = '' ) {
348
349 include_once ABSPATH . 'wp-admin/includes/plugin.php';
350
351 $is_active = is_plugin_active( $slug );
352
353 return $is_active;
354
355 }
356
357 /**
358 * Check if script debug mode enabled.
359 *
360 * @since 3.11.1
361 * @access public
362 *
363 * @return boolean is debug mode enabled
364 */
365 public static function is_debug_enabled() {
366
367 if ( null === self::$script_debug ) {
368
369 self::$script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
370 }
371
372 return self::$script_debug;
373 }
374
375 /**
376 * Get scripts dir.
377 *
378 * @access public
379 *
380 * @return string JS scripts directory.
381 */
382 public static function get_scripts_dir() {
383
384 if ( null === self::$js_dir ) {
385
386 self::$js_dir = self::is_debug_enabled() ? 'js' : 'min-js';
387 }
388
389 return self::$js_dir;
390 }
391
392 /**
393 * Get styles dir.
394 *
395 * @access public
396 *
397 * @return string CSS files directory.
398 */
399 public static function get_styles_dir() {
400
401 if ( null === self::$css_dir ) {
402
403 self::$css_dir = self::is_debug_enabled() ? 'css' : 'min-css';
404 }
405
406 return self::$css_dir;
407 }
408
409 /**
410 * Get assets suffix.
411 *
412 * @access public
413 *
414 * @return string JS scripts suffix.
415 */
416 public static function get_assets_suffix() {
417
418 if ( null === self::$assets_suffix ) {
419
420 self::$assets_suffix = self::is_debug_enabled() ? '' : '.min';
421 }
422
423 return self::$assets_suffix;
424 }
425
426 /**
427 * Get Installed Theme
428 *
429 * Returns the active theme slug
430 *
431 * @access public
432 *
433 * @return string theme slug
434 */
435 public static function get_installed_theme() {
436
437 $theme = wp_get_theme();
438
439 if ( $theme->parent() ) {
440
441 $theme_name = sanitize_key( $theme->parent()->get( 'Name' ) );
442
443 return $theme_name;
444
445 }
446
447 $theme_name = $theme->get( 'Name' );
448
449 $theme_name = sanitize_key( $theme_name );
450
451 return $theme_name;
452 }
453
454 /**
455 * Get Vimeo Video Data
456 *
457 * Get video data using Vimeo API
458 *
459 * @since 3.11.4
460 * @access public
461 *
462 * @param string $video_id video ID.
463 */
464 public static function get_vimeo_video_data( $video_id ) {
465
466 $vimeo_data = wp_remote_get( 'http://www.vimeo.com/api/v2/video/' . intval( $video_id ) . '.php' );
467
468 if ( isset( $vimeo_data['response']['code'] ) ) {
469
470 if ( 200 === $vimeo_data['response']['code'] ) {
471
472 $response = maybe_unserialize( $vimeo_data['body'] );
473 $thumbnail = isset( $response[0]['thumbnail_large'] ) ? $response[0]['thumbnail_large'] : false;
474
475 $data = array(
476 'src' => $thumbnail,
477 'url' => $response[0]['user_url'],
478 'portrait' => $response[0]['user_portrait_huge'],
479 'title' => $response[0]['title'],
480 'user' => $response[0]['user_name'],
481 );
482
483 return $data;
484
485 }
486 }
487
488 return false;
489
490 }
491
492 /**
493 * Get Video Thumbnail
494 *
495 * Get thumbnail URL for embed or self hosted
496 *
497 * @since 3.7.0
498 * @access public
499 *
500 * @param string $video_id video ID.
501 * @param string $type embed type.
502 * @param string $size youtube thumbnail size.
503 */
504 public static function get_video_thumbnail( $video_id, $type, $size = '' ) {
505
506 $thumbnail_src = 'transparent';
507
508 if ( 'youtube' === $type ) {
509 if ( '' === $size ) {
510 $size = 'maxresdefault';
511 }
512 $thumbnail_src = sprintf( 'https://i.ytimg.com/vi/%s/%s.jpg', $video_id, $size );
513
514 } elseif ( 'vimeo' === $type ) {
515
516 $vimeo = self::get_vimeo_video_data( $video_id );
517
518 $thumbnail_src = $vimeo['src'];
519
520 }
521
522 return $thumbnail_src;
523
524 }
525
526 /**
527 * Transient Expire
528 *
529 * Gets expire time of transient.
530 *
531 * @since 3.20.8
532 * @access public
533 *
534 * @param string $period transient expiration period.
535 *
536 * @return string $expire_time expire time in seconds.
537 */
538 public static function transient_expire( $period ) {
539
540 $expire_time = 24 * HOUR_IN_SECONDS;
541
542 switch ( $period ) {
543 case 'minute':
544 $expire_time = MINUTE_IN_SECONDS;
545 break;
546 case 'minutes':
547 $expire_time = 5 * MINUTE_IN_SECONDS;
548 break;
549 case 'hour':
550 $expire_time = 60 * MINUTE_IN_SECONDS;
551 break;
552 case 'week':
553 $expire_time = 7 * DAY_IN_SECONDS;
554 break;
555 case 'month':
556 $expire_time = 30 * DAY_IN_SECONDS;
557 break;
558 case 'year':
559 $expire_time = 365 * DAY_IN_SECONDS;
560 break;
561 default:
562 $expire_time = 24 * HOUR_IN_SECONDS;
563 }
564
565 return $expire_time;
566 }
567
568 /**
569 * Get Campaign Link
570 *
571 * @since 3.20.9
572 * @access public
573 *
574 * @param string $link page link.
575 * @param string $source source.
576 * @param string $medium media.
577 * @param string $campaign campaign name.
578 *
579 * @return string $link campaign URL
580 */
581 public static function get_campaign_link( $link, $source, $medium, $campaign = '' ) {
582
583 $theme = self::get_installed_theme();
584
585 $url = add_query_arg(
586 array(
587 'utm_source' => $source,
588 'utm_medium' => $medium,
589 'utm_campaign' => $campaign,
590 'utm_term' => $theme,
591 ),
592 $link
593 );
594
595 return $url;
596
597 }
598
599 /**
600 * Get Elementor UI Theme
601 *
602 * Detects user setting for UI theme
603 *
604 * @since 3.21.1
605 * @access public
606 *
607 * @return string $theme UI Theme
608 */
609 public static function get_elementor_ui_theme() {
610
611 $theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
612
613 return $theme;
614
615 }
616
617 /**
618 * Check PAPRO Version
619 *
620 * Check if PAPRO version is updated
621 *
622 * @since 3.21.6
623 * @access public
624 *
625 * @return boolen $is_updated
626 */
627 public static function check_papro_version() {
628
629 if ( ! defined( 'PREMIUM_PRO_ADDONS_VERSION' ) ) {
630 return false;
631 }
632
633 $is_updated = get_option( 'papro_updated', true );
634
635 return $is_updated;
636
637 }
638
639 /**
640 * Valide HTML Tag
641 *
642 * Validates an HTML tag against a safe allowed list.
643 *
644 * @param string $tag HTML tag.
645 *
646 * @return string
647 */
648 public static function validate_html_tag( $tag ) {
649 return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS, true ) ? $tag : 'div';
650 }
651
652 /**
653 * Get Image Data
654 *
655 * Returns image data based on image id.
656 *
657 * @since 0.0.1
658 * @access public
659 *
660 * @param int $image_id Image ID.
661 * @param string $image_url Image URL.
662 * @param array $image_size Image sizes array.
663 *
664 * @return array $data image data.
665 */
666 public static function get_image_data( $image_id, $image_url, $image_size ) {
667
668 if ( ! $image_id && ! $image_url ) {
669 return false;
670 }
671
672 $data = array();
673
674 $image_url = esc_url_raw( $image_url );
675
676 if ( ! empty( $image_id ) ) { // Existing attachment.
677
678 $attachment = get_post( $image_id );
679
680 if ( is_object( $attachment ) ) {
681 $data['id'] = $image_id;
682 $data['url'] = $image_url;
683
684 $data['image'] = wp_get_attachment_image( $attachment->ID, $image_size, true );
685 $data['image_size'] = $image_size;
686 $data['caption'] = $attachment->post_excerpt;
687 $data['title'] = $attachment->post_title;
688 $data['description'] = $attachment->post_content;
689
690 }
691 } else { // Placeholder image, most likely.
692
693 if ( empty( $image_url ) ) {
694 return;
695 }
696
697 $data['id'] = false;
698 $data['url'] = $image_url;
699 $data['image'] = '<img src="' . $image_url . '" alt="" title="" />';
700 $data['image_size'] = $image_size;
701 $data['caption'] = '';
702 $data['title'] = '';
703 $data['description'] = '';
704 }
705
706 return $data;
707 }
708
709 /**
710 * Get Final Result.
711 *
712 * @access public
713 * @since 4.4.8
714 *
715 * @param bool $condition_result result.
716 * @param string $operator operator.
717 *
718 * @return bool
719 */
720 public static function get_final_result( $condition_result, $operator ) {
721
722 if ( 'is' === $operator ) {
723 return true === $condition_result;
724 } else {
725 return true !== $condition_result;
726 }
727 }
728
729 /**
730 * Get Local Time ( WordPress TimeZone Setting ).
731 *
732 * @access public
733 * @since 4.4.8
734 *
735 * @param string $format format.
736 */
737 public static function get_local_time( $format ) {
738
739 $today = new \DateTime( 'now', new \DateTimeZone( date_default_timezone_get() ) );
740
741 return $today->format( $format );
742 }
743
744 /**
745 * Get Site Server Time ( WordPress TimeZone Setting ).
746 *
747 * @access public
748 * @since 4.4.8
749 *
750 * @param string $format format.
751 */
752 public static function get_site_server_time( $format ) {
753
754 $today = gmdate( $format, strtotime( 'now' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
755
756 return $today;
757 }
758
759 /**
760 * Get All Breakpoints.
761 *
762 * @param string $type result return type.
763 *
764 * @access public
765 * @since 4.6.1
766 *
767 * @return array $devices enabled breakpoints.
768 */
769 public static function get_all_breakpoints( $type = 'assoc' ) {
770
771 $devices = array(
772 'desktop' => __( 'Desktop', 'elementor' ),
773 'tablet' => __( 'Tablet', 'elementor' ),
774 'mobile' => __( 'Mobile', 'elementor' ),
775 );
776
777 $method_available = method_exists( Plugin::$instance->breakpoints, 'has_custom_breakpoints' );
778
779 if ( ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.4.0', '>' ) ) && $method_available ) {
780
781 if ( Plugin::$instance->breakpoints->has_custom_breakpoints() ) {
782 $devices = array_merge(
783 $devices,
784 array(
785 'widescreen' => __( 'Widescreen', 'elementor' ),
786 'laptop' => __( 'Laptop', 'elementor' ),
787 'tablet_extra' => __( 'Tablet Extra', 'elementor' ),
788 'mobile_extra' => __( 'Mobile Extra', 'elementor' ),
789 )
790 );
791 }
792 }
793
794 if ( 'keys' === $type ) {
795 $devices = array_keys( $devices );
796 }
797
798 return $devices;
799
800 }
801
802
803 /**
804 * Get WordPress language prefixes.
805 *
806 * @since 4.4.8
807 * @access public
808 *
809 * @return array
810 */
811 public static function get_lang_prefixes() {
812
813 if ( null === self::$lang_locales ) {
814
815 $langs = require_once PREMIUM_ADDONS_PATH . 'includes/lang-locale.php';
816
817 foreach ( $langs as $lang => $props ) {
818 /* translators: %s: Language Name */
819 $val = ucwords( $props['name'] );
820 self::$lang_locales[ $lang ] = $val;
821 }
822 }
823
824 return self::$lang_locales;
825 }
826
827 /**
828 * Get Woocommerce Categories.
829 *
830 * @access public
831 * @since 4.4.8
832 *
833 * @param string $id array key.
834 *
835 * @return array
836 */
837 public static function get_woo_categories( $id = 'slug' ) {
838
839 $product_cat = array();
840
841 $cat_args = array(
842 'orderby' => 'name',
843 'order' => 'asc',
844 'hide_empty' => false,
845 );
846
847 $product_categories = get_terms( 'product_cat', $cat_args );
848
849 if ( ! empty( $product_categories ) ) {
850
851 foreach ( $product_categories as $key => $category ) {
852
853 $cat_id = 'slug' === $id ? $category->slug : $category->term_id;
854 $product_cat[ $cat_id ] = $category->name;
855
856 }
857 }
858
859 return $product_cat;
860 }
861
862 /**
863 * Check Elementor Experiment
864 *
865 * Check if an Elementor experiment is enabled.
866 *
867 * @since 4.8.6
868 * @access public
869 *
870 * @param string $experiment feature ID.
871 *
872 * @return boolean $is_enabled is feature enabled.
873 */
874 public static function check_elementor_experiment( $experiment ) {
875
876 $experiments_manager = Plugin::$instance->experiments;
877
878 $is_enabled = $experiments_manager->is_feature_active( $experiment );
879
880 return $is_enabled;
881
882 }
883 }
884