display_name; $current_roles = $current_user->roles; // $all_roles = wp_roles()->get_names(); if (in_array($current_name, $restrict_for)) { return true; } // Super Admin for Multisite if (is_super_admin() && is_multisite()) { if (in_array('Super Admin', $restrict_for) || in_array('administrator', $restrict_for)) { return true; } else { return false; } } $formattedroles = []; foreach ($restrict_for as $item) { $item = is_string($item) ? strtolower($item) : $item; $item = is_string($item) ? str_replace(' ', '_', $item) : $item; array_push($formattedroles, $item); } foreach ($current_roles as $role) { // $role_name = $all_roles[$role]; if (in_array($role, $restrict_for)) { return true; } } } /** * Check Site wide plugin settings */ public static function is_site_wide($plugin) { if (!is_multisite()) { return false; } $plugins = get_site_option('active_sitewide_plugins'); if (isset($plugins[$plugin])) { return true; } return false; } /** * Get All Taxonomies * * @return void */ public static function get_all_taxonomies() { $taxonomies = get_taxonomies( [ 'show_ui' => true, ], 'objects' ); $taxonomy_names = []; foreach ($taxonomies as $taxonomy) { if ($taxonomy->name == 'post_format') { continue; } $taxonomy_names[$taxonomy->name] = $taxonomy->label; } return $taxonomy_names; } /** * Restricts for role / user */ public static function restrict_for($disabled_for) { if (!is_array($disabled_for)) { return false; } require_once ABSPATH . '/wp-includes/pluggable.php'; if (!function_exists('wp_get_current_user')) { return false; } $current_user = wp_get_current_user(); $current_name = $current_user->display_name; $current_roles = $current_user->roles; $formattedroles = []; foreach ($disabled_for as $item) { $item = strtolower($item); $item = str_replace(' ', '_', $item); array_push($formattedroles, $item); } if (in_array($current_name, $disabled_for)) { return true; } foreach ($current_roles as $role) { if (in_array($role, $formattedroles)) { return true; } } } // Get Taxonomies public static function get_taxonomies() { $args = [ 'public' => true, 'show_ui' => true, ]; $output = 'objects'; $taxonomies = get_taxonomies($args, $output); $taxonomies = $taxonomies; return $taxonomies; } // Get Post Types public static function get_post_types() { $args = [ 'public' => true, 'show_ui' => true, ]; $output = 'objects'; $post_types = get_post_types($args, $output); $post_types = $post_types; return $post_types; } // Get Post Meta public static function post_meta($meta_key) { $meta_key = get_post_meta(get_the_ID(), $meta_key, true); return $meta_key; } // verfiy current page id public static function jltwp_adminify_currentpage_id($id) { if (!function_exists('get_current_screen')) { return true; } $screen = get_current_screen(); return is_object($screen) && $screen->id == $id; } /** * Get Current Admin Page Title * * @param string $title * * @return void */ public static function admin_page_title($title = '') { $title = isset($title) && !empty($title) ? $title : WP_ADMINIFY; echo esc_html($title); if (is_multisite()) { $text = ' | ' . esc_html__('Current Blog ID', 'adminify') . ': ' . get_current_blog_id(); ?> > ', '?', '[', ']', '{', '}', '|', ':'], '', $name); return $class; } public static function jltwp_adminify_class_cleanup($string) { // Lower case everything $string = strtolower($string); // Make alphanumeric (removes all other characters) $string = preg_replace('/[^a-z0-9_\s-]/', '', $string); // Clean up multiple dashes or whitespaces $string = preg_replace('/[\s-]+/', ' ', $string); // Convert whitespaces and underscore to dash $string = preg_replace('/[\s_]/', '-', $string); return $string; } public static function sanitize_id($url) { $url = preg_replace('/^customize.php\?return=.*$/', 'customize', $url); $url = preg_replace('/(&|&|&)?_wpnonce=([^&]+)/', '', $url); return str_replace(['.php', '.', '/', '?', '='], ['', '_', '_', '_', '_'], $url); } /** * Strip tags and it's content from the given string. * * @link https://stackoverflow.com/questions/14684077/remove-all-html-tags-from-php-string/#answer-39320168 * * @param string $text The string being stripped. * @return string The stripped string. */ public static function strip_tags_content($text) { $cleanup = preg_replace('@<(\w+)\b.*?>.*?@si', '', $text); $cleanup = wp_strip_all_tags($cleanup); $cleanup = trim($cleanup); return $cleanup; } /** * String to ID * Remove Space replace with underscore and lowercase * * @param void * * @return string */ public static function string_to_id($string) { $string_replace = str_replace(' ', '_', $string); $formatted_string = strtolower($string_replace); return $formatted_string; } /** * ID to String * Remove Space replace with underscore and lowercase * * @param void * * @return string */ public static function id_to_string($string) { $string_replace = str_replace('_', ' ', $string); $formatted_string = ucwords($string_replace); return $formatted_string; } /** * Check is Plugin Active * * @param [type] $plugin_path * * @return boolean */ public static function is_plugin_active( $plugin_path ) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( $plugin_path ); } /** * Check if Block Editor Page * * @return boolean */ public static function is_block_editor_page() { if (function_exists('get_current_screen')) { $current_screen = get_current_screen(); if (!empty($current_screen->is_block_editor)) { return true; } } return false; } /** * Check is Plugin Active * * @param [type] $plugin_path * * @return boolean */ public static function is_plugin_installed_and_active($plugin_path) { // Check if the plugin is active if (is_plugin_active($plugin_path)) { return true; // Plugin is both installed and active } else { return false; // Plugin is either not installed or not active } } public static function is_plugin_installed($plugin_slug, $plugin_file) { $installed_plugins = get_plugins(); return isset($installed_plugins[$plugin_file]); } public static function jltwp_adminify_notification_bar() { $plugin_slug = 'adminify-notification-bar'; $plugin_file = 'adminify-notification-bar/adminify-notification-bar.php'; $addons_page_url = network_admin_url('admin.php?page=wp-adminify-settings-addons'); // $addons_download_link = jltwp_adminify()->_get_latest_download_local_url(14434); $html = ''; if (self::is_plugin_installed($plugin_slug, $plugin_file)) { if (!current_user_can('install_plugins')) { return; } if (!self::is_plugin_active($plugin_file)) { $activation_url = wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin_file); $html .= '' . esc_html__('Activate', 'adminify') . ''; } } else { // $install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_slug), 'install-plugin_' . $plugin_slug); $html = '' . esc_html__('Download', 'adminify') . ''; activate_plugin($plugin_file); } $html_content = '

' . esc_html__('Notification Bar', 'adminify') . '

' . esc_html__('Cookie Notice, Promotional Bar on frontend', 'adminify') . '
' . wp_kses_post($html) . '
'; echo wp_kses_post($html_content); } /** * User Defined Settings */ public static function get_user_preference($key) { $userid = get_current_user_id(); $current = get_user_meta($userid, '_wpadminify_preferences', true); $value = false; if (is_array($current)) { if (isset($current[$key])) { $value = $current[$key]; } } return $value; } /** * Sanitises and strips tags of input from ajax * * @since 1.0.0 * @variables $values = item to clean (array or string) */ public static function clean_ajax_input($values) { if (is_array($values)) { foreach ($values as $index => $in) { if (is_array($in)) { $values[$index] = self::clean_ajax_input($in); } else { $values[$index] = strip_tags($in); } } } else { $values = strip_tags($values); } return $values; } /** * Check Ajax Error Messages * * @param [type] $message * * @return void */ public static function ajax_error_message($message) { $returndata = []; $returndata['error'] = true; $returndata['error_message'] = $message; return json_encode($returndata); } /** * Get All Updates * Themes, Plugins, Core etc * * @return void */ public static function get_all_updates() { $allupdates = []; $allupdates['total'] = 0; $allupdates['wordpress'] = 0; $allupdates['theme'] = 0; $allupdates['plugin'] = 0; if (!is_admin()) { return $allupdates; } if (!current_user_can('install_plugins')) { return $allupdates; } $updatesTotal = 0; if (is_super_admin() && is_admin()) { $pluginUpdates = get_plugin_updates(); $themeUpdates = get_theme_updates(); $wpUpdates = get_core_updates(); if (isset($wpUpdates[0])) { $wpversion = $wpUpdates[0]->version; global $wp_version; if ($wpversion > $wp_version) { $wpUpdates = 1; } else { $wpUpdates = 0; } } else { $wpUpdates = 0; } $updatesTotal = count($pluginUpdates) + count($themeUpdates) + $wpUpdates; $allupdates['total'] = $updatesTotal; $allupdates['wordpress'] = $wpUpdates; $allupdates['theme'] = $themeUpdates; $allupdates['plugin'] = $pluginUpdates; } return $allupdates; } public static function adminfiy_help_urls($module_name = '', $docs = '', $youtube = '', $facebook_grp = '', $support = '') { $help_content = ''; // Modules if (empty($module_name)) { $module_name = ''; } else { $module_name = $module_name; } $help_content_urls = ''; // Docs if (!empty($docs)) { $help_content_urls .= ' ' . self::docs_icon() . ' Docs'; } // youtube if (!empty($youtube)) { $help_content_urls .= '' . self::video_tutorials_icon() . ' Video Tutorial'; } // facebook_grp if (!empty($facebook_grp)) { $help_content_urls .= '' . self::fbgroup_icon() . ' Facebook Group'; } // Support if ( !empty($support)) { $help_content_urls .= '' . self::support_icon() . ' Support'; } $help_content = sprintf( __('%1$s
%2$s
', 'adminify' ), $module_name, $help_content_urls ); return $help_content; } /** * Upgrade Pro Icon * * @return void */ public static function jltwp_adminify_upgrade_pro_icon() { return ' '; } // Upgrade to Pro Notice public static function adminify_upgrade_pro_img_notice( $image ){ return '
'; } // Upgrade to Pro Notice Class public static function upgrade_pro_class($classname = '') { if(empty($classname)){ // return ' adminify-depend-visible adminify-depend-on adminify-pro-notice '; return ' adminify-pro-feature adminify-pro-notice'; } else { echo esc_attr($classname); } } // Upgrade to Pro Notice public static function adminify_upgrade_pro($custom_message = '', $style='') { if (empty($custom_message)) { $pro_content = sprintf(__('(Upgrade to Pro)', 'adminify')); } else { $pro_content = $custom_message; } if($style === 'inline'){ return '' . $pro_content . ''; } $upgrade_notice_msg = sprintf( __('
%1$s %2$s
', 'adminify'), self::jltwp_adminify_upgrade_pro_icon(), self::wp_kses_custom($pro_content) ); return self::wp_kses_custom($upgrade_notice_msg); } /** * Documentation SVG Icon */ public static function docs_icon() { return ' '; } /** * Video Tutorials SVG Icon */ public static function video_tutorials_icon() { return ' '; } /** * Facebook Group SVG Icon */ public static function fbgroup_icon() { return ' '; } /** * Support SVG Icon */ public static function support_icon() { return ' '; } /* White Label Upgrade Pro */ public static function jltwp_adminify_white_label_upgrade() { ?>

Pro for White Labeling', 'adminify')); ?>

%1$s 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)); ?>

$name) { $options[$id] = $name; } } else { $options['no_template'] = __('No saved templates found!', 'adminify'); } return $options; } public static function get_section_template_options() { $type = 'section'; $page_templates = self::jltwp_adminify_get_page_templates($type); $options[-1] = __('Select', 'adminify'); if (count($page_templates)) { foreach ($page_templates as $id => $name) { $options[$id] = $name; } } else { $options['no_template'] = __('No saved templates found!', 'adminify'); } return $options; } public static function get_page_template_options() { $type = 'page'; $page_templates = self::jltwp_adminify_get_page_templates($type); $options[-1] = __('Select', 'adminify'); if (count($page_templates)) { foreach ($page_templates as $id => $name) { $options[$id] = $name; } } else { $options['no_template'] = __('No saved templates found!', 'adminify'); } return $options; } public static function get_theme_presets($theme = null) { $common_var = [ '--adminify-menu-vertical-padding' => '10px', '--adminify-menu-horizontal-padding' => '8px', '--adminify-menu-wrapper-padding-top' => '16px', '--adminify-menu-wrapper-padding-right' => '8px', '--adminify-menu-wrapper-padding-bottom' => '16px', '--adminify-menu-wrapper-padding-left' => '8px', '--adminify-submenu-vertical-padding' => '4px', '--adminify-submenu-wrapper-padding-top' => '8px', '--adminify-submenu-wrapper-padding-right' => '0px', '--adminify-submenu-wrapper-padding-bottom' => '8px', '--adminify-submenu-wrapper-padding-left' => '28px', // '--adminify-menu-text-align' => 'left', // '--adminify-menu-text-transform' => '', // '--adminify-menu-text-decoration' => 'none', '--adminify-menu-font-size' => '13px', '--adminify-menu-line-height' => '20px', '--adminify-menu-letter-spacing' => '', '--adminify-menu-width' => '260px' ]; $presets = [ // Base/ Default Preset 'preset1' => [ '--adminify-preset-background' => '#F9F9F9', '--adminify-primary' => '#3a3ae9', // '--adminify-text-color' => '#ffffff', '--adminify-menu-border' => '#dedee7', '--adminify-menu-bg' => '#ffffff', '--adminify-menu-hover-bg' => '#3a3ae9', '--adminify-menu-text-color' => '#48455f', '--adminify-menu-text-hover-color' => '#ffffff', '--adminify-menu-active-bg' => '#3a3ae9', '--adminify-menu-active-color' => '#ffffff', '--adminify-submenu-wrapper-bg' => '#ffffff', '--adminify-submenu-hover-bg' => 'transparent', '--adminify-submenu-text-color' => '#48455f', '--adminify-submenu-text-hover-color' => '#3a3ae9', '--adminify-submenu-active-bg' => 'transparent', '--adminify-submenu-active-color' => '#3a3ae9', '--adminify-notif-bg-color' => '#3a3ae9', '--adminify-notif-color' => '#ffffff', ], 'preset2' => [ '--adminify-preset-background' => '#F9F9F9', '--adminify-primary' => '#0347FF', '--adminify-notif-bg-color' => '#FF1C69', // '--adminify-text-color' => '#ffffff', '--adminify-menu-border' => '#404052', '--adminify-menu-bg' => '#14142B', '--adminify-menu-hover-bg' => '#0347FF', '--adminify-menu-text-color' => '#ffffff', '--adminify-menu-text-hover-color' => '#ffffff', '--adminify-menu-active-bg' => '#0347FF', '--adminify-menu-active-color' => '#ffffff', '--adminify-submenu-wrapper-bg' => '#14142B', '--adminify-submenu-hover-bg' => 'transparent', '--adminify-submenu-text-color' => '#ffffff', '--adminify-submenu-text-hover-color' => '#0347FF', '--adminify-submenu-active-bg' => 'transparent', '--adminify-submenu-active-color' => '#0347FF', '--adminify-notif-bg-color' => '#0347FF', '--adminify-notif-color' => '#ffffff', ], ]; $pro_presets = apply_filters('adminify_settings/color_presets', $common_var); if( !empty(array_key_exists('preset3', $pro_presets)) ) { $presets = array_merge($presets, $pro_presets); } // Merge $common_var variable with every preset foreach ($presets as $key => $value) { $presets[$key] = array_merge($value, $common_var); } // return all presets if (is_null($theme)) { return $presets; } // return specific preset if (array_key_exists($theme, $presets)) { return $presets[$theme]; } // specific preset not found return []; } public static function jltwp_adminify_get_page_templates($type = '') { $args = [ 'post_type' => 'elementor_library', 'posts_per_page' => -1, ]; if ($type) { $args['tax_query'] = [ [ 'taxonomy' => 'elementor_library_type', 'field' => 'slug', 'terms' => $type, ], ]; } $page_templates = get_posts($args); $options = []; if (!empty($page_templates) && !is_wp_error($page_templates)) { foreach ($page_templates as $post) { $options[$post->ID] = $post->post_title; } } return $options; } public static function assets_ext($ext) { if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { return $ext; } return '.min' . $ext; } public static function wp_kses_atts_map(array $attrs) { return array_fill_keys(array_values($attrs), true); } public static function wp_kses_custom($content) { $allowed_tags = wp_kses_allowed_html('post'); $custom_tags = [ 'select' => self::wp_kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'multiple', 'required', 'size']), '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']), 'textarea' => self::wp_kses_atts_map(['class', 'id', 'style', 'width', 'height', 'title', 'data', 'name', 'autofocus', 'disabled', 'required', 'rows', 'cols', 'wrap', 'maxlength']), 'option' => self::wp_kses_atts_map(['class', 'id', 'label', 'disabled', 'label', 'selected', 'value']), 'optgroup' => self::wp_kses_atts_map(['disabled', 'label', 'class', 'id']), 'form' => self::wp_kses_atts_map(['class', 'id', 'data', 'style', 'width', 'height', 'accept-charset', 'action', 'autocomplete', 'enctype', 'method', 'name', 'novalidate', 'rel', 'target']), 'svg' => self::wp_kses_atts_map(['class', 'xmlns', 'viewbox', 'width', 'height', 'fill', 'aria-hidden', 'aria-labelledby', 'role']), 'rect' => self::wp_kses_atts_map(['rx', 'width', 'height', 'fill']), 'path' => self::wp_kses_atts_map(['d', 'fill']), 'g' => self::wp_kses_atts_map(['fill']), 'defs' => self::wp_kses_atts_map(['fill']), 'linearGradient' => self::wp_kses_atts_map(['id', 'x1', 'x2', 'y1', 'y2', 'gradientUnits']), 'stop' => self::wp_kses_atts_map(['stop-color', 'offset', 'stop-opacity']), 'style' => self::wp_kses_atts_map(['type']), 'div' => self::wp_kses_atts_map(['class', 'id', 'style']), 'ul' => self::wp_kses_atts_map(['class', 'id', 'style']), 'li' => self::wp_kses_atts_map(['class', 'id', 'style']), 'label' => self::wp_kses_atts_map(['class', 'for']), 'span' => self::wp_kses_atts_map(['class', 'id', 'style']), 'h1' => self::wp_kses_atts_map(['class', 'id', 'style']), 'h2' => self::wp_kses_atts_map(['class', 'id', 'style']), 'h3' => self::wp_kses_atts_map(['class', 'id', 'style']), 'h4' => self::wp_kses_atts_map(['class', 'id', 'style']), 'h5' => self::wp_kses_atts_map(['class', 'id', 'style']), 'h6' => self::wp_kses_atts_map(['class', 'id', 'style']), 'a' => self::wp_kses_atts_map(['class', 'href', 'target', 'rel']), 'p' => self::wp_kses_atts_map(['class', 'id', 'style', 'data']), 'table' => self::wp_kses_atts_map(['class', 'id', 'style']), 'thead' => self::wp_kses_atts_map(['class', 'id', 'style']), 'tbody' => self::wp_kses_atts_map(['class', 'id', 'style']), 'tr' => self::wp_kses_atts_map(['class', 'id', 'style']), 'th' => self::wp_kses_atts_map(['class', 'id', 'style']), 'td' => self::wp_kses_atts_map(['class', 'id', 'style']), 'i' => self::wp_kses_atts_map(['class', 'id', 'style']), 'button' => self::wp_kses_atts_map(['class', 'id']), 'nav' => self::wp_kses_atts_map(['class', 'id', 'style']), 'time' => self::wp_kses_atts_map(['datetime']), 'br' => [], 'strong' => [], 'style' => [], 'img' => self::wp_kses_atts_map(['class', 'src', 'alt', 'height', 'width', 'srcset', 'id', 'loading']), ]; $allowed_tags = array_merge_recursive($allowed_tags, $custom_tags); return wp_kses(stripslashes_deep($content), $allowed_tags); } /** * Missing Addon/Plugin Notice * * @param [type] $args * * @return void */ public static function missing_plugin_notice( $plugin_name = '' ) { /* translators: %s: Plugin Name */ $missing_plugin_notice = sprintf( __('"%1$s" plugin is not Activated! Please install and activate %1$s Plugin

%3$s

', 'adminify'), esc_html($plugin_name), admin_url('admin.php?page=wp-adminify-addons-plugins'), __('Install Now', 'adminify') ); return '
' . self::jltwp_adminify_upgrade_pro_icon() . self::wp_kses_custom( $missing_plugin_notice ) . '
'; } /** * Update Existing Data to New Options data * * @param [type] $get_option_value * @param [type] $update_option_value * @param [type] $option_name * * @return void */ public static function update_options($get_option_value, $option_name) { // Retrieve the current option value $current_value = get_option($option_name); // $current_value = self::$option_data; // Initialize the current value if it's empty if (empty($current_value)) { $current_value = []; } // If $get_option_value is provided, use it to update the current value if (!empty($get_option_value)) { // Ensure current value is an array before merging if (!is_array($current_value)) { $current_value = []; } // Merge the provided value into the current value $current_value = array_merge($current_value, $get_option_value); } // Update the specific key within the option with the new value // $current_value[$option_key] = $update_option_value; // Update the option with the new value update_option($option_name, $current_value); // Optionally, return the updated value return get_option($option_name); } /** * Replace Array Keys * * @return void */ public static function replace_keys($sourceArray, $newArray){ $new_value = []; foreach ($newArray as $key => $value) { if (!array_key_exists($key, $sourceArray)) { return $sourceArray; } $new_value[$value] = $sourceArray[$key]; unset($sourceArray[$key]); } return array_merge($sourceArray, $new_value); } /** * Move Array Keys * * @return void */ public static function move_keys(&$sourceArray, $keysToMove) { $destinationArray = []; foreach ($keysToMove as $key) { if (array_key_exists($key, $sourceArray)) { $destinationArray[$key] = $sourceArray[$key]; unset($sourceArray[$key]); } } return $destinationArray; } /** * Remove unnecessary keys. * * @param string $option_name The name of the option. * @param array $keys_to_remove An array of keys to remove. */ public static function removeKeys($sourceArray, $keysToRemove) { foreach ($keysToRemove as $key) { if (array_key_exists($key, $sourceArray)) { unset($sourceArray[$key]); } } return $sourceArray; } /** * Move Nested Keys * * @return void */ public static function moveNestedKeys(&$sourceArray, $moveInstructions) { $destinationArray = []; foreach ($moveInstructions as $sourcePath => $destPath) { $sourcePathArray = explode('.', $sourcePath); $destPathArray = explode('.', $destPath); $sourceValue = self::getNestedValue($sourceArray, $sourcePathArray); if ($sourceValue !== null) { self::setNestedValue($destinationArray, $destPathArray, $sourceValue); self::unsetNestedValue($sourceArray, $sourcePathArray); } } return array_merge_recursive($sourceArray, $destinationArray); } public static function getNestedValue(&$array, $pathArray) { $value = &$array; foreach ($pathArray as $key) { if (is_array($value) && array_key_exists($key, $value)) { $value = &$value[$key]; } else { return null; } } return $value; } public static function setNestedValue(&$array, $pathArray, $value) { $temp = &$array; foreach ($pathArray as $key) { if (!isset($temp[$key])) { $temp[$key] = []; } $temp = &$temp[$key]; } $temp = $value; } public static function unsetNestedValue(&$array, $pathArray) { $temp = &$array; foreach ($pathArray as $key) { if (isset($temp[$key])) { if (count($pathArray) === 1) { unset($temp[$key]); } else { self::unsetNestedValue($temp[$key], array_slice($pathArray, 1)); } return; } } } /** * * Checkbox Method */ public static function checkboxes(&$old_db, $checkbox_keys) { $result = []; $parentKey = ""; $childKey = ""; $thirdStep = []; foreach ($checkbox_keys as $key => $value) { $sourceArray = explode(".", $value); foreach ($sourceArray as $x => $element) { if (!array_key_exists($element, $result) && $x === 0) { $parentKey = $element; if (count($sourceArray) === 3) { $result[$element] = []; } else { $result[$element] = []; } } if ($x === 1 && !empty($old_db[$key])) { $childKey = $element; if (count($sourceArray) === 3) { $result[$parentKey][$element] = []; } else { $result[$parentKey][] = $element; } } elseif ($x === 1 && empty($old_db[$key]) && count($sourceArray) === 3) { $childKey = $element; if (!array_key_exists($element, $result[$parentKey])) { $result[$parentKey][$element] = []; } } if ($x === 2 && !empty($old_db[$key]) && count($sourceArray) === 3) { $thirdStep[] = $element; $result[$parentKey][$childKey] = $thirdStep; } } } return array_merge_recursive($old_db, $result); } public static function adminify_upgrade_pro_class($inline_badge=false){ if(!empty($inline_badge)){ return 'Pro'; } return '' . self::jltwp_adminify_upgrade_pro_icon() . ' (Upgrade to Pro)' . ''; } public static function adminify_upgrade_pro_badge($badge_text = 'Pro'){ if(!empty($badge_text)){ return '' . $badge_text . ''; } } /* * Compares the version of WordPress running to the $version specified. * Usage: Utils::check_wp_version('>=', '4.0') version_compare( $wp_version, '4.3', '>=' ) * @param string $operator * @param string $version * @returns boolean */ public static function check_wp_version( $operator = '>', $version = '6.6' ) { global $wp_version; return version_compare( $wp_version, $version, $operator ); } }