/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); $counter = 0; $menu = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; $output = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "infotext" && $value['type'] != "info" && $value['type'] != "adstwofifty" && $value['type'] != "innertabopen" && $value['type'] != "innertabclose" && $value['type'] != "tabheading" && $value['type'] != "groupcontaineropen" && $value['type'] != "groupcontainerclose") { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['type'] != 'editor') { $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } else { $output .= '<div class="option">' . "\n" . '<div>' . "\n"; } } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != "heading" && $value['type'] != "infotext" && $value['type'] != "info" && $value['type'] != "adstwofifty" && $value['type'] != "innertabopen" && $value['type'] != "innertabclose" && $value['type'] != "tabheading" && $value['type'] != "groupcontaineropen" && $value['type'] != "groupcontainerclose") { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Upgrade to PRO // Upgrade to PRO case 'proupgrade': $output .= '<p class="proupgradep">Available in PRO. Upgrade now.</p>'; break; // Textarea // Textarea case 'textarea': $rows = '8'; if (isset($value['settings']['rows'])) { $custom_rows = $value['settings']['rows']; if (is_numeric($custom_rows)) { $rows = $custom_rows; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . esc_textarea($val) . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Image Selectors // Image Selectors case "proimages": foreach ($value['options'] as $key => $option) { $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img-pro" />'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); break; // Typography // Typography case 'typography': $typography_stored = $val; // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; // Font Style $styles = of_recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Editor // Editor case 'editor': $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; echo $output; $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']'); $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress')); $editor_settings = array(); if (isset($value['settings'])) { $editor_settings = $value['settings']; } $editor_settings = array_merge($editor_settings, $default_editor_settings); wp_editor($val, $value['id'], $editor_settings); $output = ''; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['desc']) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '</div>' . "\n"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; break; // testing // testing case "tabheading": $output .= '<div class="tabheading"><p class="tabheadingp">' . esc_html($value['name']) . '</p></div>'; break; case "infotext": $output .= '<div class="themenotice"><p>' . esc_html($value['desc']) . '</p></div>'; break; case "innertabopen": $output .= '<div id="' . esc_html($value['name']) . '" class="tabcontent">'; break; case "innertabclose": $output .= '</div>'; break; case "groupcontaineropen": $output .= '<div class="groupcontainer"><div class="groupcontainertitle"><p class="groupcontainertitlep">' . esc_html($value['name']) . '</p></div>'; break; case "groupcontainerclose": $output .= '</div>'; break; } if ($value['type'] != "heading" && $value['type'] != "infotext" && $value['type'] != "info" && $value['type'] != "adstwofifty" && $value['type'] != "innertabopen" && $value['type'] != "innertabclose" && $value['type'] != "tabheading" && $value['type'] != "groupcontaineropen" && $value['type'] != "groupcontainerclose") { $output .= '</div>'; if ($value['type'] != "checkbox" && $value['type'] != "editor") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '</div></div>' . "\n"; } echo $output; } echo '</div>'; }
/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info") { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/\\W/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; $output .= '<h3 class="heading"> ' . esc_html($value['name']) . '</h3>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Textarea // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label><br />'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/\\W/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label><br />'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); // New AJAX Uploader using Media Library break; // Typography // Typography case 'typography': $typography_stored = $val; // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic'); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; break; // Typography Without Font Face // Typography Without Font Face case 'typography2': $typography2_stored = $val; // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography2_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic'); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography2_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography2_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography2_stored['color']) . '" />'; break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h3 class="heading">' . esc_html($value['name']) . '</h3>' . "\n"; } if ($value['desc']) { $output .= '<p>' . wp_kses($value['desc'], $allowedtags) . '</p>' . "\n"; } $output .= '<div class="clear"></div></div>' . "\n"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/\\W/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<li><a id="' . esc_attr($jquery_click_hook) . '-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '"><img src="' . get_template_directory_uri() . '/admin/images/' . esc_html($value['sicon']) . '" width="16" height="16" border="0" align="left"> ' . esc_html($value['name']) . '</a></li>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '"><h2>' . esc_html($value['name']) . '</h2>' . "\n"; break; } if ($value['type'] != "heading" && $value['type'] != "info") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } $output .= '</div><div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; $output .= '<div class="clear"></div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
function fields() { global $allowedtags; $option_name = $this->id; $settings = $this->data; $options = $this->options; $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ($value['type'] != "heading" && ($value['type'] != "info" && $value['type'] != "subsection" && $value['type'] != "subsection_end") && $value['type'] != "open_outersection" && $value['type'] != "close_outersection") { // Keep all ids lowercase with no spaces $value['id'] = isset($value['id']) ? preg_replace('/\\W/', '', strtolower($value['id'])) : ""; $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; $output .= '<h3 class="heading">' . esc_html($value['name']) . '</h3>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } // Set default value to $val if (isset($value['default'])) { $val = $value['default']; } // If the option is already saved, ovveride $val if ($value['type'] != "heading" && ($value['type'] != "info" && $value['type'] != "subsection" && $value['type'] != "subsection_end") && $value['type'] != "open_outersection" && $value['type'] != "close_outersection") { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Textarea // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>'; break; // Select Box // Select Box case 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label><br />'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/\\W/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label><br />'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": // $output .= optionsframework_medialibrary_uploader( $value['id'], $val, null ); // New AJAX Uploader using Media Library if (isset($val['url'])) { $output .= "Preview:<br /> " . "<img class='upload' src='{$val['url']}'/><br/>"; } $output .= " URL <input type='text' name='{$value['id']}_text' size='72' value='" . (isset($val['url']) ? $val['url'] : "") . "'/>"; $output .= " or upload File: <input type='file' id='{$value['id']}' name='{$value['id']}'>"; break; // Typography // Typography case 'typography': $typography_stored = $val; // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = ClassyOptionsSanitize::recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; /* Font Style */ $styles = ClassyOptionsSanitize::recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h3 class="heading">' . $value['name'] . '</h3>' . "\n"; } if (isset($value['desc'])) { $output .= wpautop(wp_kses($value['desc'], $allowedtags)) . "\n"; } $output .= '<div class="clear"></div></div>' . "\n"; break; case "export": $output .= "<textarea rows='10'>" . esc_html(serialize($settings)) . "</textarea>"; break; case "import": $output .= "<textarea name='import' rows='10'></textarea>"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/\\W/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<li>'; $icon = isset($value['icon']) ? " style=\"background-image: url({$value['icon']}); background-position: 8px center; background-repeat: no-repeat; \"" : ""; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '"' . $icon . '>' . esc_html($value['name']) . ' <span></span></a></li>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '"><h2>' . esc_html($value['name']) . '</h2>' . "\n"; break; case "subsection": $id = strtolower(preg_replace("/\\W/", "", $value['name'])); $output .= "<div class='subsection' id='subsection-{$id}'><h3>{$value['name']}<span class='plus'>" . "</span></h3><div class='subsection-items'>"; break; case "subsection_end": $output .= "</div></div>"; break; case "open_outersection": $output .= "<div class='outersection'>"; break; case "close_outersection": $output .= "</div>"; break; case "section_order": $root = get_template_directory_uri(); $values = explode(",", $val); $output .= "<div class='section_order' id=" . esc_attr($value['id']) . ">"; $output .= "<div class='left_list'>"; $output .= "<div class='inactive'>Inactive Elements</div>"; $output .= "<div class='list_items'>"; foreach ($value['options'] as $k => $v) { if (in_array($k, $values)) { continue; } $output .= "<div class='list_item'>"; $output .= "<img src='{$root}/images/minus.png' class='action' title='Remove'/>"; $output .= "<span data-key='{$k}'>{$v}</span>"; $output .= "</div>"; } $output .= "</div>"; $output .= "</div>"; $output .= "<div class='arrow'><img src='{$root}/images/arrowdrag.png' /></div>"; $output .= "<div class='right_list'>"; $output .= "<div class='active'>Active Elements</div>"; $output .= "<div class='drag'>Drag & Drop Elements</div>"; $output .= "<div class='list_items'>"; foreach ($values as $k) { if (!$k) { continue; } $val = $value['options'][$k]; $output .= "<div class='list_item'>"; $output .= "<img src='{$root}/images/minus.png' class='action' title='Remove'/>"; $output .= "<span data-key='{$k}'>{$val}</span>"; $output .= "</div>"; } $output .= "</div>"; $output .= "</div>"; $output .= "<input type='hidden' id='{$value['id']}' name='{$option_name}[{$value['id']}]' />"; $output .= "</div>"; break; } if ($value['type'] != "heading" && ($value['type'] != "info" && $value['type'] != "subsection" && $value['type'] != "subsection_end") && $value['type'] != "open_outersection" && $value['type'] != "close_outersection") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } $output .= "</div>"; if ($value['type'] != "checkbox") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '<div class="clear"></div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
/** * 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>×</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 .= ' '; $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' => __('— Select —', 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>'; }
/** * Generates the options fields that are used in the form. */ static function optionsframework_fields() { global $allowedtags; $options_framework = new Options_Framework(); $option_name = $options_framework->get_option_name(); $settings = get_option($option_name); $options =& Options_Framework::_optionsframework_options(); $counter = 0; $menu = ''; foreach ($options as $value) { $val = ''; $select_value = ''; $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, override $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']; } // Set the placeholder if one exists $placeholder = ''; if (isset($value['placeholder'])) { $placeholder = ' placeholder="' . esc_attr($value['placeholder']) . '"'; } if (has_filter('optionsframework_' . $value['type'])) { $output .= apply_filters('optionsframework_' . $value['type'], $option_name, $value, $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) . '"' . $placeholder . ' />'; break; // Basic hidded input // Basic hidded input case 'hidden': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="hidden" value="' . esc_attr($val) . '"' . $placeholder . ' />'; break; // Basic text input // Basic text input case 'url': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_url($val) . '"' . $placeholder . ' />'; 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 = '14'; 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 . '"' . $placeholder . '>' . 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) { $output .= '<option' . selected($val, $key, false) . ' 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 = ''; if ($val != '' && $val == $key) { $selected = ' of-radio-img-selected'; } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . checked($val, $key, false) . ' />'; $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 .= Options_Framework_Media_Uploader::optionsframework_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 if (!isset($background['image'])) { $background['image'] = ''; } $output .= Options_Framework_Media_Uploader::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>'; // Background Size $output .= '<select class="of-background of-background-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; $sizes = of_recognized_background_size(); foreach ($sizes as $key => $size) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['size'], $key, false) . '>' . esc_html($size) . '</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($default_editor_settings, $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 (isset($value['desc'])) { $output .= $value['desc'] . "\n"; } $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 . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; // Background // Background case 'parallaxsection': if (!empty($settings['parallax_section'])) { foreach ($settings['parallax_section'] as $i => $ival) { $background = $val; $output .= '<div class="sub-option clearfix" data-id="' . $i . '"><h3 class="title">' . __('Page Title: ', 'accesspress-parallax') . '<span></span><div class="section-toggle"><i class="fa fa-chevron-down"></i> </div></h3>'; $output .= '<div class="sub-option-inner" style="display:none">'; $output .= '<div class="inline-label">'; $output .= '<label>' . __('Page', 'accesspress-parallax') . '</label>'; $output .= '<select class="of-input ' . esc_attr($value['id'] . '_page') . '" name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][page]') . '">'; foreach ($value['options'] as $key => $option) { $output .= '<option' . selected($background[$i]['page'], $key, false) . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; $output .= '</div>'; // Font Color $default_color = ''; if (isset($value['std']['font_color'])) { if ($val != $value['std']['font_color']) { $default_color = ' data-default-color="' . $value['std']['font_color'] . '" '; } } $output .= '<div class="color-picker inline-label">'; $output .= '<label class="">' . __('Font Color', 'accesspress-parallax') . '</label>'; $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][font_color]') . '" class="of-color of-background-color" type="text" value="' . esc_attr($background[$i]['font_color']) . '"' . $default_color . ' />'; $output .= '</div>'; // Background Color $default_color = ''; if (isset($value['std']['color'])) { if ($val != $value['std']['color']) { $default_color = ' data-default-color="' . $value['std']['color'] . '" '; } } $output .= '<div class="color-picker inline-label">'; $output .= '<label>' . __('Background Color', 'accesspress-parallax') . '</label>'; $output .= '<input name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][color]') . '" class="of-color of-background-color" type="text" value="' . esc_attr($background[$i]['color']) . '"' . $default_color . ' />'; $output .= '</div>'; // Section Layout $output .= '<div class="inline-label">'; $output .= '<label>' . __('Layout', 'accesspress-parallax') . '</label>'; $output .= '<select class="of-section of-section-layout" name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][layout]') . '">'; $layouts = of_recognized_layout(); foreach ($layouts as $key => $layout) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background[$i]['layout'], $key, false) . '>' . esc_html($layout) . '</option>'; } $output .= '</select>'; $output .= '</div>'; // Section Category $output .= '<div class="inline-label toggle-category">'; $output .= '<label>' . __('Category', 'accesspress-parallax') . '</label>'; $output .= '<select class="of-input of-section-category" name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][category]') . '">'; foreach ($value['category'] as $key => $category) { $output .= '<option' . selected($background[$i]['category'], $key, false) . ' value="' . esc_attr($key) . '">' . esc_html($category) . '</option>'; } $output .= '</select>'; $output .= '</div>'; // Background Image if (!isset($background[$i]['image'])) { $background[$i]['image'] = ''; } $output .= '<div class="inline-label">'; $output .= '<label class="">' . __('Background Image', 'accesspress-parallax') . '</label>'; $output .= Options_Framework_Media_Uploader::optionsframework_uploader($value['id'], $background[$i]['image'], null, esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][image]')); $output .= '</div>'; $class = 'of-background-properties'; if ('' == $background[$i]['image']) { $class .= ' hide'; } $output .= '<div class="inline-label ' . esc_attr($class) . '">'; $output .= '<label>' . __('Background Settings', 'accesspress-parallax') . '</label>'; // Background Repeat $output .= '<div class="background-settings">'; $output .= '<div class="clearfix">'; $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][repeat]') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background[$i]['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'] . '][' . $i . '][position]') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background[$i]['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'] . '][' . $i . '][attachment]') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background[$i]['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; // Background Size $output .= '<select class="of-background of-background-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][size]') . '">'; $sizes = of_recognized_background_size(); foreach ($sizes as $key => $size) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background[$i]['size'], $key, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; $output .= '</div></div>'; // Background Overlay $output .= '<div class="color-picker inline-label">'; $output .= '<label>' . __('Overlay', 'accesspress-parallax') . '</label>'; $output .= '<select class="of-background of-background-overlay" name="' . esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][overlay]') . '">'; $overlays = of_recognized_background_overlay(); foreach ($overlays as $key => $overlay) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background[$i]['overlay'], $key, false) . '>' . esc_html($overlay) . '</option>'; } $output .= '</select>'; $output .= '</div>'; $output .= '</div>'; $output .= '<div class="button-primary remove-parallax">' . __('Remove', 'accesspress-parallax') . '</div></div>'; $output .= '</div>'; } } break; // Button // Button case "button": $output .= '<a id="' . esc_attr($value['id']) . '" class="button-primary" href="javascript:void(0);">' . __('Add New Section', 'accesspress-parallax') . '</a>' . "\n"; break; } if ($value['type'] != "heading" && $value['type'] != "info") { $output .= '</div>'; if ($value['type'] != "checkbox" && $value['type'] != "editor" && $value['type'] != "parallaxsection") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '</div></div>' . "\n"; } echo $output; } // Outputs closing div if there tabs if (Options_Framework_Interface::optionsframework_tabs() != '') { echo '</div>'; } }
/** * Generates the options fields that are used in the form. */ static function optionsframework_fields() { global $allowedtags; $options_framework = new Options_Framework(); $option_name = $options_framework->get_option_name(); $settings = get_option($option_name); $options =& Options_Framework::_optionsframework_options(); $counter = 0; $menu = ''; foreach ($options as $value) { $val = ''; $select_value = ''; $output = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "title" && $value['type'] != 'groupstart' && $value['type'] != 'groupend') { // 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, override $val if ($value['type'] != 'heading' && $value['type'] != 'info' && $value['type'] != "title" && $value['type'] != 'groupstart' && $value['type'] != 'groupend') { 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']; } // Set the placeholder if one exists $placeholder = ''; if (isset($value['placeholder'])) { $placeholder = ' placeholder="' . esc_attr($value['placeholder']) . '"'; } if (has_filter('optionsframework_' . $value['type'])) { $output .= apply_filters('optionsframework_' . $value['type'], $option_name, $value, $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) . '"' . $placeholder . ' />'; break; // Basic number input // Basic number input case 'number': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="number" min="1" max="1000" value="' . esc_attr($val) . '"' . $placeholder . ' step="1" />'; 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; // } // } if (isset($value['rows'])) { $custom_rows = $value['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 . '"' . $placeholder . '>' . esc_textarea($val) . '</textarea>'; break; //Ap-Mag Textarea //Ap-Mag Textarea case 'apmagtextarea': $rows = '10'; 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 . '"' . $placeholder . '>' . $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) { $output .= '<option' . selected($val, $key, false) . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Box // Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<div class="radio"><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></div>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '' && $val == $key) { $selected = ' of-radio-img-selected'; } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . checked($val, $key, false) . ' />'; $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; // Switch // Switch case "switch": $output .= '<div class="switch_options">'; $output .= '<span class="switch_enable">' . esc_attr($value['on']) . '</span>'; $output .= '<span class="switch_disable">' . esc_attr($value['off']) . '</span>'; $output .= '<input id="' . esc_attr($value['id']) . '" type="hidden" class="switch_val" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" value="' . esc_attr($val) . '"/>'; $output .= '</div>'; break; // SliderUI // SliderUI case "sliderui": $s_min = $s_max = $s_step = $s_edit = ''; $s_edit = ' readonly="readonly"'; if (!isset($value['min'])) { $s_min = '0'; } else { $s_min = $value['min']; } if (!isset($value['max'])) { $s_max = $s_min + 1; } else { $s_max = $value['max']; } if (!isset($value['step'])) { $s_step = '1'; } else { $s_step = $value['step']; } //values $s_data = 'data-id="' . $value['id'] . '" data-val="' . esc_attr($val) . '" data-min="' . $s_min . '" data-max="' . $s_max . '" data-step="' . $s_step . '"'; //html output $output .= '<input type="text" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" value="' . esc_attr($val) . '" ' . $s_edit . ' />'; $output .= '<div id="' . $value['id'] . '-slider" class="ap_sliderui" ' . $s_data . '></div>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $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 .= Options_Framework_Media_Uploader::optionsframework_uploader($value['id'], $val, null); break; // Install Demo // Install Demo case 'demo': $output .= '<a href="#">' . __('Install Demo', 'accesspress-mag') . '</a>'; break; // Typography // Typography case 'typography': unset($font_size, $font_style, $font_face, $font_color); $typography_defaults = array('size' => $value['size'] . "px", 'face' => $value['face'], 'style' => $value['style'], 'color' => $value['color']); $typography_stored = wp_parse_args($val, $typography_defaults); $accesspress_pro_font_list = get_option('accesspress_mag_google_font'); $font_family = $typography_stored['face']; $font_array = accesspress_search_key($accesspress_pro_font_list, 'family', $font_family); $variants_array = $font_array['0']['variants']; $typography_options = array('sizes' => of_recognized_font_sizes(), 'faces' => of_recognized_font_faces(), 'styles' => $variants_array, '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); $output .= '<div class="typographytextbox" id="' . $value['id'] . '">The Quick Brown Fox Jumps Over The Lazy Dog. 1234567890</div>'; 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 .= Options_Framework_Media_Uploader::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($default_editor_settings, $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 (isset($value['desc'])) { $output .= '<div class="option"><div class="explain">' . wp_kses($value['desc'], $allowedtags) . '</div></div>' . "\n"; //$output .= $value['desc'] . "\n"; } $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 . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; // Custom Static Heading for Navigation // Custom Static Heading for Navigation case 'static_heading': break; //Custom Group Start //Custom Group Start case 'groupstart': $id = ''; $group = ''; $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']; } if (isset($value['group'])) { $group .= '[' . $value['group'] . ']'; } $output .= '<div ' . $id . 'class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="group-heading">' . esc_html($value['name']) . '<span class="heading-arrow side"><i class="fa fa-angle-right"></i></span></h4>' . "\n"; } $output .= '<div class="group-content">'; $output .= '<input class="section-order" type="hidden" name="' . esc_attr($option_name . $group . '[' . $value['id'] . ']') . '">' . "\n"; break; // Button // Button case "button": $output .= '<a id="' . esc_attr($value['id']) . '" class="button-primary" href="javascript:void(0);">' . esc_attr($value['button_name']) . '</a>' . "\n"; if (!empty($value['html'])) { $output .= wp_kses_post($value['html']); } break; //Custom Group End //Custom Group End case 'groupend': $output .= '</div></div>' . "\n"; break; } if ($value['type'] != "heading" && ($value['type'] != "info" && $value['type'] != "title" && $value['type'] != 'groupstart' && $value['type'] != 'groupend')) { $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; } // Outputs closing div if there tabs if (Options_Framework_Interface::optionsframework_tabs() != '') { echo '</div>'; } }
/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Get the theme name so we can display it up top $themename = get_theme_data(STYLESHEETPATH . '/style.css'); $themename = $themename['Name']; // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info") { // Keep all ids lowercase with no spaces //if ( isset( $value['id'] ) ){ $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); //} $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Textarea // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); // New AJAX Uploader using Media Library break; // Typography // Typography case 'typography': $typography_stored = $val; // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; /* Font Style */ $styles = of_recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; break; // WPBS Typography - removed font size from std typography set of fields // WPBS Typography - removed font size from std typography set of fields case 'wpbs_typography': $wpbs_typography_stored = $val; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; /* Font Style */ $styles = of_recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $wpbs_typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($wpbs_typography_stored['color']) . '" />'; break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['desc']) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '<div class="clear"></div></div>' . "\n"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; case "themecheck": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; $output .= '<a id="check-bootswatch" class="button-secondary">Refresh themes</a>'; $output .= '<div id="check-status"></div>'; $output .= '</div>'; break; } if ($value['type'] != "heading" && $value['type'] != "info") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } $output .= '</div>'; if ($value['type'] != "checkbox") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '<div class="clear"></div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
function of_sanitize_background_attachment($value) { $recognized = of_recognized_background_attachment(); if (array_key_exists($value, $recognized)) { return $value; } return apply_filters('of_default_background_attachment', current($recognized)); }
/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Get the theme name so we can display it up top $wp_ver = explode('.', get_bloginfo('version')); $wp_ver = array_map('intval', $wp_ver); $themename = wp_get_theme(); $themename = $themename->name; // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); // filter options for current page $options = array_filter($options, 'optionsframework_options_for_page_filter'); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ($value['type'] != "block_begin" && $value['type'] != "block_end" && $value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "page" && $value['type'] != 'js_hide_begin' && $value['type'] != 'js_hide_end') { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/(\\W!-)/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } $output .= '<div class="option">' . "\n"; $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; $output .= '<div class="controls">' . "\n"; } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info' && $value['type'] != 'page') { if (isset($value['id']) && isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } switch ($value['type']) { // Basic text input case 'text': $maxlength = isset($value['maxlength']) ? ' maxlength="' . $value['maxlength'] . '"' : ''; $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '"' . $maxlength . ' />'; break; // Textarea // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="24">' . esc_textarea($val) . '</textarea>'; break; // Select Box // Select Box case 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; $dir = get_template_directory_uri(); foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $img = $dir . $option; $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; // $output .= '<div class="of-radio-img-label" syle="display: none;">' . esc_html( $key ) . '</div>'; $output .= '<img src="' . esc_url($img) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Checkbox // Checkbox case "checkbox": $classes = array(); $classes[] = 'checkbox'; $classes[] = 'of-input'; if (isset($value['options']['java_hide']) && $value['options']['java_hide']) { $classes[] = 'of-js-hider'; } else { if (isset($value['options']['java_hide_global']) && $value['options']['java_hide_global']) { $classes[] = 'of-js-hider-global'; } } $classes = implode(' ', $classes); $output .= '<input id="' . esc_attr($value['id']) . '" class="' . $classes . '" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/\\W/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $mode = isset($value['mode']) ? $value['mode'] : 'full'; $output .= optionsframework_medialibrary_uploader($value['id'], $val, $mode); // New AJAX Uploader using Media Library break; // Typography // Typography case 'typography': $typography_stored = $val; // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; /* Font Style */ $styles = of_recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['desc']) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '<div class="clear"></div></div>' . "\n"; break; // Editor // Editor case 'editor': $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; echo $output; $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']'); $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress')); $editor_settings = array(); if (isset($value['settings'])) { $editor_settings = $value['settings']; } $editor_settings = array_merge($editor_settings, $default_editor_settings); wp_editor($val, $value['id'], $editor_settings); $output = ''; break; // Block begin // Block begin case "block_begin": $class = 'section'; $id = ''; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } if (isset($value['id'])) { $id .= ' id="' . esc_attr($value['id']) . '"'; } $output .= '<div' . $id . ' class="widgets-sortables ' . esc_attr($class) . '">' . "\n"; if (isset($value['name']) && !empty($value['name'])) { $output .= '<div class="sidebar-name"><h3>' . esc_html($value['name']) . '</h3></div>' . "\n"; } break; // Block End // Block End case "block_end": $output .= '</div>' . "\n" . '<!-- block_end -->'; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/\\W/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; //$output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n"; break; case "page": break; case "button": $output .= '<input type="button" id="' . esc_attr($value['id']) . '" class="button" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" value="' . esc_attr($value['options']['title']) . '">'; break; // fields generator // fields generator case "fields_generator": if (!isset($value['options']['fields']) || !is_array($value['options']['fields'])) { break; } $del_link = '<div class="submitbox"><a href="#" class="of_fields_gen_del submitdelete">' . _x('Delete', 'backend fields', LANGUAGE_ZONE) . '</a></div>'; $output .= '<ul class="of_fields_gen_list">'; // saved elements if (is_array($val)) { $i = 0; // create elements foreach ($val as $index => $field) { $block = $b_title = ''; // use patterns foreach ($value['options']['fields'] as $name => $data) { // if only_for list isset and current index not in the list - skip this element if (isset($data['only_for']) && is_array($data['only_for']) && !in_array($index, $data['only_for'])) { continue; } // checked если поле присутствует в записи, если нет поля value в шаблоне // или если оно есть и равно значению поля в записи $checked = false; if (isset($field[$name]) && (!isset($data['value']) || isset($data['value']) && $data['value'] == $field[$name])) { $checked = true; } // get the title if (isset($data['class']) && 'of_fields_gen_title' == $data['class']) { $b_title = $field[$name]; } $el_args = array('name' => sprintf('%s[%s][%d][%s]', $option_name, $value['id'], $index, $name), 'description' => isset($data['description']) ? $data['description'] : '', 'class' => isset($data['class']) ? $data['class'] : '', 'value' => 'checkbox' == $data['type'] ? '' : $field[$name], 'checked' => $checked); if (isset($data['desc_wrap'])) { $el_args['desc_wrap'] = $data['desc_wrap']; } if (isset($data['wrap'])) { $el_args['wrap'] = $data['wrap']; } if (isset($data['style'])) { $el_args['style'] = $data['style']; } // create form elements $element = dt_melement($data['type'], $el_args); $block .= $element; } unset($data); $output .= '<li class="nav-menus-php">'; $output .= '<div class="of_fields_gen_title menu-item-handle" data-index="' . $index . '"><span class="dt-menu-item-title">' . esc_attr($b_title) . '</span>'; $output .= '<span class="item-controls"><a title="' . _x('Edit Widgetized Area', 'backend fields', LANGUAGE_ZONE) . '" class="item-edit"></a></span></div>'; $output .= '<div class="of_fields_gen_data menu-item-settings description" style="display: none;">' . $block; if ($index > 7) { $output .= $del_link; } $output .= '</div>'; $output .= '</li>'; $i++; } unset($field); } $output .= '</ul>'; // control panel $output .= '<div class="of_fields_gen_controls">'; // use pattern foreach ($value['options']['fields'] as $name => $data) { if (isset($data['only_for'])) { continue; } $el_args = array('name' => sprintf('%s[%s][%s]', $option_name, $value['id'], $name), 'description' => isset($data['description']) ? $data['description'] : '', 'class' => isset($data['class']) ? $data['class'] : '', 'checked' => isset($data['checked']) ? $data['checked'] : false); if (isset($data['desc_wrap'])) { $el_args['desc_wrap'] = $data['desc_wrap']; } if (isset($data['wrap'])) { $el_args['wrap'] = $data['wrap']; } if (isset($data['style'])) { $el_args['style'] = $data['style']; } if (isset($data['value'])) { $el_args['value'] = $data['value']; } // create form $element = dt_melement($data['type'], $el_args); $output .= $element; } unset($data); // add button $button = dt_melement('button', array('name' => $option_name . '[' . $value['id'] . '][add]', 'title' => isset($value['options']['button']['title']) ? $value['options']['button']['title'] : _x('Add', 'backend fields button', LANGUAGE_ZONE), 'class' => 'of_fields_gen_add')); $output .= $button; $output .= '</div>'; break; // Social icons // Social icons case 'social_icon': if (!isset($value['options']['fields']) || !is_array($value['options']['fields'])) { continue; } $w = $h = '20'; if (!empty($value['options']['ico_width'])) { $w = intval($value['options']['ico_width']); } if (!empty($value['options']['ico_height'])) { $h = intval($value['options']['ico_height']); } $ico_size = sprintf('width: %dpx;height: %dpx;', $w, $h); foreach ($value['options']['fields'] as $src => $desc) { $clear_desc = strtolower(str_replace(' ', '', $desc)); $name = sprintf('%s[%s][%s]', $option_name, $value['id'], $clear_desc); $soc_link = isset($val[$clear_desc]) && isset($val[$clear_desc]['link']) ? $val[$clear_desc]['link'] : ''; $output .= '<div class="of-soc-image" style="background: url( ' . esc_attr(get_template_directory_uri() . $src) . ' ) no-repeat 0 0; vertical-align: middle; margin-right: 5px; display: inline-block;' . $ico_size . '" title="' . esc_attr($desc) . '"></div>'; $maxlength = isset($value['maxlength']) ? ' maxlength="' . $value['maxlength'] . '"' : ''; $output .= '<input class="of-input" name="' . esc_attr($name . '[link]') . '" type="text" value="' . esc_attr($soc_link) . '"' . $maxlength . ' style="display: inline-block; width: 300px; vertical-align: middle;" />'; $output .= '<input name="' . esc_attr($name . '[src]') . '" type="hidden" value="' . esc_attr($src) . '" /> <br>'; } break; case 'slider': $output .= '<div class="of-slider"></div>'; $slider_opts = array('max' => isset($value['options']['max']) ? $value['options']['max'] : 100, 'min' => isset($value['options']['min']) ? $value['options']['min'] : 0, 'step' => isset($value['options']['step']) ? $value['options']['step'] : 1, 'value' => isset($val) ? $val : 0); $str = ''; foreach ($slider_opts as $name => $val) { $str .= ' data-' . $name . '="' . esc_attr($val) . '"'; } $output .= '<input type="text" class="of-slider-value"' . $str . ' name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" readonly />'; break; case 'js_hide_begin': $output .= '<div class="of-js-hide hide-if-js">'; break; case 'js_hide_end': $output .= '</div>'; break; // beta feature // beta feature case 'web_fonts': $id = esc_attr($value['id']); $output .= '<select class="of-input dt-web-fonts" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . $id . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '' && $val == $key) { $selected = ' selected="selected"'; } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; $output .= '<div class="dt-web-fonts-preview"><iframe id="' . $id . '_preview"></iframe></div>'; // refresh button $output .= '<a href="#" class="dt-web-fonts-refresh button-secondary" onclick="dtWebfontsRefresh( \'' . $id . '\', \'' . wp_create_nonce('dt_webfonts_refresh') . '\' ); return false;">' . _x('refresh', 'backend', LANGUAGE_ZONE) . '</a>'; $output .= '<img src="' . get_admin_url() . '/images/wpspin_light.gif" class="dt-web-fonts-refresh-ajax-loading" id="' . $id . '-ajax-loading" alt="">'; // function located in options-functions.php $output .= dt_get_google_fonts_errors(); break; } if ($value['type'] != "block_begin" && $value['type'] != "block_end" && $value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "page" && $value['type'] != 'js_hide_begin' && $value['type'] != 'js_hide_end') { if ($value['type'] != "checkbox") { $output .= '<br/>'; } $explain_value = ''; if (isset($value['explain'])) { $explain_value = $value['explain']; $output .= '<div class="dt-option-info">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '</div>' . "\n"; $output .= '<div class="clear"></div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Get the theme name so we can display it up top $themename = wp_get_theme(STYLESHEETPATH . '/style.css'); $themename = $themename['Name']; // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info") { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Textarea // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes($val); if (!isset($value['editor'])) { $value['editor'] = ''; } $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input ' . esc_attr($value['editor']) . '" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Select Box custom taxonomies // Select Box custom taxonomies case $value['type'] == 'select_tax': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; $args = array('hide_empty' => true, 'hierarchical' => true, 'orderby' => 'term_group'); $terms = get_terms('multimedia-category', $args); $count = count($terms); if ($count > 0) { foreach ($terms as $term) { $selected = ''; if ($val != '') { if ($val == $term->term_id) { $selected = ' selected="selected"'; } } if ($term->parent == 0) { $output .= '<option' . $selected . ' value="' . $term->term_id . '">***** ' . $term->name . ' *****</option>'; } else { $output .= '<option' . $selected . ' value="' . $term->term_id . '">' . $term->name . '</option>'; } } } else { $output .= '<option selected value="0">' . esc_html__('No categories!', 'crystalskull') . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } if (esc_attr($key) == 'b1') { $rep = 'No repeat'; } elseif (esc_attr($key) == 'b2') { $rep = 'Repeat vertically'; } elseif (esc_attr($key) == 'b3') { $rep = 'Repeat horizontally '; } else { $rep = 'Tile'; } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<a data-toggle="tooltip" data-original-title="' . $rep . '"><img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" /></a>'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; //jquery checkbox //jquery checkbox case "jqueryselect": ?> <script type="text/javascript"> jQuery(document).ready(function($) { // Start jQuery goodness $('#itoggle input#<?php echo esc_attr($value['id']); ?> ').iToggle({ easing: 'easeOutExpo', onClickOn: function(){ $('#console').show().css({opacity:0}).animate({opacity:1},400); statusUpdate('Console on'); }, onClickOff: function(){ statusUpdate('Console off'); $('#console').animate({opacity:0},400); } }); function statusUpdate(text){ $('#console').prepend('<p>'+text+'</p>'); } // End jQuery goodness }); </script> <?php $output .= '<div id="itoggle" class="project"><input type="checkbox" class="checkbox of-input" id="' . esc_attr($value['id']) . '" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' /></div>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); // New AJAX Uploader using Media Library break; // Typography // Typography case 'typography': $typography_stored = $val; /* // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr( $option_name . '[' . $value['id'] . '][size]' ) . '" id="' . esc_attr( $value['id'] . '_size' ) . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr( $size ) . '" ' . selected( $typography_stored['size'], $size, false ) . '>' . esc_html( $size ) . '</option>'; } $output .= '</select>'; */ // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; /* // Font Weight $output .= '<select class="of-typography of-typography-style" name="'.$option_name.'['.$value['id'].'][style]" id="'. $value['id'].'_style">'; */ /* Font Style */ /* $styles = of_recognized_font_styles(); foreach ( $styles as $key => $style ) { $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['style'], $key, false ) . '>'. $style .'</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr( $value['id'] ) . '_color_picker" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $typography_stored['color'] ) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" type="text" value="' . esc_attr( $typography_stored['color'] ) . '" />'; */ break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if (isset($value['desc'])) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '<div class="clear"></div></div>' . "\n"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; break; //added by shark //added by shark case 'impbutton': $importer_url = get_template_directory_uri() . "/demo/import.php"; global $wpdb; $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type='post'"); ?> <script type="text/javascript"> jQuery(document).ready(function($) { var whatever = "<?php echo esc_url($importer_url); ?> "; var demo_stat = "<?php echo esc_attr($count); ?> "; jQuery("#close_update_nag").click(function(event) { jQuery('#import_incomp_noti').hide(); }); jQuery("#import_btn").click(function(event) { console.log('aaaa'); if(demo_stat > 4) { jQuery("input[id='import_btn']").prop('disabled', true); jQuery('#import_incomp_noti').show(); } else { jQuery.ajax( { beforeSend: function() { jQuery("input[id='import_btn']").prop('disabled', true); jQuery('#target').show(); }, complete: function() { jQuery('#target').hide(); }, url: whatever, success: function(data) { jQuery('#import_comp_noti').show(); }, error: function (data, xhr, ajaxOptions, thrownError) { console.log(xhr.status); console.log(data); } }); } }); }); </script> <?php import_completed_notice(); import_incompleted_notice(); $output .= '<input id="import_btn" class="button button-primary" type="button" value="import" rel="5">'; $output .= '<div class="loading" id="target" style="display:none;"><div class="loading_text">' . __("Please wait, the content is importing....", "crystalskull") . '</div></div>'; break; } if ($value['type'] != "heading" && $value['type'] != "info") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } $output .= '</div>'; if ($value['type'] != "checkbox") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '<div class="clear"></div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
/** * Generates the options fields that are used in the form. */ static function optionsframework_fields() { global $allowedtags, $themename; $optionsframework_settings = get_option(vpanel_options); // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = vpanel_options; } $settings = get_option($option_name); $options =& Options_Framework::_optionsframework_options(); $counter = 0; $menu = ''; foreach ($options as $value) { $val = ''; $select_value = ''; $output = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "content" && $value['type'] != 'hidden') { // 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' && $value['type'] != 'upload' && $value['type'] != 'background' && $value['type'] != 'sidebar' && $value['type'] != 'roles') { $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } else { if ($value['type'] == 'upload' || $value['type'] == 'background') { $output .= '<div class="option">' . "\n" . '<div class="controls controls-upload">' . "\n"; } else { if ($value['type'] == 'sidebar') { $output .= '<div class="option">' . "\n" . '<div class="controls controls-sidebar">' . "\n"; } else { if ($value['type'] == 'roles') { $output .= '<div class="option">' . "\n" . '<div class="controls controls-role">' . "\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, override $val if ($value['type'] != 'heading' && $value['type'] != 'info' && $value['type'] != 'content') { 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']; } if (has_filter('vpanel_' . $value['type'])) { $output .= apply_filters('vpanel_' . $value['type'], $option_name, $value, $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; // input hidden // input hidden case 'hidden': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="hidden" 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; // Role Box // Role Box case 'roles': global $wp_roles; $roles = get_option(esc_attr($value['id'])); $k = 0; $output .= ' <input id="role_name" type="text" name="role_name" value=""> <input id="role_add" type="button" value="+ Add new group"> <div class="clear"></div> <ul id="roles_list" class="roles_list">'; if ($roles) { //echo $role["id"]."<pre>";print_r($wp_roles->roles);echo "</pre>"; foreach ($roles as $role) { $k++; unset($wp_roles->roles[$role["id"]]); $output .= '<li><div class="widget-head">' . esc_html($role["group"]) . '<a class="del-builder-item del-role-item">x</a></div> <div class="widget-content"> <div class="widget-content-div"> <label for="roles[' . $k . '][group]">Type here the group name .</label> <input id="roles[' . $k . '][group]" type="text" name="roles[' . $k . '][group]" value="' . (isset($role["group"]) && $role["group"] != '' ? esc_html($role["group"]) : '') . '"> <input type="hidden" class="group_id" name="roles[' . $k . '][id]" value="group_' . $k . '"> <div class="clearfix"></div> <input id="roles[' . $k . '][ask_question]" type="checkbox" name="roles[' . $k . '][ask_question]"' . (isset($role["ask_question"]) && $role["ask_question"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles[' . $k . '][ask_question]">Select ON to add a question .</label> <div class="clearfix"></div> <input id="roles[' . $k . '][show_question]" type="checkbox" name="roles[' . $k . '][show_question]"' . (isset($role["show_question"]) && $role["show_question"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles[' . $k . '][show_question]">Select ON to show other questions .</label> <div class="clearfix"></div> <input id="roles[' . $k . '][add_answer]" type="checkbox" name="roles[' . $k . '][add_answer]"' . (isset($role["add_answer"]) && $role["add_answer"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles[' . $k . '][add_answer]">Select ON to add a answer .</label> <div class="clearfix"></div> <input id="roles[' . $k . '][show_answer]" type="checkbox" name="roles[' . $k . '][show_answer]"' . (isset($role["show_answer"]) && $role["show_answer"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles[' . $k . '][show_answer]">Select ON to show other answers .</label> <div class="clearfix"></div> <input id="roles[' . $k . '][add_post]" type="checkbox" name="roles[' . $k . '][add_post]"' . (isset($role["add_post"]) && $role["add_post"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles[' . $k . '][add_post]">Select ON to add a post .</label> <div class="clearfix"></div> </div> </div> </li>'; } } $output .= '</ul><div class="clear"></div>'; $output .= '<ul class="roles_list">'; $roles_default = get_option("roles_default"); $old_roles = $wp_roles->roles; foreach ($old_roles as $key_r => $value_r) { $output .= '<li> <div class="widget-head">' . esc_html($value_r['name']) . '</div> <div class="widget-content"> <div class="widget-content-div"> <input id="roles_default[' . $key_r . '][ask_question]" type="checkbox" name="roles_default[' . $key_r . '][ask_question]"' . (isset($roles_default[$key_r]["ask_question"]) && $roles_default[$key_r]["ask_question"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles_default[' . $key_r . '][ask_question]">Select ON to add a question .</label> <div class="clearfix"></div> <input id="roles_default[' . $key_r . '][show_question]" type="checkbox" name="roles_default[' . $key_r . '][show_question]"' . (isset($roles_default[$key_r]["show_question"]) && $roles_default[$key_r]["show_question"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles_default[' . $key_r . '][show_question]">Select ON to show other questions .</label> <div class="clearfix"></div> <input id="roles_default[' . $key_r . '][add_answer]" type="checkbox" name="roles_default[' . $key_r . '][add_answer]"' . (isset($roles_default[$key_r]["add_answer"]) && $roles_default[$key_r]["add_answer"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles_default[' . $key_r . '][add_answer]">Select ON to add a answer .</label> <div class="clearfix"></div> <input id="roles_default[' . $key_r . '][show_answer]" type="checkbox" name="roles_default[' . $key_r . '][show_answer]"' . (isset($roles_default[$key_r]["show_answer"]) && $roles_default[$key_r]["show_answer"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles_default[' . $key_r . '][show_answer]">Select ON to show other answers .</label> <div class="clearfix"></div> <input id="roles_default[' . $key_r . '][add_post]" type="checkbox" name="roles_default[' . $key_r . '][add_post]"' . (isset($roles_default[$key_r]["add_post"]) && $roles_default[$key_r]["add_post"] == 'on' ? ' checked="checked"' : '') . '> <label for="roles_default[' . $key_r . '][add_post]">Select ON to add a post .</label> <div class="clearfix"></div> </div> </div> </li>'; } $output .= '</ul><div class="clear"></div>'; $output .= '<script type="text/javascript">roles_j = ' . ($k + 1) . ';</script>'; break; // Sections // Sections case 'sections': $output .= '<ul id="sort-sections">'; $order_sections_li = $val; if (empty($order_sections_li)) { $order_sections_li = array(1 => "advertising", 2 => "author", 3 => "related", 4 => "comments", 5 => "next_previous"); } $order_sections = $order_sections_li; $i = 0; foreach ($order_sections as $key_r => $value_r) { $i++; if ($value_r == "") { unset($order_sections[$key_r]); } else { $output .= '<li id="' . esc_attr($value_r) . '" class="ui-state-default"> <div class="widget-head"><span>'; if ($value_r == "next_previous") { $output .= esc_attr("Next and Previous articles"); } else { if ($value_r == "advertising") { $output .= esc_attr("Advertising"); } else { if ($value_r == "author") { $output .= esc_attr("About the author"); } else { if ($value_r == "related") { $output .= esc_attr("Related articles"); } else { if ($value_r == "comments") { $output .= esc_attr("Comments"); } } } } } $output .= '</span></div> <input name="' . esc_attr($option_name . '[' . $value['id'] . '][' . esc_attr($i) . ']') . '" value="'; if ($value_r == "next_previous") { $output .= esc_attr("next_previous"); } else { if ($value_r == "advertising") { $output .= esc_attr("advertising"); } else { if ($value_r == "author") { $output .= esc_attr("author"); } else { if ($value_r == "related") { $output .= esc_attr("related"); } else { if ($value_r == "comments") { $output .= esc_attr("comments"); } } } } } $output .= '" type="hidden"> </li>'; } } $output .= '</ul>'; break; // Sidebar Box // Sidebar Box case 'sidebar': $output .= ' <input id="sidebar_name" type="text" name="sidebar_name" value=""> <input id="sidebar_add" type="button" value="+ Add new sidebar"> <div class="clear"></div> <ul id="sidebars_list">'; $sidebars = get_option(esc_attr($value['id'])); if ($sidebars) { foreach ($sidebars as $sidebar) { $output .= '<li><div class="widget-head">' . esc_html($sidebar) . '<input id="sidebars" name="sidebars[]" type="hidden" value="' . esc_html($sidebar) . '"><a class="del-builder-item del-sidebar-item">x</a></div></li>'; } } $output .= '</ul>'; 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) { $output .= '<option' . selected($val, $key, false) . ' 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 ' . (isset($value['class']) ? esc_attr($value['class']) : '') . '" 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 = ''; if ($val != '' && $val == $key) { $selected = ' of-radio-img-selected'; } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . checked($val, $key, false) . '>'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img ' . (isset($value['class']) ? esc_attr($value['class']) : '') . '' . $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 vpanel_checkbox" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . '>'; $output .= '<label class="explain explain-checkbox" 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 vpanel_multicheck" 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 ' . (isset($value['class']) ? esc_attr($value['class']) : '') . '" type="text" value="' . esc_attr($val) . '"' . $default_color . '>'; break; // Uploader // Uploader case "upload": $output .= Options_Framework_Media_Uploader::optionsframework_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) . '" ' . (is_string($typography_stored['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 .= Options_Framework_Media_Uploader::optionsframework_uploader($value['id'], $background['image'], null, esc_attr($option_name . '[' . $value['id'] . '][image]')); $class = 'of-background-properties ' . (isset($value['class']) ? esc_attr($value['class']) : '') . ''; 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; // export // export case 'export': $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 builder_select" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . esc_textarea($value['export']) . '</textarea>'; break; // import // import case 'import': $rows = '8'; $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '"></textarea>'; break; // Editor // Editor case 'editor': //$output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags ) . '</div>'."\n"; $output .= '<div class="vpanel_editor"></div>'; echo $output; $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']'); $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => "vpanel_editor", 'tinymce' => array('plugins' => 'wordpress')); $editor_settings = array(); if (isset($value['settings'])) { $editor_settings = $value['settings']; } $editor_settings = array_merge($default_editor_settings, $editor_settings); wp_editor($val, $value['id'], $editor_settings); $output = ''; break; // Content // Content case "content": if (isset($value['content'])) { $output .= $value['content'] . "\n"; } 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">' . $value['name'] . '</h4>' . "\n"; } if (isset($value['desc'])) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $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 . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; } if (isset($value['type'])) { if ($value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "content" && $value['type'] != 'hidden') { $output .= '</div>'; if ($value['type'] != "checkbox" && $value['type'] != "editor") { $output .= '<div class="explain vpanel_help"><div class="tooltip_s" original-title="' . wp_kses($explain_value, $allowedtags) . '"><i class="dashicons dashicons-info"></i></div></div>' . "\n"; } $output .= '</div></div>' . "\n"; } } echo $output; } // Outputs closing div if there tabs if (Options_Framework_Interface::optionsframework_tabs() != '') { echo '</div>'; } }
/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Get the theme name so we can display it up top $themename = wp_get_theme(STYLESHEETPATH . '/style.css'); $themename = $themename['Name']; // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info") { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } if (isset($value['id'])) { $val = get_option('mtheme_' . $value['id']); } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': if (isset($value['unit'])) { $output .= '<div class="ranger-min-max-wrap"><span class="ranger-min-value">' . $value['min'] . '</span>'; $output .= '<span class="ranger-max-value">' . $value['max'] . '</span></div>'; $output .= '<div id="' . esc_attr($value['id']) . '_slider"></div>'; $output .= '<div class="ranger-bar">'; } $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '"'; if (isset($value['unit'])) { if (isset($value['min'])) { $output .= ' min="' . $value['min']; } if (isset($value['max'])) { $output .= '" max="' . $value['max']; } if (isset($value['step'])) { $output .= '" step="' . $value['step']; } $output .= '" />'; if (isset($value['unit'])) { $output .= '<span>' . $value['unit'] . '</span>'; } $output .= '</div>'; } else { $output .= ' />'; } break; case 'dragdrop_sorter': // Set directory uri $directory_uri = get_template_directory_uri(); $image_page = "/framework/options/images/"; //$option_name = 'cyberchimps_options'; //$settings = get_option($option_name); $sort_order = get_option('mtheme_' . $value['id']); $val = ''; $sortoutput = ''; // If the option is already saved, ovveride $val if (isset($sort_order)) { // Assign empty array if the array returns null if ($sort_order != "") { $val = $sort_order; } else { $val = NULL; } // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } // Set default value to $val if (empty($val)) { if (isset($value['std'])) { if (is_array($value['std'])) { $val = array_keys($value['std']); } else { $val = array_keys(explode($value['std'])); } } } ///$val = $sort_order; //$sortoutput .= '<h1>Curr SOrt order '.$val.'</h1>'; $sortoutput .= "<div class='section_order' id=" . esc_attr($value['id']) . ">"; $sortoutput .= "<div class='section_storage'>"; $sortoutput .= "<div class='inactive'>Inactive Elements</div>"; $sortoutput .= "<div class='drag'>Storage for inactive elements</div>"; $sortoutput .= "<div class='item_drawer'>"; if (is_array($val)) { foreach ($value['options'] as $key => $option) { if (in_array($key, $val)) { continue; } $sortoutput .= "<div class='draggable_item'>"; $sortoutput .= '<img src="' . $directory_uri . $image_page . 'minus.png" class="action" title="Delete"/>'; $sortoutput .= "<span data-key='{$key}'>{$option}</span>"; $sortoutput .= "</div>"; } } $sortoutput .= "</div>"; $sortoutput .= "</div>"; $sortoutput .= '<div class="theme_arrow"><img src="' . $directory_uri . $image_page . 'arrow_drag.png" /></div>'; $sortoutput .= "<div class='section_active'>"; $sortoutput .= "<div class='active'>Active Elements</div>"; $sortoutput .= "<div class='drag'>Drag & Drop here to activate</div>"; $sortoutput .= "<div class='item_drawer'>"; if (is_array($val)) { foreach ($val as $key) { if (!array_key_exists($key, $value['options'])) { continue; } $sortoutput .= "<div class='draggable_item'>"; $sortoutput .= '<img src="' . $directory_uri . $image_page . 'minus.png" class="action" title="Delete"/>'; $sortoutput .= "<span data-key='{$key}'>{$value['options'][$key]}</span>"; $sortoutput .= "</div>"; } } $sortoutput .= "</div>"; $sortoutput .= "</div>"; $sortoutput .= '<div id="values" data-key="' . $option_name . '"></div>'; $sortoutput .= "</div>"; $output .= $sortoutput; break; // Textarea // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } if (!is_serialized($val)) { if (is_array($val)) { $val = serialize($val); } else { $val = stripslashes($val); } } if (is_serialized($val)) { $readonly_mode = "readonly"; } else { $readonly_mode = ""; } $textarea_class = ""; if (isset($value['class'])) { $textarea_class = $value['class']; } $output .= '<textarea ' . $readonly_mode . ' id="' . esc_attr($value['id']) . '" class="of-input opt-textbox-' . $textarea_class . '" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . $val . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; //Sorter //Sorter case 'sorter': $blog_url = home_url(); $sort_order = $value['order']; $sort_val = explode(",", $sort_order); $count = 0; $output .= '<img src="' . $blog_url . '/wp-admin/images/loading.gif" id="loading-animation" />'; $output .= '<ul id="home-list">'; for ($count = 0; $count <= 6; $count++) { foreach ($value['options'] as $key => $option) { if ($sort_val[$count] == $key) { $output .= '<li id="' . $key . '">' . $option . '</li>'; } } } $output .= '</ul>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<div class="toggle-wrap"><div class="togglebox">'; $output .= '<input id="chkbx' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' /><label for="chkbx' . esc_attr($value['id']) . '"><b></b></label></div></div>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="colorSwatch of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Editor // Editor case 'editor': echo $output; $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']'); $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress')); $editor_settings = array(); if (isset($value['settings'])) { $editor_settings = $value['settings']; } $editor_settings = array_merge($editor_settings, $default_editor_settings); wp_editor($val, $value['id'], $editor_settings); $output = ''; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); // New AJAX Uploader using Media Library break; // Typography // Typography case 'typography': unset($font_size, $font_style, $font_face, $font_color); $typography_defaults = array('size' => '', 'face' => '', 'style' => '', 'color' => ''); $typography_stored = wp_parse_args($val, $typography_defaults); $typography_options = array('sizes' => of_recognized_font_sizes(), 'faces' => of_recognized_font_faces(), 'styles' => of_recognized_font_styles(), 'color' => true); if (isset($value['options'])) { $typography_options = wp_parse_args($value['options'], $typography_options); } // Font Size if ($typography_options['sizes']) { $font_size = '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '" onchange="options_font_preview(\'' . esc_attr($value['id'] . '_size') . '\', \'' . esc_attr($value['id']) . '_preview' . '\', \'font-size\');return true;">'; $sizes = $typography_options['sizes']; foreach ($sizes as $i) { $size = $i . 'px'; $font_size .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $font_size .= '</select>'; } // Font Face if ($typography_options['faces']) { $font_face = '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '" onchange="options_font_preview(\'' . esc_attr($value['id'] . '_face') . '\', \'' . esc_attr($value['id']) . '_preview' . '\', \'font-family\');return true;">'; $faces = $typography_options['faces']; foreach ($faces as $key => $face) { $font_face .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $font_face .= '</select>'; } // Font Styles if ($typography_options['styles']) { $font_style = '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style" onchange="options_font_preview(\'' . esc_attr($value['id'] . '_style') . '\', \'' . esc_attr($value['id']) . '_preview' . '\', \'font-style\');return true;">'; $styles = $typography_options['styles']; foreach ($styles as $key => $style) { $font_style .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $font_style .= '</select>'; } // Font Color if ($typography_options['color']) { $font_color = '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $font_color .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; //onkeypress="options_face_preview(\'' . esc_attr( $value['id'] . '_size' ) . '\', \'' . esc_attr($value['id']) . '_color'. '\', \'color\');return true;"/>'; } // Allow modification/injection of typography fields $typography_fields = compact('font_size', 'font_face', 'font_style', 'font_color'); $typography_fields = apply_filters('of_typography_fields', $typography_fields, $typography_stored, $option_name, $value); $output .= implode('', $typography_fields); //$output .= '<p style="font-family: ' . $typography_stored['face'] . '; margin: 7px 0 10px 5px;display:block;width:200px; font-size: ' . $typography_stored['size'] . '" id="' . esc_attr($value['id']) . '_preview' . '">Font Preview</p>'; break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } if (isset($value['name'])) { $output .= '<h5>' . esc_html($value['name']) . '</h5>' . "\n"; } if (isset($value['desc'])) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; } if ($value['type'] != "heading" && $value['type'] != "info") { //if ( $value['type'] != "checkbox" ) { $output .= '<br/>'; //} $output .= '</div>'; //if ( $value['type'] != "checkbox" ) { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; //} $output .= '<div class="clear"></div></div></div>' . "\n"; } } $output .= '</div>'; echo $output; }
/** * Genera los campos de opciones que son usados en este formulario. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Obtiene el nombre del tema para que podamos mostrarlo en la parte superior $the_theme = wp_get_theme(); $themename = $the_theme->Name; // Obtiene el id único de la opción if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Envuelve todas las opciones if ($value['type'] != "heading" && $value['type'] != "info") { // Mantiene todos los id en minúsculas y sin espacios //if ( isset( $value['id'] ) ){ $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); //} $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } // Establece el valor predeterminado para $val if (isset($value['std'])) { $val = $value['std']; } // Si la opción ya se encuentra guardada, sobrescribe $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // Si existe una descripción guardada para las etiquetas $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Inserción básica de texto case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Area de texto // Area de texto case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>'; break; // Caja de selección // Caja de selección case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Caja de radio // Caja de radio case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Selectores de imagen // Selectores de imagen case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Casilla de verificación // Casilla de verificación case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; // Lista de selección múltiple // Lista de selección múltiple case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Selector de color // Selector de color case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Cargador // Cargador case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); // Nuevo cargador en AJAX usando Media Library break; // Tipografía // Tipografía case 'typography': $typography_stored = $val; // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; /* Font Style */ $styles = of_recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; break; // Tipografía WPBS - remueve el tamaño de fuente del grupo de campos std de la tipografía // Tipografía WPBS - remueve el tamaño de fuente del grupo de campos std de la tipografía case 'wpbs_typography': $wpbs_typography_stored = $val; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; /* Font Style */ $styles = of_recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($wpbs_typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $wpbs_typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($wpbs_typography_stored['color']) . '" />'; break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - Nuevo cargador en AJAX usando Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['desc']) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '<div class="clear"></div></div>' . "\n"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; case "themecheck": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; $output .= '<a id="check-bootswatch" class="button-secondary">Actualizar temas</a>'; $output .= '<div id="check-status"></div>'; $output .= '</div>'; break; } if ($value['type'] != "heading" && $value['type'] != "info") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } $output .= '</div>'; if ($value['type'] != "checkbox") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '<div class="clear"></div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu); }
/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Get the theme name so we can display it up top if (function_exists('wp_get_theme')) { $themename = wp_get_theme(); } else { // 'get_theme_data' deprecated as of WP 3.4 $themename = get_theme_data(get_stylesheet_directory() . '/style.css'); } $themename = $themename['Name']; // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); // pls_dump($option_name); // pls_dump($settings); $options = optionsframework_options(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info") { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; case 'integer': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Textarea // Textarea case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } else { $cols = '8'; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; // Multicheck // Multicheck case "multicheck": $output .= '<ul class="multicheck-list">'; foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<li>'; $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; $output .= '</li>'; } $output .= '</ul>'; break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); // New AJAX Uploader using Media Library break; // Typography // Typography case 'typography': $typography_stored = $val; // Check if null if (!isset($typography_stored['size'])) { $typography_stored['size'] = ''; } if (!isset($typography_stored['face'])) { $typography_stored['face'] = ''; } if (!isset($typography_stored['style'])) { $typography_stored['style'] = ''; } if (!isset($typography_stored['color'])) { $typography_stored['color'] = ''; } // Font Size $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; // Check if null if (!isset($typography_stored['size'])) { $typography_stored['size'] = ''; } $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Font Face $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); // Check if null if (!isset($typography_stored['face'])) { $typography_stored['face'] = ''; } foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select>'; // Font Weight $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; /* Font Style */ // Check if null if (!isset($typography_stored['style'])) { $typography_stored['style'] = ''; } $styles = of_recognized_font_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Font Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; break; // BG Gradient -pek // BG Gradient -pek case 'bg_gradient': $bggradient = $val; if (!isset($bggradient['color'])) { $bggradient['color'] = ''; } // Color (main color used for gradient manufacture) $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $bggradient['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($bggradient['color']) . '" />'; break; // Background // Background case 'background': // pls_dump($val); $background = $val; // Check if null if (!isset($background['repeat'])) { $background['repeat'] = ''; } if (!isset($background['position'])) { $background['position'] = ''; } if (!isset($background['attachment'])) { $background['attachment'] = ''; } if (!isset($background['image'])) { $background['image'] = ''; } if (!isset($background['color'])) { $background['color'] = ''; } // checking a new value, a checkbox, indicating desire to make gradation of color if (!isset($background['gradation'])) { $background['gradation'] = ''; } // Background Color // Background gradation $output .= '<input type="checkbox" class="checkbox of-background of-background-gradation" name="' . esc_attr($option_name . '[' . $value['id'] . '][gradation]') . '" id="' . esc_attr($value['id'] . '_gradation') . '" value="1" ' . checked($background['gradation'], 1, false) . '>Make gradation'; $output .= "<div style='clear:left;'></div>\n"; $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Info // Info case "info": $class = 'section'; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['desc']) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '<div class="clear"></div></div>' . "\n"; break; // Border // Border case 'border_shadow': case 'box_shadow': case 'border': $border_stored = $val; // Check if null if (!isset($border_stored['size'])) { $border_stored['size'] = ''; } if (!isset($border_stored['style'])) { $border_stored['style'] = ''; } if (!isset($border_stored['color'])) { $border_stored['color'] = ''; } // Border Size $output .= '<select class="of-border of-border-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 0; $i < 11; $i++) { $size = $i . 'px'; // select 1px by default if empty $stored_or_one = '' === $border_stored['size'] ? '1px' : $border_stored['size'] . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($stored_or_one, $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select>'; // Border Style $styles = of_recognized_border_styles(); $output .= '<select class="of-border of-border-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($border_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select>'; // Border Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $border_stored['color']) . '"></div></div>'; $output .= '<input class="of-color of-border of-border-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($border_stored['color']) . '" />'; break; case "slideshow": if (!isset($val['num_slides'])) { $val['num_slides'] = 6; } ob_start(); for ($i = 0; $i < $val['num_slides']; $i++) { ?> <?php if (!isset($val[$i])) { ?> <?php $val[$i] = array(); ?> <?php } ?> <?php $val[$i] = wp_parse_args($val[$i], array('image' => '', 'link' => '', 'html' => '', 'type' => '', '')); ?> <div class="featured_slideshow_options"> <div class="featured_slide"> <div class="featured_slide_header"> <h2>Slide <?php echo $i + 1; ?> </h2> <select class="slideshow_type" name="<?php echo esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][type]'); ?> " id="" > <option value="custom" <?php echo $val[$i]['type'] == 'custom' ? 'selected=selected' : ''; ?> >Custom Image</option> <option value="listing" <?php echo $val[$i]['type'] == 'listing' ? 'selected=selected' : ''; ?> >Listing</option> </select> </div> <div class="type_controls" id="custom_type"> <p>Select an image for the background of the slide and enter in text or html to be displayed. </p> <div id="image_wrapper_<?php echo $i; ?> " class="item_row"> <label for="">Background Image</label> <?php echo optionsframework_medialibrary_uploader($value['id'], $val[$i]['image'], null, '', 0, "image", $i); ?> </div> <div class="item_row"> <label for="">Click-to Link</label> <input type="text" value="<?php echo $val[$i]['link']; ?> " name="<?php echo esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][link]'); ?> "> </div> <div class="item_row"> <label for="">HTML/Text Displayed</label> <textarea name="<?php echo esc_attr($option_name . '[' . $value['id'] . '][' . $i . '][html]'); ?> " id="" cols="30" rows="10"><?php echo $val[$i]['html']; ?> </textarea> </div> </div> <div class="type_controls" id="listing_type"> <?php echo pls_generate_featured_listings_ui($value, $val[$i], $option_name, $i, $for_slideshow = true); ?> </div> </div> </div> <?php } $output .= trim(ob_get_clean()); break; // Featured Listing Selection // Featured Listing Selection case "featured_listing": $output .= pls_generate_featured_listings_ui($value, $val, $option_name); break; // Featured Listing Selection // Featured Listing Selection case "featured_neighborhoods": ob_start(); ?> <div class="featured-listing-search" id="featured-listing-search-<?php echo $value['id']; ?> "> <div class="fls-address"> <label>Neighborhoods</label> <?php $categories = get_categories('type=property&taxonomy=neighborhood'); ?> <select name="<?php echo $value['id']; ?> " class="fls-address-select" id="fls-select-neighborhood"> <?php for ($i = 1; $i <= 200; $i++) { if (!isset($categories[$i])) { break; } else { echo '<option value=' . $categories[$i]->slug . '>'; echo $categories[$i]->name; echo '</option>'; } } ?> </select> <input type="submit" name="<?php echo $value['id']; ?> " value="Add Neighborhood" class="fls-add-listing button" id="add-listing-<?php echo $value['id']; ?> "> <input type="hidden" value="<?php echo esc_attr($option_name . '[' . $value['id'] . ']'); ?> " id="option-name"> </div> <h4 class="heading">Featured Neighborhoods</h4> <div class="fls-option"> <div class="controls"> <ul name="<?php echo $value['id']; ?> " id="fls-added-listings"> <?php if (isset($settings[$value['id']])) { ?> <?php foreach ($settings[$value['id']] as $key => $text) { ?> <li style='float:left; list-style-type: none;'><div id='pls-featured-text' style='width: 200px; float: left;'><?php echo $text; ?> </div><a style='float:left;' href='#' id='pls-option-remove-listing'>Remove</a><input type='hidden' name='<?php echo esc_attr($option_name . '[' . $value['id'] . '][' . $key . ']='); ?> ' value='<?php echo $text; ?> ' /></li> <?php } ?> <?php } ?> </ul> </div> <div class="clear"></div> </div> </div> <?php $output .= trim(ob_get_clean()); break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<li class="side-bar-nav-item"><a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a></li>'; ob_start(); ?> <div class="group" id="<?php echo esc_attr($jquery_click_hook); ?> "> <h3 id="optionsframework-submit-top" > <div> <span><?php echo esc_html($value['name']); ?> </span> <input type="submit" class="top-button button-primary" name="update" value="Save Options" /> </div> </h3> <?php $output .= ob_get_clean(); break; } if ($value['type'] != "heading" && $value['type'] != "info") { if ($value['type'] != "checkbox") { $output .= '<br/>'; } $output .= '</div>'; if ($value['type'] != "checkbox") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '<div class="clear"></div></div></div>' . "\n"; } } $for_slideshow = isset($for_slideshow) ? $for_slideshow : false; $output .= PLS_Featured_Listing_Option::load(array('value' => $value, 'val' => $val, 'option_name' => $option_name, 'iterator' => isset($iterator) ? $iterator : false, 'for_slideshow' => $for_slideshow)); $output .= '</div>'; return array($output, $menu); }
/** * Generates the options fields that are used in the form. */ static 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 =& Options_Framework::_optionsframework_options(); $counter = 0; $menu = ''; foreach ($options as $value) { $val = ''; $select_value = ''; $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']; if ($value['type'] != "widget-area") { $class = 'section'; } else { $class = 'section2'; } 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, override $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']; } if (has_filter('optionsframework_' . $value['type'])) { $output .= apply_filters('optionsframework_' . $value['type'], $option_name, $value, $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) { $output .= '<option' . selected($val, $key, false) . ' 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 = ''; if ($val != '' && $val == $key) { $selected = ' of-radio-img-selected'; } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . checked($val, $key, false) . ' />'; $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 .= Options_Framework_Media_Uploader::optionsframework_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 if (!isset($background['image'])) { $background['image'] = ''; } $output .= Options_Framework_Media_Uploader::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($default_editor_settings, $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 (isset($value['desc'])) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $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 . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; //=custom type //=custom type case "start_group": $class = ''; $class = !empty($value['id']) ? $value['id'] : $value['name']; $output .= '<div class="tab_item_group ' . $class . '">'; break; case "end_group": $output .= '</div>'; break; case "title": $output .= '<div class="group_title' . $class . '"></div>'; break; case "widget-area": $list_item = get_option('_meris_home_widget_area'); if ($list_item != "" || $val != "") { if ($list_item == "") { $list_item = $val; } $list_array = json_decode($list_item, true); $list_item_str = ''; if (isset($list_array['section-widget-area-name']) && is_array($list_array['section-widget-area-name'])) { $num = count($list_array['section-widget-area-name']); for ($i = 0; $i < $num; $i++) { $areaname = isset($list_array['section-widget-area-name'][$i]) ? $list_array['section-widget-area-name'][$i] : ""; $sanitize_areaname = sanitize_title($areaname); $color = isset($list_array['list-item-color'][$i]) ? $list_array['list-item-color'][$i] : ""; $image = isset($list_array['list-item-image'][$i]) ? $list_array['list-item-image'][$i] : ""; $repeat = isset($list_array['list-item-repeat'][$i]) ? $list_array['list-item-repeat'][$i] : ""; $position = isset($list_array['list-item-position'][$i]) ? $list_array['list-item-position'][$i] : ""; $attachment = isset($list_array['list-item-attachment'][$i]) ? $list_array['list-item-attachment'][$i] : ""; $layout = isset($list_array['widget-area-layout'][$i]) ? $list_array['widget-area-layout'][$i] : ""; $padding = isset($list_array['widget-area-padding'][$i]) ? $list_array['widget-area-padding'][$i] : ""; $column = isset($list_array['widget-area-column'][$i]) ? $list_array['widget-area-column'][$i] : ""; $columns = isset($list_array['widget-area-column-item'][$sanitize_areaname]) ? $list_array['widget-area-column-item'][$sanitize_areaname] : ""; $list_item_array = array("areaname" => $areaname, "sanitize_areaname" => $sanitize_areaname, "color" => $color, "image" => $image, "repeat" => $repeat, "position" => $position, "attachment" => $attachment, "layout" => $layout, "column" => $column, "columns" => $columns, "num" => $i, "padding" => $padding); $list_item_str .= meris_widget_area_generator($list_item_array, false); } } } $output .= '<div id="section-widget" class=""> <select name="widget_layout" id="widget_layout"><option value="1">' . __("choose column", "meris") . '</option> <option value="1">' . __("1 column", "meris") . '</option> <option value="2">' . __("2 columns", "meris") . '</option> <option value="3">' . __("3 columns", "meris") . '</option> <option value="4">' . __("4 columns", "meris") . '</option> </select> <input type="text" id="list-item-val" size="20" name="list-item-val" value="" placeholder="' . __("Widget Area Name", "meris") . '" />'; // $output .= '<p style="display:block;clear: both;height:30px;"><a href="javascript:;" style="float:left;margin-right:20px;" class="button-primary" id="addItem">' . __("Add Item", "meris") . '</a> <span id="list-item-notice" style=" color:red;"></span></p></div>'; $output .= '<div id="list-widget-areas">' . $list_item_str . '</div>'; break; } if ($value['type'] != "heading" && $value['type'] != "info") { $output .= '</div>'; if ($value['type'] != "checkbox" && $value['type'] != "editor") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '</div></div>' . "\n"; } echo $output; } // Outputs closing div if there tabs if (Options_Framework_Interface::optionsframework_tabs() != '') { echo '</div>'; } }
/** * Generates the options fields that are used in the form. */ function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } $settings = get_option($option_name); $options = optionsframework_options(); $counter = 0; $menu = ''; foreach ($options as $value) { $counter++; $val = ''; $select_value = ''; $checked = ''; $output = ''; // Wrap all options if ($value['type'] != "heading" && $value['type'] != "info") { // Keep all ids lowercase with no spaces $value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id'])); $id = 'section-' . $value['id']; $class = 'section '; if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['type'] != 'editor') { $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } else { $output .= '<div class="option">' . "\n" . '<div>' . "\n"; } } // Set default value to $val if (isset($value['std'])) { $val = $value['std']; } // If the option is already saved, ovveride $val if ($value['type'] != 'heading' && $value['type'] != 'info') { if (isset($settings[$value['id']])) { $val = $settings[$value['id']]; // Striping slashes of non-array options if (!is_array($val)) { $val = stripslashes($val); } } } // If there is a description save it for labels $explain_value = ''; if (isset($value['desc'])) { $explain_value = $value['desc']; } switch ($value['type']) { // Basic text input case 'text': $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />'; break; // Textarea // Textarea case 'textarea': $rows = '8'; if (isset($value['settings']['rows'])) { $custom_rows = $value['settings']['rows']; if (is_numeric($custom_rows)) { $rows = $custom_rows; } } $val = stripslashes($val); $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . esc_attr($val) . '</textarea>'; break; // Select Box // Select Box case $value['type'] == 'select': $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">'; foreach ($value['options'] as $key => $option) { $selected = ''; if ($val != '') { if ($val == $key) { $selected = ' selected="selected"'; } } $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>'; } $output .= '</select>'; break; // Radio Box // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>'; } break; // Image Selectors // Image Selectors case "images": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $selected = ''; $checked = ''; if ($val != '') { if ($val == $key) { $selected = ' of-radio-img-selected'; $checked = ' checked="checked"'; } } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . esc_html($key) . '</div>'; $output .= '<img src="' . esc_url($option) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />'; } break; // Checkbox // Checkbox case "checkbox": $output .= '<input id="' . esc_attr($value['id']) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />'; $output .= '<label class="explain" for="' . esc_attr($value['id']) . '">' . wp_kses($explain_value, $allowedtags) . '</label>'; break; // Multicheck // Multicheck case "multicheck": foreach ($value['options'] as $key => $option) { $checked = ''; $label = $option; $option = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($key)); $id = $option_name . '-' . $value['id'] . '-' . $option; $name = $option_name . '[' . $value['id'] . '][' . $option . ']'; if (isset($val[$option])) { $checked = checked($val[$option], 1, false); } $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>'; } break; // Color picker // Color picker case "color": $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />'; break; // Uploader // Uploader case "upload": $output .= optionsframework_medialibrary_uploader($value['id'], $val, null); break; // Typography // Typography case 'typography': unset($font_size, $font_style, $font_face, $font_color); $typography_defaults = array('size' => '', 'face' => '', 'style' => '', 'color' => ''); $typography_stored = wp_parse_args($val, $typography_defaults); $typography_options = array('sizes' => of_recognized_font_sizes(), 'faces' => of_recognized_font_faces(), 'styles' => of_recognized_font_styles(), 'color' => true); if (isset($value['options'])) { $typography_options = wp_parse_args($value['options'], $typography_options); } // Font Size if ($typography_options['sizes']) { $font_size = '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; $sizes = $typography_options['sizes']; foreach ($sizes as $i) { $size = $i . 'px'; $font_size .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $font_size .= '</select>'; } // Font Face if ($typography_options['faces']) { $font_face = '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = $typography_options['faces']; foreach ($faces as $key => $face) { $font_face .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $font_face .= '</select>'; } // Font Styles if ($typography_options['styles']) { $font_style = '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; $styles = $typography_options['styles']; foreach ($styles as $key => $style) { $font_style .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>'; } $font_style .= '</select>'; } // Font Color if ($typography_options['color']) { $font_color = '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>'; $font_color .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />'; } // Allow modification/injection of typography fields $typography_fields = compact('font_size', 'font_face', 'font_style', 'font_color'); $typography_fields = apply_filters('of_typography_fields', $typography_fields, $typography_stored, $option_name, $value); $output .= implode('', $typography_fields); break; // Background // Background case 'background': $background = $val; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; // Editor // Editor case 'editor': $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; echo $output; $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']'); $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress')); $editor_settings = array(); if (isset($value['settings'])) { $editor_settings = $value['settings']; } $editor_settings = array_merge($editor_settings, $default_editor_settings); wp_editor($val, $value['id'], $editor_settings); $output = ''; break; // Info // Info case "info": $id = ''; $class = 'section'; if (isset($value['id'])) { $id = 'id="' . esc_attr($value['id']) . '" '; } if (isset($value['type'])) { $class .= ' section-' . $value['type']; } if (isset($value['class'])) { $class .= ' ' . $value['class']; } $output .= '<div ' . $id . 'class="' . esc_attr($class) . '">' . "\n"; if (isset($value['name'])) { $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n"; } if ($value['desc']) { $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n"; } $output .= '</div>' . "\n"; break; // Heading for Navigation // Heading for Navigation case "heading": if ($counter >= 2) { $output .= '</div>' . "\n"; } $class = (isset($value['class']) ? $value['class'] . ' ' : '') . 'nav-tab'; $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="' . $class . '" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>'; $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; /********************************* ********************************* ** CUSTOM FIELDS **************** ********************************* *********************************/ // Heading Typography /********************************* ********************************* ** CUSTOM FIELDS **************** ********************************* *********************************/ // Heading Typography case 'typo': $typo_stored = $val; // Font Size $output .= '<p><label>Font Size: </label>'; $output .= '<select class="of-typography of-typo-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">'; for ($i = 9; $i < 71; $i++) { $size = $i . 'px'; $output .= '<option value="' . esc_attr($size) . '" ' . selected($typo_stored['size'], $size, false) . '>' . esc_html($size) . '</option>'; } $output .= '</select></p>'; case 'header': $typo_stored = $val; // Font Face $output .= '<p><label>Font Family: </label>'; $output .= '<select class="of-typography of-typo-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">'; $faces = of_recognized_font_faces(); foreach ($faces as $key => $face) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['face'], $key, false) . '>' . esc_html($face) . '</option>'; } $output .= '</select></p>'; // Font Style $output .= '<p><label>Font Style: </label>'; $output .= '<select class="of-typography of-typo-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">'; $styles = ale_get_typo_styles(); foreach ($styles as $key => $style) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['style'], $key, false) . '>' . $style . '</option>'; } $output .= '</select></p>'; // Font Weight $output .= '<p><label>Font Weight: </label>'; $output .= '<select class="of-typography of-typo-weight" name="' . $option_name . '[' . $value['id'] . '][weight]" id="' . $value['id'] . '_style">'; $weights = ale_get_typo_weights(); foreach ($weights as $key => $weight) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['weight'], $key, false) . '>' . $weight . '</option>'; } $output .= '</select></p>'; // Font Variant $output .= '<p><label>Font Variant: </label>'; $output .= '<select class="of-typography of-typo-variant" name="' . $option_name . '[' . $value['id'] . '][variant]" id="' . $value['id'] . '_style">'; $variants = ale_get_typo_variants(); foreach ($variants as $key => $variant) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['variant'], $key, false) . '>' . $variant . '</option>'; } $output .= '</select></p>'; // Text Transform $output .= '<p><label>Text Transform: </label>'; $output .= '<select class="of-typography of-typo-transform" name="' . $option_name . '[' . $value['id'] . '][transform]" id="' . $value['id'] . '_style">'; $transforms = ale_get_typo_transforms(); foreach ($transforms as $key => $transform) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($typo_stored['transform'], $key, false) . '>' . $transform . '</option>'; } $output .= '</select></p>'; break; // Color picker // Color picker case "color_link": $color_stored = $val; if (!isset($color_stored['main'])) { $color_stored['main'] = ''; } if (!isset($color_stored['hover'])) { $color_stored['hover'] = ''; } $labels = isset($value['labels']) ? $value['labels'] : array('main' => 'Main', 'hover' => 'Hover'); $output .= '<div class="color-wrap">'; $output .= '<span class="color_helper">' . $labels['main'] . ':</span>'; $output .= '<div id="' . esc_attr($value['id'] . '_main_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $color_stored['main']) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '[main]" id="' . esc_attr($value['id']) . '_main" type="text" value="' . esc_attr($color_stored['main']) . '" />'; $output .= '</div><div class="color-wrap">'; $output .= '<span class="color_helper">' . $labels['hover'] . ':</span>'; $output .= '<div id="' . esc_attr($value['id'] . '_hover_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $color_stored['hover']) . '"></div></div>'; $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '[hover]" id="' . esc_attr($value['id']) . '_hover" type="text" value="' . esc_attr($color_stored['hover']) . '" />'; $output .= '</div>'; break; } if ($value['type'] != "heading" && $value['type'] != "info") { $output .= '</div>'; if ($value['type'] != "checkbox" && $value['type'] != "editor") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '</div></div>' . "\n"; } echo $output; } echo '</div>'; }
public static function optionsframework_machine($options) { $data = get_option(OPTIONS); $defaults = array(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; //create array of defaults if ($value['type'] == 'multicheck') { if (is_array($value['std'])) { foreach ($value['std'] as $i => $key) { $defaults[$value['id']][$key] = true; } } else { $defaults[$value['id']][$value['std']] = true; } } else { if (isset($value['id'])) { $defaults[$value['id']] = $value['std']; } } //Start Heading if ($value['type'] != "heading") { $class = ''; if (isset($value['class'])) { $class = $value['class']; } $output .= '<div id="section-' . $value['id'] . '" class="section section-' . $value['type'] . ' ' . $class . '">' . "\n"; $output .= '<label for="' . $value['id'] . '"" class="heading">' . $value['name'] . '</label>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } //End Heading switch ($value['type']) { case 'text': $t_value = ''; $t_value = stripslashes($data[$value['id']]); $mini = ''; if (!isset($value['mod'])) { $value['mod'] = ''; } if ($value['mod'] == 'mini') { $mini = 'mini'; } $output .= '<input class="of-input ' . $mini . '" name="' . $value['id'] . '" id="' . $value['id'] . '" type="' . $value['type'] . '" value="' . $t_value . '" />'; break; case 'select': $mini = ''; if (!isset($value['mod'])) { $value['mod'] = ''; } if ($value['mod'] == 'mini') { $mini = 'mini'; } $output .= '<div class="select_wrapper ' . $mini . '">'; $output .= '<select class="select of-input" name="' . $value['id'] . '" id="' . $value['id'] . '">'; foreach ($value['options'] as $select_ID => $option) { $output .= '<option id="' . $select_ID . '" value="' . $select_ID . '" ' . selected($data[$value['id']], $select_ID, false) . ' />' . $option . '</option>'; } $output .= '</select></div>'; break; case 'textarea': $cols = '8'; $ta_value = ''; if (isset($value['options'])) { $ta_options = $value['options']; if (isset($ta_options['cols'])) { $cols = $ta_options['cols']; } } $ta_value = stripslashes($data[$value['id']]); $output .= '<textarea class="of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" cols="' . $cols . '" rows="8">' . $ta_value . '</textarea>'; break; case "radio": foreach ($value['options'] as $option => $name) { $output .= '<input class="of-input of-radio" name="' . $value['id'] . '" type="radio" value="' . $option . '" ' . checked($data[$value['id']], $option, false) . ' /><label class="radio">' . $name . '</label><br/>'; } break; case 'checkbox': if (!isset($data[$value['id']])) { $data[$value['id']] = 0; } $output .= '<input type="hidden" class="checkbox aq-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="0"/>'; $output .= '<input type="checkbox" class="checkbox of-input" name="' . $value['id'] . '" id="' . $value['id'] . '" value="1" ' . checked($data[$value['id']], 1, false) . ' />'; break; case 'multicheck': $multi_stored = $data[$value['id']]; foreach ($value['options'] as $key => $option) { if (!isset($multi_stored[$key])) { $multi_stored[$key] = ''; } $of_key_string = $value['id'] . '_' . $key; $output .= '<input type="checkbox" class="checkbox of-input" name="' . $value['id'] . '[' . $key . ']' . '" id="' . $of_key_string . '" value="1" ' . checked($multi_stored[$key], 1, false) . ' /><label class="multicheck" for="' . $of_key_string . '">aaaa' . $option . '</label><br />'; } break; case 'upload': if (!isset($value['mod'])) { $value['mod'] = ''; } $output .= Options_Machine::optionsframework_uploader_function($value['id'], $value['std'], $value['mod']); break; case 'media': $_id = strip_tags(strtolower($value['id'])); $int = ''; $int = optionsframework_mlu_get_silentpost($_id); if (!isset($value['mod'])) { $value['mod'] = ''; } $output .= Options_Machine::optionsframework_media_uploader_function($value['id'], $value['std'], $int, $value['mod']); // New AJAX Uploader using Media Library break; case 'color': $output .= '<div id="' . $value['id'] . '_picker" class="colorSelector"><div style="background-color: ' . $data[$value['id']] . '"></div></div>'; $output .= '<input class="of-color" name="' . $value['id'] . '" id="' . $value['id'] . '" type="text" value="' . $data[$value['id']] . '" />'; break; case 'typography': $typography_stored = $data[$value['id']]; /* Font Size */ if (isset($typography_stored['size'])) { $output .= '<div class="select_wrapper typography-size" original-title="Font size">'; $output .= '<select class="of-typography of-typography-size select" name="' . $value['id'] . '[size]" id="' . $value['id'] . '_size">'; for ($i = 9; $i < 20; $i++) { $test = $i . 'px'; $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['size'], $test, false) . '>' . $i . 'px</option>'; } $output .= '</select></div>'; } /* Line Height */ if (isset($typography_stored['height'])) { $output .= '<div class="select_wrapper typography-height" original-title="Line height">'; $output .= '<select class="of-typography of-typography-height select" name="' . $value['id'] . '[height]" id="' . $value['id'] . '_height">'; for ($i = 20; $i < 38; $i++) { $test = $i . 'px'; $output .= '<option value="' . $i . 'px" ' . selected($typography_stored['height'], $test, false) . '>' . $i . 'px</option>'; } $output .= '</select></div>'; } /* Font Face */ if (isset($typography_stored['face'])) { $output .= '<div class="select_wrapper typography-face" original-title="Font family">'; $output .= '<select class="of-typography of-typography-face select" name="' . $value['id'] . '[face]" id="' . $value['id'] . '_face">'; $faces = array('arial' => 'Arial', 'verdana' => 'Verdana, Geneva', 'trebuchet' => 'Trebuchet', 'georgia' => 'Georgia', 'times' => 'Times New Roman', 'tahoma' => 'Tahoma, Geneva', 'palatino' => 'Palatino', 'helvetica' => 'Helvetica'); foreach ($faces as $i => $face) { $output .= '<option value="' . $i . '" ' . selected($typography_stored['face'], $i, false) . '>' . $face . '</option>'; } $output .= '</select></div>'; } /* Font Weight */ if (isset($typography_stored['style'])) { $output .= '<div class="select_wrapper typography-style" original-title="Font style">'; $output .= '<select class="of-typography of-typography-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">'; $styles = array('normal' => 'Normal', 'italic' => 'Italic', 'bold' => 'Bold', 'bold italic' => 'Bold Italic'); foreach ($styles as $i => $style) { $output .= '<option value="' . $i . '" ' . selected($typography_stored['style'], $i, false) . '>' . $style . '</option>'; } $output .= '</select></div>'; } /* Font Color */ if (isset($typography_stored['color'])) { $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector typography-color"><div style="background-color: ' . $typography_stored['color'] . '"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" original-title="Font color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $typography_stored['color'] . '" />'; } break; case 'border': /* Border Width */ $border_stored = $data[$value['id']]; $output .= '<div class="select_wrapper border-width">'; $output .= '<select class="of-border of-border-width select" name="' . $value['id'] . '[width]" id="' . $value['id'] . '_width">'; for ($i = 0; $i < 21; $i++) { $output .= '<option value="' . $i . '" ' . selected($border_stored['width'], $i, false) . '>' . $i . '</option>'; } $output .= '</select></div>'; /* Border Style */ $output .= '<div class="select_wrapper border-style">'; $output .= '<select class="of-border of-border-style select" name="' . $value['id'] . '[style]" id="' . $value['id'] . '_style">'; $styles = array('none' => 'None', 'solid' => 'Solid', 'dashed' => 'Dashed', 'dotted' => 'Dotted'); foreach ($styles as $i => $style) { $output .= '<option value="' . $i . '" ' . selected($border_stored['style'], $i, false) . '>' . $style . '</option>'; } $output .= '</select></div>'; /* Border Color */ $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div style="background-color: ' . $border_stored['color'] . '"></div></div>'; $output .= '<input class="of-color of-border of-border-color" name="' . $value['id'] . '[color]" id="' . $value['id'] . '_color" type="text" value="' . $border_stored['color'] . '" />'; break; case 'images': $i = 0; $select_value = $data[$value['id']]; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if (NULL != checked($select_value, $key, false)) { $checked = checked($select_value, $key, false); $selected = 'of-radio-img-selected'; } $output .= '<span>'; $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="' . $key . '" name="' . $value['id'] . '" ' . $checked . ' />'; $output .= '<div class="of-radio-img-label">' . $key . '</div>'; $output .= '<img src="' . $option . '" alt="" class="of-radio-img-img ' . $selected . '" onClick="document.getElementById(\'of-radio-img-' . $value['id'] . $i . '\').checked = true;" />'; $output .= '</span>'; } break; case "info": $info_text = $value['std']; $output .= '<div class="of-info">' . $info_text . '</div>'; break; case "image": $src = $value['std']; $output .= '<img src="' . $src . '">'; break; case 'heading': if ($counter >= 2) { $output .= '</div>' . "\n"; } $header_class = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name'])); $jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name'])); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '<li class="' . $header_class . '"><a title="' . $value['name'] . '" href="#' . $jquery_click_hook . '">' . $value['name'] . '</a></li>'; $output .= '<div class="group" id="' . $jquery_click_hook . '"><h2>' . $value['name'] . '</h2>' . "\n"; break; case 'slider': $_id = strip_tags(strtolower($value['id'])); $int = ''; $int = optionsframework_mlu_get_silentpost($_id); $output .= '<div class="slider"><ul id="' . $value['id'] . '" rel="' . $int . '">'; $slides = $data[$value['id']]; $count = count($slides); if ($count < 2) { $oldorder = 1; $order = 1; $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order, $int); } else { $i = 0; foreach ($slides as $slide) { $oldorder = $slide['order']; $i++; $order = $i; $output .= Options_Machine::optionsframework_slider_function($value['id'], $value['std'], $oldorder, $order, $int); } } $output .= '</ul>'; $output .= '<a href="#" class="button slide_add_button">Add New Slide</a></div>'; break; case 'sorter': $sortlists = $data[$value['id']]; $output .= '<div id="' . $value['id'] . '" class="sorter">'; if ($sortlists) { foreach ($sortlists as $group => $sortlist) { $output .= '<ul id="' . $value['id'] . '_' . $group . '" class="sortlist_' . $value['id'] . '">'; $output .= '<h3>' . $group . '</h3>'; foreach ($sortlist as $key => $list) { $output .= '<input class="sorter-placebo" type="hidden" name="' . $value['id'] . '[' . $group . '][placebo]" value="placebo">'; if ($key != "placebo") { $output .= '<li id="' . $key . '" class="sortee">'; $output .= '<input class="position" type="hidden" name="' . $value['id'] . '[' . $group . '][' . $key . ']" value="' . $list . '">'; $output .= $list; $output .= '</li>'; } } $output .= '</ul>'; } } $output .= '</div>'; break; case 'tiles': $i = 0; $select_value = ''; $select_value = $data[$value['id']]; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if (NULL != checked($select_value, $option, false)) { $checked = checked($select_value, $option, false); $selected = 'of-radio-tile-selected'; } $output .= '<span>'; $output .= '<input type="radio" id="of-radio-tile-' . $value['id'] . $i . '" class="checkbox of-radio-tile-radio" value="' . $option . '" name="' . $value['id'] . '" ' . $checked . ' />'; $output .= '<div class="of-radio-tile-img ' . $selected . '" style="background: url(' . $option . ')" onClick="document.getElementById(\'of-radio-tile-' . $value['id'] . $i . '\').checked = true;"></div>'; $output .= '</span>'; } break; // Background // Background case 'background': $background = $data[$value['id']]; // Background Color $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $output .= '</select>'; // Background Position $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $output .= '</select>'; // Background Attachment $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $output .= '</select>'; $output .= '</div>'; break; case 'backup': $instructions = $value['options']; $backup = get_option(BACKUPS); if (!isset($backup['backup_log'])) { $log = 'No backups yet'; } else { $log = $backup['backup_log']; } $output .= '<div class="backup-box">'; $output .= '<div class="instructions">' . $instructions . "\n"; $output .= '<p><strong>' . __('Last Backup : ') . '<span class="backup-log">' . $log . '</span></strong></p></div>' . "\n"; $output .= '<a href="#" id="of_backup_button" class="button" title="Backup Options">Backup Options</a>'; $output .= '<a href="#" id="of_restore_button" class="button" title="Restore Options">Restore Options</a>'; $output .= '</div>'; break; } // if TYPE is an array, formatted into smaller inputs... ie smaller values if (is_array($value['type'])) { foreach ($value['type'] as $array) { $id = $array['id']; $std = $array['std']; $saved_std = get_option($id); if ($saved_std != $std) { $std = $saved_std; } $meta = $array['meta']; if ($array['type'] == 'text') { // Only text at this point $output .= '<input class="input-text-small of-input" name="' . $id . '" id="' . $id . '" type="text" value="' . $std . '" />'; $output .= '<span class="meta-two">' . $meta . '</span>'; } } } if ($value['type'] != 'heading') { if (!isset($value['desc'])) { $explain_value = ''; } else { $explain_value = '<div class="explain">' . $value['desc'] . '</div>' . "\n"; } $output .= '</div>' . $explain_value . "\n"; $output .= '<div class="clear"> </div></div></div>' . "\n"; } } $output .= '</div>'; return array($output, $menu, $defaults); }
/** * Generates the options fields that are used in the form. */ static function optionsframework_fields() { global $allowedtags; $optionsframework_settings = get_option(ONETONE_OPTIONS_PREFIXED . 'optionsframework'); // Gets the unique option id if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = ONETONE_OPTIONS_PREFIXED . 'optionsframework'; } $settings = get_option($option_name); $options =& Options_Framework::_optionsframework_options(); $counter = 0; $menu = ''; foreach ($options as $value) { $val = ''; $select_value = ''; $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, override $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']; } if (has_filter('optionsframework_' . $value['type'])) { $output .= apply_filters('optionsframework_' . $value['type'], $option_name, $value, $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) { $output .= '<option' . selected($val, $key, false) . ' 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 = ''; if ($val != '' && $val == $key) { $selected = ' of-radio-img-selected'; } $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . checked($val, $key, false) . ' />'; $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 .= Options_Framework_Media_Uploader::optionsframework_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 if (!isset($background['image'])) { $background['image'] = ''; } $output .= Options_Framework_Media_Uploader::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' => true, 'tinymce' => array('plugins' => 'wordpress')); $editor_settings = array(); if (isset($value['settings'])) { $editor_settings = $value['settings']; } $editor_settings = array_merge($default_editor_settings, $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": $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 . '">'; $output .= '<h3>' . esc_html($value['name']) . '</h3>' . "\n"; break; case "start_group": $class = ''; $class = !empty($value['id']) ? $value['id'] : $value['name']; $output .= '<div class="tab_item_group ' . $class . '">'; break; case "end_group": $output .= '</div>'; break; case "title": $output .= '<div class="group_title' . $class . '"></div>'; break; } if ($value['type'] != "heading" && $value['type'] != "info") { $output .= '</div>'; if ($value['type'] != "checkbox" && $value['type'] != "editor") { $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n"; } $output .= '</div></div>' . "\n"; } echo $output; } // Outputs closing div if there tabs if (Options_Framework_Interface::optionsframework_tabs() != '') { echo '</div>'; } }
public function html() { $background = $this->val; // Background Color $this->output .= '<div id="' . esc_attr($this->value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>'; $this->output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][color]') . '" id="' . esc_attr($this->value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />'; // Background Image - New AJAX Uploader using Media Library if (!isset($background['image'])) { $background['image'] = ''; } $this->output .= optionsframework_medialibrary_uploader($this->value['id'], $background['image'], null, '', 0, 'image'); $class = 'of-background-properties'; if ('' == $background['image']) { $class .= ' hide'; } $this->output .= '<div class="' . esc_attr($class) . '">'; // Background Repeat $this->output .= '<select class="of-background of-background-repeat" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][repeat]') . '" id="' . esc_attr($this->value['id'] . '_repeat') . '">'; $repeats = of_recognized_background_repeat(); foreach ($repeats as $key => $repeat) { $this->output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>'; } $this->output .= '</select>'; // Background Position $this->output .= '<select class="of-background of-background-position" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][position]') . '" id="' . esc_attr($this->value['id'] . '_position') . '">'; $positions = of_recognized_background_position(); foreach ($positions as $key => $position) { $this->output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>'; } $this->output .= '</select>'; // Background Attachment $this->output .= '<select class="of-background of-background-attachment" name="' . esc_attr($this->option_name . '[' . $this->value['id'] . '][attachment]') . '" id="' . esc_attr($this->value['id'] . '_attachment') . '">'; $attachments = of_recognized_background_attachment(); foreach ($attachments as $key => $attachment) { $this->output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>'; } $this->output .= '</select>'; $this->output .= '</div>'; return $this->output; }