PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.3
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.3
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / utils.php

utils.php in Adminify – White Label, Admin Menu Editor, Login Customizer 3.2.3, at Inc/utils.php

938 lines 32.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc;
4
5 use ReturnTypeWillChange ;
6 use WPAdminify\Inc\Classes\Helper ;
7 // no direct access allowed
8 if ( !defined( 'ABSPATH' ) ) {
9 exit;
10 }
11 class Utils
12 {
13 public $post_types = '' ;
14 /**
15 * Check if the Module is Enable/Disable
16 *
17 * @param [type] $value
18 *
19 * @return void
20 */
21 public static function check_modules( $value )
22 {
23
24 if ( empty($value) ) {
25 return;
26 } else {
27 return true;
28 }
29
30 }
31
32 /**
33 * Check given value empty or not
34 *
35 * @param [type] $value
36 *
37 * @return void
38 */
39 public static function check_is_empty( $value, $default = '' )
40 {
41 $value = ( !empty(esc_attr( $value )) ? $value : $default );
42 return $value;
43 }
44
45 /**
46 * Check hidden for rules or not
47 *
48 * @param [type] $value
49 *
50 * @return bool
51 */
52 public static function restricted_for( $restrict_for )
53 {
54 if ( !function_exists( 'wp_get_current_user' ) ) {
55 include ABSPATH . 'wp-includes/pluggable.php';
56 }
57 if ( !is_array( $restrict_for ) ) {
58 $restrict_for = [ 'administrator' ];
59 }
60 $current_user = wp_get_current_user();
61 $current_name = $current_user->display_name;
62 $current_roles = $current_user->roles;
63 // $all_roles = wp_roles()->get_names();
64 if ( in_array( $current_name, $restrict_for ) ) {
65 return true;
66 }
67 // Super Admin for Multisite
68 if ( is_super_admin() && is_multisite() ) {
69
70 if ( in_array( 'Super Admin', $restrict_for ) || in_array( 'administrator', $restrict_for ) ) {
71 return true;
72 } else {
73 return false;
74 }
75
76 }
77 // Normal Super Admin
78 // if ($current_user->ID === 1) {
79 // if (in_array('Super Admin', $restrict_for)) {
80 // return true;
81 // } else {
82 // return false;
83 // }
84 // }
85 foreach ( $current_roles as $role ) {
86 // $role_name = $all_roles[$role];
87 if ( in_array( strtolower( $role ), $restrict_for ) ) {
88 return true;
89 }
90 }
91 }
92
93 /**
94 * Check Site wide plugin settings
95 */
96 public static function is_site_wide( $plugin )
97 {
98 if ( !is_multisite() ) {
99 return false;
100 }
101 $plugins = get_site_option( 'active_sitewide_plugins' );
102 if ( isset( $plugins[$plugin] ) ) {
103 return true;
104 }
105 return false;
106 }
107
108 /**
109 * Restricts for role / user
110 */
111 public static function restrict_for( $disabled_for )
112 {
113 if ( !is_array( $disabled_for ) ) {
114 return false;
115 }
116 require_once ABSPATH . '/wp-includes/pluggable.php';
117 if ( !function_exists( 'wp_get_current_user' ) ) {
118 return false;
119 }
120 $current_user = wp_get_current_user();
121 $current_name = $current_user->display_name;
122 $current_roles = $current_user->roles;
123 $formattedroles = [];
124 foreach ( $disabled_for as $item ) {
125 $item = strtolower( $item );
126 $item = str_replace( ' ', '_', $item );
127 array_push( $formattedroles, $item );
128 }
129 if ( in_array( $current_name, $disabled_for ) ) {
130 return true;
131 }
132 foreach ( $current_roles as $role ) {
133 if ( in_array( $role, $formattedroles ) ) {
134 return true;
135 }
136 }
137 }
138
139 // Get Taxonomies
140 public static function get_taxonomies()
141 {
142 $args = [
143 'public' => true,
144 'show_ui' => true,
145 ];
146 $output = 'objects';
147 $taxonomies = get_taxonomies( $args, $output );
148 $taxonomies = $taxonomies;
149 return $taxonomies;
150 }
151
152 // Get Post Types
153 public static function get_post_types()
154 {
155 $args = [
156 'public' => true,
157 'show_ui' => true,
158 ];
159 $output = 'objects';
160 $post_types = get_post_types( $args, $output );
161 $post_types = $post_types;
162 return $post_types;
163 }
164
165 // Get Post Meta
166 public static function post_meta( $meta_key )
167 {
168 $meta_key = get_post_meta( get_the_ID(), $meta_key, true );
169 return $meta_key;
170 }
171
172 // verfiy current page id
173 public static function jltwp_adminify_currentpage_id( $id )
174 {
175 if ( !function_exists( 'get_current_screen' ) ) {
176 return true;
177 }
178 $screen = get_current_screen();
179 return is_object( $screen ) && $screen->id == $id;
180 }
181
182 /**
183 * Get Current Admin Page Title
184 *
185 * @param string $title
186 *
187 * @return void
188 */
189 public static function admin_page_title( $title = '' )
190 {
191 $title = ( isset( $title ) && !empty($title) ? $title : WP_ADMINIFY );
192 echo esc_html( $title ) ;
193
194 if ( is_multisite() ) {
195 $text = ' | ' . esc_html__( 'Current Blog ID', 'adminify' ) . ': ' . get_current_blog_id();
196 ?>
197 <?php
198 echo self::wp_kses_custom( self::admin_page_subtitle( $text ) ) ;
199 ?>
200 <?php
201 }
202
203 ?>
204 <?php
205 }
206
207 /**
208 * Get Current Admin Subtitle
209 */
210 public static function admin_page_subtitle( $text )
211 {
212 ?>
213
214 <span style="color:#8b959e;" <?php
215 if ( is_rtl() ) {
216 echo ' dir="rtl"' ;
217 }
218 ?>>
219 <?php
220 echo esc_html( $text ) ;
221 ?>
222 </span>
223
224 <?php
225 }
226
227 public static function convert_name_to_class( $name )
228 {
229 $class = str_replace( [
230 ' ',
231 ',',
232 '.',
233 '"',
234 "'",
235 '/',
236 '\\',
237 '+',
238 '=',
239 ')',
240 '(',
241 '*',
242 '&',
243 '^',
244 '%',
245 '$',
246 '#',
247 '@',
248 '!',
249 '~',
250 '`',
251 '<',
252 '>',
253 '?',
254 '[',
255 ']',
256 '{',
257 '}',
258 '|',
259 ':'
260 ], '', $name );
261 return $class;
262 }
263
264 public static function jltwp_adminify_class_cleanup( $string )
265 {
266 // Lower case everything
267 $string = strtolower( $string );
268 // Make alphanumeric (removes all other characters)
269 $string = preg_replace( '/[^a-z0-9_\\s-]/', '', $string );
270 // Clean up multiple dashes or whitespaces
271 $string = preg_replace( '/[\\s-]+/', ' ', $string );
272 // Convert whitespaces and underscore to dash
273 $string = preg_replace( '/[\\s_]/', '-', $string );
274 return $string;
275 }
276
277 public static function sanitize_id( $url )
278 {
279 $url = preg_replace( '/^customize.php\\?return=.*$/', 'customize', $url );
280 $url = preg_replace( '/(&|&amp;|&#038;)?_wpnonce=([^&]+)/', '', $url );
281 return str_replace( [
282 '.php',
283 '.',
284 '/',
285 '?',
286 '='
287 ], [
288 '',
289 '_',
290 '_',
291 '_',
292 '_'
293 ], $url );
294 }
295
296 /**
297 * Strip tags and it's content from the given string.
298 *
299 * @link https://stackoverflow.com/questions/14684077/remove-all-html-tags-from-php-string/#answer-39320168
300 *
301 * @param string $text The string being stripped.
302 * @return string The stripped string.
303 */
304 public static function strip_tags_content( $text )
305 {
306 $cleanup = preg_replace( '@<(\\w+)\\b.*?>.*?</\\1>@si', '', $text );
307 $cleanup = wp_strip_all_tags( $cleanup );
308 $cleanup = trim( $cleanup );
309 return $cleanup;
310 }
311
312 /**
313 * String to ID
314 * Remove Space replace with underscore and lowercase
315 *
316 * @param void
317 *
318 * @return string
319 */
320 public static function string_to_id( $string )
321 {
322 $string_replace = str_replace( ' ', '_', $string );
323 $formatted_string = strtolower( $string_replace );
324 return $formatted_string;
325 }
326
327 /**
328 * ID to String
329 * Remove Space replace with underscore and lowercase
330 *
331 * @param void
332 *
333 * @return string
334 */
335 public static function id_to_string( $string )
336 {
337 $string_replace = str_replace( '_', ' ', $string );
338 $formatted_string = ucwords( $string_replace );
339 return $formatted_string;
340 }
341
342 /**
343 * Check is Plugin Active
344 *
345 * @param [type] $plugin_basename
346 *
347 * @return boolean
348 */
349 public static function is_plugin_active( $plugin_basename )
350 {
351 include_once ABSPATH . 'wp-admin/includes/plugin.php';
352 return is_plugin_active( $plugin_basename );
353 }
354
355 /**
356 * User Defined Settings
357 */
358 public static function get_user_preference( $key )
359 {
360 $userid = get_current_user_id();
361 $current = get_user_meta( $userid, '_wpadminify_preferences', true );
362 $value = false;
363 if ( is_array( $current ) ) {
364 if ( isset( $current[$key] ) ) {
365 $value = $current[$key];
366 }
367 }
368 return $value;
369 }
370
371 /**
372 * Sanitises and strips tags of input from ajax
373 *
374 * @since 1.0.0
375 * @variables $values = item to clean (array or string)
376 */
377 public static function clean_ajax_input( $values )
378 {
379
380 if ( is_array( $values ) ) {
381 foreach ( $values as $index => $in ) {
382
383 if ( is_array( $in ) ) {
384 $values[$index] = self::clean_ajax_input( $in );
385 } else {
386 $values[$index] = strip_tags( $in );
387 }
388
389 }
390 } else {
391 $values = strip_tags( $values );
392 }
393
394 return $values;
395 }
396
397 /**
398 * Check Ajax Error Messages
399 *
400 * @param [type] $message
401 *
402 * @return void
403 */
404 public static function ajax_error_message( $message )
405 {
406 $returndata = [];
407 $returndata['error'] = true;
408 $returndata['error_message'] = $message;
409 return json_encode( $returndata );
410 }
411
412 /**
413 * Get All Updates
414 * Themes, Plugins, Core etc
415 *
416 * @return void
417 */
418 public static function get_all_updates()
419 {
420 $allupdates = [];
421 $allupdates['total'] = 0;
422 $allupdates['wordpress'] = 0;
423 $allupdates['theme'] = 0;
424 $allupdates['plugin'] = 0;
425 if ( !is_admin() ) {
426 return $allupdates;
427 }
428 if ( !current_user_can( 'install_plugins' ) ) {
429 return $allupdates;
430 }
431 $updatesTotal = 0;
432
433 if ( is_super_admin() && is_admin() ) {
434 $pluginUpdates = get_plugin_updates();
435 $themeUpdates = get_theme_updates();
436 $wpUpdates = get_core_updates();
437
438 if ( isset( $wpUpdates[0] ) ) {
439 $wpversion = $wpUpdates[0]->version;
440 global $wp_version ;
441
442 if ( $wpversion > $wp_version ) {
443 $wpUpdates = 1;
444 } else {
445 $wpUpdates = 0;
446 }
447
448 } else {
449 $wpUpdates = 0;
450 }
451
452 $updatesTotal = count( $pluginUpdates ) + count( $themeUpdates ) + $wpUpdates;
453 $allupdates['total'] = $updatesTotal;
454 $allupdates['wordpress'] = $wpUpdates;
455 $allupdates['theme'] = $themeUpdates;
456 $allupdates['plugin'] = $pluginUpdates;
457 }
458
459 return $allupdates;
460 }
461
462 public static function adminfiy_help_urls(
463 $module_name = '',
464 $docs = '',
465 $youtube = '',
466 $facebook_grp = '',
467 $support = ''
468 )
469 {
470 $help_content = '';
471 // Modules
472
473 if ( empty($module_name) ) {
474 $module_name = 'Module';
475 } else {
476 $module_name = $module_name;
477 }
478
479 // Docs
480
481 if ( empty($docs) ) {
482 $docs = 'https://wpadminify.com/kb';
483 } else {
484 $docs = $docs;
485 }
486
487 // youtube
488
489 if ( empty($youtube) ) {
490 $youtube = 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8';
491 } else {
492 $youtube = $youtube;
493 }
494
495 // facebook_grp
496
497 if ( empty($facebook_grp) ) {
498 $facebook_grp = 'https://www.facebook.com/groups/jeweltheme';
499 } else {
500 $facebook_grp = $facebook_grp;
501 }
502
503 // Support
504
505 if ( empty($support) ) {
506 $support = 'https://wpadminify.com/support/wp-adminify';
507 } else {
508 $support = $support;
509 }
510
511 $help_content = sprintf(
512 __( '%1$s <a class="adminify-docs-url" href="%2$s" target="_blank"> ' . self::docs_icon() . ' Docs</a>
513 <a class="adminify-video-url" href="%3$s" target="_blank">' . self::video_tutorials_icon() . ' Video Tutorial</a> <a class="adminify-fbgroup-url" href="%4$s" target="_blank">' . self::fbgroup_icon() . ' Facebook Group</a> <a class="adminify-support-url" href="%5$s" target="_blank">' . self::support_icon() . ' Support</a>', 'adminify' ),
514 $module_name,
515 $docs,
516 $youtube,
517 $facebook_grp,
518 $support
519 );
520 return $help_content;
521 }
522
523 /**
524 * Upgrade Pro Icon
525 *
526 * @return void
527 */
528 public static function jltwp_adminify_upgrade_pro_icon()
529 {
530 return '<svg class="adminify-pro-notice-icon is-pulled-left mr-2" width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
531 <path fill-rule="evenodd" clip-rule="evenodd" d="M21.8233 0.18318C21.8541 0.215042 21.8753 0.255055 21.8843 0.298527C22.5767 3.32046 20.085 9.8239 16.4731 13.4209C15.8343 14.064 15.1407 14.6502 14.4002 15.1727C14.4955 16.2787 14.411 17.3846 13.9985 18.3318C12.8302 21.0043 9.75855 21.7824 8.44197 21.9937C8.36979 22.0059 8.29577 22.0012 8.22571 21.9799C8.15566 21.9587 8.09147 21.9215 8.03819 21.8713C7.9849 21.821 7.94397 21.7591 7.9186 21.6904C7.89323 21.6217 7.88411 21.548 7.89196 21.4751L8.36241 17.189C8.04096 17.1858 7.71987 17.1663 7.40039 17.1305C7.17735 17.1087 6.96893 17.0096 6.81109 16.8503L5.15076 15.1924C4.99146 15.0346 4.89242 14.8259 4.87084 14.6026C4.83497 14.281 4.81547 13.9578 4.8124 13.6343L0.524795 14.1076C0.451994 14.1156 0.378341 14.1065 0.309629 14.0811C0.240917 14.0558 0.17902 14.0148 0.128806 13.9615C0.0785915 13.9081 0.0414297 13.8438 0.0202432 13.7736C-0.000943262 13.7035 -0.0055768 13.6293 0.00670721 13.5571C0.223273 12.2368 1.00065 9.16771 3.67065 7.99148C4.61695 7.57859 5.72728 7.4965 6.83761 7.59481C7.35968 6.85546 7.94513 6.16306 8.58733 5.52547C12.1879 1.92304 18.8337 -0.585245 21.7099 0.118627C21.7531 0.128924 21.7924 0.151317 21.8233 0.18318ZM12.224 7.92186C12.3151 8.37957 12.5397 8.79996 12.8695 9.12986C13.0882 9.34908 13.348 9.52298 13.6339 9.64164C13.9198 9.7603 14.2263 9.82137 14.5358 9.82137C14.8453 9.82137 15.1517 9.7603 15.4377 9.64164C15.7236 9.52298 15.9833 9.34908 16.202 9.12986C16.5318 8.79996 16.7565 8.37957 16.8475 7.92186C16.9386 7.46415 16.892 6.98968 16.7137 6.55848C16.5353 6.12727 16.2332 5.7587 15.8455 5.49939C15.4578 5.24007 15.002 5.10166 14.5358 5.10166C14.0695 5.10166 13.6137 5.24007 13.226 5.49939C12.8384 5.7587 12.5362 6.12727 12.3579 6.55848C12.1795 6.98968 12.1329 7.46415 12.224 7.92186ZM5.47798 18.5161C5.99754 18.4262 6.4292 18.321 6.69831 18.0511C6.83974 17.9032 7.0897 18.0256 7.07153 18.2311C6.99299 18.8853 6.69667 19.4941 6.23032 19.9593C5.07579 21.1158 0.785726 21.225 0.785726 21.225C0.785726 21.225 0.894746 16.9334 2.04927 15.7768C2.51439 15.3115 3.12167 15.0153 3.77443 14.9353C3.81912 14.9292 3.86459 14.9374 3.90439 14.9586C3.94419 14.9799 3.97629 15.0131 3.99613 15.0537C4.01597 15.0942 4.02255 15.14 4.01493 15.1845C4.00731 15.229 3.98588 15.2699 3.95368 15.3015C3.80635 15.449 3.56965 16.0767 3.48961 16.5245C3.27991 17.7056 4.31069 18.7152 5.47798 18.5161Z" fill="#00BA88"/>
532 </svg>';
533 }
534
535 // Upgrade to Pro Notice
536 public static function adminify_upgrade_pro( $custom_message = '' )
537 {
538
539 if ( empty($custom_message) ) {
540 $pro_content = sprintf( __( 'Get <strong>Pro Version</strong> to Unlock this feature.', 'adminify' ) );
541 } else {
542 $pro_content = $custom_message;
543 }
544
545 $upgrade_notice_msg = sprintf(
546 __( '<div class="adminify-pro-notice"> %1$s <p> %2$s <a href="%3$s" target="_blank">%4$s</a> </p></div>', 'adminify' ),
547 self::jltwp_adminify_upgrade_pro_icon(),
548 self::wp_kses_custom( $pro_content ),
549 esc_url( 'https://wpadminify.com/pricing' ),
550 __( 'Upgrade to Pro Now!', 'adminify' )
551 );
552 return self::wp_kses_custom( $upgrade_notice_msg );
553 }
554
555 /**
556 * Documentation SVG Icon
557 */
558 public static function docs_icon()
559 {
560 return '<svg class="is-pulled-left mr-1 width="9" height="12" viewBox="0 0 9 12" fill="none" xmlns="http://www.w3.org/2000/svg">
561 <path d="M5.25 3.1875V0H0.5625C0.250781 0 0 0.250781 0 0.5625V11.4375C0 11.7492 0.250781 12 0.5625 12H8.4375C8.74922 12 9 11.7492 9 11.4375V3.75H5.8125C5.50313 3.75 5.25 3.49687 5.25 3.1875ZM6.75 8.71875C6.75 8.87344 6.62344 9 6.46875 9H2.53125C2.37656 9 2.25 8.87344 2.25 8.71875V8.53125C2.25 8.37656 2.37656 8.25 2.53125 8.25H6.46875C6.62344 8.25 6.75 8.37656 6.75 8.53125V8.71875ZM6.75 7.21875C6.75 7.37344 6.62344 7.5 6.46875 7.5H2.53125C2.37656 7.5 2.25 7.37344 2.25 7.21875V7.03125C2.25 6.87656 2.37656 6.75 2.53125 6.75H6.46875C6.62344 6.75 6.75 6.87656 6.75 7.03125V7.21875ZM6.75 5.53125V5.71875C6.75 5.87344 6.62344 6 6.46875 6H2.53125C2.37656 6 2.25 5.87344 2.25 5.71875V5.53125C2.25 5.37656 2.37656 5.25 2.53125 5.25H6.46875C6.62344 5.25 6.75 5.37656 6.75 5.53125ZM9 2.85703V3H6V0H6.14297C6.29297 0 6.43594 0.0585938 6.54141 0.164062L8.83594 2.46094C8.94141 2.56641 9 2.70938 9 2.85703Z" fill="#0347FF"/>
562 </svg>';
563 }
564
565 /**
566 * Video Tutorials SVG Icon
567 */
568 public static function video_tutorials_icon()
569 {
570 return '<svg class="is-pulled-left mr-1 width="8" height="10" viewBox="0 0 8 10" fill="none" xmlns="http://www.w3.org/2000/svg">
571 <path d="M7.5 4.13399C8.16667 4.51889 8.16667 5.48114 7.5 5.86604L1.5 9.33014C0.833334 9.71504 0 9.23392 0 8.46412V1.53592C0 0.766115 0.833333 0.28499 1.5 0.66989L7.5 4.13399Z" fill="#C30052"/>
572 </svg>';
573 }
574
575 /**
576 * Facebook Group SVG Icon
577 */
578 public static function fbgroup_icon()
579 {
580 return '<svg class="is-pulled-left mr-1 width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
581 <path d="M1.82594 0C0.814448 0 0 0.814448 0 1.82594V8.17405C0 9.18554 0.814448 9.99999 1.82594 9.99999H5.26656V6.09062H4.23281V4.68312H5.26656V3.48062C5.26656 2.53587 5.87735 1.66844 7.28437 1.66844C7.85404 1.66844 8.2753 1.72313 8.2753 1.72313L8.24217 3.0375C8.24217 3.0375 7.81254 3.03344 7.34374 3.03344C6.83635 3.03344 6.75499 3.26722 6.75499 3.65532V4.68313H8.28248L8.21592 6.09063H6.75499V10H8.17404C9.18553 10 9.99998 9.18555 9.99998 8.17406V1.82595C9.99998 0.814458 9.18553 9.99998e-06 8.17404 9.99998e-06H1.82593L1.82594 0Z" fill="#3B5998"/>
582 </svg>';
583 }
584
585 /**
586 * Support SVG Icon
587 */
588 public static function support_icon()
589 {
590 return '<svg class="is-pulled-left mr-1 width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
591 <path fill-rule="evenodd" clip-rule="evenodd" d="M10 5C10 6.32608 9.47322 7.59785 8.53553 8.53553C7.59785 9.47322 6.32608 10 5 10C3.67392 10 2.40215 9.47322 1.46447 8.53553C0.526784 7.59785 0 6.32608 0 5C0 3.67392 0.526784 2.40215 1.46447 1.46447C2.40215 0.526784 3.67392 0 5 0C6.32608 0 7.59785 0.526784 8.53553 1.46447C9.47322 2.40215 10 3.67392 10 5ZM8.75 5C8.75 5.62063 8.59937 6.20563 8.3325 6.72125L7.38 5.76813C7.52262 5.32668 7.5395 4.85425 7.42875 4.40375L8.405 3.4275C8.62625 3.90563 8.75 4.4375 8.75 5ZM5.52187 7.44563L6.50938 8.43312C6.03375 8.64254 5.51968 8.75046 5 8.75C4.45699 8.75068 3.92036 8.63294 3.4275 8.405L4.40375 7.42875C4.77042 7.5186 5.15266 7.52437 5.52187 7.44563ZM2.59875 5.69812C2.47576 5.27463 2.46692 4.82614 2.57313 4.39812L2.52313 4.44812L1.56687 3.49C1.35738 3.96582 1.24945 4.48011 1.25 5C1.25 5.59625 1.38937 6.16 1.63687 6.66062L2.59938 5.69812H2.59875ZM3.27875 1.66687C3.81076 1.39189 4.40112 1.24891 5 1.25C5.59625 1.25 6.16 1.38937 6.66062 1.63687L5.69812 2.59938C5.21829 2.45961 4.70759 2.46679 4.23187 2.62L3.27875 1.6675V1.66687ZM6.25 5C6.25 5.33152 6.1183 5.64946 5.88388 5.88388C5.64946 6.1183 5.33152 6.25 5 6.25C4.66848 6.25 4.35054 6.1183 4.11612 5.88388C3.8817 5.64946 3.75 5.33152 3.75 5C3.75 4.66848 3.8817 4.35054 4.11612 4.11612C4.35054 3.8817 4.66848 3.75 5 3.75C5.33152 3.75 5.64946 3.8817 5.88388 4.11612C6.1183 4.35054 6.25 4.66848 6.25 5Z" fill="#4E4B66"/>
592 </svg>';
593 }
594
595 /* White Label Upgrade Pro */
596 public static function jltwp_adminify_white_label_upgrade()
597 {
598 ?>
599 <div class="wp-adminify-white-label-notice-content">
600 <div class="wp-adminify-white-label-notice-logo">
601 <img src="<?php
602 echo esc_url( WP_ADMINIFY_ASSETS_IMAGE ) . 'logos/logo-text-light.svg' ;
603 ?>" alt="<?php
604 echo esc_attr( WP_ADMINIFY ) ;
605 ?>">
606 </div>
607 <h2>
608 <?php
609 echo sprintf( __( 'Upgrade <span>Pro</span> for White Labeling', 'adminify' ) ) ;
610 ?>
611 </h2>
612 <p>
613 <?php
614 echo sprintf( __( '<strong>%1$s</strong> can be completely re-branded with your own brand Logo, Name and Author Details. Your clients will never know what tools you are using to build their website and will think that this is your own tool set. White-labeling works as long as your license is active. ', 'adminify' ), esc_html( WP_ADMINIFY ) ) ;
615 ?>
616 <br>
617 <em><?php
618 esc_html_e( 'Note: Agency or Higher Plans Only', 'adminify' );
619 ?></em>
620 </p>
621 <a class="wp-adminify-btn wp-adminify-get-pro" href="<?php
622 echo esc_url( 'https://wpadminify.com/pricing/' ) ;
623 ?>" target="_blank">
624 <?php
625 esc_html_e( 'Upgrade Now', 'adminify' );
626 ?>
627 </a>
628 </div>
629 <?php
630 }
631
632 public static function get_widget_template_options()
633 {
634 $type = 'widget';
635 $page_templates = self::jltwp_adminify_get_page_templates( $type );
636 $options[-1] = __( 'Select', 'adminify' );
637
638 if ( count( $page_templates ) ) {
639 foreach ( $page_templates as $id => $name ) {
640 $options[$id] = $name;
641 }
642 } else {
643 $options['no_template'] = __( 'No saved templates found!', 'adminify' );
644 }
645
646 return $options;
647 }
648
649 public static function get_section_template_options()
650 {
651 $type = 'section';
652 $page_templates = self::jltwp_adminify_get_page_templates( $type );
653 $options[-1] = __( 'Select', 'adminify' );
654
655 if ( count( $page_templates ) ) {
656 foreach ( $page_templates as $id => $name ) {
657 $options[$id] = $name;
658 }
659 } else {
660 $options['no_template'] = __( 'No saved templates found!', 'adminify' );
661 }
662
663 return $options;
664 }
665
666 public static function get_page_template_options()
667 {
668 $type = 'page';
669 $page_templates = self::jltwp_adminify_get_page_templates( $type );
670 $options[-1] = __( 'Select', 'adminify' );
671
672 if ( count( $page_templates ) ) {
673 foreach ( $page_templates as $id => $name ) {
674 $options[$id] = $name;
675 }
676 } else {
677 $options['no_template'] = __( 'No saved templates found!', 'adminify' );
678 }
679
680 return $options;
681 }
682
683 public static function get_theme_presets( $theme = null )
684 {
685 $presets = [
686 'preset1' => [
687 '--adminify-preset-background' => '#F9F9F9',
688 '--adminify-menu-bg' => '#ffffff',
689 '--adminify-menu-text-color' => 'rgba(78, 75, 102, 0.72)',
690 '--adminify-admin-bar-bg' => 'var(--adminify-menu-bg)',
691 '--adminify-admin-bar-icon' => '#14142B',
692 '--adminify-admin-bar-input-bg' => '#F1F1F3',
693 '--adminify-admin-bar-input-text' => '#14142B',
694 '--adminify-admin-bar-icon-brightness' => '1',
695 '--adminify-notif-bg-color' => '#FF1C69',
696 '--adminify-text-color' => '#ffffff',
697 '--adminify-btn-bg' => '#0347FF',
698 '--adminify-admin-bar-icon-filter' => '0.5',
699 ],
700 'preset2' => [
701 '--adminify-preset-background' => '#F9F9F9',
702 '--adminify-menu-bg' => '#14142B',
703 '--adminify-menu-text-color' => '#ffffff',
704 '--adminify-admin-bar-bg' => 'var(--adminify-menu-bg)',
705 '--adminify-admin-bar-icon' => '#ffffff',
706 '--adminify-admin-bar-input-bg' => '#2b2a3f',
707 '--adminify-admin-bar-input-text' => '#9391A0',
708 '--adminify-admin-bar-icon-brightness' => '11',
709 '--adminify-notif-bg-color' => '#FF1C69',
710 '--adminify-text-color' => '#ffffff',
711 '--adminify-btn-bg' => '#0347FF',
712 '--adminify-admin-bar-icon-filter' => '1',
713 ],
714 ];
715 // return all presets
716 if ( is_null( $theme ) ) {
717 return $presets;
718 }
719 // return specific preset
720 if ( array_key_exists( $theme, $presets ) ) {
721 return $presets[$theme];
722 }
723 // specific preset not found
724 return [];
725 }
726
727 public static function jltwp_adminify_get_page_templates( $type = '' )
728 {
729 $args = [
730 'post_type' => 'elementor_library',
731 'posts_per_page' => -1,
732 ];
733 if ( $type ) {
734 $args['tax_query'] = [ [
735 'taxonomy' => 'elementor_library_type',
736 'field' => 'slug',
737 'terms' => $type,
738 ] ];
739 }
740 $page_templates = get_posts( $args );
741 $options = [];
742 if ( !empty($page_templates) && !is_wp_error( $page_templates ) ) {
743 foreach ( $page_templates as $post ) {
744 $options[$post->ID] = $post->post_title;
745 }
746 }
747 return $options;
748 }
749
750 public static function assets_ext( $ext )
751 {
752 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
753 return $ext;
754 }
755 return '.min' . $ext;
756 }
757
758 public static function wp_kses_atts_map( array $attrs )
759 {
760 return array_fill_keys( array_values( $attrs ), true );
761 }
762
763 public static function wp_kses_custom( $content )
764 {
765 $allowed_tags = wp_kses_allowed_html( 'post' );
766 $custom_tags = [
767 'select' => self::wp_kses_atts_map( [
768 'class',
769 'id',
770 'style',
771 'width',
772 'height',
773 'title',
774 'data',
775 'name',
776 'autofocus',
777 'disabled',
778 'multiple',
779 'required',
780 'size'
781 ] ),
782 'input' => self::wp_kses_atts_map( [
783 'class',
784 'id',
785 'style',
786 'width',
787 'height',
788 'title',
789 'data',
790 'name',
791 'autofocus',
792 'disabled',
793 'required',
794 'size',
795 'type',
796 'checked',
797 'readonly',
798 'placeholder',
799 'value',
800 'maxlength',
801 'min',
802 'max',
803 'multiple',
804 'pattern',
805 'step',
806 'autocomplete'
807 ] ),
808 'textarea' => self::wp_kses_atts_map( [
809 'class',
810 'id',
811 'style',
812 'width',
813 'height',
814 'title',
815 'data',
816 'name',
817 'autofocus',
818 'disabled',
819 'required',
820 'rows',
821 'cols',
822 'wrap',
823 'maxlength'
824 ] ),
825 'option' => self::wp_kses_atts_map( [
826 'class',
827 'id',
828 'label',
829 'disabled',
830 'label',
831 'selected',
832 'value'
833 ] ),
834 'optgroup' => self::wp_kses_atts_map( [
835 'disabled',
836 'label',
837 'class',
838 'id'
839 ] ),
840 'form' => self::wp_kses_atts_map( [
841 'class',
842 'id',
843 'data',
844 'style',
845 'width',
846 'height',
847 'accept-charset',
848 'action',
849 'autocomplete',
850 'enctype',
851 'method',
852 'name',
853 'novalidate',
854 'rel',
855 'target'
856 ] ),
857 'svg' => self::wp_kses_atts_map( [
858 'class',
859 'xmlns',
860 'viewbox',
861 'width',
862 'height',
863 'fill',
864 'aria-hidden',
865 'aria-labelledby',
866 'role'
867 ] ),
868 'rect' => self::wp_kses_atts_map( [
869 'rx',
870 'width',
871 'height',
872 'fill'
873 ] ),
874 'path' => self::wp_kses_atts_map( [ 'd', 'fill' ] ),
875 'g' => self::wp_kses_atts_map( [ 'fill' ] ),
876 'defs' => self::wp_kses_atts_map( [ 'fill' ] ),
877 'linearGradient' => self::wp_kses_atts_map( [
878 'id',
879 'x1',
880 'x2',
881 'y1',
882 'y2',
883 'gradientUnits'
884 ] ),
885 'stop' => self::wp_kses_atts_map( [ 'stop-color', 'offset', 'stop-opacity' ] ),
886 'style' => self::wp_kses_atts_map( [ 'type' ] ),
887 'div' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
888 'ul' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
889 'li' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
890 'label' => self::wp_kses_atts_map( [ 'class', 'for' ] ),
891 'span' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
892 'h1' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
893 'h2' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
894 'h3' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
895 'h4' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
896 'h5' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
897 'h6' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
898 'a' => self::wp_kses_atts_map( [
899 'class',
900 'href',
901 'target',
902 'rel'
903 ] ),
904 'p' => self::wp_kses_atts_map( [
905 'class',
906 'id',
907 'style',
908 'data'
909 ] ),
910 'table' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
911 'thead' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
912 'tbody' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
913 'tr' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
914 'th' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
915 'td' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
916 'i' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
917 'button' => self::wp_kses_atts_map( [ 'class', 'id' ] ),
918 'nav' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
919 'time' => self::wp_kses_atts_map( [ 'datetime' ] ),
920 'br' => [],
921 'strong' => [],
922 'style' => [],
923 'img' => self::wp_kses_atts_map( [
924 'class',
925 'src',
926 'alt',
927 'height',
928 'width',
929 'srcset',
930 'id',
931 'loading'
932 ] ),
933 ];
934 $allowed_tags = array_merge_recursive( $allowed_tags, $custom_tags );
935 return wp_kses( stripslashes_deep( $content ), $allowed_tags );
936 }
937
938 }