PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.11.32
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.11.32
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 9 months ago pa-display-conditions 9 months ago templates 9 months ago acf-helper.php 9 months ago addons-cross-cp.php 9 months ago addons-integration.php 9 months ago assets-manager.php 9 months ago class-pa-core.php 9 months ago class-premium-template-tags.php 9 months ago helper-functions.php 9 months ago live-editor-modal.php 9 months ago module-base.php 9 months ago pa-nav-menu-walker.php 9 months ago papro-promotion.php 9 months ago
helper-functions.php
1888 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 = wp_remote_get( 'http://www.vimeo.com/api/v2/video/' . intval( $video_id ) . '.php' );
550
551 if ( is_wp_error( $vimeo_data ) ) {
552 return false;
553 }
554
555 if ( isset( $vimeo_data['response']['code'] ) ) {
556
557 if ( 200 === $vimeo_data['response']['code'] ) {
558
559 $response = maybe_unserialize( $vimeo_data['body'] );
560 $thumbnail = isset( $response[0]['thumbnail_large'] ) ? $response[0]['thumbnail_large'] : false;
561
562 $data = array(
563 'src' => $thumbnail,
564 'url' => $response[0]['user_url'],
565 'portrait' => $response[0]['user_portrait_huge'],
566 'title' => $response[0]['title'],
567 'user' => $response[0]['user_name'],
568 );
569
570 return $data;
571
572 }
573 }
574
575 return false;
576 }
577
578 /**
579 * Get Video Thumbnail
580 *
581 * Get thumbnail URL for embed or self hosted
582 *
583 * @since 3.7.0
584 * @access public
585 *
586 * @param string $video_id video ID.
587 * @param string $type embed type.
588 * @param string $size youtube thumbnail size.
589 */
590 public static function get_video_thumbnail( $video_id, $type, $size = '' ) {
591
592 $thumbnail_src = 'transparent';
593
594 if ( 'youtube' === $type ) {
595 if ( '' === $size ) {
596 $size = 'maxresdefault';
597 }
598 $thumbnail_src = sprintf( 'https://i.ytimg.com/vi/%s/%s.jpg', $video_id, $size );
599
600 } elseif ( 'vimeo' === $type ) {
601
602 $vimeo = self::get_vimeo_video_data( $video_id );
603
604 $thumbnail_src = is_array( $vimeo ) ? $vimeo['src'] : '';
605
606 } elseif ( 'dailymotion' === $type ) {
607 $video_data = rplg_urlopen( 'https://api.dailymotion.com/video/' . $video_id . '?fields=thumbnail_url' );
608
609 if ( isset( $video_data['code'] ) ) {
610 if ( 404 === $video_data['code'] ) {
611 return $thumbnail_src;
612 }
613 }
614
615 $thumbnail_src = rplg_json_decode( $video_data['data'] )->thumbnail_url;
616 }
617
618 return $thumbnail_src;
619 }
620
621 /**
622 * Transient Expire
623 *
624 * Gets expire time of transient.
625 *
626 * @since 3.20.8
627 * @access public
628 *
629 * @param string $period transient expiration period.
630 *
631 * @return string $expire_time expire time in seconds.
632 */
633 public static function transient_expire( $period ) {
634
635 $expire_time = 24 * HOUR_IN_SECONDS;
636
637 switch ( $period ) {
638 case 'minute':
639 $expire_time = MINUTE_IN_SECONDS;
640 break;
641 case 'minutes':
642 $expire_time = 5 * MINUTE_IN_SECONDS;
643 break;
644 case 'hour':
645 $expire_time = 60 * MINUTE_IN_SECONDS;
646 break;
647 case 'week':
648 $expire_time = 7 * DAY_IN_SECONDS;
649 break;
650 case 'month':
651 $expire_time = 30 * DAY_IN_SECONDS;
652 break;
653 case 'year':
654 $expire_time = 365 * DAY_IN_SECONDS;
655 break;
656 default:
657 $expire_time = 24 * HOUR_IN_SECONDS;
658 }
659
660 return $expire_time;
661 }
662
663 /**
664 * Get Campaign Link
665 *
666 * @since 3.20.9
667 * @access public
668 *
669 * @param string $link page link.
670 * @param string $source source.
671 * @param string $medium media.
672 * @param string $campaign campaign name.
673 *
674 * @return string $link campaign URL
675 */
676 public static function get_campaign_link( $link, $source, $medium, $campaign = '' ) {
677
678 if ( null === self::$current_theme ) {
679 self::get_installed_theme();
680 }
681
682 $url = add_query_arg(
683 array(
684 'utm_source' => $source,
685 'utm_medium' => $medium,
686 'utm_campaign' => $campaign,
687 'utm_term' => self::$current_theme,
688 ),
689 $link
690 );
691
692 return $url;
693 }
694
695 /**
696 * Get Elementor UI Theme
697 *
698 * Detects user setting for UI theme
699 *
700 * @since 3.21.1
701 * @access public
702 *
703 * @return string $theme UI Theme
704 */
705 public static function get_elementor_ui_theme() {
706
707 $theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
708
709 return $theme;
710 }
711
712 /**
713 * Check PAPRO Version
714 *
715 * Check if PAPRO version is updated
716 *
717 * @since 3.21.6
718 * @access public
719 *
720 * @return boolen
721 */
722 public static function check_papro_version() {
723 return defined( 'PREMIUM_PRO_ADDONS_VERSION' );
724 }
725
726 /**
727 * Valide HTML Tag
728 *
729 * Validates an HTML tag against a safe allowed list.
730 *
731 * @param string $tag HTML tag.
732 *
733 * @return string
734 */
735 public static function validate_html_tag( $tag ) {
736 return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS, true ) ? $tag : 'div';
737 }
738
739 /**
740 * Get Image Data
741 *
742 * Returns image data based on image id.
743 *
744 * @since 0.0.1
745 * @access public
746 *
747 * @param int $image_id Image ID.
748 * @param string $image_url Image URL.
749 * @param array $image_size Image sizes array.
750 *
751 * @return array $data image data.
752 */
753 public static function get_image_data( $image_id, $image_url, $image_size ) {
754
755 if ( ! $image_id && ! $image_url ) {
756 return false;
757 }
758
759 $data = array();
760
761 $image_url = esc_url_raw( $image_url );
762
763 if ( ! empty( $image_id ) ) { // Existing attachment.
764
765 $attachment = get_post( $image_id );
766
767 if ( is_object( $attachment ) ) {
768 $data['id'] = $image_id;
769 $data['url'] = $image_url;
770
771 $data['image'] = wp_get_attachment_image( $attachment->ID, $image_size, true );
772 $data['image_size'] = $image_size;
773 $data['caption'] = $attachment->post_excerpt;
774 $data['title'] = $attachment->post_title;
775 $data['description'] = $attachment->post_content;
776
777 }
778 } else { // Placeholder image, most likely.
779
780 if ( empty( $image_url ) ) {
781 return;
782 }
783
784 $data['id'] = false;
785 $data['url'] = $image_url;
786 $data['image'] = '<img src="' . $image_url . '" alt="" title="" />';
787 $data['image_size'] = $image_size;
788 $data['caption'] = '';
789 $data['title'] = '';
790 $data['description'] = '';
791 }
792
793 return $data;
794 }
795
796 /**
797 * Returns the current page id.
798 * get_the_ID returns the first product ID in the loop if it's the shop page.
799 * and it sometimes returns a wrong ID in the other cases.
800 *
801 * @access public
802 * @since 4.11.8
803 * @return int
804 */
805 public static function pa_get_current_page_id() {
806
807 if ( class_exists( 'woocommerce' ) ) {
808
809 switch ( true ) {
810 case is_shop():
811 $page_id = wc_get_page_id( 'shop' );
812 break;
813
814 case is_cart():
815 $page_id = wc_get_page_id( 'cart' );
816 break;
817
818 case is_checkout():
819 $page_id = wc_get_page_id( 'checkout' );
820 break;
821
822 case is_account_page():
823 $page_id = wc_get_page_id( 'myaccount' );
824 break;
825
826 default:
827 $page_id = get_the_ID();
828 break;
829 }
830 } else {
831 $page_id = get_the_ID();
832 }
833
834 return $page_id;
835 }
836
837 /**
838 * Get Final Result.
839 *
840 * @access public
841 * @since 4.4.8
842 *
843 * @param bool $condition_result result.
844 * @param string $operator operator.
845 *
846 * @return bool
847 */
848 public static function get_final_result( $condition_result, $operator ) {
849
850 if ( 'is' === $operator ) {
851 return true === $condition_result;
852 } else {
853 return true !== $condition_result;
854 }
855 }
856
857 /**
858 * Get Local Time ( WordPress TimeZone Setting ).
859 *
860 * @access public
861 * @since 4.4.8
862 *
863 * @param string $format format.
864 */
865 public static function get_local_time( $format ) {
866
867 $local_time_zone = isset( $_COOKIE['localTimeZone'] ) && ! empty( $_COOKIE['localTimeZone'] ) ?
868 str_replace( 'GMT ', 'GMT+', sanitize_text_field( wp_unslash( $_COOKIE['localTimeZone'] ) ) )
869 : self::get_location_time_zone();
870
871 // $today = new \DateTime( 'now', new \DateTimeZone( $local_time_zone ) );
872
873 try {
874 $today = new \DateTime( 'now', new \DateTimeZone( $local_time_zone ) );
875 } catch ( \Exception $e ) {
876 $today = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) );
877 }
878
879 return $today->format( $format );
880 }
881
882 /**
883 * Gets the user's timezone based on his ip address.
884 *
885 * @access public
886 * @since 4.10.26
887 *
888 * @return string
889 */
890 public static function get_location_time_zone() {
891
892 $ip_address = self::get_user_ip_address();
893
894 return self::get_timezone_by_ip( $ip_address );
895 }
896
897 /**
898 * Get user's IP address.
899 *
900 * @access public
901 * @since 4.10.26
902 *
903 * @return string
904 */
905 public static function get_user_ip_address() {
906
907 if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
908
909 $x_forward = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
910
911 if ( is_array( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
912
913 $http_x_headers = explode( ',', filter_var_array( $x_forward ) );
914 $_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
915 } else {
916 $_SERVER['REMOTE_ADDR'] = $x_forward;
917 }
918 }
919
920 return isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
921 }
922
923 /**
924 * Get timezone by ip address.
925 *
926 * @access public
927 * @since 4.10.26
928 *
929 * @param string $ip_address user's ip address.
930 *
931 * @return string
932 */
933 public static function get_timezone_by_ip( $ip_address ) {
934
935 if ( '127.0.0.1' === $ip_address || empty( $ip_address ) ) {
936 return date_default_timezone_get();
937 }
938
939 $location_data = wp_remote_get(
940 'https://api.findip.net/' . $ip_address . '/?token=e21d68c353324af0af206c907e77ff97',
941 array(
942 'timeout' => 15,
943 'sslverify' => false,
944 )
945 );
946
947 if ( is_wp_error( $location_data ) || empty( $location_data ) ) {
948 return date_default_timezone_get(); // localhost.
949 }
950
951 $location_data = json_decode( wp_remote_retrieve_body( $location_data ), true );
952
953 $time_zone = strtolower( $location_data['location']['time_zone'] );
954
955 return $time_zone;
956 }
957
958 /**
959 * Get Site Server Time ( WordPress TimeZone Setting ).
960 *
961 * @access public
962 * @since 4.4.8
963 *
964 * @param string $format format.
965 */
966 public static function get_site_server_time( $format ) {
967
968 $today = gmdate( $format, strtotime( 'now' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
969
970 return $today;
971 }
972
973 /**
974 * Get All Breakpoints.
975 *
976 * @param string $type result return type.
977 *
978 * @access public
979 * @since 4.6.1
980 *
981 * @return array $devices enabled breakpoints.
982 */
983 public static function get_all_breakpoints( $type = 'assoc' ) {
984
985 $devices = array(
986 'desktop' => __( 'Desktop', 'elementor' ),
987 'tablet' => __( 'Tablet', 'elementor' ),
988 'mobile' => __( 'Mobile', 'elementor' ),
989 );
990
991 $method_available = method_exists( Plugin::$instance->breakpoints, 'has_custom_breakpoints' );
992
993 if ( ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.4.0', '>' ) ) && $method_available ) {
994
995 if ( Plugin::$instance->breakpoints->has_custom_breakpoints() ) {
996 $devices = array_merge(
997 $devices,
998 array(
999 'widescreen' => __( 'Widescreen', 'elementor' ),
1000 'laptop' => __( 'Laptop', 'elementor' ),
1001 'tablet_extra' => __( 'Tablet Extra', 'elementor' ),
1002 'mobile_extra' => __( 'Mobile Extra', 'elementor' ),
1003 )
1004 );
1005 }
1006 }
1007
1008 if ( 'keys' === $type ) {
1009 $devices = array_keys( $devices );
1010 }
1011
1012 return $devices;
1013 }
1014
1015 /**
1016 * Get WordPress language prefixes.
1017 *
1018 * @since 4.4.8
1019 * @access public
1020 *
1021 * @return array
1022 */
1023 public static function get_lang_prefixes() {
1024
1025 if ( null === self::$lang_locales ) {
1026
1027 $langs = require_once PREMIUM_ADDONS_PATH . 'includes/pa-display-conditions/lang-locale.php';
1028
1029 foreach ( $langs as $lang => $props ) {
1030 /* translators: %s: Language Name */
1031 $val = ucwords( $props['name'] );
1032 self::$lang_locales[ $lang ] = $val;
1033 }
1034 }
1035
1036 return self::$lang_locales;
1037 }
1038
1039 /**
1040 * Get Woocommerce Categories.
1041 *
1042 * @access public
1043 * @since 4.4.8
1044 *
1045 * @param string $id array key.
1046 *
1047 * @return array
1048 */
1049 public static function get_woo_categories( $id = 'slug' ) {
1050
1051 $product_cat = array();
1052
1053 $cat_args = array(
1054 'taxonomy' => 'product_cat',
1055 'orderby' => 'name',
1056 'order' => 'asc',
1057 'hide_empty' => false,
1058 );
1059
1060 $product_categories = get_terms( $cat_args );
1061
1062 if ( ! empty( $product_categories ) ) {
1063
1064 foreach ( $product_categories as $key => $category ) {
1065
1066 $cat_id = 'slug' === $id ? $category->slug : $category->term_id;
1067 $product_cat[ $cat_id ] = $category->name;
1068
1069 }
1070 }
1071
1072 return $product_cat;
1073 }
1074
1075 /**
1076 * Check Elementor Experiment
1077 *
1078 * Check if an Elementor experiment is enabled.
1079 *
1080 * @since 4.8.6
1081 * @access public
1082 *
1083 * @param string $experiment feature ID.
1084 *
1085 * @return boolean $is_enabled is feature enabled.
1086 */
1087 public static function check_elementor_experiment( $experiment ) {
1088
1089 $experiments_manager = Plugin::$instance->experiments;
1090
1091 $is_enabled = $experiments_manager->is_feature_active( $experiment );
1092
1093 return $is_enabled;
1094 }
1095
1096 /**
1097 * Is Edit Mode.
1098 *
1099 * @access public
1100 * @since 4.6.1
1101 *
1102 * @return boolean
1103 */
1104 public static function is_edit_mode() {
1105 return isset( $_REQUEST['elementor-preview'] ) && ! empty( $_REQUEST['elementor-preview'] ); // phpcs:ignore WordPress.Security.NonceVerification
1106 }
1107
1108 /**
1109 * Generate Unique ID
1110 *
1111 * Generates a unique ID for the current page.
1112 *
1113 * @since 4.6.9
1114 * @access public
1115 *
1116 * @param string $id page ID.
1117 *
1118 * @return string unique ID.
1119 */
1120 public static function generate_unique_id( $id ) {
1121 return substr( md5( $id ), 0, 9 );
1122 }
1123
1124 /**
1125 * Get Safe Path
1126 *
1127 * @since 4.6.9
1128 * @access public
1129 *
1130 * @param string $file_path unsafe file path.
1131 *
1132 * @return string safe file path.
1133 */
1134 public static function get_safe_path( $file_path ) {
1135
1136 $path = str_replace( array( '//', '\\\\' ), array( '/', '\\' ), $file_path );
1137
1138 return str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $path );
1139 }
1140
1141 /**
1142 * Check if the current post type should include addons.
1143 *
1144 * @param string $id current post ID.
1145 *
1146 * @since 4.9.18
1147 * @access public
1148 */
1149 public static function check_post_type( $id ) {
1150
1151 if ( ! $id ) {
1152 return false;
1153 }
1154
1155 $template_name = get_post_meta( $id, '_elementor_template_type', true );
1156
1157 $template_list = array(
1158 'header',
1159 'footer',
1160 'single',
1161 'post',
1162 'page',
1163 'archive',
1164 'search-results',
1165 'error-404',
1166 'product',
1167 'product-archive',
1168 'section',
1169 );
1170
1171 return in_array( $template_name, $template_list );
1172 }
1173
1174 /**
1175 * Get Draw SVG Notice
1176 *
1177 * @since 4.9.26
1178 * @access public
1179 *
1180 * @param object $elem element object.
1181 * @param string $search search query.
1182 * @param array $conditions control conditions
1183 */
1184 public static function get_draw_svg_notice( $elem, $search, $conditions, $index = 0, $nested = 'condition' ) {
1185
1186 $url = add_query_arg(
1187 array(
1188 'page' => 'premium-addons',
1189 'search' => $search,
1190 '#tab' => 'elements',
1191 ),
1192 esc_url( admin_url( 'admin.php' ) )
1193 );
1194
1195 $control_attr = array(
1196 'type' => Controls_Manager::RAW_HTML,
1197 '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>',
1198 'classes' => 'editor-pa-control-notice',
1199 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
1200 );
1201
1202 $control_attr[ $nested ] = $conditions;
1203
1204 $elem->add_control(
1205 'draw_svg_notice_' . $index,
1206 $control_attr
1207 );
1208 }
1209
1210 /**
1211 * Checks if Elementor PRO 3.8 or higher is activated && if the Loop expirement is activated.
1212 *
1213 * @since 4.9.45
1214 * @access public
1215 *
1216 * @return bool
1217 */
1218 public static function is_loop_exp_enabled() {
1219
1220 if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
1221
1222 if ( version_compare( ELEMENTOR_PRO_VERSION, '3.16.0', '>=' ) ) {
1223 return true;
1224 } elseif ( version_compare( ELEMENTOR_PRO_VERSION, '3.8', '>=' ) ) {
1225 $is_loop_enabled = self::check_elementor_experiment( 'loop' );
1226
1227 if ( $is_loop_enabled ) {
1228 return true;
1229 }
1230 }
1231 }
1232
1233 return false;
1234 }
1235
1236 /**
1237 * Get Element Classes.
1238 *
1239 * @access private
1240 * @since 2.8.22
1241 *
1242 * @param array $devices devices to hide on.
1243 *
1244 * @return array
1245 */
1246 public static function get_element_classes( $devices, $default = array() ) {
1247
1248 $classes = $default;
1249
1250 if ( count( $devices ) ) {
1251 foreach ( $devices as $index => $device ) {
1252 array_push( $classes, 'elementor-hidden-' . $device );
1253 }
1254
1255 array_push( $classes, 'premium-addons-element' );
1256 }
1257
1258 return $classes;
1259 }
1260
1261 /**
1262 * Round Numbers In A Reading-friendly Format.
1263 *
1264 * @param integer $num followers number.
1265 */
1266 public static function premium_format_numbers( $num ) {
1267 $num = intval( $num );
1268 $result = '';
1269
1270 if ( $num >= 1000000000 ) {
1271 $tmp = round( ( $num / 1000000 ), 1 );
1272 $result = $tmp . 'B';
1273 return $result;
1274 }
1275
1276 if ( $num >= 1000000 ) {
1277 $tmp = round( ( $num / 1000000 ), 1 );
1278 $result = $tmp . 'M';
1279 return $result;
1280 }
1281
1282 if ( $num >= 1000 ) {
1283 $tmp = round( ( $num / 1000 ), 1 );
1284 $result = $tmp . 'K';
1285
1286 return $result;
1287 }
1288
1289 return round( $num, 1 );
1290 }
1291
1292 /**
1293 * Get Contact Form Body
1294 *
1295 * @since 4.10.2
1296 * @access public
1297 *
1298 * @param string $preset form preset.
1299 *
1300 * @return void
1301 */
1302 public static function get_cf_form_body( $preset ) {
1303
1304 $forms_array = array(
1305
1306 'preset1' => '<div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1307 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1308 [submit "Subscribe"]',
1309
1310 'preset2' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1311 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1312
1313 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1314 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1315
1316 [submit "Send"]',
1317
1318 'preset3' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1319 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1320
1321 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1322 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1323
1324 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1325 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1326
1327 [submit "Send"]',
1328
1329 'preset4' => '<div class="premium-cf-half"><label class="premium-cf-label">Name</label>
1330 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1331
1332 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1333 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1334
1335 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1336 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1337
1338 [submit "Send"]',
1339
1340 'preset5' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1341 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1342
1343 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1344 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1345
1346 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1347 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1348
1349 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1350 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1351
1352 <div class="premium-cf-full"><label class="premium-cf-label">Gender</label>
1353 [select menu-1 "Male" "Female"]</div>
1354
1355 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1356 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1357 [submit "Send"]',
1358
1359 'preset6' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1360 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1361
1362 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1363 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1364
1365 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1366 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1367
1368 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1369 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1370
1371 <div class="premium-cf-full"><label class="premium-cf-label">Company Size</label>
1372 [radio radio-1 default:1 "1-10 employees" "11-30 employees" "30-50 employees" "Above 50 employee"]
1373 </div>
1374
1375 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1376 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1377 [submit "Send"]',
1378
1379 );
1380
1381 return $forms_array[ $preset ]; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1382 }
1383
1384 /**
1385 * Render Rating Stars
1386 *
1387 * @since 4.10.13
1388 * @access public
1389 *
1390 * @param float $rating rating score.
1391 * @param string $fill_color fill color.
1392 * @param string $empty_color empty color.
1393 * @param float $star_size star size.
1394 */
1395 public static function render_rating_stars( $rating, $fill_color, $empty_color, $star_size ) {
1396
1397 ?>
1398
1399 <span class="premium-fb-rev-stars">
1400 <?php
1401
1402 foreach ( array( 1, 2, 3, 4, 5 ) as $val ) {
1403 $score = round( ( $rating - $val ), 2 );
1404
1405 if ( $score >= -0.2 ) {
1406
1407 ?>
1408 <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>
1409 <?php
1410 } elseif ( $score > -0.8 && $score < -0.2 ) {
1411 ?>
1412 <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>
1413 <?php } else { ?>
1414 <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>
1415 <?php
1416 }
1417 }
1418 ?>
1419 </span>
1420
1421 <?php
1422 }
1423
1424
1425 /**
1426 * Get SVG Shapes
1427 *
1428 * @since 4.10.13
1429 * @access public
1430 */
1431 public static function get_svg_shapes( $shape = '' ) {
1432
1433 if ( null === self::$shapes ) {
1434
1435 self::$shapes = require PREMIUM_ADDONS_PATH . 'modules/premium-shape-divider/shapes.php';
1436
1437 }
1438
1439 $shapes = self::$shapes;
1440
1441 if ( empty( $shape ) ) {
1442 return $shapes;
1443 } else {
1444 return $shapes[ $shape ]['imagesmall'];
1445 }
1446 }
1447
1448 public static function get_btn_svgs( $style = 'line1' ) {
1449
1450 $html = '';
1451
1452 switch ( $style ) {
1453 case 'line1':
1454 $html = '<div class="premium-btn-line-wrap"><svg class="premium-btn-svg" width="100%" height="9" viewBox="0 0 101 9">
1455 <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>
1456 </svg></div>';
1457 break;
1458
1459 case 'line3':
1460 $html = '<div class="premium-btn-line-wrap"><svg class="premium-btn-svg" width="100%" height="18" viewBox="0 0 59 18">
1461 <path d="M.945.149C12.3 16.142 43.573 22.572 58.785 10.842" pathLength="1"></path>
1462 </svg></div>';
1463 break;
1464
1465 case 'line4':
1466 $html = '<svg class="premium-btn-svg" width="300%" height="100%" viewBox="0 0 1200 60" preserveAspectRatio="none">
1467 <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>
1468 </svg>';
1469 break;
1470
1471 default:
1472 // code...
1473 break;
1474 }
1475
1476 return $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1477 }
1478
1479 /**
1480 * Add Button Hover Controls
1481 *
1482 * @since 4.10.17
1483 * @access public
1484 *
1485 * @param object $elem widget object.
1486 * @param array $conditions controls conditions.
1487 */
1488 public static function add_btn_hover_controls( $elem, $conditions ) {
1489
1490 $elem->add_control(
1491 'premium_button_hover_effect',
1492 array(
1493 'label' => __( 'Hover Effect', 'premium-addons-for-elementor' ),
1494 'type' => Controls_Manager::SELECT,
1495 'default' => 'none',
1496 'options' => array(
1497 'none' => __( 'None', 'premium-addons-for-elementor' ),
1498 'style1' => __( 'Slide', 'premium-addons-for-elementor' ),
1499 'style2' => __( 'Shutter', 'premium-addons-for-elementor' ),
1500 'style5' => apply_filters( 'pa_pro_label', __( 'In & Out (Pro)', 'premium-addons-for-elementor' ) ),
1501 'style6' => apply_filters( 'pa_pro_label', __( 'Grow (Pro)', 'premium-addons-for-elementor' ) ),
1502 'style7' => apply_filters( 'pa_pro_label', __( 'Double Layers (Pro)', 'premium-addons-for-elementor' ) ),
1503 'style8' => apply_filters( 'pa_pro_label', __( 'Animated Underline (Pro)', 'premium-addons-for-elementor' ) ),
1504 ),
1505 'separator' => 'before',
1506 'label_block' => true,
1507 'condition' => $conditions,
1508 )
1509 );
1510
1511 do_action( 'pa_button_hover_controls', $elem, $conditions );
1512
1513 $elem->add_control(
1514 'premium_button_style1_dir',
1515 array(
1516 'label' => __( 'Slide Direction', 'premium-addons-for-elementor' ),
1517 'type' => Controls_Manager::SELECT,
1518 'default' => 'bottom',
1519 'options' => array(
1520 'bottom' => __( 'Top to Bottom', 'premium-addons-for-elementor' ),
1521 'top' => __( 'Bottom to Top', 'premium-addons-for-elementor' ),
1522 'left' => __( 'Right to Left', 'premium-addons-for-elementor' ),
1523 'right' => __( 'Left to Right', 'premium-addons-for-elementor' ),
1524 ),
1525 'condition' => array_merge(
1526 $conditions,
1527 array(
1528 'premium_button_hover_effect' => 'style1',
1529 )
1530 ),
1531 'label_block' => true,
1532 )
1533 );
1534
1535 $elem->add_control(
1536 'premium_button_style2_dir',
1537 array(
1538 'label' => __( 'Shutter Direction', 'premium-addons-for-elementor' ),
1539 'type' => Controls_Manager::SELECT,
1540 'default' => 'shutouthor',
1541 'options' => array(
1542 'shutinhor' => __( 'Shutter in Horizontal', 'premium-addons-for-elementor' ),
1543 'shutinver' => __( 'Shutter in Vertical', 'premium-addons-for-elementor' ),
1544 'shutoutver' => __( 'Shutter out Horizontal', 'premium-addons-for-elementor' ),
1545 'shutouthor' => __( 'Shutter out Vertical', 'premium-addons-for-elementor' ),
1546 'scshutoutver' => __( 'Scaled Shutter Vertical', 'premium-addons-for-elementor' ),
1547 'scshutouthor' => __( 'Scaled Shutter Horizontal', 'premium-addons-for-elementor' ),
1548 'dshutinver' => __( 'Tilted Left', 'premium-addons-for-elementor' ),
1549 'dshutinhor' => __( 'Tilted Right', 'premium-addons-for-elementor' ),
1550 ),
1551 'condition' => array_merge(
1552 $conditions,
1553 array(
1554 'premium_button_hover_effect' => 'style2',
1555 )
1556 ),
1557 'label_block' => true,
1558 )
1559 );
1560 }
1561
1562 /**
1563 * Add Templates Controls
1564 *
1565 * @since 4.11.25
1566 * @access public
1567 *
1568 * @param string $keyword keyword for templates.
1569 * @param string $demo demo url.
1570 */
1571 public static function add_templates_controls( $element, $keyword, $demo ) {
1572
1573 if ( ! Admin_Helper::check_element_by_key( 'premium-templates' ) ) {
1574 return;
1575 }
1576
1577 $element->add_control(
1578 'premium_templates_links',
1579 array(
1580 'type' => Controls_Manager::RAW_HTML,
1581 'raw' => '<div class="premium-promote-box widget-box">
1582 <div class="premium-promote-ctas">
1583 <a class="premium-promote-demo elementor-button elementor-button-default" href="' . esc_url( $demo ) . '" target="_blank"> ' .
1584 __( 'Widget Demo', 'premium-addons-for-elementor' ) .
1585 '</a>
1586 <a class="premium-promote-upgrade premium-widget-blocks elementor-button elementor-button-default" href="#" data-keyword="' . esc_attr( $keyword ) . '">' .
1587 __( 'Premade Templates', 'premium-addons-for-elementor' ) .
1588 '</a>
1589 </div>
1590 </div>',
1591 )
1592 );
1593 }
1594
1595 /**
1596 * Add Templates Controls
1597 *
1598 * @since 4.11.29
1599 * @access public
1600 *
1601 * @param string $keyword keyword for templates.
1602 * @param string $demo demo url.
1603 */
1604 public static function register_papro_promotion_controls( $element, $keyword ) {
1605
1606 if ( ! self::check_papro_version() ) {
1607
1608 $pro_link = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro/', $keyword, 'wp-editor', 'get-pro' );
1609
1610 $element->start_controls_section(
1611 'section_pro_features_field',
1612 array(
1613 'label' => __( 'Go Pro for More Features', 'premium-addons-for-elementor' ),
1614 )
1615 );
1616
1617 $element->add_control(
1618 'pa_pro_promotion_notice',
1619 array(
1620 'type' => Controls_Manager::NOTICE,
1621 'notice_type' => 'info',
1622 'dismissible' => false,
1623 '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' ),
1624 )
1625 );
1626
1627 $element->end_controls_section();
1628 }
1629 }
1630
1631 /**
1632 * Get Button Class
1633 *
1634 * @since 4.10.17
1635 * @access public
1636 *
1637 * @param $settings object widget settings.
1638 *
1639 * @return string $class css class.
1640 */
1641 public static function get_button_class( $settings ) {
1642
1643 $class = '';
1644
1645 $papro_activated = apply_filters( 'papro_activated', false );
1646
1647 if ( ! $papro_activated && ! in_array( $settings['premium_button_hover_effect'], array( 'none', 'style1', 'style2' ) ) ) {
1648 return '';
1649 }
1650
1651 if ( 'style1' === $settings['premium_button_hover_effect'] ) {
1652 $class = 'premium-button-style1-' . $settings['premium_button_style1_dir'];
1653 } elseif ( 'style2' === $settings['premium_button_hover_effect'] ) {
1654 $class = 'premium-button-style2-' . $settings['premium_button_style2_dir'];
1655 } elseif ( 'style5' === $settings['premium_button_hover_effect'] ) {
1656 $class = 'premium-button-style5-' . $settings['premium_button_style5_dir'];
1657 } elseif ( 'style6' === $settings['premium_button_hover_effect'] ) {
1658 $class = 'premium-button-style6';
1659 } elseif ( 'style7' === $settings['premium_button_hover_effect'] ) {
1660 $class = 'premium-button-style7-' . $settings['premium_button_style7_dir'];
1661 } elseif ( 'style8' === $settings['premium_button_hover_effect'] ) {
1662 $class = 'premium-button-' . $settings['underline_style'];
1663 }
1664
1665 return 'premium-button-' . $settings['premium_button_hover_effect'] . ' ' . $class;
1666 }
1667
1668
1669 /**
1670 * Get Empty Query Message
1671 *
1672 * Written in PHP and used to generate the final HTML when the query is empty
1673 *
1674 * @since 4.10.29
1675 * @access protected
1676 *
1677 * @param string $notice empty query notice.
1678 */
1679 public static function render_empty_query_message( $notice ) {
1680
1681 if ( empty( $notice ) ) {
1682 $notice = __( 'The current query has no posts. Please make sure you have published items matching your query.', 'premium-addons-for-elementor' );
1683 }
1684
1685 ?>
1686 <div class="premium-error-notice">
1687 <?php echo wp_kses_post( $notice ); ?>
1688 </div>
1689 <?php
1690 }
1691
1692 /**
1693 * Check Capability
1694 *
1695 * @since 4.10.28
1696 * @access public
1697 *
1698 * @param string $check capability.
1699 */
1700 public static function check_capability( $capability ) {
1701
1702 $post_author_id = get_the_author_meta( 'ID' );
1703
1704 $current_user_can = user_can( $post_author_id, $capability );
1705
1706 return $current_user_can;
1707 }
1708
1709
1710 /**
1711 * Get Allowed Icon Tags
1712 *
1713 * Returns an array of allowed HTML tags.
1714 *
1715 * @since 4.10.69
1716 * @access public
1717 *
1718 * @return array Array of allowed HTML tags.
1719 */
1720 public static function get_allowed_icon_tags() {
1721 return array(
1722 'svg' => array(
1723 'id' => array(),
1724 'class' => array(),
1725 'aria-hidden' => array(),
1726 'aria-labelledby' => array(),
1727 'role' => array(),
1728 'xmlns' => array(),
1729 'width' => array(),
1730 'height' => array(),
1731 'viewbox' => array(),
1732 'data-*' => true,
1733 ),
1734 'g' => array( 'fill' => array() ),
1735 'title' => array( 'title' => array() ),
1736 'path' => array(
1737 'd' => array(),
1738 'fill' => array(),
1739 ),
1740 'i' => array(
1741 'class' => array(),
1742 'id' => array(),
1743 'style' => array(),
1744 ),
1745 );
1746 }
1747
1748 /**
1749 * Get SVG By Icon
1750 *
1751 * @since 4.10.69
1752 * @access public
1753 */
1754 public static function get_svg_by_icon( $icon, $attributes = array() ) {
1755
1756 if ( empty( $icon ) || empty( $icon['value'] ) || empty( $icon['library'] ) ) {
1757 return '';
1758 }
1759
1760 // If icon library is SVG, then go to Elementor. Used for widgets where this function is called in all cases.
1761 if ( false === strpos( $icon['library'], 'fa-' ) ) {
1762 $svg_html = Icons_Manager::try_get_icon_html( $icon, wp_parse_args( $attributes, array( 'aria-hidden' => 'true' ) ) );
1763
1764 return $svg_html;
1765 }
1766
1767 $icon['font_family'] = 'font-awesome';
1768
1769 $i_class = str_replace( ' ', '-', $icon['value'] );
1770
1771 $svg_html = '<svg ';
1772
1773 $icon = self::get_icon_svg_data( $icon );
1774
1775 if ( ! $icon ) {
1776 // Icons_Manager::render_icon( $icon, array( 'aria-hidden' => 'true' ) );
1777 Icons_Manager::render_icon( $icon, wp_parse_args( $attributes, array( 'aria-hidden' => 'true' ) ) );
1778 return;
1779 }
1780
1781 $view_box = '0 0 ' . $icon['width'] . ' ' . $icon['height'];
1782
1783 if ( is_array( $attributes ) ) {
1784
1785 foreach ( $attributes as $key => $value ) {
1786
1787 if ( 'class' === $key ) {
1788
1789 $svg_html .= 'class="svg-inline--' . $i_class . ' ' . $value . '" ';
1790
1791 } else {
1792 $svg_html .= " {$key}='{$value}' ";
1793 }
1794 }
1795 } else {
1796
1797 $attributes = str_replace( 'class="', 'class="svg-inline--' . $i_class . ' ', $attributes );
1798
1799 $svg_html .= $attributes;
1800 }
1801
1802 $svg_html .= " aria-hidden='true' xmlns='http://www.w3.org/2000/svg' viewBox='{$view_box}'>";
1803
1804 $svg_html .= '<path d="' . esc_attr( $icon['path'] ) . '"></path>';
1805 $svg_html .= '</svg>';
1806
1807 return wp_kses( $svg_html, self::get_allowed_icon_tags() );
1808 }
1809
1810 /**
1811 * Get Elementor Template ID
1812 *
1813 * @since 4.10.80
1814 * @access public
1815 *
1816 * @param string $title template title.
1817 *
1818 * @return string $template_id template ID.
1819 */
1820 public static function get_elementor_template_id( $title ) {
1821
1822 if ( empty( $title ) ) {
1823 return;
1824 }
1825
1826 $args = array(
1827 'post_type' => 'elementor_library',
1828 'post_status' => 'publish',
1829 'posts_per_page' => 1,
1830 'title' => $title,
1831 'suppress_filters' => true,
1832 );
1833
1834 $query = new \WP_Query( $args );
1835
1836 $post_id = '';
1837
1838 if ( $query->have_posts() ) {
1839 $post_id = $query->post->ID;
1840
1841 wp_reset_postdata();
1842 }
1843
1844 return $post_id;
1845 }
1846
1847 /**
1848 * Render Elementor Template
1849 *
1850 * @since 4.10.80
1851 * @access public
1852 *
1853 * @param string|int $title Template Title||id.
1854 * @param bool $id indicates if $title is the template title or id.
1855 *
1856 * @return $template_content string HTML Markup of the selected template.
1857 */
1858 public static function render_elementor_template( $title, $id = false ) {
1859
1860 $frontend = Plugin::$instance->frontend;
1861
1862 $custom_temp = apply_filters( 'pa_temp_id', false );
1863
1864 if ( $custom_temp ) {
1865 $id = $title = $custom_temp;
1866 }
1867
1868 if ( ! $id ) {
1869 $id = self::get_elementor_template_id( $title );
1870
1871 if ( ! $id ) {
1872 // To replace the &#8211; in templates names with dash.
1873 $decoded_title = html_entity_decode( $title );
1874 $id = self::get_elementor_template_id( $decoded_title );
1875 }
1876
1877 $id = apply_filters( 'wpml_object_id', $id, 'elementor_library', true );
1878 } else {
1879 $id = $title;
1880 }
1881
1882 // $template_content = $frontend->get_builder_content( $id, true );
1883 $template_content = $frontend->get_builder_content_for_display( $id, true );
1884
1885 return $template_content;
1886 }
1887 }
1888