function fields()
 {
     global $allowedtags;
     $option_name = $this->id;
     $settings = $this->data;
     $options = $this->options;
     $counter = 0;
     $menu = '';
     $output = '';
     foreach ($options as $value) {
         $counter++;
         $val = '';
         $select_value = '';
         $checked = '';
         // Wrap all options
         if ($value['type'] != "heading" && ($value['type'] != "info" && $value['type'] != "subsection" && $value['type'] != "subsection_end") && $value['type'] != "open_outersection" && $value['type'] != "close_outersection") {
             // Keep all ids lowercase with no spaces
             $value['id'] = isset($value['id']) ? preg_replace('/\\W/', '', strtolower($value['id'])) : "";
             $id = 'section-' . $value['id'];
             $class = 'section ';
             if (isset($value['type'])) {
                 $class .= ' section-' . $value['type'];
             }
             if (isset($value['class'])) {
                 $class .= ' ' . $value['class'];
             }
             $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n";
             $output .= '<h3 class="heading">' . esc_html($value['name']) . '</h3>' . "\n";
             $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
         }
         // Set default value to $val
         if (isset($value['default'])) {
             $val = $value['default'];
         }
         // If the option is already saved, ovveride $val
         if ($value['type'] != "heading" && ($value['type'] != "info" && $value['type'] != "subsection" && $value['type'] != "subsection_end") && $value['type'] != "open_outersection" && $value['type'] != "close_outersection") {
             if (isset($settings[$value['id']])) {
                 $val = $settings[$value['id']];
                 // Striping slashes of non-array options
                 if (!is_array($val)) {
                     $val = stripslashes($val);
                 }
             }
         }
         // If there is a description save it for labels
         $explain_value = '';
         if (isset($value['desc'])) {
             $explain_value = $value['desc'];
         }
         switch ($value['type']) {
             // Basic text input
             case 'text':
                 $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />';
                 break;
                 // Textarea
             // Textarea
             case 'textarea':
                 $cols = '8';
                 $ta_value = '';
                 if (isset($value['options'])) {
                     $ta_options = $value['options'];
                     if (isset($ta_options['cols'])) {
                         $cols = $ta_options['cols'];
                     } else {
                         $cols = '8';
                     }
                 }
                 $val = stripslashes($val);
                 $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>';
                 break;
                 // Select Box
             // Select Box
             case 'select':
                 $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">';
                 foreach ($value['options'] as $key => $option) {
                     $selected = '';
                     if ($val != '') {
                         if ($val == $key) {
                             $selected = ' selected="selected"';
                         }
                     }
                     $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>';
                 }
                 $output .= '</select>';
                 break;
                 // Radio Box
             // Radio Box
             case "radio":
                 $name = $option_name . '[' . $value['id'] . ']';
                 foreach ($value['options'] as $key => $option) {
                     $id = $option_name . '-' . $value['id'] . '-' . $key;
                     $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label><br />';
                 }
                 break;
                 // Image Selectors
             // Image Selectors
             case "images":
                 $name = $option_name . '[' . $value['id'] . ']';
                 foreach ($value['options'] as $key => $option) {
                     $selected = '';
                     $checked = '';
                     if ($val != '') {
                         if ($val == $key) {
                             $selected = ' of-radio-img-selected';
                             $checked = ' checked="checked"';
                         }
                     }
                     $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />';
                     $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>';
                     $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />';
                 }
                 break;
                 // Checkbox
             // Checkbox
             case "checkbox":
                 $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />';
                 $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>';
                 break;
                 // Multicheck
             // Multicheck
             case "multicheck":
                 foreach ($value['options'] as $key => $option) {
                     $checked = '';
                     $label = $option;
                     $option = preg_replace('/\\W/', '', strtolower($key));
                     $id = $option_name . '-' . $value['id'] . '-' . $option;
                     $name = $option_name . '[' . $value['id'] . '][' . $option . ']';
                     if (isset($val[$option])) {
                         $checked = checked($val[$option], 1, false);
                     }
                     $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label><br />';
                 }
                 break;
                 // Color picker
             // Color picker
             case "color":
                 $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>';
                 $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />';
                 break;
                 // Uploader
             // Uploader
             case "upload":
                 // $output .= optionsframework_medialibrary_uploader( $value['id'], $val, null ); // New AJAX Uploader using Media Library
                 if (isset($val['url'])) {
                     $output .= "Preview:<br /> " . "<img class='upload' src='{$val['url']}'/><br/>";
                 }
                 $output .= " &nbsp;&nbsp;&nbsp;&nbsp; URL <input type='text' name='{$value['id']}_text' size='72' value='" . (isset($val['url']) ? $val['url'] : "") . "'/>";
                 $output .= " or upload File: <input type='file' id='{$value['id']}' name='{$value['id']}'>";
                 break;
                 // Typography
             // Typography
             case 'typography':
                 $typography_stored = $val;
                 // Font Size
                 $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">';
                 for ($i = 9; $i < 71; $i++) {
                     $size = $i . 'px';
                     $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>';
                 }
                 $output .= '</select>';
                 // Font Face
                 $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">';
                 $faces = ClassyOptionsSanitize::recognized_font_faces();
                 foreach ($faces as $key => $face) {
                     $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>';
                 }
                 $output .= '</select>';
                 // Font Weight
                 $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">';
                 /* Font Style */
                 $styles = ClassyOptionsSanitize::recognized_font_styles();
                 foreach ($styles as $key => $style) {
                     $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>';
                 }
                 $output .= '</select>';
                 // Font Color
                 $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>';
                 $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />';
                 break;
                 // Background
             // Background
             case 'background':
                 $background = $val;
                 // Background Color
                 $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>';
                 $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />';
                 // Background Image - New AJAX Uploader using Media Library
                 if (!isset($background['image'])) {
                     $background['image'] = '';
                 }
                 $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image');
                 $class = 'of-background-properties';
                 if ('' == $background['image']) {
                     $class .= ' hide';
                 }
                 $output .= '<div class="' . esc_attr($class) . '">';
                 // Background Repeat
                 $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">';
                 $repeats = of_recognized_background_repeat();
                 foreach ($repeats as $key => $repeat) {
                     $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>';
                 }
                 $output .= '</select>';
                 // Background Position
                 $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">';
                 $positions = of_recognized_background_position();
                 foreach ($positions as $key => $position) {
                     $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>';
                 }
                 $output .= '</select>';
                 // Background Attachment
                 $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">';
                 $attachments = of_recognized_background_attachment();
                 foreach ($attachments as $key => $attachment) {
                     $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>';
                 }
                 $output .= '</select>';
                 $output .= '</div>';
                 break;
                 // Info
             // Info
             case "info":
                 $class = 'section';
                 if (isset($value['type'])) {
                     $class .= ' section-' . $value['type'];
                 }
                 if (isset($value['class'])) {
                     $class .= ' ' . $value['class'];
                 }
                 $output .= '<div class="' . esc_attr($class) . '">' . "\n";
                 if (isset($value['name'])) {
                     $output .= '<h3 class="heading">' . $value['name'] . '</h3>' . "\n";
                 }
                 if (isset($value['desc'])) {
                     $output .= wpautop(wp_kses($value['desc'], $allowedtags)) . "\n";
                 }
                 $output .= '<div class="clear"></div></div>' . "\n";
                 break;
             case "export":
                 $output .= "<textarea rows='10'>" . esc_html(serialize($settings)) . "</textarea>";
                 break;
             case "import":
                 $output .= "<textarea name='import' rows='10'></textarea>";
                 break;
                 // Heading for Navigation
             // Heading for Navigation
             case "heading":
                 if ($counter >= 2) {
                     $output .= '</div>' . "\n";
                 }
                 $jquery_click_hook = preg_replace('/\\W/', '', strtolower($value['name']));
                 $jquery_click_hook = "of-option-" . $jquery_click_hook;
                 $menu .= '<li>';
                 $icon = isset($value['icon']) ? " style=\"background-image: url({$value['icon']}); background-position: 8px center; background-repeat: no-repeat; \"" : "";
                 $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '"' . $icon . '>' . esc_html($value['name']) . ' <span></span></a></li>';
                 $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '"><h2>' . esc_html($value['name']) . '</h2>' . "\n";
                 break;
             case "subsection":
                 $id = strtolower(preg_replace("/\\W/", "", $value['name']));
                 $output .= "<div class='subsection' id='subsection-{$id}'><h3>{$value['name']}<span class='plus'>" . "</span></h3><div class='subsection-items'>";
                 break;
             case "subsection_end":
                 $output .= "</div></div>";
                 break;
             case "open_outersection":
                 $output .= "<div class='outersection'>";
                 break;
             case "close_outersection":
                 $output .= "</div>";
                 break;
             case "section_order":
                 $root = get_template_directory_uri();
                 $values = explode(",", $val);
                 $output .= "<div class='section_order' id=" . esc_attr($value['id']) . ">";
                 $output .= "<div class='left_list'>";
                 $output .= "<div class='inactive'>Inactive Elements</div>";
                 $output .= "<div class='list_items'>";
                 foreach ($value['options'] as $k => $v) {
                     if (in_array($k, $values)) {
                         continue;
                     }
                     $output .= "<div class='list_item'>";
                     $output .= "<img src='{$root}/images/minus.png' class='action' title='Remove'/>";
                     $output .= "<span data-key='{$k}'>{$v}</span>";
                     $output .= "</div>";
                 }
                 $output .= "</div>";
                 $output .= "</div>";
                 $output .= "<div class='arrow'><img src='{$root}/images/arrowdrag.png' /></div>";
                 $output .= "<div class='right_list'>";
                 $output .= "<div class='active'>Active Elements</div>";
                 $output .= "<div class='drag'>Drag & Drop Elements</div>";
                 $output .= "<div class='list_items'>";
                 foreach ($values as $k) {
                     if (!$k) {
                         continue;
                     }
                     $val = $value['options'][$k];
                     $output .= "<div class='list_item'>";
                     $output .= "<img src='{$root}/images/minus.png' class='action' title='Remove'/>";
                     $output .= "<span data-key='{$k}'>{$val}</span>";
                     $output .= "</div>";
                 }
                 $output .= "</div>";
                 $output .= "</div>";
                 $output .= "<input type='hidden' id='{$value['id']}' name='{$option_name}[{$value['id']}]' />";
                 $output .= "</div>";
                 break;
         }
         if ($value['type'] != "heading" && ($value['type'] != "info" && $value['type'] != "subsection" && $value['type'] != "subsection_end") && $value['type'] != "open_outersection" && $value['type'] != "close_outersection") {
             if ($value['type'] != "checkbox") {
                 $output .= '<br/>';
             }
             $explain_value = '';
             if (isset($value['desc'])) {
                 $explain_value = $value['desc'];
             }
             $output .= "</div>";
             if ($value['type'] != "checkbox") {
                 $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
             }
             $output .= '<div class="clear"></div></div></div>' . "\n";
         }
     }
     $output .= '</div>';
     return array($output, $menu);
 }
/*
Based on a fork of "Options Framework" by Devin Price
(https://github.com/devinsays/options-framework-plugin)
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
/* Basic plugin definitions */
define('CLASSY_OPTIONS_FRAMEWORK_URL', get_template_directory_uri() . '/core/classy-options/classy-options-framework/');
define('TEMPLATE_URL', get_template_directory_uri());
/* Make sure we don't expose any info if called directly */
if (!function_exists('add_action')) {
    exit;
}
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'options-medialibrary-uploader.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classy-options.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classy-options-sanitize.php';
ClassyOptionsSanitize::initialize();