コード例 #1
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;
                // Password input
            // Password input
            case 'password':
                $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="password" 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_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":
                $default_color = '';
                if (isset($value['std'])) {
                    if ($val != $value['std']) {
                        $default_color = ' data-default-color="' . $value['std'] . '" ';
                    }
                }
                $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" class="of-color"  type="text" value="' . esc_attr($val) . '"' . $default_color . ' />';
                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']) {
                    $default_color = '';
                    if (isset($value['std']['color'])) {
                        if ($val != $value['std']['color']) {
                            $default_color = ' data-default-color="' . $value['std']['color'] . '" ';
                        }
                    }
                    $font_color = '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" class="of-color of-typography-color  type="text" value="' . esc_attr($typography_stored['color']) . '"' . $default_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
                $default_color = '';
                if (isset($value['std']['color'])) {
                    if ($val != $value['std']['color']) {
                        $default_color = ' data-default-color="' . $value['std']['color'] . '" ';
                    }
                }
                $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" class="of-color of-background-color"  type="text" value="' . esc_attr($background['color']) . '"' . $default_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";
                }
                $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") {
            $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>';
}
コード例 #2
0
/**
 * Format Configuration Array.
 *
 * Get an array of all default values as set in
 * options.php. The 'id','std' and 'type' keys need
 * to be defined in the configuration array. In the
 * event that these keys are not present the option
 * will not be included in this function's output.
 *
 * @return    array     Rey-keyed options configuration array.
 *
 * @access    private
 */
function of_get_default_values()
{
    $output = array();
    $config =& _optionsframework_options();
    foreach ((array) $config as $option) {
        if (!isset($option['id'])) {
            continue;
        }
        if (!isset($option['std'])) {
            continue;
        }
        if (!isset($option['type'])) {
            continue;
        }
        if (has_filter('of_sanitize_' . $option['type'])) {
            $output[$option['id']] = apply_filters('of_sanitize_' . $option['type'], $option['std'], $option);
        }
    }
    return $output;
}
コード例 #3
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
            $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;
                // 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;
        }
        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);
}
コード例 #4
0
ファイル: options-interface.php プロジェクト: scottnkerr/eeco
/**
 * 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();
    // Clear function static variables
    optionsframework_options_for_page_filter(0);
    // Filter options for current page
    $options = array_filter($options, 'optionsframework_options_for_page_filter');
    $optionsframework_debug = defined('OPTIONS_FRAMEWORK_DEBUG') && OPTIONS_FRAMEWORK_DEBUG ? true : false;
    $counter = 0;
    $menu = '';
    $elements_without_wrap = array('block_begin', 'block_end', 'heading', 'info', 'page', 'js_hide_begin', 'js_hide_end', 'title', 'divider');
    foreach ($options as $value) {
        $val = '';
        $select_value = '';
        $checked = '';
        $output = '';
        if (!empty($value['before'])) {
            $output .= $value['before'];
        }
        // Wrap all options
        if (!in_array($value['type'], $elements_without_wrap)) {
            // 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 .= '<div class="option">' . "\n";
            if (!empty($value['name']) || $optionsframework_debug) {
                $output .= '<div class="name">' . (!empty($value['name']) ? esc_html($value['name']) : '') . "\n";
                $explain_value = '';
                if (isset($value['desc'])) {
                    $explain_value = $value['desc'];
                }
                $output .= '<div class="explain"><small>' . wp_kses($explain_value, $allowedtags) . ($optionsframework_debug ? '<br /><code>' . $value['id'] . '</code>' : '') . '</small></div>' . "\n";
                $output .= '</div>' . "\n";
            }
            if ($value['type'] != 'editor') {
                if (empty($value['name'])) {
                    $output .= '<div class="controls controls-fullwidth">' . "\n";
                } else {
                    $output .= '<div class="controls">' . "\n";
                }
            } else {
                $output .= '<div>' . "\n";
            }
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if (!in_array($value['type'], array('page', 'info', 'heading'))) {
            if (isset($value['id'], $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;
                // Password input
            // Password input
            case 'password':
                $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="password" 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_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'] . ']';
                $show_hide = empty($value['show_hide']) ? array() : (array) $value['show_hide'];
                $classes = array('of-input', 'of-radio');
                if (!empty($show_hide)) {
                    $classes[] = 'of-js-hider';
                }
                foreach ($value['options'] as $key => $option) {
                    $id = $option_name . '-' . $value['id'] . '-' . $key;
                    $input_classes = $classes;
                    $attr = '';
                    if (!empty($show_hide[$key])) {
                        $input_classes[] = 'js-hider-show';
                        if (true !== $show_hide[$key]) {
                            $attr = ' data-js-target="' . $show_hide[$key] . '"';
                        }
                    }
                    $output .= '<input class="' . esc_attr(implode(' ', $input_classes)) . '"' . $attr . ' 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'] . ']';
                $show_hide = empty($value['show_hide']) ? array() : (array) $value['show_hide'];
                $classes = array('of-radio-img-radio');
                if (!empty($show_hide)) {
                    $classes[] = 'of-js-hider';
                }
                if (empty($value['base_dir'])) {
                    $dir = get_template_directory_uri();
                } else {
                    $dir = $value['base_dir'];
                }
                foreach ($value['options'] as $key => $option) {
                    $input_classes = $classes;
                    $selected = '';
                    $checked = '';
                    $attr = '';
                    if ($val != '') {
                        if ($val == $key) {
                            $selected = ' of-radio-img-selected';
                            $checked = ' checked="checked"';
                        }
                    }
                    if (!empty($show_hide[$key])) {
                        $input_classes[] = 'js-hider-show';
                        if (true !== $show_hide[$key]) {
                            $attr = ' data-js-target="' . $show_hide[$key] . '"';
                        }
                    }
                    $output .= '<div class="of-radio-img-inner-container">';
                    $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="' . esc_attr(implode(' ', $input_classes)) . '"' . $attr . ' value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />';
                    $img_info = '';
                    if (is_array($option) && isset($option['src'], $option['title'])) {
                        $img = $dir . $option['src'];
                        $title = $option['title'];
                        if ($title) {
                            $img_info = '<div class="of-radio-img-label">' . esc_html($title) . '</div>';
                        }
                    } else {
                        $img = $dir . $option;
                        $title = $option;
                    }
                    $output .= '<img src="' . esc_url($img) . '" alt="' . esc_attr($title) . '" class="of-radio-img-img' . $selected . '" onclick="dtRadioImagesSetCheckbox(\'' . esc_attr($value['id'] . '_' . $key) . '\');" />';
                    $output .= $img_info;
                    $output .= '</div>';
                }
                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('/[^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":
                $default_color = '';
                if (isset($value['std'])) {
                    if ($val != $value['std']) {
                        $default_color = ' data-default-color="' . $value['std'] . '" ';
                    }
                }
                $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" class="of-color"  type="text" value="' . esc_attr($val) . '"' . $default_color . ' />';
                break;
                // Uploader
            // Uploader
            case "upload":
                $mode = isset($value['mode']) ? $value['mode'] : 'uri_only';
                $output .= optionsframework_uploader($value['id'], $val, $mode, 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']) {
                    $default_color = '';
                    if (isset($value['std']['color'])) {
                        if ($val != $value['std']['color']) {
                            $default_color = ' data-default-color="' . $value['std']['color'] . '" ';
                        }
                    }
                    $font_color = '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" class="of-color of-typography-color  type="text" value="' . esc_attr($typography_stored['color']) . '"' . $default_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
                $default_color = '';
                if (isset($value['std']['color'])) {
                    if ($val != $value['std']['color']) {
                        $default_color = ' data-default-color="' . $value['std']['color'] . '" ';
                    }
                }
                $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" class="of-color of-background-color"  type="text" value="' . esc_attr($background['color']) . '"' . $default_color . ' />';
                // Background Image
                if (!isset($background['image'])) {
                    $background['image'] = '';
                }
                $output .= optionsframework_uploader($value['id'], $background['image'], null, esc_attr($option_name . '[' . $value['id'] . '][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";
                }
                if (!empty($value['image'])) {
                    $output .= '<div class="info-image-holder"><img src="' . esc_url($value['image']) . '" /></div>';
                }
                $output .= '</div>' . "\n";
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                $counter++;
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $class = '';
                $class = !empty($value['id']) ? $value['id'] : $value['name'];
                $class = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($class));
                $output .= '<div id="options-group-' . $counter . '" class="group ' . $class . '">';
                break;
                /* Custom fields */
                // Background
            /* Custom fields */
            // Background
            case 'background_img':
                $preset_images = empty($value['preset_images']) ? array() : $value['preset_images'];
                $img_preview = false;
                if ($preset_images) {
                    $output .= '<div class="of-background-preset-images">';
                    $dir = get_template_directory_uri();
                    foreach ($preset_images as $full_src => $thumb_src) {
                        $selected = '';
                        $img = $dir . $thumb_src;
                        $data_img = $dir . $full_src;
                        if (strpos($val['image'], $full_src) !== false) {
                            $selected = ' of-radio-img-selected';
                            $img_preview = $img;
                        }
                        $output .= '<img data-full-src="' . esc_attr($data_img) . '" src="' . esc_url($img) . '" alt="" class="of-radio-img-img' . $selected . '" />';
                    }
                    $output .= '</div>';
                }
                $background = $val;
                // Background Image
                if (!isset($background['image'])) {
                    $background['image'] = '';
                }
                $output .= optionsframework_uploader($value['id'], $background['image'], null, null, esc_attr($option_name . '[' . $value['id'] . '][image]'));
                $class = 'of-background-properties';
                if ('' == $background['image']) {
                    $class .= ' hide';
                }
                $output .= '<div class="' . esc_attr($class) . '">';
                if (!isset($value['fields']) || in_array('repeat', (array) $value['fields'])) {
                    // 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>';
                }
                if (!isset($value['fields']) || in_array('position_x', (array) $value['fields'])) {
                    // Background Position x
                    $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position_x]') . '" id="' . esc_attr($value['id'] . '_position_x') . '">';
                    $positions = of_recognized_background_horizontal_position();
                    foreach ($positions as $key => $position) {
                        $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position_x'], $key, false) . '>' . esc_html($position) . '</option>';
                    }
                    $output .= '</select>';
                }
                if (!isset($value['fields']) || in_array('position_y', (array) $value['fields'])) {
                    // Background Position y
                    $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position_y]') . '" id="' . esc_attr($value['id'] . '_position_y') . '">';
                    $positions = of_recognized_background_vertical_position();
                    foreach ($positions as $key => $position) {
                        $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position_y'], $key, false) . '>' . esc_html($position) . '</option>';
                    }
                    $output .= '</select>';
                }
                // Background Attachment
                $output .= '</div>';
                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="postbox ' . esc_attr($class) . '">' . "\n";
                if (isset($value['name']) && !empty($value['name'])) {
                    $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n";
                }
                break;
                // Block End
            // Block End
            case "block_end":
                $output .= '</div>' . "\n" . '<!-- block_end -->';
                break;
                // Page
            // Page
            case "page":
                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 ('select' == $data['type']) {
                                $el_args['options'] = isset($data['options']) ? $data['options'] : array();
                                $el_args['selected'] = $el_args['value'];
                            }
                            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_create_tag($data['type'], $el_args);
                            $block .= $element;
                        }
                        unset($data);
                        $output .= '<li class="nav-menus-php nav-menu-index-' . $index . '">';
                        $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 class="item-edit"></a></span></div>';
                        $output .= '<div class="of_fields_gen_data menu-item-settings description" style="display: none;">' . $block;
                        // if ( isset($value['std'][ $index ], $value['std'][ $index ]['permanent']) && $value['std'][ $index ]['permanent'] ) {
                        // } else {
                        $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 ('select' == $data['type']) {
                        $el_args['options'] = isset($data['options']) ? $data['options'] : array();
                        $el_args['selected'] = isset($data['selected']) ? $data['selected'] : 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_create_tag($data['type'], $el_args);
                    $output .= $element;
                }
                unset($data);
                // add button
                $button = dt_create_tag('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_icons':
                if (!isset($value['options']) || !is_array($value['options'])) {
                    continue;
                }
                foreach ($value['options'] as $class => $desc) {
                    $name = sprintf('%s[%s][%s]', $option_name, $value['id'], $class);
                    $link = isset($val[$class]) ? $val[$class] : '';
                    $maxlength = isset($value['maxlength']) ? ' maxlength="' . $value['maxlength'] . '"' : '';
                    $output .= '<label>' . esc_html($desc) . '<input class="of-input" name="' . esc_attr($name) . '" type="text" value="' . esc_url($link) . '"' . $maxlength . '/></label>';
                }
                break;
                // fields generator alpha
            // fields generator alpha
            case "fields_generator_alpha":
                if (!empty($value['options']['interface_filter']) && function_exists($value['options']['interface_filter'])) {
                    add_filter('optionsframework_interface_fields_generator', $value['options']['interface_filter'], 10, 2);
                }
                $del_link = '<div class="submitbox"><a href="#" class="of_fields_gen_del submitdelete">' . _x('Delete', 'backend fields', LANGUAGE_ZONE) . '</a></div>';
                $name = sprintf('%s[%s]', $option_name, $value['id']);
                $output .= '<ul class="of_fields_gen_list">';
                // saved elements
                if (is_array($val)) {
                    $next_id = isset($val['next_id']) ? $val['next_id'] : max(array_keys($val));
                    $output .= '<input id="of-wa-nextid" type="hidden" name="' . $name . '[next_id]" value="' . $next_id . '" />';
                    $i = 0;
                    // create elements
                    foreach ($val as $field_id => $field_data) {
                        $title = empty($field_data['title']) ? _x('no title', 'theme-options', LANGUAGE_ZONE) : $field_data['title'];
                        $output .= '<li class="nav-menus-php">';
                        foreach ($field_data as $f_name => $f_val) {
                            $output .= sprintf('<input type="hidden" data-field="%1$s" class="of-wa-datafield" name="%2$s" value="%3$s" />', esc_attr($f_name), esc_attr($name . "[{$field_id}][{$f_name}]"), esc_attr($f_val));
                        }
                        $output .= '<div class="of_fields_gen_title menu-item-handle" data-id="' . $field_id . '"><span class="dt-menu-item-title">' . esc_attr($title) . '</span>';
                        $output .= '</li>';
                        $i++;
                    }
                    unset($field);
                }
                $output .= '</ul>';
                // control panel
                $output .= '<div class="of_fields_gen_controls">';
                $output .= apply_filters('optionsframework_interface_fields_generator', '', $value);
                $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 $field => $ico) {
                    $defaults = array('img' => '', 'desc' => '');
                    $ico = wp_parse_args((array) $ico, $defaults);
                    extract($ico);
                    $name = sprintf('%s[%s][%s]', $option_name, $value['id'], $field);
                    $soc_link = isset($val[$field], $val[$field]['link']) ? $val[$field]['link'] : '';
                    $src = isset($val[$field], $val[$field]['src']) ? $val[$field]['src'] : '';
                    $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 .= '<div class="of-soc-image" style="background: url( ' . $img . ' ) no-repeat 0 0; vertical-align: middle; margin-right: 5px; display: inline-block;' . $ico_size . '"></div>';
                }
                break;
                // Slider
            // Slider
            case 'slider':
                $classes = array('of-slider');
                if (!empty($value['options']['java_hide_if_not_max'])) {
                    $classes[] = 'of-js-hider';
                    $classes[] = 'js-hide-if-not-max';
                } else {
                    if (!empty($value['options']['java_hide_global_not_max'])) {
                        $classes[] = 'of-js-hider-global';
                        $classes[] = 'js-hide-if-not-max';
                    }
                }
                $classes = implode(' ', $classes);
                $output .= '<div class="' . $classes . '"></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 : 100);
                $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;
                // Hidden area begin
            // Hidden area begin
            case 'js_hide_begin':
                $class = 'of-js-hide hide-if-js';
                if (!empty($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                $output .= '<div class="' . esc_attr($class) . '">';
                break;
                // Hidden area end
            // Hidden area end
            case 'js_hide_end':
                $output .= '</div>';
                break;
                // Social buttons
            // Social buttons
            case 'social_buttons':
                $social_buttons = (array) apply_filters('optionsframework_interface-social_buttons', array());
                if (empty($social_buttons)) {
                    $output .= '<p>Use "optionsframework_interface-social_buttons" filter to add some buttons. It needs array( id1 => name1, id2 => name2 ).</p>';
                    break;
                }
                $saved_buttons = isset($val) ? (array) $val : array();
                $output .= '<ul class="connectedSortable content-holder">';
                $output .= '<li class="ui-dt-sb-hidden"><input type="hidden" name="' . esc_attr($option_name . '[' . $value['id'] . '][]') . '" value="" /></li>';
                foreach ($saved_buttons as $field) {
                    $output .= '<li class="ui-state-default"><input type="hidden" name="' . esc_attr($option_name . '[' . $value['id'] . '][]') . '" value="' . esc_attr($field) . '" data-name="' . esc_attr($option_name . '[' . $value['id'] . '][]') . '"/>' . $social_buttons[$field] . '</li>';
                }
                $output .= '</ul>';
                $output .= '<ul class="connectedSortable tools-palette">';
                foreach ($social_buttons as $v => $desc) {
                    if (in_array($v, $saved_buttons)) {
                        continue;
                    }
                    $output .= '<li class="ui-state-default"><input type="hidden" value="' . esc_attr($v) . '" data-name="' . esc_attr($option_name . '[' . $value['id'] . '][]') . '"/>' . $desc . '</li>';
                }
                $output .= '</ul>';
                break;
                // Web fonts
            // Web fonts
            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"><span>Silence is a true friend who never betrays.</span></div>';
                break;
            case 'square_size':
                $id = esc_attr($value['id']);
                $output .= '<input type="text" class="of-input dt-square-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][width]') . '" value="' . absint($val['width']) . '" />';
                $output .= '<span>&times;</span>';
                $output .= '<input type="text" class="of-input dt-square-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][height]') . '" value="' . absint($val['height']) . '" />';
                break;
                // import/export theme options
            // import/export theme options
            case 'import_export_options':
                $rows = '8';
                if (isset($value['settings']['rows'])) {
                    $custom_rows = $value['settings']['rows'];
                    if (is_numeric($custom_rows)) {
                        $rows = $custom_rows;
                    }
                }
                $valid_settings = $settings;
                $fields_black_list = apply_filters('optionsframework_fields_black_list', array());
                // do not export preserved settings
                foreach ($fields_black_list as $black_setting) {
                    if (array_key_exists($black_setting, $valid_settings)) {
                        unset($valid_settings[$black_setting]);
                    }
                }
                $val = base64_encode(serialize($valid_settings));
                $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input of-import-export" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '" onclick="this.focus();this.select()">' . esc_textarea($val) . '</textarea>';
                break;
            case 'title':
                $output .= '<div class="of-title"><h4>' . esc_html($value['name']) . '</h4></div>';
                break;
            case 'divider':
                $output .= '<div class="divider"></div>';
                break;
                // Gradient
            // Gradient
            case "gradient":
                $default_color = '';
                if (isset($value['std'][0])) {
                    if ($val != $value['std'][0]) {
                        $default_color_1 = ' data-default-color="' . $value['std'][0] . '" ';
                    }
                }
                if (isset($value['std'][1])) {
                    if ($val != $value['std'][1]) {
                        $default_color_2 = ' data-default-color="' . $value['std'][1] . '" ';
                    }
                }
                $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][0]') . '" id="' . esc_attr($value['id']) . '-0" class="of-color"  type="text" value="' . esc_attr($val[0]) . '"' . $default_color_1 . ' />';
                $output .= '&nbsp;';
                $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][1]') . '" id="' . esc_attr($value['id']) . '-1" class="of-color"  type="text" value="' . esc_attr($val[1]) . '"' . $default_color_2 . ' />';
                break;
                // sortable
            // sortable
            case 'sortable':
                if (!empty($value['items'])) {
                    $sortable_items = $value['items'];
                } else {
                    $output .= '<p>No items specified. It needs array( id1 => name1, id2 => name2 ).</p>';
                    break;
                }
                $saved_items = isset($val) ? (array) $val : array();
                if (!empty($value['fields']) && is_array($value['fields'])) {
                    $fields_count = 0;
                    $output .= '<div class="sortable-fields-holder">';
                    foreach ($value['fields'] as $field_id => $field_settings) {
                        // classes
                        $field_classes = 'connectedSortable content-holder';
                        if (!empty($field_settings['class'])) {
                            $field_classes .= ' ' . $field_settings['class'];
                        }
                        // items name
                        $item_name = esc_attr(sprintf('%1$s[%2$s][%3$s][]', $option_name, $value['id'], $field_id));
                        // saved items
                        $saved_field_items = array_key_exists($field_id, $saved_items) ? $saved_items[$field_id] : array();
                        // field title
                        if (!empty($field_settings['title'])) {
                            $output .= '<div class="sortable-field-title">' . ++$fields_count . '. ' . esc_html($field_settings['title']) . '</div>';
                        }
                        $output .= '<div class="sortable-field">';
                        // output fields
                        $output .= '<ul class="' . esc_attr($field_classes) . '" data-sortable-item-name="' . $item_name . '">';
                        $output .= '<li class="ui-dt-sb-hidden"><input type="hidden" name="' . $item_name . '" value="" /></li>';
                        if (!empty($saved_field_items) && is_array($saved_field_items)) {
                            foreach ($saved_field_items as $item_value) {
                                $item_settings = $sortable_items[$item_value];
                                $item_title = empty($item_settings['title']) ? 'undefined' : esc_html($item_settings['title']);
                                $item_class = empty($item_settings['class']) ? '' : ' ' . esc_attr($item_settings['class']);
                                $output .= '<li class="ui-state-default' . $item_class . '"><input type="hidden" name="' . $item_name . '" value="' . esc_attr($item_value) . '" /><span>' . $item_title . '</span></li>';
                                // remove item from palette list
                                unset($sortable_items[$item_value]);
                            }
                        }
                        $output .= '</ul>';
                        $output .= '</div>';
                    }
                    $output .= '</div>';
                }
                $output .= '<div class="sortable-items-holder">';
                // palette title
                if (!empty($value['palette_title'])) {
                    $output .= '<div class="sortable-palette-title">' . esc_html($value['palette_title']) . '</div>';
                }
                $output .= '<ul class="connectedSortable tools-palette">';
                foreach ($sortable_items as $item_value => $item_settings) {
                    $item_title = empty($item_settings['title']) ? 'undefined' : esc_html($item_settings['title']);
                    $item_class = empty($item_settings['class']) ? '' : ' ' . esc_attr($item_settings['class']);
                    $output .= '<li class="ui-state-default' . $item_class . '"><input type="hidden" value="' . esc_attr($item_value) . '" /><span>' . $item_title . '</span></li>';
                }
                $output .= '</ul>';
                $output .= '</div>';
                break;
                // Select Box
            // Select Box
            case 'pages_list':
                $html = wp_dropdown_pages(array('name' => esc_attr($option_name . '[' . $value['id'] . ']'), 'id' => esc_attr($value['id']), 'echo' => 0, 'show_option_none' => __('&mdash; Select &mdash;', LANGUAGE_ZONE), 'option_none_value' => '0', 'selected' => $val));
                $html = str_replace('<select', '<select class="of-input"', $html);
                $output .= $html;
                break;
        }
        if (!in_array($value['type'], $elements_without_wrap)) {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $output .= '</div>';
            $output .= '<div class="clear"></div></div></div>' . "\n";
        }
        if (!empty($value['after'])) {
            $output .= $value['after'];
        }
        do_action('options-interface-before-output', $output, $value, $val);
        echo apply_filters('options-interface-output', $output, $value, $val);
    }
    echo '</div>';
}
コード例 #5
0
ファイル: options-framework.php プロジェクト: scottnkerr/eeco
/**
 * Format Configuration Array.
 *
 * Get an array of all default values as set in
 * options.php. The 'id','std' and 'type' keys need
 * to be defined in the configuration array. In the
 * event that these keys are not present the option
 * will not be included in this function's output.
 *
 * @return    array     Rey-keyed options configuration array.
 *
 * @access    private
 */
function of_get_default_values($page = null)
{
    $output = $preset = $saved_options = array();
    $config =& _optionsframework_options();
    $known_options = get_option('optionsframework', array());
    $tmp_options = get_option($known_options['id'], array());
    $first_run = false;
    // If this is first run - use one of preset
    if (empty($tmp_options)) {
        $tmp_options['preset'] = apply_filters('options_framework_first_run_skin', '');
        $first_run = true;
    }
    // If this is preset page - restore it's defaults
    if (isset($tmp_options['preset'])) {
        // Get preset options
        $preset = optionsframework_presets_data($tmp_options['preset']);
        // if preset not set - set it
        if (!isset($preset['preset'])) {
            $preset['preset'] = $tmp_options['preset'];
        }
        // For first run preserve some options
        if ($first_run) {
            $preserve = array('widgetareas', 'bottom_bar-copyrights', 'bottom_bar-credits', 'social_buttons-post', 'social_buttons-portfolio', 'social_buttons-albums', 'general-tracking_code', 'general-favicon', 'general-wysiwig_visual_columns');
            foreach ($preserve as $option) {
                if (isset($preset[$option])) {
                    unset($preset[$option]);
                }
            }
        }
    }
    // Current page defaults
    if ($page) {
        $arr = array();
        $found = null;
        // Find Page options
        foreach ($config as $option) {
            if ('options-framework' == $page && null === $found) {
                $found = true;
            } elseif (isset($option['type']) && 'page' == $option['type'] && $option['menu_slug'] == $page) {
                $found = true;
                continue;
            } elseif (isset($option['type']) && 'page' == $option['type']) {
                $found = false;
            }
            if ($found) {
                $arr[] = $option;
            }
        }
        $config = $arr;
        $saved_options = $tmp_options;
    }
    foreach ((array) $config as $option) {
        if (!isset($option['id'])) {
            continue;
        }
        if (!isset($option['std'])) {
            continue;
        }
        if (!isset($option['type'])) {
            continue;
        }
        if (has_filter('of_sanitize_' . $option['type'])) {
            $value = $option['std'];
            // Use defaults from preset if it's present
            if (isset($preset[$option['id']])) {
                $preset_value = $preset[$option['id']];
                if ('upload' == $option['type'] && isset($option['mode']) && 'full' == $option['mode']) {
                    $preset_value = array_reverse($preset_value);
                }
                $value = $preset_value;
            }
            $output[$option['id']] = apply_filters('of_sanitize_' . $option['type'], $value, $option);
        }
    }
    $output = array_merge($saved_options, $output);
    return $output;
}
コード例 #6
0
 protected static function sanitize_options($used_options, $defaults = array())
 {
     // Use all options for sanitazing.
     $options =& _optionsframework_options();
     $clean = array();
     foreach ($options as $option) {
         if (!isset($option['id'], $option['type'])) {
             continue;
         }
         $id = preg_replace('/(\\W!-)/', '', strtolower($option['id']));
         // Set checkbox to false if it wasn't sent in the $_POST.
         if ('checkbox' == $option['type'] && !isset($used_options[$id])) {
             $used_options[$id] = false;
         }
         // Set each item in the multicheck to false if it wasn't sent in the $_POST.
         if ('multicheck' == $option['type'] && !isset($used_options[$id])) {
             foreach ($option['options'] as $key => $value) {
                 $used_options[$id][$key] = false;
             }
         }
         // Override defaults.
         if (isset($defaults[$id])) {
             $option['std'] = $defaults[$id];
         }
         if (!isset($used_options[$id])) {
             continue;
         }
         if ('upload' == $option['type'] && is_array($used_options[$id]) && isset($used_options[$id][1]) && is_numeric($used_options[$id][1])) {
             $used_options[$id] = array_reverse($used_options[$id]);
         }
         // For a value to be submitted to database it must pass through a sanitization filter.
         if (!empty($option['sanitize']) && has_filter('of_sanitize_' . $option['sanitize'])) {
             $clean[$id] = apply_filters('of_sanitize_' . $option['sanitize'], $used_options[$id], $option);
         } elseif (has_filter('of_sanitize_' . $option['type'])) {
             $clean[$id] = apply_filters('of_sanitize_' . $option['type'], $used_options[$id], $option);
         }
     }
     return $clean;
 }
コード例 #7
0
 public function import_theme_options($input = array())
 {
     // update import status
     // update_option( $this->import_status_slug, 'imported' );
     $of_options = get_option('optionsframework');
     $the7_options = get_option('the7');
     $current_theme_options = $input;
     $options_fields =& _optionsframework_options();
     $options_intersect = array_intersect_key($the7_options, $current_theme_options);
     unset($options_intersect['preset']);
     $options_intersect_keys = array_keys($options_intersect);
     foreach ($options_fields as $option_field) {
         if (empty($option_field['id']) || !in_array($option_field['id'], $options_intersect_keys)) {
             continue;
         }
         $option_id = $option_field['id'];
         $intersect_value = $options_intersect[$option_id];
         $current_theme_value = $current_theme_options[$option_id];
         switch ($option_field['type']) {
             case 'radio':
                 $radio_options = array_keys($option_field['options']);
                 if (!in_array($intersect_value, $radio_options)) {
                     $options_intersect[$option_id] = $current_theme_value;
                 }
                 break;
             case 'background_img':
                 if (!dt_maybe_uploaded_image_url($intersect_value['image'])) {
                     $options_intersect[$option_id]['image'] = $current_theme_value['image'];
                 }
                 break;
             case 'upload':
                 if ($intersect_value) {
                     if (is_array($intersect_value) && dt_maybe_uploaded_image_url($intersect_value[0])) {
                         $options_intersect[$option_id] = $intersect_value;
                     } else {
                         if (!is_array($intersect_value) && dt_maybe_uploaded_image_url($intersect_value)) {
                             $options_intersect[$option_id] = $intersect_value;
                         } else {
                             $options_intersect[$option_id] = $current_theme_value;
                         }
                     }
                 }
                 break;
         }
     }
     $current_theme_options = array_merge($current_theme_options, $options_intersect);
     return apply_filters('presscore_compatibility_import_theme_options', $current_theme_options, $the7_options);
 }
コード例 #8
0
 public function import_theme_options($input = array())
 {
     if (!$input) {
         return $input;
     }
     update_option($this->import_status_slug, 'options_imported');
     $the72_options = get_option($this->old_options_key);
     $header_preset_relation = array('side' => 'wizard05', 'left' => 'wizard01', 'classic' => 'wizard03', 'center' => 'wizard03');
     $header_layout = $the72_options['header-layout'];
     $preset_id = isset($header_preset_relation[$header_layout]) ? $header_preset_relation[$header_layout] : 'skin07s';
     $preset_options = optionsframework_presets_data($preset_id);
     // Skin.
     $the72_options['preset'] = $preset_options['preset'];
     // Top bar.
     $the72_options['top_bar-font-size'] = self::fix_font_size_option($the72_options['top_bar-font_size']);
     $the72_options['top_bar-font-color'] = $the72_options['top_bar-text_color'];
     $the72_options['top_bar-paddings-top'] = $the72_options['top_bar-paddings-bottom'] = $the72_options['top_bar-paddings'];
     $the72_options['top_bar-bg-style'] = $the72_options['top_bar-bg_mode'];
     $the72_options['top_bar-bg-color'] = $the72_options['top_bar-bg_color'];
     $the72_options['top_bar-bg-opacity'] = $the72_options['top_bar-bg_opacity'];
     $the72_options['top_bar-bg-image'] = $the72_options['top_bar-bg_image'];
     // Microwidgets.
     $the72_options['header-elements-near_menu-font_family'] = $the72_options['fonts-font_family'];
     $the72_options['header-elements-near_menu-font_size'] = '12';
     $the72_options['header-elements-near_menu-font_color'] = $the72_options['menu-font_color'];
     $the72_options['header-elements-near_logo-font_family'] = $the72_options['fonts-font_family'];
     $the72_options['header-elements-near_logo-font_size'] = $the72_options['menu-font_size'];
     $the72_options['header-elements-near_logo-font_color'] = $the72_options['menu-font_color'];
     // Header.
     $the72_options['header-layout'] = $preset_options['header-layout'];
     $the72_options['header-bg-color'] = $the72_options['header-bg_color'];
     $the72_options['header-bg-opacity'] = $the72_options['header-bg_opacity'];
     $the72_options['header-bg-image'] = $the72_options['header-bg_image'];
     $the72_options['header-bg-is_fullscreen'] = $the72_options['header-bg_fullscreen'];
     $the72_options['header-bg-is_fixed'] = $the72_options['header-bg_fixed'];
     $the72_options['header-decoration'] = 'shadow';
     $the72_options['header-menu-item-padding-top'] = '0';
     $the72_options['header-menu-item-padding-bottom'] = '0';
     $the72_options['header-menu-item-padding-left'] = '0';
     $the72_options['header-menu-item-padding-right'] = '0';
     $the72_options['header-menu-item-margin-top'] = '0';
     $the72_options['header-menu-item-margin-right'] = '0';
     $the72_options['header-menu-item-margin-bottom'] = '0';
     $the72_options['header-menu-item-margin-left'] = '0';
     $the72_options['header-menu-decoration-other-border-radius'] = '6';
     $the72_options['header-menu-decoration-other-links-is_justified'] = '0';
     switch ($header_layout) {
         case 'side':
             if ('sticky' == $the72_options['header-side_menu_visibility']) {
                 $the72_options['header-layout'] = 'slide_out';
                 $the72_options['header-slide_out-show_elements'] = 'show' == $the72_options['header-side_layout_elements_visibility'] ? '1' : '0';
                 $the72_options['header-slide_out-elements'] = self::fix_header_elements_option($header_layout, $the72_options['header-side_layout_elements']);
                 $the72_options['header-slide_out-position'] = $the72_options['header-side_position'];
                 $the72_options['header-slide_out-width'] = $the72_options['header-slide_out-content-width'] = $the72_options['header-side_menu_width'];
                 $the72_options['header-slide_out-layout'] = 'menu_icon';
                 $the72_options['header-slide_out-layout-menu_icon-show_floating_logo'] = '0';
                 $the72_options['header-slide_out-overlay-animation'] = 'slide';
                 $the72_options['header-slide_out-menu-position'] = 'v_top';
                 $the72_options['header-slide_out-logo-position'] = 'inside';
                 $the72_options['header-slide_out-elements-below_menu-padding-top'] = '6';
                 $the72_options['header-slide_out-elements-below_menu-padding-right'] = '0';
                 $the72_options['header-slide_out-elements-below_menu-padding-bottom'] = '6';
                 $the72_options['header-slide_out-elements-below_menu-padding-left'] = '0';
                 $the72_options['header-slide_out-content-padding-top'] = '0';
                 $the72_options['header-slide_out-content-padding-bottom'] = '0';
                 $the72_options['header-slide_out-content-padding-right'] = $the72_options['header-side_paddings'];
                 $the72_options['header-slide_out-content-padding-left'] = $the72_options['header-side_paddings'];
                 $the72_options['header-slide_out-content-position'] = 'center';
                 $the72_options['header-slide_out-menu-items_alignment'] = 'center';
                 $the72_options['header-slide_out-menu-items_link'] = 'textwidth';
                 $the72_options['header-menu_icon-hover-bg-color'] = $the72_options['header-menu_icon-bg-color'] = 'color' == $the72_options['general-accent_color_mode'] ? $the72_options['general-accent_bg_color'] : $the72_options['general-accent_bg_color_gradient'][0];
                 $the72_options['header-menu_icon-hover-bg-opacity'] = $the72_options['header-menu_icon-bg-opacity'] = '100';
                 $the72_options['header-menu_icon-bg-border-radius'] = '3';
                 $the72_options['header-menu_icon-margin-top'] = '50';
                 $the72_options['header-menu_icon-margin-right'] = '0';
                 $the72_options['header-menu_icon-margin-bottom'] = '0';
                 $the72_options['header-menu_icon-margin-left'] = '50';
             } else {
                 $the72_options['header-side-show_elements'] = 'show' == $the72_options['header-side_layout_elements_visibility'] ? '1' : '0';
                 $the72_options['header-side-elements'] = self::fix_header_elements_option($header_layout, $the72_options['header-side_layout_elements']);
                 $the72_options['header-side-position'] = $the72_options['header-side_position'];
                 $the72_options['header-side-width'] = $the72_options['header-side-content-width'] = $the72_options['header-side_menu_width'];
                 $the72_options['header-side-menu-position'] = 'v_top';
                 $the72_options['header-side-logo-position'] = 'inside';
                 $the72_options['header-side-content-padding-top'] = '0';
                 $the72_options['header-side-content-padding-bottom'] = '0';
                 $the72_options['header-side-elements-below_menu-padding-top'] = '6';
                 $the72_options['header-side-elements-below_menu-padding-right'] = '0';
                 $the72_options['header-side-elements-below_menu-padding-bottom'] = '6';
                 $the72_options['header-side-elements-below_menu-padding-left'] = '0';
                 $the72_options['header-side-content-padding-right'] = $the72_options['header-side_paddings'];
                 $the72_options['header-side-content-padding-left'] = $the72_options['header-side_paddings'];
                 $the72_options['header-side-content-position'] = 'center';
                 $the72_options['header-side-menu-items_alignment'] = 'center';
                 $the72_options['header-side-menu-items_link'] = 'textwidth';
             }
             break;
         case 'left':
             $the72_options['header-inline-show_elements'] = 'show' == $the72_options['header-left_layout_elements_visibility'] ? '1' : '0';
             $the72_options['header-inline-elements'] = self::fix_header_elements_option($header_layout, $the72_options['header-left_layout_elements']);
             // Hide top bar if it's empty.
             if (empty($the72_options['header-inline-elements']['top_bar_left']) && empty($the72_options['header-inline-elements']['top_bar_right'])) {
                 $the72_options['top_bar-paddings-top'] = $the72_options['top_bar-paddings-bottom'] = '0';
             }
             $the72_options['header-inline-is_fullwidth'] = '0';
             $the72_options['header-inline-elements-near_menu_right-padding-left'] = '30';
             $the72_options['header-inline-elements-near_menu_right-padding-right'] = '0';
             $the72_options['header-menu-item-padding-top'] = '4';
             $the72_options['header-menu-item-padding-bottom'] = '6';
             $the72_options['header-inline-menu-position'] = 'center';
             break;
         case 'classic':
             $the72_options['header-classic-show_elements'] = 'show' == $the72_options['header-classic_layout_elements_visibility'] ? '1' : '0';
             $the72_options['header-classic-elements'] = self::fix_header_elements_option($header_layout, $the72_options['header-classic_layout_elements']);
             // Hide top bar if it's empty.
             if (empty($the72_options['header-classic-elements']['top_bar_left']) && empty($the72_options['header-classic-elements']['top_bar_right'])) {
                 $the72_options['top_bar-paddings-top'] = $the72_options['top_bar-paddings-bottom'] = '0';
             }
             $the72_options['header-classic-menu-bg-style'] = $the72_options['header-classic_menu_bg_mode'];
             $the72_options['header-classic-menu-bg-color'] = $the72_options['header-classic_menu_bg_color'];
             $the72_options['header-classic-menu-bg-opacity'] = $the72_options['header-classic_menu_bg_opacity'];
             $the72_options['header-classic-logo-position'] = 'left';
             $the72_options['header-classic-menu-position'] = 'center';
             $the72_options['header-elements-near_logo-font_size'] = self::fix_font_size_option($the72_options['header-near_logo_font_size']);
             $the72_options['header-elements-near_logo-font_color'] = $the72_options['header-near_logo_bg_color'];
             break;
         case 'center':
             $the72_options['header-classic-show_elements'] = 'show' == $the72_options['header-center_layout_elements_visibility'] ? '1' : '0';
             $the72_options['header-classic-elements'] = self::fix_header_elements_option($header_layout, $the72_options['header-center_layout_elements']);
             // Hide top bar if it's empty.
             if (empty($the72_options['header-classic-elements']['top_bar_left']) && empty($the72_options['header-classic-elements']['top_bar_right'])) {
                 $the72_options['top_bar-paddings-top'] = $the72_options['top_bar-paddings-bottom'] = '0';
             }
             $the72_options['header-classic-logo-position'] = 'center';
             $the72_options['header-classic-menu-position'] = 'center';
             $the72_options['header-classic-menu-bg-style'] = $the72_options['header-center_menu_bg_mode'];
             $the72_options['header-classic-menu-bg-color'] = $the72_options['header-center_menu_bg_color'];
             $the72_options['header-classic-menu-bg-opacity'] = $the72_options['header-center_menu_bg_opacity'];
             break;
     }
     // Cart.
     $the72_options['header-elements-woocommerce_cart-caption'] = $the72_options['header-woocommerce_cart_caption'];
     $the72_options['header-elements-woocommerce_cart-icon'] = $the72_options['header-woocommerce_cart_icon'];
     $the72_options['header-elements-woocommerce_cart-mobile-layout'] = 'in_menu';
     $the72_options['header-elements-woocommerce_cart-show_sub_cart'] = '1';
     $the72_options['header-elements-woocommerce_cart-show_subtotal'] = $the72_options['header-woocommerce_show_cart_subtotal'];
     $the72_options['header-elements-woocommerce_cart-show_counter'] = $the72_options['header-woocommerce_show_counter'];
     $the72_options['header-elements-woocommerce_cart-counter-style'] = 'rectangular';
     $the72_options['header-elements-woocommerce_cart-counter-color'] = $the72_options['header-woocommerce_counter_color'];
     $the72_options['header-elements-woocommerce_cart-counter-bg'] = $the72_options['header-woocommerce_counter_bg_mode'];
     $the72_options['header-elements-woocommerce_cart-counter-bg-color'] = $the72_options['header-woocommerce_counter_bg_color'];
     $the72_options['header-elements-woocommerce_cart-counter-bg-gradient'] = $the72_options['header-woocommerce_counter_bg_color_gradient'];
     // Search.
     $the72_options['header-elements-search-caption'] = $the72_options['header-search_caption'];
     $the72_options['header-elements-search-icon'] = $the72_options['header-search_icon'];
     $the72_options['header-elements-search-mobile-layout'] = 'in_menu';
     // Contact information.
     $contact_info = array('address', 'phone', 'email', 'skype', 'clock');
     foreach ($contact_info as $element) {
         $the72_options["header-elements-contact-{$element}-caption"] = $the72_options["header-contact_{$element}"];
         $the72_options["header-elements-contact-{$element}-icon"] = $the72_options["header-contact_{$element}_icon"];
         $the72_options["header-elements-contact-{$element}-mobile-layout"] = 'in_menu';
     }
     // Login.
     $the72_options['header-elements-login-caption'] = $the72_options['header-login_caption'];
     $the72_options['header-elements-logout-caption'] = $the72_options['header-logout_caption'];
     $the72_options['header-elements-login-icon'] = $the72_options['header-login_icon'];
     $the72_options['header-elements-login-mobile-layout'] = 'in_menu';
     $the72_options['header-elements-login-url'] = $the72_options['header-login_url'];
     // Text.
     $the72_options['header-elements-text'] = $the72_options['header-text'];
     $the72_options['header-elements-text-mobile-layout'] = 'in_menu';
     // Custom menu.
     $the72_options['header-elements-text-mobile-layout'] = 'hidden';
     // Social icons.
     $the72_options['header-elements-text-mobile-layout'] = 'hidden';
     $the72_options['header-elements-soc_icons-color'] = $the72_options['header-soc_icon_color'];
     $the72_options['header-elements-soc_icons-bg'] = $the72_options['header-soc_icon_bg_color_mode'];
     $the72_options['header-elements-soc_icons-bg-color'] = $the72_options['header-soc_icon_bg_color'];
     $the72_options['header-elements-soc_icons-bg-opacity'] = '100';
     $the72_options['header-elements-soc_icons-bg-gradient'] = $the72_options['header-soc_icon_bg_color_gradient'];
     $the72_options['header-elements-soc_icons-hover-color'] = $the72_options['header-soc_icon_hover_color'];
     $the72_options['header-elements-soc_icons-hover-bg'] = $the72_options['header-soc_icon_hover_bg_color_mode'];
     $the72_options['header-elements-soc_icons-hover-bg-color'] = $the72_options['header-soc_icon_hover_bg_color'];
     $the72_options['header-elements-soc_icons-bg-hover-opacity'] = '100';
     $the72_options['header-elements-soc_icons-hover-bg-gradient'] = $the72_options['header-soc_icon_hover_bg_color_gradient'];
     $the72_options['header-elements-soc_icons'] = array_reverse($the72_options['header-soc_icons']);
     // Menu.
     $the72_options['header-menu-font-family'] = $the72_options['menu-font_family'];
     $the72_options['header-menu-font-size'] = $the72_options['menu-font_size'];
     $the72_options['header-menu-font-is_capitalized'] = $the72_options['menu-font_uppercase'];
     $the72_options['header-menu-font-color'] = $the72_options['menu-font_color'];
     $the72_options['header-menu-hover-font-color-style'] = $the72_options['header-menu-active_item-font-color-style'] = $the72_options['menu-hover_font_color_mode'];
     $the72_options['header-menu-hover-font-color'] = $the72_options['header-menu-active_item-font-color'] = $the72_options['menu-hover_font_color'];
     $the72_options['header-menu-hover-font-gradient'] = $the72_options['header-menu-active_item-font-gradient'] = $the72_options['menu-hover_font_color_gradient'];
     $the72_options['header-menu-icon-size'] = $the72_options['menu-iconfont_size'];
     $the72_options['header-menu-show_next_lvl_icons'] = $the72_options['menu-next_level_indicator'];
     $the72_options['header-classic-height'] = $the72_options['header-inline-height'] = $the72_options['header-bg_height'];
     $the72_options['header-menu-show_dividers'] = '0';
     switch ($the72_options['menu-decoration_style']) {
         // Left to right.
         case 'underline':
             $the72_options['header-menu-decoration-style'] = 'underline';
             $the72_options['header-menu-decoration-underline-direction'] = 'left_to_right';
             $the72_options['header-menu-decoration-underline-color-style'] = $the72_options['menu-hover_decoration_color_mode'];
             $the72_options['header-menu-decoration-underline-color'] = $the72_options['menu-hover_decoration_color'];
             $the72_options['header-menu-decoration-underline-gradient'] = $the72_options['menu-hover_decoration_color_gradient'];
             $the72_options['header-menu-item-padding-top'] = $the72_options['header-menu-item-padding-bottom'] = '4';
             break;
             // From centre.
         // From centre.
         case 'brackets':
             $the72_options['header-menu-decoration-style'] = 'underline';
             $the72_options['header-menu-decoration-underline-direction'] = 'from_center';
             $the72_options['header-menu-decoration-underline-color-style'] = $the72_options['menu-hover_decoration_color_mode'];
             $the72_options['header-menu-decoration-underline-color'] = $the72_options['menu-hover_decoration_color'];
             $the72_options['header-menu-decoration-underline-gradient'] = $the72_options['menu-hover_decoration_color_gradient'];
             $the72_options['header-menu-item-padding-top'] = $the72_options['header-menu-item-padding-bottom'] = '4';
             break;
             // Upwards.
         // Upwards.
         case 'upwards':
             $the72_options['header-menu-decoration-style'] = 'underline';
             $the72_options['header-menu-decoration-underline-direction'] = 'upwards';
             $the72_options['header-menu-decoration-underline-color-style'] = $the72_options['menu-hover_decoration_color_mode'];
             $the72_options['header-menu-decoration-underline-color'] = $the72_options['menu-hover_decoration_color'];
             $the72_options['header-menu-decoration-underline-gradient'] = $the72_options['menu-hover_decoration_color_gradient'];
             $the72_options['header-menu-item-padding-top'] = $the72_options['header-menu-item-padding-bottom'] = '4';
             break;
             // Downwards.
         // Downwards.
         case 'downwards':
             $the72_options['header-menu-decoration-style'] = 'underline';
             $the72_options['header-menu-decoration-underline-direction'] = 'downwards';
             $the72_options['header-menu-decoration-underline-color-style'] = $the72_options['menu-hover_decoration_color_mode'];
             $the72_options['header-menu-decoration-underline-color'] = $the72_options['menu-hover_decoration_color'];
             $the72_options['header-menu-decoration-underline-gradient'] = $the72_options['menu-hover_decoration_color_gradient'];
             $the72_options['header-menu-item-padding-top'] = $the72_options['header-menu-item-padding-bottom'] = '4';
             break;
             // Background & outline.
         // Background & outline.
         case 'background':
             $the72_options['header-menu-decoration-style'] = 'other';
             $the72_options['header-menu-decoration-other-hover-style'] = 'outline';
             $the72_options['header-menu-decoration-other-click_decor'] = '0';
             $the72_options['header-menu-decoration-other-active-style'] = 'background';
             $the72_options['header-menu-item-padding-top'] = '7';
             $the72_options['header-menu-item-padding-right'] = '11';
             $the72_options['header-menu-item-padding-bottom'] = '8';
             $the72_options['header-menu-item-padding-left'] = '11';
             $the72_options['header-menu-decoration-other-hover-line'] = $the72_options['header-menu-decoration-other-active-line'] = '0';
             $the72_options['header-menu-decoration-other-opacity'] = $the72_options['header-menu-decoration-other-active-opacity'] = '100';
             // Hover font and hover/active decoration colors.
             $the72_options['header-menu-hover-font-color-style'] = $the72_options['header-menu-decoration-other-hover-color-style'] = $the72_options['header-menu-decoration-other-active-color-style'] = $the72_options['menu-hover_decoration_color_mode'];
             $the72_options['header-menu-hover-font-color'] = $the72_options['header-menu-decoration-other-hover-color'] = $the72_options['header-menu-decoration-other-active-color'] = $the72_options['menu-hover_decoration_color'];
             $the72_options['header-menu-hover-font-gradient'] = $the72_options['header-menu-decoration-other-hover-gradient'] = $the72_options['header-menu-decoration-other-active-gradient'] = $the72_options['menu-hover_decoration_color_gradient'];
             break;
             // Material background.
         // Material background.
         case 'material':
             $the72_options['header-menu-decoration-style'] = 'other';
             $the72_options['header-menu-decoration-other-hover-style'] = 'background';
             $the72_options['header-menu-decoration-other-click_decor'] = '1';
             $the72_options['header-menu-decoration-other-active-style'] = 'background';
             $the72_options['header-menu-item-padding-top'] = '7';
             $the72_options['header-menu-item-padding-right'] = '11';
             $the72_options['header-menu-item-padding-bottom'] = '8';
             $the72_options['header-menu-item-padding-left'] = '11';
             $the72_options['header-menu-decoration-other-hover-line'] = $the72_options['header-menu-decoration-other-active-line'] = '0';
             $the72_options['header-menu-decoration-other-active-opacity'] = '100';
             // Hover font and hover/active decoration colors.
             $the72_options['header-menu-decoration-other-click_decor-color-style'] = $the72_options['header-menu-hover-font-color-style'] = $the72_options['header-menu-decoration-other-hover-color-style'] = $the72_options['header-menu-decoration-other-active-color-style'] = $the72_options['menu-hover_decoration_color_mode'];
             $the72_options['header-menu-decoration-other-click_decor-color'] = $the72_options['header-menu-hover-font-color'] = $the72_options['header-menu-decoration-other-hover-color'] = $the72_options['header-menu-decoration-other-active-color'] = $the72_options['menu-hover_decoration_color'];
             $the72_options['header-menu-decoration-other-click_decor-gradient'] = $the72_options['header-menu-hover-font-gradient'] = $the72_options['header-menu-decoration-other-hover-gradient'] = $the72_options['header-menu-decoration-other-active-gradient'] = $the72_options['menu-hover_decoration_color_gradient'];
             break;
             // Material underline.
         // Material underline.
         case 'material_underline':
             $the72_options['header-menu-decoration-style'] = 'other';
             $the72_options['header-menu-decoration-other-hover-style'] = 'background';
             $the72_options['header-menu-decoration-other-click_decor'] = '1';
             $the72_options['header-menu-decoration-other-active-style'] = 'background';
             if ('left' == $header_layout) {
                 $the72_options['header-menu-item-padding-top'] = '0';
                 $the72_options['header-menu-item-padding-right'] = '0';
                 $the72_options['header-menu-item-padding-bottom'] = '0';
                 $the72_options['header-menu-item-padding-left'] = '0';
                 $the72_options['header-menu-item-margin-top'] = '0';
                 $the72_options['header-menu-item-margin-right'] = '0';
                 $the72_options['header-menu-item-margin-bottom'] = '0';
                 $the72_options['header-menu-item-margin-left'] = '0';
             } else {
                 $the72_options['header-menu-item-padding-top'] = $the72_options['header-menu-item-padding-bottom'] = ceil(intval($the72_options['header-bg_height'] - $the72_options['header-menu-font-size']) / 2);
                 $the72_options['header-menu-item-padding-right'] = '9';
                 $the72_options['header-menu-item-padding-left'] = '9';
                 $the72_options['header-menu-item-margin-top'] = '0';
                 $the72_options['header-menu-item-margin-bottom'] = '0';
             }
             $the72_options['header-menu-decoration-other-hover-line'] = $the72_options['header-menu-decoration-other-active-line'] = '1';
             $the72_options['header-menu-decoration-other-active-opacity'] = '0';
             $the72_options['header-menu-decoration-other-opacity'] = '0';
             $the72_options['header-menu-decoration-other-border-radius'] = '0';
             $the72_options['header-menu-decoration-other-links-is_justified'] = '1';
             $the72_options['header-menu-decoration-other-active-line-opacity'] = '100';
             $the72_options['header-menu-decoration-other-hover-line-opacity'] = '100';
             // Hover font and hover/active decoration colors.
             $the72_options['header-menu-decoration-other-hover-line-color-style'] = $the72_options['header-menu-decoration-other-active-line-color-style'] = $the72_options['header-menu-decoration-other-click_decor-color-style'] = $the72_options['header-menu-decoration-other-hover-color-style'] = $the72_options['header-menu-decoration-other-active-color-style'] = $the72_options['menu-hover_decoration_color_mode'];
             $the72_options['header-menu-decoration-other-hover-line-color'] = $the72_options['header-menu-decoration-other-active-line-color'] = $the72_options['header-menu-decoration-other-click_decor-color'] = $the72_options['header-menu-decoration-other-hover-color'] = $the72_options['header-menu-decoration-other-active-color'] = $the72_options['menu-hover_decoration_color'];
             $the72_options['header-menu-decoration-other-hover-line-gradient'] = $the72_options['header-menu-decoration-other-active-line-gradient'] = $the72_options['header-menu-decoration-other-click_decor-gradient'] = $the72_options['header-menu-decoration-other-hover-gradient'] = $the72_options['header-menu-decoration-other-active-gradient'] = $the72_options['menu-hover_decoration_color_gradient'];
             break;
             // Disabled.
         // Disabled.
         default:
             $the72_options['header-menu-decoration-style'] = 'none';
     }
     if ('side' == $header_layout) {
         $the72_options['header-menu-item-padding-top'] = $the72_options['header-menu-item-margin-bottom'] = intval(round(intval($the72_options['menu-items_distance']) / 2));
     } else {
         $the72_options['header-menu-item-margin-right'] = $the72_options['header-menu-item-margin-left'] = intval(round(intval($the72_options['menu-items_distance']) / 2));
         if ('material_underline' != $the72_options['menu-decoration_style']) {
             $the72_options['header-menu-item-margin-top'] = $the72_options['header-menu-item-margin-bottom'] = intval(round(intval($the72_options['header-bg_height'] - $the72_options['header-menu-font-size']) / 2));
         }
     }
     // Submenu.
     $the72_options['header-menu-submenu-font-family'] = $the72_options['header-menu-submenu-subtitle-font-family'] = $the72_options['submenu-font_family'];
     $the72_options['header-menu-submenu-font-size'] = $the72_options['submenu-font_size'];
     $the72_options['header-menu-submenu-font-is_uppercase'] = $the72_options['submenu-font_uppercase'];
     $the72_options['header-menu-submenu-font-color'] = $the72_options['submenu-font_color'];
     $the72_options['header-menu-submenu-show_next_lvl_icons'] = $the72_options['submenu-next_level_indicator'];
     $the72_options['header-menu-submenu-active-font-color-style'] = $the72_options['header-menu-submenu-hover-font-color-style'] = $the72_options['submenu-hover_font_color_mode'];
     $the72_options['header-menu-submenu-active-font-color'] = $the72_options['header-menu-submenu-hover-font-color'] = $the72_options['submenu-hover_font_color'];
     $the72_options['header-menu-submenu-active-font-gradient'] = $the72_options['header-menu-submenu-hover-font-gradient'] = $the72_options['submenu-hover_font_color_gradient'];
     $the72_options['header-menu-submenu-icon-size'] = $the72_options['submenu-iconfont_size'];
     $the72_options['header-menu-submenu-item-margin-top'] = '0';
     $the72_options['header-menu-submenu-item-margin-right'] = '0';
     $the72_options['header-menu-submenu-item-margin-bottom'] = '0';
     $the72_options['header-menu-submenu-item-margin-left'] = '0';
     $the72_options['header-menu-submenu-item-padding-left'] = '10';
     $the72_options['header-menu-submenu-item-padding-right'] = '30';
     $the72_options['header-menu-submenu-item-padding-top'] = $the72_options['header-menu-submenu-item-padding-bottom'] = intval(round(intval($the72_options['submenu-items_distance']) / 2));
     $the72_options['header-menu-submenu-bg-color'] = $the72_options['submenu-bg_color'];
     $the72_options['header-menu-submenu-bg-opacity'] = $the72_options['submenu-bg_opacity'];
     $the72_options['header-menu-submenu-bg-width'] = $the72_options['submenu-bg_width'];
     $the72_options['header-menu-submenu-parent_is_clickable'] = $the72_options['submenu-parent_clickable'];
     // Floating navigation.
     $the72_options['header-show_floating_navigation'] = $the72_options['header-show_floating_menu'];
     $the72_options['header-floating_navigation-height'] = $the72_options['float_menu-height'];
     if ('header_color' == $the72_options['float_menu-bg_color_mode']) {
         $the72_options['header-floating_navigation-bg-color'] = $the72_options['header-bg_color'];
     } else {
         $the72_options['header-floating_navigation-bg-color'] = $the72_options['float_menu-bg_color'];
     }
     $the72_options['header-floating_navigation-bg-opacity'] = $the72_options['float_menu-transparency'];
     $the72_options['header-floating_navigation-style'] = $the72_options['header-floating_menu_animation'];
     $the72_options['header-floating_navigation-decoration'] = 'shadow';
     // Mobile header.
     if ('accent' == $the72_options['header-mobile-menu_color']) {
         $the72_options['header-mobile-menu-font-color'] = $the72_options['submenu-font_color'];
         $the72_options['header-mobile-menu-bg-color'] = $the72_options['submenu-bg_color'];
     } else {
         $the72_options['header-mobile-menu-font-color'] = $the72_options['header-mobile-menu_color-text'];
         $the72_options['header-mobile-menu-bg-color'] = $the72_options['header-mobile-menu_color-background'];
     }
     $the72_options['header-mobile-menu-font-hover-color-style'] = $the72_options['submenu-hover_font_color_mode'];
     $the72_options['header-mobile-menu-font-hover-color'] = $the72_options['submenu-hover_font_color'];
     $the72_options['header-mobile-menu-font-hover-gradient'] = $the72_options['submenu-hover_font_color_gradient'];
     $the72_options['header-mobile-menu-font-family'] = $the72_options['menu-font_family'];
     $the72_options['header-mobile-menu-font-size'] = $the72_options['menu-font_size'];
     $the72_options['header-mobile-menu-font-is_capitalized'] = $the72_options['menu-font_uppercase'];
     $the72_options['header-mobile-submenu-font-family'] = $the72_options['submenu-font_family'];
     $the72_options['header-mobile-submenu-font-size'] = $the72_options['submenu-font_size'];
     $the72_options['header-mobile-submenu-font-is_capitalized'] = $the72_options['submenu-font_uppercase'];
     $the72_options['header-mobile-menu-bg-opacity'] = '100';
     $the72_options['header-mobile-floating_navigation'] = 'disabled';
     // Branding.
     // Main.
     $the72_options['header-logo_regular'] = $the72_options['header-logo_regular'];
     $the72_options['header-logo_hd'] = $the72_options['header-logo_hd'];
     $the72_options['header-logo-padding-top'] = $the72_options['header-logo_padding_top'];
     $the72_options['header-logo-padding-bottom'] = $the72_options['header-logo_padding_bottom'];
     $the72_options['header-logo-padding-right'] = '0';
     $the72_options['header-logo-padding-left'] = '0';
     // Transparent.
     $the72_options['header-style-transparent-logo_regular'] = $the72_options['header-logo_regular'];
     $the72_options['header-style-transparent-logo_hd'] = $the72_options['header-logo_hd'];
     $the72_options['header-style-transparent-logo-padding-top'] = $the72_options['header-logo_padding_top'];
     $the72_options['header-style-transparent-logo-padding-bottom'] = $the72_options['header-logo_padding_bottom'];
     $the72_options['header-style-transparent-logo-padding-right'] = '0';
     $the72_options['header-style-transparent-logo-padding-left'] = '0';
     // Menu icon.
     $the72_options['header-style-mixed-logo_regular'] = array('', 0);
     $the72_options['header-style-mixed-logo_hd'] = array('', 0);
     $the72_options['header-style-mixed-logo-padding-top'] = $the72_options['header-logo_padding_top'];
     $the72_options['header-style-mixed-logo-padding-bottom'] = $the72_options['header-logo_padding_bottom'];
     $the72_options['header-style-mixed-logo-padding-right'] = '0';
     $the72_options['header-style-mixed-logo-padding-left'] = '0';
     // Floating navigation.
     $the72_options['header-style-floating-choose_logo'] = '1' == $the72_options['general-floating_menu_show_logo'] ? 'custom' : 'none';
     $the72_options['header-style-floating-logo_regular'] = $the72_options['general-floating_menu_logo_regular'];
     $the72_options['header-style-floating-logo_hd'] = $the72_options['general-floating_menu_logo_hd'];
     $the72_options['header-style-floating-logo-padding-top'] = '0';
     $the72_options['header-style-floating-logo-padding-bottom'] = '0';
     $the72_options['header-style-floating-logo-padding-right'] = '0';
     $the72_options['header-style-floating-logo-padding-left'] = '0';
     // Mobile logo.
     $the72_options['header-mobile-first_switch-logo'] = $the72_options['header-mobile-first_switch-logo'];
     $the72_options['header-mobile-second_switch-logo'] = $the72_options['header-mobile-second_switch-logo'];
     $the72_options['header-style-mobile-logo_regular'] = $the72_options['general-mobile_logo-regular'];
     $the72_options['header-style-mobile-logo_hd'] = $the72_options['general-mobile_logo-hd'];
     $the72_options['header-style-mobile-logo-padding-top'] = $the72_options['general-mobile_logo-padding_top'];
     $the72_options['header-style-mobile-logo-padding-bottom'] = $the72_options['general-mobile_logo-padding_bottom'];
     $the72_options['header-style-mobile-logo-padding-right'] = '0';
     $the72_options['header-style-mobile-logo-padding-left'] = '0';
     // Bottom logo.
     $the72_options['bottom_bar-logo-padding-top'] = '10';
     $the72_options['bottom_bar-logo-padding-bottom'] = '10';
     $the72_options['bottom_bar-logo-padding-right'] = '10';
     $the72_options['bottom_bar-logo-padding-left'] = '0';
     // Content boxes.
     if ('solid' == $the72_options['general-content_boxes_bg_mode']) {
         $the72_options['general-content_boxes_bg_color'] = $the72_options['general-content_boxes_solid_bg_color'];
         $the72_options['general-content_boxes_bg_opacity'] = '100';
     } else {
         $the72_options['general-content_boxes_bg_color'] = '#888888';
         $the72_options['general-content_boxes_bg_opacity'] = '8';
     }
     $the72_options['general-content_boxes_decoration'] = 'none';
     // Stripes.
     for ($i = 1; $i <= 3; $i++) {
         $the72_options["stripes-stripe_{$i}_outline"] = 'hide';
         $the72_options["stripes-stripe_{$i}_content_boxes_decoration"] = 'none';
         if ('solid' == $the72_options["stripes-stripe_{$i}_content_boxes_bg_mode"]) {
             $the72_options["stripes-stripe_{$i}_content_boxes_bg_color"] = $the72_options["stripes-stripe_{$i}_content_boxes_solid_bg_color"];
             $the72_options["stripes-stripe_{$i}_content_boxes_bg_opacity"] = '100';
         } else {
             $the72_options["stripes-stripe_{$i}_content_boxes_bg_color"] = '#888888';
             $the72_options["stripes-stripe_{$i}_content_boxes_bg_opacity"] = '8';
         }
     }
     // Bottom bar.
     $the72_options['footer-padding-top'] = $the72_options['footer-paddings-top-bottom'];
     $the72_options['footer-padding-bottom'] = '10';
     switch ($the72_options['footer-style']) {
         case 'content_width_line':
         case 'full_width_line':
             $the72_options['footer-bg_color'] = $the72_options['footer-primary_text_color'];
             $the72_options['footer-bg_opacity'] = '15';
             break;
         case 'transparent_bg_line':
             $the72_options['footer-bg_color'] = $the72_options['footer-primary_text_color'];
             $the72_options['footer-bg_opacity'] = '8';
             $the72_options['footer-style'] = 'solid_background';
             $the72_options['footer-decoration'] = 'none';
             break;
         case 'solid_background':
             $the72_options['footer-bg_opacity'] = '100';
             break;
     }
     switch ($the72_options['bottom_bar-style']) {
         case 'content_width_line':
         case 'full_width_line':
             $the72_options['bottom_bar-bg_color'] = $the72_options['footer-primary_text_color'];
             $the72_options['bottom_bar-bg_opacity'] = '15';
             break;
         case 'solid_background':
             $the72_options['bottom_bar-bg_opacity'] = '100';
             break;
     }
     // Page title.
     $the72_options['page_title-padding-top'] = $the72_options['page_title-padding-bottom'] = '0';
     $the72_options['general-title_decoration'] = 'none';
     switch ($the72_options['general-title_bg_mode']) {
         case 'transparent_bg':
             $the72_options['general-title_bg_mode'] = 'background';
             $the72_options['header-background'] = 'normal';
             $the72_options['general-title_bg_color'] = $the72_options['content-primary_text_color'];
             $the72_options['general-title_bg_opacity'] = '8';
             $the72_options['general-title_bg_parallax'] = '';
             $the72_options['general-title_bg_image'] = array('image' => '', 'repeat' => 'repeat', 'position_x' => 'center', 'position_y' => 'center');
             break;
         case 'gradient':
         case 'background':
             $the72_options['general-title_bg_opacity'] = '100';
             if ('transparent' == $the72_options['header-background'] && 'disabled' == $the72_options['header-style']) {
                 $the72_options['header-transparent_bg_opacity'] = '0';
             }
             break;
     }
     if (in_array($the72_options['header-menu_top_bar_color_mode'], array('theme', 'dark'))) {
         $the72_options['page_title-background-style-transparent-color_scheme'] = 'from_options';
     }
     // Buttons.
     $the72_options['buttons-hover_color_mode'] = $the72_options['buttons-color_mode'];
     $the72_options['buttons-hover_color'] = $the72_options['buttons-color'];
     $the72_options['buttons-hover_color_gradient'] = $the72_options['buttons-color_gradient'];
     $the72_options['buttons-text_hover_color_mode'] = $preset_options['buttons-text_color_mode'];
     $the72_options['buttons-text_hover_color'] = $preset_options['buttons-text_color'];
     // Image hovers.
     $the72_options['image_hover-project_rollover_color_mode'] = $the72_options['image_hover-color_mode'];
     $the72_options['image_hover-project_rollover_color'] = $the72_options['image_hover-color'];
     $the72_options['image_hover-project_rollover_color_gradient'] = $the72_options['image_hover-color_gradient'];
     $the72_options['image_hover-project_rollover_opacity'] = $the72_options['image_hover-opacity'];
     $the72_options['image_hover-default_icon'] = 'none' == $the72_options['image_hover-default_icon'] ? 'none' : 'big_center';
     switch ($the72_options['general-style']) {
         case 'ios7':
             $the72_options['general-filter_style'] = $the72_options['general-contact_form_style'] = 'ios';
             break;
         case 'minimalistic':
             $the72_options['image_hover-project_icons_style'] = 'transparent';
             $the72_options['image_hover-album_miniatures_style'] = 'style_1';
             $the72_options['general-filter_style'] = $the72_options['general-contact_form_style'] = 'minimal';
             break;
         case 'material':
             $the72_options['image_hover-project_icons_style'] = 'small';
             $the72_options['image_hover-album_miniatures_style'] = 'style_2';
             $the72_options['general-filter_style'] = $the72_options['general-contact_form_style'] = 'material';
             break;
     }
     // Filted style.
     $the72_options['general-filter-font-family'] = $the72_options['fonts-font_family'];
     $the72_options['general-filter_ucase'] = '0';
     $the72_options['general-filter-padding-top'] = '8';
     $the72_options['general-filter-padding-right'] = '13';
     $the72_options['general-filter-padding-bottom'] = '8';
     $the72_options['general-filter-padding-left'] = '13';
     $the72_options['general-filter-margin-top'] = '0';
     $the72_options['general-filter-margin-right'] = '5';
     $the72_options['general-filter-margin-bottom'] = '0';
     $the72_options['general-filter-margin-left'] = '0';
     // Beautiful loading.
     if ('accent' == $the72_options['general-beautiful_loading']) {
         $the72_options['general-fullscreen_overlay_color_mode'] = 'accent';
         $the72_options['general-spinner_color'] = '#ffffff';
     }
     $the72_options['general-beautiful_loading'] = 'disabled' == $the72_options['general-beautiful_loading'] ? 'disabled' : 'enabled';
     // Sidebar.
     $the72_options['sidebar-bg_opacity'] = '100';
     $merged_options = array_merge($preset_options, $the72_options);
     // Validate options.
     $options_fields =& _optionsframework_options();
     foreach ($options_fields as $option_field) {
         if (isset($option_field['id']) && !array_key_exists($option_field['id'], $merged_options)) {
             unset($merged_options[$option_field['id']]);
         }
     }
     return apply_filters('presscore_compatibility_import_theme_options', $merged_options);
 }
コード例 #9
0
/**
 * Return array with actual theme options.
 * 
 * @return mixed
 */
function _optionsframework_get_clean_options()
{
    if (false === ($clean_options = get_transient('optionsframework_clean_options'))) {
        $options =& _optionsframework_options();
        $clean_options = array();
        foreach ($options as $option) {
            if (isset($option['id'], $option['type'])) {
                $clean_options[$option['id']] = $option;
            }
        }
        set_transient('optionsframework_clean_options', $clean_options, 60);
    }
    return $clean_options;
}