PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.10.15
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.10.15
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 2 years ago controls 2 years ago pa-display-conditions 2 years ago templates 2 years ago acf-helper.php 2 years ago addons-cross-cp.php 2 years ago addons-integration.php 2 years ago assets-manager.php 2 years ago class-pa-core.php 2 years ago class-premium-template-tags.php 2 years ago helper-functions.php 2 years ago live-editor-modal.php 2 years ago module-base.php 2 years ago pa-nav-menu-walker.php 2 years ago
helper-functions.php
1281 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 use Elementor\Controls_Manager;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Class Helper_Functions.
22 */
23 class Helper_Functions {
24
25 /**
26 * A list of safe tage for `validate_html_tag` method.
27 */
28 const ALLOWED_HTML_WRAPPER_TAGS = array(
29 'article',
30 'aside',
31 'div',
32 'footer',
33 'h1',
34 'h2',
35 'h3',
36 'h4',
37 'h5',
38 'h6',
39 'header',
40 'main',
41 'nav',
42 'p',
43 'section',
44 'span',
45 );
46
47 /**
48 * Google maps prefixes
49 *
50 * @var google_localize
51 */
52 private static $google_localize = null;
53
54 /**
55 * SVG Shapes
56 *
57 * @var shapes
58 */
59 private static $shapes = null;
60
61 /**
62 * WP lang prefixes
63 *
64 * @var lang_locales
65 */
66 private static $lang_locales = null;
67
68 /**
69 * Script debug enabled
70 *
71 * @var script_debug
72 */
73 private static $script_debug = null;
74
75 /**
76 * JS scripts directory
77 *
78 * @var js_dir
79 */
80 private static $js_dir = null;
81
82 /**
83 * CSS fiels directory
84 *
85 * @var js_dir
86 */
87 private static $css_dir = null;
88
89 /**
90 * JS Suffix
91 *
92 * @var js_suffix
93 */
94 private static $assets_suffix = null;
95
96 /**
97 * Check if white labeling - Free version author field is set
98 *
99 * @since 1.0.0
100 * @access public
101 *
102 * @return string
103 */
104 public static function author() {
105
106 $author_free = 'Leap13';
107
108 if ( self::check_papro_version() ) {
109
110 $white_label = Helper::get_white_labeling_settings();
111
112 $author_free = $white_label['premium-wht-lbl-name'];
113
114 }
115
116 return '' !== $author_free ? $author_free : 'Leap13';
117 }
118
119 /**
120 * Check if white labeling - Free version name field is set
121 *
122 * @since 1.0.0
123 * @access public
124 *
125 * @return string
126 */
127 public static function name() {
128
129 $name_free = 'Premium Addons for Elementor';
130
131 if ( self::check_papro_version() ) {
132
133 $white_label = Helper::get_white_labeling_settings();
134
135 $name_free = $white_label['premium-wht-lbl-plugin-name'];
136
137 }
138
139 return '' !== $name_free ? $name_free : 'Premium Addons for Elementor';
140 }
141
142 /**
143 * Check if white labeling - Hide row meta option is checked
144 *
145 * @since 1.0.0
146 * @return boolean
147 */
148 public static function is_hide_row_meta() {
149
150 if ( self::check_papro_version() ) {
151
152 $white_label = Helper::get_white_labeling_settings();
153
154 $hide_meta = $white_label['premium-wht-lbl-row'];
155
156 }
157
158 return isset( $hide_meta ) ? $hide_meta : false;
159 }
160
161 /**
162 * Check if white labeling - Hide plugin logo option is checked
163 *
164 * @since 1.0.0
165 * @access public
166 *
167 * @return boolean
168 */
169 public static function is_hide_logo() {
170
171 if ( self::check_papro_version() ) {
172
173 if ( isset( get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'] ) ) {
174
175 $hide_logo = get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'];
176
177 }
178 }
179
180 return isset( $hide_logo ) ? $hide_logo : false;
181 }
182
183 /**
184 * Get White Labeling - Widgets Category string
185 *
186 * @since 1.0.0
187 * @access public
188 *
189 * @return string
190 */
191 public static function get_category() {
192
193 $category = __( 'Premium Addons', 'premium-addons-for-elementor' );
194
195 if ( self::check_papro_version() ) {
196
197 $white_label = Helper::get_white_labeling_settings();
198
199 $category = $white_label['premium-wht-lbl-short-name'];
200
201 }
202
203 return '' !== $category ? $category : __( 'Premium Addons', 'premium-addons-for-elementor' );
204
205 }
206
207 /**
208 * Get White Labeling - Widgets Prefix string
209 *
210 * @since 1.0.0
211 * @access public
212 *
213 * @return string
214 */
215 public static function get_prefix() {
216
217 $prefix = __( 'Premium', 'premium-addons-for-elementor' );
218
219 if ( self::check_papro_version() ) {
220
221 $white_label = Helper::get_white_labeling_settings();
222
223 $prefix = $white_label['premium-wht-lbl-prefix'];
224
225 }
226
227 return '' !== $prefix ? $prefix : __( 'Premium', 'premium-addons-for-elementor' );
228 }
229
230 /**
231 * Check if white labeling - Future notification checked
232 *
233 * @since 1.0.0
234 * @return boolean
235 */
236 public static function check_hide_notifications() {
237
238 if ( self::check_papro_version() ) {
239
240 $white_label = Helper::get_white_labeling_settings();
241
242 $hide_notification = isset( $white_label['premium-wht-lbl-not'] ) ? $white_label['premium-wht-lbl-not'] : false;
243
244 }
245
246 return isset( $hide_notification ) ? $hide_notification : false;
247 }
248
249 /**
250 * Get White Labeling - Widgets Badge string
251 *
252 * @since 1.0.0
253 * @access public
254 *
255 * @return string
256 */
257 public static function get_badge() {
258
259 $badge = 'PA';
260
261 if ( self::check_papro_version() ) {
262
263 $white_label = Helper::get_white_labeling_settings();
264
265 $badge = $white_label['premium-wht-lbl-badge'];
266
267 }
268
269 return '' !== $badge ? $badge : 'PA';
270 }
271
272 /**
273 * Get Google Maps localization prefixes
274 *
275 * @since 1.0.0
276 * @access public
277 *
278 * @return array
279 */
280 public static function get_google_maps_prefixes() {
281
282 if ( null === self::$google_localize ) {
283
284 self::$google_localize = array(
285 'ar' => __( 'Arabic', 'premium-addons-for-elementor' ),
286 'eu' => __( 'Basque', 'premium-addons-for-elementor' ),
287 'bg' => __( 'Bulgarian', 'premium-addons-for-elementor' ),
288 'bn' => __( 'Bengali', 'premium-addons-for-elementor' ),
289 'ca' => __( 'Catalan', 'premium-addons-for-elementor' ),
290 'cs' => __( 'Czech', 'premium-addons-for-elementor' ),
291 'da' => __( 'Danish', 'premium-addons-for-elementor' ),
292 'de' => __( 'German', 'premium-addons-for-elementor' ),
293 'el' => __( 'Greek', 'premium-addons-for-elementor' ),
294 'en' => __( 'English', 'premium-addons-for-elementor' ),
295 'en-AU' => __( 'English (australian)', 'premium-addons-for-elementor' ),
296 'en-GB' => __( 'English (great britain)', 'premium-addons-for-elementor' ),
297 'es' => __( 'Spanish', 'premium-addons-for-elementor' ),
298 'fa' => __( 'Farsi', 'premium-addons-for-elementor' ),
299 'fi' => __( 'Finnish', 'premium-addons-for-elementor' ),
300 'fil' => __( 'Filipino', 'premium-addons-for-elementor' ),
301 'fr' => __( 'French', 'premium-addons-for-elementor' ),
302 'gl' => __( 'Galician', 'premium-addons-for-elementor' ),
303 'gu' => __( 'Gujarati', 'premium-addons-for-elementor' ),
304 'hi' => __( 'Hindi', 'premium-addons-for-elementor' ),
305 'hr' => __( 'Croatian', 'premium-addons-for-elementor' ),
306 'hu' => __( 'Hungarian', 'premium-addons-for-elementor' ),
307 'id' => __( 'Indonesian', 'premium-addons-for-elementor' ),
308 'it' => __( 'Italian', 'premium-addons-for-elementor' ),
309 'iw' => __( 'Hebrew', 'premium-addons-for-elementor' ),
310 'ja' => __( 'Japanese', 'premium-addons-for-elementor' ),
311 'kn' => __( 'Kannada', 'premium-addons-for-elementor' ),
312 'ko' => __( 'Korean', 'premium-addons-for-elementor' ),
313 'lt' => __( 'Lithuanian', 'premium-addons-for-elementor' ),
314 'lv' => __( 'Latvian', 'premium-addons-for-elementor' ),
315 'ml' => __( 'Malayalam', 'premium-addons-for-elementor' ),
316 'mr' => __( 'Marathi', 'premium-addons-for-elementor' ),
317 'nl' => __( 'Dutch', 'premium-addons-for-elementor' ),
318 'no' => __( 'Norwegian', 'premium-addons-for-elementor' ),
319 'pl' => __( 'Polish', 'premium-addons-for-elementor' ),
320 'pt' => __( 'Portuguese', 'premium-addons-for-elementor' ),
321 'pt-BR' => __( 'Portuguese (brazil)', 'premium-addons-for-elementor' ),
322 'pt-PT' => __( 'Portuguese (portugal)', 'premium-addons-for-elementor' ),
323 'ro' => __( 'Romanian', 'premium-addons-for-elementor' ),
324 'ru' => __( 'Russian', 'premium-addons-for-elementor' ),
325 'sk' => __( 'Slovak', 'premium-addons-for-elementor' ),
326 'sl' => __( 'Slovenian', 'premium-addons-for-elementor' ),
327 'sr' => __( 'Serbian', 'premium-addons-for-elementor' ),
328 'sv' => __( 'Swedish', 'premium-addons-for-elementor' ),
329 'tl' => __( 'Tagalog', 'premium-addons-for-elementor' ),
330 'ta' => __( 'Tamil', 'premium-addons-for-elementor' ),
331 'te' => __( 'Telugu', 'premium-addons-for-elementor' ),
332 'th' => __( 'Thai', 'premium-addons-for-elementor' ),
333 'tr' => __( 'Turkish', 'premium-addons-for-elementor' ),
334 'uk' => __( 'Ukrainian', 'premium-addons-for-elementor' ),
335 'vi' => __( 'Vietnamese', 'premium-addons-for-elementor' ),
336 'zh-CN' => __( 'Chinese (simplified)', 'premium-addons-for-elementor' ),
337 'zh-TW' => __( 'Chinese (traditional)', 'premium-addons-for-elementor' ),
338 );
339 }
340
341 return self::$google_localize;
342
343 }
344
345 /**
346 * Checks if a plugin is installed
347 *
348 * @since 1.0.0
349 * @access public
350 *
351 * @param string $plugin_path plugin path.
352 *
353 * @return boolean
354 */
355 public static function is_plugin_installed( $plugin_path ) {
356
357 require_once ABSPATH . 'wp-admin/includes/plugin.php';
358
359 $plugins = get_plugins();
360
361 return isset( $plugins[ $plugin_path ] );
362 }
363
364 /**
365 * Check Plugin Active
366 *
367 * @since 4.2.5
368 * @access public
369 *
370 * @param string $slug plugin slug.
371 *
372 * @return boolean $is_active plugin active.
373 */
374 public static function check_plugin_active( $slug = '' ) {
375
376 include_once ABSPATH . 'wp-admin/includes/plugin.php';
377
378 $is_active = in_array( $slug, (array) get_option( 'active_plugins', array() ), true );
379
380 return $is_active;
381
382 }
383
384 /**
385 * Check if script debug mode enabled.
386 *
387 * @since 3.11.1
388 * @access public
389 *
390 * @return boolean is debug mode enabled
391 */
392 public static function is_debug_enabled() {
393
394 if ( null === self::$script_debug ) {
395
396 self::$script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
397 }
398
399 return self::$script_debug;
400 }
401
402 /**
403 * Get scripts dir.
404 *
405 * @access public
406 *
407 * @return string JS scripts directory.
408 */
409 public static function get_scripts_dir() {
410
411 if ( null === self::$js_dir ) {
412
413 self::$js_dir = self::is_debug_enabled() ? 'js' : 'min-js';
414 }
415
416 return self::$js_dir;
417 }
418
419 /**
420 * Get styles dir.
421 *
422 * @access public
423 *
424 * @return string CSS files directory.
425 */
426 public static function get_styles_dir() {
427
428 if ( null === self::$css_dir ) {
429
430 self::$css_dir = self::is_debug_enabled() ? 'css' : 'min-css';
431 }
432
433 return self::$css_dir;
434 }
435
436 /**
437 * Get assets suffix.
438 *
439 * @access public
440 *
441 * @return string JS scripts suffix.
442 */
443 public static function get_assets_suffix() {
444
445 if ( null === self::$assets_suffix ) {
446
447 self::$assets_suffix = self::is_debug_enabled() ? '' : '.min';
448 }
449
450 return self::$assets_suffix;
451 }
452
453 /**
454 * Get Installed Theme
455 *
456 * Returns the active theme slug
457 *
458 * @access public
459 *
460 * @return string theme slug
461 */
462 public static function get_installed_theme() {
463
464 $theme = wp_get_theme();
465
466 if ( $theme->parent() ) {
467
468 $theme_name = sanitize_key( $theme->parent()->get( 'Name' ) );
469
470 return $theme_name;
471
472 }
473
474 $theme_name = $theme->get( 'Name' );
475
476 $theme_name = sanitize_key( $theme_name );
477
478 return $theme_name;
479 }
480
481 /**
482 * Get Vimeo Video Data
483 *
484 * Get video data using Vimeo API
485 *
486 * @since 3.11.4
487 * @access public
488 *
489 * @param string $video_id video ID.
490 */
491 public static function get_vimeo_video_data( $video_id ) {
492
493 $vimeo_data = wp_remote_get( 'http://www.vimeo.com/api/v2/video/' . intval( $video_id ) . '.php' );
494
495 if ( is_wp_error( $vimeo_data ) ) {
496 return false;
497 }
498
499 if ( isset( $vimeo_data['response']['code'] ) ) {
500
501 if ( 200 === $vimeo_data['response']['code'] ) {
502
503 $response = maybe_unserialize( $vimeo_data['body'] );
504 $thumbnail = isset( $response[0]['thumbnail_large'] ) ? $response[0]['thumbnail_large'] : false;
505
506 $data = array(
507 'src' => $thumbnail,
508 'url' => $response[0]['user_url'],
509 'portrait' => $response[0]['user_portrait_huge'],
510 'title' => $response[0]['title'],
511 'user' => $response[0]['user_name'],
512 );
513
514 return $data;
515
516 }
517 }
518
519 return false;
520
521 }
522
523 /**
524 * Get Video Thumbnail
525 *
526 * Get thumbnail URL for embed or self hosted
527 *
528 * @since 3.7.0
529 * @access public
530 *
531 * @param string $video_id video ID.
532 * @param string $type embed type.
533 * @param string $size youtube thumbnail size.
534 */
535 public static function get_video_thumbnail( $video_id, $type, $size = '' ) {
536
537 $thumbnail_src = 'transparent';
538
539 if ( 'youtube' === $type ) {
540 if ( '' === $size ) {
541 $size = 'maxresdefault';
542 }
543 $thumbnail_src = sprintf( 'https://i.ytimg.com/vi/%s/%s.jpg', $video_id, $size );
544
545 } elseif ( 'vimeo' === $type ) {
546
547 $vimeo = self::get_vimeo_video_data( $video_id );
548
549 $thumbnail_src = $vimeo['src'];
550
551 } elseif ( 'dailymotion' === $type ) {
552 $video_data = rplg_urlopen( 'https://api.dailymotion.com/video/' . $video_id . '?fields=thumbnail_url' );
553
554 if ( isset( $video_data['code'] ) ) {
555 if ( 404 === $video_data['code'] ) {
556 return $thumbnail_src;
557 }
558 }
559
560 $thumbnail_src = rplg_json_decode( $video_data['data'] )->thumbnail_url;
561 }
562
563 return $thumbnail_src;
564
565 }
566
567 /**
568 * Transient Expire
569 *
570 * Gets expire time of transient.
571 *
572 * @since 3.20.8
573 * @access public
574 *
575 * @param string $period transient expiration period.
576 *
577 * @return string $expire_time expire time in seconds.
578 */
579 public static function transient_expire( $period ) {
580
581 $expire_time = 24 * HOUR_IN_SECONDS;
582
583 switch ( $period ) {
584 case 'minute':
585 $expire_time = MINUTE_IN_SECONDS;
586 break;
587 case 'minutes':
588 $expire_time = 5 * MINUTE_IN_SECONDS;
589 break;
590 case 'hour':
591 $expire_time = 60 * MINUTE_IN_SECONDS;
592 break;
593 case 'week':
594 $expire_time = 7 * DAY_IN_SECONDS;
595 break;
596 case 'month':
597 $expire_time = 30 * DAY_IN_SECONDS;
598 break;
599 case 'year':
600 $expire_time = 365 * DAY_IN_SECONDS;
601 break;
602 default:
603 $expire_time = 24 * HOUR_IN_SECONDS;
604 }
605
606 return $expire_time;
607 }
608
609 /**
610 * Get Campaign Link
611 *
612 * @since 3.20.9
613 * @access public
614 *
615 * @param string $link page link.
616 * @param string $source source.
617 * @param string $medium media.
618 * @param string $campaign campaign name.
619 *
620 * @return string $link campaign URL
621 */
622 public static function get_campaign_link( $link, $source, $medium, $campaign = '' ) {
623
624 $theme = self::get_installed_theme();
625
626 $url = add_query_arg(
627 array(
628 'utm_source' => $source,
629 'utm_medium' => $medium,
630 'utm_campaign' => $campaign,
631 'utm_term' => $theme,
632 ),
633 $link
634 );
635
636 return $url;
637
638 }
639
640 /**
641 * Get Elementor UI Theme
642 *
643 * Detects user setting for UI theme
644 *
645 * @since 3.21.1
646 * @access public
647 *
648 * @return string $theme UI Theme
649 */
650 public static function get_elementor_ui_theme() {
651
652 $theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
653
654 return $theme;
655
656 }
657
658 /**
659 * Check PAPRO Version
660 *
661 * Check if PAPRO version is updated
662 *
663 * @since 3.21.6
664 * @access public
665 *
666 * @return boolen $is_updated
667 */
668 public static function check_papro_version() {
669
670 if ( ! defined( 'PREMIUM_PRO_ADDONS_VERSION' ) ) {
671 return false;
672 }
673
674 $is_updated = get_option( 'papro_updated', true );
675
676 return $is_updated;
677
678 }
679
680 /**
681 * Valide HTML Tag
682 *
683 * Validates an HTML tag against a safe allowed list.
684 *
685 * @param string $tag HTML tag.
686 *
687 * @return string
688 */
689 public static function validate_html_tag( $tag ) {
690 return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS, true ) ? $tag : 'div';
691 }
692
693 /**
694 * Get Image Data
695 *
696 * Returns image data based on image id.
697 *
698 * @since 0.0.1
699 * @access public
700 *
701 * @param int $image_id Image ID.
702 * @param string $image_url Image URL.
703 * @param array $image_size Image sizes array.
704 *
705 * @return array $data image data.
706 */
707 public static function get_image_data( $image_id, $image_url, $image_size ) {
708
709 if ( ! $image_id && ! $image_url ) {
710 return false;
711 }
712
713 $data = array();
714
715 $image_url = esc_url_raw( $image_url );
716
717 if ( ! empty( $image_id ) ) { // Existing attachment.
718
719 $attachment = get_post( $image_id );
720
721 if ( is_object( $attachment ) ) {
722 $data['id'] = $image_id;
723 $data['url'] = $image_url;
724
725 $data['image'] = wp_get_attachment_image( $attachment->ID, $image_size, true );
726 $data['image_size'] = $image_size;
727 $data['caption'] = $attachment->post_excerpt;
728 $data['title'] = $attachment->post_title;
729 $data['description'] = $attachment->post_content;
730
731 }
732 } else { // Placeholder image, most likely.
733
734 if ( empty( $image_url ) ) {
735 return;
736 }
737
738 $data['id'] = false;
739 $data['url'] = $image_url;
740 $data['image'] = '<img src="' . $image_url . '" alt="" title="" />';
741 $data['image_size'] = $image_size;
742 $data['caption'] = '';
743 $data['title'] = '';
744 $data['description'] = '';
745 }
746
747 return $data;
748 }
749
750 /**
751 * Get Final Result.
752 *
753 * @access public
754 * @since 4.4.8
755 *
756 * @param bool $condition_result result.
757 * @param string $operator operator.
758 *
759 * @return bool
760 */
761 public static function get_final_result( $condition_result, $operator ) {
762
763 if ( 'is' === $operator ) {
764 return true === $condition_result;
765 } else {
766 return true !== $condition_result;
767 }
768 }
769
770 /**
771 * Get Local Time ( WordPress TimeZone Setting ).
772 *
773 * @access public
774 * @since 4.4.8
775 *
776 * @param string $format format.
777 */
778 public static function get_local_time( $format ) {
779
780 $local_time_zone = isset( $_COOKIE['localTimeZone'] ) && ! empty( $_COOKIE['localTimeZone'] ) ?
781 str_replace( 'GMT ', 'GMT+', sanitize_text_field( wp_unslash( $_COOKIE['localTimeZone'] ) ) )
782 : date_default_timezone_get();
783
784 $today = new \DateTime( 'now', new \DateTimeZone( $local_time_zone ) );
785
786 return $today->format( $format );
787 }
788
789 /**
790 * Get Site Server Time ( WordPress TimeZone Setting ).
791 *
792 * @access public
793 * @since 4.4.8
794 *
795 * @param string $format format.
796 */
797 public static function get_site_server_time( $format ) {
798
799 $today = gmdate( $format, strtotime( 'now' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
800
801 return $today;
802 }
803
804 /**
805 * Get All Breakpoints.
806 *
807 * @param string $type result return type.
808 *
809 * @access public
810 * @since 4.6.1
811 *
812 * @return array $devices enabled breakpoints.
813 */
814 public static function get_all_breakpoints( $type = 'assoc' ) {
815
816 $devices = array(
817 'desktop' => __( 'Desktop', 'elementor' ),
818 'tablet' => __( 'Tablet', 'elementor' ),
819 'mobile' => __( 'Mobile', 'elementor' ),
820 );
821
822 $method_available = method_exists( Plugin::$instance->breakpoints, 'has_custom_breakpoints' );
823
824 if ( ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.4.0', '>' ) ) && $method_available ) {
825
826 if ( Plugin::$instance->breakpoints->has_custom_breakpoints() ) {
827 $devices = array_merge(
828 $devices,
829 array(
830 'widescreen' => __( 'Widescreen', 'elementor' ),
831 'laptop' => __( 'Laptop', 'elementor' ),
832 'tablet_extra' => __( 'Tablet Extra', 'elementor' ),
833 'mobile_extra' => __( 'Mobile Extra', 'elementor' ),
834 )
835 );
836 }
837 }
838
839 if ( 'keys' === $type ) {
840 $devices = array_keys( $devices );
841 }
842
843 return $devices;
844
845 }
846
847 /**
848 * Get WordPress language prefixes.
849 *
850 * @since 4.4.8
851 * @access public
852 *
853 * @return array
854 */
855 public static function get_lang_prefixes() {
856
857 if ( null === self::$lang_locales ) {
858
859 $langs = require_once PREMIUM_ADDONS_PATH . 'includes/pa-display-conditions/lang-locale.php';
860
861 foreach ( $langs as $lang => $props ) {
862 /* translators: %s: Language Name */
863 $val = ucwords( $props['name'] );
864 self::$lang_locales[ $lang ] = $val;
865 }
866 }
867
868 return self::$lang_locales;
869 }
870
871 /**
872 * Get Woocommerce Categories.
873 *
874 * @access public
875 * @since 4.4.8
876 *
877 * @param string $id array key.
878 *
879 * @return array
880 */
881 public static function get_woo_categories( $id = 'slug' ) {
882
883 $product_cat = array();
884
885 $cat_args = array(
886 'orderby' => 'name',
887 'order' => 'asc',
888 'hide_empty' => false,
889 );
890
891 $product_categories = get_terms( 'product_cat', $cat_args );
892
893 if ( ! empty( $product_categories ) ) {
894
895 foreach ( $product_categories as $key => $category ) {
896
897 $cat_id = 'slug' === $id ? $category->slug : $category->term_id;
898 $product_cat[ $cat_id ] = $category->name;
899
900 }
901 }
902
903 return $product_cat;
904 }
905
906 /**
907 * Check Elementor Experiment
908 *
909 * Check if an Elementor experiment is enabled.
910 *
911 * @since 4.8.6
912 * @access public
913 *
914 * @param string $experiment feature ID.
915 *
916 * @return boolean $is_enabled is feature enabled.
917 */
918 public static function check_elementor_experiment( $experiment ) {
919
920 $experiments_manager = Plugin::$instance->experiments;
921
922 $is_enabled = $experiments_manager->is_feature_active( $experiment );
923
924 return $is_enabled;
925
926 }
927
928 /**
929 * Is Edit Mode.
930 *
931 * @access public
932 * @since 4.6.1
933 *
934 * @return boolean
935 */
936 public static function is_edit_mode() {
937 return isset( $_REQUEST['elementor-preview'] ) && ! empty( $_REQUEST['elementor-preview'] ); // phpcs:ignore WordPress.Security.NonceVerification
938 }
939
940 /**
941 * Generate Unique ID
942 *
943 * Generates a unique ID for the current page.
944 *
945 * @since 4.6.9
946 * @access public
947 *
948 * @param string $id page ID.
949 *
950 * @return string unique ID.
951 */
952 public static function generate_unique_id( $id ) {
953 return substr( md5( $id ), 0, 9 );
954 }
955
956 /**
957 * Get Safe Path
958 *
959 * @since 4.6.9
960 * @access public
961 *
962 * @param string $file_path unsafe file path.
963 *
964 * @return string safe file path.
965 */
966 public static function get_safe_path( $file_path ) {
967
968 $path = str_replace( array( '//', '\\\\' ), array( '/', '\\' ), $file_path );
969
970 return str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $path );
971
972 }
973
974 /**
975 * Check if the current post type should include addons.
976 *
977 * @param string $id current post ID.
978 *
979 * @since 4.9.18
980 * @access public
981 */
982 public static function check_post_type( $id ) {
983
984 if ( ! $id ) {
985 return false;
986 }
987
988 $template_name = get_post_meta( $id, '_elementor_template_type', true );
989
990 $template_list = array(
991 'header',
992 'footer',
993 'single',
994 'post',
995 'page',
996 'archive',
997 'search-results',
998 'error-404',
999 'product',
1000 'product-archive',
1001 'section',
1002 );
1003
1004 return in_array( $template_name, $template_list );
1005 }
1006
1007 /**
1008 * Get Draw SVG Notice
1009 *
1010 * @since 4.9.26
1011 * @access public
1012 *
1013 * @param object $elem element object.
1014 * @param string $search search query.
1015 * @param array $conditions control conditions
1016 */
1017 public static function get_draw_svg_notice( $elem, $search, $conditions, $index = 0 ) {
1018
1019 $url = add_query_arg(
1020 array(
1021 'page' => sprintf( 'premium-addons&search=%s#tab=elements', $search ),
1022 ),
1023 esc_url( admin_url( 'admin.php' ) )
1024 );
1025
1026 $elem->add_control(
1027 'draw_svg_notice_' . $index,
1028 array(
1029 'type' => Controls_Manager::RAW_HTML,
1030 'raw' => __( 'You need first to enable SVG Draw option checkbox from ', 'premium-addons-for-elementor' ) . '<a href="' . esc_url( $url ) . '" target="_blank">' . __( 'here.', 'premium-addons-for-elementor' ) . '</a>',
1031 'classes' => 'editor-pa-control-notice',
1032 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
1033 'condition' => $conditions,
1034 )
1035 );
1036
1037 }
1038
1039 /**
1040 * Checks if Elementor PRO 3.8 or higher is activated && if the Loop expirement is activated.
1041 *
1042 * @since 4.9.45
1043 * @access public
1044 *
1045 * @return bool
1046 */
1047 public static function is_loop_exp_enabled() {
1048
1049 if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
1050
1051 if( version_compare( ELEMENTOR_PRO_VERSION, '3.16.0', '>=' ) ) {
1052 return true;
1053 } else if( version_compare( ELEMENTOR_PRO_VERSION, '3.8', '>=' ) ) {
1054 $is_loop_enabled = self::check_elementor_experiment( 'loop' );
1055
1056 if ( $is_loop_enabled ) {
1057 return true;
1058 }
1059 }
1060 }
1061
1062 return false;
1063 }
1064
1065 /**
1066 * Get Element Classes.
1067 *
1068 * @access private
1069 * @since 2.8.22
1070 *
1071 * @param array $devices devices to hide on.
1072 *
1073 * @return array
1074 */
1075 public static function get_element_classes( $devices, $default = array() ) {
1076
1077 $classes = $default;
1078
1079 if ( count( $devices ) ) {
1080 foreach ( $devices as $index => $device ) {
1081 array_push( $classes, 'elementor-hidden-' . $device );
1082 }
1083
1084 array_push( $classes, 'premium-addons-element' );
1085 }
1086
1087 return $classes;
1088 }
1089
1090 /**
1091 * Round Numbers In A Reading-friendly Format.
1092 *
1093 * @param integer $num followers number.
1094 */
1095 public static function premium_format_numbers( $num ) {
1096 $num = intval( $num );
1097 $result = '';
1098
1099 if ( $num >= 1000000000 ) {
1100 $tmp = round( ( $num / 1000000 ), 1 );
1101 $result = $tmp . 'B';
1102 return $result;
1103 }
1104
1105 if ( $num >= 1000000 ) {
1106 $tmp = round( ( $num / 1000000 ), 1 );
1107 $result = $tmp . 'M';
1108 return $result;
1109 }
1110
1111 if ( $num >= 1000 ) {
1112 $tmp = round( ( $num / 1000 ), 1 );
1113 $result = $tmp . 'K';
1114
1115 return $result;
1116 }
1117
1118 return round( $num, 1 );
1119 }
1120
1121 /**
1122 * Get Contact Form Body
1123 *
1124 * @since 4.10.2
1125 * @access public
1126 *
1127 * @param string $preset form preset.
1128 *
1129 * @return void
1130 */
1131 public static function get_cf_form_body( $preset ) {
1132
1133 $forms_array = array(
1134
1135 'preset1' => '<div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1136 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1137 [submit "Subscribe"]',
1138
1139 'preset2' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1140 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1141
1142 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1143 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1144
1145 [submit "Send"]',
1146
1147 'preset3' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1148 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1149
1150 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1151 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1152
1153 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1154 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1155
1156 [submit "Send"]',
1157
1158 'preset4' => '<div class="premium-cf-half"><label class="premium-cf-label">Name</label>
1159 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1160
1161 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1162 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1163
1164 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1165 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1166
1167 [submit "Send"]',
1168
1169 'preset5' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1170 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1171
1172 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1173 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1174
1175 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1176 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1177
1178 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1179 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1180
1181 <div class="premium-cf-full"><label class="premium-cf-label">Gender</label>
1182 [select menu-1 "Male" "Female"]</div>
1183
1184 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1185 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1186 [submit "Send"]',
1187
1188 'preset6' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1189 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1190
1191 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1192 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1193
1194 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1195 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1196
1197 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1198 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1199
1200 <div class="premium-cf-full"><label class="premium-cf-label">Company Size</label>
1201 [radio radio-1 default:1 "1-10 employees" "11-30 employees" "30-50 employees" "Above 50 employee"]
1202 </div>
1203
1204 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1205 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1206 [submit "Send"]',
1207
1208 );
1209
1210 return $forms_array[ $preset ]; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1211
1212 }
1213
1214 /**
1215 * Render Rating Stars
1216 *
1217 * @since 4.10.13
1218 * @access public
1219 *
1220 * @param float $rating rating score.
1221 * @param string $fill_color fill color.
1222 * @param string $empty_color empty color.
1223 * @param float $star_size star size.
1224 */
1225 public static function render_rating_stars( $rating, $fill_color, $empty_color, $star_size ) {
1226
1227 ?>
1228
1229 <span class="premium-fb-rev-stars">
1230 <?php
1231
1232 foreach ( array( 1, 2, 3, 4, 5 ) as $val ) {
1233 $score = round( ( $rating - $val ), 2 );
1234
1235 if ( $score >= -0.2 ) {
1236
1237 ?>
1238 <span class="premium-fb-rev-star"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="<?php echo esc_attr( $star_size ); ?>" height="<?php echo esc_attr( $star_size ); ?>" viewBox="0 0 1792 1792"><path d="M1728 647q0 22-26 48l-363 354 86 500q1 7 1 20 0 21-10.5 35.5t-30.5 14.5q-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="<?php echo esc_attr( $fill_color ); ?>"></path></svg></span>
1239 <?php
1240 } elseif ( $score > -0.8 && $score < -0.2 ) {
1241 ?>
1242 <span class="premium-fb-rev-star"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="<?php echo esc_attr( $star_size ); ?>" height="<?php echo esc_attr( $star_size ); ?>" viewBox="0 0 1792 1792"><path d="M1250 957l257-250-356-52-66-10-30-60-159-322v963l59 31 318 168-60-355-12-66zm452-262l-363 354 86 500q5 33-6 51.5t-34 18.5q-17 0-40-12l-449-236-449 236q-23 12-40 12-23 0-34-18.5t-6-51.5l86-500-364-354q-32-32-23-59.5t54-34.5l502-73 225-455q20-41 49-41 28 0 49 41l225 455 502 73q45 7 54 34.5t-24 59.5z" fill="<?php echo esc_attr( $fill_color ); ?>"></path></svg></span>
1243 <?php } else { ?>
1244 <span class="premium-fb-rev-star"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="<?php echo esc_attr( $star_size ); ?>" height="<?php echo esc_attr( $star_size ); ?>" viewBox="0 0 1792 1792"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="<?php echo esc_attr( $empty_color ); ?>"></path></svg></span>
1245 <?php
1246 }
1247 }
1248 ?>
1249 </span>
1250
1251 <?php
1252 }
1253
1254
1255 /**
1256 * Get SVG Shapes
1257 *
1258 * @since 4.10.13
1259 * @access public
1260 *
1261 */
1262 public static function get_svg_shapes( $shape = '' ) {
1263
1264 if ( null === self::$shapes ) {
1265
1266 self::$shapes = require PREMIUM_ADDONS_PATH . 'modules/premium-shape-divider/shapes.php';
1267
1268 }
1269
1270 $shapes = self::$shapes;
1271
1272 if( empty( $shape ) ) {
1273 return $shapes;
1274 } else {
1275 return $shapes[ $shape ]['imagesmall'];
1276 }
1277
1278 }
1279
1280 }
1281