Exemplo n.º 1
0
function circleflip_of_sanitize_font_size($value)
{
    $recognized = circleflip_of_recognized_font_sizes();
    $value_check = preg_replace('/px/', '', $value);
    if (in_array((int) $value_check, $recognized)) {
        return $value;
    }
    return apply_filters('circleflip_of_default_font_size', $recognized);
}
Exemplo n.º 2
0
function circleflip_optionsframework_option_interface_indented($value, $option_name, $parent = '', $val, $children_type, $counter)
{
    global $allowedtags;
    $value_class = isset($value['class']) ? $value['class'] : '';
    $value_placeholder = isset($value['placeholder']) ? $value['placeholder'] : '';
    $value_wrappertype = isset($value['wrapper_type']) ? $value['wrapper_type'] : '';
    $value_children = isset($value['children']) ? $value['children'] : '';
    $output = '';
    $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']) . '" placeholder="' . esc_attr($value_placeholder) . '" class="of-input ' . $value_class . '" name="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr(isset($val[$counter][$value['id']]) ? $val[$counter][$value['id']] : '') . '" />
            			<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>';
            break;
        case 'empty':
            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) . '" />
            <label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>
            ';
            break;
            // Textarea
        // Textarea
        case 'textarea':
            $output .= '<div class="option_container">';
            $rows = '8';
            if (isset($value['settings']['rows'])) {
                $custom_rows = $value['settings']['rows'];
                if (is_numeric($custom_rows)) {
                    $rows = $custom_rows;
                }
            }
            $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . esc_textarea($val) . '</textarea>
                <label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>
                </div>';
            break;
            // Select Box
        // Select Box
        case 'select':
            $output .= '<select class="of-input ' . $value_class . '" name="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">';
            foreach ($value['options'] as $key => $option) {
                $selected = '';
                if ($val != '') {
                    if (isset($val[$counter][$value['id']]) && $val[$counter][$value['id']] == $key) {
                        $selected = ' selected="selected"';
                    }
                }
                $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>';
            }
            $output .= '</select>
                <label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>';
            break;
            // encoding input
        // encoding input
        case 'hiddenInput':
            $output .= '<input type="hidden" id="' . esc_attr($value['id']) . '" name="' . esc_attr($option_name . '[' . $value['hidden_name'] . ']') . '" value="" />';
            break;
            // Radio Box
        // Radio Box
        case "radio":
            $name = esc_attr($option_name . '[' . $children_type . '][' . $counter . '][' . $value['id'] . ']');
            //;
            $output .= '<ul class="radioButtonWrapper">';
            foreach ($value['options'] as $key => $option) {
                $checked = isset($val[$counter][$value['id']]) ? checked($val[$counter][$value['id']], $key, false) : '';
                $id = $option_name . '-' . $value['id'] . '-' . $key;
                $output .= '<li><label><input class="of-input of-radio ' . $value_class . '" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . $checked . ' />' . esc_html($option) . '</label></li>';
            }
            $output .= '</ul>
            <label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>';
            break;
            // Image Selectors
        // Image Selectors
        case "images":
            $class = isset($value['class']) ? $value['class'] : '';
            $output .= '<div class="option_container"><ul class="' . $class . '">';
            $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 .= '<li><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;" /></li>';
            }
            $output .= '</ul>
                <label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>
                </div>';
            break;
            // Checkbox
        // Checkbox
        case "checkbox":
            $output .= '<div class="option_container">';
            $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></div>';
            break;
            // Multicheck
        // Multicheck
        case "multicheck":
            $output .= '<div class="option_container">';
            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>';
            }
            $output .= '</div>';
            break;
            // Color picker
        // Color picker
        case "color":
            $output .= '<div class="option_container">';
            $default_color = '';
            if (isset($value['std'])) {
                if ($val != $value['std']) {
                    $default_color = ' data-default-color="' . $value['std'] . '" ';
                }
            }
            $output .= '<input name="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" class="of-color"  type="text" value="' . esc_attr(isset($val[$counter][$value['id']]) ? $val[$counter][$value['id']] : '') . '"' . $default_color . ' />
                <label class="explain" for="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $value['id'] . ']') . '">' . wp_kses($explain_value, $allowedtags) . '</label>
                </div>';
            break;
        case "selectmultiple":
            $output .= '<div class="option_container">';
            $output .= '<select name="' . esc_attr($option_name . '[' . $value['id'] . '][]') . '" id="' . esc_attr($value['id']) . '" multiple>';
            foreach ($value['options'] as $key => $option) {
                $selected = '';
                if (isset($val) && is_array($val)) {
                    if (in_array($key, $val)) {
                        $selected = 'selected = "selected"';
                    }
                }
                $output .= '<option value="' . $key . '"' . $selected . '>' . $option . '</option>';
            }
            $output .= '</select>
				<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>';
            $output .= '</div>';
            break;
            // Uploader
        // Uploader
        case "upload":
            $valid_val = isset($val[$counter][$value['id']]) ? $val[$counter][$value['id']] : '';
            $name = $option_name . '[' . $children_type . '][' . $counter . '][' . $value['id'] . ']';
            $output .= circleflip_optionsframework_uploader($value['id'], $valid_val, null, $name);
            $output .= '<label class="explain ' . $value_class . '" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>';
            break;
            // Button
        // Button
        case "button":
            $output .= '<button id="' . $value['id'] . '" class="' . $value_class . ' button" type="button">' . $value['text'] . '</button>';
            $output .= isset($value['desc']) ? $value['desc'] : '';
            break;
            // Button
        // Button
        case "builder_button":
            $output .= '<button id="' . $value['id'] . '" class="' . $value_class . ' button" type="button">' . $value['text'] . '</button>';
            break;
            // Typography
        // Typography
        case 'typography':
            unset($font_size, $font_style, $font_face, $font_color, $font_weight);
            $typography_defaults = array('size' => '', 'face' => '', 'style' => '', 'weight' => '', 'color' => '');
            $typography_stored = wp_parse_args(isset($val[$counter][$value['id']]) ? $val[$counter][$value['id']] : '', $typography_defaults);
            $typography_options = array('sizes' => circleflip_of_recognized_font_sizes(), 'faces' => circleflip_of_recognized_font_faces(), 'styles' => circleflip_of_recognized_font_styles(), 'weights' => circleflip_of_recognized_font_weights(), '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 ' . $value_class . '" name="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $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 ' . $value_class . '" name="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $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 ' . $value_class . '" name="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $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 Weights
            if ($typography_options['weights']) {
                $font_weight = '<select class="of-typography of-typography-weight ' . $value_class . '" name="' . esc_attr($option_name . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $value['id'] . '][weight]') . '" id="' . $value['id'] . '_weight">';
                $weights = $typography_options['weights'];
                foreach ($weights as $key => $weight) {
                    $font_weight .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['weight'], $key, false) . '>' . $weight . '</option>';
                }
                $font_weight .= '</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 . '[' . $children_type . ']' . '[' . $counter . ']' . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id']) . '" class="of-color of-typography-color ' . $value_class . '"  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', 'font_weight');
            $typography_fields = apply_filters('circleflip_of_typography_fields', $typography_fields, $typography_stored, $option_name, $value);
            $output .= implode('', $typography_fields);
            break;
    }
    return $output;
}