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