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