PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0
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 +140 -307 4.2.144.0 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2
3 -namespace PXLBSAdminify\Inc;
3 +namespace WPAdminify\Inc;
4 4
5 +use ReturnTypeWillChange;
6 +use WPAdminify\Inc\Classes\Helper;
5 7 // no direct access allowed
6 8 if (!defined('ABSPATH')) {
7 9 exit;
8 10 }
@@ -41,9 +43,9 @@
41 43 }
42 44
43 45
44 46 /**
45 - * Check hidden for roles or not
47 + * Check hidden for rules or not
46 48 *
47 49 * @param [type] $value
48 50 *
49 51 * @return bool
@@ -53,15 +55,10 @@
53 55 if (empty($disabled_for)) {
54 56 return false;
55 57 }
56 58
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 59 if (!function_exists('wp_get_current_user')) {
63 - return false;
60 + include ABSPATH . 'wp-includes/pluggable.php';
64 61 }
65 62
66 63 $restrict_for = array();
67 64
@@ -75,16 +72,12 @@
75 72 $current_user = wp_get_current_user();
76 73 $current_name = $current_user->display_name;
77 74 $current_roles = $current_user->roles;
78 75 // $all_roles = wp_roles()->get_names();
79 -
76 +
80 77 if (in_array($current_name, $restrict_for)) {
81 78 return true;
82 79 }
83 -
84 - // if (in_array('Super Admin', $restrict_for) || in_array('administrator', $restrict_for)) {
85 - // return true;
86 - // }
87 80
88 81 // Super Admin for Multisite
89 82 if (is_super_admin() && is_multisite()) {
90 83 if (in_array('Super Admin', $restrict_for) || in_array('administrator', $restrict_for)) {
@@ -160,16 +153,13 @@
160 153 if (!is_array($disabled_for)) {
161 154 return false;
162 155 }
163 156
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.
157 + require_once ABSPATH . '/wp-includes/pluggable.php';
158 +
168 159 if (!function_exists('wp_get_current_user')) {
169 160 return false;
170 161 }
171 -
172 162 $current_user = wp_get_current_user();
173 163 $current_name = $current_user->display_name;
174 164 $current_roles = $current_user->roles;
175 165
@@ -227,9 +217,9 @@
227 217 }
228 218
229 219
230 220 // verfiy current page id
231 - public static function currentpage_id($id)
221 + public static function jltwp_adminify_currentpage_id($id)
232 222 {
233 223 if (!function_exists('get_current_screen')) {
234 224 return true;
235 225 }
@@ -246,14 +236,14 @@
246 236 * @return void
247 237 */
248 238 public static function admin_page_title($title = '')
249 239 {
250 - $title = isset($title) && !empty($title) ? $title : PXLBSADMINIFY;
240 + $title = isset($title) && !empty($title) ? $title : WP_ADMINIFY;
251 241 echo esc_html($title);
252 242
253 243 if (is_multisite()) {
254 244 $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. ?>
245 + <?php echo self::wp_kses_custom(self::admin_page_subtitle($text)); ?>
256 246 <?php } ?>
257 247 <?php
258 248 }
259 249
@@ -280,9 +270,9 @@
280 270 $class = str_replace([' ', ',', '.', '"', "'", '/', '\\', '+', '=', ')', '(', '*', '&', '^', '%', '$', '#', '@', '!', '~', '`', '<', '>', '?', '[', ']', '{', '}', '|', ':'], '', $name);
281 271 return $class;
282 272 }
283 273
284 - public static function class_cleanup($string)
274 + public static function jltwp_adminify_class_cleanup($string)
285 275 {
286 276 // Lower case everything
287 277 $string = strtolower($string);
288 278 // Make alphanumeric (removes all other characters)
@@ -356,11 +346,9 @@
356 346 * @return boolean
357 347 */
358 348 public static function is_plugin_active( $plugin_path )
359 349 {
360 - if (!function_exists('is_plugin_active')) {
361 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
362 - }
350 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
363 351 return is_plugin_active( $plugin_path );
364 352 }
365 353
366 354 /**
@@ -400,9 +388,9 @@
400 388 $installed_plugins = get_plugins();
401 389 return isset($installed_plugins[$plugin_file]);
402 390 }
403 391
404 - public static function notification_bar()
392 + public static function jltwp_adminify_notification_bar()
405 393 {
406 394 $plugin_slug = 'adminify-notification-bar';
407 395 $plugin_file = 'adminify-notification-bar/adminify-notification-bar.php';
408 396 $addons_page_url = network_admin_url('admin.php?page=wp-adminify-settings-addons');
@@ -447,9 +435,9 @@
447 435
448 436 public static function get_user_preference($key)
449 437 {
450 438 $userid = get_current_user_id();
451 - $current = get_user_meta($userid, 'pxlbsadminify_preferences', true);
439 + $current = get_user_meta($userid, '_wpadminify_preferences', true);
452 440 $value = false;
453 441
454 442 if (is_array($current)) {
455 443 if (isset($current[$key])) {
@@ -472,13 +460,13 @@
472 460 foreach ($values as $index => $in) {
473 461 if (is_array($in)) {
474 462 $values[$index] = self::clean_ajax_input($in);
475 463 } else {
476 - $values[$index] = wp_strip_all_tags($in);
464 + $values[$index] = strip_tags($in);
477 465 }
478 466 }
479 467 } else {
480 - $values = wp_strip_all_tags($values);
468 + $values = strip_tags($values);
481 469 }
482 470
483 471 return $values;
484 472 }
@@ -494,9 +482,9 @@
494 482 {
495 483 $returndata = [];
496 484 $returndata['error'] = true;
497 485 $returndata['error_message'] = $message;
498 - return wp_json_encode($returndata);
486 + return json_encode($returndata);
499 487 }
500 488
501 489 /**
502 490 * Get All Updates
@@ -547,15 +535,51 @@
547 535 }
548 536 return $allupdates;
549 537 }
550 538
539 + public static function adminfiy_help_urls($module_name = '', $docs = '', $youtube = '', $facebook_grp = '', $support = '')
540 + {
541 + $help_content = '';
551 542
543 + // Modules
544 + if (empty($module_name)) {
545 + $module_name = '';
546 + } else {
547 + $module_name = $module_name;
548 + }
549 +
550 + $help_content_urls = '';
551 +
552 + // Docs
553 + if (!empty($docs)) {
554 + $help_content_urls .= '<a class="adminify-tag adminify-tag-purple adminify-docs-url" href="' . esc_url( $docs ) . '" target="_blank"> ' . self::docs_icon() . ' Docs</a>';
555 + }
556 +
557 + // youtube
558 + if (!empty($youtube)) {
559 + $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>';
560 + }
561 +
562 + // facebook_grp
563 + if (!empty($facebook_grp)) {
564 + $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>';
565 + }
566 +
567 + // Support
568 + if ( !empty($support)) {
569 + $help_content_urls .= '<a class="adminify-tag adminify-tag-secondary adminify-support-url" href="' . esc_url($support) . '" target="_blank">' . self::support_icon() . ' Support</a>';
570 + }
571 +
572 + $help_content = sprintf( __('%1$s <div class="adminify-helps">%2$s</div>', 'adminify' ), $module_name, $help_content_urls );
573 + return $help_content;
574 + }
575 +
552 576 /**
553 577 * Upgrade Pro Icon
554 578 *
555 - * @return string
579 + * @return void
556 580 */
557 - public static function upgrade_pro_icon()
581 + public static function jltwp_adminify_upgrade_pro_icon()
558 582 {
559 583 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 584 <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 585 </svg>';
@@ -562,29 +586,29 @@
562 586 }
563 587
564 588
565 589 // Upgrade to Pro Notice
566 - public static function upgrade_pro_img_notice( $image ){
590 + public static function adminify_upgrade_pro_img_notice( $image ){
567 591 return '<div class="adminify-pro-notice"><img src="' . esc_url_raw($image ) . '" /></div>';
568 592 }
569 593
570 594 // Upgrade to Pro Notice Class
571 - public static function upgrade_pro_notice_class($notice = '')
595 + public static function upgrade_pro_class($classname = '')
572 596 {
573 - if(empty($notice)){
597 + if(empty($classname)){
574 598 // return ' adminify-depend-visible adminify-depend-on adminify-pro-notice ';
575 599 return ' adminify-pro-feature adminify-pro-notice';
576 600 } else {
577 - echo esc_attr($notice);
601 + echo esc_attr($classname);
578 602 }
579 603 }
580 604
581 605 // Upgrade to Pro Notice
582 - public static function upgrade_pro_notice($custom_message = '', $style='')
606 + public static function adminify_upgrade_pro($custom_message = '', $style='')
583 607 {
584 608
585 609 if (empty($custom_message)) {
586 - $pro_content = '<strong>' . __('(Upgrade to Pro)', 'adminify') . '</strong>';
610 + $pro_content = sprintf(__('<strong>(Upgrade to Pro)</strong>', 'adminify'));
587 611 } else {
588 612 $pro_content = $custom_message;
589 613 }
590 614
@@ -591,14 +615,14 @@
591 615 if($style === 'inline'){
592 616 return '<strong style="font-size:16px;">' . $pro_content . '</strong>';
593 617 }
594 618
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)
619 + $upgrade_notice_msg = sprintf(
620 + __('<div class="adminify-pro-notice"> %1$s %2$s </div>', 'adminify'),
621 + self::jltwp_adminify_upgrade_pro_icon(),
622 + self::wp_kses_custom($pro_content)
599 623 );
600 - return self::kses_custom($upgrade_notice_msg);
624 + return self::wp_kses_custom($upgrade_notice_msg);
601 625 }
602 626
603 627
604 628
@@ -641,22 +665,21 @@
641 665 </svg>';
642 666 }
643 667
644 668 /* White Label Upgrade Pro */
645 - public static function white_label_upgrade()
669 + public static function jltwp_adminify_white_label_upgrade()
646 670 {
647 671 ?>
648 672 <div class="wp-adminify-white-label-notice-content">
649 673 <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); ?>">
674 + <img src="<?php echo esc_url(WP_ADMINIFY_ASSETS_IMAGE) . 'logos/logo-text-light.svg'; ?>" alt="<?php echo esc_attr(WP_ADMINIFY); ?>">
651 675 </div>
652 676 <h2>
653 - <?php echo wp_kses_post( sprintf(__('Upgrade <span>Pro</span> for White Labeling', 'adminify')) ); ?>
677 + <?php echo sprintf(__('Upgrade <span>Pro</span> for White Labeling', 'adminify')); ?>
654 678 </h2>
655 679 <p>
656 680 <?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)) );
681 + 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));
659 682 ?>
660 683 <br>
661 684 <em><?php esc_html_e('Note: Agency or Higher Plans Only', 'adminify'); ?></em>
662 685 </p>
@@ -670,9 +693,9 @@
670 693
671 694 public static function get_widget_template_options()
672 695 {
673 696 $type = 'widget';
674 - $page_templates = self::get_page_templates($type);
697 + $page_templates = self::jltwp_adminify_get_page_templates($type);
675 698
676 699 $options[-1] = __('Select', 'adminify');
677 700
678 701 if (count($page_templates)) {
@@ -688,9 +711,9 @@
688 711
689 712 public static function get_section_template_options()
690 713 {
691 714 $type = 'section';
692 - $page_templates = self::get_page_templates($type);
715 + $page_templates = self::jltwp_adminify_get_page_templates($type);
693 716
694 717 $options[-1] = __('Select', 'adminify');
695 718
696 719 if (count($page_templates)) {
@@ -706,9 +729,9 @@
706 729
707 730 public static function get_page_template_options()
708 731 {
709 732 $type = 'page';
710 - $page_templates = self::get_page_templates($type);
733 + $page_templates = self::jltwp_adminify_get_page_templates($type);
711 734
712 735 $options[-1] = __('Select', 'adminify');
713 736
714 737 if (count($page_templates)) {
@@ -721,22 +744,14 @@
721 744
722 745 return $options;
723 746 }
724 747
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()
748 + public static function get_theme_presets($theme = null)
735 749 {
736 - return [
750 +
751 + $common_var = [
737 752 '--adminify-menu-vertical-padding' => '10px',
738 - '--adminify-menu-horizontal-padding' => '8px',
753 + '--adminify-menu-horizontal-padding' => '8px',
739 754 '--adminify-menu-wrapper-padding-top' => '16px',
740 755 '--adminify-menu-wrapper-padding-right' => '8px',
741 756 '--adminify-menu-wrapper-padding-bottom' => '16px',
742 757 '--adminify-menu-wrapper-padding-left' => '8px',
@@ -744,20 +759,17 @@
744 759 '--adminify-submenu-wrapper-padding-top' => '8px',
745 760 '--adminify-submenu-wrapper-padding-right' => '0px',
746 761 '--adminify-submenu-wrapper-padding-bottom' => '8px',
747 762 '--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',
763 + // '--adminify-menu-text-align' => 'left',
764 + // '--adminify-menu-text-transform' => '',
765 + // '--adminify-menu-text-decoration' => 'none',
766 + '--adminify-menu-font-size' => '13px',
767 + '--adminify-menu-line-height' => '20px',
768 + '--adminify-menu-letter-spacing' => '',
769 + '--adminify-menu-width' => '260px'
752 770 ];
753 - }
754 771
755 - public static function get_theme_presets($theme = null)
756 - {
757 -
758 - $common_var = self::get_common_preset_vars();
759 -
760 772 $presets = [
761 773
762 774 // Base/ Default Preset
763 775 'preset1' => [
@@ -803,9 +815,9 @@
803 815 '--adminify-notif-color' => '#ffffff',
804 816 ],
805 817 ];
806 818
807 - $pro_presets = apply_filters('pxlbsadminify_settings/color_presets', $common_var);
819 + $pro_presets = apply_filters('adminify_settings/color_presets', $common_var);
808 820
809 821 if( !empty(array_key_exists('preset3', $pro_presets)) ) {
810 822 $presets = array_merge($presets, $pro_presets);
811 823 }
@@ -824,14 +836,13 @@
824 836 if (array_key_exists($theme, $presets)) {
825 837 return $presets[$theme];
826 838 }
827 839
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;
840 + // specific preset not found
841 + return [];
831 842 }
832 843
833 - public static function get_page_templates($type = '')
844 + public static function jltwp_adminify_get_page_templates($type = '')
834 845 {
835 846 $args = [
836 847 'post_type' => 'elementor_library',
837 848 'posts_per_page' => -1,
@@ -837,9 +848,9 @@
837 848 'posts_per_page' => -1,
838 849 ];
839 850
840 851 if ($type) {
841 - $args['tax_query'] = [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- intentional taxonomy filter on an admin-side query.
852 + $args['tax_query'] = [
842 853 [
843 854 'taxonomy' => 'elementor_library_type',
844 855 'field' => 'slug',
845 856 'terms' => $type,
@@ -866,112 +877,64 @@
866 877 }
867 878 return '.min' . $ext;
868 879 }
869 880
870 - public static function kses_atts_map(array $attrs)
881 + public static function wp_kses_atts_map(array $attrs)
871 882 {
872 883 return array_fill_keys(array_values($attrs), true);
873 884 }
874 885
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()
886 + public static function wp_kses_custom($content)
885 887 {
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 888 $allowed_tags = wp_kses_allowed_html('post');
916 - if( !is_array($allowed_tags) ) $allowed_tags = [];
917 889
918 890 $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']),
891 + 'select' => self::wp_kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'multiple', 'required', 'size']),
892 + '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']),
893 + 'textarea' => self::wp_kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'required', 'rows', 'cols', 'wrap', 'maxlength']),
894 + 'option' => self::wp_kses_atts_map(['class', 'id', 'label', 'disabled', 'label', 'selected', 'value']),
895 + 'optgroup' => self::wp_kses_atts_map(['disabled', 'label', 'class', 'id']),
896 + 'form' => self::wp_kses_atts_map(['class', 'id', 'data', 'style', 'width', 'height', 'accept-charset', 'action', 'autocomplete', 'enctype', 'method', 'name', 'novalidate', 'rel', 'target']),
897 + 'svg' => self::wp_kses_atts_map(['class', 'xmlns', 'viewbox', 'width', 'height', 'fill', 'aria-hidden', 'aria-labelledby', 'role']),
898 + 'rect' => self::wp_kses_atts_map(['rx', 'width', 'height', 'fill']),
899 + 'path' => self::wp_kses_atts_map(['d', 'fill']),
900 + 'g' => self::wp_kses_atts_map(['fill']),
901 + 'defs' => self::wp_kses_atts_map(['fill']),
902 + 'linearGradient' => self::wp_kses_atts_map(['id', 'x1', 'x2', 'y1', 'y2', 'gradientUnits']),
903 + 'stop' => self::wp_kses_atts_map(['stop-color', 'offset', 'stop-opacity']),
904 + 'style' => self::wp_kses_atts_map(['type']),
905 + 'div' => self::wp_kses_atts_map(['class', 'id', 'style']),
906 + 'ul' => self::wp_kses_atts_map(['class', 'id', 'style']),
907 + 'li' => self::wp_kses_atts_map(['class', 'id', 'style']),
908 + 'label' => self::wp_kses_atts_map(['class', 'for']),
909 + 'span' => self::wp_kses_atts_map(['class', 'id', 'style']),
910 + 'h1' => self::wp_kses_atts_map(['class', 'id', 'style']),
911 + 'h2' => self::wp_kses_atts_map(['class', 'id', 'style']),
912 + 'h3' => self::wp_kses_atts_map(['class', 'id', 'style']),
913 + 'h4' => self::wp_kses_atts_map(['class', 'id', 'style']),
914 + 'h5' => self::wp_kses_atts_map(['class', 'id', 'style']),
915 + 'h6' => self::wp_kses_atts_map(['class', 'id', 'style']),
916 + 'a' => self::wp_kses_atts_map(['class', 'href', 'target', 'rel']),
917 + 'p' => self::wp_kses_atts_map(['class', 'id', 'style', 'data']),
918 + 'table' => self::wp_kses_atts_map(['class', 'id', 'style']),
919 + 'thead' => self::wp_kses_atts_map(['class', 'id', 'style']),
920 + 'tbody' => self::wp_kses_atts_map(['class', 'id', 'style']),
921 + 'tr' => self::wp_kses_atts_map(['class', 'id', 'style']),
922 + 'th' => self::wp_kses_atts_map(['class', 'id', 'style']),
923 + 'td' => self::wp_kses_atts_map(['class', 'id', 'style']),
924 + 'i' => self::wp_kses_atts_map(['class', 'id', 'style']),
925 + 'button' => self::wp_kses_atts_map(['class', 'id']),
926 + 'nav' => self::wp_kses_atts_map(['class', 'id', 'style']),
927 + 'time' => self::wp_kses_atts_map(['datetime']),
956 928 'br' => [],
957 929 'strong' => [],
958 930 'style' => [],
959 - 'img' => self::kses_atts_map(['class', 'src', 'alt', 'height', 'width', 'srcset', 'id', 'loading']),
931 + 'img' => self::wp_kses_atts_map(['class', 'src', 'alt', 'height', 'width', 'srcset', 'id', 'loading']),
960 932 ];
961 933
962 - return array_merge_recursive($allowed_tags, $custom_tags);
963 - }
934 + $allowed_tags = array_merge_recursive($allowed_tags, $custom_tags);
964 935
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() );
936 + return wp_kses(stripslashes_deep($content), $allowed_tags);
974 937 }
975 938
976 939
977 940 /**
@@ -982,16 +945,16 @@
982 945 * @return void
983 946 */
984 947 public static function missing_plugin_notice( $plugin_name = '' )
985 948 {
949 + /* translators: %s: Plugin Name */
986 950 $missing_plugin_notice = sprintf(
987 - /* translators: 1: Plugin name, 2: Addons/plugins admin page URL, 3: "Install Now" link text */
988 951 __('<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 952 esc_html($plugin_name),
990 953 admin_url('admin.php?page=wp-adminify-addons-plugins'),
991 954 __('Install Now', 'adminify')
992 955 );
993 - return '<div class="adminify-missing-addons">' . self::upgrade_pro_icon() . self::kses_custom( $missing_plugin_notice ) . '</div>';
956 + return '<div class="adminify-missing-addons">' . self::jltwp_adminify_upgrade_pro_icon() . self::wp_kses_custom( $missing_plugin_notice ) . '</div>';
994 957 }
995 958
996 959
997 960 /**
@@ -1038,9 +1001,8 @@
1038 1001 * @return void
1039 1002 */
1040 1003 public static function replace_keys($sourceArray, $newArray){
1041 1004 $new_value = [];
1042 - if( ! is_array($sourceArray)) $sourceArray = [];
1043 1005 foreach ($newArray as $key => $value) {
1044 1006 if (!array_key_exists($key, $sourceArray)) {
1045 1007 return $sourceArray;
1046 1008 }
@@ -1195,62 +1157,21 @@
1195 1157
1196 1158 return array_merge_recursive($old_db, $result);
1197 1159 }
1198 1160
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)){
1161 + public static function adminify_upgrade_pro_class($inline_badge=false){
1162 + if(!empty($inline_badge)){
1218 1163 return '<span class="adminify-pro-checkbox adminify-pro-badge adminify-pro-notice">Pro</span>';
1219 1164 }
1220 - return '<span class="adminify-pro-checkbox">' . self::upgrade_pro_icon() . ' <strong>(Upgrade to Pro)</strong>' . '</span>';
1165 + return '<span class="adminify-pro-checkbox">' . self::jltwp_adminify_upgrade_pro_icon() . ' <strong>(Upgrade to Pro)</strong>' . '</span>';
1221 1166 }
1222 1167
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 '';
1168 + public static function adminify_upgrade_pro_badge($badge_text = 'Pro'){
1169 + if(!empty($badge_text)){
1170 + return '<span class="adminify-pro-badge">' . $badge_text . '</span>';
1238 1171 }
1239 - if (!empty($badge_text)){
1240 - return '<span class="adminify-pro-badge">' . esc_html($badge_text) . '</span>';
1241 - }
1242 - return '';
1243 1172 }
1244 1173
1245 - public static function new_badge($badge_text = 'New') {
1246 - if( empty( $badge_text ) ) {
1247 - return '';
1248 - }
1249 -
1250 - return '<span class="adminify-new-badge">' . esc_html($badge_text) . '</span>';
1251 - }
1252 -
1253 1174 /*
1254 1175 * Compares the version of WordPress running to the $version specified.
1255 1176 * Usage: Utils::check_wp_version('>=', '4.0')
1256 1177 version_compare( $wp_version, '4.3', '>=' )
@@ -1260,95 +1181,7 @@
1260 1181 */
1261 1182 public static function check_wp_version( $operator = '>', $version = '6.6' ) {
1262 1183 global $wp_version;
1263 1184 return version_compare( $wp_version, $version, $operator );
1264 - }
1265 -
1266 - public static function help_urls($module_name = '', $docs = '', $youtube = '', $facebook_grp = '', $support = '')
1267 - {
1268 - $help_content = '';
1269 -
1270 - // Modules ( sanitize the label so the returned template is safe to echo ).
1271 - // Callers may pass benign markup (e.g. an empty <span></span> used for layout/icons),
1272 - // so use wp_kses_post() — it keeps that markup while stripping scripts. esc_html()
1273 - // would print the tags literally (e.g. "<span></span>" shown as text).
1274 - $module_name = empty($module_name) ? '' : wp_kses_post($module_name);
1275 -
1276 - $help_content_urls = '';
1277 -
1278 - // Docs
1279 - if (!empty($docs)) {
1280 - $help_content_urls .= '<a class="adminify-tag adminify-tag-purple adminify-docs-url" href="' . esc_url( $docs ) . '" target="_blank"> ' . self::docs_icon() . ' Docs</a>';
1281 - }
1282 -
1283 - // youtube
1284 - if (!empty($youtube)) {
1285 - $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>';
1286 - }
1287 -
1288 - // facebook_grp
1289 - if (!empty($facebook_grp)) {
1290 - $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>';
1291 - }
1292 -
1293 - // Support
1294 - if ( !empty($support)) {
1295 - $help_content_urls .= '<a class="adminify-tag adminify-tag-secondary adminify-support-url" href="' . esc_url($support) . '" target="_blank">' . self::support_icon() . ' Support</a>';
1296 - }
1297 -
1298 - $help_content = sprintf( '%1$s <div class="adminify-helps">%2$s</div>', $module_name, $help_content_urls );
1299 - return $help_content;
1300 - }
1301 -
1302 - /**
1303 - * Check if the request is coming from an iframe.
1304 - *
1305 - * @param None
1306 - * @throws None
1307 - * @return bool
1308 - */
1309 - public static function is_iframe()
1310 - {
1311 - return isset($_SERVER["HTTP_SEC_FETCH_DEST"]) && strtolower(sanitize_text_field(wp_unslash($_SERVER["HTTP_SEC_FETCH_DEST"]))) === "iframe";
1312 - // $isIframe = isset($_SERVER["HTTP_SEC_FETCH_DEST"]) && strtolower($_SERVER["HTTP_SEC_FETCH_DEST"]) === "iframe";
1313 - // if ( $isIframe ) return true;
1314 - // if ( isset($_GET['adminify-iframe']) ) return true;
1315 - // return false;
1316 - }
1317 -
1318 - /**
1319 - * Load a template file.
1320 - *
1321 - * @param string $template_name The name of the template file to load.
1322 - * @throws None
1323 - * @return void
1324 - */
1325 - public static function load_template($template_name)
1326 - {
1327 - require_once PXLBSADMINIFY_PATH . 'Inc/Admin/Frames/Templates/' . $template_name;
1328 - }
1329 -
1330 - /**
1331 - * Multisite Check
1332 - * @param URL
1333 - * @return Admin_URL
1334 - */
1335 - public static function maybe_network_admin_url($url) {
1336 - if ( is_network_admin() ) {
1337 - return network_admin_url($url);
1338 - }
1339 - return admin_url($url);
1340 - }
1341 -
1342 - /**
1343 - * Sluggify a string and replace hyphens with underscores.
1344 - * @param string $string The string to sluggify.
1345 - * @return string The sluggified string with underscores.
1346 - */
1347 - public static function sluggify_with_underscores($string) {
1348 - $slug = sanitize_title($string);
1349 - $slug = str_replace('-', '_', $slug);
1350 -
1351 - return $slug;
1352 1185 }
1353 1186
1354 1187 }