Beispiel #1
1
function thb_import_theme_options()
{
    $file = get_template_directory_uri() . "/inc/democontent/theme-options.txt";
    $theme_options_txt = wp_remote_get($file);
    $options = unserialize(ot_decode($theme_options_txt['body']));
    /* get settings array */
    $settings = get_option(ot_settings_id());
    /* validate options */
    foreach ($settings['settings'] as $setting) {
        if (isset($options[$setting['id']])) {
            $content = ot_stripslashes($options[$setting['id']]);
            $options[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
        }
    }
    /* update the option tree array */
    update_option(ot_options_id(), $options);
    $message = 'success';
}
function tm_import_themeoptions($data)
{
    /* get settings array */
    $settings = get_option('option_tree_settings');
    /* validate options */
    if (is_array($settings)) {
        foreach ($settings['settings'] as $setting) {
            if (isset($data[$setting['id']])) {
                $content = ot_stripslashes($data[$setting['id']]);
                $data[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
            }
        }
    }
    /* execute the action hook and pass the theme options to it */
    do_action('ot_before_theme_options_save', $data);
    /* update the option tree array */
    update_option('option_tree', $data);
}
 function ut_load_layout_into_ot($ot_layout_file)
 {
     $GLOBALS['ut_load_ot_layout'] = true;
     /* default file for theme activation */
     $ot_layout_file = !empty($ot_layout_file) ? $ot_layout_file : 'default.txt';
     /* needed option tree file for operatiob */
     include_once THEME_DOCUMENT_ROOT . '/admin/includes/ot-functions-admin.php';
     /* theme options file */
     $ot_layout_file = get_template_directory() . '/admin/assets/optionsdata/' . $ot_layout_file;
     if (!is_readable($ot_layout_file)) {
         return;
     }
     /* file rawdata */
     $rawdata = file_get_contents($ot_layout_file);
     $options = isset($rawdata) ? unserialize(ot_decode($rawdata)) : '';
     /* get settings array */
     $settings = get_option('option_tree_settings');
     /* has options */
     if (is_array($options)) {
         /* validate options */
         if (is_array($settings)) {
             foreach ($settings['settings'] as $setting) {
                 if (isset($options[$setting['id']])) {
                     $content = ot_stripslashes($options[$setting['id']]);
                     $options[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
                 }
             }
         }
         /* end validate */
         /* execute the action hook and pass the theme options to it */
         do_action('ot_before_theme_options_save', $options);
         /* update the option tree array */
         update_option('option_tree', $options);
         update_option('ut_layout_loaded', 'active');
         $GLOBALS['ut_load_ot_layout'] = false;
     }
 }
 /**
  * Saves the meta box values
  *
  * @return    void
  *
  * @access    public
  * @since     1.0
  */
 function save_meta_box($post_id, $post_object)
 {
     global $pagenow;
     /* don't save during quick edit */
     if ($pagenow == 'admin-ajax.php') {
         return $post_id;
     }
     /* don't save during autosave */
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     /* don't save if viewing a revision */
     if ($post_object->post_type == 'revision') {
         return $post_id;
     }
     /* verify nonce */
     if (isset($_POST[$this->meta_box['id'] . '_nonce']) && !wp_verify_nonce($_POST[$this->meta_box['id'] . '_nonce'], $this->meta_box['id'])) {
         return $post_id;
     }
     /* check permissions */
     if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     foreach ($this->meta_box['fields'] as $field) {
         $old = get_post_meta($post_id, $field['id'], true);
         $new = '';
         /* there is data to validate */
         if (isset($_POST[$field['id']])) {
             /* slider and list item */
             if (in_array($field['type'], array('list-item', 'slider'))) {
                 /* required title setting */
                 $required_setting = array(array('id' => 'title', 'label' => __('Title', 'option-tree'), 'desc' => '', 'std' => '', 'type' => 'text', 'rows' => '', 'class' => 'option-tree-setting-title', 'post_type' => '', 'choices' => array()));
                 /* get the settings array */
                 $settings = isset($_POST[$field['id'] . '_settings_array']) ? unserialize(ot_decode($_POST[$field['id'] . '_settings_array'])) : array();
                 /* settings are empty for some odd ass reason get the defaults */
                 if (empty($settings)) {
                     $settings = 'slider' == $field['type'] ? ot_slider_settings($field['id']) : ot_list_item_settings($field['id']);
                 }
                 /* merge the two settings array */
                 $settings = array_merge($required_setting, $settings);
                 foreach ($_POST[$field['id']] as $k => $setting_array) {
                     foreach ($settings as $sub_setting) {
                         /* verify sub setting has a type & value */
                         if (isset($sub_setting['type']) && isset($_POST[$field['id']][$k][$sub_setting['id']])) {
                             $_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting($_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id']);
                         }
                     }
                 }
                 /* set up new data with validated data */
                 $new = $_POST[$field['id']];
             } else {
                 /* run through validattion */
                 $new = ot_validate_setting($_POST[$field['id']], $field['type'], $field['id']);
             }
             /* insert CSS */
             if ($field['type'] == 'css') {
                 /* insert CSS into dynamic.css */
                 if ('' !== $new) {
                     ot_insert_css_with_markers($field['id'], $new, true);
                     /* remove old CSS from dynamic.css */
                 } else {
                     ot_remove_old_css($field['id']);
                 }
             }
         }
         if ($new && $new !== $old) {
             update_post_meta($post_id, $field['id'], $new);
         } else {
             if ('' == $new && $old) {
                 delete_post_meta($post_id, $field['id'], $old);
             }
         }
     }
 }
 /**
  * Sanitize callback for register_setting()
  *
  * @return    string
  *
  * @access    public
  * @since     2.0
  */
 public function sanitize_callback($input)
 {
     /* loop through options */
     foreach ((array) $this->options as $option) {
         /* loop through pages */
         foreach ((array) $this->get_pages($option) as $page) {
             /* loop through page settings */
             foreach ((array) $this->get_settings($page) as $setting) {
                 /* verify setting has a type & value */
                 if (isset($setting['type']) && isset($input[$setting['id']])) {
                     /* validate setting */
                     if (is_array($input[$setting['id']]) && in_array($setting['type'], array('list-item', 'slider'))) {
                         /* required title setting */
                         $required_setting = array(array('id' => 'title', 'label' => __('Title', 'option-tree'), 'desc' => '', 'std' => '', 'type' => 'text', 'rows' => '', 'class' => 'option-tree-setting-title', 'post_type' => '', 'choices' => array()));
                         /* get the settings array */
                         $settings = isset($_POST[$setting['id'] . '_settings_array']) ? unserialize(base64_decode($_POST[$setting['id'] . '_settings_array'])) : array();
                         /* settings are empty for some odd ass reason get the defaults */
                         if (empty($settings)) {
                             $settings = 'slider' == $setting['type'] ? ot_slider_settings($setting['id']) : ot_list_item_settings($setting['id']);
                         }
                         /* merge the two settings array */
                         $settings = array_merge($required_setting, $settings);
                         foreach ($input[$setting['id']] as $k => $setting_array) {
                             foreach ($settings as $sub_setting) {
                                 /* verify sub setting has a type & value */
                                 if (isset($sub_setting['type']) && isset($input[$setting['id']][$k][$sub_setting['id']])) {
                                     $input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting($input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id']);
                                 }
                             }
                         }
                     } else {
                         $input[$setting['id']] = ot_validate_setting($input[$setting['id']], $setting['type'], $setting['id']);
                     }
                 }
             }
         }
     }
     return $input;
 }
 /**
  * Sanitize callback for register_setting()
  *
  * @return    string
  *
  * @access    public
  * @since     2.0
  */
 public function sanitize_callback($input)
 {
     /* loop through options */
     foreach ((array) $this->options as $option) {
         /* loop through pages */
         foreach ((array) $this->get_pages($option) as $page) {
             /* loop through page settings */
             foreach ((array) $this->get_the_settings($page) as $setting) {
                 /* verify setting has a type & value */
                 if (isset($setting['type']) && isset($input[$setting['id']])) {
                     /* get the defaults */
                     $current_settings = get_option('option_tree_settings');
                     $current_options = get_option($option['id']);
                     /* validate setting */
                     if (is_array($input[$setting['id']]) && in_array($setting['type'], array('list-item', 'slider'))) {
                         /* required title setting */
                         $required_setting = array(array('id' => 'title', 'label' => __('Title', 'option-tree'), 'desc' => '', 'std' => '', 'type' => 'text', 'rows' => '', 'class' => 'option-tree-setting-title', 'post_type' => '', 'choices' => array()));
                         /* get the settings array */
                         $settings = isset($_POST[$setting['id'] . '_settings_array']) ? unserialize(ot_decode($_POST[$setting['id'] . '_settings_array'])) : array();
                         /* settings are empty for some odd ass reason get the defaults */
                         if (empty($settings)) {
                             $settings = 'slider' == $setting['type'] ? ot_slider_settings($setting['id']) : ot_list_item_settings($setting['id']);
                         }
                         /* merge the two settings array */
                         $settings = array_merge($required_setting, $settings);
                         /* create an empty WPML id array */
                         $wpml_ids = array();
                         foreach ($input[$setting['id']] as $k => $setting_array) {
                             foreach ($settings as $sub_setting) {
                                 /* setup the WPML ID */
                                 $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
                                 /* add id to array */
                                 $wpml_ids[] = $wpml_id;
                                 /* verify sub setting has a type & value */
                                 if (isset($sub_setting['type']) && isset($input[$setting['id']][$k][$sub_setting['id']])) {
                                     /* validate setting */
                                     $input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting($input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id);
                                 }
                             }
                         }
                     } else {
                         $input[$setting['id']] = ot_validate_setting($input[$setting['id']], $setting['type'], $setting['id'], $setting['id']);
                     }
                 }
                 /* unregister WPML strings that were deleted from lists and sliders */
                 if (isset($current_settings['settings']) && isset($setting['type']) && in_array($setting['type'], array('list-item', 'slider'))) {
                     if (!isset($wpml_ids)) {
                         $wpml_ids = array();
                     }
                     foreach ($current_settings['settings'] as $check_setting) {
                         if ($setting['id'] == $check_setting['id'] && !empty($current_options[$setting['id']])) {
                             foreach ($current_options[$setting['id']] as $key => $value) {
                                 foreach ($value as $ckey => $cvalue) {
                                     $id = $setting['id'] . '_' . $ckey . '_' . $key;
                                     if (!in_array($id, $wpml_ids)) {
                                         ot_wpml_unregister_string($id);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $input;
 }
 function ot_import()
 {
     /* check and verify import xml nonce */
     if (isset($_POST['import_xml_nonce']) && wp_verify_nonce($_POST['import_xml_nonce'], 'import_xml_form')) {
         /* import input value */
         $file = isset($_POST['import_xml']) ? esc_url($_POST['import_xml']) : '';
         /* validate xml file */
         if (preg_match("/(.xml)\$/i", $file) && class_exists('SimpleXMLElement')) {
             $settings = ot_import_xml($file);
         }
         /* default message */
         $message = 'failed';
         /* cleanup, save, & show success message */
         if (isset($settings) && !empty($settings)) {
             /* delete file */
             if ($file) {
                 global $wpdb;
                 $attachmentid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE guid='{$file}'");
                 wp_delete_attachment($attachmentid, true);
             }
             /* update settings */
             update_option(ot_settings_id(), $settings);
             /* set message */
             $message = 'success';
         }
         /* redirect */
         wp_redirect(add_query_arg(array('action' => 'import-xml', 'message' => $message), $_POST['_wp_http_referer']));
         exit;
     }
     /* check and verify import settings nonce */
     if (isset($_POST['import_settings_nonce']) && wp_verify_nonce($_POST['import_settings_nonce'], 'import_settings_form')) {
         /* textarea value */
         $textarea = isset($_POST['import_settings']) ? unserialize(ot_decode($_POST['import_settings'])) : '';
         /* default message */
         $message = 'failed';
         /* is array: save & show success message */
         if (is_array($textarea)) {
             update_option(ot_settings_id(), $textarea);
             $message = 'success';
         }
         /* redirect */
         wp_redirect(add_query_arg(array('action' => 'import-settings', 'message' => $message), $_POST['_wp_http_referer']));
         exit;
     }
     /* check and verify import theme options data nonce */
     if (isset($_POST['import_data_nonce']) && wp_verify_nonce($_POST['import_data_nonce'], 'import_data_form')) {
         /* default message */
         $message = 'failed';
         /* textarea value */
         $options = isset($_POST['import_data']) ? unserialize(ot_decode($_POST['import_data'])) : '';
         /* get settings array */
         $settings = get_option(ot_settings_id());
         /* has options */
         if (is_array($options)) {
             /* validate options */
             if (is_array($settings)) {
                 foreach ($settings['settings'] as $setting) {
                     if (isset($options[$setting['id']])) {
                         $content = ot_stripslashes($options[$setting['id']]);
                         $options[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
                     }
                 }
             }
             /* execute the action hook and pass the theme options to it */
             do_action('ot_before_theme_options_save', $options);
             /* update the option tree array */
             update_option(ot_options_id(), $options);
             $message = 'success';
         }
         /* redirect accordingly */
         wp_redirect(add_query_arg(array('action' => 'import-data', 'message' => $message), $_POST['_wp_http_referer']));
         exit;
     }
     /* check and verify import layouts nonce */
     if (isset($_POST['import_layouts_nonce']) && wp_verify_nonce($_POST['import_layouts_nonce'], 'import_layouts_form')) {
         /* default message */
         $message = 'failed';
         /* textarea value */
         $layouts = isset($_POST['import_layouts']) ? unserialize(ot_decode($_POST['import_layouts'])) : '';
         /* get settings array */
         $settings = get_option(ot_settings_id());
         /* has layouts */
         if (is_array($layouts)) {
             /* validate options */
             if (is_array($settings)) {
                 foreach ($layouts as $key => $value) {
                     if ($key == 'active_layout') {
                         continue;
                     }
                     $options = unserialize(ot_decode($value));
                     foreach ($settings['settings'] as $setting) {
                         if (isset($options[$setting['id']])) {
                             $content = ot_stripslashes($options[$setting['id']]);
                             $options[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
                         }
                     }
                     $layouts[$key] = ot_encode(serialize($options));
                 }
             }
             /* update the option tree array */
             if (isset($layouts['active_layout'])) {
                 $new_options = unserialize(ot_decode($layouts[$layouts['active_layout']]));
                 /* execute the action hook and pass the theme options to it */
                 do_action('ot_before_theme_options_save', $new_options);
                 update_option(ot_options_id(), $new_options);
             }
             /* update the option tree layouts array */
             update_option(ot_layouts_id(), $layouts);
             $message = 'success';
         }
         /* redirect accordingly */
         wp_redirect(add_query_arg(array('action' => 'import-layouts', 'message' => $message), $_POST['_wp_http_referer']));
         exit;
     }
     return false;
 }
 function compat_ot_import_from_files()
 {
     /* file path & name without extention */
     $ot_xml = '/option-tree/theme-options.xml';
     $ot_data = '/option-tree/theme-options.txt';
     $ot_layout = '/option-tree/layouts.txt';
     /* XML file path - child theme first then parent */
     if (is_readable(get_stylesheet_directory() . $ot_xml)) {
         $xml_file = get_stylesheet_directory_uri() . $ot_xml;
     } else {
         if (is_readable(get_template_directory() . $ot_xml)) {
             $xml_file = get_template_directory_uri() . $ot_xml;
         }
     }
     /* Data file path - child theme first then parent */
     if (is_readable(get_stylesheet_directory() . $ot_data)) {
         $data_file = get_stylesheet_directory_uri() . $ot_data;
     } else {
         if (is_readable(get_template_directory() . $ot_data)) {
             $data_file = get_template_directory_uri() . $ot_data;
         }
     }
     /* Layout file path - child theme first then parent */
     if (is_readable(get_stylesheet_directory() . $ot_layout)) {
         $layout_file = get_stylesheet_directory_uri() . $ot_layout;
     } else {
         if (is_readable(get_template_directory() . $ot_layout)) {
             $layout_file = get_template_directory_uri() . $ot_layout;
         }
     }
     /* check for files */
     $has_xml = isset($xml_file) ? true : false;
     $has_data = isset($data_file) ? true : false;
     $has_layout = isset($layout_file) ? true : false;
     /* auto import XML file */
     if ($has_xml == true && !get_option('option_tree_settings') && class_exists('SimpleXMLElement')) {
         $settings = ot_import_xml($xml_file);
         if (isset($settings) && !empty($settings)) {
             update_option('option_tree_settings', $settings);
         }
     }
     /* auto import Data file */
     if ($has_data == true && !get_option('option_tree')) {
         $get_data = wp_remote_get($data_file);
         if (is_wp_error($get_data)) {
             return false;
         }
         $rawdata = isset($get_data['body']) ? $get_data['body'] : '';
         $options = unserialize(ot_decode($rawdata));
         /* get settings array */
         $settings = get_option('option_tree_settings');
         /* has options */
         if (is_array($options)) {
             /* validate options */
             if (is_array($settings)) {
                 foreach ($settings['settings'] as $setting) {
                     if (isset($options[$setting['id']])) {
                         $content = ot_stripslashes($options[$setting['id']]);
                         $options[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
                     }
                 }
             }
             /* update the option tree array */
             update_option('option_tree', $options);
         }
     }
     /* auto import Layout file */
     if ($has_layout == true && !get_option('option_tree_layouts')) {
         $get_data = wp_remote_get($data_file);
         if (is_wp_error($get_data)) {
             return false;
         }
         $rawdata = isset($get_data['body']) ? $get_data['body'] : '';
         $layouts = unserialize(ot_decode($rawdata));
         /* get settings array */
         $settings = get_option('option_tree_settings');
         /* has layouts */
         if (is_array($layouts)) {
             /* validate options */
             if (is_array($settings)) {
                 foreach ($layouts as $key => $value) {
                     if ($key == 'active_layout') {
                         continue;
                     }
                     $options = unserialize(ot_decode($value));
                     foreach ($settings['settings'] as $setting) {
                         if (isset($options[$setting['id']])) {
                             $content = ot_stripslashes($options[$setting['id']]);
                             $options[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
                         }
                     }
                     $layouts[$key] = ot_encode(serialize($options));
                 }
             }
             /* update the option tree array */
             if (isset($layouts['active_layout'])) {
                 update_option('option_tree', unserialize(ot_decode($layouts[$layouts['active_layout']])));
             }
             /* update the option tree layouts array */
             update_option('option_tree_layouts', $layouts);
         }
     }
 }
 public function set_demo_theme_options($file)
 {
     $response = wp_remote_get(esc_url_raw($file));
     /* Will result in $api_response being an array of data,
     		parsed from the JSON response of the API listed above */
     $data = wp_remote_retrieve_body($response);
     // Have valid data?
     // If no data or could not decode
     if (empty($data)) {
         wp_die(esc_html__('Theme options import data could not be read. Please try a different file.', 'radium'), '', array('back_link' => true));
     }
     /* textarea value */
     $options = unserialize(base64_decode($data));
     /* get settings array */
     $settings = get_option(ot_settings_id());
     /* has options */
     if (is_array($options)) {
         /* validate options */
         if (is_array($settings)) {
             foreach ($settings['settings'] as $setting) {
                 if (isset($options[$setting['id']])) {
                     $content = ot_stripslashes($options[$setting['id']]);
                     $options[$setting['id']] = ot_validate_setting($content, $setting['type'], $setting['id']);
                 }
             }
         }
         /* update the option tree array */
         update_option(ot_options_id(), $options);
         /* execute the action hook and pass the theme options to it */
         do_action('ot_after_theme_options_save', $options);
     }
 }
 function ot_validate_setting($input, $type, $field_id, $wmpl_id = '')
 {
     /* exit early if missing data */
     if (!$input || !$type || !$field_id) {
         return $input;
     }
     $input = apply_filters('ot_validate_setting', $input, $type, $field_id);
     /* WPML Register and Unregister strings */
     if (!empty($wmpl_id)) {
         /* Allow filtering on the WPML option types */
         $single_string_types = apply_filters('ot_wpml_option_types', array('text', 'textarea', 'textarea-simple'));
         if (in_array($type, $single_string_types)) {
             if (!empty($input)) {
                 ot_wpml_register_string($wmpl_id, $input);
             } else {
                 ot_wpml_unregister_string($wmpl_id);
             }
         }
     }
     if ('background' == $type) {
         $input['background-color'] = ot_validate_setting($input['background-color'], 'colorpicker', $field_id);
         $input['background-image'] = ot_validate_setting($input['background-image'], 'upload', $field_id);
         // Loop over array and check for values
         foreach ((array) $input as $key => $value) {
             if (!empty($value)) {
                 $has_value = true;
             }
         }
         // No value; set to empty
         if (!isset($has_value)) {
             $input = '';
         }
     } else {
         if ('border' == $type) {
             // Loop over array and set errors or unset key from array.
             foreach ($input as $key => $value) {
                 // Validate width
                 if ($key == 'width' && !empty($value) && !is_numeric($value)) {
                     $input[$key] = '0';
                 }
                 // Validate color
                 if ($key == 'color' && !empty($value)) {
                     $input[$key] = ot_validate_setting($value, 'colorpicker', $field_id);
                 }
                 // Unset keys with empty values.
                 if (empty($value) && strlen($value) == 0) {
                     unset($input[$key]);
                 }
             }
             if (empty($input)) {
                 $input = '';
             }
         } else {
             if ('box-shadow' == $type) {
                 // Validate inset
                 $input['inset'] = isset($input['inset']) ? 'inset' : '';
                 // Validate offset-x
                 $input['offset-x'] = ot_validate_setting($input['offset-x'], 'text', $field_id);
                 // Validate offset-y
                 $input['offset-y'] = ot_validate_setting($input['offset-y'], 'text', $field_id);
                 // Validate blur-radius
                 $input['blur-radius'] = ot_validate_setting($input['blur-radius'], 'text', $field_id);
                 // Validate spread-radius
                 $input['spread-radius'] = ot_validate_setting($input['spread-radius'], 'text', $field_id);
                 // Validate color
                 $input['color'] = ot_validate_setting($input['color'], 'colorpicker', $field_id);
                 // Unset keys with empty values.
                 foreach ($input as $key => $value) {
                     if (empty($value) && strlen($value) == 0) {
                         unset($input[$key]);
                     }
                 }
                 // Set empty array to empty string.
                 if (empty($input)) {
                     $input = '';
                 }
             } else {
                 if ('colorpicker' == $type) {
                     /* return empty & set error */
                     if (0 === preg_match('/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input) && 0 === preg_match('/^rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9\\.]{1,4})\\s*\\)/i', $input)) {
                         $input = '';
                     }
                 } else {
                     if ('colorpicker-opacity' == $type) {
                         // Not allowed
                         if (is_array($input)) {
                             $input = '';
                         }
                         // Validate color
                         $input = ot_validate_setting($input, 'colorpicker', $field_id);
                     } else {
                         if (in_array($type, array('css', 'javascript', 'text', 'textarea', 'textarea-simple'))) {
                             if (!current_user_can('unfiltered_html') && OT_ALLOW_UNFILTERED_HTML == false) {
                                 $input = wp_kses_post($input);
                             }
                         } else {
                             if ('dimension' == $type) {
                                 // Loop over array and set error keys or unset key from array.
                                 foreach ($input as $key => $value) {
                                     if (!empty($value) && !is_numeric($value) && $key !== 'unit') {
                                         $errors[] = $key;
                                     }
                                     if (empty($value) && strlen($value) == 0) {
                                         unset($input[$key]);
                                     }
                                 }
                                 /* return 0 & set error */
                                 if (isset($errors)) {
                                     foreach ($errors as $error) {
                                         $input[$error] = '0';
                                     }
                                 }
                                 if (empty($input)) {
                                     $input = '';
                                 }
                             } else {
                                 if ('google-fonts' == $type) {
                                     unset($input['%key%']);
                                     // Loop over array and check for values
                                     if (is_array($input) && !empty($input)) {
                                         $input = array_values($input);
                                     }
                                     // No value; set to empty
                                     if (empty($input)) {
                                         $input = '';
                                     }
                                 } else {
                                     if ('link-color' == $type) {
                                         // Loop over array and check for values
                                         if (is_array($input) && !empty($input)) {
                                             foreach ($input as $key => $value) {
                                                 if (!empty($value)) {
                                                     $input[$key] = ot_validate_setting($input[$key], 'colorpicker', $field_id . '-' . $key);
                                                     $has_value = true;
                                                 }
                                             }
                                         }
                                         // No value; set to empty
                                         if (!isset($has_value)) {
                                             $input = '';
                                         }
                                     } else {
                                         if ('measurement' == $type) {
                                             $input[0] = sanitize_text_field($input[0]);
                                             // No value; set to empty
                                             if (empty($input[0]) && strlen($input[0]) == 0 && empty($input[1])) {
                                                 $input = '';
                                             }
                                         } else {
                                             if ('spacing' == $type) {
                                                 // Loop over array and set error keys or unset key from array.
                                                 foreach ($input as $key => $value) {
                                                     if (!empty($value) && !is_numeric($value) && $key !== 'unit') {
                                                         $errors[] = $key;
                                                     }
                                                     if (empty($value) && strlen($value) == 0) {
                                                         unset($input[$key]);
                                                     }
                                                 }
                                                 /* return 0 & set error */
                                                 if (isset($errors)) {
                                                     foreach ($errors as $error) {
                                                         $input[$error] = '0';
                                                     }
                                                 }
                                                 if (empty($input)) {
                                                     $input = '';
                                                 }
                                             } else {
                                                 if ('typography' == $type && isset($input['font-color'])) {
                                                     $input['font-color'] = ot_validate_setting($input['font-color'], 'colorpicker', $field_id);
                                                     // Loop over array and check for values
                                                     foreach ($input as $key => $value) {
                                                         if (!empty($value)) {
                                                             $has_value = true;
                                                         }
                                                     }
                                                     // No value; set to empty
                                                     if (!isset($has_value)) {
                                                         $input = '';
                                                     }
                                                 } else {
                                                     if ('upload' == $type) {
                                                         if (filter_var($input, FILTER_VALIDATE_INT) === FALSE) {
                                                             $input = esc_url_raw($input);
                                                         }
                                                     } else {
                                                         if ('gallery' == $type) {
                                                             $input = trim($input);
                                                         } else {
                                                             if ('social-links' == $type) {
                                                                 // Loop over array and check for values, plus sanitize the text field
                                                                 foreach ((array) $input as $key => $value) {
                                                                     if (!empty($value) && is_array($value)) {
                                                                         foreach ((array) $value as $item_key => $item_value) {
                                                                             if (!empty($item_value)) {
                                                                                 $has_value = true;
                                                                                 $input[$key][$item_key] = sanitize_text_field($item_value);
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                                 // No value; set to empty
                                                                 if (!isset($has_value)) {
                                                                     $input = '';
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $input = apply_filters('ot_after_validate_setting', $input, $type, $field_id);
     return $input;
 }