* @license GPL-2.0+ * @link http://wptheming.com * @copyright 2010-2014 WP Theming */ class Options_Framework_Interface { /** * Generates the tabs that are used in the options menu */ public static function optionsframework_tabs() { $counter = 0; $options = &Options_Framework::_optionsframework_options(); $menu = ''; foreach ($options as $value) { // Heading for Navigation if ($value['type'] == "heading") { $counter++; $class = ''; $class = !empty($value['id']) ? $value['id'] : $value['name']; $class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class)) . '-tab'; $menu .= '' . esc_html($value['name']) . ''; } } return $menu; } /** * Generates the options fields that are used in the form. */ public 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'] != "about")) { // 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 .= '
' . "\n"; if (isset($value['name'])) { $output .= '

' . esc_html($value['name']) . '

' . "\n"; } if ($value['type'] != 'editor') { $output .= '
' . "\n" . '
' . "\n"; } else { $output .= '
' . "\n" . '
' . "\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'] != "about")) { 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 .= ''; break; // Password input case 'password': $output .= ''; break; // 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 .= ''; break; // Select Box case 'select': $output .= ''; break; // Radio Box case "radio": $name = $option_name . '[' . $value['id'] . ']'; foreach ($value['options'] as $key => $option) { $id = $option_name . '-' . $value['id'] . '-' . $key; $output .= ''; } break; // 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 .= ''; $output .= '
' . esc_html($key) . '
'; $output .= '' . $option . ''; } break; // Checkbox case "checkbox": $output .= ''; $output .= ''; break; // Color picker case "color": $default_color = ''; if (isset($value['std'])) { if ($val != $value['std']) { $default_color = ' data-default-color="' . $value['std'] . '" '; } } $output .= ''; break; // Uploader case "upload": $output .= Options_Framework_Media_Uploader::optionsframework_uploader($value['id'], $val, null); break; 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 .= '
' . "\n"; if (isset($value['name'])) { $output .= '

' . esc_html($value['name']) . '

' . "\n"; } if (isset($value['desc'])) { $output .= $value['desc'] . "\n"; } $output .= '
' . "\n"; break; case "about": global $wp_version; $version = $wp_version; $output .= '

' . __('基础信息', 'kratos') . '

  • ' . __('PHP 版本:', 'kratos') . PHP_VERSION . '
  • ' . __('Kratos 版本:', 'kratos') . THEME_VERSION . '
  • ' . __('WordPress 版本:', 'kratos') . $version . '
  • ' . __('User Agent 信息:', 'kratos') . $_SERVER['HTTP_USER_AGENT'] . '

' . __('提示:在提交主题相关问题反馈时,请将上面「基础信息」中的内容复制到环境信息中。', 'kratos') . '

' . __('资料文档', 'kratos') . '

' . __('讨论交流', 'kratos') . '

' . __('版权声明', 'kratos') . '

' . __('主题源码使用 MIT 协议 进行许可,说明文档使用 CC BY-NC-ND 4.0 进行许可。', 'kratos') . '

' . __('打赏支持', 'kratos') . '

'; break; case "sendmail": $output .= ''; break; // Heading for Navigation case "heading": $counter++; if ($counter >= 2) { $output .= '
' . "\n"; } $class = ''; $class = !empty($value['id']) ? $value['id'] : $value['name']; $class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class)); $output .= '
'; $output .= '

' . esc_html($value['name']) . '

' . "\n"; break; } if (($value['type'] != "heading") && ($value['type'] != "info") && ($value['type'] != "about")) { $output .= '
'; if (($value['type'] != "checkbox") && ($value['type'] != "editor")) { $output .= '
' . wp_kses($explain_value, $allowedtags) . '
' . "\n"; } $output .= '
' . "\n"; } echo $output; } // Outputs closing div if there tabs if (Options_Framework_Interface::optionsframework_tabs() != '') { echo '
'; } } }