PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.10.30
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.10.30
4.11.79 4.11.78 4.11.77 4.11.76 4.11.75 3.20.5 4.11.69 3.20.6 4.11.7 3.20.7 4.11.70 3.20.8 4.11.71 3.20.9 4.11.72 3.21.1 4.11.73 3.21.2 4.11.74 3.21.3 4.11.8 3.21.4 4.11.9 3.21.5 4.2.0 3.21.6 4.2.1 3.3.0 4.2.2 3.3.1 4.2.3 3.3.2 4.2.4 3.3.3 4.2.5 3.3.4 4.2.6 3.3.5 4.2.7 3.3.6 4.2.8 3.3.7 4.2.9 3.3.8 4.3.0 3.3.9 4.3.1 3.4.0 4.3.2 3.4.1 4.3.3 3.4.2 4.3.4 3.4.3 4.3.5 3.4.4 4.3.6 3.4.5 4.3.7 3.4.6 4.3.8 3.4.7 4.3.9 3.4.8 4.4.0 3.4.9 4.4.1 3.5.0 4.4.2 3.5.1 4.4.3 3.5.2 4.4.4 3.5.3 4.4.5 3.5.4 4.4.6 3.5.5 4.4.7 3.5.6 4.4.8 3.5.7 4.4.9 3.5.8 4.5.0 3.5.9 4.5.1 3.6.0 4.5.2 3.6.1 4.5.3 3.6.2 4.5.4 3.6.3 4.5.5 3.6.4 4.5.6 3.6.5 4.5.7 3.6.6 4.5.8 3.6.7 4.5.9 3.6.8 4.6.0 3.6.9 4.6.1 3.7.0 4.7.0 3.7.1 4.7.1 3.7.2 4.7.2 3.7.3 4.7.3 3.7.4 4.7.4 3.7.5 4.7.5 3.7.6 4.7.6 3.7.7 4.7.7 3.7.8 4.7.8 3.7.9 4.7.9 3.8.0 4.8.0 3.8.1 4.8.1 3.8.2 4.8.10 3.8.3 4.8.11 3.8.4 4.8.2 3.8.5 4.8.3 3.8.6 4.8.4 3.8.7 4.8.5 3.8.8 4.8.6 3.8.9 4.8.7 3.9.0 4.8.8 3.9.1 4.8.9 3.9.2 4.9.0 3.9.3 4.9.0-beta1 3.9.4 4.9.0-beta2 3.9.5 4.9.1 3.9.6 4.9.10 3.9.7 4.9.11 3.9.8 4.9.12 3.9.9 4.9.13 4.0.1 4.9.14 4.0.3 4.9.15 4.0.4 4.9.16 4.0.5 4.9.17 4.0.6 4.9.18 4.0.7 4.9.19 4.0.8 4.9.2 4.0.9 4.9.20 4.1.0 4.9.21 4.1.1 4.9.22 4.1.2 4.9.23 4.1.3 4.9.24 trunk 4.1.4 4.9.25 1.0 4.1.5 4.9.26 1.01 4.1.6 4.9.27 1.02 4.1.7 4.9.28 1.03 4.1.8 4.9.29 1.04 4.1.9 4.9.3 1.05 4.10.0 4.9.30 1.06 4.10.1 4.9.31 1.07 4.10.10 4.9.32 1.08 4.10.11 4.9.33 1.09 4.10.12 4.9.34 2.0 4.10.13 4.9.35 2.0.1 4.10.14 4.9.36 2.0.2 4.10.15 4.9.37 2.0.3 4.10.16 4.9.38 2.0.4 4.10.17 4.9.39 2.0.5 4.10.18 4.9.4 2.0.6 4.10.19 4.9.40 2.0.7 4.10.2 4.9.41 2.0.8 4.10.20 4.9.42 2.0.9 4.10.21 4.9.43 2.1.0 4.10.22 4.9.45 2.1.1 4.10.23 4.9.46 2.1.2 4.10.24 4.9.47 2.1.3 4.10.25 4.9.48 2.1.4 4.10.26 4.9.49 2.1.5 4.10.27 4.9.5 2.1.5-beta1 4.10.28 4.9.50 2.1.6 4.10.29 4.9.51 2.1.7 4.10.3 4.9.52 2.1.8 4.10.30 4.9.53 2.1.9 4.10.31 4.9.54 2.2.0 4.10.32 4.9.55 2.2.1 4.10.33 4.9.56 2.2.2 4.10.34 4.9.57 2.2.3 4.10.35 4.9.6 2.2.4 4.10.36 4.9.7 2.2.5 4.10.37 4.9.8 2.2.6 4.10.38 4.9.9 2.2.7 4.10.39 2.2.8 4.10.4 2.2.9 4.10.40 2.3.0 4.10.41 2.3.1 4.10.42 2.3.2 4.10.43 2.3.3 4.10.44 2.3.4 4.10.45 2.3.5 4.10.46 2.3.6 4.10.47 2.3.7 4.10.48 2.3.8 4.10.49 2.3.9 4.10.5 2.4.0 4.10.50 2.4.1 4.10.51 2.5.0 4.10.52 2.5.1 4.10.53 2.5.2 4.10.54 2.5.3 4.10.55 2.5.4 4.10.56 2.5.5 4.10.57 2.5.6 4.10.58 2.5.7 4.10.59 2.5.8 4.10.6 2.5.9 4.10.60 2.6.0 4.10.61 2.6.1 4.10.62 2.6.2 4.10.63 2.6.3 4.10.64 2.6.4 4.10.65 2.6.5 4.10.66 2.6.6 4.10.67 2.6.7 4.10.68 2.6.8 4.10.69 2.6.9 4.10.7 2.7.0 4.10.70 2.7.1 4.10.71 2.7.2 4.10.72 2.7.3 4.10.73 2.7.4 4.10.74 2.7.5 4.10.75 2.7.6 4.10.76 2.7.7 4.10.77 2.7.8 4.10.78 2.7.9 4.10.79 2.8.0 4.10.8 2.8.1 4.10.80 2.8.2 4.10.81 2.8.3 4.10.82 2.8.4 4.10.83 2.8.5 4.10.84 2.8.6 4.10.85 2.8.7 4.10.86 2.8.8 4.10.87 2.8.9 4.10.88 2.9.0 4.10.89 2.9.1 4.10.9 2.9.2 4.10.90 2.9.3 4.11.0 2.9.4 4.11.1 2.9.5 4.11.10 2.9.6 4.11.11 2.9.7 4.11.12 2.9.8 4.11.13 2.9.9 4.11.14 3.0.0 4.11.15 3.0.1 4.11.16 3.0.2 4.11.17 3.0.3 4.11.18 3.0.4 4.11.19 3.0.5 4.11.2 3.0.6 4.11.20 3.0.7 4.11.21 3.0.8 4.11.22 3.0.9 4.11.23 3.1.0 4.11.24 3.1.1 4.11.25 3.1.2 4.11.26 3.1.3 4.11.27 3.1.4 4.11.28 3.1.5 4.11.29 3.1.6 4.11.3 3.1.7 4.11.30 3.1.8 4.11.31 3.1.9 4.11.32 3.10.0 4.11.33 3.10.1 4.11.34 3.10.2 4.11.35 3.10.3 4.11.36 3.10.4 4.11.37 3.10.5 4.11.38 3.10.6 4.11.39 3.10.7 4.11.4 3.10.8 4.11.40 3.10.9 4.11.41 3.11.0 4.11.42 3.11.1 4.11.43 3.11.2 4.11.44 3.11.3 4.11.45 3.11.4 4.11.46 3.11.5 4.11.47 3.11.6 4.11.48 3.11.7 4.11.49 3.11.8 4.11.5 3.11.9 4.11.50 3.12.0 4.11.51 3.12.1 4.11.52 3.12.2 4.11.53 3.12.3 4.11.54 3.2.0 4.11.55 3.2.1 4.11.56 3.2.2 4.11.57 3.2.3 4.11.58 3.2.4 4.11.59 3.2.5 4.11.6 3.2.6 4.11.60 3.2.7 4.11.61 3.2.8 4.11.62 3.2.9 4.11.63 3.20.0 4.11.64 3.20.1 4.11.65 3.20.2 4.11.66 3.20.3 4.11.67 3.20.4 4.11.68
premium-addons-for-elementor / includes / helper-functions.php
premium-addons-for-elementor / includes Last commit date
compatibility 2 years ago controls 2 years ago pa-display-conditions 2 years ago templates 2 years ago acf-helper.php 2 years ago addons-cross-cp.php 2 years ago addons-integration.php 2 years ago assets-manager.php 2 years ago class-pa-core.php 2 years ago class-premium-template-tags.php 2 years ago helper-functions.php 2 years ago live-editor-modal.php 2 years ago module-base.php 2 years ago pa-nav-menu-walker.php 2 years ago
helper-functions.php
1537 lines
1 <?php
2 /**
3 * PA Helper Functions.
4 */
5
6 namespace PremiumAddons\Includes;
7
8 // Premium Addons Pro Classes.
9 use PremiumAddonsPro\Includes\White_Label\Helper;
10
11 // Elementor Classes.
12 use Elementor\Core\Settings\Manager as SettingsManager;
13 use Elementor\Plugin;
14 use Elementor\Controls_Manager;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Class Helper_Functions.
22 */
23 class Helper_Functions {
24
25 /**
26 * A list of safe tage for `validate_html_tag` method.
27 */
28 const ALLOWED_HTML_WRAPPER_TAGS = array(
29 'article',
30 'aside',
31 'div',
32 'footer',
33 'h1',
34 'h2',
35 'h3',
36 'h4',
37 'h5',
38 'h6',
39 'header',
40 'main',
41 'nav',
42 'p',
43 'section',
44 'span',
45 );
46
47 /**
48 * Google maps prefixes
49 *
50 * @var google_localize
51 */
52 private static $google_localize = null;
53
54 /**
55 * SVG Shapes
56 *
57 * @var shapes
58 */
59 private static $shapes = null;
60
61 /**
62 * WP lang prefixes
63 *
64 * @var lang_locales
65 */
66 private static $lang_locales = null;
67
68 /**
69 * Script debug enabled
70 *
71 * @var script_debug
72 */
73 private static $script_debug = null;
74
75 /**
76 * JS scripts directory
77 *
78 * @var js_dir
79 */
80 private static $js_dir = null;
81
82 /**
83 * CSS fiels directory
84 *
85 * @var js_dir
86 */
87 private static $css_dir = null;
88
89 /**
90 * JS Suffix
91 *
92 * @var js_suffix
93 */
94 private static $assets_suffix = null;
95
96 /**
97 * Check if white labeling - Free version author field is set
98 *
99 * @since 1.0.0
100 * @access public
101 *
102 * @return string
103 */
104 public static function author() {
105
106 $author_free = 'Leap13';
107
108 if ( self::check_papro_version() ) {
109
110 $white_label = Helper::get_white_labeling_settings();
111
112 $author_free = $white_label['premium-wht-lbl-name'];
113
114 }
115
116 return '' !== $author_free ? $author_free : 'Leap13';
117 }
118
119 /**
120 * Check if white labeling - Free version name field is set
121 *
122 * @since 1.0.0
123 * @access public
124 *
125 * @return string
126 */
127 public static function name() {
128
129 $name_free = 'Premium Addons for Elementor';
130
131 if ( self::check_papro_version() ) {
132
133 $white_label = Helper::get_white_labeling_settings();
134
135 $name_free = $white_label['premium-wht-lbl-plugin-name'];
136
137 }
138
139 return '' !== $name_free ? $name_free : 'Premium Addons for Elementor';
140 }
141
142 /**
143 * Check if white labeling - Hide row meta option is checked
144 *
145 * @since 1.0.0
146 * @return boolean
147 */
148 public static function is_hide_row_meta() {
149
150 if ( self::check_papro_version() ) {
151
152 $white_label = Helper::get_white_labeling_settings();
153
154 $hide_meta = $white_label['premium-wht-lbl-row'];
155
156 }
157
158 return isset( $hide_meta ) ? $hide_meta : false;
159 }
160
161 /**
162 * Check if white labeling - Hide plugin logo option is checked
163 *
164 * @since 1.0.0
165 * @access public
166 *
167 * @return boolean
168 */
169 public static function is_hide_logo() {
170
171 if ( self::check_papro_version() ) {
172
173 if ( isset( get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'] ) ) {
174
175 $hide_logo = get_option( 'pa_wht_lbl_save_settings' )['premium-wht-lbl-logo'];
176
177 }
178 }
179
180 return isset( $hide_logo ) ? $hide_logo : false;
181 }
182
183 /**
184 * Get White Labeling - Widgets Category string
185 *
186 * @since 1.0.0
187 * @access public
188 *
189 * @return string
190 */
191 public static function get_category() {
192
193 $category = __( 'Premium Addons', 'premium-addons-for-elementor' );
194
195 if ( self::check_papro_version() ) {
196
197 $white_label = Helper::get_white_labeling_settings();
198
199 $category = $white_label['premium-wht-lbl-short-name'];
200
201 }
202
203 return '' !== $category ? $category : __( 'Premium Addons', 'premium-addons-for-elementor' );
204 }
205
206 /**
207 * Get White Labeling - Widgets Prefix string
208 *
209 * @since 1.0.0
210 * @access public
211 *
212 * @return string
213 */
214 public static function get_prefix() {
215
216 $prefix = __( 'Premium', 'premium-addons-for-elementor' );
217
218 if ( self::check_papro_version() ) {
219
220 $white_label = Helper::get_white_labeling_settings();
221
222 $prefix = $white_label['premium-wht-lbl-prefix'];
223
224 }
225
226 return '' !== $prefix ? $prefix : __( 'Premium', 'premium-addons-for-elementor' );
227 }
228
229 /**
230 * Check if white labeling - Future notification checked
231 *
232 * @since 1.0.0
233 * @return boolean
234 */
235 public static function check_hide_notifications() {
236
237 if ( self::check_papro_version() ) {
238
239 $white_label = Helper::get_white_labeling_settings();
240
241 $hide_notification = isset( $white_label['premium-wht-lbl-not'] ) ? $white_label['premium-wht-lbl-not'] : false;
242
243 }
244
245 return isset( $hide_notification ) ? $hide_notification : false;
246 }
247
248 /**
249 * Get White Labeling - Widgets Badge string
250 *
251 * @since 1.0.0
252 * @access public
253 *
254 * @return string
255 */
256 public static function get_badge() {
257
258 $badge = 'PA';
259
260 if ( self::check_papro_version() ) {
261
262 $white_label = Helper::get_white_labeling_settings();
263
264 $badge = $white_label['premium-wht-lbl-badge'];
265
266 }
267
268 return '' !== $badge ? $badge : 'PA';
269 }
270
271 /**
272 * Get Google Maps localization prefixes
273 *
274 * @since 1.0.0
275 * @access public
276 *
277 * @return array
278 */
279 public static function get_google_maps_prefixes() {
280
281 if ( null === self::$google_localize ) {
282
283 self::$google_localize = array(
284 'ar' => __( 'Arabic', 'premium-addons-for-elementor' ),
285 'eu' => __( 'Basque', 'premium-addons-for-elementor' ),
286 'bg' => __( 'Bulgarian', 'premium-addons-for-elementor' ),
287 'bn' => __( 'Bengali', 'premium-addons-for-elementor' ),
288 'ca' => __( 'Catalan', 'premium-addons-for-elementor' ),
289 'cs' => __( 'Czech', 'premium-addons-for-elementor' ),
290 'da' => __( 'Danish', 'premium-addons-for-elementor' ),
291 'de' => __( 'German', 'premium-addons-for-elementor' ),
292 'el' => __( 'Greek', 'premium-addons-for-elementor' ),
293 'en' => __( 'English', 'premium-addons-for-elementor' ),
294 'en-AU' => __( 'English (australian)', 'premium-addons-for-elementor' ),
295 'en-GB' => __( 'English (great britain)', 'premium-addons-for-elementor' ),
296 'es' => __( 'Spanish', 'premium-addons-for-elementor' ),
297 'fa' => __( 'Farsi', 'premium-addons-for-elementor' ),
298 'fi' => __( 'Finnish', 'premium-addons-for-elementor' ),
299 'fil' => __( 'Filipino', 'premium-addons-for-elementor' ),
300 'fr' => __( 'French', 'premium-addons-for-elementor' ),
301 'gl' => __( 'Galician', 'premium-addons-for-elementor' ),
302 'gu' => __( 'Gujarati', 'premium-addons-for-elementor' ),
303 'hi' => __( 'Hindi', 'premium-addons-for-elementor' ),
304 'hr' => __( 'Croatian', 'premium-addons-for-elementor' ),
305 'hu' => __( 'Hungarian', 'premium-addons-for-elementor' ),
306 'id' => __( 'Indonesian', 'premium-addons-for-elementor' ),
307 'it' => __( 'Italian', 'premium-addons-for-elementor' ),
308 'iw' => __( 'Hebrew', 'premium-addons-for-elementor' ),
309 'ja' => __( 'Japanese', 'premium-addons-for-elementor' ),
310 'kn' => __( 'Kannada', 'premium-addons-for-elementor' ),
311 'ko' => __( 'Korean', 'premium-addons-for-elementor' ),
312 'lt' => __( 'Lithuanian', 'premium-addons-for-elementor' ),
313 'lv' => __( 'Latvian', 'premium-addons-for-elementor' ),
314 'ml' => __( 'Malayalam', 'premium-addons-for-elementor' ),
315 'mr' => __( 'Marathi', 'premium-addons-for-elementor' ),
316 'nl' => __( 'Dutch', 'premium-addons-for-elementor' ),
317 'no' => __( 'Norwegian', 'premium-addons-for-elementor' ),
318 'pl' => __( 'Polish', 'premium-addons-for-elementor' ),
319 'pt' => __( 'Portuguese', 'premium-addons-for-elementor' ),
320 'pt-BR' => __( 'Portuguese (brazil)', 'premium-addons-for-elementor' ),
321 'pt-PT' => __( 'Portuguese (portugal)', 'premium-addons-for-elementor' ),
322 'ro' => __( 'Romanian', 'premium-addons-for-elementor' ),
323 'ru' => __( 'Russian', 'premium-addons-for-elementor' ),
324 'sk' => __( 'Slovak', 'premium-addons-for-elementor' ),
325 'sl' => __( 'Slovenian', 'premium-addons-for-elementor' ),
326 'sr' => __( 'Serbian', 'premium-addons-for-elementor' ),
327 'sv' => __( 'Swedish', 'premium-addons-for-elementor' ),
328 'tl' => __( 'Tagalog', 'premium-addons-for-elementor' ),
329 'ta' => __( 'Tamil', 'premium-addons-for-elementor' ),
330 'te' => __( 'Telugu', 'premium-addons-for-elementor' ),
331 'th' => __( 'Thai', 'premium-addons-for-elementor' ),
332 'tr' => __( 'Turkish', 'premium-addons-for-elementor' ),
333 'uk' => __( 'Ukrainian', 'premium-addons-for-elementor' ),
334 'vi' => __( 'Vietnamese', 'premium-addons-for-elementor' ),
335 'zh-CN' => __( 'Chinese (simplified)', 'premium-addons-for-elementor' ),
336 'zh-TW' => __( 'Chinese (traditional)', 'premium-addons-for-elementor' ),
337 );
338 }
339
340 return self::$google_localize;
341 }
342
343 /**
344 * Checks if a plugin is installed
345 *
346 * @since 1.0.0
347 * @access public
348 *
349 * @param string $plugin_path plugin path.
350 *
351 * @return boolean
352 */
353 public static function is_plugin_installed( $plugin_path ) {
354
355 require_once ABSPATH . 'wp-admin/includes/plugin.php';
356
357 $plugins = get_plugins();
358
359 return isset( $plugins[ $plugin_path ] );
360 }
361
362 /**
363 * Check Plugin Active
364 *
365 * @since 4.2.5
366 * @access public
367 *
368 * @param string $slug plugin slug.
369 *
370 * @return boolean $is_active plugin active.
371 */
372 public static function check_plugin_active( $slug = '' ) {
373
374 include_once ABSPATH . 'wp-admin/includes/plugin.php';
375
376 $is_active = in_array( $slug, (array) get_option( 'active_plugins', array() ), true );
377
378 return $is_active;
379 }
380
381 /**
382 * Check if script debug mode enabled.
383 *
384 * @since 3.11.1
385 * @access public
386 *
387 * @return boolean is debug mode enabled
388 */
389 public static function is_debug_enabled() {
390
391 if ( null === self::$script_debug ) {
392
393 self::$script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
394 }
395
396 return self::$script_debug;
397 }
398
399 /**
400 * Get scripts dir.
401 *
402 * @access public
403 *
404 * @return string JS scripts directory.
405 */
406 public static function get_scripts_dir() {
407
408 if ( null === self::$js_dir ) {
409
410 self::$js_dir = self::is_debug_enabled() ? 'js' : 'min-js';
411 }
412
413 return self::$js_dir;
414 }
415
416 /**
417 * Get styles dir.
418 *
419 * @access public
420 *
421 * @return string CSS files directory.
422 */
423 public static function get_styles_dir() {
424
425 if ( null === self::$css_dir ) {
426
427 self::$css_dir = self::is_debug_enabled() ? 'css' : 'min-css';
428 }
429
430 return self::$css_dir;
431 }
432
433 /**
434 * Get assets suffix.
435 *
436 * @access public
437 *
438 * @return string JS scripts suffix.
439 */
440 public static function get_assets_suffix() {
441
442 if ( null === self::$assets_suffix ) {
443
444 self::$assets_suffix = self::is_debug_enabled() ? '' : '.min';
445 }
446
447 return self::$assets_suffix;
448 }
449
450 /**
451 * Get Installed Theme
452 *
453 * Returns the active theme slug
454 *
455 * @access public
456 *
457 * @return string theme slug
458 */
459 public static function get_installed_theme() {
460
461 $theme = wp_get_theme();
462
463 if ( $theme->parent() ) {
464
465 $theme_name = sanitize_key( $theme->parent()->get( 'Name' ) );
466
467 return $theme_name;
468
469 }
470
471 $theme_name = $theme->get( 'Name' );
472
473 $theme_name = sanitize_key( $theme_name );
474
475 return $theme_name;
476 }
477
478 /**
479 * Get Vimeo Video Data
480 *
481 * Get video data using Vimeo API
482 *
483 * @since 3.11.4
484 * @access public
485 *
486 * @param string $video_id video ID.
487 */
488 public static function get_vimeo_video_data( $video_id ) {
489
490 $vimeo_data = wp_remote_get( 'http://www.vimeo.com/api/v2/video/' . intval( $video_id ) . '.php' );
491
492 if ( is_wp_error( $vimeo_data ) ) {
493 return false;
494 }
495
496 if ( isset( $vimeo_data['response']['code'] ) ) {
497
498 if ( 200 === $vimeo_data['response']['code'] ) {
499
500 $response = maybe_unserialize( $vimeo_data['body'] );
501 $thumbnail = isset( $response[0]['thumbnail_large'] ) ? $response[0]['thumbnail_large'] : false;
502
503 $data = array(
504 'src' => $thumbnail,
505 'url' => $response[0]['user_url'],
506 'portrait' => $response[0]['user_portrait_huge'],
507 'title' => $response[0]['title'],
508 'user' => $response[0]['user_name'],
509 );
510
511 return $data;
512
513 }
514 }
515
516 return false;
517 }
518
519 /**
520 * Get Video Thumbnail
521 *
522 * Get thumbnail URL for embed or self hosted
523 *
524 * @since 3.7.0
525 * @access public
526 *
527 * @param string $video_id video ID.
528 * @param string $type embed type.
529 * @param string $size youtube thumbnail size.
530 */
531 public static function get_video_thumbnail( $video_id, $type, $size = '' ) {
532
533 $thumbnail_src = 'transparent';
534
535 if ( 'youtube' === $type ) {
536 if ( '' === $size ) {
537 $size = 'maxresdefault';
538 }
539 $thumbnail_src = sprintf( 'https://i.ytimg.com/vi/%s/%s.jpg', $video_id, $size );
540
541 } elseif ( 'vimeo' === $type ) {
542
543 $vimeo = self::get_vimeo_video_data( $video_id );
544
545 $thumbnail_src = is_array( $vimeo ) ? $vimeo['src'] : '';
546
547 } elseif ( 'dailymotion' === $type ) {
548 $video_data = rplg_urlopen( 'https://api.dailymotion.com/video/' . $video_id . '?fields=thumbnail_url' );
549
550 if ( isset( $video_data['code'] ) ) {
551 if ( 404 === $video_data['code'] ) {
552 return $thumbnail_src;
553 }
554 }
555
556 $thumbnail_src = rplg_json_decode( $video_data['data'] )->thumbnail_url;
557 }
558
559 return $thumbnail_src;
560 }
561
562 /**
563 * Transient Expire
564 *
565 * Gets expire time of transient.
566 *
567 * @since 3.20.8
568 * @access public
569 *
570 * @param string $period transient expiration period.
571 *
572 * @return string $expire_time expire time in seconds.
573 */
574 public static function transient_expire( $period ) {
575
576 $expire_time = 24 * HOUR_IN_SECONDS;
577
578 switch ( $period ) {
579 case 'minute':
580 $expire_time = MINUTE_IN_SECONDS;
581 break;
582 case 'minutes':
583 $expire_time = 5 * MINUTE_IN_SECONDS;
584 break;
585 case 'hour':
586 $expire_time = 60 * MINUTE_IN_SECONDS;
587 break;
588 case 'week':
589 $expire_time = 7 * DAY_IN_SECONDS;
590 break;
591 case 'month':
592 $expire_time = 30 * DAY_IN_SECONDS;
593 break;
594 case 'year':
595 $expire_time = 365 * DAY_IN_SECONDS;
596 break;
597 default:
598 $expire_time = 24 * HOUR_IN_SECONDS;
599 }
600
601 return $expire_time;
602 }
603
604 /**
605 * Get Campaign Link
606 *
607 * @since 3.20.9
608 * @access public
609 *
610 * @param string $link page link.
611 * @param string $source source.
612 * @param string $medium media.
613 * @param string $campaign campaign name.
614 *
615 * @return string $link campaign URL
616 */
617 public static function get_campaign_link( $link, $source, $medium, $campaign = '' ) {
618
619 $theme = self::get_installed_theme();
620
621 $url = add_query_arg(
622 array(
623 'utm_source' => $source,
624 'utm_medium' => $medium,
625 'utm_campaign' => $campaign,
626 'utm_term' => $theme,
627 ),
628 $link
629 );
630
631 return $url;
632 }
633
634 /**
635 * Get Elementor UI Theme
636 *
637 * Detects user setting for UI theme
638 *
639 * @since 3.21.1
640 * @access public
641 *
642 * @return string $theme UI Theme
643 */
644 public static function get_elementor_ui_theme() {
645
646 $theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
647
648 return $theme;
649 }
650
651 /**
652 * Check PAPRO Version
653 *
654 * Check if PAPRO version is updated
655 *
656 * @since 3.21.6
657 * @access public
658 *
659 * @return boolen $is_updated
660 */
661 public static function check_papro_version() {
662
663 if ( ! defined( 'PREMIUM_PRO_ADDONS_VERSION' ) ) {
664 return false;
665 }
666
667 $is_updated = get_option( 'papro_updated', true );
668
669 return $is_updated;
670 }
671
672 /**
673 * Valide HTML Tag
674 *
675 * Validates an HTML tag against a safe allowed list.
676 *
677 * @param string $tag HTML tag.
678 *
679 * @return string
680 */
681 public static function validate_html_tag( $tag ) {
682 return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS, true ) ? $tag : 'div';
683 }
684
685 /**
686 * Get Image Data
687 *
688 * Returns image data based on image id.
689 *
690 * @since 0.0.1
691 * @access public
692 *
693 * @param int $image_id Image ID.
694 * @param string $image_url Image URL.
695 * @param array $image_size Image sizes array.
696 *
697 * @return array $data image data.
698 */
699 public static function get_image_data( $image_id, $image_url, $image_size ) {
700
701 if ( ! $image_id && ! $image_url ) {
702 return false;
703 }
704
705 $data = array();
706
707 $image_url = esc_url_raw( $image_url );
708
709 if ( ! empty( $image_id ) ) { // Existing attachment.
710
711 $attachment = get_post( $image_id );
712
713 if ( is_object( $attachment ) ) {
714 $data['id'] = $image_id;
715 $data['url'] = $image_url;
716
717 $data['image'] = wp_get_attachment_image( $attachment->ID, $image_size, true );
718 $data['image_size'] = $image_size;
719 $data['caption'] = $attachment->post_excerpt;
720 $data['title'] = $attachment->post_title;
721 $data['description'] = $attachment->post_content;
722
723 }
724 } else { // Placeholder image, most likely.
725
726 if ( empty( $image_url ) ) {
727 return;
728 }
729
730 $data['id'] = false;
731 $data['url'] = $image_url;
732 $data['image'] = '<img src="' . $image_url . '" alt="" title="" />';
733 $data['image_size'] = $image_size;
734 $data['caption'] = '';
735 $data['title'] = '';
736 $data['description'] = '';
737 }
738
739 return $data;
740 }
741
742 /**
743 * Get Final Result.
744 *
745 * @access public
746 * @since 4.4.8
747 *
748 * @param bool $condition_result result.
749 * @param string $operator operator.
750 *
751 * @return bool
752 */
753 public static function get_final_result( $condition_result, $operator ) {
754
755 if ( 'is' === $operator ) {
756 return true === $condition_result;
757 } else {
758 return true !== $condition_result;
759 }
760 }
761
762 /**
763 * Get Local Time ( WordPress TimeZone Setting ).
764 *
765 * @access public
766 * @since 4.4.8
767 *
768 * @param string $format format.
769 */
770 public static function get_local_time( $format ) {
771
772 $local_time_zone = isset( $_COOKIE['localTimeZone'] ) && ! empty( $_COOKIE['localTimeZone'] ) ?
773 str_replace( 'GMT ', 'GMT+', sanitize_text_field( wp_unslash( $_COOKIE['localTimeZone'] ) ) )
774 : self::get_location_time_zone();
775
776 $today = new \DateTime( 'now', new \DateTimeZone( $local_time_zone ) );
777
778 return $today->format( $format );
779 }
780
781 /**
782 * Gets the user's timezone based on his ip address.
783 *
784 * @access public
785 * @since 4.10.26
786 *
787 * @return string
788 */
789 public static function get_location_time_zone() {
790
791 $ip_address = self::get_user_ip_address();
792
793 return self::get_timezone_by_ip( $ip_address );
794 }
795
796 /**
797 * Get user's IP address.
798 *
799 * @access public
800 * @since 4.10.26
801 *
802 * @return string
803 */
804 public static function get_user_ip_address() {
805
806 if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
807
808 $x_forward = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
809
810 if ( is_array( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
811
812 $http_x_headers = explode( ',', filter_var_array( $x_forward ) );
813 $_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
814 } else {
815 $_SERVER['REMOTE_ADDR'] = $x_forward;
816 }
817 }
818
819 return isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
820 }
821
822 /**
823 * Get timezone by ip address.
824 *
825 * @access public
826 * @since 4.10.26
827 *
828 * @param string $ip_address user's ip address.
829 *
830 * @return string
831 */
832 public static function get_timezone_by_ip( $ip_address ) {
833
834 if ( '127.0.0.1' === $ip_address || empty( $ip_address ) ) {
835 return date_default_timezone_get();
836 }
837
838 $location_data = wp_remote_get(
839 'https://api.findip.net/' . $ip_address . '/?token=e21d68c353324af0af206c907e77ff97',
840 array(
841 'timeout' => 60,
842 'sslverify' => false,
843 )
844 );
845
846 if ( is_wp_error( $location_data ) || empty( $location_data ) ) {
847 return date_default_timezone_get(); // localhost.
848 }
849
850 $location_data = json_decode( wp_remote_retrieve_body( $location_data ), true );
851
852 $time_zone = strtolower( $location_data['location']['time_zone'] );
853
854 return $time_zone;
855 }
856
857 /**
858 * Get Site Server 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_site_server_time( $format ) {
866
867 $today = gmdate( $format, strtotime( 'now' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
868
869 return $today;
870 }
871
872 /**
873 * Get All Breakpoints.
874 *
875 * @param string $type result return type.
876 *
877 * @access public
878 * @since 4.6.1
879 *
880 * @return array $devices enabled breakpoints.
881 */
882 public static function get_all_breakpoints( $type = 'assoc' ) {
883
884 $devices = array(
885 'desktop' => __( 'Desktop', 'elementor' ),
886 'tablet' => __( 'Tablet', 'elementor' ),
887 'mobile' => __( 'Mobile', 'elementor' ),
888 );
889
890 $method_available = method_exists( Plugin::$instance->breakpoints, 'has_custom_breakpoints' );
891
892 if ( ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.4.0', '>' ) ) && $method_available ) {
893
894 if ( Plugin::$instance->breakpoints->has_custom_breakpoints() ) {
895 $devices = array_merge(
896 $devices,
897 array(
898 'widescreen' => __( 'Widescreen', 'elementor' ),
899 'laptop' => __( 'Laptop', 'elementor' ),
900 'tablet_extra' => __( 'Tablet Extra', 'elementor' ),
901 'mobile_extra' => __( 'Mobile Extra', 'elementor' ),
902 )
903 );
904 }
905 }
906
907 if ( 'keys' === $type ) {
908 $devices = array_keys( $devices );
909 }
910
911 return $devices;
912 }
913
914 /**
915 * Get WordPress language prefixes.
916 *
917 * @since 4.4.8
918 * @access public
919 *
920 * @return array
921 */
922 public static function get_lang_prefixes() {
923
924 if ( null === self::$lang_locales ) {
925
926 $langs = require_once PREMIUM_ADDONS_PATH . 'includes/pa-display-conditions/lang-locale.php';
927
928 foreach ( $langs as $lang => $props ) {
929 /* translators: %s: Language Name */
930 $val = ucwords( $props['name'] );
931 self::$lang_locales[ $lang ] = $val;
932 }
933 }
934
935 return self::$lang_locales;
936 }
937
938 /**
939 * Get Woocommerce Categories.
940 *
941 * @access public
942 * @since 4.4.8
943 *
944 * @param string $id array key.
945 *
946 * @return array
947 */
948 public static function get_woo_categories( $id = 'slug' ) {
949
950 $product_cat = array();
951
952 $cat_args = array(
953 'orderby' => 'name',
954 'order' => 'asc',
955 'hide_empty' => false,
956 );
957
958 $product_categories = get_terms( 'product_cat', $cat_args );
959
960 if ( ! empty( $product_categories ) ) {
961
962 foreach ( $product_categories as $key => $category ) {
963
964 $cat_id = 'slug' === $id ? $category->slug : $category->term_id;
965 $product_cat[ $cat_id ] = $category->name;
966
967 }
968 }
969
970 return $product_cat;
971 }
972
973 /**
974 * Check Elementor Experiment
975 *
976 * Check if an Elementor experiment is enabled.
977 *
978 * @since 4.8.6
979 * @access public
980 *
981 * @param string $experiment feature ID.
982 *
983 * @return boolean $is_enabled is feature enabled.
984 */
985 public static function check_elementor_experiment( $experiment ) {
986
987 $experiments_manager = Plugin::$instance->experiments;
988
989 $is_enabled = $experiments_manager->is_feature_active( $experiment );
990
991 return $is_enabled;
992 }
993
994 /**
995 * Is Edit Mode.
996 *
997 * @access public
998 * @since 4.6.1
999 *
1000 * @return boolean
1001 */
1002 public static function is_edit_mode() {
1003 return isset( $_REQUEST['elementor-preview'] ) && ! empty( $_REQUEST['elementor-preview'] ); // phpcs:ignore WordPress.Security.NonceVerification
1004 }
1005
1006 /**
1007 * Generate Unique ID
1008 *
1009 * Generates a unique ID for the current page.
1010 *
1011 * @since 4.6.9
1012 * @access public
1013 *
1014 * @param string $id page ID.
1015 *
1016 * @return string unique ID.
1017 */
1018 public static function generate_unique_id( $id ) {
1019 return substr( md5( $id ), 0, 9 );
1020 }
1021
1022 /**
1023 * Get Safe Path
1024 *
1025 * @since 4.6.9
1026 * @access public
1027 *
1028 * @param string $file_path unsafe file path.
1029 *
1030 * @return string safe file path.
1031 */
1032 public static function get_safe_path( $file_path ) {
1033
1034 $path = str_replace( array( '//', '\\\\' ), array( '/', '\\' ), $file_path );
1035
1036 return str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $path );
1037 }
1038
1039 /**
1040 * Check if the current post type should include addons.
1041 *
1042 * @param string $id current post ID.
1043 *
1044 * @since 4.9.18
1045 * @access public
1046 */
1047 public static function check_post_type( $id ) {
1048
1049 if ( ! $id ) {
1050 return false;
1051 }
1052
1053 $template_name = get_post_meta( $id, '_elementor_template_type', true );
1054
1055 $template_list = array(
1056 'header',
1057 'footer',
1058 'single',
1059 'post',
1060 'page',
1061 'archive',
1062 'search-results',
1063 'error-404',
1064 'product',
1065 'product-archive',
1066 'section',
1067 );
1068
1069 return in_array( $template_name, $template_list );
1070 }
1071
1072 /**
1073 * Get Draw SVG Notice
1074 *
1075 * @since 4.9.26
1076 * @access public
1077 *
1078 * @param object $elem element object.
1079 * @param string $search search query.
1080 * @param array $conditions control conditions
1081 */
1082 public static function get_draw_svg_notice( $elem, $search, $conditions, $index = 0, $nested = 'condition' ) {
1083
1084 $url = add_query_arg(
1085 array(
1086 'page' => sprintf( 'premium-addons&search=%s#tab=elements', $search ),
1087 ),
1088 esc_url( admin_url( 'admin.php' ) )
1089 );
1090
1091 $control_attr = array(
1092 'type' => Controls_Manager::RAW_HTML,
1093 '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>',
1094 'classes' => 'editor-pa-control-notice',
1095 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
1096 );
1097
1098 $control_attr[ $nested ] = $conditions;
1099
1100 $elem->add_control(
1101 'draw_svg_notice_' . $index,
1102 $control_attr
1103 );
1104 }
1105
1106 /**
1107 * Checks if Elementor PRO 3.8 or higher is activated && if the Loop expirement is activated.
1108 *
1109 * @since 4.9.45
1110 * @access public
1111 *
1112 * @return bool
1113 */
1114 public static function is_loop_exp_enabled() {
1115
1116 if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
1117
1118 if ( version_compare( ELEMENTOR_PRO_VERSION, '3.16.0', '>=' ) ) {
1119 return true;
1120 } elseif ( version_compare( ELEMENTOR_PRO_VERSION, '3.8', '>=' ) ) {
1121 $is_loop_enabled = self::check_elementor_experiment( 'loop' );
1122
1123 if ( $is_loop_enabled ) {
1124 return true;
1125 }
1126 }
1127 }
1128
1129 return false;
1130 }
1131
1132 /**
1133 * Get Element Classes.
1134 *
1135 * @access private
1136 * @since 2.8.22
1137 *
1138 * @param array $devices devices to hide on.
1139 *
1140 * @return array
1141 */
1142 public static function get_element_classes( $devices, $default = array() ) {
1143
1144 $classes = $default;
1145
1146 if ( count( $devices ) ) {
1147 foreach ( $devices as $index => $device ) {
1148 array_push( $classes, 'elementor-hidden-' . $device );
1149 }
1150
1151 array_push( $classes, 'premium-addons-element' );
1152 }
1153
1154 return $classes;
1155 }
1156
1157 /**
1158 * Round Numbers In A Reading-friendly Format.
1159 *
1160 * @param integer $num followers number.
1161 */
1162 public static function premium_format_numbers( $num ) {
1163 $num = intval( $num );
1164 $result = '';
1165
1166 if ( $num >= 1000000000 ) {
1167 $tmp = round( ( $num / 1000000 ), 1 );
1168 $result = $tmp . 'B';
1169 return $result;
1170 }
1171
1172 if ( $num >= 1000000 ) {
1173 $tmp = round( ( $num / 1000000 ), 1 );
1174 $result = $tmp . 'M';
1175 return $result;
1176 }
1177
1178 if ( $num >= 1000 ) {
1179 $tmp = round( ( $num / 1000 ), 1 );
1180 $result = $tmp . 'K';
1181
1182 return $result;
1183 }
1184
1185 return round( $num, 1 );
1186 }
1187
1188 /**
1189 * Get Contact Form Body
1190 *
1191 * @since 4.10.2
1192 * @access public
1193 *
1194 * @param string $preset form preset.
1195 *
1196 * @return void
1197 */
1198 public static function get_cf_form_body( $preset ) {
1199
1200 $forms_array = array(
1201
1202 'preset1' => '<div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1203 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1204 [submit "Subscribe"]',
1205
1206 'preset2' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1207 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1208
1209 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1210 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1211
1212 [submit "Send"]',
1213
1214 'preset3' => '<div class="premium-cf-full"><label class="premium-cf-label">Name</label>
1215 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1216
1217 <div class="premium-cf-full"><label class="premium-cf-label">Email</label>
1218 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1219
1220 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1221 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1222
1223 [submit "Send"]',
1224
1225 'preset4' => '<div class="premium-cf-half"><label class="premium-cf-label">Name</label>
1226 [text* text-1 class:premium-cf-field placeholder "John Smith"]</div>
1227
1228 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1229 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1230
1231 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1232 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1233
1234 [submit "Send"]',
1235
1236 'preset5' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1237 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1238
1239 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1240 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1241
1242 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1243 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1244
1245 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1246 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1247
1248 <div class="premium-cf-full"><label class="premium-cf-label">Gender</label>
1249 [select menu-1 "Male" "Female"]</div>
1250
1251 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1252 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1253 [submit "Send"]',
1254
1255 'preset6' => '<div class="premium-cf-half"><label class="premium-cf-label">First Name</label>
1256 [text* text-1 class:premium-cf-field placeholder "John"]</div>
1257
1258 <div class="premium-cf-half"><label class="premium-cf-label">Last Name</label>
1259 [text* text-2 class:premium-cf-field placeholder "Smith"]</div>
1260
1261 <div class="premium-cf-half"><label class="premium-cf-label">Email</label>
1262 [email* email-1 class:premium-cf-field placeholder "john@smith.com"]</div>
1263
1264 <div class="premium-cf-half"><label class="premium-cf-label">Phone</label>
1265 [tel* tel-1 class:premium-cf-field placeholder "+13137262547"]</div>
1266
1267 <div class="premium-cf-full"><label class="premium-cf-label">Company Size</label>
1268 [radio radio-1 default:1 "1-10 employees" "11-30 employees" "30-50 employees" "Above 50 employee"]
1269 </div>
1270
1271 <div class="premium-cf-full"><label class="premium-cf-label">Message</label>
1272 [textarea* textarea-1 class:premium-cf-field placeholder "Enter your message here..."]</div>
1273 [submit "Send"]',
1274
1275 );
1276
1277 return $forms_array[ $preset ]; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1278 }
1279
1280 /**
1281 * Render Rating Stars
1282 *
1283 * @since 4.10.13
1284 * @access public
1285 *
1286 * @param float $rating rating score.
1287 * @param string $fill_color fill color.
1288 * @param string $empty_color empty color.
1289 * @param float $star_size star size.
1290 */
1291 public static function render_rating_stars( $rating, $fill_color, $empty_color, $star_size ) {
1292
1293 ?>
1294
1295 <span class="premium-fb-rev-stars">
1296 <?php
1297
1298 foreach ( array( 1, 2, 3, 4, 5 ) as $val ) {
1299 $score = round( ( $rating - $val ), 2 );
1300
1301 if ( $score >= -0.2 ) {
1302
1303 ?>
1304 <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>
1305 <?php
1306 } elseif ( $score > -0.8 && $score < -0.2 ) {
1307 ?>
1308 <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>
1309 <?php } else { ?>
1310 <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>
1311 <?php
1312 }
1313 }
1314 ?>
1315 </span>
1316
1317 <?php
1318 }
1319
1320
1321 /**
1322 * Get SVG Shapes
1323 *
1324 * @since 4.10.13
1325 * @access public
1326 */
1327 public static function get_svg_shapes( $shape = '' ) {
1328
1329 if ( null === self::$shapes ) {
1330
1331 self::$shapes = require PREMIUM_ADDONS_PATH . 'modules/premium-shape-divider/shapes.php';
1332
1333 }
1334
1335 $shapes = self::$shapes;
1336
1337 if ( empty( $shape ) ) {
1338 return $shapes;
1339 } else {
1340 return $shapes[ $shape ]['imagesmall'];
1341 }
1342 }
1343
1344 public static function get_btn_svgs( $style = 'line1' ) {
1345
1346 $html = '';
1347
1348 switch ( $style ) {
1349 case 'line1':
1350 $html = '<div class="premium-btn-line-wrap"><svg class="premium-btn-svg" width="100%" height="9" viewBox="0 0 101 9">
1351 <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>
1352 </svg></div>';
1353 break;
1354
1355 case 'line3':
1356 $html = '<div class="premium-btn-line-wrap"><svg class="premium-btn-svg" width="100%" height="18" viewBox="0 0 59 18">
1357 <path d="M.945.149C12.3 16.142 43.573 22.572 58.785 10.842" pathLength="1"></path>
1358 </svg></div>';
1359 break;
1360
1361 case 'line4':
1362 $html = '<svg class="premium-btn-svg" width="300%" height="100%" viewBox="0 0 1200 60" preserveAspectRatio="none">
1363 <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>
1364 </svg>';
1365 break;
1366
1367 default:
1368 // code...
1369 break;
1370 }
1371
1372 return $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1373 }
1374
1375 /**
1376 * Add Button Hover Controls
1377 *
1378 * @since 4.10.17
1379 * @access public
1380 *
1381 * @param object $elem widget object.
1382 * @param array $conditions controls conditions.
1383 */
1384 public static function add_btn_hover_controls( $elem, $conditions ) {
1385
1386 $elem->add_control(
1387 'premium_button_hover_effect',
1388 array(
1389 'label' => __( 'Hover Effect', 'premium-addons-for-elementor' ),
1390 'type' => Controls_Manager::SELECT,
1391 'default' => 'none',
1392 'options' => array(
1393 'none' => __( 'None', 'premium-addons-for-elementor' ),
1394 'style1' => __( 'Slide', 'premium-addons-for-elementor' ),
1395 'style2' => __( 'Shutter', 'premium-addons-for-elementor' ),
1396 'style5' => apply_filters( 'pa_pro_label', __( 'In & Out (Pro)', 'premium-addons-for-elementor' ) ),
1397 'style6' => apply_filters( 'pa_pro_label', __( 'Grow (Pro)', 'premium-addons-for-elementor' ) ),
1398 'style7' => apply_filters( 'pa_pro_label', __( 'Double Layers (Pro)', 'premium-addons-for-elementor' ) ),
1399 'style8' => apply_filters( 'pa_pro_label', __( 'Animated Underline (Pro)', 'premium-addons-for-elementor' ) ),
1400 ),
1401 'separator' => 'before',
1402 'label_block' => true,
1403 'condition' => $conditions,
1404 )
1405 );
1406
1407 do_action( 'pa_button_hover_controls', $elem, $conditions );
1408
1409 $elem->add_control(
1410 'premium_button_style1_dir',
1411 array(
1412 'label' => __( 'Slide Direction', 'premium-addons-for-elementor' ),
1413 'type' => Controls_Manager::SELECT,
1414 'default' => 'bottom',
1415 'options' => array(
1416 'bottom' => __( 'Top to Bottom', 'premium-addons-for-elementor' ),
1417 'top' => __( 'Bottom to Top', 'premium-addons-for-elementor' ),
1418 'left' => __( 'Right to Left', 'premium-addons-for-elementor' ),
1419 'right' => __( 'Left to Right', 'premium-addons-for-elementor' ),
1420 ),
1421 'condition' => array_merge(
1422 $conditions,
1423 array(
1424 'premium_button_hover_effect' => 'style1',
1425 )
1426 ),
1427 'label_block' => true,
1428 )
1429 );
1430
1431 $elem->add_control(
1432 'premium_button_style2_dir',
1433 array(
1434 'label' => __( 'Shutter Direction', 'premium-addons-for-elementor' ),
1435 'type' => Controls_Manager::SELECT,
1436 'default' => 'shutouthor',
1437 'options' => array(
1438 'shutinhor' => __( 'Shutter in Horizontal', 'premium-addons-for-elementor' ),
1439 'shutinver' => __( 'Shutter in Vertical', 'premium-addons-for-elementor' ),
1440 'shutoutver' => __( 'Shutter out Horizontal', 'premium-addons-for-elementor' ),
1441 'shutouthor' => __( 'Shutter out Vertical', 'premium-addons-for-elementor' ),
1442 'scshutoutver' => __( 'Scaled Shutter Vertical', 'premium-addons-for-elementor' ),
1443 'scshutouthor' => __( 'Scaled Shutter Horizontal', 'premium-addons-for-elementor' ),
1444 'dshutinver' => __( 'Tilted Left', 'premium-addons-for-elementor' ),
1445 'dshutinhor' => __( 'Tilted Right', 'premium-addons-for-elementor' ),
1446 ),
1447 'condition' => array_merge(
1448 $conditions,
1449 array(
1450 'premium_button_hover_effect' => 'style2',
1451 )
1452 ),
1453 'label_block' => true,
1454 )
1455 );
1456 }
1457
1458 /**
1459 * Get Button Class
1460 *
1461 * @since 4.10.17
1462 * @access public
1463 *
1464 * @param $settings object widget settings.
1465 *
1466 * @return string $class css class.
1467 */
1468 public static function get_button_class( $settings ) {
1469
1470 $class = '';
1471
1472 $papro_activated = apply_filters( 'papro_activated', false );
1473
1474 if ( ! $papro_activated && ! in_array( $settings['premium_button_hover_effect'], array( 'none', 'style1', 'style2' ) ) ) {
1475 return '';
1476 }
1477
1478 if ( 'style1' === $settings['premium_button_hover_effect'] ) {
1479 $class = 'premium-button-style1-' . $settings['premium_button_style1_dir'];
1480 } elseif ( 'style2' === $settings['premium_button_hover_effect'] ) {
1481 $class = 'premium-button-style2-' . $settings['premium_button_style2_dir'];
1482 } elseif ( 'style5' === $settings['premium_button_hover_effect'] ) {
1483 $class = 'premium-button-style5-' . $settings['premium_button_style5_dir'];
1484 } elseif ( 'style6' === $settings['premium_button_hover_effect'] ) {
1485 $class = 'premium-button-style6';
1486 } elseif ( 'style7' === $settings['premium_button_hover_effect'] ) {
1487 $class = 'premium-button-style7-' . $settings['premium_button_style7_dir'];
1488 } elseif ( 'style8' === $settings['premium_button_hover_effect'] ) {
1489 $class = 'premium-button-' . $settings['underline_style'];
1490 }
1491
1492 return 'premium-button-' . $settings['premium_button_hover_effect'] . ' ' . $class;
1493 }
1494
1495
1496 /**
1497 * Get Empty Query Message
1498 *
1499 * Written in PHP and used to generate the final HTML when the query is empty
1500 *
1501 * @since 4.10.29
1502 * @access protected
1503 *
1504 * @param string $notice empty query notice.
1505 */
1506 public static function render_empty_query_message( $notice ) {
1507
1508 if ( empty( $notice ) ) {
1509 $notice = __( 'The current query has no posts. Please make sure you have published items matching your query.', 'premium-addons-for-elementor' );
1510 }
1511
1512 ?>
1513 <div class="premium-error-notice">
1514 <?php echo wp_kses_post( $notice ); ?>
1515 </div>
1516 <?php
1517 }
1518
1519 /**
1520 * Check Capability
1521 *
1522 * @since 4.10.28
1523 * @access public
1524 *
1525 * @param string $check capability.
1526 */
1527 public static function check_capability( $capability ) {
1528
1529 $post_author_id = get_the_author_meta( 'ID' );
1530
1531 $current_user_can = user_can( $post_author_id, $capability );
1532
1533 return $current_user_can;
1534
1535 }
1536 }
1537