PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.11.34
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.11.34
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
controls 8 months ago pa-display-conditions 8 months ago templates 8 months ago acf-helper.php 8 months ago addons-cross-cp.php 8 months ago addons-integration.php 8 months ago assets-manager.php 8 months ago class-pa-core.php 8 months ago class-premium-template-tags.php 8 months ago helper-functions.php 8 months ago live-editor-modal.php 8 months ago module-base.php 8 months ago pa-nav-menu-walker.php 8 months ago papro-promotion.php 8 months ago
helper-functions.php
1897 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 use PremiumAddons\Admin\Includes\Admin_Helper;
12
13 // Elementor Classes.
14 use Elementor\Icons_Manager;
15 use Elementor\Core\Settings\Manager as SettingsManager;
16 use Elementor\Plugin;
17 use Elementor\Controls_Manager;
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22
23 /**
24 * Class Helper_Functions.
25 */
26 class Helper_Functions {
27
28 /**
29 * A list of safe tage for `validate_html_tag` method.
30 */
31 const ALLOWED_HTML_WRAPPER_TAGS = array(
32 'article',
33 'aside',
34 'div',
35 'footer',
36 'h1',
37 'h2',
38 'h3',
39 'h4',
40 'h5',
41 'h6',
42 'header',
43 'main',
44 'nav',
45 'p',
46 'section',
47 'span',
48 );
49
50 /**
51 * Theme
52 *
53 * @var theme
54 */
55 private static $current_theme = null;
56
57 /**
58 * Google maps prefixes
59 *
60 * @var google_localize
61 */
62 private static $google_localize = null;
63
64 /**
65 * SVG Shapes
66 *
67 * @var shapes
68 */
69 private static $shapes = null;
70
71 /**
72 * WP lang prefixes
73 *
74 * @var lang_locales
75 */
76 private static $lang_locales = null;
77
78 /**
79 * Script debug enabled
80 *
81 * @var script_debug
82 */
83 private static $script_debug = null;
84
85 /**
86 * JS scripts directory
87 *
88 * @var js_dir
89 */
90 private static $js_dir = null;
91
92 /**
93 * CSS fiels directory
94 *
95 * @var js_dir
96 */
97 private static $css_dir = null;
98
99 /**
100 * JS Suffix
101 *
102 * @var js_suffix
103 */
104 private static $assets_suffix = null;
105
106 /**
107 * Get Icon SVG Data
108 *
109 * @since 4.10.72
110 * @access private
111 *
112 * @return array icon data.
113 */
114 private static function get_icon_svg_data( $icon ) {
115
116 preg_match( '/fa(.*) fa-/', $icon['value'], $icon_name_matches );
117
118 if ( empty( $icon_name_matches ) ) {
119 return;
120 }
121
122 $icon_name = str_replace( $icon_name_matches[0], '', $icon['value'] );
123
124 $icon_key = str_replace( ' fa-', '-', $icon['value'] );
125
126 $icon_file_name = str_replace( 'fa-', '', $icon['library'] );
127
128 $path = ELEMENTOR_ASSETS_PATH . 'lib/font-awesome/json/' . $icon_file_name . '.json';
129
130 $data = file_get_contents( $path );
131
132 if ( ! $data ) {
133 return;
134 }
135
136 $data = json_decode( $data, true );
137
138 $svg_data = $data['icons'][ $icon_name ];
139
140 return array(
141 'width' => $svg_data[0],
142 'height' => $svg_data[1],
143 'path' => $svg_data[4],
144 );
145 }
146
147 /**
148 * Check if white labeling - Free version author field is set
149 *
150 * @since 1.0.0
151 * @access public
152 *
153 * @return string
154 */
155 public static function author() {
156
157 $author_free = 'Leap13';
158
159 if ( self::check_papro_version() ) {
160
161 $white_label = Helper::get_white_labeling_settings();
162
163 $author_free = $white_label['premium-wht-lbl-name'];
164
165 }
166
167 return '' !== $author_free ? $author_free : 'Leap13';
168 }
169
170 /**
171 * Check if white labeling - Free version name field is set
172 *
173 * @since 1.0.0
174 * @access public
175 *
176 * @return string
177 */
178 public static function name() {
179
180 $name_free = 'Premium Addons';
181
182 if ( self::check_papro_version() ) {
183
184 $white_label = Helper::get_white_labeling_settings();
185
186 $name_free = $white_label['premium-wht-lbl-plugin-name'];
187
188 }
189
190 return '' !== $name_free ? $name_free : 'Premium Addons';
191 }
192
193 /**
194 * Check if white labeling - Hide row meta option is checked
195 *
196 * @since 1.0.0
197 * @return boolean
198 */
199 public static function is_hide_row_meta() {
200
201 $hide_meta = false;
202
203 if ( self::check_papro_version() ) {
204
205 $white_label = Helper::get_white_labeling_settings();
206
207 $hide_meta = $white_label['premium-wht-lbl-row'];
208
209 }
210
211 return $hide_meta;
212 }
213
214 /**
215 * Check if white labeling - Hide plugin logo option is checked
216 *
217 * @since 1.0.0
218 * @access public
219 *
220 * @return boolean
221 */
222 public static function is_hide_logo() {
223
224 if ( self::check_papro_version() ) {
225
226 if ( isset( get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'] ) ) {
227
228 $hide_logo = get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'];
229
230 }
231 }
232
233 return isset( $hide_logo ) ? $hide_logo : false;
234 }
235
236 /**
237 * Get White Labeling - Widgets Category string
238 *
239 * @since 1.0.0
240 * @access public
241 *
242 * @return string
243 */
244 public static function get_category() {
245
246 $category = __( 'Premium Addons', 'premium-addons-for-elementor' );
247
248 if ( self::check_papro_version() ) {
249
250 $white_label = Helper::get_white_labeling_settings();
251
252 $category = $white_label['premium-wht-lbl-short-name'];
253
254 }
255
256 return '' !== $category ? $category : __( 'Premium Addons', 'premium-addons-for-elementor' );
257 }
258
259 /**
260 * Get White Labeling - Widgets Prefix string
261 *
262 * @since 1.0.0
263 * @access public
264 *
265 * @return string
266 */
267 public static function get_prefix() {
268
269 $prefix = __( 'Premium', 'premium-addons-for-elementor' );
270
271 if ( self::check_papro_version() ) {
272
273 $white_label = Helper::get_white_labeling_settings();
274
275 $prefix = $white_label['premium-wht-lbl-prefix'];
276
277 }
278
279 return '' !== $prefix ? $prefix : __( 'Premium', 'premium-addons-for-elementor' );
280 }
281
282 /**
283 * Check if white labeling - Future notification checked
284 *
285 * @since 1.0.0
286 * @return boolean
287 */
288 public static function check_hide_notifications() {
289
290 if ( self::check_papro_version() ) {
291
292 $white_label = Helper::get_white_labeling_settings();
293
294 $hide_notification = isset( $white_label['premium-wht-lbl-not'] ) ? $white_label['premium-wht-lbl-not'] : false;
295
296 }
297
298 return isset( $hide_notification ) ? $hide_notification : false;
299 }
300
301 /**
302 * Get White Labeling - Widgets Badge string
303 *
304 * @since 1.0.0
305 * @access public
306 *
307 * @return string
308 */
309 public static function get_badge() {
310
311 $badge = 'PA';
312
313 if ( self::check_papro_version() ) {
314
315 $white_label = Helper::get_white_labeling_settings();
316
317 $badge = $white_label['premium-wht-lbl-badge'];
318
319 }
320
321 return '' !== $badge ? $badge : 'PA';
322 }
323
324 /**
325 * Get Google Maps localization prefixes
326 *
327 * @since 1.0.0
328 * @access public
329 *
330 * @return array
331 */
332 public static function get_google_maps_prefixes() {
333
334 if ( null === self::$google_localize ) {
335
336 self::$google_localize = array(
337 'ar' => __( 'Arabic', 'premium-addons-for-elementor' ),
338 'eu' => __( 'Basque', 'premium-addons-for-elementor' ),
339 'bg' => __( 'Bulgarian', 'premium-addons-for-elementor' ),
340 'bn' => __( 'Bengali', 'premium-addons-for-elementor' ),
341 'ca' => __( 'Catalan', 'premium-addons-for-elementor' ),
342 'cs' => __( 'Czech', 'premium-addons-for-elementor' ),
343 'da' => __( 'Danish', 'premium-addons-for-elementor' ),
344 'de' => __( 'German', 'premium-addons-for-elementor' ),
345 'el' => __( 'Greek', 'premium-addons-for-elementor' ),
346 'en' => __( 'English', 'premium-addons-for-elementor' ),
347 'en-AU' => __( 'English (australian)', 'premium-addons-for-elementor' ),
348 'en-GB' => __( 'English (great britain)', 'premium-addons-for-elementor' ),
349 'es' => __( 'Spanish', 'premium-addons-for-elementor' ),
350 'fa' => __( 'Farsi', 'premium-addons-for-elementor' ),
351 'fi' => __( 'Finnish', 'premium-addons-for-elementor' ),
352 'fil' => __( 'Filipino', 'premium-addons-for-elementor' ),
353 'fr' => __( 'French', 'premium-addons-for-elementor' ),
354 'gl' => __( 'Galician', 'premium-addons-for-elementor' ),
355 'gu' => __( 'Gujarati', 'premium-addons-for-elementor' ),
356 'hi' => __( 'Hindi', 'premium-addons-for-elementor' ),
357 'hr' => __( 'Croatian', 'premium-addons-for-elementor' ),
358 'hu' => __( 'Hungarian', 'premium-addons-for-elementor' ),
359 'id' => __( 'Indonesian', 'premium-addons-for-elementor' ),
360 'it' => __( 'Italian', 'premium-addons-for-elementor' ),
361 'iw' => __( 'Hebrew', 'premium-addons-for-elementor' ),
362 'ja' => __( 'Japanese', 'premium-addons-for-elementor' ),
363 'kn' => __( 'Kannada', 'premium-addons-for-elementor' ),
364 'ko' => __( 'Korean', 'premium-addons-for-elementor' ),
365 'lt' => __( 'Lithuanian', 'premium-addons-for-elementor' ),
366 'lv' => __( 'Latvian', 'premium-addons-for-elementor' ),
367 'ml' => __( 'Malayalam', 'premium-addons-for-elementor' ),
368 'mr' => __( 'Marathi', 'premium-addons-for-elementor' ),
369 'nl' => __( 'Dutch', 'premium-addons-for-elementor' ),
370 'no' => __( 'Norwegian', 'premium-addons-for-elementor' ),
371 'pl' => __( 'Polish', 'premium-addons-for-elementor' ),
372 'pt' => __( 'Portuguese', 'premium-addons-for-elementor' ),
373 'pt-BR' => __( 'Portuguese (brazil)', 'premium-addons-for-elementor' ),
374 'pt-PT' => __( 'Portuguese (portugal)', 'premium-addons-for-elementor' ),
375 'ro' => __( 'Romanian', 'premium-addons-for-elementor' ),
376 'ru' => __( 'Russian', 'premium-addons-for-elementor' ),
377 'sk' => __( 'Slovak', 'premium-addons-for-elementor' ),
378 'sl' => __( 'Slovenian', 'premium-addons-for-elementor' ),
379 'sr' => __( 'Serbian', 'premium-addons-for-elementor' ),
380 'sv' => __( 'Swedish', 'premium-addons-for-elementor' ),
381 'tl' => __( 'Tagalog', 'premium-addons-for-elementor' ),
382 'ta' => __( 'Tamil', 'premium-addons-for-elementor' ),
383 'te' => __( 'Telugu', 'premium-addons-for-elementor' ),
384 'th' => __( 'Thai', 'premium-addons-for-elementor' ),
385 'tr' => __( 'Turkish', 'premium-addons-for-elementor' ),
386 'uk' => __( 'Ukrainian', 'premium-addons-for-elementor' ),
387 'vi' => __( 'Vietnamese', 'premium-addons-for-elementor' ),
388 'zh-CN' => __( 'Chinese (simplified)', 'premium-addons-for-elementor' ),
389 'zh-TW' => __( 'Chinese (traditional)', 'premium-addons-for-elementor' ),
390 );
391 }
392
393 return self::$google_localize;
394 }
395
396 /**
397 * Checks if a plugin is installed
398 *
399 * @since 1.0.0
400 * @access public
401 *
402 * @param string $plugin_path plugin path.
403 *
404 * @return boolean
405 */
406 public static function is_plugin_installed( $plugin_path ) {
407
408 require_once ABSPATH . 'wp-admin/includes/plugin.php';
409
410 $plugins = get_plugins();
411
412 return isset( $plugins[ $plugin_path ] );
413 }
414
415 /**
416 * Check Plugin Active
417 *
418 * @since 4.2.5
419 * @access public
420 *
421 * @param string $slug plugin slug.
422 *
423 * @return boolean $is_active plugin active.
424 */
425 public static function check_plugin_active( $slug = '' ) {
426
427 include_once ABSPATH . 'wp-admin/includes/plugin.php';
428
429 $is_active = in_array( $slug, (array) get_option( 'active_plugins', array() ), true );
430
431 return $is_active;
432 }
433
434 /**
435 * Check if script debug mode enabled.
436 *
437 * @since 3.11.1
438 * @access public
439 *
440 * @return boolean is debug mode enabled
441 */
442 public static function is_debug_enabled() {
443
444 if ( null === self::$script_debug ) {
445
446 self::$script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
447 }
448
449 return self::$script_debug;
450 }
451
452 /**
453 * Get scripts dir.
454 *
455 * @access public
456 *
457 * @return string JS scripts directory.
458 */
459 public static function get_scripts_dir() {
460
461 if ( null === self::$js_dir ) {
462
463 self::$js_dir = self::is_debug_enabled() ? 'js' : 'min-js';
464 }
465
466 return self::$js_dir;
467 }
468
469 /**
470 * Get styles dir.
471 *
472 * @access public
473 *
474 * @return string CSS files directory.
475 */
476 public static function get_styles_dir() {
477
478 if ( null === self::$css_dir ) {
479
480 self::$css_dir = self::is_debug_enabled() ? 'css' : 'min-css';
481 }
482
483 return self::$css_dir;
484 }
485
486 /**
487 * Get assets suffix.
488 *
489 * @access public
490 *
491 * @return string JS scripts suffix.
492 */
493 public static function get_assets_suffix() {
494
495 if ( null === self::$assets_suffix ) {
496
497 self::$assets_suffix = self::is_debug_enabled() ? '' : '.min';
498 }
499
500 return self::$assets_suffix;
501 }
502
503 /**
504 * Get Installed Theme
505 *
506 * Returns the active theme slug
507 *
508 * @access public
509 *
510 * @return string theme slug
511 */
512 public static function get_installed_theme() {
513
514 if ( null === self::$current_theme ) {
515
516 $theme = wp_get_theme();
517
518 if ( $theme->parent() ) {
519
520 $theme_name = sanitize_key( $theme->parent()->get( 'Name' ) );
521
522 } else {
523
524 $theme_name = $theme->get( 'Name' );
525
526 $theme_name = sanitize_key( $theme_name );
527
528 }
529
530 self::$current_theme = $theme_name;
531
532 }
533
534 return self::$current_theme;
535 }
536
537 /**
538 * Get Vimeo Video Data
539 *
540 * Get video data using Vimeo API
541 *
542 * @since 3.11.4
543 * @access public
544 *
545 * @param string $video_id video ID.
546 */
547 public static function get_vimeo_video_data( $video_id ) {
548
549 $vimeo_data = get_transient( 'premium_vimeo_' . $video_id );
550
551 if( $vimeo_data === false ) {
552
553 $vimeo_data = wp_remote_get( 'http://www.vimeo.com/api/v2/video/' . intval( $video_id ) . '.php' );
554
555 if ( is_wp_error( $vimeo_data ) ) {
556 return false;
557 }
558
559 if ( isset( $vimeo_data['response']['code'] ) ) {
560
561 if ( 200 === $vimeo_data['response']['code'] ) {
562
563 $response = maybe_unserialize( $vimeo_data['body'] );
564 $thumbnail = isset( $response[0]['thumbnail_large'] ) ? $response[0]['thumbnail_large'] : false;
565
566 $data = array(
567 'src' => $thumbnail,
568 'url' => $response[0]['user_url'],
569 'portrait' => $response[0]['user_portrait_huge'],
570 'title' => $response[0]['title'],
571 'user' => $response[0]['user_name'],
572 );
573
574 set_transient( 'premium_vimeo_' . $video_id, $data, WEEK_IN_SECONDS );
575
576 return $data;
577
578 }
579 }
580
581 }
582
583 return $vimeo_data;
584 }
585
586 /**
587 * Get Video Thumbnail
588 *
589 * Get thumbnail URL for embed or self hosted
590 *
591 * @since 3.7.0
592 * @access public
593 *
594 * @param string $video_id video ID.
595 * @param string $type embed type.
596 * @param string $size youtube thumbnail size.
597 */
598 public static function get_video_thumbnail( $video_id, $type, $size = '' ) {
599
600 $thumbnail_src = 'transparent';
601
602 if ( 'youtube' === $type ) {
603 if ( '' === $size ) {
604 $size = 'maxresdefault';
605 }
606 $thumbnail_src = sprintf( 'https://i.ytimg.com/vi/%s/%s.jpg', $video_id, $size );
607
608 } elseif ( 'vimeo' === $type ) {
609
610 $vimeo = self::get_vimeo_video_data( $video_id );
611
612 $thumbnail_src = is_array( $vimeo ) ? $vimeo['src'] : '';
613
614 } elseif ( 'dailymotion' === $type ) {
615 $video_data = wp_remote_get( 'https://api.dailymotion.com/video/' . $video_id . '?fields=thumbnail_url' );
616
617 if ( is_wp_error( $video_data ) || 200 !== wp_remote_retrieve_response_code( $video_data ) ) {
618 return $thumbnail_src;
619 }
620
621 $video_data = wp_remote_retrieve_body( $video_data );
622 $video_data = json_decode( $video_data );
623
624 $thumbnail_src = $video_data->thumbnail_url;
625 }
626
627 return $thumbnail_src;
628 }
629
630 /**
631 * Transient Expire
632 *
633 * Gets expire time of transient.
634 *
635 * @since 3.20.8
636 * @access public
637 *
638 * @param string $period transient expiration period.
639 *
640 * @return string $expire_time expire time in seconds.
641 */
642 public static function transient_expire( $period ) {
643
644 $expire_time = 24 * HOUR_IN_SECONDS;
645
646 switch ( $period ) {
647 case 'minute':
648 $expire_time = MINUTE_IN_SECONDS;
649 break;
650 case 'minutes':
651 $expire_time = 5 * MINUTE_IN_SECONDS;
652 break;
653 case 'hour':
654 $expire_time = 60 * MINUTE_IN_SECONDS;
655 break;
656 case 'week':
657 $expire_time = 7 * DAY_IN_SECONDS;
658 break;
659 case 'month':
660 $expire_time = 30 * DAY_IN_SECONDS;
661 break;
662 case 'year':
663 $expire_time = 365 * DAY_IN_SECONDS;
664 break;
665 default:
666 $expire_time = 24 * HOUR_IN_SECONDS;
667 }
668
669 return $expire_time;
670 }
671
672 /**
673 * Get Campaign Link
674 *
675 * @since 3.20.9
676 * @access public
677 *
678 * @param string $link page link.
679 * @param string $source source.
680 * @param string $medium media.
681 * @param string $campaign campaign name.
682 *
683 * @return string $link campaign URL
684 */
685 public static function get_campaign_link( $link, $source, $medium, $campaign = '' ) {
686
687 if ( null === self::$current_theme ) {
688 self::get_installed_theme();
689 }
690
691 $url = add_query_arg(
692 array(
693 'utm_source' => $source,
694 'utm_medium' => $medium,
695 'utm_campaign' => $campaign,
696 'utm_term' => self::$current_theme,
697 ),
698 $link
699 );
700
701 return $url;
702 }
703
704 /**
705 * Get Elementor UI Theme
706 *
707 * Detects user setting for UI theme
708 *
709 * @since 3.21.1
710 * @access public
711 *
712 * @return string $theme UI Theme
713 */
714 public static function get_elementor_ui_theme() {
715
716 $theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
717
718 return $theme;
719 }
720
721 /**
722 * Check PAPRO Version
723 *
724 * Check if PAPRO version is updated
725 *
726 * @since 3.21.6
727 * @access public
728 *
729 * @return boolen
730 */
731 public static function check_papro_version() {
732 return defined( 'PREMIUM_PRO_ADDONS_VERSION' );
733 }
734
735 /**
736 * Valide HTML Tag
737 *
738 * Validates an HTML tag against a safe allowed list.
739 *
740 * @param string $tag HTML tag.
741 *
742 * @return string
743 */
744 public static function validate_html_tag( $tag ) {
745 return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS, true ) ? $tag : 'div';
746 }
747
748 /**
749 * Get Image Data
750 *
751 * Returns image data based on image id.
752 *
753 * @since 0.0.1
754 * @access public
755 *
756 * @param int $image_id Image ID.
757 * @param string $image_url Image URL.
758 * @param array $image_size Image sizes array.
759 *
760 * @return array $data image data.
761 */
762 public static function get_image_data( $image_id, $image_url, $image_size ) {
763
764 if ( ! $image_id && ! $image_url ) {
765 return false;
766 }
767
768 $data = array();
769
770 $image_url = esc_url_raw( $image_url );
771
772 if ( ! empty( $image_id ) ) { // Existing attachment.
773
774 $attachment = get_post( $image_id );
775
776 if ( is_object( $attachment ) ) {
777 $data['id'] = $image_id;
778 $data['url'] = $image_url;
779
780 $data['image'] = wp_get_attachment_image( $attachment->ID, $image_size, true );
781 $data['image_size'] = $image_size;
782 $data['caption'] = $attachment->post_excerpt;
783 $data['title'] = $attachment->post_title;
784 $data['description'] = $attachment->post_content;
785
786 }
787 } else { // Placeholder image, most likely.
788
789 if ( empty( $image_url ) ) {
790 return;
791 }
792
793 $data['id'] = false;
794 $data['url'] = $image_url;
795 $data['image'] = '<img src="' . $image_url . '" alt="" title="" />';
796 $data['image_size'] = $image_size;
797 $data['caption'] = '';
798 $data['title'] = '';
799 $data['description'] = '';
800 }
801
802 return $data;
803 }
804
805 /**
806 * Returns the current page id.
807 * get_the_ID returns the first product ID in the loop if it's the shop page.
808 * and it sometimes returns a wrong ID in the other cases.
809 *
810 * @access public
811 * @since 4.11.8
812 * @return int
813 */
814 public static function pa_get_current_page_id() {
815
816 if ( class_exists( 'woocommerce' ) ) {
817
818 switch ( true ) {
819 case is_shop():
820 $page_id = wc_get_page_id( 'shop' );
821 break;
822
823 case is_cart():
824 $page_id = wc_get_page_id( 'cart' );
825 break;
826
827 case is_checkout():
828 $page_id = wc_get_page_id( 'checkout' );
829 break;
830
831 case is_account_page():
832 $page_id = wc_get_page_id( 'myaccount' );
833 break;
834
835 default:
836 $page_id = get_the_ID();
837 break;
838 }
839 } else {
840 $page_id = get_the_ID();
841 }
842
843 return $page_id;
844 }
845
846 /**
847 * Get Final Result.
848 *
849 * @access public
850 * @since 4.4.8
851 *
852 * @param bool $condition_result result.
853 * @param string $operator operator.
854 *
855 * @return bool
856 */
857 public static function get_final_result( $condition_result, $operator ) {
858
859 if ( 'is' === $operator ) {
860 return true === $condition_result;
861 } else {
862 return true !== $condition_result;
863 }
864 }
865
866 /**
867 * Get Local Time ( WordPress TimeZone Setting ).
868 *
869 * @access public
870 * @since 4.4.8
871 *
872 * @param string $format format.
873 */
874 public static function get_local_time( $format ) {
875
876 $local_time_zone = isset( $_COOKIE['localTimeZone'] ) && ! empty( $_COOKIE['localTimeZone'] ) ?
877 str_replace( 'GMT ', 'GMT+', sanitize_text_field( wp_unslash( $_COOKIE['localTimeZone'] ) ) )
878 : self::get_location_time_zone();
879
880 // $today = new \DateTime( 'now', new \DateTimeZone( $local_time_zone ) );
881
882 try {
883 $today = new \DateTime( 'now', new \DateTimeZone( $local_time_zone ) );
884 } catch ( \Exception $e ) {
885 $today = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) );
886 }
887
888 return $today->format( $format );
889 }
890
891 /**
892 * Gets the user's timezone based on his ip address.
893 *
894 * @access public
895 * @since 4.10.26
896 *
897 * @return string
898 */
899 public static function get_location_time_zone() {
900
901 $ip_address = self::get_user_ip_address();
902
903 return self::get_timezone_by_ip( $ip_address );
904 }
905
906 /**
907 * Get user's IP address.
908 *
909 * @access public
910 * @since 4.10.26
911 *
912 * @return string
913 */
914 public static function get_user_ip_address() {
915
916 if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
917
918 $x_forward = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
919
920 if ( is_array( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
921
922 $http_x_headers = explode( ',', filter_var_array( $x_forward ) );
923 $_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
924 } else {
925 $_SERVER['REMOTE_ADDR'] = $x_forward;
926 }
927 }
928
929 return isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
930 }
931
932 /**
933 * Get timezone by ip address.
934 *
935 * @access public
936 * @since 4.10.26
937 *
938 * @param string $ip_address user's ip address.
939 *
940 * @return string
941 */
942 public static function get_timezone_by_ip( $ip_address ) {
943
944 if ( '127.0.0.1' === $ip_address || empty( $ip_address ) ) {
945 return date_default_timezone_get();
946 }
947
948 $location_data = wp_remote_get(
949 'https://api.findip.net/' . $ip_address . '/?token=e21d68c353324af0af206c907e77ff97',
950 array(
951 'timeout' => 15,
952 'sslverify' => false,
953 )
954 );
955
956 if ( is_wp_error( $location_data ) || empty( $location_data ) ) {
957 return date_default_timezone_get(); // localhost.
958 }
959
960 $location_data = json_decode( wp_remote_retrieve_body( $location_data ), true );
961
962 $time_zone = strtolower( $location_data['location']['time_zone'] );
963
964 return $time_zone;
965 }
966
967 /**
968 * Get Site Server Time ( WordPress TimeZone Setting ).
969 *
970 * @access public
971 * @since 4.4.8
972 *
973 * @param string $format format.
974 */
975 public static function get_site_server_time( $format ) {
976
977 $today = gmdate( $format, strtotime( 'now' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
978
979 return $today;
980 }
981
982 /**
983 * Get All Breakpoints.
984 *
985 * @param string $type result return type.
986 *
987 * @access public
988 * @since 4.6.1
989 *
990 * @return array $devices enabled breakpoints.
991 */
992 public static function get_all_breakpoints( $type = 'assoc' ) {
993
994 $devices = array(
995 'desktop' => __( 'Desktop', 'elementor' ),
996 'tablet' => __( 'Tablet', 'elementor' ),
997 'mobile' => __( 'Mobile', 'elementor' ),
998 );
999
1000 $method_available = method_exists( Plugin::$instance->breakpoints, 'has_custom_breakpoints' );
1001
1002 if ( ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.4.0', '>' ) ) && $method_available ) {
1003
1004 if ( Plugin::$instance->breakpoints->has_custom_breakpoints() ) {
1005 $devices = array_merge(
1006 $devices,
1007 array(
1008 'widescreen' => __( 'Widescreen', 'elementor' ),
1009 'laptop' => __( 'Laptop', 'elementor' ),
1010 'tablet_extra' => __( 'Tablet Extra', 'elementor' ),
1011 'mobile_extra' => __( 'Mobile Extra', 'elementor' ),
1012 )
1013 );
1014 }
1015 }
1016
1017 if ( 'keys' === $type ) {
1018 $devices = array_keys( $devices );
1019 }
1020
1021 return $devices;
1022 }
1023
1024 /**
1025 * Get WordPress language prefixes.
1026 *
1027 * @since 4.4.8
1028 * @access public
1029 *
1030 * @return array
1031 */
1032 public static function get_lang_prefixes() {
1033
1034 if ( null === self::$lang_locales ) {
1035
1036 $langs = require_once PREMIUM_ADDONS_PATH . 'includes/pa-display-conditions/lang-locale.php';
1037
1038 foreach ( $langs as $lang => $props ) {
1039 /* translators: %s: Language Name */
1040 $val = ucwords( $props['name'] );
1041 self::$lang_locales[ $lang ] = $val;
1042 }
1043 }
1044
1045 return self::$lang_locales;
1046 }
1047
1048 /**
1049 * Get Woocommerce Categories.
1050 *
1051 * @access public
1052 * @since 4.4.8
1053 *
1054 * @param string $id array key.
1055 *
1056 * @return array
1057 */
1058 public static function get_woo_categories( $id = 'slug' ) {
1059
1060 $product_cat = array();
1061
1062 $cat_args = array(
1063 'taxonomy' => 'product_cat',
1064 'orderby' => 'name',
1065 'order' => 'asc',
1066 'hide_empty' => false,
1067 );
1068
1069 $product_categories = get_terms( $cat_args );
1070
1071 if ( ! empty( $product_categories ) ) {
1072
1073 foreach ( $product_categories as $key => $category ) {
1074
1075 $cat_id = 'slug' === $id ? $category->slug : $category->term_id;
1076 $product_cat[ $cat_id ] = $category->name;
1077
1078 }
1079 }
1080
1081 return $product_cat;
1082 }
1083
1084 /**
1085 * Check Elementor Experiment
1086 *
1087 * Check if an Elementor experiment is enabled.
1088 *
1089 * @since 4.8.6
1090 * @access public
1091 *
1092 * @param string $experiment feature ID.
1093 *
1094 * @return boolean $is_enabled is feature enabled.
1095 */
1096 public static function check_elementor_experiment( $experiment ) {
1097
1098 $experiments_manager = Plugin::$instance->experiments;
1099
1100 $is_enabled = $experiments_manager->is_feature_active( $experiment );
1101
1102 return $is_enabled;
1103 }
1104
1105 /**
1106 * Is Edit Mode.
1107 *
1108 * @access public
1109 * @since 4.6.1
1110 *
1111 * @return boolean
1112 */
1113 public static function is_edit_mode() {
1114 return isset( $_REQUEST['elementor-preview'] ) && ! empty( $_REQUEST['elementor-preview'] ); // phpcs:ignore WordPress.Security.NonceVerification
1115 }
1116
1117 /**
1118 * Generate Unique ID
1119 *
1120 * Generates a unique ID for the current page.
1121 *
1122 * @since 4.6.9
1123 * @access public
1124 *
1125 * @param string $id page ID.
1126 *
1127 * @return string unique ID.
1128 */
1129 public static function generate_unique_id( $id ) {
1130 return substr( md5( $id ), 0, 9 );
1131 }
1132
1133 /**
1134 * Get Safe Path
1135 *
1136 * @since 4.6.9
1137 * @access public
1138 *
1139 * @param string $file_path unsafe file path.
1140 *
1141 * @return string safe file path.
1142 */
1143 public static function get_safe_path( $file_path ) {
1144
1145 $path = str_replace( array( '//', '\\\\' ), array( '/', '\\' ), $file_path );
1146
1147 return str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $path );
1148 }
1149
1150 /**
1151 * Check if the current post type should include addons.
1152 *
1153 * @param string $id current post ID.
1154 *
1155 * @since 4.9.18
1156 * @access public
1157 */
1158 public static function check_post_type( $id ) {
1159
1160 if ( ! $id ) {
1161 return false;
1162 }
1163
1164 $template_name = get_post_meta( $id, '_elementor_template_type', true );
1165
1166 $template_list = array(
1167 'header',
1168 'footer',
1169 'single',
1170 'post',
1171 'page',
1172 'archive',
1173 'search-results',
1174 'error-404',
1175 'product',
1176 'product-archive',
1177 'section',
1178 );
1179
1180 return in_array( $template_name, $template_list );
1181 }
1182
1183 /**
1184 * Get Draw SVG Notice
1185 *
1186 * @since 4.9.26
1187 * @access public
1188 *
1189 * @param object $elem element object.
1190 * @param string $search search query.
1191 * @param array $conditions control conditions
1192 */
1193 public static function get_draw_svg_notice( $elem, $search, $conditions, $index = 0, $nested = 'condition' ) {
1194
1195 $url = add_query_arg(
1196 array(
1197 'page' => 'premium-addons',
1198 'search' => $search,
1199 '#tab' => 'elements',
1200 ),
1201 esc_url( admin_url( 'admin.php' ) )
1202 );
1203
1204 $control_attr = array(
1205 'type' => Controls_Manager::RAW_HTML,
1206 '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>',
1207 'classes' => 'editor-pa-control-notice',
1208 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
1209 );
1210
1211 $control_attr[ $nested ] = $conditions;
1212
1213 $elem->add_control(
1214 'draw_svg_notice_' . $index,
1215 $control_attr
1216 );
1217 }
1218
1219 /**
1220 * Checks if Elementor PRO 3.8 or higher is activated && if the Loop expirement is activated.
1221 *
1222 * @since 4.9.45
1223 * @access public
1224 *
1225 * @return bool
1226 */
1227 public static function is_loop_exp_enabled() {
1228
1229 if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
1230
1231 if ( version_compare( ELEMENTOR_PRO_VERSION, '3.16.0', '>=' ) ) {
1232 return true;
1233 } elseif ( version_compare( ELEMENTOR_PRO_VERSION, '3.8', '>=' ) ) {
1234 $is_loop_enabled = self::check_elementor_experiment( 'loop' );
1235
1236 if ( $is_loop_enabled ) {
1237 return true;
1238 }
1239 }
1240 }
1241
1242 return false;
1243 }
1244
1245 /**
1246 * Get Element Classes.
1247 *
1248 * @access private
1249 * @since 2.8.22
1250 *
1251 * @param array $devices devices to hide on.
1252 *
1253 * @return array
1254 */
1255 public static function get_element_classes( $devices, $default = array() ) {
1256
1257 $classes = $default;
1258
1259 if ( count( $devices ) ) {
1260 foreach ( $devices as $index => $device ) {
1261 array_push( $classes, 'elementor-hidden-' . $device );
1262 }
1263
1264 array_push( $classes, 'premium-addons-element' );
1265 }
1266
1267 return $classes;
1268 }
1269
1270 /**
1271 * Round Numbers In A Reading-friendly Format.
1272 *
1273 * @param integer $num followers number.
1274 */
1275 public static function premium_format_numbers( $num ) {
1276 $num = intval( $num );
1277 $result = '';
1278
1279 if ( $num >= 1000000000 ) {
1280 $tmp = round( ( $num / 1000000 ), 1 );
1281 $result = $tmp . 'B';
1282 return $result;
1283 }
1284
1285 if ( $num >= 1000000 ) {
1286 $tmp = round( ( $num / 1000000 ), 1 );
1287 $result = $tmp . 'M';
1288 return $result;
1289 }
1290
1291 if ( $num >= 1000 ) {
1292 $tmp = round( ( $num / 1000 ), 1 );
1293 $result = $tmp . 'K';
1294
1295 return $result;
1296 }
1297
1298 return round( $num, 1 );
1299 }
1300
1301 /**
1302 * Get Contact Form Body
1303 *
1304 * @since 4.10.2
1305 * @access public
1306 *
1307 * @param string $preset form preset.
1308 *
1309 * @return void
1310 */
1311 public static function get_cf_form_body( $preset ) {
1312
1313 $forms_array = array(
1314
1315 'preset1' => '<div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1316 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1317 [submit "Subscribe"]',
1318
1319 'preset2' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1320 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1321
1322 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1323 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1324
1325 [submit "Send"]',
1326
1327 'preset3' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1328 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1329
1330 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1331 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1332
1333 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1334 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1335
1336 [submit "Send"]',
1337
1338 'preset4' => '<div class="premium-cf-half"><label class="premium-cf-label">Name</label>
1339 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1340
1341 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1342 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1343
1344 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1345 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1346
1347 [submit "Send"]',
1348
1349 'preset5' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1350 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1351
1352 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1353 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1354
1355 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1356 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1357
1358 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1359 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1360
1361 <div class="premium-cf-full"><label class="premium-cf-label">Gender</label>
1362 [select menu-1 "Male" "Female"]</div>
1363
1364 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1365 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1366 [submit "Send"]',
1367
1368 'preset6' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1369 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1370
1371 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1372 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1373
1374 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1375 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1376
1377 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1378 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1379
1380 <div class="premium-cf-full"><label class="premium-cf-label">Company Size</label>
1381 [radio radio-1 default:1 "1-10 employees" "11-30 employees" "30-50 employees" "Above 50 employee"]
1382 </div>
1383
1384 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1385 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1386 [submit "Send"]',
1387
1388 );
1389
1390 return $forms_array[ $preset ]; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1391 }
1392
1393 /**
1394 * Render Rating Stars
1395 *
1396 * @since 4.10.13
1397 * @access public
1398 *
1399 * @param float $rating rating score.
1400 * @param string $fill_color fill color.
1401 * @param string $empty_color empty color.
1402 * @param float $star_size star size.
1403 */
1404 public static function render_rating_stars( $rating, $fill_color, $empty_color, $star_size ) {
1405
1406 ?>
1407
1408 <span class="premium-fb-rev-stars">
1409 <?php
1410
1411 foreach ( array( 1, 2, 3, 4, 5 ) as $val ) {
1412 $score = round( ( $rating - $val ), 2 );
1413
1414 if ( $score >= -0.2 ) {
1415
1416 ?>
1417 <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>
1418 <?php
1419 } elseif ( $score > -0.8 && $score < -0.2 ) {
1420 ?>
1421 <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>
1422 <?php } else { ?>
1423 <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>
1424 <?php
1425 }
1426 }
1427 ?>
1428 </span>
1429
1430 <?php
1431 }
1432
1433
1434 /**
1435 * Get SVG Shapes
1436 *
1437 * @since 4.10.13
1438 * @access public
1439 */
1440 public static function get_svg_shapes( $shape = '' ) {
1441
1442 if ( null === self::$shapes ) {
1443
1444 self::$shapes = require PREMIUM_ADDONS_PATH . 'modules/premium-shape-divider/shapes.php';
1445
1446 }
1447
1448 $shapes = self::$shapes;
1449
1450 if ( empty( $shape ) ) {
1451 return $shapes;
1452 } else {
1453 return $shapes[ $shape ]['imagesmall'];
1454 }
1455 }
1456
1457 public static function get_btn_svgs( $style = 'line1' ) {
1458
1459 $html = '';
1460
1461 switch ( $style ) {
1462 case 'line1':
1463 $html = '<div class="premium-btn-line-wrap"><svg class="premium-btn-svg" width="100%" height="9" viewBox="0 0 101 9">
1464 <path d="M.426 1.973C4.144 1.567 17.77-.514 21.443 1.48 24.296 3.026 24.844 4.627 27.5 7c3.075 2.748 6.642-4.141 10.066-4.688 7.517-1.2 13.237 5.425 17.59 2.745C58.5 3 60.464-1.786 66 2c1.996 1.365 3.174 3.737 5.286 4.41 5.423 1.727 25.34-7.981 29.14-1.294" pathLength="1"></path>
1465 </svg></div>';
1466 break;
1467
1468 case 'line3':
1469 $html = '<div class="premium-btn-line-wrap"><svg class="premium-btn-svg" width="100%" height="18" viewBox="0 0 59 18">
1470 <path d="M.945.149C12.3 16.142 43.573 22.572 58.785 10.842" pathLength="1"></path>
1471 </svg></div>';
1472 break;
1473
1474 case 'line4':
1475 $html = '<svg class="premium-btn-svg" width="300%" height="100%" viewBox="0 0 1200 60" preserveAspectRatio="none">
1476 <path d="M0,56.5c0,0,298.666,0,399.333,0C448.336,56.5,513.994,46,597,46c77.327,0,135,10.5,200.999,10.5c95.996,0,402.001,0,402.001,0"></path>
1477 </svg>';
1478 break;
1479
1480 default:
1481 // code...
1482 break;
1483 }
1484
1485 return $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1486 }
1487
1488 /**
1489 * Add Button Hover Controls
1490 *
1491 * @since 4.10.17
1492 * @access public
1493 *
1494 * @param object $elem widget object.
1495 * @param array $conditions controls conditions.
1496 */
1497 public static function add_btn_hover_controls( $elem, $conditions ) {
1498
1499 $elem->add_control(
1500 'premium_button_hover_effect',
1501 array(
1502 'label' => __( 'Hover Effect', 'premium-addons-for-elementor' ),
1503 'type' => Controls_Manager::SELECT,
1504 'default' => 'none',
1505 'options' => array(
1506 'none' => __( 'None', 'premium-addons-for-elementor' ),
1507 'style1' => __( 'Slide', 'premium-addons-for-elementor' ),
1508 'style2' => __( 'Shutter', 'premium-addons-for-elementor' ),
1509 'style5' => apply_filters( 'pa_pro_label', __( 'In & Out (Pro)', 'premium-addons-for-elementor' ) ),
1510 'style6' => apply_filters( 'pa_pro_label', __( 'Grow (Pro)', 'premium-addons-for-elementor' ) ),
1511 'style7' => apply_filters( 'pa_pro_label', __( 'Double Layers (Pro)', 'premium-addons-for-elementor' ) ),
1512 'style8' => apply_filters( 'pa_pro_label', __( 'Animated Underline (Pro)', 'premium-addons-for-elementor' ) ),
1513 ),
1514 'separator' => 'before',
1515 'label_block' => true,
1516 'condition' => $conditions,
1517 )
1518 );
1519
1520 do_action( 'pa_button_hover_controls', $elem, $conditions );
1521
1522 $elem->add_control(
1523 'premium_button_style1_dir',
1524 array(
1525 'label' => __( 'Slide Direction', 'premium-addons-for-elementor' ),
1526 'type' => Controls_Manager::SELECT,
1527 'default' => 'bottom',
1528 'options' => array(
1529 'bottom' => __( 'Top to Bottom', 'premium-addons-for-elementor' ),
1530 'top' => __( 'Bottom to Top', 'premium-addons-for-elementor' ),
1531 'left' => __( 'Right to Left', 'premium-addons-for-elementor' ),
1532 'right' => __( 'Left to Right', 'premium-addons-for-elementor' ),
1533 ),
1534 'condition' => array_merge(
1535 $conditions,
1536 array(
1537 'premium_button_hover_effect' => 'style1',
1538 )
1539 ),
1540 'label_block' => true,
1541 )
1542 );
1543
1544 $elem->add_control(
1545 'premium_button_style2_dir',
1546 array(
1547 'label' => __( 'Shutter Direction', 'premium-addons-for-elementor' ),
1548 'type' => Controls_Manager::SELECT,
1549 'default' => 'shutouthor',
1550 'options' => array(
1551 'shutinhor' => __( 'Shutter in Horizontal', 'premium-addons-for-elementor' ),
1552 'shutinver' => __( 'Shutter in Vertical', 'premium-addons-for-elementor' ),
1553 'shutoutver' => __( 'Shutter out Horizontal', 'premium-addons-for-elementor' ),
1554 'shutouthor' => __( 'Shutter out Vertical', 'premium-addons-for-elementor' ),
1555 'scshutoutver' => __( 'Scaled Shutter Vertical', 'premium-addons-for-elementor' ),
1556 'scshutouthor' => __( 'Scaled Shutter Horizontal', 'premium-addons-for-elementor' ),
1557 'dshutinver' => __( 'Tilted Left', 'premium-addons-for-elementor' ),
1558 'dshutinhor' => __( 'Tilted Right', 'premium-addons-for-elementor' ),
1559 ),
1560 'condition' => array_merge(
1561 $conditions,
1562 array(
1563 'premium_button_hover_effect' => 'style2',
1564 )
1565 ),
1566 'label_block' => true,
1567 )
1568 );
1569 }
1570
1571 /**
1572 * Add Templates Controls
1573 *
1574 * @since 4.11.25
1575 * @access public
1576 *
1577 * @param string $keyword keyword for templates.
1578 * @param string $demo demo url.
1579 */
1580 public static function add_templates_controls( $element, $keyword, $demo ) {
1581
1582 if ( ! Admin_Helper::check_element_by_key( 'premium-templates' ) ) {
1583 return;
1584 }
1585
1586 $element->add_control(
1587 'premium_templates_links',
1588 array(
1589 'type' => Controls_Manager::RAW_HTML,
1590 'raw' => '<div class="premium-promote-box widget-box">
1591 <div class="premium-promote-ctas">
1592 <a class="premium-promote-demo elementor-button elementor-button-default" href="' . esc_url( $demo ) . '" target="_blank"> ' .
1593 __( 'Widget Demo', 'premium-addons-for-elementor' ) .
1594 '</a>
1595 <a class="premium-promote-upgrade premium-widget-blocks elementor-button elementor-button-default" href="#" data-keyword="' . esc_attr( $keyword ) . '">' .
1596 __( 'Premade Templates', 'premium-addons-for-elementor' ) .
1597 '</a>
1598 </div>
1599 </div>',
1600 )
1601 );
1602 }
1603
1604 /**
1605 * Add Templates Controls
1606 *
1607 * @since 4.11.29
1608 * @access public
1609 *
1610 * @param string $keyword keyword for templates.
1611 * @param string $demo demo url.
1612 */
1613 public static function register_papro_promotion_controls( $element, $keyword ) {
1614
1615 if ( ! self::check_papro_version() ) {
1616
1617 $pro_link = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro/', $keyword, 'wp-editor', 'get-pro' );
1618
1619 $element->start_controls_section(
1620 'section_pro_features_field',
1621 array(
1622 'label' => __( 'Go Pro for More Features', 'premium-addons-for-elementor' ),
1623 )
1624 );
1625
1626 $element->add_control(
1627 'pa_pro_promotion_notice',
1628 array(
1629 'type' => Controls_Manager::NOTICE,
1630 'notice_type' => 'info',
1631 'dismissible' => false,
1632 'content' => __( '<b>Build smarter and faster</b> with premium widgets, 580+ container blocks, and advanced customization controls — all available in the <a href="'. esc_url( $pro_link ) .'" target="_blank">PA Pro</a>. Use the code <b>SUMMER10</b> to get 10% OFF on Lifetime license.', 'premium-addons-for-elementor' ),
1633 )
1634 );
1635
1636 $element->end_controls_section();
1637 }
1638 }
1639
1640 /**
1641 * Get Button Class
1642 *
1643 * @since 4.10.17
1644 * @access public
1645 *
1646 * @param $settings object widget settings.
1647 *
1648 * @return string $class css class.
1649 */
1650 public static function get_button_class( $settings ) {
1651
1652 $class = '';
1653
1654 $papro_activated = apply_filters( 'papro_activated', false );
1655
1656 if ( ! $papro_activated && ! in_array( $settings['premium_button_hover_effect'], array( 'none', 'style1', 'style2' ) ) ) {
1657 return '';
1658 }
1659
1660 if ( 'style1' === $settings['premium_button_hover_effect'] ) {
1661 $class = 'premium-button-style1-' . $settings['premium_button_style1_dir'];
1662 } elseif ( 'style2' === $settings['premium_button_hover_effect'] ) {
1663 $class = 'premium-button-style2-' . $settings['premium_button_style2_dir'];
1664 } elseif ( 'style5' === $settings['premium_button_hover_effect'] ) {
1665 $class = 'premium-button-style5-' . $settings['premium_button_style5_dir'];
1666 } elseif ( 'style6' === $settings['premium_button_hover_effect'] ) {
1667 $class = 'premium-button-style6';
1668 } elseif ( 'style7' === $settings['premium_button_hover_effect'] ) {
1669 $class = 'premium-button-style7-' . $settings['premium_button_style7_dir'];
1670 } elseif ( 'style8' === $settings['premium_button_hover_effect'] ) {
1671 $class = 'premium-button-' . $settings['underline_style'];
1672 }
1673
1674 return 'premium-button-' . $settings['premium_button_hover_effect'] . ' ' . $class;
1675 }
1676
1677
1678 /**
1679 * Get Empty Query Message
1680 *
1681 * Written in PHP and used to generate the final HTML when the query is empty
1682 *
1683 * @since 4.10.29
1684 * @access protected
1685 *
1686 * @param string $notice empty query notice.
1687 */
1688 public static function render_empty_query_message( $notice ) {
1689
1690 if ( empty( $notice ) ) {
1691 $notice = __( 'The current query has no posts. Please make sure you have published items matching your query.', 'premium-addons-for-elementor' );
1692 }
1693
1694 ?>
1695 <div class="premium-error-notice">
1696 <?php echo wp_kses_post( $notice ); ?>
1697 </div>
1698 <?php
1699 }
1700
1701 /**
1702 * Check Capability
1703 *
1704 * @since 4.10.28
1705 * @access public
1706 *
1707 * @param string $check capability.
1708 */
1709 public static function check_capability( $capability ) {
1710
1711 $post_author_id = get_the_author_meta( 'ID' );
1712
1713 $current_user_can = user_can( $post_author_id, $capability );
1714
1715 return $current_user_can;
1716 }
1717
1718
1719 /**
1720 * Get Allowed Icon Tags
1721 *
1722 * Returns an array of allowed HTML tags.
1723 *
1724 * @since 4.10.69
1725 * @access public
1726 *
1727 * @return array Array of allowed HTML tags.
1728 */
1729 public static function get_allowed_icon_tags() {
1730 return array(
1731 'svg' => array(
1732 'id' => array(),
1733 'class' => array(),
1734 'aria-hidden' => array(),
1735 'aria-labelledby' => array(),
1736 'role' => array(),
1737 'xmlns' => array(),
1738 'width' => array(),
1739 'height' => array(),
1740 'viewbox' => array(),
1741 'data-*' => true,
1742 ),
1743 'g' => array( 'fill' => array() ),
1744 'title' => array( 'title' => array() ),
1745 'path' => array(
1746 'd' => array(),
1747 'fill' => array(),
1748 ),
1749 'i' => array(
1750 'class' => array(),
1751 'id' => array(),
1752 'style' => array(),
1753 ),
1754 );
1755 }
1756
1757 /**
1758 * Get SVG By Icon
1759 *
1760 * @since 4.10.69
1761 * @access public
1762 */
1763 public static function get_svg_by_icon( $icon, $attributes = array() ) {
1764
1765 if ( empty( $icon ) || empty( $icon['value'] ) || empty( $icon['library'] ) ) {
1766 return '';
1767 }
1768
1769 // If icon library is SVG, then go to Elementor. Used for widgets where this function is called in all cases.
1770 if ( false === strpos( $icon['library'], 'fa-' ) ) {
1771 $svg_html = Icons_Manager::try_get_icon_html( $icon, wp_parse_args( $attributes, array( 'aria-hidden' => 'true' ) ) );
1772
1773 return $svg_html;
1774 }
1775
1776 $icon['font_family'] = 'font-awesome';
1777
1778 $i_class = str_replace( ' ', '-', $icon['value'] );
1779
1780 $svg_html = '<svg ';
1781
1782 $icon = self::get_icon_svg_data( $icon );
1783
1784 if ( ! $icon ) {
1785 // Icons_Manager::render_icon( $icon, array( 'aria-hidden' => 'true' ) );
1786 Icons_Manager::render_icon( $icon, wp_parse_args( $attributes, array( 'aria-hidden' => 'true' ) ) );
1787 return;
1788 }
1789
1790 $view_box = '0 0 ' . $icon['width'] . ' ' . $icon['height'];
1791
1792 if ( is_array( $attributes ) ) {
1793
1794 foreach ( $attributes as $key => $value ) {
1795
1796 if ( 'class' === $key ) {
1797
1798 $svg_html .= 'class="svg-inline--' . $i_class . ' ' . $value . '" ';
1799
1800 } else {
1801 $svg_html .= " {$key}='{$value}' ";
1802 }
1803 }
1804 } else {
1805
1806 $attributes = str_replace( 'class="', 'class="svg-inline--' . $i_class . ' ', $attributes );
1807
1808 $svg_html .= $attributes;
1809 }
1810
1811 $svg_html .= " aria-hidden='true' xmlns='http://www.w3.org/2000/svg' viewBox='{$view_box}'>";
1812
1813 $svg_html .= '<path d="' . esc_attr( $icon['path'] ) . '"></path>';
1814 $svg_html .= '</svg>';
1815
1816 return wp_kses( $svg_html, self::get_allowed_icon_tags() );
1817 }
1818
1819 /**
1820 * Get Elementor Template ID
1821 *
1822 * @since 4.10.80
1823 * @access public
1824 *
1825 * @param string $title template title.
1826 *
1827 * @return string $template_id template ID.
1828 */
1829 public static function get_elementor_template_id( $title ) {
1830
1831 if ( empty( $title ) ) {
1832 return;
1833 }
1834
1835 $args = array(
1836 'post_type' => 'elementor_library',
1837 'post_status' => 'publish',
1838 'posts_per_page' => 1,
1839 'title' => $title,
1840 'suppress_filters' => true,
1841 );
1842
1843 $query = new \WP_Query( $args );
1844
1845 $post_id = '';
1846
1847 if ( $query->have_posts() ) {
1848 $post_id = $query->post->ID;
1849
1850 wp_reset_postdata();
1851 }
1852
1853 return $post_id;
1854 }
1855
1856 /**
1857 * Render Elementor Template
1858 *
1859 * @since 4.10.80
1860 * @access public
1861 *
1862 * @param string|int $title Template Title||id.
1863 * @param bool $id indicates if $title is the template title or id.
1864 *
1865 * @return $template_content string HTML Markup of the selected template.
1866 */
1867 public static function render_elementor_template( $title, $id = false ) {
1868
1869 $frontend = Plugin::$instance->frontend;
1870
1871 $custom_temp = apply_filters( 'pa_temp_id', false );
1872
1873 if ( $custom_temp ) {
1874 $id = $title = $custom_temp;
1875 }
1876
1877 if ( ! $id ) {
1878 $id = self::get_elementor_template_id( $title );
1879
1880 if ( ! $id ) {
1881 // To replace the &#8211; in templates names with dash.
1882 $decoded_title = html_entity_decode( $title );
1883 $id = self::get_elementor_template_id( $decoded_title );
1884 }
1885
1886 $id = apply_filters( 'wpml_object_id', $id, 'elementor_library', true );
1887 } else {
1888 $id = $title;
1889 }
1890
1891 // $template_content = $frontend->get_builder_content( $id, true );
1892 $template_content = $frontend->get_builder_content_for_display( $id, true );
1893
1894 return $template_content;
1895 }
1896 }
1897