/** * Sanitises a HEX value. * (part of the Kirki Toolkit) * The way this works is by splitting the string in 6 substrings. * Each sub-string is individually sanitized, and the result is then returned. * * @var string The hex value of a color * @param boolean Whether we want to include a hash (#) at the beginning or not * @return string The sanitized hex color. */ public static function hex($color) { return Avada_Color::sanitize_hex($color); }
/** * HEX sanitization */ public function color_hex() { $options = get_option(Avada::get_option_name(), array()); $this->fields = Avada_Options::get_option_fields(); foreach ($this->fields as $field) { if (isset($field['type'])) { /** * Make sure color fields are properly formatted */ if ('color' == $field['type']) { $initial_value = isset($options[$field['id']]) ? $options[$field['id']] : 'UNDEFINED'; if (isset($options[$field['id']])) { if (!empty($options[$field['id']])) { $value = $options[$field['id']]; if (is_string($options[$field['id']])) { $value = trim($options[$field['id']]); } } else { $value = $field['default']; } if (is_array($value)) { if (isset($value['color'])) { $value['color'] = 'transparent' == $value['color'] ? '#ffffff' : $value['color']; $options[$field['id']] = Avada_Color::sanitize_hex($value['color']); } } else { $value = 'transparent' == $value ? '#ffffff' : $value; if (false !== strpos('rgba', $value)) { $value = Avada_Color::rgba2hex($value); } $options[$field['id']] = Avada_Color::sanitize_hex($value); } } elseif (isset($field['default'])) { $options[$field['id']] = Avada_Color::sanitize_hex($field['default']); } Avada_Migrate::generate_debug_log(array($field['id'], $field['id'], $initial_value, $options[$field['id']])); } } } // Update the options with our modifications. update_option(Avada::get_option_name(), $options); }