PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
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
← All changes | Inc/utils.php +913 -1224 4.1.173.2.4.1 View file →
@@ -1,1254 +1,943 @@
1 1 <?php
2 2
3 3 namespace WPAdminify\Inc;
4 4
5 -use ReturnTypeWillChange;
6 -use WPAdminify\Inc\Classes\Helper;
5 +use ReturnTypeWillChange ;
6 +use WPAdminify\Inc\Classes\Helper ;
7 7 // no direct access allowed
8 -if (!defined('ABSPATH')) {
9 - exit;
8 +if ( !defined( 'ABSPATH' ) ) {
9 + exit;
10 10 }
11 -
12 11 class Utils
13 12 {
14 - public $post_types = '';
15 -
16 - /**
17 - * Check if the Module is Enable/Disable
18 - *
19 - * @param [type] $value
20 - *
21 - * @return void
22 - */
23 - public static function check_modules($value)
24 - {
25 - if (empty($value)) {
26 - return;
27 - } else {
28 - return true;
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 - /**
47 - * Check hidden for roles or not
48 - *
49 - * @param [type] $value
50 - *
51 - * @return bool
52 - */
53 - public static function restricted_for($disabled_for)
54 - {
55 - if (empty($disabled_for)) {
56 - return false;
57 - }
58 -
59 - // wp_get_current_user() lives in wp-includes/pluggable.php and is
60 - // always available in normal plugin execution. If it is somehow
61 - // unavailable (e.g. very early bootstrap), bail out instead of
62 - // manually loading core files, which is disallowed by the
63 - // WordPress.org plugin guidelines.
64 - if (!function_exists('wp_get_current_user')) {
65 - return false;
66 - }
67 -
68 - $restrict_for = array();
69 -
70 - if (!is_array($disabled_for)) {
71 - $restrict_for[] = $disabled_for;
72 - } else {
73 - $restrict_for = $disabled_for;
74 - }
75 -
76 -
77 - $current_user = wp_get_current_user();
78 - $current_name = $current_user->display_name;
79 - $current_roles = $current_user->roles;
80 - // $all_roles = wp_roles()->get_names();
81 -
82 - if (in_array($current_name, $restrict_for)) {
83 - return true;
84 - }
85 -
86 - // if (in_array('Super Admin', $restrict_for) || in_array('administrator', $restrict_for)) {
87 - // return true;
88 - // }
89 -
90 - // Super Admin for Multisite
91 - if (is_super_admin() && is_multisite()) {
92 - if (in_array('Super Admin', $restrict_for) || in_array('administrator', $restrict_for)) {
93 - return true;
94 - } else {
95 - return false;
96 - }
97 - }
98 -
99 - $formattedroles = [];
100 -
101 - foreach ($restrict_for as $item) {
102 - $item = is_string($item) ? strtolower($item) : $item;
103 - $item = is_string($item) ? str_replace(' ', '_', $item) : $item;
104 - array_push($formattedroles, $item);
105 - }
106 -
107 - foreach ($current_roles as $role) {
108 - // $role_name = $all_roles[$role];
109 - if (in_array($role, $restrict_for)) {
110 - return true;
111 - }
112 - }
113 - }
114 -
115 -
116 - /**
117 - * Check Site wide plugin settings
118 - */
119 - public static function is_site_wide($plugin)
120 - {
121 - if (!is_multisite()) {
122 - return false;
123 - }
124 -
125 - $plugins = get_site_option('active_sitewide_plugins');
126 - if (isset($plugins[$plugin])) {
127 - return true;
128 - }
129 -
130 - return false;
131 - }
132 -
133 - /**
134 - * Get All Taxonomies
135 - *
136 - * @return void
137 - */
138 - public static function get_all_taxonomies()
139 - {
140 - $taxonomies = get_taxonomies(
141 - [
142 - 'show_ui' => true,
143 - ],
144 - 'objects'
145 - );
146 - $taxonomy_names = [];
147 - foreach ($taxonomies as $taxonomy) {
148 - if ($taxonomy->name == 'post_format') {
149 - continue;
150 - }
151 - $taxonomy_names[$taxonomy->name] = $taxonomy->label;
152 - }
153 - return $taxonomy_names;
154 - }
155 -
156 - /**
157 - * Restricts for role / user
158 - */
159 -
160 - public static function restrict_for($disabled_for)
161 - {
162 - if (!is_array($disabled_for)) {
163 - return false;
164 - }
165 -
166 - // wp_get_current_user() is provided by wp-includes/pluggable.php and
167 - // is loaded by core early in normal plugin execution. Manually
168 - // loading core files is disallowed by the plugin guidelines, so we
169 - // simply bail out if it is unavailable for any reason.
170 - if (!function_exists('wp_get_current_user')) {
171 - return false;
172 - }
173 -
174 - $current_user = wp_get_current_user();
175 - $current_name = $current_user->display_name;
176 - $current_roles = $current_user->roles;
177 -
178 - $formattedroles = [];
179 -
180 - foreach ($disabled_for as $item) {
181 - $item = strtolower($item);
182 - $item = str_replace(' ', '_', $item);
183 - array_push($formattedroles, $item);
184 - }
185 -
186 - if (in_array($current_name, $disabled_for)) {
187 - return true;
188 - }
189 -
190 - foreach ($current_roles as $role) {
191 - if (in_array($role, $formattedroles)) {
192 - return true;
193 - }
194 - }
195 - }
196 -
197 -
198 - // Get Taxonomies
199 - public static function get_taxonomies()
200 - {
201 - $args = [
202 - 'public' => true,
203 - 'show_ui' => true,
204 - ];
205 - $output = 'objects';
206 - $taxonomies = get_taxonomies($args, $output);
207 - $taxonomies = $taxonomies;
208 - return $taxonomies;
209 - }
210 -
211 - // Get Post Types
212 - public static function get_post_types()
213 - {
214 - $args = [
215 - 'public' => true,
216 - 'show_ui' => true,
217 - ];
218 - $output = 'objects';
219 - $post_types = get_post_types($args, $output);
220 - $post_types = $post_types;
221 - return $post_types;
222 - }
223 -
224 - // Get Post Meta
225 - public static function post_meta($meta_key)
226 - {
227 - $meta_key = get_post_meta(get_the_ID(), $meta_key, true);
228 - return $meta_key;
229 - }
230 -
231 -
232 - // verfiy current page id
233 - public static function jltwp_adminify_currentpage_id($id)
234 - {
235 - if (!function_exists('get_current_screen')) {
236 - return true;
237 - }
238 -
239 - $screen = get_current_screen();
240 - return is_object($screen) && $screen->id == $id;
241 - }
242 -
243 - /**
244 - * Get Current Admin Page Title
245 - *
246 - * @param string $title
247 - *
248 - * @return void
249 - */
250 - public static function admin_page_title($title = '')
251 - {
252 - $title = isset($title) && !empty($title) ? $title : WP_ADMINIFY;
253 - echo esc_html($title);
254 -
255 - if (is_multisite()) {
256 - $text = ' | ' . esc_html__('Current Blog ID', 'adminify') . ': ' . get_current_blog_id(); ?>
257 - <?php echo self::wp_kses_custom(self::admin_page_subtitle($text)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_kses_custom() is a wp_kses() wrapper; output already escaped. ?>
258 - <?php } ?>
259 - <?php
260 - }
261 -
262 - /**
263 - * Get Current Admin Subtitle
264 - */
265 -
266 - public static function admin_page_subtitle($text)
267 - {
268 - ?>
269 - <span style="color:#8b959e;" <?php
270 - if (is_rtl()) {
271 - echo ' dir="rtl"';
272 - }
273 - ?>>
274 - <?php echo esc_html($text); ?>
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( $disabled_for )
53 + {
54 + if ( empty($disabled_for) ) {
55 + return false;
56 + }
57 + if ( !function_exists( 'wp_get_current_user' ) ) {
58 + include ABSPATH . 'wp-includes/pluggable.php';
59 + }
60 + $restrict_for = array();
61 +
62 + if ( !is_array( $disabled_for ) ) {
63 + $restrict_for[] = $disabled_for;
64 + } else {
65 + $restrict_for = $disabled_for;
66 + }
67 +
68 + $current_user = wp_get_current_user();
69 + $current_name = $current_user->display_name;
70 + $current_roles = $current_user->roles;
71 + // $all_roles = wp_roles()->get_names();
72 + if ( in_array( $current_name, $restrict_for ) ) {
73 + return true;
74 + }
75 + // Super Admin for Multisite
76 + if ( is_super_admin() && is_multisite() ) {
77 +
78 + if ( in_array( 'Super Admin', $restrict_for ) || in_array( 'administrator', $restrict_for ) ) {
79 + return true;
80 + } else {
81 + return false;
82 + }
83 +
84 + }
85 + $formattedroles = [];
86 + foreach ( $restrict_for as $item ) {
87 + $item = ( is_string( $item ) ? strtolower( $item ) : $item );
88 + $item = ( is_string( $item ) ? str_replace( ' ', '_', $item ) : $item );
89 + array_push( $formattedroles, $item );
90 + }
91 + foreach ( $current_roles as $role ) {
92 + // $role_name = $all_roles[$role];
93 + if ( in_array( $role, $restrict_for ) ) {
94 + return true;
95 + }
96 + }
97 + }
98 +
99 + /**
100 + * Check Site wide plugin settings
101 + */
102 + public static function is_site_wide( $plugin )
103 + {
104 + if ( !is_multisite() ) {
105 + return false;
106 + }
107 + $plugins = get_site_option( 'active_sitewide_plugins' );
108 + if ( isset( $plugins[$plugin] ) ) {
109 + return true;
110 + }
111 + return false;
112 + }
113 +
114 + /**
115 + * Restricts for role / user
116 + */
117 + public static function restrict_for( $disabled_for )
118 + {
119 + if ( !is_array( $disabled_for ) ) {
120 + return false;
121 + }
122 + require_once ABSPATH . '/wp-includes/pluggable.php';
123 + if ( !function_exists( 'wp_get_current_user' ) ) {
124 + return false;
125 + }
126 + $current_user = wp_get_current_user();
127 + $current_name = $current_user->display_name;
128 + $current_roles = $current_user->roles;
129 + $formattedroles = [];
130 + foreach ( $disabled_for as $item ) {
131 + $item = strtolower( $item );
132 + $item = str_replace( ' ', '_', $item );
133 + array_push( $formattedroles, $item );
134 + }
135 + if ( in_array( $current_name, $disabled_for ) ) {
136 + return true;
137 + }
138 + foreach ( $current_roles as $role ) {
139 + if ( in_array( $role, $formattedroles ) ) {
140 + return true;
141 + }
142 + }
143 + }
144 +
145 + // Get Taxonomies
146 + public static function get_taxonomies()
147 + {
148 + $args = [
149 + 'public' => true,
150 + 'show_ui' => true,
151 + ];
152 + $output = 'objects';
153 + $taxonomies = get_taxonomies( $args, $output );
154 + $taxonomies = $taxonomies;
155 + return $taxonomies;
156 + }
157 +
158 + // Get Post Types
159 + public static function get_post_types()
160 + {
161 + $args = [
162 + 'public' => true,
163 + 'show_ui' => true,
164 + ];
165 + $output = 'objects';
166 + $post_types = get_post_types( $args, $output );
167 + $post_types = $post_types;
168 + return $post_types;
169 + }
170 +
171 + // Get Post Meta
172 + public static function post_meta( $meta_key )
173 + {
174 + $meta_key = get_post_meta( get_the_ID(), $meta_key, true );
175 + return $meta_key;
176 + }
177 +
178 + // verfiy current page id
179 + public static function jltwp_adminify_currentpage_id( $id )
180 + {
181 + if ( !function_exists( 'get_current_screen' ) ) {
182 + return true;
183 + }
184 + $screen = get_current_screen();
185 + return is_object( $screen ) && $screen->id == $id;
186 + }
187 +
188 + /**
189 + * Get Current Admin Page Title
190 + *
191 + * @param string $title
192 + *
193 + * @return void
194 + */
195 + public static function admin_page_title( $title = '' )
196 + {
197 + $title = ( isset( $title ) && !empty($title) ? $title : WP_ADMINIFY );
198 + echo esc_html( $title ) ;
199 +
200 + if ( is_multisite() ) {
201 + $text = ' | ' . esc_html__( 'Current Blog ID', 'adminify' ) . ': ' . get_current_blog_id();
202 + ?>
203 + <?php
204 + echo self::wp_kses_custom( self::admin_page_subtitle( $text ) ) ;
205 + ?>
206 + <?php
207 + }
208 +
209 + ?>
210 + <?php
211 + }
212 +
213 + /**
214 + * Get Current Admin Subtitle
215 + */
216 + public static function admin_page_subtitle( $text )
217 + {
218 + ?>
219 + <span style="color:#8b959e;" <?php
220 + if ( is_rtl() ) {
221 + echo ' dir="rtl"' ;
222 + }
223 + ?>>
224 + <?php
225 + echo esc_html( $text ) ;
226 + ?>
275 227 </span>
276 228
277 - <?php
278 - }
279 -
280 - public static function convert_name_to_class($name)
281 - {
282 - $class = str_replace([' ', ',', '.', '"', "'", '/', '\\', '+', '=', ')', '(', '*', '&', '^', '%', '$', '#', '@', '!', '~', '`', '<', '>', '?', '[', ']', '{', '}', '|', ':'], '', $name);
283 - return $class;
284 - }
285 -
286 - public static function jltwp_adminify_class_cleanup($string)
287 - {
288 - // Lower case everything
289 - $string = strtolower($string);
290 - // Make alphanumeric (removes all other characters)
291 - $string = preg_replace('/[^a-z0-9_\s-]/', '', $string);
292 - // Clean up multiple dashes or whitespaces
293 - $string = preg_replace('/[\s-]+/', ' ', $string);
294 - // Convert whitespaces and underscore to dash
295 - $string = preg_replace('/[\s_]/', '-', $string);
296 - return $string;
297 - }
298 -
299 - public static function sanitize_id($url)
300 - {
301 - $url = preg_replace('/^customize.php\?return=.*$/', 'customize', $url);
302 - $url = preg_replace('/(&|&amp;|&#038;)?_wpnonce=([^&]+)/', '', $url);
303 - return str_replace(['.php', '.', '/', '?', '='], ['', '_', '_', '_', '_'], $url);
304 - }
305 -
306 - /**
307 - * Strip tags and it's content from the given string.
308 - *
309 - * @link https://stackoverflow.com/questions/14684077/remove-all-html-tags-from-php-string/#answer-39320168
310 - *
311 - * @param string $text The string being stripped.
312 - * @return string The stripped string.
313 - */
314 - public static function strip_tags_content($text)
315 - {
316 - $cleanup = preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text);
317 - $cleanup = wp_strip_all_tags($cleanup);
318 - $cleanup = trim($cleanup);
319 -
320 - return $cleanup;
321 - }
322 -
323 - /**
324 - * String to ID
325 - * Remove Space replace with underscore and lowercase
326 - *
327 - * @param void
328 - *
329 - * @return string
330 - */
331 - public static function string_to_id($string)
332 - {
333 - $string_replace = str_replace(' ', '_', $string);
334 - $formatted_string = strtolower($string_replace);
335 - return $formatted_string;
336 - }
337 -
338 - /**
339 - * ID to String
340 - * Remove Space replace with underscore and lowercase
341 - *
342 - * @param void
343 - *
344 - * @return string
345 - */
346 - public static function id_to_string($string)
347 - {
348 - $string_replace = str_replace('_', ' ', $string);
349 - $formatted_string = ucwords($string_replace);
350 - return $formatted_string;
351 - }
352 -
353 - /**
354 - * Check is Plugin Active
355 - *
356 - * @param [type] $plugin_path
357 - *
358 - * @return boolean
359 - */
360 - public static function is_plugin_active( $plugin_path )
361 - {
362 - if (!function_exists('is_plugin_active')) {
363 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
364 - }
365 - return is_plugin_active( $plugin_path );
366 - }
367 -
368 - /**
369 - * Check if Block Editor Page
370 - *
371 - * @return boolean
372 - */
373 - public static function is_block_editor_page() {
374 - if (function_exists('get_current_screen')) {
375 - $current_screen = get_current_screen();
376 - if (!empty($current_screen->is_block_editor)) {
377 - return true;
378 - }
379 - }
380 - return false;
381 - }
382 -
383 - /**
384 - * Check is Plugin Active
385 - *
386 - * @param [type] $plugin_path
387 - *
388 - * @return boolean
389 - */
390 - public static function is_plugin_installed_and_active($plugin_path)
391 - {
392 - // Check if the plugin is active
393 - if (is_plugin_active($plugin_path)) {
394 - return true; // Plugin is both installed and active
395 - } else {
396 - return false; // Plugin is either not installed or not active
397 - }
398 - }
399 -
400 - public static function is_plugin_installed($plugin_slug, $plugin_file)
401 - {
402 - $installed_plugins = get_plugins();
403 - return isset($installed_plugins[$plugin_file]);
404 - }
405 -
406 - public static function jltwp_adminify_notification_bar()
407 - {
408 - $plugin_slug = 'adminify-notification-bar';
409 - $plugin_file = 'adminify-notification-bar/adminify-notification-bar.php';
410 - $addons_page_url = network_admin_url('admin.php?page=wp-adminify-settings-addons');
411 -
412 - // $addons_download_link = jltwp_adminify()->_get_latest_download_local_url(14434);
413 -
414 - $html = '';
415 - if (self::is_plugin_installed($plugin_slug, $plugin_file)) {
416 - if (!current_user_can('install_plugins')) {
417 - return;
418 - }
419 -
420 - if (!self::is_plugin_active($plugin_file)) {
421 - $activation_url = wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin_file);
422 - $html .= '<a class="wp-adminify-addons-download addon-active" href="' . $activation_url . '" ><span class="pr-1">' . esc_html__('Activate', 'adminify') . '</span><i class="dashicons dashicons-yes-alt"></i></a>';
423 - }
424 - } else {
425 - // $install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_slug), 'install-plugin_' . $plugin_slug);
426 - $html = '<a class="wp-adminify-addons-download addon-download" href="' . $addons_page_url . '"><span class="wp-adminify-addons-download-text">' . esc_html__('Download', 'adminify') . '</span><i class="dashicons dashicons-download"></i></a>';
427 -
428 - activate_plugin($plugin_file);
429 - }
430 -
431 - $html_content = '<div class="adminify-title">
432 - <h4>' . esc_html__('Notification Bar', 'adminify') . '</h4>
433 - <div class="adminify-subtitle-text">' . esc_html__('Cookie Notice, Promotional Bar on frontend', 'adminify') . '</div>
434 - </div>
435 - <div class="adminify-fieldset">
436 - <div class="adminify--addons" style="width: 100px;">
437 - ' . wp_kses_post($html) . '
438 - </div>
439 - </div>
440 - <div class="clear"></div>';
441 -
442 - echo wp_kses_post($html_content);
443 - }
444 -
445 -
446 - /**
447 - * User Defined Settings
448 - */
449 -
450 - public static function get_user_preference($key)
451 - {
452 - $userid = get_current_user_id();
453 - $current = get_user_meta($userid, '_wpadminify_preferences', true);
454 - $value = false;
455 -
456 - if (is_array($current)) {
457 - if (isset($current[$key])) {
458 - $value = $current[$key];
459 - }
460 - }
461 -
462 - return $value;
463 - }
464 -
465 - /**
466 - * Sanitises and strips tags of input from ajax
467 - *
468 - * @since 1.0.0
469 - * @variables $values = item to clean (array or string)
470 - */
471 - public static function clean_ajax_input($values)
472 - {
473 - if (is_array($values)) {
474 - foreach ($values as $index => $in) {
475 - if (is_array($in)) {
476 - $values[$index] = self::clean_ajax_input($in);
477 - } else {
478 - $values[$index] = wp_strip_all_tags($in);
479 - }
480 - }
481 - } else {
482 - $values = wp_strip_all_tags($values);
483 - }
484 -
485 - return $values;
486 - }
487 -
488 - /**
489 - * Check Ajax Error Messages
490 - *
491 - * @param [type] $message
492 - *
493 - * @return void
494 - */
495 - public static function ajax_error_message($message)
496 - {
497 - $returndata = [];
498 - $returndata['error'] = true;
499 - $returndata['error_message'] = $message;
500 - return json_encode($returndata);
501 - }
502 -
503 - /**
504 - * Get All Updates
505 - * Themes, Plugins, Core etc
506 - *
507 - * @return void
508 - */
509 - public static function get_all_updates()
510 - {
511 - $allupdates = [];
512 - $allupdates['total'] = 0;
513 - $allupdates['wordpress'] = 0;
514 - $allupdates['theme'] = 0;
515 - $allupdates['plugin'] = 0;
516 -
517 - if (!is_admin()) {
518 - return $allupdates;
519 - }
520 -
521 - if (!current_user_can('install_plugins')) {
522 - return $allupdates;
523 - }
524 - $updatesTotal = 0;
525 - if (is_super_admin() && is_admin()) {
526 - $pluginUpdates = get_plugin_updates();
527 - $themeUpdates = get_theme_updates();
528 - $wpUpdates = get_core_updates();
529 -
530 - if (isset($wpUpdates[0])) {
531 - $wpversion = $wpUpdates[0]->version;
532 - global $wp_version;
533 -
534 - if ($wpversion > $wp_version) {
535 - $wpUpdates = 1;
536 - } else {
537 - $wpUpdates = 0;
538 - }
539 - } else {
540 - $wpUpdates = 0;
541 - }
542 -
543 - $updatesTotal = count($pluginUpdates) + count($themeUpdates) + $wpUpdates;
544 -
545 - $allupdates['total'] = $updatesTotal;
546 - $allupdates['wordpress'] = $wpUpdates;
547 - $allupdates['theme'] = $themeUpdates;
548 - $allupdates['plugin'] = $pluginUpdates;
549 - }
550 - return $allupdates;
551 - }
552 -
553 -
554 - /**
555 - * Upgrade Pro Icon
556 - *
557 - * @return void
558 - */
559 - public static function jltwp_adminify_upgrade_pro_icon()
560 - {
561 - 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">
562 - <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="#000"/>
229 + <?php
230 + }
231 +
232 + public static function convert_name_to_class( $name )
233 + {
234 + $class = str_replace( [
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 + ']',
261 + '{',
262 + '}',
263 + '|',
264 + ':'
265 + ], '', $name );
266 + return $class;
267 + }
268 +
269 + public static function jltwp_adminify_class_cleanup( $string )
270 + {
271 + // Lower case everything
272 + $string = strtolower( $string );
273 + // Make alphanumeric (removes all other characters)
274 + $string = preg_replace( '/[^a-z0-9_\\s-]/', '', $string );
275 + // Clean up multiple dashes or whitespaces
276 + $string = preg_replace( '/[\\s-]+/', ' ', $string );
277 + // Convert whitespaces and underscore to dash
278 + $string = preg_replace( '/[\\s_]/', '-', $string );
279 + return $string;
280 + }
281 +
282 + public static function sanitize_id( $url )
283 + {
284 + $url = preg_replace( '/^customize.php\\?return=.*$/', 'customize', $url );
285 + $url = preg_replace( '/(&|&amp;|&#038;)?_wpnonce=([^&]+)/', '', $url );
286 + return str_replace( [
287 + '.php',
288 + '.',
289 + '/',
290 + '?',
291 + '='
292 + ], [
293 + '',
294 + '_',
295 + '_',
296 + '_',
297 + '_'
298 + ], $url );
299 + }
300 +
301 + /**
302 + * Strip tags and it's content from the given string.
303 + *
304 + * @link https://stackoverflow.com/questions/14684077/remove-all-html-tags-from-php-string/#answer-39320168
305 + *
306 + * @param string $text The string being stripped.
307 + * @return string The stripped string.
308 + */
309 + public static function strip_tags_content( $text )
310 + {
311 + $cleanup = preg_replace( '@<(\\w+)\\b.*?>.*?</\\1>@si', '', $text );
312 + $cleanup = wp_strip_all_tags( $cleanup );
313 + $cleanup = trim( $cleanup );
314 + return $cleanup;
315 + }
316 +
317 + /**
318 + * String to ID
319 + * Remove Space replace with underscore and lowercase
320 + *
321 + * @param void
322 + *
323 + * @return string
324 + */
325 + public static function string_to_id( $string )
326 + {
327 + $string_replace = str_replace( ' ', '_', $string );
328 + $formatted_string = strtolower( $string_replace );
329 + return $formatted_string;
330 + }
331 +
332 + /**
333 + * ID to String
334 + * Remove Space replace with underscore and lowercase
335 + *
336 + * @param void
337 + *
338 + * @return string
339 + */
340 + public static function id_to_string( $string )
341 + {
342 + $string_replace = str_replace( '_', ' ', $string );
343 + $formatted_string = ucwords( $string_replace );
344 + return $formatted_string;
345 + }
346 +
347 + /**
348 + * Check is Plugin Active
349 + *
350 + * @param [type] $plugin_basename
351 + *
352 + * @return boolean
353 + */
354 + public static function is_plugin_active( $plugin_basename )
355 + {
356 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
357 + return is_plugin_active( $plugin_basename );
358 + }
359 +
360 + /**
361 + * User Defined Settings
362 + */
363 + public static function get_user_preference( $key )
364 + {
365 + $userid = get_current_user_id();
366 + $current = get_user_meta( $userid, '_wpadminify_preferences', true );
367 + $value = false;
368 + if ( is_array( $current ) ) {
369 + if ( isset( $current[$key] ) ) {
370 + $value = $current[$key];
371 + }
372 + }
373 + return $value;
374 + }
375 +
376 + /**
377 + * Sanitises and strips tags of input from ajax
378 + *
379 + * @since 1.0.0
380 + * @variables $values = item to clean (array or string)
381 + */
382 + public static function clean_ajax_input( $values )
383 + {
384 +
385 + if ( is_array( $values ) ) {
386 + foreach ( $values as $index => $in ) {
387 +
388 + if ( is_array( $in ) ) {
389 + $values[$index] = self::clean_ajax_input( $in );
390 + } else {
391 + $values[$index] = strip_tags( $in );
392 + }
393 +
394 + }
395 + } else {
396 + $values = strip_tags( $values );
397 + }
398 +
399 + return $values;
400 + }
401 +
402 + /**
403 + * Check Ajax Error Messages
404 + *
405 + * @param [type] $message
406 + *
407 + * @return void
408 + */
409 + public static function ajax_error_message( $message )
410 + {
411 + $returndata = [];
412 + $returndata['error'] = true;
413 + $returndata['error_message'] = $message;
414 + return json_encode( $returndata );
415 + }
416 +
417 + /**
418 + * Get All Updates
419 + * Themes, Plugins, Core etc
420 + *
421 + * @return void
422 + */
423 + public static function get_all_updates()
424 + {
425 + $allupdates = [];
426 + $allupdates['total'] = 0;
427 + $allupdates['wordpress'] = 0;
428 + $allupdates['theme'] = 0;
429 + $allupdates['plugin'] = 0;
430 + if ( !is_admin() ) {
431 + return $allupdates;
432 + }
433 + if ( !current_user_can( 'install_plugins' ) ) {
434 + return $allupdates;
435 + }
436 + $updatesTotal = 0;
437 +
438 + if ( is_super_admin() && is_admin() ) {
439 + $pluginUpdates = get_plugin_updates();
440 + $themeUpdates = get_theme_updates();
441 + $wpUpdates = get_core_updates();
442 +
443 + if ( isset( $wpUpdates[0] ) ) {
444 + $wpversion = $wpUpdates[0]->version;
445 + global $wp_version ;
446 +
447 + if ( $wpversion > $wp_version ) {
448 + $wpUpdates = 1;
449 + } else {
450 + $wpUpdates = 0;
451 + }
452 +
453 + } else {
454 + $wpUpdates = 0;
455 + }
456 +
457 + $updatesTotal = count( $pluginUpdates ) + count( $themeUpdates ) + $wpUpdates;
458 + $allupdates['total'] = $updatesTotal;
459 + $allupdates['wordpress'] = $wpUpdates;
460 + $allupdates['theme'] = $themeUpdates;
461 + $allupdates['plugin'] = $pluginUpdates;
462 + }
463 +
464 + return $allupdates;
465 + }
466 +
467 + public static function adminfiy_help_urls(
468 + $module_name = '',
469 + $docs = '',
470 + $youtube = '',
471 + $facebook_grp = '',
472 + $support = ''
473 + )
474 + {
475 + $help_content = '';
476 + // Modules
477 +
478 + if ( empty($module_name) ) {
479 + $module_name = 'Module';
480 + } else {
481 + $module_name = $module_name;
482 + }
483 +
484 + // Docs
485 +
486 + if ( empty($docs) ) {
487 + $docs = 'https://wpadminify.com/kb';
488 + } else {
489 + $docs = $docs;
490 + }
491 +
492 + // youtube
493 +
494 + if ( empty($youtube) ) {
495 + $youtube = 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8';
496 + } else {
497 + $youtube = $youtube;
498 + }
499 +
500 + // facebook_grp
501 +
502 + if ( empty($facebook_grp) ) {
503 + $facebook_grp = 'https://www.facebook.com/groups/jeweltheme';
504 + } else {
505 + $facebook_grp = $facebook_grp;
506 + }
507 +
508 + // Support
509 +
510 + if ( empty($support) ) {
511 + $support = 'https://wpadminify.com/support/wp-adminify';
512 + } else {
513 + $support = $support;
514 + }
515 +
516 + $help_content = sprintf(
517 + __( '%1$s <a class="adminify-docs-url" href="%2$s" target="_blank"> ' . self::docs_icon() . ' Docs</a>
518 + <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' ),
519 + $module_name,
520 + $docs,
521 + $youtube,
522 + $facebook_grp,
523 + $support
524 + );
525 + return $help_content;
526 + }
527 +
528 + /**
529 + * Upgrade Pro Icon
530 + *
531 + * @return void
532 + */
533 + public static function jltwp_adminify_upgrade_pro_icon()
534 + {
535 + 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">
536 + <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"/>
563 537 </svg>';
564 - }
565 -
566 -
567 - // Upgrade to Pro Notice
568 - public static function adminify_upgrade_pro_img_notice( $image ){
569 - return '<div class="adminify-pro-notice"><img src="' . esc_url_raw($image ) . '" /></div>';
570 - }
571 -
572 - // Upgrade to Pro Notice Class
573 - public static function upgrade_pro_class($classname = '')
574 - {
575 - if(empty($classname)){
576 - // return ' adminify-depend-visible adminify-depend-on adminify-pro-notice ';
577 - return ' adminify-pro-feature adminify-pro-notice';
578 - } else {
579 - echo esc_attr($classname);
580 - }
581 - }
582 -
583 - // Upgrade to Pro Notice
584 - public static function adminify_upgrade_pro($custom_message = '', $style='')
585 - {
586 -
587 - if (empty($custom_message)) {
588 - $pro_content = '<strong>' . __('(Upgrade to Pro)', 'adminify') . '</strong>';
589 - } else {
590 - $pro_content = $custom_message;
591 - }
592 -
593 - if($style === 'inline'){
594 - return '<strong style="font-size:16px;">' . $pro_content . '</strong>';
595 - }
596 -
597 - $upgrade_notice_msg = sprintf(
598 - '<div class="adminify-pro-notice adminify-missing-addons"> %1$s %2$s </div>',
599 - self::jltwp_adminify_upgrade_pro_icon(),
600 - self::wp_kses_custom($pro_content)
601 - );
602 - return self::wp_kses_custom($upgrade_notice_msg);
603 - }
604 -
605 -
606 -
607 - /**
608 - * Documentation SVG Icon
609 - */
610 - public static function docs_icon()
611 - {
612 - 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">
538 + }
539 +
540 + // Upgrade to Pro Notice
541 + public static function adminify_upgrade_pro( $custom_message = '' )
542 + {
543 +
544 + if ( empty($custom_message) ) {
545 + $pro_content = sprintf( __( 'Get <strong>Pro Version</strong> to Unlock this feature.', 'adminify' ) );
546 + } else {
547 + $pro_content = $custom_message;
548 + }
549 +
550 + $upgrade_notice_msg = sprintf(
551 + __( '<div class="adminify-pro-notice"> %1$s <p> %2$s <a href="%3$s" target="_blank">%4$s</a> </p></div>', 'adminify' ),
552 + self::jltwp_adminify_upgrade_pro_icon(),
553 + self::wp_kses_custom( $pro_content ),
554 + esc_url( 'https://wpadminify.com/pricing' ),
555 + __( 'Upgrade to Pro Now!', 'adminify' )
556 + );
557 + return self::wp_kses_custom( $upgrade_notice_msg );
558 + }
559 +
560 + /**
561 + * Documentation SVG Icon
562 + */
563 + public static function docs_icon()
564 + {
565 + 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">
613 566 <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"/>
614 567 </svg>';
615 - }
616 - /**
617 - * Video Tutorials SVG Icon
618 - */
619 - public static function video_tutorials_icon()
620 - {
621 - 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">
568 + }
569 +
570 + /**
571 + * Video Tutorials SVG Icon
572 + */
573 + public static function video_tutorials_icon()
574 + {
575 + 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">
622 576 <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"/>
623 577 </svg>';
624 - }
625 -
626 - /**
627 - * Facebook Group SVG Icon
628 - */
629 - public static function fbgroup_icon()
630 - {
631 - 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">
578 + }
579 +
580 + /**
581 + * Facebook Group SVG Icon
582 + */
583 + public static function fbgroup_icon()
584 + {
585 + 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">
632 586 <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"/>
633 587 </svg>';
634 - }
635 -
636 - /**
637 - * Support SVG Icon
638 - */
639 - public static function support_icon()
640 - {
641 - 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">
588 + }
589 +
590 + /**
591 + * Support SVG Icon
592 + */
593 + public static function support_icon()
594 + {
595 + 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">
642 596 <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"/>
643 597 </svg>';
644 - }
645 -
646 - /* White Label Upgrade Pro */
647 - public static function jltwp_adminify_white_label_upgrade()
648 - {
649 - ?>
598 + }
599 +
600 + /* White Label Upgrade Pro */
601 + public static function jltwp_adminify_white_label_upgrade()
602 + {
603 + ?>
650 604 <div class="wp-adminify-white-label-notice-content">
651 605 <div class="wp-adminify-white-label-notice-logo">
652 - <img src="<?php echo esc_url(WP_ADMINIFY_ASSETS_IMAGE) . 'logos/logo-text-light.svg'; ?>" alt="<?php echo esc_attr(WP_ADMINIFY); ?>">
606 + <img src="<?php
607 + echo esc_url( WP_ADMINIFY_ASSETS_IMAGE ) . 'logos/logo-text-light.svg' ;
608 + ?>" alt="<?php
609 + echo esc_attr( WP_ADMINIFY ) ;
610 + ?>">
653 611 </div>
654 612 <h2>
655 - <?php echo wp_kses_post( sprintf(__('Upgrade <span>Pro</span> for White Labeling', 'adminify')) ); ?>
613 + <?php
614 + echo sprintf( __( 'Upgrade <span>Pro</span> for White Labeling', 'adminify' ) ) ;
615 + ?>
656 616 </h2>
657 617 <p>
658 - <?php
659 - /* translators: %s: Plugin name */
660 - echo wp_kses_post( 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)) );
661 - ?>
618 + <?php
619 + 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 ) ) ;
620 + ?>
662 621 <br>
663 - <em><?php esc_html_e('Note: Agency or Higher Plans Only', 'adminify'); ?></em>
622 + <em><?php
623 + esc_html_e( 'Note: Agency or Higher Plans Only', 'adminify' );
624 + ?></em>
664 625 </p>
665 - <a class="wp-adminify-btn wp-adminify-get-pro" href="<?php echo esc_url('https://wpadminify.com/pricing/'); ?>" target="_blank">
666 - <?php esc_html_e('Upgrade Now', 'adminify'); ?>
626 + <a class="wp-adminify-btn wp-adminify-get-pro" href="<?php
627 + echo esc_url( 'https://wpadminify.com/pricing/' ) ;
628 + ?>" target="_blank">
629 + <?php
630 + esc_html_e( 'Upgrade Now', 'adminify' );
631 + ?>
667 632 </a>
668 633 </div>
669 -<?php
670 - }
634 +<?php
635 + }
636 +
637 + public static function get_widget_template_options()
638 + {
639 + $type = 'widget';
640 + $page_templates = self::jltwp_adminify_get_page_templates( $type );
641 + $options[-1] = __( 'Select', 'adminify' );
642 +
643 + if ( count( $page_templates ) ) {
644 + foreach ( $page_templates as $id => $name ) {
645 + $options[$id] = $name;
646 + }
647 + } else {
648 + $options['no_template'] = __( 'No saved templates found!', 'adminify' );
649 + }
650 +
651 + return $options;
652 + }
653 +
654 + public static function get_section_template_options()
655 + {
656 + $type = 'section';
657 + $page_templates = self::jltwp_adminify_get_page_templates( $type );
658 + $options[-1] = __( 'Select', 'adminify' );
659 +
660 + if ( count( $page_templates ) ) {
661 + foreach ( $page_templates as $id => $name ) {
662 + $options[$id] = $name;
663 + }
664 + } else {
665 + $options['no_template'] = __( 'No saved templates found!', 'adminify' );
666 + }
667 +
668 + return $options;
669 + }
670 +
671 + public static function get_page_template_options()
672 + {
673 + $type = 'page';
674 + $page_templates = self::jltwp_adminify_get_page_templates( $type );
675 + $options[-1] = __( 'Select', 'adminify' );
676 +
677 + if ( count( $page_templates ) ) {
678 + foreach ( $page_templates as $id => $name ) {
679 + $options[$id] = $name;
680 + }
681 + } else {
682 + $options['no_template'] = __( 'No saved templates found!', 'adminify' );
683 + }
684 +
685 + return $options;
686 + }
687 +
688 + public static function get_theme_presets( $theme = null )
689 + {
690 + $presets = [
691 + 'preset1' => [
692 + '--adminify-preset-background' => '#F9F9F9',
693 + '--adminify-menu-bg' => '#ffffff',
694 + '--adminify-menu-text-color' => 'rgba(78, 75, 102, 0.72)',
695 + '--adminify-admin-bar-bg' => 'var(--adminify-menu-bg)',
696 + '--adminify-admin-bar-icon' => '#14142B',
697 + '--adminify-admin-bar-input-bg' => '#F1F1F3',
698 + '--adminify-admin-bar-input-text' => '#14142B',
699 + '--adminify-admin-bar-icon-brightness' => '1',
700 + '--adminify-notif-bg-color' => '#FF1C69',
701 + '--adminify-text-color' => '#ffffff',
702 + '--adminify-btn-bg' => '#0347FF',
703 + '--adminify-admin-bar-icon-filter' => '0.5',
704 + ],
705 + 'preset2' => [
706 + '--adminify-preset-background' => '#F9F9F9',
707 + '--adminify-menu-bg' => '#14142B',
708 + '--adminify-menu-text-color' => '#ffffff',
709 + '--adminify-admin-bar-bg' => 'var(--adminify-menu-bg)',
710 + '--adminify-admin-bar-icon' => '#ffffff',
711 + '--adminify-admin-bar-input-bg' => '#2b2a3f',
712 + '--adminify-admin-bar-input-text' => '#9391A0',
713 + '--adminify-admin-bar-icon-brightness' => '11',
714 + '--adminify-notif-bg-color' => '#FF1C69',
715 + '--adminify-text-color' => '#ffffff',
716 + '--adminify-btn-bg' => '#0347FF',
717 + '--adminify-admin-bar-icon-filter' => '1',
718 + ],
719 + ];
720 + // return all presets
721 + if ( is_null( $theme ) ) {
722 + return $presets;
723 + }
724 + // return specific preset
725 + if ( array_key_exists( $theme, $presets ) ) {
726 + return $presets[$theme];
727 + }
728 + // specific preset not found
729 + return [];
730 + }
731 +
732 + public static function jltwp_adminify_get_page_templates( $type = '' )
733 + {
734 + $args = [
735 + 'post_type' => 'elementor_library',
736 + 'posts_per_page' => -1,
737 + ];
738 + if ( $type ) {
739 + $args['tax_query'] = [ [
740 + 'taxonomy' => 'elementor_library_type',
741 + 'field' => 'slug',
742 + 'terms' => $type,
743 + ] ];
744 + }
745 + $page_templates = get_posts( $args );
746 + $options = [];
747 + if ( !empty($page_templates) && !is_wp_error( $page_templates ) ) {
748 + foreach ( $page_templates as $post ) {
749 + $options[$post->ID] = $post->post_title;
750 + }
751 + }
752 + return $options;
753 + }
754 +
755 + public static function assets_ext( $ext )
756 + {
757 + if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
758 + return $ext;
759 + }
760 + return '.min' . $ext;
761 + }
762 +
763 + public static function wp_kses_atts_map( array $attrs )
764 + {
765 + return array_fill_keys( array_values( $attrs ), true );
766 + }
767 +
768 + public static function wp_kses_custom( $content )
769 + {
770 + $allowed_tags = wp_kses_allowed_html( 'post' );
771 + $custom_tags = [
772 + 'select' => self::wp_kses_atts_map( [
773 + 'class',
774 + 'id',
775 + 'style',
776 + 'width',
777 + 'height',
778 + 'title',
779 + 'data',
780 + 'name',
781 + 'autofocus',
782 + 'disabled',
783 + 'multiple',
784 + 'required',
785 + 'size'
786 + ] ),
787 + 'input' => self::wp_kses_atts_map( [
788 + 'class',
789 + 'id',
790 + 'style',
791 + 'width',
792 + 'height',
793 + 'title',
794 + 'data',
795 + 'name',
796 + 'autofocus',
797 + 'disabled',
798 + 'required',
799 + 'size',
800 + 'type',
801 + 'checked',
802 + 'readonly',
803 + 'placeholder',
804 + 'value',
805 + 'maxlength',
806 + 'min',
807 + 'max',
808 + 'multiple',
809 + 'pattern',
810 + 'step',
811 + 'autocomplete'
812 + ] ),
813 + 'textarea' => self::wp_kses_atts_map( [
814 + 'class',
815 + 'id',
816 + 'style',
817 + 'width',
818 + 'height',
819 + 'title',
820 + 'data',
821 + 'name',
822 + 'autofocus',
823 + 'disabled',
824 + 'required',
825 + 'rows',
826 + 'cols',
827 + 'wrap',
828 + 'maxlength'
829 + ] ),
830 + 'option' => self::wp_kses_atts_map( [
831 + 'class',
832 + 'id',
833 + 'label',
834 + 'disabled',
835 + 'label',
836 + 'selected',
837 + 'value'
838 + ] ),
839 + 'optgroup' => self::wp_kses_atts_map( [
840 + 'disabled',
841 + 'label',
842 + 'class',
843 + 'id'
844 + ] ),
845 + 'form' => self::wp_kses_atts_map( [
846 + 'class',
847 + 'id',
848 + 'data',
849 + 'style',
850 + 'width',
851 + 'height',
852 + 'accept-charset',
853 + 'action',
854 + 'autocomplete',
855 + 'enctype',
856 + 'method',
857 + 'name',
858 + 'novalidate',
859 + 'rel',
860 + 'target'
861 + ] ),
862 + 'svg' => self::wp_kses_atts_map( [
863 + 'class',
864 + 'xmlns',
865 + 'viewbox',
866 + 'width',
867 + 'height',
868 + 'fill',
869 + 'aria-hidden',
870 + 'aria-labelledby',
871 + 'role'
872 + ] ),
873 + 'rect' => self::wp_kses_atts_map( [
874 + 'rx',
875 + 'width',
876 + 'height',
877 + 'fill'
878 + ] ),
879 + 'path' => self::wp_kses_atts_map( [ 'd', 'fill' ] ),
880 + 'g' => self::wp_kses_atts_map( [ 'fill' ] ),
881 + 'defs' => self::wp_kses_atts_map( [ 'fill' ] ),
882 + 'linearGradient' => self::wp_kses_atts_map( [
883 + 'id',
884 + 'x1',
885 + 'x2',
886 + 'y1',
887 + 'y2',
888 + 'gradientUnits'
889 + ] ),
890 + 'stop' => self::wp_kses_atts_map( [ 'stop-color', 'offset', 'stop-opacity' ] ),
891 + 'style' => self::wp_kses_atts_map( [ 'type' ] ),
892 + 'div' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
893 + 'ul' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
894 + 'li' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
895 + 'label' => self::wp_kses_atts_map( [ 'class', 'for' ] ),
896 + 'span' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
897 + 'h1' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
898 + 'h2' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
899 + 'h3' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
900 + 'h4' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
901 + 'h5' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
902 + 'h6' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
903 + 'a' => self::wp_kses_atts_map( [
904 + 'class',
905 + 'href',
906 + 'target',
907 + 'rel'
908 + ] ),
909 + 'p' => self::wp_kses_atts_map( [
910 + 'class',
911 + 'id',
912 + 'style',
913 + 'data'
914 + ] ),
915 + 'table' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
916 + 'thead' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
917 + 'tbody' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
918 + 'tr' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
919 + 'th' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
920 + 'td' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
921 + 'i' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
922 + 'button' => self::wp_kses_atts_map( [ 'class', 'id' ] ),
923 + 'nav' => self::wp_kses_atts_map( [ 'class', 'id', 'style' ] ),
924 + 'time' => self::wp_kses_atts_map( [ 'datetime' ] ),
925 + 'br' => [],
926 + 'strong' => [],
927 + 'style' => [],
928 + 'img' => self::wp_kses_atts_map( [
929 + 'class',
930 + 'src',
931 + 'alt',
932 + 'height',
933 + 'width',
934 + 'srcset',
935 + 'id',
936 + 'loading'
937 + ] ),
938 + ];
939 + $allowed_tags = array_merge_recursive( $allowed_tags, $custom_tags );
940 + return wp_kses( stripslashes_deep( $content ), $allowed_tags );
941 + }
671 942
672 -
673 - public static function get_widget_template_options()
674 - {
675 - $type = 'widget';
676 - $page_templates = self::jltwp_adminify_get_page_templates($type);
677 -
678 - $options[-1] = __('Select', 'adminify');
679 -
680 - if (count($page_templates)) {
681 - foreach ($page_templates as $id => $name) {
682 - $options[$id] = $name;
683 - }
684 - } else {
685 - $options['no_template'] = __('No saved templates found!', 'adminify');
686 - }
687 -
688 - return $options;
689 - }
690 -
691 - public static function get_section_template_options()
692 - {
693 - $type = 'section';
694 - $page_templates = self::jltwp_adminify_get_page_templates($type);
695 -
696 - $options[-1] = __('Select', 'adminify');
697 -
698 - if (count($page_templates)) {
699 - foreach ($page_templates as $id => $name) {
700 - $options[$id] = $name;
701 - }
702 - } else {
703 - $options['no_template'] = __('No saved templates found!', 'adminify');
704 - }
705 -
706 - return $options;
707 - }
708 -
709 - public static function get_page_template_options()
710 - {
711 - $type = 'page';
712 - $page_templates = self::jltwp_adminify_get_page_templates($type);
713 -
714 - $options[-1] = __('Select', 'adminify');
715 -
716 - if (count($page_templates)) {
717 - foreach ($page_templates as $id => $name) {
718 - $options[$id] = $name;
719 - }
720 - } else {
721 - $options['no_template'] = __('No saved templates found!', 'adminify');
722 - }
723 -
724 - return $options;
725 - }
726 -
727 - /**
728 - * Common preset CSS variables (padding / sizing / typography
729 - * defaults) shared by every theme preset and by the Pro
730 - * custom-color preset path. Extracted so the Pro filter
731 - * (Pro/Classes/OutputCSS_Body_Pro::build_custom_color_preset())
732 - * can reuse the same defaults instead of re-declaring them.
733 - *
734 - * @return array<string,string>
735 - */
736 - public static function get_common_preset_vars()
737 - {
738 - return [
739 - '--adminify-menu-vertical-padding' => '10px',
740 - '--adminify-menu-horizontal-padding' => '8px',
741 - '--adminify-menu-wrapper-padding-top' => '16px',
742 - '--adminify-menu-wrapper-padding-right' => '8px',
743 - '--adminify-menu-wrapper-padding-bottom' => '16px',
744 - '--adminify-menu-wrapper-padding-left' => '8px',
745 - '--adminify-submenu-vertical-padding' => '4px',
746 - '--adminify-submenu-wrapper-padding-top' => '8px',
747 - '--adminify-submenu-wrapper-padding-right' => '0px',
748 - '--adminify-submenu-wrapper-padding-bottom' => '8px',
749 - '--adminify-submenu-wrapper-padding-left' => '28px',
750 - '--adminify-menu-font-size' => '13px',
751 - '--adminify-menu-line-height' => '20px',
752 - '--adminify-menu-letter-spacing' => '',
753 - '--adminify-menu-width' => '260px',
754 - ];
755 - }
756 -
757 - public static function get_theme_presets($theme = null)
758 - {
759 -
760 - $common_var = self::get_common_preset_vars();
761 -
762 - $presets = [
763 -
764 - // Base/ Default Preset
765 - 'preset1' => [
766 - '--adminify-preset-background' => '#F9F9F9',
767 - '--adminify-primary' => '#3a3ae9',
768 - // '--adminify-text-color' => '#ffffff',
769 - '--adminify-menu-border' => '#dedee7',
770 - '--adminify-menu-bg' => '#ffffff',
771 - '--adminify-menu-hover-bg' => '#3a3ae9',
772 - '--adminify-menu-text-color' => '#48455f',
773 - '--adminify-menu-text-hover-color' => '#ffffff',
774 - '--adminify-menu-active-bg' => '#3a3ae9',
775 - '--adminify-menu-active-color' => '#ffffff',
776 - '--adminify-submenu-wrapper-bg' => '#ffffff',
777 - '--adminify-submenu-hover-bg' => 'transparent',
778 - '--adminify-submenu-text-color' => '#48455f',
779 - '--adminify-submenu-text-hover-color' => '#3a3ae9',
780 - '--adminify-submenu-active-bg' => 'transparent',
781 - '--adminify-submenu-active-color' => '#3a3ae9',
782 - '--adminify-notif-bg-color' => '#3a3ae9',
783 - '--adminify-notif-color' => '#ffffff',
784 - ],
785 -
786 - 'preset2' => [
787 - '--adminify-preset-background' => '#F9F9F9',
788 - '--adminify-primary' => '#0347FF',
789 - '--adminify-notif-bg-color' => '#FF1C69',
790 - // '--adminify-text-color' => '#ffffff',
791 - '--adminify-menu-border' => '#404052',
792 - '--adminify-menu-bg' => '#14142B',
793 - '--adminify-menu-hover-bg' => '#0347FF',
794 - '--adminify-menu-text-color' => '#ffffff',
795 - '--adminify-menu-text-hover-color' => '#ffffff',
796 - '--adminify-menu-active-bg' => '#0347FF',
797 - '--adminify-menu-active-color' => '#ffffff',
798 - '--adminify-submenu-wrapper-bg' => '#14142B',
799 - '--adminify-submenu-hover-bg' => 'transparent',
800 - '--adminify-submenu-text-color' => '#ffffff',
801 - '--adminify-submenu-text-hover-color' => '#0347FF',
802 - '--adminify-submenu-active-bg' => 'transparent',
803 - '--adminify-submenu-active-color' => '#0347FF',
804 - '--adminify-notif-bg-color' => '#0347FF',
805 - '--adminify-notif-color' => '#ffffff',
806 - ],
807 - ];
808 -
809 - $pro_presets = apply_filters('adminify_settings/color_presets', $common_var);
810 -
811 - if( !empty(array_key_exists('preset3', $pro_presets)) ) {
812 - $presets = array_merge($presets, $pro_presets);
813 - }
814 -
815 - // Merge $common_var variable with every preset
816 - foreach ($presets as $key => $value) {
817 - $presets[$key] = array_merge($value, $common_var);
818 - }
819 -
820 - // return all presets
821 - if (is_null($theme)) {
822 - return $presets;
823 - }
824 -
825 - // return specific preset
826 - if (array_key_exists($theme, $presets)) {
827 - return $presets[$theme];
828 - }
829 -
830 - // specific preset not found
831 - return [];
832 - }
833 -
834 - public static function jltwp_adminify_get_page_templates($type = '')
835 - {
836 - $args = [
837 - 'post_type' => 'elementor_library',
838 - 'posts_per_page' => -1,
839 - ];
840 -
841 - if ($type) {
842 - $args['tax_query'] = [
843 - [
844 - 'taxonomy' => 'elementor_library_type',
845 - 'field' => 'slug',
846 - 'terms' => $type,
847 - ],
848 - ];
849 - }
850 -
851 - $page_templates = get_posts($args);
852 -
853 - $options = [];
854 -
855 - if (!empty($page_templates) && !is_wp_error($page_templates)) {
856 - foreach ($page_templates as $post) {
857 - $options[$post->ID] = $post->post_title;
858 - }
859 - }
860 - return $options;
861 - }
862 -
863 - public static function assets_ext($ext)
864 - {
865 - if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
866 - return $ext;
867 - }
868 - return '.min' . $ext;
869 - }
870 -
871 - public static function wp_kses_atts_map(array $attrs)
872 - {
873 - return array_fill_keys(array_values($attrs), true);
874 - }
875 -
876 - public static function wp_kses_custom($content)
877 - {
878 - /**
879 - * the context can be different
880 - * The context for which to retrieve tags. Allowed values are 'post', 'strip', 'data', 'entities', or the name of a field filter such as 'pre_user_description', or an array of allowed HTML elements and attributes.
881 - * the post means here it will return all the tags that are allowed in post such as a, p, strong, em etc
882 - */
883 - $allowed_tags = wp_kses_allowed_html('post'); // Details : https://developer.wordpress.org/reference/functions/wp_kses_allowed_html/
884 - if( !is_array($allowed_tags) ) $allowed_tags = [];
885 -
886 - $custom_tags = [
887 - 'select' => self::wp_kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'multiple', 'required', 'size']),
888 - 'input' => self::wp_kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'required', 'size', 'type', 'checked', 'readonly', 'placeholder', 'value', 'maxlength', 'min', 'max', 'multiple', 'pattern', 'step', 'autocomplete']),
889 - 'textarea' => self::wp_kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'required', 'rows', 'cols', 'wrap', 'maxlength']),
890 - 'option' => self::wp_kses_atts_map(['class', 'id', 'label', 'disabled', 'label', 'selected', 'value']),
891 - 'optgroup' => self::wp_kses_atts_map(['disabled', 'label', 'class', 'id']),
892 - 'form' => self::wp_kses_atts_map(['class', 'id', 'data', 'style', 'width', 'height', 'accept-charset', 'action', 'autocomplete', 'enctype', 'method', 'name', 'novalidate', 'rel', 'target']),
893 - 'svg' => self::wp_kses_atts_map(['class', 'xmlns', 'viewbox', 'width', 'height', 'fill', 'aria-hidden', 'aria-labelledby', 'role']),
894 - 'rect' => self::wp_kses_atts_map(['rx', 'width', 'height', 'fill']),
895 - 'path' => self::wp_kses_atts_map(['d', 'fill']),
896 - 'g' => self::wp_kses_atts_map(['fill']),
897 - 'defs' => self::wp_kses_atts_map(['fill']),
898 - 'linearGradient' => self::wp_kses_atts_map(['id', 'x1', 'x2', 'y1', 'y2', 'gradientUnits']),
899 - 'stop' => self::wp_kses_atts_map(['stop-color', 'offset', 'stop-opacity']),
900 - 'style' => self::wp_kses_atts_map(['type']),
901 - 'div' => self::wp_kses_atts_map(['class', 'id', 'style']),
902 - 'ul' => self::wp_kses_atts_map(['class', 'id', 'style']),
903 - 'li' => self::wp_kses_atts_map(['class', 'id', 'style']),
904 - 'label' => self::wp_kses_atts_map(['class', 'for']),
905 - 'span' => self::wp_kses_atts_map(['class', 'id', 'style']),
906 - 'h1' => self::wp_kses_atts_map(['class', 'id', 'style']),
907 - 'h2' => self::wp_kses_atts_map(['class', 'id', 'style']),
908 - 'h3' => self::wp_kses_atts_map(['class', 'id', 'style']),
909 - 'h4' => self::wp_kses_atts_map(['class', 'id', 'style']),
910 - 'h5' => self::wp_kses_atts_map(['class', 'id', 'style']),
911 - 'h6' => self::wp_kses_atts_map(['class', 'id', 'style']),
912 - 'a' => self::wp_kses_atts_map(['class', 'href', 'target', 'rel']),
913 - 'p' => self::wp_kses_atts_map(['class', 'id', 'style', 'data']),
914 - 'table' => self::wp_kses_atts_map(['class', 'id', 'style']),
915 - 'thead' => self::wp_kses_atts_map(['class', 'id', 'style']),
916 - 'tbody' => self::wp_kses_atts_map(['class', 'id', 'style']),
917 - 'tr' => self::wp_kses_atts_map(['class', 'id', 'style']),
918 - 'th' => self::wp_kses_atts_map(['class', 'id', 'style']),
919 - 'td' => self::wp_kses_atts_map(['class', 'id', 'style']),
920 - 'i' => self::wp_kses_atts_map(['class', 'id', 'style']),
921 - 'button' => self::wp_kses_atts_map(['class', 'id']),
922 - 'nav' => self::wp_kses_atts_map(['class', 'id', 'style']),
923 - 'time' => self::wp_kses_atts_map(['datetime']),
924 - 'br' => [],
925 - 'strong' => [],
926 - 'style' => [],
927 - 'img' => self::wp_kses_atts_map(['class', 'src', 'alt', 'height', 'width', 'srcset', 'id', 'loading']),
928 - ];
929 -
930 - $allowed_tags = array_merge_recursive($allowed_tags, $custom_tags);
931 -
932 - return wp_kses(stripslashes_deep($content), $allowed_tags);
933 - }
934 -
935 -
936 - /**
937 - * Missing Addon/Plugin Notice
938 - *
939 - * @param [type] $args
940 - *
941 - * @return void
942 - */
943 - public static function missing_plugin_notice( $plugin_name = '' )
944 - {
945 - $missing_plugin_notice = sprintf(
946 - /* translators: 1: Plugin name, 2: Addons/plugins admin page URL, 3: "Install Now" link text */
947 - __('<strong>"%1$s"</strong> plugin is not Activated! Please install and activate <strong>%1$s</strong> Plugin <p> <a class="adminify-missing-addons" href="%2$s">%3$s</a></p>', 'adminify'),
948 - esc_html($plugin_name),
949 - admin_url('admin.php?page=wp-adminify-addons-plugins'),
950 - __('Install Now', 'adminify')
951 - );
952 - return '<div class="adminify-missing-addons">' . self::jltwp_adminify_upgrade_pro_icon() . self::wp_kses_custom( $missing_plugin_notice ) . '</div>';
953 - }
954 -
955 -
956 - /**
957 - * Update Existing Data to New Options data
958 - *
959 - * @param [type] $get_option_value
960 - * @param [type] $update_option_value
961 - * @param [type] $option_name
962 - *
963 - * @return void
964 - */
965 - public static function update_options($get_option_value, $option_name)
966 - {
967 -
968 - // Retrieve the current option value
969 - $current_value = get_option($option_name);
970 - // $current_value = self::$option_data;
971 - // Initialize the current value if it's empty
972 - if (empty($current_value)) {
973 - $current_value = [];
974 - }
975 - // If $get_option_value is provided, use it to update the current value
976 - if (!empty($get_option_value)) {
977 - // Ensure current value is an array before merging
978 - if (!is_array($current_value)) {
979 - $current_value = [];
980 - }
981 - // Merge the provided value into the current value
982 - $current_value = array_merge($current_value, $get_option_value);
983 - }
984 - // Update the specific key within the option with the new value
985 - // $current_value[$option_key] = $update_option_value;
986 -
987 - // Update the option with the new value
988 - update_option($option_name, $current_value);
989 - // Optionally, return the updated value
990 - return get_option($option_name);
991 - }
992 -
993 -
994 - /**
995 - * Replace Array Keys
996 - *
997 - * @return void
998 - */
999 - public static function replace_keys($sourceArray, $newArray){
1000 - $new_value = [];
1001 - if( ! is_array($sourceArray)) $sourceArray = [];
1002 - foreach ($newArray as $key => $value) {
1003 - if (!array_key_exists($key, $sourceArray)) {
1004 - return $sourceArray;
1005 - }
1006 - $new_value[$value] = $sourceArray[$key];
1007 - unset($sourceArray[$key]);
1008 - }
1009 - return array_merge($sourceArray, $new_value);
1010 - }
1011 -
1012 -
1013 - /**
1014 - * Move Array Keys
1015 - *
1016 - * @return void
1017 - */
1018 - public static function move_keys(&$sourceArray, $keysToMove)
1019 - {
1020 - $destinationArray = [];
1021 - foreach ($keysToMove as $key) {
1022 - if (array_key_exists($key, $sourceArray)) {
1023 - $destinationArray[$key] = $sourceArray[$key];
1024 - unset($sourceArray[$key]);
1025 - }
1026 - }
1027 - return $destinationArray;
1028 - }
1029 -
1030 -
1031 - /**
1032 - * Remove unnecessary keys.
1033 - *
1034 - * @param string $option_name The name of the option.
1035 - * @param array $keys_to_remove An array of keys to remove.
1036 - */
1037 - public static function removeKeys($sourceArray, $keysToRemove)
1038 - {
1039 - foreach ($keysToRemove as $key) {
1040 - if (array_key_exists($key, $sourceArray)) {
1041 - unset($sourceArray[$key]);
1042 - }
1043 - }
1044 - return $sourceArray;
1045 - }
1046 -
1047 -
1048 -
1049 - /**
1050 - * Move Nested Keys
1051 - *
1052 - * @return void
1053 - */
1054 - public static function moveNestedKeys(&$sourceArray, $moveInstructions) {
1055 - $destinationArray = [];
1056 - foreach ($moveInstructions as $sourcePath => $destPath) {
1057 - $sourcePathArray = explode('.', $sourcePath);
1058 - $destPathArray = explode('.', $destPath);
1059 - $sourceValue = self::getNestedValue($sourceArray, $sourcePathArray);
1060 - if ($sourceValue !== null) {
1061 - self::setNestedValue($destinationArray, $destPathArray, $sourceValue);
1062 - self::unsetNestedValue($sourceArray, $sourcePathArray);
1063 - }
1064 - }
1065 -
1066 - return array_merge_recursive($sourceArray, $destinationArray);
1067 - }
1068 -
1069 - public static function getNestedValue(&$array, $pathArray) {
1070 - $value = &$array;
1071 - foreach ($pathArray as $key) {
1072 - if (is_array($value) && array_key_exists($key, $value)) {
1073 - $value = &$value[$key];
1074 - } else {
1075 - return null;
1076 - }
1077 - }
1078 - return $value;
1079 - }
1080 -
1081 - public static function setNestedValue(&$array, $pathArray, $value) {
1082 - $temp = &$array;
1083 - foreach ($pathArray as $key) {
1084 - if (!isset($temp[$key])) {
1085 - $temp[$key] = [];
1086 - }
1087 - $temp = &$temp[$key];
1088 - }
1089 - $temp = $value;
1090 - }
1091 -
1092 - public static function unsetNestedValue(&$array, $pathArray) {
1093 - $temp = &$array;
1094 - foreach ($pathArray as $key) {
1095 - if (isset($temp[$key])) {
1096 - if (count($pathArray) === 1) {
1097 - unset($temp[$key]);
1098 - } else {
1099 - self::unsetNestedValue($temp[$key], array_slice($pathArray, 1));
1100 - }
1101 - return;
1102 - }
1103 - }
1104 - }
1105 -
1106 -
1107 -
1108 - /**
1109 - *
1110 - * Checkbox Method
1111 - */
1112 - public static function checkboxes(&$old_db, $checkbox_keys) {
1113 - $result = [];
1114 - $parentKey = "";
1115 - $childKey = "";
1116 -
1117 - $thirdStep = [];
1118 -
1119 - foreach ($checkbox_keys as $key => $value) {
1120 -
1121 - $sourceArray = explode(".", $value);
1122 -
1123 - foreach ($sourceArray as $x => $element) {
1124 - if (!array_key_exists($element, $result) && $x === 0) {
1125 - $parentKey = $element;
1126 - if (count($sourceArray) === 3) {
1127 - $result[$element] = [];
1128 - } else {
1129 - $result[$element] = [];
1130 - }
1131 - }
1132 -
1133 -
1134 - if ($x === 1 && !empty($old_db[$key])) {
1135 - $childKey = $element;
1136 - if (count($sourceArray) === 3) {
1137 - $result[$parentKey][$element] = [];
1138 - } else {
1139 - $result[$parentKey][] = $element;
1140 - }
1141 - } elseif ($x === 1 && empty($old_db[$key]) && count($sourceArray) === 3) {
1142 - $childKey = $element;
1143 - if (!array_key_exists($element, $result[$parentKey])) {
1144 - $result[$parentKey][$element] = [];
1145 - }
1146 - }
1147 -
1148 - if ($x === 2 && !empty($old_db[$key]) && count($sourceArray) === 3) {
1149 - $thirdStep[] = $element;
1150 - $result[$parentKey][$childKey] = $thirdStep;
1151 - }
1152 - }
1153 - }
1154 -
1155 - return array_merge_recursive($old_db, $result);
1156 - }
1157 -
1158 - /**
1159 - * Inline "Upgrade to Pro" marker rendered next to a checkbox option
1160 - * label in the free build.
1161 - *
1162 - * Returns the rocket-icon + (Upgrade to Pro) span the settings UI
1163 - * has rendered historically. The
1164 - * Inc/Admin/AdminSettings::adminify_render_pro_locked_field() handler
1165 - * detects this span inside a checkbox <li> and strips name= + sets
1166 - * disabled on the enclosed input so the locked option cannot submit
1167 - * a value.
1168 - *
1169 - * Returns an empty string when the Pro plugin is active so the Pro
1170 - * UI is unchanged.
1171 - */
1172 - public static function adminify_upgrade_pro_class($inline_badge = false){
1173 - if (function_exists('jltwp_adminify') && jltwp_adminify()->can_use_premium_code__premium_only()) {
1174 - return '';
1175 - }
1176 - if (!empty($inline_badge)){
1177 - return '<span class="adminify-pro-checkbox adminify-pro-badge adminify-pro-notice">Pro</span>';
1178 - }
1179 - return '<span class="adminify-pro-checkbox">' . self::jltwp_adminify_upgrade_pro_icon() . ' <strong>(Upgrade to Pro)</strong>' . '</span>';
1180 - }
1181 -
1182 - /**
1183 - * Inline "Pro" badge rendered next to a field title in the free
1184 - * build.
1185 - *
1186 - * Returns the legacy <span class="adminify-pro-badge">Pro</span>
1187 - * markup. The render handler detects fields whose class list
1188 - * contains adminify-pro-fieldset / -feature / -notice (the
1189 - * Pro-style classes used alongside this badge) and neutralises
1190 - * the inputs at render time.
1191 - *
1192 - * Returns an empty string when the Pro plugin is active.
1193 - */
1194 - public static function adminify_upgrade_pro_badge($badge_text = 'Pro'){
1195 - if (function_exists('jltwp_adminify') && jltwp_adminify()->can_use_premium_code__premium_only()) {
1196 - return '';
1197 - }
1198 - if (!empty($badge_text)){
1199 - return '<span class="adminify-pro-badge">' . esc_html($badge_text) . '</span>';
1200 - }
1201 - return '';
1202 - }
1203 -
1204 - /*
1205 - * Compares the version of WordPress running to the $version specified.
1206 - * Usage: Utils::check_wp_version('>=', '4.0')
1207 - version_compare( $wp_version, '4.3', '>=' )
1208 - * @param string $operator
1209 - * @param string $version
1210 - * @returns boolean
1211 - */
1212 - public static function check_wp_version( $operator = '>', $version = '6.6' ) {
1213 - global $wp_version;
1214 - return version_compare( $wp_version, $version, $operator );
1215 - }
1216 -
1217 - public static function adminfiy_help_urls($module_name = '', $docs = '', $youtube = '', $facebook_grp = '', $support = '')
1218 - {
1219 - $help_content = '';
1220 -
1221 - // Modules
1222 - if (empty($module_name)) {
1223 - $module_name = '';
1224 - } else {
1225 - $module_name = $module_name;
1226 - }
1227 -
1228 - $help_content_urls = '';
1229 -
1230 - // Docs
1231 - if (!empty($docs)) {
1232 - $help_content_urls .= '<a class="adminify-tag adminify-tag-purple adminify-docs-url" href="' . esc_url( $docs ) . '" target="_blank"> ' . self::docs_icon() . ' Docs</a>';
1233 - }
1234 -
1235 - // youtube
1236 - if (!empty($youtube)) {
1237 - $help_content_urls .= '<a class="adminify-tag adminify-tag-danger adminify-video-url" href="' . esc_url( $youtube ) . '" target="_blank">' . self::video_tutorials_icon() . ' Video Tutorial</a>';
1238 - }
1239 -
1240 - // facebook_grp
1241 - if (!empty($facebook_grp)) {
1242 - $help_content_urls .= '<a class="adminify-tag adminify-tag-primary adminify-fbgroup-url" href="' . esc_url($facebook_grp) . '" target="_blank">' . self::fbgroup_icon() . ' Facebook Group</a>';
1243 - }
1244 -
1245 - // Support
1246 - if ( !empty($support)) {
1247 - $help_content_urls .= '<a class="adminify-tag adminify-tag-secondary adminify-support-url" href="' . esc_url($support) . '" target="_blank">' . self::support_icon() . ' Support</a>';
1248 - }
1249 -
1250 - $help_content = sprintf( '%1$s <div class="adminify-helps">%2$s</div>', $module_name, $help_content_urls );
1251 - return $help_content;
1252 - }
1253 -
1254 -}
943 +}