' . 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] = wp_strip_all_tags($in);
}
}
} else {
$values = wp_strip_all_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;
}
/**
* 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 = '' . __('(Upgrade to Pro)', 'adminify') . '';
} else {
$pro_content = $custom_message;
}
if($style === 'inline'){
return '' . $pro_content . '';
}
$upgrade_notice_msg = sprintf(
'
%1$s %2$s
',
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;
}
/**
* Common preset CSS variables (padding / sizing / typography
* defaults) shared by every theme preset and by the Pro
* custom-color preset path. Extracted so the Pro filter
* (Pro/Classes/OutputCSS_Body_Pro::build_custom_color_preset())
* can reuse the same defaults instead of re-declaring them.
*
* @return array
*/
public static function get_common_preset_vars()
{
return [
'--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-font-size' => '13px',
'--adminify-menu-line-height' => '20px',
'--adminify-menu-letter-spacing' => '',
'--adminify-menu-width' => '260px',
];
}
public static function get_theme_presets($theme = null)
{
$common_var = self::get_common_preset_vars();
$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)
{
/**
* the context can be different
* The context for which to retrieve tags. Allowed values are 'post', 'strip', 'data', 'entities', or the name of a field filter such as 'pre_user_description', or an array of allowed HTML elements and attributes.
* the post means here it will return all the tags that are allowed in post such as a, p, strong, em etc
*/
$allowed_tags = wp_kses_allowed_html('post'); // Details : https://developer.wordpress.org/reference/functions/wp_kses_allowed_html/
if( !is_array($allowed_tags) ) $allowed_tags = [];
$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 = '' )
{
$missing_plugin_notice = sprintf(
/* translators: 1: Plugin name, 2: Addons/plugins admin page URL, 3: "Install Now" link text */
__('"%1$s" plugin is not Activated! Please install and activate %1$s Plugin
';
}
/**
* 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 = [];
if( ! is_array($sourceArray)) $sourceArray = [];
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);
}
/**
* Inline "Upgrade to Pro" marker rendered next to a checkbox option
* label in the free build.
*
* Returns the rocket-icon + (Upgrade to Pro) span the settings UI
* has rendered historically. The
* Inc/Admin/AdminSettings::adminify_render_pro_locked_field() handler
* detects this span inside a checkbox
and strips name= + sets
* disabled on the enclosed input so the locked option cannot submit
* a value.
*
* Returns an empty string when the Pro plugin is active so the Pro
* UI is unchanged.
*/
public static function adminify_upgrade_pro_class($inline_badge = false){
if (function_exists('jltwp_adminify') && jltwp_adminify()->can_use_premium_code__premium_only()) {
return '';
}
if (!empty($inline_badge)){
return 'Pro';
}
return '' . self::jltwp_adminify_upgrade_pro_icon() . ' (Upgrade to Pro)' . '';
}
/**
* Inline "Pro" badge rendered next to a field title in the free
* build.
*
* Returns the legacy Pro
* markup. The render handler detects fields whose class list
* contains adminify-pro-fieldset / -feature / -notice (the
* Pro-style classes used alongside this badge) and neutralises
* the inputs at render time.
*
* Returns an empty string when the Pro plugin is active.
*/
public static function adminify_upgrade_pro_badge($badge_text = 'Pro'){
if (function_exists('jltwp_adminify') && jltwp_adminify()->can_use_premium_code__premium_only()) {
return '';
}
if (!empty($badge_text)){
return '' . esc_html($badge_text) . '';
}
return '';
}
/*
* 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 );
}
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