/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Keep all ids lowercase with no spaces
            $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['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            if (isset($settings[$value['id']])) {
                $val = $settings[$value['id']];
                // Striping slashes of non-array options
                if (!is_array($val)) {
                    $val = stripslashes($val);
                }
            }
        }
        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 $value['type'] == '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) . ' />';
                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
                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 = of_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">';
                $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic');
                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;
                // Typography Without Font Face
            // Typography Without Font Face
            case 'typography2':
                $typography2_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($typography2_stored['size'], $size, false) . '>' . esc_html($size) . '</option>';
                }
                $output .= '</select>';
                // Font Weight
                $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">';
                $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic');
                foreach ($styles as $key => $style) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography2_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:' . $typography2_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($typography2_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">' . esc_html($value['name']) . '</h3>' . "\n";
                }
                if ($value['desc']) {
                    $output .= '<p>' . wp_kses($value['desc'], $allowedtags) . '</p>' . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                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><a id="' . esc_attr($jquery_click_hook) . '-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '"><img src="' . get_template_directory_uri() . '/admin/images/' . esc_html($value['sicon']) . '" width="16" height="16" border="0" align="left"> &nbsp;' . esc_html($value['name']) . '</a></li>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '"><h2>' . esc_html($value['name']) . '</h2>' . "\n";
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $explain_value = '';
            if (isset($value['desc'])) {
                $explain_value = $value['desc'];
            }
            $output .= '</div><div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
            $output .= '<div class="clear"></div></div></div>' . "\n";
        }
    }
    $output .= '</div>';
    return array($output, $menu);
}
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        $output = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "infotext" && $value['type'] != "info" && $value['type'] != "adstwofifty" && $value['type'] != "innertabopen" && $value['type'] != "innertabclose" && $value['type'] != "tabheading" && $value['type'] != "groupcontaineropen" && $value['type'] != "groupcontainerclose") {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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";
            if (isset($value['name'])) {
                $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            }
            if ($value['type'] != 'editor') {
                $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
            } else {
                $output .= '<div class="option">' . "\n" . '<div>' . "\n";
            }
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != "heading" && $value['type'] != "infotext" && $value['type'] != "info" && $value['type'] != "adstwofifty" && $value['type'] != "innertabopen" && $value['type'] != "innertabclose" && $value['type'] != "tabheading" && $value['type'] != "groupcontaineropen" && $value['type'] != "groupcontainerclose") {
            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;
                // Upgrade to PRO
            // Upgrade to PRO
            case 'proupgrade':
                $output .= '<p class="proupgradep">Available in PRO. Upgrade now.</p>';
                break;
                // Textarea
            // Textarea
            case 'textarea':
                $rows = '8';
                if (isset($value['settings']['rows'])) {
                    $custom_rows = $value['settings']['rows'];
                    if (is_numeric($custom_rows)) {
                        $rows = $custom_rows;
                    }
                }
                $val = stripslashes($val);
                $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . esc_textarea($val) . '</textarea>';
                break;
                // Select Box
            // Select Box
            case $value['type'] == '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>';
                }
                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;
                // Image Selectors
            // Image Selectors
            case "proimages":
                foreach ($value['options'] as $key => $option) {
                    $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img-pro" />';
                }
                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('/[^a-zA-Z0-9._\\-]/', '', 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>';
                }
                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);
                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 = of_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 = of_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;
                // Editor
            // Editor
            case 'editor':
                $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
                echo $output;
                $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']');
                $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress'));
                $editor_settings = array();
                if (isset($value['settings'])) {
                    $editor_settings = $value['settings'];
                }
                $editor_settings = array_merge($editor_settings, $default_editor_settings);
                wp_editor($val, $value['id'], $editor_settings);
                $output = '';
                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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '</div>' . "\n";
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                break;
                // testing
            // testing
            case "tabheading":
                $output .= '<div class="tabheading"><p class="tabheadingp">' . esc_html($value['name']) . '</p></div>';
                break;
            case "infotext":
                $output .= '<div class="themenotice"><p>' . esc_html($value['desc']) . '</p></div>';
                break;
            case "innertabopen":
                $output .= '<div id="' . esc_html($value['name']) . '" class="tabcontent">';
                break;
            case "innertabclose":
                $output .= '</div>';
                break;
            case "groupcontaineropen":
                $output .= '<div class="groupcontainer"><div class="groupcontainertitle"><p class="groupcontainertitlep">' . esc_html($value['name']) . '</p></div>';
                break;
            case "groupcontainerclose":
                $output .= '</div>';
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "infotext" && $value['type'] != "info" && $value['type'] != "adstwofifty" && $value['type'] != "innertabopen" && $value['type'] != "innertabclose" && $value['type'] != "tabheading" && $value['type'] != "groupcontaineropen" && $value['type'] != "groupcontainerclose") {
            $output .= '</div>';
            if ($value['type'] != "checkbox" && $value['type'] != "editor") {
                $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
            }
            $output .= '</div></div>' . "\n";
        }
        echo $output;
    }
    echo '</div>';
}
Ejemplo n.º 3
0
/** 
 * Generates The Options Within the Panel - 
 * O P T I O N S F R A M E W O R K   M A C H I N E
 */
function optionsframework_machine($iva_options)
{
    $counter = 0;
    $menu = $output = '';
    $menuitems = array();
    $s_headings = array();
    foreach ($iva_options as $key => $value) {
        if ($value['type'] == 'heading' || $value['type'] == 'subnav') {
            $s_headings[] = $value;
        }
    }
    $heading_key = 0;
    foreach ($s_headings as $key => $value) {
        $head = 'atp-option-' . preg_replace('/[^a-zA-Z0-9\\s]/', '', strtolower(trim(str_replace(' ', '', $value['name']))));
        $value['head'] = $head;
        if ($value['type'] == 'heading') {
            $menuitems[$head] = $value;
            $heading_key = $head;
        }
        if ($value['type'] == 'subnav') {
            $menuitems[$heading_key]['children'][] = $value;
        }
    }
    foreach ($iva_options as $value) {
        $counter++;
        $val = '';
        // H E A D I N G
        //---------------------------------
        if ($value['type'] != "heading" && $value['type'] != "subnav") {
            $class = '';
            if (isset($value['class'])) {
                $class = $value['class'];
            }
            $output .= '<div  class="section section-' . $value['type'] . ' ' . $class . '">' . "\n";
        }
        if (!isset($value['desc'])) {
            $explain_value = '';
        } else {
            $explain_value = $value['desc'];
        }
        $select_value = '';
        switch ($value['type']) {
            // S U B S E C T I O N
            //---------------------------------
            case 'subsection':
                $default = $value['name'];
                //$output .= '<h3>'.$default.'</h3>';
                $output .= '<div class="help">' . $explain_value . '</div>';
                break;
                // T E X T
                //---------------------------------
            // T E X T
            //---------------------------------
            case 'text':
                $val = $value['std'];
                $std = get_option($value['id']);
                if ($std != "") {
                    $val = $std;
                }
                $inputsize = isset($value['inputsize']) ? $value['inputsize'] : '10';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<input class="atp-input" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $val . '" style="width:' . $inputsize . 'px" />';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // S E L E C T
                //---------------------------------
            // S E L E C T
            //---------------------------------
            case 'select':
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div class="select_wrapper ' . $value['class'] . '">';
                $output .= '<select class="of-input select " name="' . $value['id'] . '" id="' . $value['id'] . '">';
                foreach ($value['options'] as $key => $option) {
                    $output .= '<option value="' . $key . '" ' . selected(get_option($value['id']), $key, false) . ' />' . $option . '</option>';
                }
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // M U L T I S E L E C T
                //---------------------------------
            // M U L T I S E L E C T
            //---------------------------------
            case 'multiselect':
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div>';
                $output .= '<select class="of-input  "  multiple="multiple"   name="' . $value['id'] . '[]" id="' . $value['id'] . '[]">';
                foreach ($value['options'] as $key => $option) {
                    $selected = "";
                    if (get_option($value['id'])) {
                        if (@in_array($key, get_option($value['id']))) {
                            $selected = "selected=\"selected\"";
                        }
                    } else {
                        //Empty Value if Unchecked
                    }
                    $output .= '<option value="' . $key . '"  ' . $selected . ' />' . $option . '</option>';
                }
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // S O C I A B L E S
                //---------------------------------
            // S O C I A B L E S
            //---------------------------------
            case 'custom_socialbook_mark':
                global $socialimages_select;
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div id="sys_social_book">';
                $output .= '<h2>Social Networking Sites</h2>';
                $output .= '<table id="sys_socialbookmark" class="fancy_table">';
                $output .= '<tr>';
                $output .= '<th align="center" width="70">Delete</th>';
                $output .= '<th width="100">Alt Tag</th>';
                $output .= '<th width="100">Icon</th>';
                $output .= '<th width="100">URL</th>';
                $output .= '</tr>';
                if (get_option('atp_social_bookmark') != '') {
                    $sys_social_items = explode('#;', get_option('atp_social_bookmark'));
                    for ($i = 0; $i < count($sys_social_items); $i++) {
                        $sys_social_item = explode('#|', $sys_social_items[$i]);
                        $output .= '<tr>';
                        $output .= '<td>';
                        $output .= '<a href="#" class="sys_social_item_delete button-primary">Delete</a>';
                        $output .= '</td>';
                        $output .= '<td>';
                        $output .= '<input type="text" class="sys_social_title" value="' . $sys_social_item[0] . '" />';
                        $output .= '</td>';
                        $output .= '<td>';
                        $sociable = array('beatport' => 'Beatport', 'blogger' => 'Blogger', 'delicious' => 'Delicious', 'deviant' => 'Deviant', 'facebook' => 'Facebook', 'flickr' => 'Flickr', 'forrst' => 'Forrst', 'instagram' => 'InstaGram', 'twitter' => 'Twitter', 'google' => 'Google', 'linkedin' => 'Linkedin', 'pinterest' => 'Pinterest', 'rss' => 'Rss', 'soundcloud' => 'Soundcloud ', 'skype' => 'skype', 'stumbleupon' => 'stumbleupon', 'tumblr' => 'tumblr', 'vimeo' => 'vimeo', 'yahoo' => 'yahoo', 'youtube' => 'youtube');
                        $output .= '<select id="sys_social_file_icon" class="sys_social_file_icon" name="sys_social_file_icon"  width="300">';
                        foreach ($sociable as $key => $values) {
                            $selected = $sys_social_item[1] == $key ? ' selected="selected"' : '';
                            $output .= '<option ' . $selected . ' value="' . $key . '" >' . $values . '</option>';
                            $selected = "";
                        }
                        $output .= '</select>';
                        $output .= '</td>';
                        $output .= '<td>';
                        $output .= '<input type="text" class="sys_social_account_url" value="' . $sys_social_item[2] . '" />';
                        $output .= '</td>';
                        $output .= '</tr>';
                    }
                }
                $output .= '</table>';
                $output .= '<p>';
                $output .= '<button name="sys_add_social_book" id="sys_add_social_item" type="button" value="Add New Row" class="button button-primary button-large" /><span>Add New</span></button>';
                $output .= '<input type="hidden" id="atp_social_bookmark" name="atp_social_bookmark"/>';
                $output .= '</p>';
                $output .= '</div></div>';
                break;
                // S I D E B A R
                //---------------------------------
            // S I D E B A R
            //---------------------------------
            case 'customsidebar':
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $val = $value['std'];
                $std = get_option($value['id']);
                $custom_sidebar_arr = @get_option($value['id']);
                // print_r($custom_sidebar_arr);
                if ($std != "") {
                    $val = $std;
                }
                $output .= '<div id="custom_widget_sidebar"><table id="custom_widget_table" cellpadding="0" cellspacing="0">';
                $output .= '<tbody>';
                if ($custom_sidebar_arr != "") {
                    foreach ($custom_sidebar_arr as $custom_sidebar_code) {
                        $output .= '<tr><td><input type="text" name="' . $value['id'] . '[]" value="' . $custom_sidebar_code . '"  size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0);return false;" onClick="jQuery(this).parent().parent().remove();">Delete</a></td></tr>';
                    }
                }
                $output .= '</tbody></table><button type="button" class="button button-primary button-large" name="add_custom_widget" value="Add Sidebar" onClick="addWidgetRow()">Add Sidebar</button></div>';
                ?>
						<script type="text/javascript" language="javascript">
							function addWidgetRow(){
								jQuery('#custom_widget_table').append('<tr><td><input type="text" name="<?php 
                echo $value['id'];
                ?>
[]" value="" size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0);return false;" onClick="jQuery(this).parent().parent().remove();">Delete</a></td></tr>');
							}
						</script>
						<?php 
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // T E X T A R E A
                //---------------------------------
            // T E X T A R E A
            //---------------------------------
            case 'textarea':
                $cols = '8';
                $ta_value = '';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="explain">' . $explain_value . '</div>';
                $output .= '<div class="controls" >' . "\n";
                if (isset($value['std'])) {
                    $ta_value = $value['std'];
                    if (isset($value['options'])) {
                        $ta_options = $value['options'];
                        if (isset($ta_options['cols'])) {
                            $cols = $ta_options['cols'];
                        } else {
                            $cols = '8';
                        }
                    }
                }
                $std = get_option($value['id']);
                if ($std != "") {
                    $ta_value = stripslashes($std);
                }
                $output .= '<textarea class="atp-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . esc_textarea($ta_value) . '</textarea>';
                $output .= '</div>';
                break;
                // E X P O R T
                //---------------------------------
            // E X P O R T
            //---------------------------------
            case 'export':
                $cols = '8';
                $ta_value = '';
                $std = get_option($value['id']);
                if ($std != "") {
                    $ta_value = stripslashes($std);
                }
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                //$output .= serialize((get_option('atp_template_option_values')));
                $output .= '<textarea class="atp-input" cols="' . $cols . '" rows="8">' . base64_encode(serialize(get_option('atp_template_option_values'))) . '</textarea>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // I M P O R T
                //---------------------------------
            // I M P O R T
            //---------------------------------
            case 'import':
                $cols = '8';
                $ta_value = '';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<textarea class="atp-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8"></textarea>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // R A D I O
                //---------------------------------
            // R A D I O
            //---------------------------------
            case "radio":
                $select_value = get_option($value['id']);
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                foreach ($value['options'] as $key => $option) {
                    $checked = '';
                    if ($select_value != '') {
                        if ($select_value == $key) {
                            $checked = ' checked';
                        }
                    } else {
                        if ($value['std'] == $key) {
                            $checked = ' checked';
                        }
                    }
                    $output .= '<input class="atp-input atp-radio" type="radio" name="' . $value['id'] . '" value="' . $key . '" ' . $checked . ' />' . $option . '&nbsp;&nbsp;&nbsp;';
                }
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // CHECKBOX
                //---------------------------------
            // CHECKBOX
            //---------------------------------
            case "checkbox":
                $std = $value['std'];
                $saved_std = get_option($value['id']);
                $checked = '';
                if (!empty($saved_std)) {
                    if ($saved_std == 'on') {
                        $checked = 'checked="checked"';
                    } else {
                        $checked = '';
                    }
                } elseif ($std == 'on') {
                    $checked = 'checked="checked"';
                } else {
                    $checked = '';
                }
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<input type="checkbox" class="checkbox" value="on" id="' . $value['id'] . '" name="' . $value['id'] . '" ' . $checked . ' />';
                $output .= '</div>';
                $output .= '<div class="explain"><label for="' . $value['id'] . '">' . $explain_value . '</label></div>';
                break;
                // M U L T I   C H E C K B O X
                //---------------------------------
            // M U L T I   C H E C K B O X
            //---------------------------------
            case "multicheck":
                $std = $value['std'];
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                foreach ($value['options'] as $key => $option) {
                    $checked = "";
                    if (get_option($value['id'])) {
                        if (@in_array($key, get_option($value['id']))) {
                            $checked = "checked=\"checked\"";
                        }
                    } else {
                        //Empty Value if Unchecked
                    }
                    $output .= '<input type="checkbox" class="checkbox" name="' . $value['id'] . '[]" id="' . $key . '" value="' . $key . '" ' . $checked . ' /> <label for="' . $key . '">' . $option . '</label><br>';
                }
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // U P L O A D
                //---------------------------------
            // U P L O A D
            //---------------------------------
            case "upload":
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= optionsframework_medialibrary_uploader($value['id'], $val, null);
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // C O L O R
                //---------------------------------
            // C O L O R
            //---------------------------------
            case "color":
                $val = $value['std'];
                $stored = get_option($value['id']);
                if ($stored != "") {
                    $val = $stored;
                }
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<input class="color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . $val . '" />';
                $output .= '<div class="wpcolorSelector"><div  id="' . $value['id'] . '_picker" ></div></div>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // T Y P O G R A P H Y
                //---------------------------------
            // T Y P O G R A P H Y
            //---------------------------------
            case "typography":
                $default = $value['std'];
                $typography_stored = get_option($value['id']);
                $output .= '<h3 class="heading">' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                // C O L O R
                if (isset($default['color'])) {
                    $val = $default['color'];
                }
                if ($typography_stored['color'] != "") {
                    $val = $typography_stored['color'];
                }
                $output .= '<div class="typocolor"><input class="atp-color atp-typography color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . $val . '" />';
                $output .= '<div class="wpcolorSelector"><div id="' . $value['id'] . '_color_picker"></div></div></div>';
                // F O N T   S I Z E
                $val = $default['size'];
                if ($typography_stored['size'] != "") {
                    $val = $typography_stored['size'];
                }
                $output .= '<div class="atp-typo-size"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_size" id="' . $value['id'] . '_size">';
                $output .= '<option value="">Font Size</option>';
                for ($i = 9; $i < 71; $i++) {
                    if ($val == $i) {
                        $active = 'selected="selected"';
                    } else {
                        $active = '';
                    }
                    $output .= '<option value="' . $i . 'px" ' . $active . '>' . $i . 'px</option>';
                }
                $output .= '</select></div></div>';
                // L I N E   H E I G H T
                $val = $default['lineheight'];
                if ($typography_stored['lineheight'] != "") {
                    $val = $typography_stored['lineheight'];
                }
                $output .= '<div class="atp-typo-lineheight"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_lineheight" id="' . $value['id'] . '_lineheight">';
                $output .= '<option value="">Line Height</option>';
                for ($i = 9; $i < 71; $i++) {
                    if ($val == $i) {
                        $active = 'selected="selected"';
                    } else {
                        $active = '';
                    }
                    $output .= '<option value="' . $i . 'px" ' . $active . '>' . $i . 'px</option>';
                }
                $output .= '</select></div></div>';
                // F O N T   S T Y L E
                $val = $default['style'];
                if ($typography_stored['style'] != "") {
                    $val = $typography_stored['style'];
                }
                $normal = '';
                $italic = '';
                if ($val == 'normal') {
                    $normal = 'selected="selected"';
                }
                if ($val == 'italic') {
                    $italic = 'selected="selected"';
                }
                $output .= '<div class="atp-typo-style"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_style" id="' . $value['id'] . '_style">';
                $output .= '<option value="">Font-Style</option>';
                $output .= '<option value="normal" ' . $normal . '>Normal</option>';
                $output .= '<option value="italic" ' . $italic . '>Italic</option>';
                $output .= '</select></div></div>';
                // F O N T   V A R I A N T
                if (isset($default['fontvariant'])) {
                    $val = $default['fontvariant'];
                }
                if ($typography_stored['fontvariant'] != "") {
                    $val = $typography_stored['fontvariant'];
                }
                $array_weight = array('normal' => 'Normal', 'bold' => 'Bold', 'lighter' => 'Lighter', '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900');
                $output .= '<div class="atp-typo-fontvariant"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_fontvariant" id="' . $value['id'] . '_fontvariant">';
                $output .= '<option value="">Font-Variant</option>';
                foreach ($array_weight as $key => $values) {
                    $fontselected = '';
                    if ($val == $key) {
                        $fontselected = 'selected="selected"';
                    }
                    $output .= '<option value="' . $key . '" ' . $fontselected . '>' . $values . '</option>';
                }
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '</div>';
                // section-typography end.
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // F O N T  F A M I L Y S E L E C T
            // F O N T  F A M I L Y S E L E C T
            case 'atpfontfamily':
                global $fontface;
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div class="select_wrapper ' . $value['class'] . '">';
                $output .= '<select class="of-input select  google_font_select" name="' . $value['id'] . '" id="' . $value['id'] . '">';
                foreach ($value['options'] as $select_key => $option) {
                    $output .= '<option value="' . $select_key . '" ' . selected(get_option($value['id']), $key, false) . ' />' . $option . '</option>';
                }
                $google_fonts = atp_google_webfonts();
                $output .= '<optgroup label="Google Web Fonts">';
                foreach ($google_fonts as $key => $googlefont) {
                    $name = $googlefont['name'];
                    $output .= '<option value="' . $name . '" ' . selected(get_option($value['id']), $name, false) . ' />' . $name . '</option>';
                }
                $output .= '</optgroup>';
                $output .= '</select></div>';
                if (isset($value['preview']['text'])) {
                    $g_text = $value['preview']['text'];
                } else {
                    $g_text = '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz';
                }
                if (isset($value['preview']['size'])) {
                    $g_size = 'style="font-size: ' . $value['preview']['size'] . ';"';
                } else {
                    $g_size = '';
                }
                $hide = "hide";
                if (get_option($value['id']) != "") {
                    $hide = "";
                }
                $output .= '<p  class="' . $value['id'] . '_ggf_previewer google_font_preview ' . $hide . '" ' . $g_size . '>' . $g_text . '</p>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // B A C K G R O U N D
                //---------------------------------
            // B A C K G R O U N D
            //---------------------------------
            case "background":
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $default = $value['std'];
                $background_stored = get_option($value['id']);
                // U P L O A D   I M A G E
                $val = $default['image'];
                $imgid = $value['id'] . '_image';
                if ($background_stored['image'] != "") {
                    $val = $background_stored['image'];
                }
                $output .= '<div class="atp-background-upload clearfix">';
                $output .= optionsframework_medialibrary_uploader($imgid, $val, null);
                $output .= '</div>';
                // C O L O R
                $val = $default['color'];
                if ($background_stored['color'] != "") {
                    $val = $background_stored['color'];
                }
                $output .= '<div class="atp-background-color">';
                $output .= '<input class="color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . $val . '" />';
                $output .= '<div class="wpcolorSelector"><div  id="' . $value['id'] . '_color_picker" ></div></div>';
                $output .= '</div>';
                // R E P E A T
                $val = $default['style'];
                if ($background_stored['style'] != "") {
                    $val = $background_stored['style'];
                }
                $repeat = '';
                $norepeat = '';
                $repeatx = '';
                $repeaty = '';
                if ($val == 'repeat') {
                    $repeat = 'selected="selected"';
                }
                if ($val == 'no-repeat') {
                    $norepeat = 'selected="selected"';
                }
                if ($val == 'repeat-x') {
                    $repeatx = 'selected="selected"';
                }
                if ($val == 'repeat-y') {
                    $repeaty = 'selected="selected"';
                }
                $output .= '<div class="atp-background-repeat">';
                $output .= '<div class="select_wrapper">';
                $output .= '<select class="atp-background select" name="' . $value['id'] . '_style" id="' . $value['id'] . '_style">';
                $output .= '<option value="repeat" ' . $repeat . '>Repeat</option>';
                $output .= '<option value="no-repeat" ' . $norepeat . '>No-Repeat</option>';
                $output .= '<option value="repeat-x" ' . $repeatx . '>Repeat-X</option>';
                $output .= '<option value="repeat-y" ' . $repeaty . '>Repeat-Y</option>';
                $output .= '</select>';
                $output .= '</div></div>';
                // P O S I T I O N
                $val = $default['position'];
                if ($background_stored['position'] != "") {
                    $val = $background_stored['position'];
                }
                $lefttop = $leftcenter = $leftbottom = $righttop = $rightcenter = $rightbottom = $centertop = $centercenter = $centerbottom = '';
                if ($val == 'left top') {
                    $lefttop = 'selected="selected"';
                }
                if ($val == 'left center') {
                    $leftcenter = 'selected="selected"';
                }
                if ($val == 'left bottom') {
                    $leftbottom = 'selected="selected"';
                }
                if ($val == 'right top') {
                    $righttop = 'selected="selected"';
                }
                if ($val == 'right center') {
                    $rightcenter = 'selected="selected"';
                }
                if ($val == 'right bottom') {
                    $rightbottom = 'selected="selected"';
                }
                if ($val == 'center top') {
                    $centertop = 'selected="selected"';
                }
                if ($val == 'center center') {
                    $centercenter = 'selected="selected"';
                }
                if ($val == 'center bottom') {
                    $centerbottom = 'selected="selected"';
                }
                $output .= '<div class="atp-background-position">';
                $output .= '<div class="select_wrapper">';
                $output .= '<select class="atp-background select" name="' . $value['id'] . '_position" id="' . $value['id'] . '_style">';
                $output .= '<option value="left top" ' . $lefttop . '>Left Top</option>';
                $output .= '<option value="left center" ' . $leftcenter . '>Left Center</option>';
                $output .= '<option value="left bottom" ' . $leftbottom . '>Left Bottom</option>';
                $output .= '<option value="right top" ' . $righttop . '>Right Top</option>';
                $output .= '<option value="right center" ' . $rightcenter . '>Right Center</option>';
                $output .= '<option value="right bottom" ' . $rightbottom . '>Right Bottom</option>';
                $output .= '<option value="center top" ' . $centertop . '>Center Top</option>';
                $output .= '<option value="center center" ' . $centercenter . '>Center Center</option>';
                $output .= '<option value="center bottom" ' . $centerbottom . '>Center Bottom</option>';
                $output .= '</select>';
                $output .= '</div></div>';
                // A T T A C H M E N T
                $val = $default['attachment'];
                if ($background_stored['attachment'] != "") {
                    $val = $background_stored['attachment'];
                }
                $fixed = $scroll = '';
                if ($val == 'fixed') {
                    $fixed = 'selected="selected"';
                }
                if ($val == 'scroll') {
                    $scroll = 'selected="selected"';
                }
                $output .= '<div class="atp-background-attachment">';
                $output .= '<div class="select_wrapper">';
                $output .= '<select class="atp-background select" name="' . $value['id'] . '_attachment" id="' . $value['id'] . '_style">';
                $output .= '<option value="fixed" ' . $fixed . '>Fixed</option>';
                $output .= '<option value="scroll" ' . $scroll . '>Scroll</option>';
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '</div>';
                //controls part end
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // I M A G E S
                //---------------------------------
            // I M A G E S
            //---------------------------------
            case "images":
                $i = 0;
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $select_value = get_option($value['id']);
                foreach ($value['options'] as $key => $option) {
                    $i++;
                    $checked = '';
                    $selected = '';
                    if ($select_value != '') {
                        if ($select_value == $key) {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        }
                    } else {
                        if ($value['std'] == $key) {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        } elseif ($i == 1 && !isset($select_value)) {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        } elseif ($i == 1 && $value['std'] == '') {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        } else {
                            $checked = '';
                        }
                    }
                    $output .= '<span>';
                    $output .= '<input type="radio" id="atp-radio-img-' . $value['id'] . $i . '" class="checkbox atp-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />';
                    $output .= '<div class="atp-radio-img-label">' . $key . '</div>';
                    $output .= '<img src="' . $option . '" title="' . $key . '" alt="' . $key . '" class="atp-radio-option ' . $selected . '" onClick="document.getElementById(\'atp-radio-img-' . $value['id'] . $i . '\').checked = true;" />';
                    $output .= '</span>';
                }
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
            case "businesshours":
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $default = $value['std'];
                $businesshours_stored = get_option($value['id']);
                // Opening
                //$val = $default['opening'];
                if ($businesshours_stored['opening'] != "") {
                    $val = $businesshours_stored['opening'];
                }
                $output .= '<div class="otime"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_opening" id="' . $value['id'] . '_opening">';
                $output .= '<option value="">Opening-Time</option>';
                for ($i = 0; $i < 24; $i++) {
                    $h = $i;
                    if ($h < 10) {
                        $h = '0' . $h;
                    }
                    for ($m = 0; $m <= 45; $m += 15) {
                        if ($m == 0) {
                            $m .= '0';
                        }
                        $hours = $h . ':' . $m;
                        if ($val === $hours) {
                            $active = 'selected="selected"';
                        } else {
                            $active = '';
                        }
                        $output .= '<option value="' . $h . ':' . $m . '" ' . $active . '>' . $h . ':' . $m . '</option>';
                    }
                }
                $output .= '</select></div></div>';
                // Closing
                //$val = $default['closing'];
                if ($businesshours_stored['closing'] != "") {
                    $val = $businesshours_stored['closing'];
                }
                $output .= '<div class="ctime"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_closing" id="' . $value['id'] . '_closing">';
                $output .= '<option value="">Closing-Time</option>';
                for ($i = 0; $i < 24; $i++) {
                    $h = $i;
                    if ($h < 10) {
                        $h = '0' . $h;
                    }
                    for ($m = 0; $m <= 45; $m += 15) {
                        if ($m == 0) {
                            $m .= '0';
                        }
                        $hours = $h . ':' . $m;
                        if ($val === $hours) {
                            $active = 'selected="selected"';
                        } else {
                            $active = '';
                        }
                        $output .= '<option value="' . $h . ':' . $m . '" ' . $active . '>' . $h . ':' . $m . '</option>';
                    }
                }
                $output .= '</select></div></div>';
                // Closed
                //$val = $default['close'];
                if ($businesshours_stored['close'] != "") {
                    $val = $businesshours_stored['close'];
                }
                $checked = '';
                if (!empty($val)) {
                    if ($val == 'on') {
                        $checked = 'checked="checked"';
                    } else {
                        $checked = '';
                    }
                }
                $output .= '<div class="cclosed"><input ' . $checked . ' type="checkbox" class="checkbox atp-input " value="on" name="' . $value['id'] . '_close" id="' . $value['id'] . '_close"> <label for="' . $value['id'] . '_close">Check this if you wish the display this day as closed. </label></div>';
                break;
                // H E A D I N G
                //---------------------------------
            // H E A D I N G
            //---------------------------------
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = str_replace(' ', '', strtolower($value['name']));
                $jquery_click_hook = "atp-option-" . trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($jquery_click_hook))))));
                $output .= '<div class="group" id="' . $jquery_click_hook . '">' . "\n";
                break;
                //S U B  N A V I G A T I O N
                //---------------------------------
            //S U B  N A V I G A T I O N
            //---------------------------------
            case "subnav":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = str_replace(' ', '', strtolower($value['name']));
                $jquery_click_hook = "atp-option-" . trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($jquery_click_hook))))));
                $output .= '<div class="group" id="' . $jquery_click_hook . '">' . "\n";
                break;
        }
        //------------------------------------
        //	E N D   S W I T C H   C A S E
        //------------------------------------
        // Option Value Type
        // if TYPE is an array, formatted into smaller inputs... ie smaller values
        if (is_array($value['type'])) {
            foreach ($value['type'] as $array) {
                $id = $array['id'];
                $std = $array['std'];
                $saved_std = get_option($id);
                if ($saved_std != $std) {
                    $std = $saved_std;
                }
                $meta = $array['meta'];
                if ($array['type'] == 'text') {
                    // Only text at this point
                    $output .= '<input class="input-text-small atp-input" name="' . $id . '" id="' . $id . '" type="text" value="' . $std . '" />';
                    $output .= '<span class="meta-two">' . $meta . '</span>';
                }
            }
        }
        // Option Value not equals to Headings and checkbox
        if ($value['type'] != "heading" && $value['type'] != "subnav") {
            if ($value['type'] != "checkbox") {
                $output .= '';
            }
            $output .= '</div>' . "\n";
        }
    }
    // E N D - for each
    if (count($menuitems) > 0) {
        $menu = '';
        foreach ($menuitems as $key => $value) {
            if (isset($v['icon']) && $v['icon'] != '') {
                //$class = $v['icon'];
            }
            if (isset($value['children']) && count($value['children']) > 0) {
                $class = 'parent';
                $hasdropdown = 'class="dropmenu"';
            } else {
                $class = "parent no-child";
                $hasdropdown = '';
            }
            $menu .= '<li ' . $hasdropdown . '>' . "\n" . '';
            $menu .= '<a class="' . $class . '" title="' . $value['name'] . '" href="#' . $value['head'] . '"><img src="' . $value['icon'] . '" height="16" alt=""/> ' . $value['name'] . '</a>' . "\n";
            if (isset($value['children']) && count($value['children']) > 0) {
                $menu .= '<ul class="sub-menu">' . "\n";
                foreach ($value['children'] as $i => $j) {
                    $menu .= '<li>' . "\n" . '<a  title="' . $j['name'] . '" href="#' . $j['head'] . '">' . $j['name'] . '</a></li>' . "\n";
                }
                $menu .= '</ul>' . "\n";
            }
            $menu .= '</li>' . "\n";
        }
    }
    $output .= '</div>';
    return array($output, $menu, $menuitems);
}
Ejemplo n.º 4
0
 public static function optionsframework_machine($options)
 {
     $data = get_option(OPTIONS);
     $defaults = array();
     $counter = 0;
     $menu = '';
     $output = '';
     foreach ($options as $value) {
         $counter++;
         $val = '';
         //create array of defaults
         if ($value['type'] == 'multicheck') {
             if (is_array($value['std'])) {
                 foreach ($value['std'] as $i => $key) {
                     $defaults[$value['id']][$key] = true;
                 }
             } else {
                 $defaults[$value['id']][$value['std']] = true;
             }
         } else {
             if (isset($value['id'])) {
                 $defaults[$value['id']] = $value['std'];
             }
         }
         //Start Heading
         if ($value['type'] != "heading") {
             $class = '';
             if (isset($value['class'])) {
                 $class = $value['class'];
             }
             $output .= '<div id="section-' . $value['id'] . '" class="section section-' . $value['type'] . ' ' . $class . '">' . "\n";
             $output .= '<label for="' . $value['id'] . '"" class="heading">' . $value['name'] . '</label>' . "\n";
             $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
         }
         //End Heading
         switch ($value['type']) {
             case 'text':
                 $t_value = '';
                 $t_value = stripslashes($data[$value['id']]);
                 $mini = '';
                 if (!isset($value['mod'])) {
                     $value['mod'] = '';
                 }
                 if ($value['mod'] == 'mini') {
                     $mini = 'mini';
                 }
                 $output .= '<input class="of-input ' . $mini . '" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $t_value . '" />';
                 break;
             case 'select':
                 $mini = '';
                 if (!isset($value['mod'])) {
                     $value['mod'] = '';
                 }
                 if ($value['mod'] == 'mini') {
                     $mini = 'mini';
                 }
                 $output .= '<div class="select_wrapper ' . $mini . '">';
                 $output .= '<select class="select of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">';
                 foreach ($value['options'] as $select_ID => $option) {
                     $output .= '<option id="' . $select_ID . '" value="' . $select_ID . '" ' . selected($data[$value['id']], $select_ID, false) . ' />' . $option . '</option>';
                 }
                 $output .= '</select></div>';
                 break;
             case 'textarea':
                 $cols = '8';
                 $ta_value = '';
                 if (isset($value['options'])) {
                     $ta_options = $value['options'];
                     if (isset($ta_options['cols'])) {
                         $cols = $ta_options['cols'];
                     }
                 }
                 $ta_value = stripslashes($data[$value['id']]);
                 $output .= '<textarea class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . $ta_value . '</textarea>';
                 break;
             case "radio":
                 foreach ($value['options'] as $option => $name) {
                     $output .= '<input class="of-input of-radio" name="' . $value['id'] . '" type="radio" value="' . $option . '" ' . checked($data[$value['id']], $option, false) . ' /><label class="radio">' . $name . '</label><br/>';
                 }
                 break;
             case 'checkbox':
                 if (!isset($data[$value['id']])) {
                     $data[$value['id']] = 0;
                 }
                 $output .= '<input type="hidden" class="checkbox aq-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="0"/>';
                 $output .= '<input type="checkbox" class="checkbox of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="1" ' . checked($data[$value['id']], 1, false) . ' />';
                 break;
             case 'multicheck':
                 $multi_stored = $data[$value['id']];
                 foreach ($value['options'] as $key => $option) {
                     if (!isset($multi_stored[$key])) {
                         $multi_stored[$key] = '';
                     }
                     $of_key_string = $value['id'] . '_' . $key;
                     $output .= '<input type="checkbox" class="checkbox of-input" name="' . $value['id'] . '[' . $key . ']' . '" id="' . $of_key_string . '" value="1" ' . checked($multi_stored[$key], 1, false) . ' /><label class="multicheck" for="' . $of_key_string . '">aaaa' . $option . '</label><br />';
                 }
                 break;
             case 'upload':
                 if (!isset($value['mod'])) {
                     $value['mod'] = '';
                 }
                 $output .= Options_Machine::optionsframework_uploader_function($value['id'], $value['std'], $value['mod']);
                 break;
             case 'media':
                 $_id = strip_tags(strtolower($value['id']));
                 $int = '';
                 $int = optionsframework_mlu_get_silentpost($_id);
                 if (!isset($value['mod'])) {
                     $value['mod'] = '';
                 }
                 $output .= Options_Machine::optionsframework_media_uploader_function($value['id'], $value['std'], $int, $value['mod']);
                 // New AJAX Uploader using Media Library
                 break;
             case 'color':
                 $output .= '<div id="' . $value['id'] . '_picker" class="colorSelector"><div style="background-color: ' . $data[$value['id']] . '"></div></div>';
                 $output .= '<input class="of-color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . $data[$value['id']] . '" />';
                 break;
             case 'typography':
                 $typography_stored = $data[$value['id']];
                 /* Font Size */
                 if (isset($typography_stored['size'])) {
                     $output .= '<div class="select_wrapper typography-size" original-title="Font size">';
                     $output .= '<select class="of-typography of-typography-size select" name="' . $value['id'] . '[size]" id="' . $value['id'] . '_size">';
                     for ($i = 9; $i < 20; $i++) {
                         $test = $i . 'px';
                         $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['size'], $test, false) . '>' . $i . 'px</option>';
                     }
                     $output .= '</select></div>';
                 }
                 /* Line Height */
                 if (isset($typography_stored['height'])) {
                     $output .= '<div class="select_wrapper typography-height" original-title="Line height">';
                     $output .= '<select class="of-typography of-typography-height select" name="' . $value['id'] . '[height]" id="' . $value['id'] . '_height">';
                     for ($i = 20; $i < 38; $i++) {
                         $test = $i . 'px';
                         $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['height'], $test, false) . '>' . $i . 'px</option>';
                     }
                     $output .= '</select></div>';
                 }
                 /* Font Face */
                 if (isset($typography_stored['face'])) {
                     $output .= '<div class="select_wrapper typography-face" original-title="Font family">';
                     $output .= '<select class="of-typography of-typography-face select" name="' . $value['id'] . '[face]" id="' . $value['id'] . '_face">';
                     $faces = array('arial' => 'Arial', 'verdana' => 'Verdana, Geneva', 'trebuchet' => 'Trebuchet', 'georgia' => 'Georgia', 'times' => 'Times New Roman', 'tahoma' => 'Tahoma, Geneva', 'palatino' => 'Palatino', 'helvetica' => 'Helvetica');
                     foreach ($faces as $i => $face) {
                         $output .= '<option value="' . $i . '" ' . selected($typography_stored['face'], $i, false) . '>' . $face . '</option>';
                     }
                     $output .= '</select></div>';
                 }
                 /* Font Weight */
                 if (isset($typography_stored['style'])) {
                     $output .= '<div class="select_wrapper typography-style" original-title="Font style">';
                     $output .= '<select class="of-typography of-typography-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">';
                     $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic');
                     foreach ($styles as $i => $style) {
                         $output .= '<option value="' . $i . '" ' . selected($typography_stored['style'], $i, false) . '>' . $style . '</option>';
                     }
                     $output .= '</select></div>';
                 }
                 /* Font Color */
                 if (isset($typography_stored['color'])) {
                     $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector typography-color"><div style="background-color: ' . $typography_stored['color'] . '"></div></div>';
                     $output .= '<input class="of-color of-typography of-typography-color" original-title="Font color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $typography_stored['color'] . '" />';
                 }
                 break;
             case 'border':
                 /* Border Width */
                 $border_stored = $data[$value['id']];
                 $output .= '<div class="select_wrapper border-width">';
                 $output .= '<select class="of-border of-border-width select" name="' . $value['id'] . '[width]" id="' . $value['id'] . '_width">';
                 for ($i = 0; $i < 21; $i++) {
                     $output .= '<option value="' . $i . '" ' . selected($border_stored['width'], $i, false) . '>' . $i . '</option>';
                 }
                 $output .= '</select></div>';
                 /* Border Style */
                 $output .= '<div class="select_wrapper border-style">';
                 $output .= '<select class="of-border of-border-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">';
                 $styles = array('none' => 'None', 'solid' => 'Solid', 'dashed' => 'Dashed', 'dotted' => 'Dotted');
                 foreach ($styles as $i => $style) {
                     $output .= '<option value="' . $i . '" ' . selected($border_stored['style'], $i, false) . '>' . $style . '</option>';
                 }
                 $output .= '</select></div>';
                 /* Border Color */
                 $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div style="background-color: ' . $border_stored['color'] . '"></div></div>';
                 $output .= '<input class="of-color of-border of-border-color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $border_stored['color'] . '" />';
                 break;
             case 'images':
                 $i = 0;
                 $select_value = $data[$value['id']];
                 foreach ($value['options'] as $key => $option) {
                     $i++;
                     $checked = '';
                     $selected = '';
                     if (NULL != checked($select_value, $key, false)) {
                         $checked = checked($select_value, $key, false);
                         $selected = 'of-radio-img-selected';
                     }
                     $output .= '<span>';
                     $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />';
                     $output .= '<div class="of-radio-img-label">' . $key . '</div>';
                     $output .= '<img src="' . $option . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />';
                     $output .= '</span>';
                 }
                 break;
             case "info":
                 $info_text = $value['std'];
                 $output .= '<div class="of-info">' . $info_text . '</div>';
                 break;
             case "image":
                 $src = $value['std'];
                 $output .= '<img src="' . $src . '">';
                 break;
             case 'heading':
                 if ($counter >= 2) {
                     $output .= '</div>' . "\n";
                 }
                 $header_class = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name']));
                 $jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name']));
                 $jquery_click_hook = "of-option-" . $jquery_click_hook;
                 $menu .= '<li class="' . $header_class . '"><a title="' . $value['name'] . '" href="#' . $jquery_click_hook . '">' . $value['name'] . '</a></li>';
                 $output .= '<div class="group" id="' . $jquery_click_hook . '"><h2>' . $value['name'] . '</h2>' . "\n";
                 break;
             case 'slider':
                 $_id = strip_tags(strtolower($value['id']));
                 $int = '';
                 $int = optionsframework_mlu_get_silentpost($_id);
                 $output .= '<div class="slider"><ul id="' . $value['id'] . '" rel="' . $int . '">';
                 $slides = $data[$value['id']];
                 $count = count($slides);
                 if ($count < 2) {
                     $oldorder = 1;
                     $order = 1;
                     $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order, $int);
                 } else {
                     $i = 0;
                     foreach ($slides as $slide) {
                         $oldorder = $slide['order'];
                         $i++;
                         $order = $i;
                         $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order, $int);
                     }
                 }
                 $output .= '</ul>';
                 $output .= '<a href="#" class="button slide_add_button">Add New Slide</a></div>';
                 break;
             case 'sorter':
                 $sortlists = $data[$value['id']];
                 $output .= '<div id="' . $value['id'] . '" class="sorter">';
                 if ($sortlists) {
                     foreach ($sortlists as $group => $sortlist) {
                         $output .= '<ul id="' . $value['id'] . '_' . $group . '" class="sortlist_' . $value['id'] . '">';
                         $output .= '<h3>' . $group . '</h3>';
                         foreach ($sortlist as $key => $list) {
                             $output .= '<input class="sorter-placebo" type="hidden" name="' . $value['id'] . '[' . $group . '][placebo]" value="placebo">';
                             if ($key != "placebo") {
                                 $output .= '<li id="' . $key . '" class="sortee">';
                                 $output .= '<input class="position" type="hidden" name="' . $value['id'] . '[' . $group . '][' . $key . ']" value="' . $list . '">';
                                 $output .= $list;
                                 $output .= '</li>';
                             }
                         }
                         $output .= '</ul>';
                     }
                 }
                 $output .= '</div>';
                 break;
             case 'tiles':
                 $i = 0;
                 $select_value = '';
                 $select_value = $data[$value['id']];
                 foreach ($value['options'] as $key => $option) {
                     $i++;
                     $checked = '';
                     $selected = '';
                     if (NULL != checked($select_value, $option, false)) {
                         $checked = checked($select_value, $option, false);
                         $selected = 'of-radio-tile-selected';
                     }
                     $output .= '<span>';
                     $output .= '<input type="radio" id="of-radio-tile-' . $value['id'] . $i . '" class="checkbox of-radio-tile-radio" value="' . $option . '" name="' . $value['id'] . '" ' . $checked . ' />';
                     $output .= '<div class="of-radio-tile-img ' . $selected . '" style="background: url(' . $option . ')" onClick="document.getElementById(\'of-radio-tile-' . $value['id'] . $i . '\').checked = true;"></div>';
                     $output .= '</span>';
                 }
                 break;
                 // Background
             // Background
             case 'background':
                 $background = $data[$value['id']];
                 // 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;
             case 'backup':
                 $instructions = $value['options'];
                 $backup = get_option(BACKUPS);
                 if (!isset($backup['backup_log'])) {
                     $log = 'No backups yet';
                 } else {
                     $log = $backup['backup_log'];
                 }
                 $output .= '<div class="backup-box">';
                 $output .= '<div class="instructions">' . $instructions . "\n";
                 $output .= '<p><strong>' . __('Last Backup : ') . '<span class="backup-log">' . $log . '</span></strong></p></div>' . "\n";
                 $output .= '<a href="#" id="of_backup_button" class="button" title="Backup Options">Backup Options</a>';
                 $output .= '<a href="#" id="of_restore_button" class="button" title="Restore Options">Restore Options</a>';
                 $output .= '</div>';
                 break;
         }
         // if TYPE is an array, formatted into smaller inputs... ie smaller values
         if (is_array($value['type'])) {
             foreach ($value['type'] as $array) {
                 $id = $array['id'];
                 $std = $array['std'];
                 $saved_std = get_option($id);
                 if ($saved_std != $std) {
                     $std = $saved_std;
                 }
                 $meta = $array['meta'];
                 if ($array['type'] == 'text') {
                     // Only text at this point
                     $output .= '<input class="input-text-small of-input" name="' . $id . '" id="' . $id . '" type="text" value="' . $std . '" />';
                     $output .= '<span class="meta-two">' . $meta . '</span>';
                 }
             }
         }
         if ($value['type'] != 'heading') {
             if (!isset($value['desc'])) {
                 $explain_value = '';
             } else {
                 $explain_value = '<div class="explain">' . $value['desc'] . '</div>' . "\n";
             }
             $output .= '</div>' . $explain_value . "\n";
             $output .= '<div class="clear"> </div></div></div>' . "\n";
         }
     }
     $output .= '</div>';
     return array($output, $menu, $defaults);
 }
Ejemplo n.º 5
0
 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);
 }
/**
 * Genera los campos de opciones que son usados en este formulario.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Obtiene el nombre del tema para que podamos mostrarlo en la parte superior
    $the_theme = wp_get_theme();
    $themename = $the_theme->Name;
    // Obtiene el id único de la opción
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Envuelve todas las opciones
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Mantiene todos los id en minúsculas y sin espacios
            //if ( isset( $value['id'] ) ){
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
        }
        // Establece el valor predeterminado para $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // Si la opción ya se encuentra guardada, sobrescribe $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            if (isset($settings[$value['id']])) {
                $val = $settings[$value['id']];
                // Striping slashes of non-array options
                if (!is_array($val)) {
                    $val = stripslashes($val);
                }
            }
        }
        // Si existe una descripción guardada para las etiquetas
        $explain_value = '';
        if (isset($value['desc'])) {
            $explain_value = $value['desc'];
        }
        switch ($value['type']) {
            // Inserción básica de texto
            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;
                // Area de texto
            // Area de texto
            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;
                // Caja de selección
            // Caja de selección
            case $value['type'] == '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;
                // Caja de radio
            // Caja de radio
            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>';
                }
                break;
                // Selectores de imagen
            // Selectores de imagen
            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;
                // Casilla de verificación
            // Casilla de verificación
            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;
                // Lista de selección múltiple
            // Lista de selección múltiple
            case "multicheck":
                foreach ($value['options'] as $key => $option) {
                    $checked = '';
                    $label = $option;
                    $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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>';
                }
                break;
                // Selector de color
            // Selector de color
            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;
                // Cargador
            // Cargador
            case "upload":
                $output .= optionsframework_medialibrary_uploader($value['id'], $val, null);
                // Nuevo cargador en AJAX usando Media Library
                break;
                // Tipografía
            // Tipografía
            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 = of_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 = of_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;
                // Tipografía WPBS - remueve el tamaño de fuente del grupo de campos std de la tipografía
            // Tipografía WPBS - remueve el tamaño de fuente del grupo de campos std de la tipografía
            case 'wpbs_typography':
                $wpbs_typography_stored = $val;
                // 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 = of_recognized_font_faces();
                foreach ($faces as $key => $face) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_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 = of_recognized_font_styles();
                foreach ($styles as $key => $style) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_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:' . $wpbs_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($wpbs_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 - Nuevo cargador en AJAX usando 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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n";
                break;
            case "themecheck":
                $class = 'section';
                if (isset($value['type'])) {
                    $class .= ' section-' . $value['type'];
                }
                if (isset($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                $output .= '<div class="' . esc_attr($class) . '">' . "\n";
                $output .= '<a id="check-bootswatch" class="button-secondary">Actualizar temas</a>';
                $output .= '<div id="check-status"></div>';
                $output .= '</div>';
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $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);
}
Ejemplo n.º 7
0
/** 
 * Generates The Options Within the Panel - 
 * O P T I O N S F R A M E W O R K   M A C H I N E
 */
function optionsframework_machine($iva_of_options)
{
    $counter = 0;
    $menu = $output = '';
    $menuitems = array();
    $s_headings = array();
    foreach ($iva_of_options as $key => $value) {
        if ($value['type'] == 'heading' || $value['type'] == 'subnav') {
            $s_headings[] = $value;
        }
    }
    $heading_key = 0;
    foreach ($s_headings as $key => $value) {
        $head = 'atp-option-' . preg_replace('/[^a-zA-Z0-9\\s]/', '', strtolower(trim(str_replace(' ', '', $value['name']))));
        $value['head'] = $head;
        if ($value['type'] == 'heading') {
            $menuitems[$head] = $value;
            $heading_key = $head;
        }
        if ($value['type'] == 'subnav') {
            $menuitems[$heading_key]['children'][] = $value;
        }
    }
    foreach ($iva_of_options as $value) {
        $counter++;
        $val = '';
        // H E A D I N G
        //---------------------------------
        if ($value['type'] != "heading" && $value['type'] != "subnav") {
            $class = '';
            if (isset($value['class'])) {
                $class = $value['class'];
            }
            $output .= '<div  class="section section-' . $value['type'] . ' ' . $class . '">' . "\n";
        }
        if (!isset($value['desc'])) {
            $explain_value = '';
        } else {
            $explain_value = $value['desc'];
        }
        $select_value = '';
        switch ($value['type']) {
            // S U B S E C T I O N
            //---------------------------------
            case 'subsection':
                $default = $value['name'];
                $output .= '<div class="sub-section"><h1 class="sub-title">' . $default . '</h1>' . $explain_value . '</div>';
                break;
                // T E X T
                //---------------------------------
            // T E X T
            //---------------------------------
            case 'text':
                $val = $value['std'];
                $std = get_option($value['id']);
                if ($std != "") {
                    $val = $std;
                }
                $inputsize = isset($value['inputsize']) ? $value['inputsize'] : '10';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<input class="atp-input" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $val . '" style="width:' . $inputsize . 'px" />';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // S E L E C T
                //---------------------------------
            // S E L E C T
            //---------------------------------
            case 'select':
                $class = '';
                if (isset($value['class'])) {
                    $class = $value['class'];
                }
                $value_options = isset($value['options']) ? $value['options'] : '';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div class="select_wrapper ' . $class . '">';
                $output .= '<select class="of-input select " name="' . $value['id'] . '" id="' . $value['id'] . '">';
                if (!empty($value_options)) {
                    foreach ($value_options as $key => $option) {
                        $output .= '<option value="' . $key . '" ' . selected(get_option($value['id']), $key, false) . ' />' . $option . '</option>';
                    }
                }
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // M U L T I S E L E C T
                //---------------------------------
            // M U L T I S E L E C T
            //---------------------------------
            case 'multiselect':
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div>';
                $output .= '<select class="of-input  "  multiple="multiple"   name="' . $value['id'] . '[]" id="' . $value['id'] . '[]">';
                foreach ($value['options'] as $key => $option) {
                    $selected = "";
                    if (get_option($value['id'])) {
                        if (@in_array($key, get_option($value['id']))) {
                            $selected = "selected=\"selected\"";
                        }
                    } else {
                        //Empty Value if Unchecked
                    }
                    $output .= '<option value="' . $key . '"  ' . $selected . ' />' . $option . '</option>';
                }
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // BUSINESS HOURS
                //---------------------------------
            // BUSINESS HOURS
            //---------------------------------
            case "businesshours":
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $default = $value['std'];
                $businesshours_stored = get_option($value['id']);
                $interval = get_option('iva_time_interval') ? get_option('iva_time_interval') : '15';
                // Opening
                //$val = $default['opening'];
                if ($businesshours_stored['opening'] != "") {
                    $val = $businesshours_stored['opening'];
                }
                $output .= '<div class="otime"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_opening" id="' . $value['id'] . '_opening">';
                $output .= '<option value="">' . __('Opening-Time', 'iva_theme_admin') . '</option>';
                for ($i = 0; $i < 24; $i++) {
                    $h = $i;
                    if ($h < 10) {
                        $h = '0' . $h;
                    }
                    for ($m = 0; $m <= 45; $m += $interval) {
                        if ($m == 0) {
                            $m .= '0';
                        }
                        $hours = $h . ':' . $m;
                        if ($val === $hours) {
                            $active = 'selected="selected"';
                        } else {
                            $active = '';
                        }
                        $output .= '<option value="' . $h . ':' . $m . '" ' . $active . '>' . $h . ':' . $m . '</option>';
                    }
                }
                $output .= '</select></div></div>';
                // Closing
                //$val = $default['closing'];
                if ($businesshours_stored['closing'] != "") {
                    $val = $businesshours_stored['closing'];
                }
                $output .= '<div class="ctime"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_closing" id="' . $value['id'] . '_closing">';
                $output .= '<option value="">' . __('Closing-Time', 'iva_theme_admin') . '</option>';
                for ($i = 0; $i < 24; $i++) {
                    $h = $i;
                    if ($h < 10) {
                        $h = '0' . $h;
                    }
                    for ($m = 0; $m <= 45; $m += $interval) {
                        if ($m == 0) {
                            $m .= '0';
                        }
                        $hours = $h . ':' . $m;
                        if ($val === $hours) {
                            $active = 'selected="selected"';
                        } else {
                            $active = '';
                        }
                        $output .= '<option value="' . $h . ':' . $m . '" ' . $active . '>' . $h . ':' . $m . '</option>';
                    }
                }
                $output .= '</select></div></div>';
                // Closed
                //$val = $default['close'];
                if ($businesshours_stored['close'] != "") {
                    $val = $businesshours_stored['close'];
                }
                $checked = '';
                if (!empty($val)) {
                    if ($val == 'on') {
                        $checked = 'checked="checked"';
                    } else {
                        $checked = '';
                    }
                }
                $output .= '<div class="cclosed"><input ' . $checked . ' type="checkbox" class="checkbox atp-input " value="on" name="' . $value['id'] . '_close" id="' . $value['id'] . '_close"> <label for="' . $value['id'] . '_close">' . __('Check this if you wish the display this day as closed.', 'iva_theme_admin') . '</label></div>';
                break;
                // CLOSED HOURS
                //---------------------------------
            // CLOSED HOURS
            //---------------------------------
            case 'closehours':
                $interval = get_option('iva_time_interval') ? get_option('iva_time_interval') : '15';
                $iva_time_interval = '+' . $interval . 'minutes';
                $optionid = get_option($value['id']);
                $iva_weekdays = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
                foreach ($iva_weekdays as $key => $day) {
                    $iva_hrs = get_option('iva_' . $day);
                    $iva_stored_val = $optionid[$key];
                    $open_hrs = strtotime($iva_hrs['opening']);
                    $close_hrs = strtotime($iva_hrs['closing']);
                    $closed_hrs = $iva_hrs['close'];
                    if ($closed_hrs == 'off') {
                        $output .= '<h3>' . ucfirst($day) . '</h3>';
                        $output .= '<div class="hours">';
                        $output .= '<select class=" of-input  "  multiple="multiple"  name="' . $value['id'] . '_' . $key . '_closed[]" id="' . $value['id'] . '_' . $key . '_closed[]">';
                        while ($open_hrs < $close_hrs) {
                            $iva_time_hrs = date('H:i', $open_hrs);
                            $selected = '';
                            if (get_option($value['id'])) {
                                if (@in_array($iva_time_hrs, $iva_stored_val)) {
                                    $selected = "selected=\"selected\"";
                                }
                            } else {
                            }
                            $output .= '<option value="' . $iva_time_hrs . '" ' . $selected . '>' . $iva_time_hrs . '</option>';
                            $open_hrs = strtotime($iva_time_interval, $open_hrs);
                        }
                        $output .= '</select></div>';
                    }
                }
                break;
                // S O C I A B L E S
                //---------------------------------
            // S O C I A B L E S
            //---------------------------------
            case 'custom_socialbook_mark':
                global $socialimages_select, $iva_sociable;
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div id="sys_social_book">';
                $output .= '<h2>Social Websites</h2>';
                $output .= '<table id="sys_socialbookmark" class="fancy_table">';
                $output .= '<tr>';
                $output .= '<th width="100">Website</th>';
                $output .= '<th width="100">URL</th>';
                $output .= '<th width="100">Tool Tip</th>';
                $output .= '<th align="center" width="70">' . __('Delete', 'iva_theme_admin') . '</th>';
                $output .= '</tr>';
                if (get_option('atp_social_bookmark') != '') {
                    $sys_social_items = explode('#;', get_option('atp_social_bookmark'));
                    for ($i = 0; $i < count($sys_social_items); $i++) {
                        $sys_social_item = explode('#|', $sys_social_items[$i]);
                        $output .= '<tr>';
                        $output .= '<td>';
                        //$iva_sociable = '';
                        $output .= '<select id="sys_social_file_icon" class="sys_social_file_icon" name="sys_social_file_icon"  width="300">';
                        foreach ($iva_sociable as $key => $values) {
                            $selected = $sys_social_item[1] == $key ? ' selected="selected"' : '';
                            $output .= '<option ' . $selected . ' value="' . $key . '" >' . $values . '</option>';
                            $selected = "";
                        }
                        $output .= '</select>';
                        $output .= '</td>';
                        $output .= '<td><input type="text" class="sys_social_account_url" value="' . $sys_social_item[2] . '" /></td>';
                        $output .= '<td><input type="text" class="sys_social_title" value="' . $sys_social_item[0] . '" /></td>';
                        $output .= '<td><a href="#" class="sys_social_item_delete button button-primary red-button">' . __('Delete', 'iva_theme_admin') . '</a></td>';
                        $output .= '</tr>';
                    }
                }
                $output .= '</table>';
                $output .= '<p>';
                $output .= '<button name="sys_add_social_book" id="sys_add_social_item" type="button" value="Add New Row" class="button button-primary red-button" /><span>' . __('Add New', 'iva_theme_admin') . '</span></button>';
                $output .= '<input type="hidden" id="atp_social_bookmark" name="atp_social_bookmark"/>';
                $output .= '</p>';
                $output .= '</div></div>';
                break;
                // S I D E B A R
                //---------------------------------
            // S I D E B A R
            //---------------------------------
            case 'customsidebar':
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $val = $value['std'];
                $std = get_option($value['id']);
                $custom_sidebar_arr = @get_option($value['id']);
                // print_r($custom_sidebar_arr);
                if ($std != "") {
                    $val = $std;
                }
                $output .= '<div id="custom_widget_sidebar"><table id="custom_widget_table" cellpadding="0" cellspacing="0">';
                $output .= '<tbody>';
                if ($custom_sidebar_arr != "") {
                    foreach ($custom_sidebar_arr as $custom_sidebar_code) {
                        $output .= '<tr><td><input type="text" name="' . $value['id'] . '[]" value="' . $custom_sidebar_code . '"  size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0)" onClick="jQuery(this).parent().parent().remove();">' . __('Delete', 'iva_theme_admin') . '</a></td></tr>';
                    }
                }
                $output .= '</tbody></table><button type="button" class="button button-primary button-large" name="add_custom_widget" value="Add Sidebar" onClick="addWidgetRow()">' . __('Add Sidebar', 'iva_theme_admin') . '</button></div>';
                ?>
						<script type="text/javascript" language="javascript">
							function addWidgetRow(){
								jQuery('#custom_widget_table').append('<tr><td><input type="text" name="<?php 
                echo $value['id'];
                ?>
[]" value="" size="30" style="width:97%" /></td><td><a class="button button-secondary" href="javascript:void(0)" onClick="jQuery(this).parent().parent().remove();"><?php 
                _e('Delete', 'iva_theme_admin');
                ?>
</a></td></tr>');
							}
						</script>
						<?php 
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // T E X T A R E A
                //---------------------------------
            // T E X T A R E A
            //---------------------------------
            case 'textarea':
                $cols = '8';
                $ta_value = '';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="explain">' . $explain_value . '</div>';
                $output .= '<div class="controls" >' . "\n";
                if (isset($value['std'])) {
                    $ta_value = $value['std'];
                    if (isset($value['options'])) {
                        $ta_options = $value['options'];
                        if (isset($ta_options['cols'])) {
                            $cols = $ta_options['cols'];
                        } else {
                            $cols = '8';
                        }
                    }
                }
                $std = get_option($value['id']);
                if ($std != "") {
                    $ta_value = stripslashes($std);
                }
                $output .= '<textarea class="atp-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . esc_textarea($ta_value) . '</textarea>';
                $output .= '</div>';
                break;
                // E X P O R T
                //---------------------------------
            // E X P O R T
            //---------------------------------
            case 'export':
                $cols = '8';
                $ta_value = '';
                $std = get_option($value['id']);
                if ($std != "") {
                    $ta_value = stripslashes($std);
                }
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                //$output .= serialize((get_option('atp_template_option_values')));
                $output .= '<textarea class="atp-input" cols="' . $cols . '" rows="8">' . base64_encode(serialize(get_option('atp_template_option_values'))) . '</textarea>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // I M P O R T
                //---------------------------------
            // I M P O R T
            //---------------------------------
            case 'import':
                $cols = '8';
                $ta_value = '';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<textarea class="atp-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8"></textarea>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // R A D I O
                //---------------------------------
            // R A D I O
            //---------------------------------
            case "radio":
                $select_value = get_option($value['id']);
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                foreach ($value['options'] as $key => $option) {
                    $checked = '';
                    if ($select_value != '') {
                        if ($select_value == $key) {
                            $checked = ' checked';
                        }
                    } else {
                        if ($value['std'] == $key) {
                            $checked = ' checked';
                        }
                    }
                    $output .= '<div class="controls" >' . "\n";
                    $output .= '<input class="atp-input atp-radio" type="radio" name="' . $value['id'] . '" value="' . $key . '" ' . $checked . ' />' . $option . '<br />';
                    $output .= '</div>';
                }
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // CHECKBOX
                //---------------------------------
            // CHECKBOX
            //---------------------------------
            case "checkbox":
                $std = $value['std'];
                $saved_std = get_option($value['id']);
                $checked = '';
                if (!empty($saved_std)) {
                    if ($saved_std == 'on') {
                        $checked = 'checked="checked"';
                    } else {
                        $checked = '';
                    }
                } elseif ($std == 'on') {
                    $checked = 'checked="checked"';
                } else {
                    $checked = '';
                }
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<input type="checkbox" class="checkbox" value="on" id="' . $value['id'] . '" name="' . $value['id'] . '" ' . $checked . ' />';
                $output .= '</div>';
                $output .= '<div class="explain"><label for="' . $value['id'] . '">' . $explain_value . '</label></div>';
                break;
                // M U L T I   C H E C K B O X
                //---------------------------------
            // M U L T I   C H E C K B O X
            //---------------------------------
            case "multicheck":
                $std = $value['std'];
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                foreach ($value['options'] as $key => $option) {
                    $checked = "";
                    if (get_option($value['id'])) {
                        if (@in_array($key, get_option($value['id']))) {
                            $checked = "checked=\"checked\"";
                        }
                    } else {
                        //Empty Value if Unchecked
                    }
                    $output .= '<input type="checkbox" class="checkbox" name="' . $value['id'] . '[]" id="' . $key . '" value="' . $key . '" ' . $checked . ' /> <label for="' . $key . '">' . $option . '</label><br>';
                }
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // U P L O A D
                //---------------------------------
            // U P L O A D
            //---------------------------------
            case "upload":
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= optionsframework_medialibrary_uploader($value['id'], $val, null);
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // C O L O R
                //---------------------------------
            // C O L O R
            //---------------------------------
            case "color":
                $val = $value['std'];
                $stored = get_option($value['id']);
                if ($stored != "") {
                    $val = $stored;
                }
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<input class="color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . $val . '" />';
                $output .= '<div class="wpcolorSelector"><div  id="' . $value['id'] . '_picker" ></div></div>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // T Y P O G R A P H Y
                //---------------------------------
            // T Y P O G R A P H Y
            //---------------------------------
            case "typography":
                $default = $value['std'];
                $typography_stored = get_option($value['id']);
                $output .= '<h3 class="heading">' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                // C O L O R
                if (isset($default['color'])) {
                    $val = $default['color'];
                }
                if ($typography_stored['color'] != "") {
                    $val = $typography_stored['color'];
                }
                $output .= '<div class="typocolor"><input class="atp-color atp-typography color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . $val . '" />';
                $output .= '<div class="wpcolorSelector"><div id="' . $value['id'] . '_color_picker"></div></div></div>';
                // F O N T   S I Z E
                $val = $default['size'];
                if ($typography_stored['size'] != "") {
                    $val = $typography_stored['size'];
                }
                $output .= '<div class="atp-typo-size"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_size" id="' . $value['id'] . '_size">';
                $output .= '<option value="">' . __('Font Size', 'iva_theme_admin') . '</option>';
                for ($i = 9; $i < 71; $i++) {
                    if ($val == $i) {
                        $active = 'selected="selected"';
                    } else {
                        $active = '';
                    }
                    $output .= '<option value="' . $i . 'px" ' . $active . '>' . $i . 'px</option>';
                }
                $output .= '</select></div></div>';
                // L I N E   H E I G H T
                $val = $default['lineheight'];
                if ($typography_stored['lineheight'] != "") {
                    $val = $typography_stored['lineheight'];
                }
                $output .= '<div class="atp-typo-lineheight"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_lineheight" id="' . $value['id'] . '_lineheight">';
                $output .= '<option value="">' . __('Line Height', 'iva_theme_admin') . '</option>';
                for ($i = 9; $i < 71; $i++) {
                    if ($val == $i) {
                        $active = 'selected="selected"';
                    } else {
                        $active = '';
                    }
                    $output .= '<option value="' . $i . 'px" ' . $active . '>' . $i . 'px</option>';
                }
                $output .= '</select></div></div>';
                // F O N T   S T Y L E
                $val = $default['style'];
                if ($typography_stored['style'] != "") {
                    $val = $typography_stored['style'];
                }
                $normal = '';
                $italic = '';
                if ($val == 'normal') {
                    $normal = 'selected="selected"';
                }
                if ($val == 'italic') {
                    $italic = 'selected="selected"';
                }
                $output .= '<div class="atp-typo-style"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_style" id="' . $value['id'] . '_style">';
                $output .= '<option value="">' . __('Font-Style', 'iva_theme_admin') . '</option>';
                $output .= '<option value="normal" ' . $normal . '>Normal</option>';
                $output .= '<option value="italic" ' . $italic . '>Italic</option>';
                $output .= '</select></div></div>';
                // F O N T   V A R I A N T
                if (isset($default['fontvariant'])) {
                    $val = $default['fontvariant'];
                }
                if ($typography_stored['fontvariant'] != "") {
                    $val = $typography_stored['fontvariant'];
                }
                $array_weight = array('normal' => 'Normal', 'bold' => 'Bold', 'lighter' => 'Lighter', '100' => '100', '200' => '200', '300' => '300', '400' => '400', '500' => '500', '600' => '600', '700' => '700', '800' => '800', '900' => '900');
                $output .= '<div class="atp-typo-fontvariant"><div class="select_wrapper"><select class="select" name="' . $value['id'] . '_fontvariant" id="' . $value['id'] . '_fontvariant">';
                $output .= '<option value="">' . __('Font-Variant', 'iva_theme_admin') . '</option>';
                foreach ($array_weight as $key => $values) {
                    $fontselected = '';
                    if ($val == $key) {
                        $fontselected = 'selected="selected"';
                    }
                    $output .= '<option value="' . $key . '" ' . $fontselected . '>' . $values . '</option>';
                }
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '</div>';
                // section-typography end.
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // F O N T  F A M I L Y S E L E C T
            // F O N T  F A M I L Y S E L E C T
            case 'atpfontfamily':
                global $iva_fontface;
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div class="select_wrapper ' . $value['class'] . '">';
                $output .= '<select class="of-input select  google_font_select" name="' . $value['id'] . '" id="' . $value['id'] . '">';
                foreach ($value['options'] as $select_key => $option) {
                    $output .= '<option value="' . $select_key . '" ' . selected(get_option($value['id']), $key, false) . ' />' . $option . '</option>';
                }
                $google_fonts = atp_google_webfonts();
                $output .= '<optgroup label="Google Web Fonts">';
                foreach ($google_fonts as $key => $googlefont) {
                    $name = $googlefont['name'];
                    $output .= '<option value="' . $name . '" ' . selected(get_option($value['id']), $name, false) . ' />' . $name . '</option>';
                }
                $output .= '</optgroup>';
                $output .= '</select></div>';
                if (isset($value['preview']['text'])) {
                    $g_text = $value['preview']['text'];
                } else {
                    $g_text = '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz';
                }
                if (isset($value['preview']['size'])) {
                    $g_size = 'style="font-size: ' . $value['preview']['size'] . ';"';
                } else {
                    $g_size = '';
                }
                $hide = "hide";
                if (get_option($value['id']) != "") {
                    $hide = "";
                }
                $output .= '<p  class="' . $value['id'] . '_ggf_previewer google_font_preview ' . $hide . '" ' . $g_size . '>' . $g_text . '</p>';
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // B A C K G R O U N D
                //---------------------------------
            // B A C K G R O U N D
            //---------------------------------
            case "background":
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $default = $value['std'];
                $background_stored = get_option($value['id']);
                // U P L O A D   I M A G E
                $val = $default['image'];
                $imgid = $value['id'] . '_image';
                if ($background_stored['image'] != "") {
                    $val = $background_stored['image'];
                }
                $output .= '<div class="atp-background-upload clearfix">';
                $output .= optionsframework_medialibrary_uploader($imgid, $val, null);
                $output .= '</div>';
                // C O L O R
                $val = $default['color'];
                if ($background_stored['color'] != "") {
                    $val = $background_stored['color'];
                }
                $output .= '<div class="atp-background-color">';
                $output .= '<input class="color" name="' . $value['id'] . '_color" id="' . $value['id'] . '_color" type="text" value="' . $val . '" />';
                $output .= '<div class="wpcolorSelector"><div  id="' . $value['id'] . '_color_picker" ></div></div>';
                $output .= '</div>';
                // R E P E A T
                $val = $default['style'];
                if ($background_stored['style'] != "") {
                    $val = $background_stored['style'];
                }
                $repeat = '';
                $norepeat = '';
                $repeatx = '';
                $repeaty = '';
                if ($val == 'repeat') {
                    $repeat = 'selected="selected"';
                }
                if ($val == 'no-repeat') {
                    $norepeat = 'selected="selected"';
                }
                if ($val == 'repeat-x') {
                    $repeatx = 'selected="selected"';
                }
                if ($val == 'repeat-y') {
                    $repeaty = 'selected="selected"';
                }
                $output .= '<div class="atp-background-repeat">';
                $output .= '<div class="select_wrapper">';
                $output .= '<select class="atp-background select" name="' . $value['id'] . '_style" id="' . $value['id'] . '_style">';
                $output .= '<option value="repeat" ' . $repeat . '>Repeat</option>';
                $output .= '<option value="no-repeat" ' . $norepeat . '>No-Repeat</option>';
                $output .= '<option value="repeat-x" ' . $repeatx . '>Repeat-X</option>';
                $output .= '<option value="repeat-y" ' . $repeaty . '>Repeat-Y</option>';
                $output .= '</select>';
                $output .= '</div></div>';
                // P O S I T I O N
                $val = $default['position'];
                if ($background_stored['position'] != "") {
                    $val = $background_stored['position'];
                }
                $lefttop = '';
                $leftcenter = '';
                $leftbottom = '';
                $righttop = '';
                $rightcenter = '';
                $rightbottom = '';
                $centertop = '';
                $centercenter = '';
                $centerbottom = '';
                if ($val == 'left top') {
                    $lefttop = 'selected="selected"';
                }
                if ($val == 'left center') {
                    $leftcenter = 'selected="selected"';
                }
                if ($val == 'left bottom') {
                    $leftbottom = 'selected="selected"';
                }
                if ($val == 'right top') {
                    $righttop = 'selected="selected"';
                }
                if ($val == 'right center') {
                    $rightcenter = 'selected="selected"';
                }
                if ($val == 'right bottom') {
                    $rightbottom = 'selected="selected"';
                }
                if ($val == 'center top') {
                    $centertop = 'selected="selected"';
                }
                if ($val == 'center center') {
                    $centercenter = 'selected="selected"';
                }
                if ($val == 'center bottom') {
                    $centerbottom = 'selected="selected"';
                }
                $output .= '<div class="atp-background-position">';
                $output .= '<div class="select_wrapper">';
                $output .= '<select class="atp-background select" name="' . $value['id'] . '_position" id="' . $value['id'] . '_style">';
                $output .= '<option value="left top" ' . $lefttop . '>Left Top</option>';
                $output .= '<option value="left center" ' . $leftcenter . '>Left Center</option>';
                $output .= '<option value="left bottom" ' . $leftbottom . '>Left Bottom</option>';
                $output .= '<option value="right top" ' . $righttop . '>Right Top</option>';
                $output .= '<option value="right center" ' . $rightcenter . '>Right Center</option>';
                $output .= '<option value="right bottom" ' . $rightbottom . '>Right Bottom</option>';
                $output .= '<option value="center top" ' . $centertop . '>Center Top</option>';
                $output .= '<option value="center center" ' . $centercenter . '>Center Center</option>';
                $output .= '<option value="center bottom" ' . $centerbottom . '>Center Bottom</option>';
                $output .= '</select>';
                $output .= '</div></div>';
                // A T T A C H M E N T
                $val = $default['attachment'];
                if ($background_stored['attachment'] != "") {
                    $val = $background_stored['attachment'];
                }
                $fixed = $scroll = '';
                if ($val == 'fixed') {
                    $fixed = 'selected="selected"';
                }
                if ($val == 'scroll') {
                    $scroll = 'selected="selected"';
                }
                $output .= '<div class="atp-background-attachment">';
                $output .= '<div class="select_wrapper">';
                $output .= '<select class="atp-background select" name="' . $value['id'] . '_attachment" id="' . $value['id'] . '_style">';
                $output .= '<option value="fixed" ' . $fixed . '>Fixed</option>';
                $output .= '<option value="scroll" ' . $scroll . '>Scroll</option>';
                $output .= '</select>';
                $output .= '</div></div>';
                $output .= '</div>';
                //controls part end
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // I M A G E S
                //---------------------------------
            // I M A G E S
            //---------------------------------
            case "images":
                $i = 0;
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $select_value = get_option($value['id']);
                foreach ($value['options'] as $key => $option) {
                    $i++;
                    $checked = $selected = '';
                    if ($select_value != '') {
                        if ($select_value == $key) {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        }
                    } else {
                        if ($value['std'] == $key) {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        } elseif ($i == 1 && !isset($select_value)) {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        } elseif ($i == 1 && $value['std'] == '') {
                            $checked = ' checked';
                            $selected = 'atp-radio-option-selected';
                        } else {
                            $checked = '';
                        }
                    }
                    $output .= '<span>';
                    $output .= '<input type="radio" id="atp-radio-img-' . $value['id'] . $i . '" class="checkbox atp-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />';
                    $output .= '<div class="atp-radio-img-label">' . $key . '</div>';
                    $output .= '<img src="' . esc_url($option) . '" alt="" class="atp-radio-option ' . $selected . '" onClick="document.getElementById(\'atp-radio-img-' . $value['id'] . $i . '\').checked = true;" />';
                    $output .= '</span>';
                }
                $output .= '</div>';
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // H E A D I N G
                //---------------------------------
            // H E A D I N G
            //---------------------------------
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = str_replace(' ', '', strtolower($value['name']));
                $jquery_click_hook = "atp-option-" . trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($jquery_click_hook))))));
                $output .= '<div class="group" id="' . $jquery_click_hook . '">' . "\n";
                break;
                //S U B  N A V I G A T I O N
                //---------------------------------
            //S U B  N A V I G A T I O N
            //---------------------------------
            case "subnav":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = str_replace(' ', '', strtolower($value['name']));
                $jquery_click_hook = "atp-option-" . trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($jquery_click_hook))))));
                $output .= '<div class="group" id="' . $jquery_click_hook . '">' . "\n";
                break;
            case 'export_backupoptions':
                $output .= '<form class="export_form" method="post" enctype="multipart/form-data">';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div class="iva_export_ob_msg"></div>';
                // Export Backup options
                $output .= '<span class="iva_style_wrap"><a href="#" class="export-data-btn button-primary button-large" data_url= ' . admin_url("admin.php?page=optionsframework") . '>' . __('Export Options', 'iva_theme_admin') . '</a></span>';
                $output .= '<div class="clearfix"></div>';
                $ob_path = FRAMEWORK_DIR . '/admin/options_backup/';
                $latest_ctime = 0;
                $entry = $latest_ob_filename = '';
                $dir_instance = dir($ob_path);
                while (false !== ($entry = $dir_instance->read())) {
                    $ob_filepath = "{$ob_path}/{$entry}";
                    // could do also other checks than just checking whether the entry is a file
                    if (is_file($ob_filepath) && filectime($ob_filepath) > $latest_ctime) {
                        $latest_ctime = filectime($ob_filepath);
                        $latest_ob_filename = $entry;
                    }
                }
                $theme_options_txt_files1 = array();
                if (is_dir(FRAMEWORK_DIR . '/admin/options_backup/')) {
                    if ($theme_options_backup_dir = opendir(FRAMEWORK_DIR . '/admin/options_backup/')) {
                        while (($theme_options_txt_file = readdir($theme_options_backup_dir)) !== false) {
                            if (stristr($theme_options_txt_file, '.txt') !== false) {
                                $theme_options_txt_files1[$theme_options_txt_file] = $theme_options_txt_file;
                            }
                        }
                    }
                }
                if (!empty($theme_options_txt_files1)) {
                    $ob_file_info = pathinfo($latest_ob_filename);
                    $ob_file_name = $ob_file_info['filename'];
                    $output .= '<div class="export_wrap">';
                    $output .= '<div class="export_ob_wrap"><div class="export_ob_title">' . $ob_file_name . '</div></div>';
                    $output .= '<div class="export_ob_btn"><span><a class="ob_download button green-button" data_download="' . $latest_ob_filename . '">' . __('download', 'iva_theme_admin') . '</a></span></div>';
                    $output .= '</div>';
                    //.export_wrap
                }
                $output .= '<div class="clearfix"></div>';
                $output .= '</div>';
                //.controls
                $output .= '<div class="explain">' . $explain_value . '</div>';
                $output .= '<script>
						jQuery(document).ready(function () {
							jQuery(".ob_download").click(function(){
								var ob_download_file = jQuery(this).attr("data_download");
								jQuery.post(
									atp_panel.SiteUrl+"/framework/admin/ob_import_export.php",
									{ 
									download_file:ob_download_file,
									},
									function(response) {
										window.location	= atp_panel.SiteUrl+"/framework/admin/ob_import_export.php?download_file="+ob_download_file+"";
									}
								);
							});
							jQuery(".export-data-btn").click(function(){
								
								var iva_admin_url = jQuery(this).attr("data_url");
								jQuery.ajax({ 
									type: "POST",
									url:ajaxurl,
									data: { action: "iva_export_ob" },
									success: function( response ){ 
										jQuery(".iva_export_ob_msg").html("Export Options Backup Successfully Please wait a few seconds untill reload the page");
										jQuery(".iva_export_ob_msg").css( "display", "block" );
										window.location = iva_admin_url;
										window.location.reload(true);
									}
								});
							});
						});
						</script>';
                break;
            case 'import_backupoptions':
                $output .= '<form class="export_form" method="post" enctype="multipart/form-data">';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $output .= '<div class="iva_import_ob_msg"></div>';
                $output .= '<div class="clearfix"></div>';
                $theme_options_txt_files = array();
                if (is_dir(FRAMEWORK_DIR . '/admin/options_backup/')) {
                    if ($theme_options_backup_dir = opendir(FRAMEWORK_DIR . '/admin/options_backup/')) {
                        while (($theme_options_txt_file = readdir($theme_options_backup_dir)) !== false) {
                            if (stristr($theme_options_txt_file, '.txt') !== false) {
                                $theme_options_txt_files[$theme_options_txt_file] = $theme_options_txt_file;
                            }
                        }
                    }
                }
                ksort($theme_options_txt_files);
                if (!empty($theme_options_txt_files)) {
                    $i = 1;
                    foreach ($theme_options_txt_files as $ob_txt_name => $ob_txt_value) {
                        $ob_file_info = pathinfo($ob_txt_value);
                        $ob_file_name = $ob_file_info['filename'];
                        $output .= '<div class="export_wrap">';
                        $output .= '<div class="export_ob_wrap"><div class="export_ob_title">' . $i . '. ' . $ob_file_name . '</div></div>';
                        $output .= '<div class="export_ob_btn">';
                        $output .= '	<span><a class="ob_import button green-button" data_url= ' . admin_url("admin.php?page=optionsframework") . ' data_import="' . $ob_txt_name . '">' . __('Import', 'iva_theme_admin') . '</a></span>';
                        $output .= '	<span><a class="ob_delete button red-button" data_url= ' . admin_url("admin.php?page=optionsframework") . ' data_delete="' . $ob_txt_name . '" >' . __('Delete', 'iva_theme_admin') . '</a></span>';
                        $output .= '</div>';
                        //.export_ob_btn
                        $output .= '</div>';
                        //.export_wrap
                        $i++;
                    }
                }
                $output .= '<div class="clearfix"></div>';
                $iva_ob_txtarea_cols = '8';
                $output .= '<div class="import-options-bkp">';
                $output .= '<p>' . __('Input your sample options data exported in a text file to restore. Copy the content from the text file then place in below textarea and hit <strong>Import File</strong> button', 'iva_theme_admin') . '</p>';
                $output .= '<textarea class="atp-input import_ob_input" id="import_ob_input" cols="' . $iva_ob_txtarea_cols . '" rows="8" data_url= ' . admin_url("admin.php?page=optionsframework") . '></textarea>';
                $output .= '	<span><a class="import_options_btn button green-button button-hero" data_url= ' . admin_url("admin.php?page=optionsframework") . '>' . __('Import File', 'iva_theme_admin') . '</a></span>';
                $output .= '</div>';
                $output .= '</div>';
                //.controls
                $output .= '<div class="explain">' . $explain_value . '</div>';
                $output .= '<script>
						jQuery(document).ready(function () {
							jQuery(".import_options_btn").click(function(){
								 var import_ob_input_value = jQuery(".import_ob_input").val();
								 var iva_admin_url = jQuery(this).attr("data_url");
								 
								 if( import_ob_input_value == "" ){
									alert("Enter content from a txt file.");
									return false;
								 }
								 if( import_ob_input_value ){
									jQuery.ajax({ 
										type: "POST",
										url:ajaxurl,
										data: { 
											action: "iva_import_ob_from_file" ,
											"import_ob_file": import_ob_input_value,
											},
										success: function( response ){ 
											
											jQuery(".iva_import_ob_msg").html("Imported Successfully Please wait a few seconds untill reload the page");
											jQuery(".iva_import_ob_msg").css( "display", "block" );
											
											window.location = iva_admin_url;
											window.location.reload(true);
										}
									});
								}	 
							}); 
						
							jQuery(".ob_delete").click(function(){
								var ob_delete_file = jQuery(this).attr("data_delete");
								var iva_admin_url = jQuery(this).attr("data_url");
								if( confirm("Are you sure you want to delete file permanently?") ){
									jQuery(this).parent().parent().parent().remove();
									jQuery.ajax({ 
										type: "POST",
										url:ajaxurl,
										data: { 
											action: "iva_delete_ob" ,
											"delete_file": ob_delete_file,
											},
										success: function( response ){ 
											
											jQuery(".iva_import_ob_msg").html("Deleted successfully Please wait a few seconds untill reload the page");
											jQuery(".iva_import_ob_msg").css( "display", "block" );
											
											window.location = iva_admin_url;
											window.location.reload(true);
										}
									});
								}	
							});
							jQuery(".ob_import").click(function(){
								var iva_admin_url = jQuery(this).attr("data_url");
								var iva_ob_import = jQuery(this).attr("data_import");
								
								jQuery.ajax({ 
									type: "POST",
									url:ajaxurl,
									data: { 
										action: "iva_import_ob" ,
										"ob_import":iva_ob_import,
									},
									success: function( response ){ 
										jQuery(".iva_import_ob_msg").html("Imported Successfully Please wait a few seconds untill reloading the page");
										jQuery(".iva_import_ob_msg").css( "display", "block" );
										// setInterval(function(){
											// jQuery(".iva_import_ob_msg").css( "display", "none" );
										// },2000);
										window.location = iva_admin_url;
										window.location.reload(true);
									}
								});
							});
						});
						</script>';
                break;
            case 'importsampledata':
                $output .= '<div class="one-click"></div>';
                $output .= '<form class="import_form" method="post" enctype="multipart/form-data">';
                $output .= '<div class="iva_import_content">';
                $output .= '<h1>' . $value['name'] . '</h1>';
                $output .= $explain_value;
                // Success message
                $output .= '<span class="iva_import_result"></span>';
                // Button
                $output .= '<div class="iva_import_button"><a href="#" class="import-data-btn button button-primary green-button button-hero">' . __('Import Sample Content', 'iva_theme_admin') . '</a></div>';
                $output .= '<div class="iva_import_alerts">';
                // Loader
                $output .= '<span class="iva_loading iva_import_loading"></span>';
                // Waiting message
                $output .= '<div class="iva_import_wait">' . __('<strong>Import Started.</strong><br/>Please wait a few seconds and dont reload the page. You will be notified as soon as the import has finished! :)', 'iva_theme_admin') . '</div>';
                $output .= '</div>';
                $output .= '</div>';
                $output .= '<script>
						jQuery(document).ready(function () {
							jQuery(".import-data-btn").click(function(){
								activate = confirm("Importing the sample data will overwrite your current pages and content. Please make sure you take a backup of content and proceed with importing.");
								if(activate == false) return false; 
								jQuery.ajax({ 
									type: "POST",
									url:ajaxurl,
									data: { action: "iva_importer" },
									beforeSend: function()
									{
										//Show loader
										jQuery(".iva_loading").css({ opacity:0, display:"block"}).animate({opacity:1});
										jQuery(".iva_import_wait").show();
									},
									success: function(response)
									{	
										jQuery(".iva_import_result").css({ display:"inline-block"});
										
										if(response.match("No xml file exists in data folder")){
											jQuery(".iva_import_result").html("No xml file exists in data folder");
										}
										else if(response.match("An Error Occurred During Import")){
											jQuery(".iva_import_result").html("An Error Occurred During Import");
										}else if(response.match("All done")){
											jQuery(".iva_import_result").html("Content Imported Successfully");
										}else if(response.match("already exists")){
											jQuery(".iva_import_result").html("Content Imported Successfully");
										}
										setInterval(function(){
											jQuery(".iva_import_result").css( "display", "none" );
										},3000);
									},
									complete: function( response )
									{	
										jQuery(".iva_import_wait").hide();
										jQuery(".iva_loading").css({ display:"none"});   
									}
								});
							});
						});
						</script>';
                break;
                // Mega menu case
            // Mega menu case
            case 'mmenu_ancestor':
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $mm_img_val = $mm_position = '';
                $mm_pright = $mm_pbottom = $mm_pleft = '0';
                $mm_img_id = $value['id'] . '_image';
                $mmenu_stored = get_option($value['id']);
                if ($mmenu_stored != '') {
                    $mm_img_val = $mmenu_stored['image'];
                    $mm_pright = $mmenu_stored['pright'];
                    $mm_pbottom = $mmenu_stored['pbottom'];
                    $mm_pleft = $mmenu_stored['pleft'];
                    $mm_position = $mmenu_stored['position'];
                }
                $output .= '<div class="mm_upload atp-background-upload clearfix">';
                $output .= optionsframework_medialibrary_uploader($mm_img_id, $mm_img_val, null);
                $output .= '</div>';
                $position_lb = $position_rb = $position_cb = '';
                // Adds selected attribute for the option value
                if ($mm_position == 'left bottom') {
                    $position_lb = ' selected="selected"';
                }
                if ($mm_position == 'right bottom') {
                    $position_rb = ' selected="selected"';
                }
                if ($mm_position == 'center bottom') {
                    $position_cb = ' selected="selected"';
                }
                $output .= '<div class="mm_desc">Background position</div>';
                $output .= '<div class="select_wrapper select200">';
                $output .= '<select class="atp-background select" name="' . $value['id'] . '_position" id="' . $value['id'] . '_position">';
                $output .= '<option value="left bottom" ' . $position_lb . '>Left Bottom</option>';
                $output .= '<option value="right bottom" ' . $position_rb . '>Right Bottom</option>';
                $output .= '<option value="center bottom" ' . $position_cb . '>Center Bottom</option>';
                $output .= '</select>';
                $output .= '</div>';
                //select_wrapper
                $output .= '<div class="clear"></div>';
                $output .= '<div class="mm_wrap">';
                $output .= '<div class="mm_desc">Padding</div>';
                $output .= '<input class="input40 input_disable" name="' . $value['id'] . '_ptop" id="' . $value['id'] . '_ptop" type="text" readonly="readonly" value="25"/>';
                $output .= '<input class="input40" name="' . $value['id'] . '_pright" id="' . $value['id'] . '_pright" type="text"  value="' . $mm_pright . '" />';
                $output .= '<input class="input40" name="' . $value['id'] . '_pbottom" id="' . $value['id'] . '_pbottom" type="text" value="' . $mm_pbottom . '" />';
                $output .= '<input class="input40" name="' . $value['id'] . '_pleft" id="' . $value['id'] . '_pleft" type="text" value="' . $mm_pleft . '" />';
                $output .= '<div class="mm_desc"><span>Top</span><span>Right</span><span>Bottom</span><span>Left</span></div>';
                $output .= '</div>';
                //mm_wrap
                $output .= '</div>';
                //controls part end
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
                // C U S T O M D A T E S
                //---------------------------------
            // C U S T O M D A T E S
            //---------------------------------
            case 'add_custom_dates':
                $c = 0;
                $output .= '<script type="text/javascript">
								jQuery(document).ready(function($) {
									jQuery(".iva_custom_datepicker").each(function(){
										var iva_custom_dateid = jQuery(this).attr("id");								
										jQuery( "#"+iva_custom_dateid ).datepicker({ dateFormat: "m/d/yy" });
										jQuery( "#ui-datepicker-div" ).addClass("iva-date-ui");	
									});
								});			
							</script>';
                $output .= '<h3>' . $value['name'] . '</h3>' . "\n";
                $output .= '<div class="controls" >' . "\n";
                $val = $value['std'];
                $std = get_option($value['id']);
                $custom_dates = @get_option($value['id']);
                if ($std != "") {
                    $val = $std;
                }
                $output .= '<div id="custom_date"><table id="iva_custom_date_table" cellpadding="0" cellspacing="0">';
                $output .= '<tbody>';
                if ($custom_dates != '') {
                    foreach ($custom_dates as $custom_date_value) {
                        $output .= '<tr><td><input type="text" class="iva_custom_datepicker" id="' . $value['id'] . $c . '" name="' . $value['id'] . '[]" value="' . $custom_date_value . '"  size="30" style="width:97%" /></td><td><a class="red-button button button-secondary" href="javascript:void(0)" onClick="jQuery(this).parent().parent().remove();">Delete</a></td></tr>';
                        $c = $c + 1;
                    }
                }
                $output .= '</tbody>';
                $output .= '</table><button type="button" class="green-button  button button-primary button-large" name="add_custom_date" value="Add Date" onClick="add_date_Row()">Add Date</button></div>';
                ?>
							<script type="text/javascript" language="javascript">
							var count = <?php 
                echo $c;
                ?>
;
							function add_date_Row(){
								count = count + 1;								
								jQuery('#iva_custom_date_table').append('<tr><td><input type="text" class="iva_custom_datepicker" id="<?php 
                echo $value['id'];
                ?>
'+count+'" name="<?php 
                echo $value['id'];
                ?>
[]" value="" size="30" style="width:97%" /></td><td><a class="red-button  button button-secondary" href="javascript:void(0)" onClick="jQuery(this).parent().parent().remove();">Delete</a></td></tr>');
								jQuery(".iva_custom_datepicker").each(function(){
									var iva_custom_dateid = jQuery(this).attr("id");								
									jQuery("#"+iva_custom_dateid ).datepicker({ dateFormat: "m/d/yy" });
									jQuery("#ui-datepicker-div").addClass("iva-date-ui");	
								});
							}
							</script>
							<?php 
                $output .= '</div>';
                //.controls
                $output .= '<div class="explain">' . $explain_value . '</div>';
                break;
        }
        //------------------------------------
        //	E N D   S W I T C H   C A S E
        //------------------------------------
        // Option Value Type
        // if TYPE is an array, formatted into smaller inputs... ie smaller values
        if (is_array($value['type'])) {
            foreach ($value['type'] as $array) {
                $id = $array['id'];
                $std = $array['std'];
                $saved_std = get_option($id);
                if ($saved_std != $std) {
                    $std = $saved_std;
                }
                $meta = $array['meta'];
                if ($array['type'] == 'text') {
                    // Only text at this point
                    $output .= '<input class="input-text-small atp-input" name="' . $id . '" id="' . $id . '" type="text" value="' . $std . '" />';
                    $output .= '<span class="meta-two">' . $meta . '</span>';
                }
            }
        }
        // Option Value not equals to Headings and checkbox
        if ($value['type'] != "heading" && $value['type'] != "subnav") {
            if ($value['type'] != "checkbox") {
                $output .= '';
            }
            $output .= '</div>' . "\n";
        }
    }
    // E N D - for each
    if (count($menuitems) > 0) {
        $menu = '';
        foreach ($menuitems as $key => $value) {
            if (isset($v['icon']) && $v['icon'] != '') {
                //$class = $v['icon'];
            }
            if (isset($value['children']) && count($value['children']) > 0) {
                $class = 'parent';
                $hasdropdown = 'class="dropmenu"';
            } else {
                $class = "parent no-child";
                $hasdropdown = '';
            }
            $menu .= '<li ' . $hasdropdown . '>' . "\n" . '';
            $menu .= '<a class="' . $class . '" title="' . $value['name'] . '" href="#' . $value['head'] . '"><img src="' . esc_url($value['icon']) . '" height="16" alt=""/> ' . $value['name'] . '</a>' . "\n";
            if (isset($value['children']) && count($value['children']) > 0) {
                $menu .= '<ul class="sub-menu">' . "\n";
                foreach ($value['children'] as $i => $j) {
                    $menu .= '<li>' . "\n" . '<a  title="' . $j['name'] . '" href="#' . $j['head'] . '">' . $j['name'] . '</a></li>' . "\n";
                }
                $menu .= '</ul>' . "\n";
            }
            $menu .= '</li>' . "\n";
        }
    }
    $output .= '</div>';
    return array($output, $menu, $menuitems);
}
Ejemplo n.º 8
0
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Get the theme name so we can display it up top
    $themename = wp_get_theme(STYLESHEETPATH . '/style.css');
    $themename = $themename['Name'];
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            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);
                if (!isset($value['editor'])) {
                    $value['editor'] = '';
                }
                $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input ' . esc_attr($value['editor']) . '" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>';
                break;
                // Select Box
            // Select Box
            case $value['type'] == '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;
                // Select Box custom taxonomies
            // Select Box custom taxonomies
            case $value['type'] == 'select_tax':
                $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">';
                $args = array('hide_empty' => true, 'hierarchical' => true, 'orderby' => 'term_group');
                $terms = get_terms('multimedia-category', $args);
                $count = count($terms);
                if ($count > 0) {
                    foreach ($terms as $term) {
                        $selected = '';
                        if ($val != '') {
                            if ($val == $term->term_id) {
                                $selected = ' selected="selected"';
                            }
                        }
                        if ($term->parent == 0) {
                            $output .= '<option' . $selected . ' value="' . $term->term_id . '">***** ' . $term->name . ' *****</option>';
                        } else {
                            $output .= '<option' . $selected . ' value="' . $term->term_id . '">' . $term->name . '</option>';
                        }
                    }
                } else {
                    $output .= '<option selected value="0">' . esc_html__('No categories!', 'crystalskull') . '</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>';
                }
                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"';
                        }
                    }
                    if (esc_attr($key) == 'b1') {
                        $rep = 'No repeat';
                    } elseif (esc_attr($key) == 'b2') {
                        $rep = 'Repeat vertically';
                    } elseif (esc_attr($key) == 'b3') {
                        $rep = 'Repeat horizontally ';
                    } else {
                        $rep = 'Tile';
                    }
                    $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 .= '<a data-toggle="tooltip" data-original-title="' . $rep . '"><img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" /></a>';
                }
                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;
                //jquery checkbox
            //jquery checkbox
            case "jqueryselect":
                ?>
<script type="text/javascript">
		jQuery(document).ready(function($) {
		// Start jQuery goodness
			$('#itoggle input#<?php 
                echo esc_attr($value['id']);
                ?>
').iToggle({
				easing: 'easeOutExpo',
				onClickOn: function(){
					$('#console').show().css({opacity:0}).animate({opacity:1},400);
					statusUpdate('Console on');
				},
				onClickOff: function(){
					statusUpdate('Console off');
					$('#console').animate({opacity:0},400);
				}
			});
			function statusUpdate(text){
				$('#console').prepend('<p>'+text+'</p>');
			}
		// End jQuery goodness
		});
	</script>
	<?php 
                $output .= '<div id="itoggle" class="project"><input type="checkbox" class="checkbox of-input" id="' . esc_attr($value['id']) . '" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . '  /></div>';
                break;
                // Multicheck
            // Multicheck
            case "multicheck":
                foreach ($value['options'] as $key => $option) {
                    $checked = '';
                    $label = $option;
                    $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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>';
                }
                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
                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 = of_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 = of_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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if (isset($value['desc'])) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                break;
                //added by shark
            //added by shark
            case 'impbutton':
                $importer_url = get_template_directory_uri() . "/demo/import.php";
                global $wpdb;
                $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type='post'");
                ?>
            	<script type="text/javascript">
					jQuery(document).ready(function($)
					{
						var whatever = "<?php 
                echo esc_url($importer_url);
                ?>
";
						var demo_stat = "<?php 
                echo esc_attr($count);
                ?>
";
						jQuery("#close_update_nag").click(function(event)
						{
							jQuery('#import_incomp_noti').hide();
						});

						jQuery("#import_btn").click(function(event)
						{ console.log('aaaa');
							if(demo_stat > 4)
							{
								jQuery("input[id='import_btn']").prop('disabled', true);
								 jQuery('#import_incomp_noti').show();
							} else {
							jQuery.ajax(
							{
								beforeSend: function()
								{
									jQuery("input[id='import_btn']").prop('disabled', true);
									jQuery('#target').show();
								},
								complete: function()
								{
									jQuery('#target').hide();
								},

								url: whatever,
								success: function(data)
								{
								jQuery('#import_comp_noti').show();

								},
						      error: function (data, xhr, ajaxOptions, thrownError) {
						        console.log(xhr.status);
						        console.log(data);
						      }

							});
							}
						});
					});
            	</script>

        	<?php 
                import_completed_notice();
                import_incompleted_notice();
                $output .= '<input id="import_btn" class="button button-primary" type="button" value="import" rel="5">';
                $output .= '<div class="loading" id="target" style="display:none;"><div class="loading_text">' . __("Please wait, the content is importing....", "crystalskull") . '</div></div>';
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $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);
}
Ejemplo n.º 9
0
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Get the theme name so we can display it up top
    $themename = get_theme_data(STYLESHEETPATH . '/style.css');
    $themename = $themename['Name'];
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Keep all ids lowercase with no spaces
            //if ( isset( $value['id'] ) ){
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            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 $value['type'] == '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>';
                }
                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('/[^a-zA-Z0-9._\\-]/', '', 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>';
                }
                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
                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 = of_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 = of_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;
                // WPBS Typography - removed font size from std typography set of fields
            // WPBS Typography - removed font size from std typography set of fields
            case 'wpbs_typography':
                $wpbs_typography_stored = $val;
                // 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 = of_recognized_font_faces();
                foreach ($faces as $key => $face) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_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 = of_recognized_font_styles();
                foreach ($styles as $key => $style) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_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:' . $wpbs_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($wpbs_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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n";
                break;
            case "themecheck":
                $class = 'section';
                if (isset($value['type'])) {
                    $class .= ' section-' . $value['type'];
                }
                if (isset($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                $output .= '<div class="' . esc_attr($class) . '">' . "\n";
                $output .= '<a id="check-bootswatch" class="button-secondary">Refresh themes</a>';
                $output .= '<div id="check-status"></div>';
                $output .= '</div>';
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $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);
}
Ejemplo n.º 10
0
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Get the theme name so we can display it up top
    $wp_ver = explode('.', get_bloginfo('version'));
    $wp_ver = array_map('intval', $wp_ver);
    $themename = wp_get_theme();
    $themename = $themename->name;
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    // filter options for current page
    $options = array_filter($options, 'optionsframework_options_for_page_filter');
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "block_begin" && $value['type'] != "block_end" && $value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "page" && $value['type'] != 'js_hide_begin' && $value['type'] != 'js_hide_end') {
            // Keep all ids lowercase with no spaces
            $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";
            if (isset($value['name'])) {
                $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            }
            $output .= '<div class="option">' . "\n";
            $explain_value = '';
            if (isset($value['desc'])) {
                $explain_value = $value['desc'];
            }
            $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
            $output .= '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info' && $value['type'] != 'page') {
            if (isset($value['id']) && isset($settings[$value['id']])) {
                $val = $settings[$value['id']];
                // Striping slashes of non-array options
                if (!is_array($val)) {
                    $val = stripslashes($val);
                }
            }
        }
        switch ($value['type']) {
            // Basic text input
            case 'text':
                $maxlength = isset($value['maxlength']) ? ' maxlength="' . $value['maxlength'] . '"' : '';
                $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '"' . $maxlength . ' />';
                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="24">' . 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>';
                }
                break;
                // Image Selectors
            // Image Selectors
            case "images":
                $name = $option_name . '[' . $value['id'] . ']';
                $dir = get_template_directory_uri();
                foreach ($value['options'] as $key => $option) {
                    $selected = '';
                    $checked = '';
                    if ($val != '') {
                        if ($val == $key) {
                            $selected = ' of-radio-img-selected';
                            $checked = ' checked="checked"';
                        }
                    }
                    $img = $dir . $option;
                    $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" syle="display: none;">' . esc_html( $key ) . '</div>';
                    $output .= '<img src="' . esc_url($img) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />';
                }
                break;
                // Checkbox
            // Checkbox
            case "checkbox":
                $classes = array();
                $classes[] = 'checkbox';
                $classes[] = 'of-input';
                if (isset($value['options']['java_hide']) && $value['options']['java_hide']) {
                    $classes[] = 'of-js-hider';
                } else {
                    if (isset($value['options']['java_hide_global']) && $value['options']['java_hide_global']) {
                        $classes[] = 'of-js-hider-global';
                    }
                }
                $classes = implode(' ', $classes);
                $output .= '<input id="' . esc_attr($value['id']) . '" class="' . $classes . '" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />';
                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>';
                }
                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":
                $mode = isset($value['mode']) ? $value['mode'] : 'full';
                $output .= optionsframework_medialibrary_uploader($value['id'], $val, $mode);
                // New AJAX Uploader using Media Library
                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 = of_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 = of_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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                // Editor
            // Editor
            case 'editor':
                $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
                echo $output;
                $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']');
                $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress'));
                $editor_settings = array();
                if (isset($value['settings'])) {
                    $editor_settings = $value['settings'];
                }
                $editor_settings = array_merge($editor_settings, $default_editor_settings);
                wp_editor($val, $value['id'], $editor_settings);
                $output = '';
                break;
                // Block begin
            // Block begin
            case "block_begin":
                $class = 'section';
                $id = '';
                if (isset($value['type'])) {
                    $class .= ' section-' . $value['type'];
                }
                if (isset($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                if (isset($value['id'])) {
                    $id .= ' id="' . esc_attr($value['id']) . '"';
                }
                $output .= '<div' . $id . ' class="widgets-sortables ' . esc_attr($class) . '">' . "\n";
                if (isset($value['name']) && !empty($value['name'])) {
                    $output .= '<div class="sidebar-name"><h3>' . esc_html($value['name']) . '</h3></div>' . "\n";
                }
                break;
                // Block End
            // Block End
            case "block_end":
                $output .= '</div>' . "\n" . '<!-- block_end -->';
                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 .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                //$output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
                break;
            case "page":
                break;
            case "button":
                $output .= '<input type="button" id="' . esc_attr($value['id']) . '" class="button" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" value="' . esc_attr($value['options']['title']) . '">';
                break;
                // fields generator
            // fields generator
            case "fields_generator":
                if (!isset($value['options']['fields']) || !is_array($value['options']['fields'])) {
                    break;
                }
                $del_link = '<div class="submitbox"><a href="#" class="of_fields_gen_del submitdelete">' . _x('Delete', 'backend fields', LANGUAGE_ZONE) . '</a></div>';
                $output .= '<ul class="of_fields_gen_list">';
                // saved elements
                if (is_array($val)) {
                    $i = 0;
                    // create elements
                    foreach ($val as $index => $field) {
                        $block = $b_title = '';
                        // use patterns
                        foreach ($value['options']['fields'] as $name => $data) {
                            // if only_for list isset and current index not in the list - skip this element
                            if (isset($data['only_for']) && is_array($data['only_for']) && !in_array($index, $data['only_for'])) {
                                continue;
                            }
                            // checked если поле присутствует в записи, если нет поля value в шаблоне
                            // или если оно есть и равно значению поля в записи
                            $checked = false;
                            if (isset($field[$name]) && (!isset($data['value']) || isset($data['value']) && $data['value'] == $field[$name])) {
                                $checked = true;
                            }
                            // get the title
                            if (isset($data['class']) && 'of_fields_gen_title' == $data['class']) {
                                $b_title = $field[$name];
                            }
                            $el_args = array('name' => sprintf('%s[%s][%d][%s]', $option_name, $value['id'], $index, $name), 'description' => isset($data['description']) ? $data['description'] : '', 'class' => isset($data['class']) ? $data['class'] : '', 'value' => 'checkbox' == $data['type'] ? '' : $field[$name], 'checked' => $checked);
                            if (isset($data['desc_wrap'])) {
                                $el_args['desc_wrap'] = $data['desc_wrap'];
                            }
                            if (isset($data['wrap'])) {
                                $el_args['wrap'] = $data['wrap'];
                            }
                            if (isset($data['style'])) {
                                $el_args['style'] = $data['style'];
                            }
                            // create form elements
                            $element = dt_melement($data['type'], $el_args);
                            $block .= $element;
                        }
                        unset($data);
                        $output .= '<li class="nav-menus-php">';
                        $output .= '<div class="of_fields_gen_title menu-item-handle" data-index="' . $index . '"><span class="dt-menu-item-title">' . esc_attr($b_title) . '</span>';
                        $output .= '<span class="item-controls"><a title="' . _x('Edit Widgetized Area', 'backend fields', LANGUAGE_ZONE) . '" class="item-edit"></a></span></div>';
                        $output .= '<div class="of_fields_gen_data menu-item-settings description" style="display: none;">' . $block;
                        if ($index > 7) {
                            $output .= $del_link;
                        }
                        $output .= '</div>';
                        $output .= '</li>';
                        $i++;
                    }
                    unset($field);
                }
                $output .= '</ul>';
                // control panel
                $output .= '<div class="of_fields_gen_controls">';
                // use pattern
                foreach ($value['options']['fields'] as $name => $data) {
                    if (isset($data['only_for'])) {
                        continue;
                    }
                    $el_args = array('name' => sprintf('%s[%s][%s]', $option_name, $value['id'], $name), 'description' => isset($data['description']) ? $data['description'] : '', 'class' => isset($data['class']) ? $data['class'] : '', 'checked' => isset($data['checked']) ? $data['checked'] : false);
                    if (isset($data['desc_wrap'])) {
                        $el_args['desc_wrap'] = $data['desc_wrap'];
                    }
                    if (isset($data['wrap'])) {
                        $el_args['wrap'] = $data['wrap'];
                    }
                    if (isset($data['style'])) {
                        $el_args['style'] = $data['style'];
                    }
                    if (isset($data['value'])) {
                        $el_args['value'] = $data['value'];
                    }
                    // create form
                    $element = dt_melement($data['type'], $el_args);
                    $output .= $element;
                }
                unset($data);
                // add button
                $button = dt_melement('button', array('name' => $option_name . '[' . $value['id'] . '][add]', 'title' => isset($value['options']['button']['title']) ? $value['options']['button']['title'] : _x('Add', 'backend fields button', LANGUAGE_ZONE), 'class' => 'of_fields_gen_add'));
                $output .= $button;
                $output .= '</div>';
                break;
                // Social icons
            // Social icons
            case 'social_icon':
                if (!isset($value['options']['fields']) || !is_array($value['options']['fields'])) {
                    continue;
                }
                $w = $h = '20';
                if (!empty($value['options']['ico_width'])) {
                    $w = intval($value['options']['ico_width']);
                }
                if (!empty($value['options']['ico_height'])) {
                    $h = intval($value['options']['ico_height']);
                }
                $ico_size = sprintf('width: %dpx;height: %dpx;', $w, $h);
                foreach ($value['options']['fields'] as $src => $desc) {
                    $clear_desc = strtolower(str_replace(' ', '', $desc));
                    $name = sprintf('%s[%s][%s]', $option_name, $value['id'], $clear_desc);
                    $soc_link = isset($val[$clear_desc]) && isset($val[$clear_desc]['link']) ? $val[$clear_desc]['link'] : '';
                    $output .= '<div class="of-soc-image" style="background: url( ' . esc_attr(get_template_directory_uri() . $src) . ' ) no-repeat 0 0; vertical-align: middle; margin-right: 5px; display: inline-block;' . $ico_size . '" title="' . esc_attr($desc) . '"></div>';
                    $maxlength = isset($value['maxlength']) ? ' maxlength="' . $value['maxlength'] . '"' : '';
                    $output .= '<input class="of-input" name="' . esc_attr($name . '[link]') . '" type="text" value="' . esc_attr($soc_link) . '"' . $maxlength . ' style="display: inline-block; width: 300px; vertical-align: middle;" />';
                    $output .= '<input name="' . esc_attr($name . '[src]') . '" type="hidden" value="' . esc_attr($src) . '" /> <br>';
                }
                break;
            case 'slider':
                $output .= '<div class="of-slider"></div>';
                $slider_opts = array('max' => isset($value['options']['max']) ? $value['options']['max'] : 100, 'min' => isset($value['options']['min']) ? $value['options']['min'] : 0, 'step' => isset($value['options']['step']) ? $value['options']['step'] : 1, 'value' => isset($val) ? $val : 0);
                $str = '';
                foreach ($slider_opts as $name => $val) {
                    $str .= ' data-' . $name . '="' . esc_attr($val) . '"';
                }
                $output .= '<input type="text" class="of-slider-value"' . $str . ' name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" readonly />';
                break;
            case 'js_hide_begin':
                $output .= '<div class="of-js-hide hide-if-js">';
                break;
            case 'js_hide_end':
                $output .= '</div>';
                break;
                // beta feature
            // beta feature
            case 'web_fonts':
                $id = esc_attr($value['id']);
                $output .= '<select class="of-input dt-web-fonts" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . $id . '">';
                foreach ($value['options'] as $key => $option) {
                    $selected = '';
                    if ($val != '' && $val == $key) {
                        $selected = ' selected="selected"';
                    }
                    $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>';
                }
                $output .= '</select>';
                $output .= '<div class="dt-web-fonts-preview"><iframe id="' . $id . '_preview"></iframe></div>';
                // refresh button
                $output .= '<a href="#" class="dt-web-fonts-refresh button-secondary" onclick="dtWebfontsRefresh( \'' . $id . '\', \'' . wp_create_nonce('dt_webfonts_refresh') . '\' ); return false;">' . _x('refresh', 'backend', LANGUAGE_ZONE) . '</a>';
                $output .= '<img src="' . get_admin_url() . '/images/wpspin_light.gif" class="dt-web-fonts-refresh-ajax-loading" id="' . $id . '-ajax-loading" alt="">';
                // function located in options-functions.php
                $output .= dt_get_google_fonts_errors();
                break;
        }
        if ($value['type'] != "block_begin" && $value['type'] != "block_end" && $value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "page" && $value['type'] != 'js_hide_begin' && $value['type'] != 'js_hide_end') {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $explain_value = '';
            if (isset($value['explain'])) {
                $explain_value = $value['explain'];
                $output .= '<div class="dt-option-info">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
            }
            $output .= '</div>' . "\n";
            $output .= '<div class="clear"></div></div></div>' . "\n";
        }
    }
    $output .= '</div>';
    return array($output, $menu);
}
    /**
     * Generates the an indivdual panel to edit a slide.
     * This has been broken into a separate public function because
     * not only does it show each slide when loading the
     * Edit Slider screen, but it's used to insert a new
     * slide when called with AJAX.
     *
     * @since 1.0.0
     *
     * @param string $slider_type type of slider
     * @param string $slide_id ID for individual slide
     * @param array $slide_options any current options for current slide
     */
    public function edit_slide($slider_id, $slider_type, $slide_id, $slide_options = null, $visibility = null)
    {
        global $_wp_additional_image_sizes;
        $api = Theme_Blvd_Sliders_API::get_instance();
        $slider_types = $api->get_sliders();
        $current_slide_type = $this->slide_value($slide_options, 'slide_type');
        $current_image = $this->slide_value($slide_options, 'image');
        $current_video = $this->slide_value($slide_options, 'video');
        ?>
		<div id="<?php 
        echo $slide_id;
        ?>
" class="widget slide-options"<?php 
        if ($visibility == 'hide') {
            echo ' style="display:none"';
        }
        ?>
>
			<div class="widget-name">
				<a href="#" class="widget-name-arrow">Toggle</a>
				<h3 class="image"><?php 
        echo $slider_types[$slider_type]['types'][$current_slide_type]['name'];
        ?>
</h3>
				<span class="slide-summary"></span>
			</div><!-- .element-name (end) -->
			<div class="widget-content">
				<div class="slide-set-type">
					<strong><?php 
        _e('Image Slide', 'themeblvd_sliders');
        ?>
</strong>
					<select name="slides[<?php 
        echo $slide_id;
        ?>
][slide_type]">
						<?php 
        foreach ($slider_types[$slider_type]['types'] as $key => $value) {
            echo '<option ' . selected($key, $current_slide_type, false) . ' value="' . $key . '">' . $value['name'] . '</option>';
        }
        ?>
					</select>
				</div><!-- .slide-set-type (end) -->
				<div class="pad">
					<div class="slide-media controls grid-wrap">
						<div class="slide-set-media">
							<?php 
        foreach ($slider_types[$slider_type]['types'] as $type => $config) {
            switch ($type) {
                case 'image':
                    ?>
										<div class="slide-set-image">
											<h3><?php 
                    echo $config['main_title'];
                    ?>
</h3>
											<div class="field section-upload">
												<?php 
                    if (function_exists('wp_enqueue_media') && function_exists('themeblvd_media_uploader')) {
                        $title = isset($current_image['title']) ? $current_image['title'] : '';
                        // If updating from v1.0, this check prevents PHP warning.
                        echo themeblvd_media_uploader(array('option_name' => 'slides[' . $slide_id . ']', 'type' => 'slider', 'id' => $slide_id . 'image', 'value' => $current_image['url'], 'value_title' => $title, 'value_id' => $current_image['id']));
                    } else {
                        // @deprecated
                        echo optionsframework_medialibrary_uploader('slides[' . $slide_id . ']', 'slider', $slide_id . 'image', $current_image, null, null, $slider_id, null, __('Get Image', 'themeblvd_sliders'));
                    }
                    ?>
											</div><!-- .field (end) -->
										</div><!-- .slide-set-image (end) -->
										<?php 
                    break;
                case 'video':
                    ?>
										<div class="slide-set-video">
											<h3><?php 
                    echo $config['main_title'];
                    ?>
</h3>
											<div class="field video-link">
												<?php 
                    echo '<input type="text" name="slides[' . $slide_id . '][video]" placeholder="' . __('Video Link', 'themeblvd') . '" value="' . $current_video . '" />';
                    /*
                    // @todo -- Incorporate "Get Video" button. Let's not bring this feature
                    // to center-satge until we have a better handle on mp4's in WP 3.6.
                    $current_video = $this->slide_value( $slide_options, 'video' );
                    if ( function_exists('wp_video_shortcode') && function_exists('themeblvd_media_uploader') ) {
                    	echo '<div class="section-upload">';
                    	echo themeblvd_media_uploader( array( 'option_name' => 'slides', 'type' => 'video', 'name' => 'video', 'id' => $slide_id, 'value' => $current_video ) );
                    	echo '</div>';
                    	//echo '<input type="text" name="slides['.$slide_id.'][video]" value="'.$current_video.'" />';
                    } else {
                    	// @deprecated with release of WP 3.6
                    	echo '<input type="text" name="slides['.$slide_id.'][video]" placeholder="'.__('Video Link', 'themeblvd').'" value="'.$current_video.'" />';
                    }
                    */
                    ?>
												<p class="explain">
													<?php 
                    _e('Enter in a video URL compatible with <a href="http://codex.wordpress.org/Embeds" target="_blank">WordPress\'s oEmbed</a>.<br><br>Ex: http://youtube.com/watch?v=HPPj6viIBmU<br>Ex: http://vimeo.com/11178250', 'themeblvd_sliders');
                    ?>
													<?php 
                    /* @todo if ( function_exists('wp_video_shortcode') ) : ?>
                    				<br><?php _e('Ex: http://yoursite.com/uploads/video.mp4', 'themeblvd_sliders'); ?>
                    			<?php endif; */
                    ?>
												</p>
											</div><!-- .field (end) -->
										</div><!-- .slide-set-video (end) -->
										<?php 
                    break;
            }
        }
        ?>
						</div><!-- .slide-set-media (end) -->
						<div class="slide-include-elements">

							<div class="slide-section">
								<?php 
        if ($slider_types[$slider_type]['positions']) {
            ?>
									<h4 class="header_has_icon"><?php 
            _e('Media Display', 'themeblvd_sliders');
            ?>
</h4>
									<?php 
            $position = $this->slide_value($slide_options, 'position');
            ?>

									<select class="slide-position slide-position-image" name="slides[<?php 
            echo $slide_id;
            ?>
][position_image]">
										<?php 
            foreach ($slider_types[$slider_type]['positions'] as $key => $value) {
                // Set name for option
                $name = '';
                switch ($key) {
                    case 'full':
                        $name = __('Full Size', 'themeblvd_sliders');
                        break;
                    case 'align-left':
                        $name = __('Aligned Left', 'themeblvd_sliders');
                        break;
                    case 'align-right':
                        $name = __('Aligned Right', 'themeblvd_sliders');
                        break;
                }
                $exclude_dimensions = $key == 'full' && $slider_types[$slider_type]['custom_size'] ? true : false;
                echo '<option ' . selected($key, $position, false) . ' value="' . $key . '">' . $this->get_image_size_desc($value, $name, $exclude_dimensions) . '</option>';
            }
            ?>
									</select>

									<?php 
            if (isset($slider_types[$slider_type]['positions']['full']) && $slider_types[$slider_type]['custom_size']) {
                ?>
										<select class="slide-crop" name="slides[<?php 
                echo $slide_id;
                ?>
][image_size]">
											<?php 
                $full_size = $slider_types[$slider_type]['positions']['full'];
                $image_size = $this->slide_value($slide_options, 'image_size');
                // First option is the default framework "slider-large" image size
                echo '<option ' . selected('slider-large', $image_size, false) . ' value="' . $full_size . '">' . $this->get_image_size_desc($full_size, __('Default', 'themeblvd_sliders')) . '</option>';
                // Now get all WP-registered image sizes and make them available for selection.
                $wp_image_sizes = get_intermediate_image_sizes();
                if ($wp_image_sizes) {
                    foreach ($wp_image_sizes as $size) {
                        if ($size == $full_size) {
                            continue;
                        }
                        echo '<option ' . selected($size, $image_size, false) . ' value="' . $size . '">' . $this->get_image_size_desc($size) . '</option>';
                    }
                }
                // Add option for raw image, with no crop.
                echo '<option ' . selected('full', $image_size, false) . ' value="full">' . __('Do not crop image.', 'themeblvd_sliders') . '</option>';
                ?>
										</select>
									<?php 
            }
            ?>

									<select class="slide-position slide-position-video" name="slides[<?php 
            echo $slide_id;
            ?>
][position_video]">
										<?php 
            foreach ($slider_types[$slider_type]['positions'] as $key => $value) {
                // Set name for option
                $name = '';
                switch ($key) {
                    case 'full':
                        $name = __('Full Width', 'themeblvd_sliders');
                        break;
                    case 'align-left':
                        $name = __('Aligned Left', 'themeblvd_sliders');
                        break;
                    case 'align-right':
                        $name = __('Aligned Right', 'themeblvd_sliders');
                        break;
                }
                echo '<option ' . selected($key, $position, false) . ' value="' . $key . '">' . $name . '</option>';
            }
            ?>
									</select>

									<div class="slide-video-height mini-control clearfix">
										<input type="text" value="<?php 
            echo $this->slide_value($slide_options, 'video_height');
            ?>
" name="slides[<?php 
            echo $slide_id;
            ?>
][video_height]" class="numeric" />
										<label for="slides[<?php 
            echo $slide_id;
            ?>
][video_height]">
											<?php 
            _e('Maximum Video Height (use 0 for no limit)', 'themeblvd_sliders');
            ?>
										</label>
									</div>

									<p class="note image-note"><?php 
            _e('When you upload an image, it must be at a minimum the size selected above in order for WordPress to generate and register the crop size. Images will be scaled down proportionally from their respective crop sizes depending on where the slider is placed.', 'themeblvd_sliders');
            ?>
</p>

								<?php 
        }
        ?>
							</div><!-- .slide-section (end) -->

							<?php 
        if (!empty($slider_types) && !empty($slider_types[$slider_type]['elements'])) {
            ?>
								<div class="slide-section">
									<h4><?php 
            _e('Slide Elements', 'themeblvd_sliders');
            ?>
</h4>
									<table class="widefat slide-elements">
										<tbody>
										<?php 
            foreach ($slider_types[$slider_type]['elements'] as $element) {
                switch ($element) {
                    case 'image_link':
                        if ($key != 'video') {
                            // A video would never be wrapped in a link
                            ?>
														<tr class="element-image_link slide-element-header">
															<td class="slide-element-check"><input value="image_link" type="checkbox" name="slides[<?php 
                            echo $slide_id;
                            ?>
][elements][include][]"<?php 
                            echo $this->slide_value($slide_options, 'include', 'image_link');
                            ?>
 /></td>
															<td class="slide-element-name"><?php 
                            _e('Image Link', 'themeblvd_sliders');
                            ?>
</td>
															<td class="slide-element-help"><a href="#" class="help-icon tb-icon-help-circled tooltip-link" title="<?php 
                            _e('This will allow you to apply a link to the image of this slide. You can configure it to open a webpage or a lightbox popup of different media types. If you\'re linking to a Lightbox Image, use the image file URL. If you\'re linking to a Lightbox Video, you can put in the URL to the Vimeo or YouTube video page.', 'themeblvd_sliders');
                            ?>
"></a></td>
														</tr>
														<tr class="element-image_link slide-element-options">
															<td colspan="3">
																<div class="field">
																	<h5><?php 
                            _e('Where should the link open?', 'themeblvd_sliders');
                            ?>
</h5>
																	<?php 
                            $target = $this->slide_value($slide_options, 'image_link', 'target');
                            ?>
																	<select name="slides[<?php 
                            echo $slide_id;
                            ?>
][elements][image_link][target]">
																		<option value="_self" <?php 
                            selected($target, '_self');
                            ?>
><?php 
                            _e('Same Window', 'themeblvd_sliders');
                            ?>
</option>
																		<option value="_blank" <?php 
                            selected($target, '_blank');
                            ?>
><?php 
                            _e('New Window', 'themeblvd_sliders');
                            ?>
</option>
																		<option value="lightbox" <?php 
                            selected($target, 'lightbox');
                            ?>
><?php 
                            _e('Lightbox Image', 'themeblvd_sliders');
                            ?>
</option>
																		<option value="lightbox_video" <?php 
                            selected($target, 'lightbox_video');
                            ?>
><?php 
                            _e('Lightbox Video', 'themeblvd_sliders');
                            ?>
</option>
																	</select>
																</div><!-- .field (end) -->
																<div class="field">
																	<h5><?php 
                            _e('Where should the link go?', 'themeblvd_sliders');
                            ?>
</h5>
																	<input name="slides[<?php 
                            echo $slide_id;
                            ?>
][elements][image_link][url]" type="text" value="<?php 
                            echo $this->slide_value($slide_options, 'image_link', 'url');
                            ?>
" class="input" />
																	</div><!-- .class="more-info (end) -->
																</div><!-- .field (end) -->
															</td>
														</tr>
														<?php 
                        }
                        break;
                    case 'headline':
                        ?>
													<tr class="element-headline slide-element-header">
														<td class="slide-element-check"><input value="headline" type="checkbox" name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][include][]"<?php 
                        echo $this->slide_value($slide_options, 'include', 'headline');
                        ?>
 /></td>
														<td class="slide-element-name"><?php 
                        _e('Headline', 'themeblvd_sliders');
                        ?>
</td>
														<td class="slide-element-help"><a href="#" class="help-icon tb-icon-help-circled tooltip-link" title="<?php 
                        _e('This will allow you to insert a simple headline on your slide. The location and style of this headline will vary depending on the design of the current theme.', 'themeblvd_sliders');
                        ?>
"></a></td>
													</tr>
													<tr class="element-headline slide-element-options">
														<td colspan="3">
															<div class="field">
																<h5><?php 
                        _e('What should the headline say?', 'themeblvd_sliders');
                        ?>
</h5>
																<textarea name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][headline]"><?php 
                        echo $this->slide_value($slide_options, 'headline');
                        ?>
</textarea>
															</div><!-- .field (end) -->
														</td>
													</tr>
													<?php 
                        break;
                    case 'description':
                        ?>
													<tr class="element-description slide-element-header">
														<td class="slide-element-check"><input value="description" type="checkbox" name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][include][]"<?php 
                        echo $this->slide_value($slide_options, 'include', 'description');
                        ?>
 /></td>
														<td class="slide-element-name"><?php 
                        _e('Description', 'themeblvd_sliders');
                        ?>
</td>
														<td class="slide-element-help"><a href="#" class="help-icon tb-icon-help-circled tooltip-link" title="<?php 
                        _e('This will allow you to insert a simple description on your slide. The location and style of this description will vary depending on the design of the current theme.', 'themeblvd_sliders');
                        ?>
"></a></td>
													</tr>
													<tr class="element-description slide-element-options">
														<td colspan="3">
															<div class="field">
																<h5><?php 
                        _e('What should the description say?', 'themeblvd_sliders');
                        ?>
</h5>
																<textarea name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][description]"><?php 
                        echo $this->slide_value($slide_options, 'description');
                        ?>
</textarea>
															</div><!-- .field (end) -->
														</td>
													</tr>
													<?php 
                        break;
                    case 'button':
                        ?>
													<tr class="element-button slide-element-header">
														<td class="slide-element-check"><input value="button" type="checkbox" name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][include][]"<?php 
                        echo $this->slide_value($slide_options, 'include', 'button');
                        ?>
 /></td>
														<td class="slide-element-name"><?php 
                        _e('Button', 'themeblvd_sliders');
                        ?>
</td>
														<td class="slide-element-help"><a href="#" class="help-icon tb-icon-help-circled tooltip-link" title="<?php 
                        _e('This will allow you to include a button on your slide. You can configure it to open a webpage or a lightbox popup of different media types.', 'themeblvd_sliders');
                        ?>
"></a></td>
													</tr>
													<tr class="element-button slide-element-options">
														<td colspan="3">
															<div class="field">
																<h5><?php 
                        _e('What should the button say?', 'themeblvd_sliders');
                        ?>
</h5>
																<input name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][button][text]" type="text" value="<?php 
                        echo $this->slide_value($slide_options, 'button', 'text');
                        ?>
" class="input" />
															</div><!-- .field (end) -->
															<div class="field">
																<h5><?php 
                        _e('Where should the link open?', 'themeblvd_sliders');
                        ?>
</h5>
																<?php 
                        $target = $this->slide_value($slide_options, 'button', 'target');
                        ?>
																<select name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][button][target]">
																	<option value="_self" <?php 
                        selected($target, '_self');
                        ?>
><?php 
                        _e('Same Window', 'themeblvd_sliders');
                        ?>
</option>
																	<option value="_blank" <?php 
                        selected($target, '_blank');
                        ?>
><?php 
                        _e('New Window', 'themeblvd_sliders');
                        ?>
</option>
																	<option value="lightbox" <?php 
                        selected($target, 'lightbox');
                        ?>
><?php 
                        _e('Lightbox Image', 'themeblvd_sliders');
                        ?>
</option>
																	<option value="lightbox_video" <?php 
                        selected($target, 'lightbox_video');
                        ?>
><?php 
                        _e('Lightbox Video', 'themeblvd_sliders');
                        ?>
</option>
																</select>
															</div><!-- .field (end) -->
															<div class="field">
																<h5><?php 
                        _e('Where should the link go?', 'themeblvd_sliders');
                        ?>
</h5>
																<input name="slides[<?php 
                        echo $slide_id;
                        ?>
][elements][button][url]" type="text" value="<?php 
                        echo $this->slide_value($slide_options, 'button', 'url');
                        ?>
" class="input" />
															</div><!-- .field (end) -->
														</td>
													</tr>
													<?php 
                        break;
                }
            }
            ?>
										</tbody>
									</table>
									<p class="warning slide-elements-warning"><?php 
            _e('You cannot have any elements on top of full-size video. If you\'d like to include elements, align the video to the right or left.', 'themeblvd_sliders');
            ?>
</p>
								</div><!-- .slide-section (end) -->
							<?php 
        }
        ?>
						</div><!-- .slide-include-elements (end) -->
						<div class="clear"></div>
					</div><!-- .grid-wrap (end) -->
					<?php 
        if (array_key_exists('custom', $slider_types[$slider_type]['types'])) {
            ?>
					<div class="controls slide-custom">
						<h3><?php 
            echo $slider_types[$slider_type]['types']['custom']['main_title'];
            ?>
</h3>
						<?php 
            $custom = $this->slide_value($slide_options, 'custom');
            ?>
						<textarea name="slides[<?php 
            echo $slide_id;
            ?>
][custom]"><?php 
            echo $custom;
            ?>
</textarea>
					</div><!-- .slide-custom (end) -->
					<?php 
        }
        ?>
				</div><!-- .pad (end) -->
				<div class="submitbox widget-footer">
					<a href="#<?php 
        echo $slide_id;
        ?>
" class="submitdelete delete-me" title="<?php 
        _e('Are you sure you want to delete this slide?', 'themeblvd_sliders');
        ?>
"><?php 
        _e('Delete Slide', 'themeblvd_sliders');
        ?>
</a>
					<div class="clear"></div>
				</div><!-- .widget-footer (end) -->
			</div><!-- .element-content (end) -->
		</div><!-- .slide-options(end) -->
		<?php 
    }
Ejemplo n.º 12
0
/**
 * Generates option to edit a logo.
 *
 * This has been moved to a separate function
 * because it's a custom addition to the optionframework
 * module and it's pretty lengthy.
 *
 * @since 2.0.0
 *
 * @param $id string unique ID for option
 * @param $name string prefix for form name value
 * @param $val array currently saved data if exists
 * @return $output string HTML for option
 */
function themeblvd_logo_option($id, $name, $val)
{
    /*------------------------------------------------------*/
    /* Type of logo
    	/*------------------------------------------------------*/
    $types = array('title' => __('Site Title', 'themeblvd'), 'title_tagline' => __('Site Title + Tagline', 'themeblvd'), 'custom' => __('Custom Text', 'themeblvd'), 'image' => __('Image', 'themeblvd'));
    $current_value = '';
    if (!empty($val) && !empty($val['type'])) {
        $current_value = $val['type'];
    }
    $select_type = '<div class="tb-fancy-select">';
    $select_type .= '<select name="' . esc_attr($name . '[' . $id . '][type]') . '">';
    foreach ($types as $key => $type) {
        $select_type .= sprintf('<option value="%s" %s>%s</option>', $key, selected($current_value, $key, false), $type);
    }
    $select_type .= '</select>';
    $select_type .= '<span class="trigger"></span>';
    $select_type .= '<span class="textbox"></span>';
    $select_type .= '</div><!-- .tb-fancy-select (end) -->';
    /*------------------------------------------------------*/
    /* Site Title
    	/*------------------------------------------------------*/
    $site_title = '<p class="note">';
    $site_title .= __('Current Site Title', 'themeblvd') . ': <strong>';
    $site_title .= get_bloginfo('name') . '</strong><br><br>';
    $site_title .= __('You can change your site title and tagline by going <a href="options-general.php" target="_blank">here</a>.', 'themeblvd');
    $site_title .= '</p>';
    /*------------------------------------------------------*/
    /* Site Title + Tagline
    	/*------------------------------------------------------*/
    $site_title_tagline = '<p class="note">';
    $site_title_tagline .= __('Current Site Title', 'themeblvd') . ': <strong>';
    $site_title_tagline .= get_bloginfo('name') . '</strong><br>';
    $site_title_tagline .= __('Current Tagline', 'themeblvd') . ': <strong>';
    $site_title_tagline .= get_bloginfo('description') . '</strong><br><br>';
    $site_title_tagline .= __('You can change your site title by going <a href="options-general.php" target="_blank">here</a>.', 'themeblvd');
    $site_title_tagline .= '</p>';
    /*------------------------------------------------------*/
    /* Custom Text
    	/*------------------------------------------------------*/
    $current_value = '';
    if (!empty($val) && !empty($val['custom'])) {
        $current_value = $val['custom'];
    }
    $current_tagline = '';
    if (!empty($val) && !empty($val['custom_tagline'])) {
        $current_tagline = $val['custom_tagline'];
    }
    $custom_text = sprintf('<p><label class="inner-label"><strong>%s</strong></label>', __('Title', 'themeblvd'));
    $custom_text .= sprintf('<input type="text" name="%s" value="%s" /></p>', esc_attr($name . '[' . $id . '][custom]'), esc_attr($current_value));
    $custom_text .= sprintf('<p><label class="inner-label"><strong>%s</strong> (%s)</label>', __('Tagline', 'themeblvd'), __('optional', 'themeblvd'));
    $custom_text .= sprintf('<input type="text" name="%s" value="%s" /></p>', esc_attr($name . '[' . $id . '][custom_tagline]'), esc_attr($current_tagline));
    $custom_text .= sprintf('<p class="note">%s</p>', __('Insert your custom text.', 'themeblvd'));
    /*------------------------------------------------------*/
    /* Image
    	/*------------------------------------------------------*/
    if (function_exists('wp_enqueue_media')) {
        // WP 3.5+
        $current_value = array('url' => '', 'width' => '');
        if (is_array($val) && isset($val['image'])) {
            $current_value = array('url' => $val['image'], 'width' => $val['image_width']);
        }
        $current_retina = array('url' => '');
        if (is_array($val) && isset($val['image_2x'])) {
            $current_retina = array('url' => $val['image_2x']);
        }
        // Standard Image
        $image_upload = '<div class="section-upload image-standard">';
        $image_upload .= '<label class="inner-label"><strong>' . __('Standard Image', 'themeblvd') . '</strong></label>';
        $image_upload .= themeblvd_media_uploader(array('option_name' => $name, 'type' => 'logo', 'id' => $id, 'value' => $current_value['url'], 'value_width' => $current_value['width'], 'name' => 'image'));
        $image_upload .= '</div>';
        // Retina image (2x)
        $image_upload .= '<div class="section-upload image-2x">';
        $image_upload .= '<label class="inner-label"><strong>' . __('HiDPI-optimized Image (optional)', 'themeblvd') . '</strong></label>';
        $image_upload .= themeblvd_media_uploader(array('option_name' => $name, 'type' => 'logo_2x', 'id' => $id, 'value' => $current_retina['url'], 'name' => 'image_2x'));
        $image_upload .= '</div>';
    } else {
        // Media uploader prior to WP 3.5 -- @deprecated
        $current_value = array('url' => '', 'width' => '', 'id' => '');
        if (is_array($val) && isset($val['image'])) {
            $current_value = array('url' => $val['image'], 'width' => $val['image_width'], 'id' => '');
        }
        $current_retina = array('url' => '', 'id' => '');
        if (is_array($val) && isset($val['image_2x'])) {
            $current_retina = array('url' => $val['image_2x'], 'id' => '');
        }
        // Standard Image
        $image_upload = '<div class="section-upload image-standard">';
        $image_upload .= '<label class="inner-label"><strong>' . __('Standard Image', 'themeblvd') . '</strong></label>';
        $image_upload .= optionsframework_medialibrary_uploader($name, 'logo', $id, $current_value, null, null, 0, 'image');
        $image_upload .= '</div>';
        // Retina image (2x)
        $image_upload .= '<div class="section-upload image-2x">';
        $image_upload .= '<label class="inner-label"><strong>' . __('HiDPI-optimized Image (optional)', 'themeblvd') . '</strong></label>';
        $image_upload .= optionsframework_medialibrary_uploader($name, 'logo_2x', $id, $current_retina, null, null, 0, 'image_2x');
        $image_upload .= '</div>';
    }
    /*------------------------------------------------------*/
    /* Primary Output
    	/*------------------------------------------------------*/
    $output = sprintf('<div class="select-type">%s</div>', $select_type);
    $output .= sprintf('<div class="logo-item title">%s</div>', $site_title);
    $output .= sprintf('<div class="logo-item title_tagline">%s</div>', $site_title_tagline);
    $output .= sprintf('<div class="logo-item custom">%s</div>', $custom_text);
    $output .= sprintf('<div class="logo-item image">%s</div>', $image_upload);
    return $output;
}
Ejemplo n.º 13
0
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Get the theme name so we can display it up top
    $themename = wp_get_theme(STYLESHEETPATH . '/style.css');
    $themename = $themename['Name'];
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            if (isset($settings[$value['id']])) {
                $val = $settings[$value['id']];
                // Striping slashes of non-array options
                if (!is_array($val)) {
                    $val = stripslashes($val);
                }
            }
        }
        if (isset($value['id'])) {
            $val = get_option('mtheme_' . $value['id']);
        }
        // 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':
                if (isset($value['unit'])) {
                    $output .= '<div class="ranger-min-max-wrap"><span class="ranger-min-value">' . $value['min'] . '</span>';
                    $output .= '<span class="ranger-max-value">' . $value['max'] . '</span></div>';
                    $output .= '<div id="' . esc_attr($value['id']) . '_slider"></div>';
                    $output .= '<div class="ranger-bar">';
                }
                $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '"';
                if (isset($value['unit'])) {
                    if (isset($value['min'])) {
                        $output .= ' min="' . $value['min'];
                    }
                    if (isset($value['max'])) {
                        $output .= '" max="' . $value['max'];
                    }
                    if (isset($value['step'])) {
                        $output .= '" step="' . $value['step'];
                    }
                    $output .= '" />';
                    if (isset($value['unit'])) {
                        $output .= '<span>' . $value['unit'] . '</span>';
                    }
                    $output .= '</div>';
                } else {
                    $output .= ' />';
                }
                break;
            case 'dragdrop_sorter':
                // Set directory uri
                $directory_uri = get_template_directory_uri();
                $image_page = "/framework/options/images/";
                //$option_name = 'cyberchimps_options';
                //$settings = get_option($option_name);
                $sort_order = get_option('mtheme_' . $value['id']);
                $val = '';
                $sortoutput = '';
                // If the option is already saved, ovveride $val
                if (isset($sort_order)) {
                    // Assign empty array if the array returns null
                    if ($sort_order != "") {
                        $val = $sort_order;
                    } else {
                        $val = NULL;
                    }
                    // Striping slashes of non-array options
                    if (!is_array($val)) {
                        $val = stripslashes($val);
                    }
                }
                // Set default value to $val
                if (empty($val)) {
                    if (isset($value['std'])) {
                        if (is_array($value['std'])) {
                            $val = array_keys($value['std']);
                        } else {
                            $val = array_keys(explode($value['std']));
                        }
                    }
                }
                ///$val = $sort_order;
                //$sortoutput	.= '<h1>Curr SOrt order '.$val.'</h1>';
                $sortoutput .= "<div class='section_order' id=" . esc_attr($value['id']) . ">";
                $sortoutput .= "<div class='section_storage'>";
                $sortoutput .= "<div class='inactive'>Inactive Elements</div>";
                $sortoutput .= "<div class='drag'>Storage for inactive elements</div>";
                $sortoutput .= "<div class='item_drawer'>";
                if (is_array($val)) {
                    foreach ($value['options'] as $key => $option) {
                        if (in_array($key, $val)) {
                            continue;
                        }
                        $sortoutput .= "<div class='draggable_item'>";
                        $sortoutput .= '<img src="' . $directory_uri . $image_page . 'minus.png" class="action" title="Delete"/>';
                        $sortoutput .= "<span data-key='{$key}'>{$option}</span>";
                        $sortoutput .= "</div>";
                    }
                }
                $sortoutput .= "</div>";
                $sortoutput .= "</div>";
                $sortoutput .= '<div class="theme_arrow"><img src="' . $directory_uri . $image_page . 'arrow_drag.png" /></div>';
                $sortoutput .= "<div class='section_active'>";
                $sortoutput .= "<div class='active'>Active Elements</div>";
                $sortoutput .= "<div class='drag'>Drag & Drop here to activate</div>";
                $sortoutput .= "<div class='item_drawer'>";
                if (is_array($val)) {
                    foreach ($val as $key) {
                        if (!array_key_exists($key, $value['options'])) {
                            continue;
                        }
                        $sortoutput .= "<div class='draggable_item'>";
                        $sortoutput .= '<img src="' . $directory_uri . $image_page . 'minus.png" class="action" title="Delete"/>';
                        $sortoutput .= "<span data-key='{$key}'>{$value['options'][$key]}</span>";
                        $sortoutput .= "</div>";
                    }
                }
                $sortoutput .= "</div>";
                $sortoutput .= "</div>";
                $sortoutput .= '<div id="values" data-key="' . $option_name . '"></div>';
                $sortoutput .= "</div>";
                $output .= $sortoutput;
                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';
                    }
                }
                if (!is_serialized($val)) {
                    if (is_array($val)) {
                        $val = serialize($val);
                    } else {
                        $val = stripslashes($val);
                    }
                }
                if (is_serialized($val)) {
                    $readonly_mode = "readonly";
                } else {
                    $readonly_mode = "";
                }
                $textarea_class = "";
                if (isset($value['class'])) {
                    $textarea_class = $value['class'];
                }
                $output .= '<textarea ' . $readonly_mode . ' id="' . esc_attr($value['id']) . '" class="of-input opt-textbox-' . $textarea_class . '" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . $val . '</textarea>';
                break;
                // Select Box
            // Select Box
            case $value['type'] == '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;
                //Sorter
            //Sorter
            case 'sorter':
                $blog_url = home_url();
                $sort_order = $value['order'];
                $sort_val = explode(",", $sort_order);
                $count = 0;
                $output .= '<img src="' . $blog_url . '/wp-admin/images/loading.gif" id="loading-animation" />';
                $output .= '<ul id="home-list">';
                for ($count = 0; $count <= 6; $count++) {
                    foreach ($value['options'] as $key => $option) {
                        if ($sort_val[$count] == $key) {
                            $output .= '<li id="' . $key . '">' . $option . '</li>';
                        }
                    }
                }
                $output .= '</ul>';
                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>';
                }
                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 .= '<div class="toggle-wrap"><div class="togglebox">';
                $output .= '<input id="chkbx' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' /><label for="chkbx' . esc_attr($value['id']) . '"><b></b></label></div></div>';
                break;
                // Multicheck
            // Multicheck
            case "multicheck":
                foreach ($value['options'] as $key => $option) {
                    $checked = '';
                    $label = $option;
                    $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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>';
                }
                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="colorSwatch of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />';
                break;
                // Editor
            // Editor
            case 'editor':
                echo $output;
                $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']');
                $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress'));
                $editor_settings = array();
                if (isset($value['settings'])) {
                    $editor_settings = $value['settings'];
                }
                $editor_settings = array_merge($editor_settings, $default_editor_settings);
                wp_editor($val, $value['id'], $editor_settings);
                $output = '';
                break;
                // Uploader
            // Uploader
            case "upload":
                $output .= optionsframework_medialibrary_uploader($value['id'], $val, null);
                // New AJAX Uploader using Media Library
                break;
                // Typography
            // Typography
            case 'typography':
                unset($font_size, $font_style, $font_face, $font_color);
                $typography_defaults = array('size' => '', 'face' => '', 'style' => '', 'color' => '');
                $typography_stored = wp_parse_args($val, $typography_defaults);
                $typography_options = array('sizes' => of_recognized_font_sizes(), 'faces' => of_recognized_font_faces(), 'styles' => of_recognized_font_styles(), 'color' => true);
                if (isset($value['options'])) {
                    $typography_options = wp_parse_args($value['options'], $typography_options);
                }
                // Font Size
                if ($typography_options['sizes']) {
                    $font_size = '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '"
                                                onchange="options_font_preview(\'' . esc_attr($value['id'] . '_size') . '\', \'' . esc_attr($value['id']) . '_preview' . '\', \'font-size\');return true;">';
                    $sizes = $typography_options['sizes'];
                    foreach ($sizes as $i) {
                        $size = $i . 'px';
                        $font_size .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>';
                    }
                    $font_size .= '</select>';
                }
                // Font Face
                if ($typography_options['faces']) {
                    $font_face = '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '" 
                                                onchange="options_font_preview(\'' . esc_attr($value['id'] . '_face') . '\', \'' . esc_attr($value['id']) . '_preview' . '\', \'font-family\');return true;">';
                    $faces = $typography_options['faces'];
                    foreach ($faces as $key => $face) {
                        $font_face .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>';
                    }
                    $font_face .= '</select>';
                }
                // Font Styles
                if ($typography_options['styles']) {
                    $font_style = '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style"
                                                onchange="options_font_preview(\'' . esc_attr($value['id'] . '_style') . '\', \'' . esc_attr($value['id']) . '_preview' . '\', \'font-style\');return true;">';
                    $styles = $typography_options['styles'];
                    foreach ($styles as $key => $style) {
                        $font_style .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>';
                    }
                    $font_style .= '</select>';
                }
                // Font Color
                if ($typography_options['color']) {
                    $font_color = '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>';
                    $font_color .= '<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']) . '" />';
                    //onkeypress="options_face_preview(\'' . esc_attr( $value['id'] . '_size' ) . '\', \'' . esc_attr($value['id']) . '_color'. '\', \'color\');return true;"/>';
                }
                // Allow modification/injection of typography fields
                $typography_fields = compact('font_size', 'font_face', 'font_style', 'font_color');
                $typography_fields = apply_filters('of_typography_fields', $typography_fields, $typography_stored, $option_name, $value);
                $output .= implode('', $typography_fields);
                //$output .= '<p style="font-family: ' . $typography_stored['face'] . '; margin: 7px 0 10px 5px;display:block;width:200px; font-size: ' . $typography_stored['size'] . '" id="' . esc_attr($value['id']) . '_preview' . '">Font Preview</p>';
                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'];
                }
                if (isset($value['name'])) {
                    $output .= '<h5>' . esc_html($value['name']) . '</h5>' . "\n";
                }
                if (isset($value['desc'])) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n";
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            //if ( $value['type'] != "checkbox" ) {
            $output .= '<br/>';
            //}
            $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>';
    echo $output;
}
/**
 * Generates the options fields that are used in forms for
 * internal options framework.
 *
 * Total props to Devin Price for originally creating this function
 * for his "Options Framework" -- This function has since been adapted
 * over time to be utilized throughout many parts of the Theme Blvd
 * theme framework.
 * Devin Price's website: http://wptheming.com
 *
 * @since 2.2.0
 *
 * @param string $option_name Prefix for all field name attributes
 * @param array $options All options to show in form
 * @param array $settings Any current settings for all form fields
 * @param boolean $close Whether to add closing </div>
 * @return array $form Final options form
 */
function themeblvd_option_fields($option_name, $options, $settings, $close = true)
{
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        $class = '';
        // Sub Groups --
        // This allows for a wrapping div around groups of elements.
        // The primary reason for this is to help link certain options
        // together in order to apply custom javascript for certain
        // common groups.
        if ($value['type'] == 'subgroup_start') {
            if (isset($value['class'])) {
                $class = ' ' . $value['class'];
            }
            $output .= '<div class="subgroup' . $class . '">';
            continue;
        }
        if ($value['type'] == 'subgroup_end') {
            $output .= '</div><!-- .subgroup (end) -->';
            continue;
        }
        // Name Grouping --
        // This allows certain options to be grouped together in the
        // final saved options array by adding a common prefix to their
        // name form attributes.
        if (isset($value['group'])) {
            $option_name .= '[' . $value['group'] . ']';
        }
        // Sections --
        // This allows for a wrapping div around certain sections. This
        // is meant to create visual dividing styles between sections,
        // opposed to sub groups, which are used to section off the code
        // for hidden purposes.
        if ($value['type'] == 'section_start') {
            $name = !empty($value['name']) ? esc_html($value['name']) : '';
            if (isset($value['class'])) {
                $class = ' ' . $value['class'];
            }
            if (!$name) {
                $class .= ' no-name';
            }
            $output .= '<div class="postbox inner-section' . $class . '">';
            if ($name) {
                $output .= '<h3>' . $name . '</h3>';
            }
            if (!empty($value['desc'])) {
                $output .= '<div class="section-description">' . $value['desc'] . '</div>';
            }
            continue;
        }
        if ($value['type'] == 'section_end') {
            $output .= '</div><!-- .inner-section (end) -->';
            continue;
        }
        // Wrap all options
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/\\W/', '', strtolower($value['id']));
            // Determine CSS classes
            $id = 'section-' . $value['id'];
            $class = 'section ';
            if (isset($value['type'])) {
                $class .= ' section-' . $value['type'];
                if ($value['type'] == 'logo' || $value['type'] == 'background') {
                    $class .= ' section-upload';
                }
            }
            if (!empty($value['class'])) {
                $class .= ' ' . $value['class'];
            }
            // Start Output
            $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n";
            if (!empty($value['name'])) {
                // Name not required
                $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            }
            $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, override $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            if (isset($value['group'])) {
                // Set grouped value
                if (isset($settings[$value['group']][$value['id']])) {
                    $val = $settings[$value['group']][$value['id']];
                    // Striping slashes of non-array options
                    if (!is_array($val)) {
                        $val = stripslashes($val);
                    }
                }
            } else {
                // Set non-grouped value
                if (isset($settings[$value['id']])) {
                    $val = $settings[$value['id']];
                    // Striping slashes of non-array options
                    if (!is_array($val)) {
                        $val = stripslashes($val);
                    }
                }
            }
        }
        // Add each option to output based on type.
        switch ($value['type']) {
            /*---------------------------------------*/
            /* Basic Text Input
            			/*---------------------------------------*/
            case 'text':
                $place_holder = '';
                if (!empty($value['pholder'])) {
                    $place_holder = ' placeholder="' . $value['pholder'] . '"';
                }
                $output .= sprintf('<input id="%s" class="of-input" name="%s" type="text" value="%s"%s />', esc_attr($value['id']), esc_attr($option_name . '[' . $value['id'] . ']'), stripslashes(esc_attr($val)), $place_holder);
                break;
                /*---------------------------------------*/
                /* Text Area
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Text Area
            			/*---------------------------------------*/
            case 'textarea':
                $place_holder = '';
                if (!empty($value['pholder'])) {
                    $place_holder = ' placeholder="' . $value['pholder'] . '"';
                }
                $cols = '8';
                if (isset($value['options']) && isset($value['options']['cols'])) {
                    $cols = $value['options']['cols'];
                }
                $output .= sprintf('<textarea id="%s" class="of-input" name="%s" cols="%s" rows="8"%s>%s</textarea>', esc_textarea($value['id']), stripslashes(esc_attr($option_name . '[' . $value['id'] . ']')), esc_attr($cols), $place_holder, esc_textarea($val));
                break;
                /*---------------------------------------*/
                /* Select
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Select
            			/*---------------------------------------*/
            case 'select':
                $output .= '<div class="tb-fancy-select">';
                $output .= sprintf('<select class="of-input" name="%s" id="%s">', esc_attr($option_name . '[' . $value['id'] . ']'), esc_attr($value['id']));
                foreach ($value['options'] as $key => $option) {
                    $output .= sprintf('<option%s value="%s">%s</option>', selected($key, $val, false), esc_attr($key), esc_html($option));
                }
                $output .= '</select>';
                $output .= '<span class="trigger"></span>';
                $output .= '<span class="textbox"></span>';
                $output .= '</div><!-- .tb-fancy-select (end) -->';
                // If this is a builder sample select, show preview images
                if (isset($value['class']) && $value['class'] == 'builder_samples' && function_exists('themeblvd_builder_sample_previews')) {
                    $output .= themeblvd_builder_sample_previews();
                }
                break;
                /*---------------------------------------*/
                /* Radio
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Radio
            			/*---------------------------------------*/
            case 'radio':
                $name = sprintf('%s[%s]', $option_name, $value['id']);
                foreach ($value['options'] as $key => $option) {
                    $id = sprintf('%s-%s-%s', $option_name, $value['id'], $key);
                    $output .= '<div class="radio-input clearfix">';
                    $output .= sprintf('<input class="of-input of-radio" type="radio" name="%s" id="%s" value="%s" %s />', esc_attr($name), esc_attr($id), esc_attr($key), checked($val, $key, false));
                    $output .= sprintf('<label for="%s">%s</label>', esc_attr($id), esc_html($option));
                    $output .= '</div><!-- .radio-input (end) -->';
                }
                break;
                /*---------------------------------------*/
                /* Image Selectors
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Image Selectors
            			/*---------------------------------------*/
            case 'images':
                $name = sprintf('%s[%s]', $option_name, $value['id']);
                $width = '';
                if (isset($value['img_width'])) {
                    $width = $value['img_width'];
                }
                foreach ($value['options'] as $key => $option) {
                    $selected = '';
                    $checked = checked($val, $key, false);
                    $selected = $checked ? ' of-radio-img-selected' : '';
                    $output .= sprintf('<input type="radio" id="%s" class="of-radio-img-radio" value="%s" name="%s" %s />', esc_attr($value['id'] . '_' . $key), esc_attr($key), esc_attr($name), $checked);
                    $output .= sprintf('<div class="of-radio-img-label">%s</div>', esc_html($key));
                    $output .= sprintf('<img src="%s" alt="%s" class="of-radio-img-img%s" width="%s" onclick="document.getElementById(\'%s\').checked=true;" />', esc_url($option), $option, $selected, $width, esc_attr($value['id'] . '_' . $key));
                }
                break;
                /*---------------------------------------*/
                /* Checkbox
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Checkbox
            			/*---------------------------------------*/
            case 'checkbox':
                $name = sprintf('%s[%s]', $option_name, $value['id']);
                $output .= sprintf('<input id="%s" class="checkbox of-input" type="checkbox" name="%s" %s />', esc_attr($value['id']), esc_attr($name), checked($val, 1, false));
                break;
                /*---------------------------------------*/
                /* Multicheck
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Multicheck
            			/*---------------------------------------*/
            case 'multicheck':
                foreach ($value['options'] as $key => $option) {
                    $checked = isset($val[$key]) ? checked($val[$key], 1, false) : '';
                    $label = $option;
                    $option = preg_replace('/\\W/', '', strtolower($key));
                    $id = sprintf('%s-%s-%s', $option_name, $value['id'], $option);
                    $name = sprintf('%s[%s][%s]', $option_name, $value['id'], $key);
                    $output .= sprintf('<input id="%s" class="checkbox of-input" type="checkbox" name="%s" %s /><label for="%s">%s</label>', esc_attr($id), esc_attr($name), $checked, esc_attr($id), $label);
                }
                break;
                /*---------------------------------------*/
                /* Color picker
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Color picker
            			/*---------------------------------------*/
            case 'color':
                $output .= sprintf('<div id="%s" class="colorSelector"><div style="%s"></div></div>', esc_attr($value['id'] . '_picker'), esc_attr('background-color:' . $val));
                $output .= sprintf('<input class="of-color" name="%s" id="%s" type="text" value="%s" />', esc_attr($option_name . '[' . $value['id'] . ']'), esc_attr($value['id']), esc_attr($val));
                break;
                /*---------------------------------------*/
                /* Uploader
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Uploader
            			/*---------------------------------------*/
            case 'upload':
                if (function_exists('wp_enqueue_media')) {
                    // Media uploader WP 3.5+
                    $args = array('option_name' => $option_name, 'type' => 'standard', 'id' => $value['id'], 'value' => $val);
                    $output .= themeblvd_media_uploader($args);
                } else {
                    // Legacy media uploader
                    $val = array('url' => $val, 'id' => '');
                    $output .= optionsframework_medialibrary_uploader($option_name, 'standard', $value['id'], $val);
                    // @deprecated
                }
                break;
                /*---------------------------------------*/
                /* Typography
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Typography
            			/*---------------------------------------*/
            case 'typography':
                $typography_stored = $val;
                // Font Size
                if (in_array('size', $value['atts'])) {
                    $output .= '<div class="tb-fancy-select">';
                    $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">';
                    $sizes = themeblvd_recognized_font_sizes();
                    foreach ($sizes as $i) {
                        $size = $i . 'px';
                        $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>';
                    }
                    $output .= '</select>';
                    $output .= '<span class="trigger"></span>';
                    $output .= '<span class="textbox"></span>';
                    $output .= '</div><!-- .tb-fancy-select (end) -->';
                }
                // Font Style
                if (in_array('style', $value['atts'])) {
                    $output .= '<div class="tb-fancy-select">';
                    $output .= '<select class="of-typography of-typography-style" name="' . esc_attr($option_name . '[' . $value['id'] . '][style]') . '" id="' . esc_attr($value['id'] . '_style') . '">';
                    $styles = themeblvd_recognized_font_styles();
                    foreach ($styles as $key => $style) {
                        $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . esc_html($style) . '</option>';
                    }
                    $output .= '</select>';
                    $output .= '<span class="trigger"></span>';
                    $output .= '<span class="textbox"></span>';
                    $output .= '</div><!-- .tb-fancy-select (end) -->';
                }
                // Font Face
                if (in_array('face', $value['atts'])) {
                    $output .= '<div class="tb-fancy-select">';
                    $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">';
                    $faces = themeblvd_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>';
                    $output .= '<span class="trigger"></span>';
                    $output .= '<span class="textbox"></span>';
                    $output .= '</div><!-- .tb-fancy-select (end) -->';
                }
                // Font Color
                if (in_array('color', $value['atts'])) {
                    $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']) . '" />';
                }
                $output .= '<div class="clear"></div>';
                // Google Font support
                if (in_array('face', $value['atts'])) {
                    $output .= '<div class="google-font hide">';
                    $output .= '<h5>' . __('Enter the name of a font from the <a href="http://www.google.com/webfonts" target="_blank">Google Font Directory</a>.', 'themeblvd') . '</h5>';
                    $output .= '<input type="text" name="' . esc_attr($option_name . '[' . $value['id'] . '][google]') . '" value="' . esc_attr($typography_stored['google']) . '" />';
                    $output .= '<p class="note">Example Font Name: "Hammersmith One"</p>';
                    $output .= '</div>';
                }
                break;
                /*---------------------------------------*/
                /* Background
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Background
            			/*---------------------------------------*/
            case 'background':
                $background = $val;
                // Background Color
                $current_color = '';
                if (!empty($background['color'])) {
                    $current_color = $background['color'];
                }
                $output .= sprintf('<div id="%s_color_picker" class="colorSelector"><div style="%s"></div></div>', esc_attr($value['id']), esc_attr('background-color:' . $current_color));
                $output .= sprintf('<input class="of-color of-background of-background-color" name="%s" id="%s" type="text" value="%s" />', esc_attr($option_name . '[' . $value['id'] . '][color]'), esc_attr($value['id'] . '_color'), esc_attr($current_color));
                // Background Image - New AJAX Uploader using Media Library
                if (!isset($background['image'])) {
                    $background['image'] = '';
                }
                // Currrent BG formatted correctly
                $current_bg_url = '';
                if (!empty($background['image'])) {
                    $current_bg_url = $background['image'];
                }
                $current_bg_image = array('url' => $current_bg_url, 'id' => '');
                // Start output
                // Uploader
                if (function_exists('wp_enqueue_media')) {
                    $output .= themeblvd_media_uploader(array('option_name' => $option_name, 'type' => 'background', 'id' => $value['id'], 'value' => $current_bg_url, 'name' => 'image'));
                } else {
                    $output .= optionsframework_medialibrary_uploader($option_name, 'standard', $value['id'], $current_bg_image, null, '', 0, 'image');
                    // @deprecated
                }
                $class = 'of-background-properties';
                if (empty($background['image'])) {
                    $class .= ' hide';
                }
                $output .= '<div class="' . esc_attr($class) . '">';
                // Background Repeat
                $current_repeat = !empty($background['repeat']) ? $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 = themeblvd_recognized_background_repeat();
                foreach ($repeats as $key => $repeat) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($current_repeat, $key, false) . '>' . esc_html($repeat) . '</option>';
                }
                $output .= '</select>';
                $output .= '<span class="trigger"></span>';
                $output .= '<span class="textbox"></span>';
                // Background Position
                $current_position = !empty($background['position']) ? $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 = themeblvd_recognized_background_position();
                foreach ($positions as $key => $position) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($current_position, $key, false) . '>' . esc_html($position) . '</option>';
                }
                $output .= '</select>';
                $output .= '<span class="trigger"></span>';
                $output .= '<span class="textbox"></span>';
                // Background Attachment
                $current_attachment = !empty($background['attachment']) ? $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 = themeblvd_recognized_background_attachment();
                foreach ($attachments as $key => $attachment) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($current_attachment, $key, false) . '>' . esc_html($attachment) . '</option>';
                }
                $output .= '</select>';
                $output .= '<span class="trigger"></span>';
                $output .= '<span class="textbox"></span>';
                $output .= '</div>';
                break;
                /*---------------------------------------*/
                /* Info
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Info
            			/*---------------------------------------*/
            case 'info':
                // Classes
                $class = 'section';
                if (isset($value['type'])) {
                    $class .= ' section-' . $value['type'];
                }
                if (isset($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                // Start output
                $output .= '<div class="' . esc_attr($class) . '">' . "\n";
                if (isset($value['name'])) {
                    $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if (isset($value['desc'])) {
                    $output .= $value['desc'] . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                /*---------------------------------------*/
                /* Columns Setup
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Columns Setup
            			/*---------------------------------------*/
            case 'columns':
                $output .= themeblvd_columns_option($value['options'], $value['id'], $option_name, $val);
                break;
                /*---------------------------------------*/
                /* Tabs Setup
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Tabs Setup
            			/*---------------------------------------*/
            case 'tabs':
                $output .= themeblvd_tabs_option($value['id'], $option_name, $val);
                break;
                /*---------------------------------------*/
                /* Content --
                			/* Originally designed to work in conjunction
                			/* with setting up columns and tabs.
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Content --
            			/* Originally designed to work in conjunction
            			/* with setting up columns and tabs.
            			/*---------------------------------------*/
            case 'content':
                $output .= themeblvd_content_option($value['id'], $option_name, $val, $value['options']);
                break;
                /*---------------------------------------*/
                /* Conditionals --
                			/* Originally designed to allow users to
                			/* assign custom sidebars to certain pages.
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Conditionals --
            			/* Originally designed to allow users to
            			/* assign custom sidebars to certain pages.
            			/*---------------------------------------*/
            case 'conditionals':
                $output .= themeblvd_conditionals_option($value['id'], $option_name, $val);
                break;
                /*---------------------------------------*/
                /* Logo
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Logo
            			/*---------------------------------------*/
            case 'logo':
                $output .= themeblvd_logo_option($value['id'], $option_name, $val);
                break;
                /*---------------------------------------*/
                /* Social Media
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Social Media
            			/*---------------------------------------*/
            case 'social_media':
                $output .= themeblvd_social_media_option($value['id'], $option_name, $val);
                break;
                /*---------------------------------------*/
                /* Editor
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Editor
            			/*---------------------------------------*/
            case 'editor':
                // Settings
                $editor_settings = array('wpautop' => true, 'textarea_name' => esc_attr($option_name . '[' . $value['id'] . ']'), 'media_buttons' => true, 'tinymce' => array('plugins' => 'wordpress'), 'height' => 'small');
                // @todo -- Add TB shortcode generator button.
                // This will work however currently there is a quirk that won't allow for
                // more than one editor on a page. Shortcodes will get inserted in whichever
                // the last editor the cursor was in.
                /*
                if ( defined('TB_SHORTCODES_PLUGIN_VERSION') && get_option('themeblvd_shortcode_generator') != 'no' )
                	$editor_settings['tinymce']['plugins'] .= ',ThemeBlvdShortcodes';
                */
                if (!empty($value['settings'])) {
                    $editor_settings = wp_parse_args($value['settings'], $editor_settings);
                }
                // Setup description
                if (!empty($value['desc_location']) && $value['desc_location'] == 'before') {
                    $desc_location = 'before';
                } else {
                    $desc_location = 'after';
                }
                $explain_value = '';
                $has_description = '';
                if (!empty($value['desc'])) {
                    $explain_value = $value['desc'];
                    $has_description = ' has-desc';
                }
                // Output description and editor
                $output .= '<div class="tb-wp-editor desc-' . $desc_location . $has_description . ' height-' . $editor_settings['height'] . '">';
                if ($desc_location == 'before') {
                    $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
                }
                ob_start();
                wp_editor($val, uniqid($value['id'] . '_' . rand()), $editor_settings);
                $output .= ob_get_clean();
                if ($desc_location == 'after') {
                    $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
                }
                $output .= '</div><!-- .tb-wp-editor (end) -->';
                break;
                /*---------------------------------------*/
                /* Heading for Navigation
                			/*---------------------------------------*/
            /*---------------------------------------*/
            /* Heading for Navigation
            			/*---------------------------------------*/
            case 'heading':
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $id = $value['name'];
                if (!empty($value['id'])) {
                    $id = $value['id'];
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($id));
                $jquery_click_hook = esc_attr("of-option-" . $jquery_click_hook);
                $menu .= sprintf('<a id="%s-tab" class="nav-tab" title="%s" href="%s">%s</a>', $jquery_click_hook, esc_attr($value['name']), esc_attr('#' . $jquery_click_hook), esc_html($value['name']));
                $output .= sprintf('<div class="group" id="%s">', $jquery_click_hook);
                break;
        }
        // end switch ( $value['type'] )
        // Here's your chance to add in your own custom
        // option type while we're looping through each
        // option. If you come up with a unique $type,
        // you can intercept things here and append
        // to the $output.
        $output = apply_filters('themeblvd_option_type', $output, $value, $option_name, $val);
        // Finish off standard options and add description
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            if ($value['type'] != 'checkbox') {
                $output .= '<br/>';
            }
            $output .= '</div>';
            $explain_value = '';
            if (!empty($value['desc'])) {
                $explain_value = $value['desc'];
            }
            if ($value['type'] != 'editor') {
                // Editor displays description above it
                $output .= '<div class="explain">' . wp_kses($explain_value, themeblvd_allowed_tags()) . '</div>' . "\n";
            }
            $output .= '<div class="clear"></div></div></div>' . "\n";
        }
    }
    // Optional closing div
    if ($close) {
        $output .= '</div>';
    }
    // Construct final return
    $form = array($output, $menu);
    return $form;
}
Ejemplo n.º 15
0
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Get the theme name so we can display it up top
    if (function_exists('wp_get_theme')) {
        $themename = wp_get_theme();
    } else {
        // 'get_theme_data' deprecated as of WP 3.4
        $themename = get_theme_data(get_stylesheet_directory() . '/style.css');
    }
    $themename = $themename['Name'];
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    // pls_dump($option_name);
    // pls_dump($settings);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            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;
            case 'integer':
                $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 $value['type'] == '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>';
                }
                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":
                $output .= '<ul class="multicheck-list">';
                foreach ($value['options'] as $key => $option) {
                    $checked = '';
                    $label = $option;
                    $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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 .= '<li>';
                    $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>';
                    $output .= '</li>';
                }
                $output .= '</ul>';
                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
                break;
                // Typography
            // Typography
            case 'typography':
                $typography_stored = $val;
                // Check if null
                if (!isset($typography_stored['size'])) {
                    $typography_stored['size'] = '';
                }
                if (!isset($typography_stored['face'])) {
                    $typography_stored['face'] = '';
                }
                if (!isset($typography_stored['style'])) {
                    $typography_stored['style'] = '';
                }
                if (!isset($typography_stored['color'])) {
                    $typography_stored['color'] = '';
                }
                // 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';
                    // Check if null
                    if (!isset($typography_stored['size'])) {
                        $typography_stored['size'] = '';
                    }
                    $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 = of_recognized_font_faces();
                // Check if null
                if (!isset($typography_stored['face'])) {
                    $typography_stored['face'] = '';
                }
                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 */
                // Check if null
                if (!isset($typography_stored['style'])) {
                    $typography_stored['style'] = '';
                }
                $styles = of_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;
                // BG Gradient -pek
            // BG Gradient -pek
            case 'bg_gradient':
                $bggradient = $val;
                if (!isset($bggradient['color'])) {
                    $bggradient['color'] = '';
                }
                // Color (main color used for gradient manufacture)
                $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $bggradient['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($bggradient['color']) . '" />';
                break;
                // Background
            // Background
            case 'background':
                // pls_dump($val);
                $background = $val;
                // Check if null
                if (!isset($background['repeat'])) {
                    $background['repeat'] = '';
                }
                if (!isset($background['position'])) {
                    $background['position'] = '';
                }
                if (!isset($background['attachment'])) {
                    $background['attachment'] = '';
                }
                if (!isset($background['image'])) {
                    $background['image'] = '';
                }
                if (!isset($background['color'])) {
                    $background['color'] = '';
                }
                // checking a new value, a checkbox, indicating desire to make gradation of color
                if (!isset($background['gradation'])) {
                    $background['gradation'] = '';
                }
                // Background Color
                // Background gradation
                $output .= '<input type="checkbox" class="checkbox of-background of-background-gradation" name="' . esc_attr($option_name . '[' . $value['id'] . '][gradation]') . '" id="' . esc_attr($value['id'] . '_gradation') . '" value="1" ' . checked($background['gradation'], 1, false) . '>Make gradation';
                $output .= "<div style='clear:left;'></div>\n";
                $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
                $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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                // Border
            // Border
            case 'border_shadow':
            case 'box_shadow':
            case 'border':
                $border_stored = $val;
                // Check if null
                if (!isset($border_stored['size'])) {
                    $border_stored['size'] = '';
                }
                if (!isset($border_stored['style'])) {
                    $border_stored['style'] = '';
                }
                if (!isset($border_stored['color'])) {
                    $border_stored['color'] = '';
                }
                // Border Size
                $output .= '<select class="of-border of-border-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">';
                for ($i = 0; $i < 11; $i++) {
                    $size = $i . 'px';
                    // select 1px by default if empty
                    $stored_or_one = '' === $border_stored['size'] ? '1px' : $border_stored['size'] . 'px';
                    $output .= '<option value="' . esc_attr($size) . '" ' . selected($stored_or_one, $size, false) . '>' . esc_html($size) . '</option>';
                }
                $output .= '</select>';
                // Border Style
                $styles = of_recognized_border_styles();
                $output .= '<select class="of-border of-border-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">';
                foreach ($styles as $key => $style) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($border_stored['style'], $key, false) . '>' . $style . '</option>';
                }
                $output .= '</select>';
                // Border Color
                $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $border_stored['color']) . '"></div></div>';
                $output .= '<input class="of-color of-border of-border-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($border_stored['color']) . '" />';
                break;
            case "slideshow":
                if (!isset($val['num_slides'])) {
                    $val['num_slides'] = 6;
                }
                ob_start();
                for ($i = 0; $i < $val['num_slides']; $i++) {
                    ?>
					<?php 
                    if (!isset($val[$i])) {
                        ?>
						<?php 
                        $val[$i] = array();
                        ?>
					<?php 
                    }
                    ?>
					<?php 
                    $val[$i] = wp_parse_args($val[$i], array('image' => '', 'link' => '', 'html' => '', 'type' => '', ''));
                    ?>
					<div class="featured_slideshow_options">
						<div class="featured_slide">
							<div class="featured_slide_header">
								<h2>Slide <?php 
                    echo $i + 1;
                    ?>
</h2>
								<select class="slideshow_type" name="<?php 
                    echo esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][type]');
                    ?>
" id="" >
									<option value="custom" <?php 
                    echo $val[$i]['type'] == 'custom' ? 'selected=selected' : '';
                    ?>
 >Custom Image</option>
									<option value="listing" <?php 
                    echo $val[$i]['type'] == 'listing' ? 'selected=selected' : '';
                    ?>
 >Listing</option>
								</select>
							</div>
							<div class="type_controls" id="custom_type">
								<p>Select an image for the background of the slide and enter in text or html to be displayed. </p>
								<div id="image_wrapper_<?php 
                    echo $i;
                    ?>
" class="item_row">
									<label for="">Background Image</label>
									<?php 
                    echo optionsframework_medialibrary_uploader($value['id'], $val[$i]['image'], null, '', 0, "image", $i);
                    ?>
		
								</div>
								<div class="item_row">
									<label for="">Click-to Link</label>
									<input type="text" value="<?php 
                    echo $val[$i]['link'];
                    ?>
" name="<?php 
                    echo esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][link]');
                    ?>
">
								</div>
								<div class="item_row">
									<label for="">HTML/Text Displayed</label>
									<textarea name="<?php 
                    echo esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][html]');
                    ?>
" id="" cols="30" rows="10"><?php 
                    echo $val[$i]['html'];
                    ?>
</textarea>	
								</div>
							</div>
							<div class="type_controls" id="listing_type">
								<?php 
                    echo pls_generate_featured_listings_ui($value, $val[$i], $option_name, $i, $for_slideshow = true);
                    ?>
		
							</div>
						</div>						
					</div>
				<?php 
                }
                $output .= trim(ob_get_clean());
                break;
                // Featured Listing Selection
            // Featured Listing Selection
            case "featured_listing":
                $output .= pls_generate_featured_listings_ui($value, $val, $option_name);
                break;
                // Featured Listing Selection
            // Featured Listing Selection
            case "featured_neighborhoods":
                ob_start();
                ?>

			<div class="featured-listing-search" id="featured-listing-search-<?php 
                echo $value['id'];
                ?>
">

				<div class="fls-address">

          <label>Neighborhoods</label>
          <?php 
                $categories = get_categories('type=property&taxonomy=neighborhood');
                ?>
          <select name="<?php 
                echo $value['id'];
                ?>
" class="fls-address-select" id="fls-select-neighborhood">
            <?php 
                for ($i = 1; $i <= 200; $i++) {
                    if (!isset($categories[$i])) {
                        break;
                    } else {
                        echo '<option value=' . $categories[$i]->slug . '>';
                        echo $categories[$i]->name;
                        echo '</option>';
                    }
                }
                ?>
          </select>
          

					<input type="submit" name="<?php 
                echo $value['id'];
                ?>
" value="Add Neighborhood" class="fls-add-listing button" id="add-listing-<?php 
                echo $value['id'];
                ?>
">	
					<input type="hidden" value="<?php 
                echo esc_attr($option_name . '[' . $value['id'] . ']');
                ?>
" id="option-name">	

				</div>

				<h4 class="heading">Featured Neighborhoods</h4>
				<div class="fls-option">
					<div class="controls">
						<ul name="<?php 
                echo $value['id'];
                ?>
" id="fls-added-listings">
							<?php 
                if (isset($settings[$value['id']])) {
                    ?>
								<?php 
                    foreach ($settings[$value['id']] as $key => $text) {
                        ?>
									<li style='float:left; list-style-type: none;'><div id='pls-featured-text' style='width: 200px; float: left;'><?php 
                        echo $text;
                        ?>
</div><a style='float:left;' href='#' id='pls-option-remove-listing'>Remove</a><input type='hidden' name='<?php 
                        echo esc_attr($option_name . '[' . $value['id'] . '][' . $key . ']=');
                        ?>
' value='<?php 
                        echo $text;
                        ?>
' /></li>
								<?php 
                    }
                    ?>
							<?php 
                }
                ?>
						</ul>
					</div>
					<div class="clear"></div>
				</div>
			</div>


			<?php 
                $output .= trim(ob_get_clean());
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<li class="side-bar-nav-item"><a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a></li>';
                ob_start();
                ?>

			<div class="group" id="<?php 
                echo esc_attr($jquery_click_hook);
                ?>
">
				<h3 id="optionsframework-submit-top" >
					<div>
						<span><?php 
                echo esc_html($value['name']);
                ?>
</span>
						<input type="submit" class="top-button button-primary" name="update" value="Save Options" />
					</div>	
				</h3>

			<?php 
                $output .= ob_get_clean();
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $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";
        }
    }
    $for_slideshow = isset($for_slideshow) ? $for_slideshow : false;
    $output .= PLS_Featured_Listing_Option::load(array('value' => $value, 'val' => $val, 'option_name' => $option_name, 'iterator' => isset($iterator) ? $iterator : false, 'for_slideshow' => $for_slideshow));
    $output .= '</div>';
    return array($output, $menu);
}
Ejemplo n.º 16
0
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Get the theme name so we can display it up top
    $themename = get_theme_data(get_stylesheet_directory() . '/style.css');
    $themename = $themename['Name'];
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            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;
                // Select Box
            // Select Box
            case $value['type'] == '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>';
                }
                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 .= '<div style="background: #f8f8f8 url(' . esc_url($option) . ') repeat; width: 40px;height:40px; display:block; float:left" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;"></div>';
                }
                break;
                // Uploader
            // Uploader
            case "upload":
                $output .= optionsframework_medialibrary_uploader($value['id'], $val, null);
                // New AJAX Uploader using Media Library
                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 .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n";
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $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);
}
Ejemplo n.º 17
0
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    $counter = 0;
    $menu = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        $output = '';
        // Wrap all options
        if ($value['type'] != "heading" && $value['type'] != "info") {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', 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";
            if (isset($value['name'])) {
                $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            }
            if ($value['type'] != 'editor') {
                $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
            } else {
                $output .= '<div class="option">' . "\n" . '<div>' . "\n";
            }
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info') {
            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':
                $rows = '8';
                if (isset($value['settings']['rows'])) {
                    $custom_rows = $value['settings']['rows'];
                    if (is_numeric($custom_rows)) {
                        $rows = $custom_rows;
                    }
                }
                $val = stripslashes($val);
                $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . esc_attr($val) . '</textarea>';
                break;
                // Select Box
            // Select Box
            case $value['type'] == '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>';
                }
                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('/[^a-zA-Z0-9._\\-]/', '', 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>';
                }
                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);
                break;
                // Typography
            // Typography
            case 'typography':
                unset($font_size, $font_style, $font_face, $font_color);
                $typography_defaults = array('size' => '', 'face' => '', 'style' => '', 'color' => '');
                $typography_stored = wp_parse_args($val, $typography_defaults);
                $typography_options = array('sizes' => of_recognized_font_sizes(), 'faces' => of_recognized_font_faces(), 'styles' => of_recognized_font_styles(), 'color' => true);
                if (isset($value['options'])) {
                    $typography_options = wp_parse_args($value['options'], $typography_options);
                }
                // Font Size
                if ($typography_options['sizes']) {
                    $font_size = '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">';
                    $sizes = $typography_options['sizes'];
                    foreach ($sizes as $i) {
                        $size = $i . 'px';
                        $font_size .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>';
                    }
                    $font_size .= '</select>';
                }
                // Font Face
                if ($typography_options['faces']) {
                    $font_face = '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">';
                    $faces = $typography_options['faces'];
                    foreach ($faces as $key => $face) {
                        $font_face .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>';
                    }
                    $font_face .= '</select>';
                }
                // Font Styles
                if ($typography_options['styles']) {
                    $font_style = '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">';
                    $styles = $typography_options['styles'];
                    foreach ($styles as $key => $style) {
                        $font_style .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>';
                    }
                    $font_style .= '</select>';
                }
                // Font Color
                if ($typography_options['color']) {
                    $font_color = '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>';
                    $font_color .= '<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']) . '" />';
                }
                // Allow modification/injection of typography fields
                $typography_fields = compact('font_size', 'font_face', 'font_style', 'font_color');
                $typography_fields = apply_filters('of_typography_fields', $typography_fields, $typography_stored, $option_name, $value);
                $output .= implode('', $typography_fields);
                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;
                // Editor
            // Editor
            case 'editor':
                $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
                echo $output;
                $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']');
                $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress'));
                $editor_settings = array();
                if (isset($value['settings'])) {
                    $editor_settings = $value['settings'];
                }
                $editor_settings = array_merge($editor_settings, $default_editor_settings);
                wp_editor($val, $value['id'], $editor_settings);
                $output = '';
                break;
                // Info
            // Info
            case "info":
                $id = '';
                $class = 'section';
                if (isset($value['id'])) {
                    $id = 'id="' . esc_attr($value['id']) . '" ';
                }
                if (isset($value['type'])) {
                    $class .= ' section-' . $value['type'];
                }
                if (isset($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                $output .= '<div ' . $id . 'class="' . esc_attr($class) . '">' . "\n";
                if (isset($value['name'])) {
                    $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '</div>' . "\n";
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $class = (isset($value['class']) ? $value['class'] . ' ' : '') . 'nav-tab';
                $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="' . $class . '" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n";
                break;
                /*********************************
                 *********************************
                 ** CUSTOM FIELDS ****************
                 *********************************
                 *********************************/
                // Heading Typography
            /*********************************
             *********************************
             ** CUSTOM FIELDS ****************
             *********************************
             *********************************/
            // Heading Typography
            case 'typo':
                $typo_stored = $val;
                // Font Size
                $output .= '<p><label>Font Size: </label>';
                $output .= '<select class="of-typography of-typo-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($typo_stored['size'], $size, false) . '>' . esc_html($size) . '</option>';
                }
                $output .= '</select></p>';
            case 'header':
                $typo_stored = $val;
                // Font Face
                $output .= '<p><label>Font Family: </label>';
                $output .= '<select class="of-typography of-typo-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">';
                $faces = of_recognized_font_faces();
                foreach ($faces as $key => $face) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['face'], $key, false) . '>' . esc_html($face) . '</option>';
                }
                $output .= '</select></p>';
                // Font Style
                $output .= '<p><label>Font Style: </label>';
                $output .= '<select class="of-typography of-typo-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">';
                $styles = ale_get_typo_styles();
                foreach ($styles as $key => $style) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['style'], $key, false) . '>' . $style . '</option>';
                }
                $output .= '</select></p>';
                // Font Weight
                $output .= '<p><label>Font Weight: </label>';
                $output .= '<select class="of-typography of-typo-weight" name="' . $option_name . '[' . $value['id'] . '][weight]" id="' . $value['id'] . '_style">';
                $weights = ale_get_typo_weights();
                foreach ($weights as $key => $weight) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['weight'], $key, false) . '>' . $weight . '</option>';
                }
                $output .= '</select></p>';
                // Font Variant
                $output .= '<p><label>Font Variant: </label>';
                $output .= '<select class="of-typography of-typo-variant" name="' . $option_name . '[' . $value['id'] . '][variant]" id="' . $value['id'] . '_style">';
                $variants = ale_get_typo_variants();
                foreach ($variants as $key => $variant) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['variant'], $key, false) . '>' . $variant . '</option>';
                }
                $output .= '</select></p>';
                // Text Transform
                $output .= '<p><label>Text Transform: </label>';
                $output .= '<select class="of-typography of-typo-transform" name="' . $option_name . '[' . $value['id'] . '][transform]" id="' . $value['id'] . '_style">';
                $transforms = ale_get_typo_transforms();
                foreach ($transforms as $key => $transform) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['transform'], $key, false) . '>' . $transform . '</option>';
                }
                $output .= '</select></p>';
                break;
                // Color picker
            // Color picker
            case "color_link":
                $color_stored = $val;
                if (!isset($color_stored['main'])) {
                    $color_stored['main'] = '';
                }
                if (!isset($color_stored['hover'])) {
                    $color_stored['hover'] = '';
                }
                $labels = isset($value['labels']) ? $value['labels'] : array('main' => 'Main', 'hover' => 'Hover');
                $output .= '<div class="color-wrap">';
                $output .= '<span class="color_helper">' . $labels['main'] . ':</span>';
                $output .= '<div id="' . esc_attr($value['id'] . '_main_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $color_stored['main']) . '"></div></div>';
                $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '[main]" id="' . esc_attr($value['id']) . '_main" type="text" value="' . esc_attr($color_stored['main']) . '" />';
                $output .= '</div><div class="color-wrap">';
                $output .= '<span class="color_helper">' . $labels['hover'] . ':</span>';
                $output .= '<div id="' . esc_attr($value['id'] . '_hover_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $color_stored['hover']) . '"></div></div>';
                $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '[hover]" id="' . esc_attr($value['id']) . '_hover" type="text" value="' . esc_attr($color_stored['hover']) . '" />';
                $output .= '</div>';
                break;
        }
        if ($value['type'] != "heading" && $value['type'] != "info") {
            $output .= '</div>';
            if ($value['type'] != "checkbox" && $value['type'] != "editor") {
                $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
            }
            $output .= '</div></div>' . "\n";
        }
        echo $output;
    }
    echo '</div>';
}
 public function html()
 {
     $background = $this->val;
     // Background Color
     $this->output .= '<div id="' . esc_attr($this->value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>';
     $this->output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][color]') . '" id="' . esc_attr($this->value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />';
     // Background Image - New AJAX Uploader using Media Library
     if (!isset($background['image'])) {
         $background['image'] = '';
     }
     $this->output .= optionsframework_medialibrary_uploader($this->value['id'], $background['image'], null, '', 0, 'image');
     $class = 'of-background-properties';
     if ('' == $background['image']) {
         $class .= ' hide';
     }
     $this->output .= '<div class="' . esc_attr($class) . '">';
     // Background Repeat
     $this->output .= '<select class="of-background of-background-repeat" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][repeat]') . '" id="' . esc_attr($this->value['id'] . '_repeat') . '">';
     $repeats = of_recognized_background_repeat();
     foreach ($repeats as $key => $repeat) {
         $this->output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>';
     }
     $this->output .= '</select>';
     // Background Position
     $this->output .= '<select class="of-background of-background-position" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][position]') . '" id="' . esc_attr($this->value['id'] . '_position') . '">';
     $positions = of_recognized_background_position();
     foreach ($positions as $key => $position) {
         $this->output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>';
     }
     $this->output .= '</select>';
     // Background Attachment
     $this->output .= '<select class="of-background of-background-attachment" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][attachment]') . '" id="' . esc_attr($this->value['id'] . '_attachment') . '">';
     $attachments = of_recognized_background_attachment();
     foreach ($attachments as $key => $attachment) {
         $this->output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>';
     }
     $this->output .= '</select>';
     $this->output .= '</div>';
     return $this->output;
 }