本文整理汇总了PHP中_optionsframework_options函数的典型用法代码示例。如果您正苦于以下问题:PHP _optionsframework_options函数的具体用法?PHP _optionsframework_options怎么用?PHP _optionsframework_options使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_optionsframework_options函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optionsframework_fields
/**
* Generates the options fields that are used in the form.
*/
function optionsframework_fields()
{
global $allowedtags;
$optionsframework_settings = get_option('optionsframework');
// Gets the unique option id
if (isset($optionsframework_settings['id'])) {
$option_name = $optionsframework_settings['id'];
} else {
$option_name = 'optionsframework';
}
$settings = get_option($option_name);
$options =& _optionsframework_options();
$counter = 0;
$menu = '';
foreach ($options as $value) {
$counter++;
$val = '';
$select_value = '';
$checked = '';
$output = '';
// Wrap all options
if ($value['type'] != "heading" && $value['type'] != "info") {
// Keep all ids lowercase with no spaces
$value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id']));
$id = 'section-' . $value['id'];
$class = 'section ';
if (isset($value['type'])) {
$class .= ' section-' . $value['type'];
}
if (isset($value['class'])) {
$class .= ' ' . $value['class'];
}
$output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n";
if (isset($value['name'])) {
$output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
}
if ($value['type'] != 'editor') {
$output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
} else {
$output .= '<div class="option">' . "\n" . '<div>' . "\n";
}
}
// Set default value to $val
if (isset($value['std'])) {
$val = $value['std'];
}
// If the option is already saved, ovveride $val
if ($value['type'] != 'heading' && $value['type'] != 'info') {
if (isset($settings[$value['id']])) {
$val = $settings[$value['id']];
// Striping slashes of non-array options
if (!is_array($val)) {
$val = stripslashes($val);
}
}
}
// If there is a description save it for labels
$explain_value = '';
if (isset($value['desc'])) {
$explain_value = $value['desc'];
}
switch ($value['type']) {
// Basic text input
case 'text':
$output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />';
break;
// Password input
// Password input
case 'password':
$output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="password" value="' . esc_attr($val) . '" />';
break;
// Textarea
// Textarea
case 'textarea':
$rows = '8';
if (isset($value['settings']['rows'])) {
$custom_rows = $value['settings']['rows'];
if (is_numeric($custom_rows)) {
$rows = $custom_rows;
}
}
$val = stripslashes($val);
$output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" rows="' . $rows . '">' . esc_textarea($val) . '</textarea>';
break;
// Select Box
// Select Box
case $value['type'] == 'select':
$output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">';
foreach ($value['options'] as $key => $option) {
$selected = '';
if ($val != '') {
if ($val == $key) {
$selected = ' selected="selected"';
}
}
$output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>';
}
//.........这里部分代码省略.........
示例2: of_get_default_values
/**
* Format Configuration Array.
*
* Get an array of all default values as set in
* options.php. The 'id','std' and 'type' keys need
* to be defined in the configuration array. In the
* event that these keys are not present the option
* will not be included in this function's output.
*
* @return array Rey-keyed options configuration array.
*
* @access private
*/
function of_get_default_values()
{
$output = array();
$config =& _optionsframework_options();
foreach ((array) $config as $option) {
if (!isset($option['id'])) {
continue;
}
if (!isset($option['std'])) {
continue;
}
if (!isset($option['type'])) {
continue;
}
if (has_filter('of_sanitize_' . $option['type'])) {
$output[$option['id']] = apply_filters('of_sanitize_' . $option['type'], $option['std'], $option);
}
}
return $output;
}
示例3: optionsframework_fields
/**
* Generates the options fields that are used in the form.
*/
function optionsframework_fields()
{
global $allowedtags;
$optionsframework_settings = get_option('optionsframework');
// Get the theme name so we can display it up top
$themename = get_theme_data(STYLESHEETPATH . '/style.css');
$themename = $themename['Name'];
// Gets the unique option id
if (isset($optionsframework_settings['id'])) {
$option_name = $optionsframework_settings['id'];
} else {
$option_name = 'optionsframework';
}
$settings = get_option($option_name);
$options =& _optionsframework_options();
$counter = 0;
$menu = '';
$output = '';
foreach ($options as $value) {
$counter++;
$val = '';
$select_value = '';
$checked = '';
// Wrap all options
if ($value['type'] != "heading" && $value['type'] != "info") {
// Keep all ids lowercase with no spaces
$value['id'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($value['id']));
$id = 'section-' . $value['id'];
$class = 'section ';
if (isset($value['type'])) {
$class .= ' section-' . $value['type'];
}
if (isset($value['class'])) {
$class .= ' ' . $value['class'];
}
$output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n";
$output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
$output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
}
// Set default value to $val
if (isset($value['std'])) {
$val = $value['std'];
}
// If the option is already saved, ovveride $val
if ($value['type'] != 'heading' && $value['type'] != 'info') {
if (isset($settings[$value['id']])) {
$val = $settings[$value['id']];
// Striping slashes of non-array options
if (!is_array($val)) {
$val = stripslashes($val);
}
}
}
// If there is a description save it for labels
$explain_value = '';
if (isset($value['desc'])) {
$explain_value = $value['desc'];
}
switch ($value['type']) {
// Basic text input
case 'text':
$output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '" />';
break;
// Textarea
// Textarea
case 'textarea':
$cols = '8';
$ta_value = '';
if (isset($value['options'])) {
$ta_options = $value['options'];
if (isset($ta_options['cols'])) {
$cols = $ta_options['cols'];
} else {
$cols = '8';
}
}
$val = stripslashes($val);
$output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="8">' . esc_textarea($val) . '</textarea>';
break;
// Select Box
// Select Box
case $value['type'] == 'select':
$output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">';
foreach ($value['options'] as $key => $option) {
$selected = '';
if ($val != '') {
if ($val == $key) {
$selected = ' selected="selected"';
}
}
$output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>';
}
$output .= '</select>';
break;
// Radio Box
// Radio Box
case "radio":
//.........这里部分代码省略.........
示例4: optionsframework_fields
/**
* 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>';
//.........这里部分代码省略.........
示例5: of_get_default_values
/**
* Format Configuration Array.
*
* Get an array of all default values as set in
* options.php. The 'id','std' and 'type' keys need
* to be defined in the configuration array. In the
* event that these keys are not present the option
* will not be included in this function's output.
*
* @return array Rey-keyed options configuration array.
*
* @access private
*/
function of_get_default_values($page = null)
{
$output = $preset = $saved_options = array();
$config =& _optionsframework_options();
$known_options = get_option('optionsframework', array());
$tmp_options = get_option($known_options['id'], array());
$first_run = false;
// If this is first run - use one of preset
if (empty($tmp_options)) {
$tmp_options['preset'] = apply_filters('options_framework_first_run_skin', '');
$first_run = true;
}
// If this is preset page - restore it's defaults
if (isset($tmp_options['preset'])) {
// Get preset options
$preset = optionsframework_presets_data($tmp_options['preset']);
// if preset not set - set it
if (!isset($preset['preset'])) {
$preset['preset'] = $tmp_options['preset'];
}
// For first run preserve some options
if ($first_run) {
$preserve = array('widgetareas', 'bottom_bar-copyrights', 'bottom_bar-credits', 'social_buttons-post', 'social_buttons-portfolio', 'social_buttons-albums', 'general-tracking_code', 'general-favicon', 'general-wysiwig_visual_columns');
foreach ($preserve as $option) {
if (isset($preset[$option])) {
unset($preset[$option]);
}
}
}
}
// Current page defaults
if ($page) {
$arr = array();
$found = null;
// Find Page options
foreach ($config as $option) {
if ('options-framework' == $page && null === $found) {
$found = true;
} elseif (isset($option['type']) && 'page' == $option['type'] && $option['menu_slug'] == $page) {
$found = true;
continue;
} elseif (isset($option['type']) && 'page' == $option['type']) {
$found = false;
}
if ($found) {
$arr[] = $option;
}
}
$config = $arr;
$saved_options = $tmp_options;
}
foreach ((array) $config as $option) {
if (!isset($option['id'])) {
continue;
}
if (!isset($option['std'])) {
continue;
}
if (!isset($option['type'])) {
continue;
}
if (has_filter('of_sanitize_' . $option['type'])) {
$value = $option['std'];
// Use defaults from preset if it's present
if (isset($preset[$option['id']])) {
$preset_value = $preset[$option['id']];
if ('upload' == $option['type'] && isset($option['mode']) && 'full' == $option['mode']) {
$preset_value = array_reverse($preset_value);
}
$value = $preset_value;
}
$output[$option['id']] = apply_filters('of_sanitize_' . $option['type'], $value, $option);
}
}
$output = array_merge($saved_options, $output);
return $output;
}
示例6: sanitize_options
protected static function sanitize_options($used_options, $defaults = array())
{
// Use all options for sanitazing.
$options =& _optionsframework_options();
$clean = array();
foreach ($options as $option) {
if (!isset($option['id'], $option['type'])) {
continue;
}
$id = preg_replace('/(\\W!-)/', '', strtolower($option['id']));
// Set checkbox to false if it wasn't sent in the $_POST.
if ('checkbox' == $option['type'] && !isset($used_options[$id])) {
$used_options[$id] = false;
}
// Set each item in the multicheck to false if it wasn't sent in the $_POST.
if ('multicheck' == $option['type'] && !isset($used_options[$id])) {
foreach ($option['options'] as $key => $value) {
$used_options[$id][$key] = false;
}
}
// Override defaults.
if (isset($defaults[$id])) {
$option['std'] = $defaults[$id];
}
if (!isset($used_options[$id])) {
continue;
}
if ('upload' == $option['type'] && is_array($used_options[$id]) && isset($used_options[$id][1]) && is_numeric($used_options[$id][1])) {
$used_options[$id] = array_reverse($used_options[$id]);
}
// For a value to be submitted to database it must pass through a sanitization filter.
if (!empty($option['sanitize']) && has_filter('of_sanitize_' . $option['sanitize'])) {
$clean[$id] = apply_filters('of_sanitize_' . $option['sanitize'], $used_options[$id], $option);
} elseif (has_filter('of_sanitize_' . $option['type'])) {
$clean[$id] = apply_filters('of_sanitize_' . $option['type'], $used_options[$id], $option);
}
}
return $clean;
}
示例7: import_theme_options
public function import_theme_options($input = array())
{
// update import status
// update_option( $this->import_status_slug, 'imported' );
$of_options = get_option('optionsframework');
$the7_options = get_option('the7');
$current_theme_options = $input;
$options_fields =& _optionsframework_options();
$options_intersect = array_intersect_key($the7_options, $current_theme_options);
unset($options_intersect['preset']);
$options_intersect_keys = array_keys($options_intersect);
foreach ($options_fields as $option_field) {
if (empty($option_field['id']) || !in_array($option_field['id'], $options_intersect_keys)) {
continue;
}
$option_id = $option_field['id'];
$intersect_value = $options_intersect[$option_id];
$current_theme_value = $current_theme_options[$option_id];
switch ($option_field['type']) {
case 'radio':
$radio_options = array_keys($option_field['options']);
if (!in_array($intersect_value, $radio_options)) {
$options_intersect[$option_id] = $current_theme_value;
}
break;
case 'background_img':
if (!dt_maybe_uploaded_image_url($intersect_value['image'])) {
$options_intersect[$option_id]['image'] = $current_theme_value['image'];
}
break;
case 'upload':
if ($intersect_value) {
if (is_array($intersect_value) && dt_maybe_uploaded_image_url($intersect_value[0])) {
$options_intersect[$option_id] = $intersect_value;
} else {
if (!is_array($intersect_value) && dt_maybe_uploaded_image_url($intersect_value)) {
$options_intersect[$option_id] = $intersect_value;
} else {
$options_intersect[$option_id] = $current_theme_value;
}
}
}
break;
}
}
$current_theme_options = array_merge($current_theme_options, $options_intersect);
return apply_filters('presscore_compatibility_import_theme_options', $current_theme_options, $the7_options);
}
示例8: import_theme_options
//.........这里部分代码省略.........
break;
case 'transparent_bg_line':
$the72_options['footer-bg_color'] = $the72_options['footer-primary_text_color'];
$the72_options['footer-bg_opacity'] = '8';
$the72_options['footer-style'] = 'solid_background';
$the72_options['footer-decoration'] = 'none';
break;
case 'solid_background':
$the72_options['footer-bg_opacity'] = '100';
break;
}
switch ($the72_options['bottom_bar-style']) {
case 'content_width_line':
case 'full_width_line':
$the72_options['bottom_bar-bg_color'] = $the72_options['footer-primary_text_color'];
$the72_options['bottom_bar-bg_opacity'] = '15';
break;
case 'solid_background':
$the72_options['bottom_bar-bg_opacity'] = '100';
break;
}
// Page title.
$the72_options['page_title-padding-top'] = $the72_options['page_title-padding-bottom'] = '0';
$the72_options['general-title_decoration'] = 'none';
switch ($the72_options['general-title_bg_mode']) {
case 'transparent_bg':
$the72_options['general-title_bg_mode'] = 'background';
$the72_options['header-background'] = 'normal';
$the72_options['general-title_bg_color'] = $the72_options['content-primary_text_color'];
$the72_options['general-title_bg_opacity'] = '8';
$the72_options['general-title_bg_parallax'] = '';
$the72_options['general-title_bg_image'] = array('image' => '', 'repeat' => 'repeat', 'position_x' => 'center', 'position_y' => 'center');
break;
case 'gradient':
case 'background':
$the72_options['general-title_bg_opacity'] = '100';
if ('transparent' == $the72_options['header-background'] && 'disabled' == $the72_options['header-style']) {
$the72_options['header-transparent_bg_opacity'] = '0';
}
break;
}
if (in_array($the72_options['header-menu_top_bar_color_mode'], array('theme', 'dark'))) {
$the72_options['page_title-background-style-transparent-color_scheme'] = 'from_options';
}
// Buttons.
$the72_options['buttons-hover_color_mode'] = $the72_options['buttons-color_mode'];
$the72_options['buttons-hover_color'] = $the72_options['buttons-color'];
$the72_options['buttons-hover_color_gradient'] = $the72_options['buttons-color_gradient'];
$the72_options['buttons-text_hover_color_mode'] = $preset_options['buttons-text_color_mode'];
$the72_options['buttons-text_hover_color'] = $preset_options['buttons-text_color'];
// Image hovers.
$the72_options['image_hover-project_rollover_color_mode'] = $the72_options['image_hover-color_mode'];
$the72_options['image_hover-project_rollover_color'] = $the72_options['image_hover-color'];
$the72_options['image_hover-project_rollover_color_gradient'] = $the72_options['image_hover-color_gradient'];
$the72_options['image_hover-project_rollover_opacity'] = $the72_options['image_hover-opacity'];
$the72_options['image_hover-default_icon'] = 'none' == $the72_options['image_hover-default_icon'] ? 'none' : 'big_center';
switch ($the72_options['general-style']) {
case 'ios7':
$the72_options['general-filter_style'] = $the72_options['general-contact_form_style'] = 'ios';
break;
case 'minimalistic':
$the72_options['image_hover-project_icons_style'] = 'transparent';
$the72_options['image_hover-album_miniatures_style'] = 'style_1';
$the72_options['general-filter_style'] = $the72_options['general-contact_form_style'] = 'minimal';
break;
case 'material':
$the72_options['image_hover-project_icons_style'] = 'small';
$the72_options['image_hover-album_miniatures_style'] = 'style_2';
$the72_options['general-filter_style'] = $the72_options['general-contact_form_style'] = 'material';
break;
}
// Filted style.
$the72_options['general-filter-font-family'] = $the72_options['fonts-font_family'];
$the72_options['general-filter_ucase'] = '0';
$the72_options['general-filter-padding-top'] = '8';
$the72_options['general-filter-padding-right'] = '13';
$the72_options['general-filter-padding-bottom'] = '8';
$the72_options['general-filter-padding-left'] = '13';
$the72_options['general-filter-margin-top'] = '0';
$the72_options['general-filter-margin-right'] = '5';
$the72_options['general-filter-margin-bottom'] = '0';
$the72_options['general-filter-margin-left'] = '0';
// Beautiful loading.
if ('accent' == $the72_options['general-beautiful_loading']) {
$the72_options['general-fullscreen_overlay_color_mode'] = 'accent';
$the72_options['general-spinner_color'] = '#ffffff';
}
$the72_options['general-beautiful_loading'] = 'disabled' == $the72_options['general-beautiful_loading'] ? 'disabled' : 'enabled';
// Sidebar.
$the72_options['sidebar-bg_opacity'] = '100';
$merged_options = array_merge($preset_options, $the72_options);
// Validate options.
$options_fields =& _optionsframework_options();
foreach ($options_fields as $option_field) {
if (isset($option_field['id']) && !array_key_exists($option_field['id'], $merged_options)) {
unset($merged_options[$option_field['id']]);
}
}
return apply_filters('presscore_compatibility_import_theme_options', $merged_options);
}
示例9: _optionsframework_get_clean_options
/**
* Return array with actual theme options.
*
* @return mixed
*/
function _optionsframework_get_clean_options()
{
if (false === ($clean_options = get_transient('optionsframework_clean_options'))) {
$options =& _optionsframework_options();
$clean_options = array();
foreach ($options as $option) {
if (isset($option['id'], $option['type'])) {
$clean_options[$option['id']] = $option;
}
}
set_transient('optionsframework_clean_options', $clean_options, 60);
}
return $clean_options;
}