doing some clean up to the new options (which are awesome btw)

This commit is contained in:
Ben Word
2011-05-31 19:51:50 -06:00
parent 97ed6f4f2d
commit 72cdfe7dea
17 changed files with 135 additions and 133 deletions

View File

@@ -9,8 +9,8 @@ add_action('roots_footer_after', 'roots_1140_footer_after');
add_action('roots_post_inside_before', 'roots_page_breadcrumb');
function roots_1140_head() {
$options = roots_get_theme_options();
$roots_css_framework = $options['css_grid_framework'];
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
$template_uri = get_template_directory_uri();
if ($roots_css_framework === '1140') {
echo "<script src=\"$template_uri/js/libs/css3-mediaqueries.js\"></script>";
@@ -18,8 +18,8 @@ function roots_1140_head() {
}
function roots_adapt_head() {
$options = roots_get_theme_options();
$roots_css_framework = $options['css_grid_framework'];
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
$template_uri = get_template_directory_uri();
if ($roots_css_framework === 'adapt') {
echo "<script>\n";
@@ -41,16 +41,16 @@ function roots_adapt_head() {
}
function roots_1140_header_before() {
$options = roots_get_theme_options();
$roots_css_framework = $options['css_grid_framework'];
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "<div class=\"row\">";
}
}
function roots_1140_header_after() {
$options = roots_get_theme_options();
$roots_css_framework = $options['css_grid_framework'];
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "</div><!-- /.row -->";
echo "<div class=\"row\">";
@@ -58,8 +58,8 @@ function roots_1140_header_after() {
}
function roots_1140_footer_before() {
$options = roots_get_theme_options();
$roots_css_framework = $options['css_grid_framework'];
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "</div><!-- /.row -->";
echo "<div class=\"row\">";
@@ -67,8 +67,8 @@ function roots_1140_footer_before() {
}
function roots_1140_footer_after() {
$options = roots_get_theme_options();
$roots_css_framework = $options['css_grid_framework'];
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === '1140') {
echo "</div><!-- /.row -->";
}
@@ -81,7 +81,6 @@ function roots_page_breadcrumb() {
yoast_breadcrumb('<p id="breadcrumbs">','</p>');
}
}
wp_reset_postdata();
}
?>

View File

@@ -132,13 +132,37 @@ function roots_language_attributes() {
add_filter('language_attributes', 'roots_language_attributes');
// remove WordPress version from RSS feed
function roots_no_generator() { return ''; }
add_filter('the_generator', 'roots_no_generator');
// cleanup wp_head
function roots_noindex() {
if ('0' == get_option('blog_public'))
echo "<meta name=\"robots\" content=\"noindex,nofollow\">\n";
}
function roots_rel_canonical() {
if (!is_singular())
return;
global $wp_the_query;
if (!$id = $wp_the_query->get_queried_object_id())
return;
$link = get_permalink($id);
echo "<link rel=\"canonical\" href=\"$link\">\n";
}
// remove CSS from recent comments widget
function roots_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style') );
}
// remove CSS from gallery
function roots_gallery_style($css) {
return preg_replace("#<style type='text/css'>(.*?)</style>#s", '', $css);
}
function roots_head_cleanup() {
// http://wpengineer.com/1438/wordpress-header/
remove_action('wp_head', 'feed_links', 2);
@@ -151,25 +175,12 @@ function roots_head_cleanup() {
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'noindex', 1);
function roots_noindex() {
if ('0' == get_option('blog_public'))
echo "<meta name=\"robots\" content=\"noindex,nofollow\">\n";
}
add_action('wp_head', 'roots_noindex');
remove_action('wp_head', 'rel_canonical');
function roots_rel_canonical() {
if (!is_singular())
return;
global $wp_the_query;
if (!$id = $wp_the_query->get_queried_object_id())
return;
$link = get_permalink($id);
echo "<link rel=\"canonical\" href=\"$link\">\n";
}
add_action('wp_head', 'roots_rel_canonical');
add_action('wp_head', 'roots_rel_canonical');
add_action('wp_head', 'roots_remove_recent_comments_style', 1);
add_filter('gallery_style', 'roots_gallery_style');
// stop Gravity Forms from outputting CSS since it's linked in header.php
if (class_exists('RGForms')) {
@@ -187,28 +198,11 @@ function roots_head_cleanup() {
wp_deregister_script('jquery');
wp_register_script('jquery', '', '', '', true);
}
// remove CSS from recent comments widget
function roots_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style') );
}
add_action('wp_head', 'roots_recent_comments_style', 1);
// remove CSS from gallery
function roots_gallery_style($css) {
return preg_replace("#<style type='text/css'>(.*?)</style>#s", '', $css);
}
add_filter('gallery_style', 'roots_gallery_style');
}
add_action('init', 'roots_head_cleanup');
// cleanup gallery_shortcode()
remove_shortcode('gallery');
function roots_gallery_shortcode($attr) {
global $post, $wp_locale;
@@ -309,9 +303,9 @@ function roots_gallery_shortcode($attr) {
return $output;
}
remove_shortcode('gallery');
add_shortcode('gallery', 'roots_gallery_shortcode');
// http://www.deluxeblogtips.com/2011/01/remove-dashboard-widgets-in-wordpress.html
function roots_remove_dashboard_widgets() {
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
@@ -338,4 +332,12 @@ function roots_auto_excerpt_more($more) {
add_filter('excerpt_length', 'roots_excerpt_length');
add_filter('excerpt_more', 'roots_auto_excerpt_more');
// remove container from menus
function roots_nav_menu_args($args = '') {
$args['container'] = false;
return $args;
}
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
?>

View File

@@ -13,7 +13,6 @@ function roots_admin_enqueue_scripts($hook_suffix) {
add_action('admin_enqueue_scripts', 'roots_admin_enqueue_scripts');
function roots_theme_options_init() {
if (false === roots_get_theme_options())
add_option('roots_theme_options', roots_get_default_theme_options());
@@ -41,8 +40,8 @@ function roots_theme_options_add_page() {
}
add_action('admin_menu', 'roots_theme_options_add_page');
function roots_grid_framework() {
$grid_options = array(
function roots_css_framework() {
$framework_options = array(
'blueprint' => array(
'value' => 'blueprint',
'label' => __('Blueprint CSS', 'roots'),
@@ -69,14 +68,15 @@ function roots_grid_framework() {
),
);
return apply_filters('roots_grid_framework', $grid_options);
return apply_filters('roots_css_framework', $framework_options);
}
function roots_get_default_theme_options() {
$default_theme_options = array(
'css_grid_framework' => 'blueprint',
'css_main_class' => 'span-14 append-1',
'css_sidebar_class' => 'span-8 prepend-1 last',
'css_framework' => 'blueprint',
'container_class' => 'span-24',
'main_class' => 'span-14 append-1',
'sidebar_class' => 'span-8 prepend-1 last',
'google_analytics_id' => ''
);
@@ -97,8 +97,8 @@ function theme_options_render_page() {
<form method="post" action="options.php">
<?php
settings_fields('roots_options');
$options = roots_get_theme_options();
$default_options = roots_get_default_theme_options();
$roots_options = roots_get_theme_options();
$roots_default_options = roots_get_default_theme_options();
?>
<table class="form-table">
@@ -107,13 +107,13 @@ function theme_options_render_page() {
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('CSS Grid Framework', 'roots'); ?></span></legend>
<?php
foreach (roots_grid_framework() as $grid_framework) {
foreach (roots_css_framework() as $css_framework) {
?>
<div class="layout">
<label class="description">
<input type="radio" name="roots_theme_options[css_grid_framework]" value="<?php echo esc_attr($grid_framework['value']); ?>" <?php checked($options['css_grid_framework'], $grid_framework['value']); ?> />
<input type="radio" name="roots_theme_options[css_framework]" value="<?php echo esc_attr($css_framework['value']); ?>" <?php checked($roots_options['css_framework'], $css_framework['value']); ?> />
<span>
<?php echo $grid_framework['label']; ?>
<?php echo $css_framework['label']; ?>
</span>
</label>
</div>
@@ -127,9 +127,9 @@ function theme_options_render_page() {
<tr valign="top"><th scope="row"><?php _e('#main CSS Classes', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('#main CSS Classes', 'roots'); ?></span></legend>
<input type="text" name="roots_theme_options[css_main_class]" id="css_main_class" value="<?php echo esc_attr($options['css_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 />
<small class="description"><?php printf( __('Default: %s', 'roots'), $default_options['css_main_class']); ?></small>
<small class="description"><?php printf( __('Default: %s', 'roots'), $roots_default_options['main_class']); ?></small>
</fieldset>
</td>
</tr>
@@ -137,9 +137,9 @@ function theme_options_render_page() {
<tr valign="top"><th scope="row"><?php _e('#sidebar CSS Classes', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('#sidebar CSS Classes', 'roots'); ?></span></legend>
<input type="text" name="roots_theme_options[css_sidebar_class]" id="css_sidebar_class" value="<?php echo esc_attr($options['css_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 />
<small class="description"><?php printf( __('Default: %s', 'roots'), $default_options['css_sidebar_class']); ?></small>
<small class="description"><?php printf( __('Default: %s', 'roots'), $roots_default_options['sidebar_class']); ?></small>
</fieldset>
</td>
</tr>
@@ -147,7 +147,7 @@ function theme_options_render_page() {
<tr valign="top"><th scope="row"><?php _e('Google Analytics ID', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Google Analytics ID', 'roots'); ?></span></legend>
<input type="text" name="roots_theme_options[google_analytics_id]" id="google_analytics_id" value="<?php echo esc_attr($options['google_analytics_id']); ?>" />
<input type="text" name="roots_theme_options[google_analytics_id]" id="google_analytics_id" value="<?php echo esc_attr($roots_options['google_analytics_id']); ?>" />
<br />
<small class="description"><?php printf(__('Enter your UA-XXXXX-X ID', 'roots')); ?></small>
</fieldset>
@@ -165,15 +165,35 @@ function theme_options_render_page() {
function roots_theme_options_validate($input) {
$output = $defaults = roots_get_default_theme_options();
if (isset($input['css_framework']) && array_key_exists($input['css_framework'], roots_css_framework()))
$output['css_framework'] = $input['css_framework'];
// set the value of the main container class depending on the selected grid framework
if ($output['css_framework'] = 'blueprint') {
$output['container_class'] = 'span-24';
}
if ($output['css_framework'] = '960gs_12') {
$output['container_class'] = 'container_12';
}
if ($output['css_framework'] = '960gs_16') {
$output['container_class'] = 'container_16';
}
if ($output['css_framework'] = '960gs_24') {
$output['container_class'] = 'container_24';
}
if ($output['css_framework'] = '1140') {
$output['container_class'] = 'container';
}
if ($output['css_framework'] = 'adapt') {
$output['container_class'] = 'container_12 clearfix';
}
if (isset( $input['css_grid_framework']) && array_key_exists($input['css_grid_framework'], roots_grid_framework()))
$output['css_grid_framework'] = $input['css_grid_framework'];
if (isset($input['main_class']))
$output['main_class'] = $input['main_class'];
if (isset($input['css_main_class']))
$output['css_main_class'] = $input['css_main_class'];
if (isset($input['css_sidebar_class']))
$output['css_sidebar_class'] = $input['css_sidebar_class'];
if (isset($input['sidebar_class']))
$output['sidebar_class'] = $input['sidebar_class'];
if (isset($input['google_analytics_id']))
$output['google_analytics_id'] = $input['google_analytics_id'];