changing the radio inputs into select lists, code formatting cleanup
This commit is contained in:
@@ -2,28 +2,27 @@ jQuery.noConflict();
|
|||||||
|
|
||||||
jQuery(document).ready(function(){
|
jQuery(document).ready(function(){
|
||||||
|
|
||||||
var $main = jQuery('#main_class');
|
var $main = jQuery('#main_class');
|
||||||
var $sidebar = jQuery('#sidebar_class');
|
var $sidebar = jQuery('#sidebar_class');
|
||||||
var framework = jQuery('.roots_css_frameworks input:checked').val();
|
var framework = jQuery('.roots_css_frameworks select option:selected').val();
|
||||||
var user_main_class = $main.val();
|
var user_main_class = $main.val();
|
||||||
var user_sidebar_class = $sidebar.val();
|
var user_sidebar_class = $sidebar.val();
|
||||||
|
|
||||||
jQuery('.roots_css_frameworks input').change(function (e) {
|
jQuery('.roots_css_frameworks select').change(function (e) {
|
||||||
var main_class = roots_css_frameworks[this.value].classes.main;
|
var main_class = roots_css_frameworks[this.value].classes.main;
|
||||||
var sidebar_class = roots_css_frameworks[this.value].classes.sidebar;
|
var sidebar_class = roots_css_frameworks[this.value].classes.sidebar;
|
||||||
|
|
||||||
// if the selected framework was the one originally set, load the original classes instead of the defaults
|
// if the selected framework was the one originally set, load the original classes instead of the defaults
|
||||||
if (this.value === framework) {
|
if (this.value === framework) {
|
||||||
$main.val(user_main_class);
|
$main.val(user_main_class);
|
||||||
$sidebar.val(user_sidebar_class);
|
$sidebar.val(user_sidebar_class);
|
||||||
} else {
|
} else {
|
||||||
$main.val(main_class);
|
$main.val(main_class);
|
||||||
$sidebar.val(sidebar_class);
|
$sidebar.val(sidebar_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
$main.siblings('small').children().text(main_class);
|
$main.siblings('small').children().text(main_class);
|
||||||
$sidebar.siblings('small').children().text(sidebar_class);
|
$sidebar.siblings('small').children().text(sidebar_class);
|
||||||
|
});
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function roots_theme_options_add_page() {
|
|||||||
__('Theme Options', 'roots'),
|
__('Theme Options', 'roots'),
|
||||||
'edit_theme_options',
|
'edit_theme_options',
|
||||||
'theme_options',
|
'theme_options',
|
||||||
'theme_options_render_page'
|
'roots_theme_options_render_page'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$theme_page)
|
if (!$theme_page)
|
||||||
@@ -45,104 +45,104 @@ add_action('admin_menu', 'roots_theme_options_add_page');
|
|||||||
|
|
||||||
global $roots_css_frameworks;
|
global $roots_css_frameworks;
|
||||||
$roots_css_frameworks = array(
|
$roots_css_frameworks = array(
|
||||||
'blueprint' => array(
|
'blueprint' => array(
|
||||||
'name' => 'blueprint',
|
'name' => 'blueprint',
|
||||||
'label' => __('Blueprint CSS', 'roots'),
|
'label' => __('Blueprint CSS', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'span-24',
|
'container' => 'span-24',
|
||||||
'main' => 'span-14 append-1',
|
'main' => 'span-14 append-1',
|
||||||
'sidebar' => 'span-8 prepend-1 last'
|
'sidebar' => 'span-8 prepend-1 last'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'960gs_12' => array(
|
'960gs_12' => array(
|
||||||
'name' => '960gs_12',
|
'name' => '960gs_12',
|
||||||
'label' => __('960gs (12 cols)', 'roots'),
|
'label' => __('960gs (12 cols)', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_12',
|
'container' => 'container_12',
|
||||||
'main' => 'grid_7 suffix_1',
|
'main' => 'grid_7 suffix_1',
|
||||||
'sidebar' => 'grid_4'
|
'sidebar' => 'grid_4'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'960gs_16' => array(
|
'960gs_16' => array(
|
||||||
'name' => '960gs_16',
|
'name' => '960gs_16',
|
||||||
'label' => __('960gs (16 cols)', 'roots'),
|
'label' => __('960gs (16 cols)', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_16',
|
'container' => 'container_16',
|
||||||
'main' => 'grid_9 suffix_1',
|
'main' => 'grid_9 suffix_1',
|
||||||
'sidebar' => 'grid_6'
|
'sidebar' => 'grid_6'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'960gs_24' => array(
|
'960gs_24' => array(
|
||||||
'name' => '960gs_24',
|
'name' => '960gs_24',
|
||||||
'label' => __('960gs (24 cols)', 'roots'),
|
'label' => __('960gs (24 cols)', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_24',
|
'container' => 'container_24',
|
||||||
'main' => 'grid_15 suffix_1',
|
'main' => 'grid_15 suffix_1',
|
||||||
'sidebar' => 'grid_8'
|
'sidebar' => 'grid_8'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'1140' => array(
|
'1140' => array(
|
||||||
'name' => '1140',
|
'name' => '1140',
|
||||||
'label' => __('1140', 'roots'),
|
'label' => __('1140', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container',
|
'container' => 'container',
|
||||||
'main' => 'sevencol',
|
'main' => 'sevencol',
|
||||||
'sidebar' => 'fourcol last'
|
'sidebar' => 'fourcol last'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'adapt' => array(
|
'adapt' => array(
|
||||||
'name' => 'adapt',
|
'name' => 'adapt',
|
||||||
'label' => __('Adapt.js', 'roots'),
|
'label' => __('Adapt.js', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_12 clearfix',
|
'container' => 'container_12 clearfix',
|
||||||
'main' => 'grid_7 suffix_1',
|
'main' => 'grid_7 suffix_1',
|
||||||
'sidebar' => 'grid_4'
|
'sidebar' => 'grid_4'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'less' => array(
|
'less' => array(
|
||||||
'name' => 'less',
|
'name' => 'less',
|
||||||
'label' => __('Less Framework 4', 'roots'),
|
'label' => __('Less Framework 4', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container',
|
'container' => 'container',
|
||||||
'main' => '',
|
'main' => '',
|
||||||
'sidebar' => ''
|
'sidebar' => ''
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'none' => array(
|
'none' => array(
|
||||||
'name' => 'none',
|
'name' => 'none',
|
||||||
'label' => __('None', 'roots'),
|
'label' => __('None', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => '',
|
'container' => '',
|
||||||
'main' => '',
|
'main' => '',
|
||||||
'sidebar' => ''
|
'sidebar' => ''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Write the above array of CSS frameworks into a script tag
|
// Write the above array of CSS frameworks into a script tag
|
||||||
function roots_add_frameworks_object_script() {
|
function roots_add_frameworks_object_script() {
|
||||||
global $roots_css_frameworks;
|
global $roots_css_frameworks;
|
||||||
$json = json_encode($roots_css_frameworks);
|
$json = json_encode($roots_css_frameworks);
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
var roots_css_frameworks = <?php echo $json; ?>;
|
var roots_css_frameworks = <?php echo $json; ?>;
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
add_action('admin_head', 'roots_add_frameworks_object_script');
|
add_action('admin_head', 'roots_add_frameworks_object_script');
|
||||||
|
|
||||||
function roots_get_default_theme_options() {
|
function roots_get_default_theme_options() {
|
||||||
global $roots_css_frameworks;
|
global $roots_css_frameworks;
|
||||||
$default_framework = 'blueprint';
|
$default_framework = 'blueprint';
|
||||||
$default_framework_settings = $roots_css_frameworks[$default_framework];
|
$default_framework_settings = $roots_css_frameworks[$default_framework];
|
||||||
$default_theme_options = array(
|
$default_theme_options = array(
|
||||||
'css_framework' => $default_framework,
|
'css_framework' => $default_framework,
|
||||||
'container_class' => $default_framework_settings['classes']['container'],
|
'container_class' => $default_framework_settings['classes']['container'],
|
||||||
'main_class' => $default_framework_settings['classes']['main'],
|
'main_class' => $default_framework_settings['classes']['main'],
|
||||||
'sidebar_class' => $default_framework_settings['classes']['sidebar'],
|
'sidebar_class' => $default_framework_settings['classes']['sidebar'],
|
||||||
'google_analytics_id' => '',
|
'google_analytics_id' => '',
|
||||||
'clean_menu' => true,
|
'clean_menu' => true,
|
||||||
'fout_b_gone' => false
|
'fout_b_gone' => false
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters('roots_default_theme_options', $default_theme_options);
|
return apply_filters('roots_default_theme_options', $default_theme_options);
|
||||||
@@ -152,8 +152,8 @@ function roots_get_theme_options() {
|
|||||||
return get_option('roots_theme_options', roots_get_default_theme_options());
|
return get_option('roots_theme_options', roots_get_default_theme_options());
|
||||||
}
|
}
|
||||||
|
|
||||||
function theme_options_render_page() {
|
function roots_theme_options_render_page() {
|
||||||
global $roots_css_frameworks;
|
global $roots_css_frameworks;
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php screen_icon(); ?>
|
<?php screen_icon(); ?>
|
||||||
@@ -172,20 +172,11 @@ function theme_options_render_page() {
|
|||||||
<tr valign="top" class="radio-option"><th scope="row"><?php _e('CSS Grid Framework', 'roots'); ?></th>
|
<tr valign="top" class="radio-option"><th scope="row"><?php _e('CSS Grid Framework', 'roots'); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<fieldset class="roots_css_frameworks"><legend class="screen-reader-text"><span><?php _e('CSS Grid Framework', 'roots'); ?></span></legend>
|
<fieldset class="roots_css_frameworks"><legend class="screen-reader-text"><span><?php _e('CSS Grid Framework', 'roots'); ?></span></legend>
|
||||||
<?php
|
<select name="roots_theme_options[css_framework]" id="roots_theme_options[css_framework]">
|
||||||
foreach ($roots_css_frameworks as $css_framework) {
|
<?php foreach ($roots_css_frameworks as $css_framework) { ?>
|
||||||
?>
|
<option value="<?php echo esc_attr($css_framework['name']); ?>" <?php selected($roots_options['css_framework'], $css_framework['name']); ?>><?php echo $css_framework['label']; ?></option>
|
||||||
<div class="layout">
|
<?php } ?>
|
||||||
<label class="description">
|
</select>
|
||||||
<input type="radio" name="roots_theme_options[css_framework]" value="<?php echo esc_attr($css_framework['name']); ?>" <?php checked($roots_options['css_framework'], $css_framework['name']); ?> />
|
|
||||||
<span>
|
|
||||||
<?php echo $css_framework['label']; ?>
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -195,7 +186,7 @@ function theme_options_render_page() {
|
|||||||
<fieldset><legend class="screen-reader-text"><span><?php _e('#main CSS Classes', 'roots'); ?></span></legend>
|
<fieldset><legend class="screen-reader-text"><span><?php _e('#main CSS Classes', 'roots'); ?></span></legend>
|
||||||
<input type="text" name="roots_theme_options[main_class]" id="main_class" value="<?php echo esc_attr($roots_options['main_class']); ?>" class="regular-text" />
|
<input type="text" name="roots_theme_options[main_class]" id="main_class" value="<?php echo esc_attr($roots_options['main_class']); ?>" class="regular-text" />
|
||||||
<br />
|
<br />
|
||||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['main_class']; ?></span></small>
|
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['main_class']; ?></span></small>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -205,7 +196,7 @@ function theme_options_render_page() {
|
|||||||
<fieldset><legend class="screen-reader-text"><span><?php _e('#sidebar CSS Classes', 'roots'); ?></span></legend>
|
<fieldset><legend class="screen-reader-text"><span><?php _e('#sidebar CSS Classes', 'roots'); ?></span></legend>
|
||||||
<input type="text" name="roots_theme_options[sidebar_class]" id="sidebar_class" value="<?php echo esc_attr($roots_options['sidebar_class']); ?>" class="regular-text" />
|
<input type="text" name="roots_theme_options[sidebar_class]" id="sidebar_class" value="<?php echo esc_attr($roots_options['sidebar_class']); ?>" class="regular-text" />
|
||||||
<br />
|
<br />
|
||||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['sidebar_class']; ?></span></small>
|
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['sidebar_class']; ?></span></small>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -223,18 +214,10 @@ function theme_options_render_page() {
|
|||||||
<tr valign="top"><th scope="row"><?php _e('Cleanup Menu Output', 'roots'); ?></th>
|
<tr valign="top"><th scope="row"><?php _e('Cleanup Menu Output', 'roots'); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Cleanup Menu Output', 'roots'); ?></span></legend>
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Cleanup Menu Output', 'roots'); ?></span></legend>
|
||||||
<div>
|
<select name="roots_theme_options[clean_menu]" id="roots_theme_options[clean_menu]">
|
||||||
<label class="description">
|
<option value="yes" <?php selected($roots_options['clean_menu'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||||
<input type="radio" name="roots_theme_options[clean_menu]" value="yes" <?php checked($roots_options['clean_menu'], true); ?> />
|
<option value="no" <?php selected($roots_options['clean_menu'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||||
<span><?php echo _e('Yes', 'roots'); ?></span>
|
</select>
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="description">
|
|
||||||
<input type="radio" name="roots_theme_options[clean_menu]" value="no" <?php checked($roots_options['clean_menu'], false); ?> />
|
|
||||||
<span><?php echo _e('No', 'roots'); ?></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -242,18 +225,10 @@ function theme_options_render_page() {
|
|||||||
<tr valign="top"><th scope="row"><?php _e('Enable FOUT-B-Gone', 'roots'); ?></th>
|
<tr valign="top"><th scope="row"><?php _e('Enable FOUT-B-Gone', 'roots'); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable FOUT-B-Gone', 'roots'); ?></span></legend>
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable FOUT-B-Gone', 'roots'); ?></span></legend>
|
||||||
<div>
|
<select name="roots_theme_options[fout_b_gone]" id="roots_theme_options[fout_b_gone]">
|
||||||
<label class="description">
|
<option value="yes" <?php selected($roots_options['fout_b_gone'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||||
<input type="radio" name="roots_theme_options[fout_b_gone]" value="yes" <?php checked($roots_options['fout_b_gone'], true); ?> />
|
<option value="no" <?php selected($roots_options['fout_b_gone'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||||
<span><?php echo _e('Yes', 'roots'); ?></span>
|
</select>
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="description">
|
|
||||||
<input type="radio" name="roots_theme_options[fout_b_gone]" value="no" <?php checked($roots_options['fout_b_gone'], false); ?> />
|
|
||||||
<span><?php echo _e('No', 'roots'); ?></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -268,14 +243,14 @@ function theme_options_render_page() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function roots_theme_options_validate($input) {
|
function roots_theme_options_validate($input) {
|
||||||
global $roots_css_frameworks;
|
global $roots_css_frameworks;
|
||||||
$output = $defaults = roots_get_default_theme_options();
|
$output = $defaults = roots_get_default_theme_options();
|
||||||
|
|
||||||
if (isset($input['css_framework']) && array_key_exists($input['css_framework'], $roots_css_frameworks))
|
if (isset($input['css_framework']) && array_key_exists($input['css_framework'], $roots_css_frameworks))
|
||||||
$output['css_framework'] = $input['css_framework'];
|
$output['css_framework'] = $input['css_framework'];
|
||||||
|
|
||||||
// set the value of the main container class depending on the selected grid framework
|
// set the value of the main container class depending on the selected grid framework
|
||||||
$output['container_class'] = $roots_css_frameworks[$output['css_framework']]['classes']['container'];
|
$output['container_class'] = $roots_css_frameworks[$output['css_framework']]['classes']['container'];
|
||||||
|
|
||||||
if (isset($input['main_class']))
|
if (isset($input['main_class']))
|
||||||
$output['main_class'] = $input['main_class'];
|
$output['main_class'] = $input['main_class'];
|
||||||
|
|||||||
Reference in New Issue
Block a user