Remove all frameworks except Bootstrap (#251)

- Remove all frameworks except Bootstrap

- Remove roots-options.php and replace with a more simple
  roots-config.php

- Include all Bootstrap Javascript plugins by default in
  js/plugins.js

- Use Bootstrap Responsive and Topbar navigation by default

- Use Bootstrap markup on forms, page titles, image galleries,
  alerts and errors, post and comment navigation

- Remove Roots styles from style.css and introduce app.css for
  site-specific CSS. Remove almost all previous default Roots
  styles.

- Add latest updates from H5BP project
This commit is contained in:
Ben Word
2012-02-03 12:10:44 -07:00
parent 7266dae71b
commit 3c3b71fac0
143 changed files with 7480 additions and 17483 deletions

View File

@@ -1,33 +0,0 @@
jQuery.noConflict();
jQuery(document).ready(function(){
var $main = jQuery('#main_class');
var $sidebar = jQuery('#sidebar_class');
var $fullwidth = jQuery('#fullwidth_class');
var framework = jQuery('.roots_css_frameworks select option:selected').val();
var user_main_class = $main.val();
var user_sidebar_class = $sidebar.val();
var user_fullwidth_class = $fullwidth.val();
jQuery('.roots_css_frameworks select').change(function (e) {
var main_class = roots_css_frameworks[this.value].classes.main;
var sidebar_class = roots_css_frameworks[this.value].classes.sidebar;
var fullwidth_class = roots_css_frameworks[this.value].classes.fullwidth;
// if the selected framework was the one originally set, load the original classes instead of the defaults
if (this.value === framework) {
$main.val(user_main_class);
$sidebar.val(user_sidebar_class);
$fullwidth.val(user_fullwidth_class);
} else {
$main.val(main_class);
$sidebar.val(sidebar_class);
$fullwidth.val(fullwidth_class);
}
$main.siblings('small').children().text(main_class);
$sidebar.siblings('small').children().text(sidebar_class);
$fullwidth.siblings('small').children().text(fullwidth_class);
});
});

View File

@@ -3,79 +3,18 @@
add_action('roots_stylesheets', 'roots_get_stylesheets');
function roots_get_stylesheets() {
global $roots_options;
global $roots_css_framework;
$styles = '';
$styles .= stylesheet_link_tag('/style.css', 1);
$styles .= stylesheet_link_tag('/bootstrap.css', 1);
if (class_exists('RGForms')) {
$styles .= "\t<link rel=\"stylesheet\" href=\"" . plugins_url(). "/gravityforms/css/forms.css\">\n";
if (BOOTSTRAP_RESPONSIVE) {
$styles .= stylesheet_link_tag('/bootstrap-responsive.css', 1);
}
$styles .= stylesheet_link_tag('/app.css', 1);
if (is_child_theme()) {
$styles .= stylesheet_link_tag('/style.css', 1);
$styles .= "\t<link rel=\"stylesheet\" href=\"" . get_stylesheet_uri(). "\">\n";
} else {
$styles .= stylesheet_link_tag('/style.css', 1);
}
switch ($roots_css_framework) {
case 'blueprint' :
$styles .= stylesheet_link_tag('/blueprint/screen.css');
break;
case '960gs_12' :
case '960gs_16' :
$styles .= stylesheet_link_tag('/960/reset.css');
$styles .= stylesheet_link_tag('/960/text.css', 1);
$styles .= stylesheet_link_tag('/960/960.css', 1);
break;
case '960gs_24' :
$styles .= stylesheet_link_tag('/960/reset.css');
$styles .= stylesheet_link_tag('/960/text.css', 1);
$styles .= stylesheet_link_tag('/960/960_24_col.css', 1);
break;
case '1140' :
$styles .= stylesheet_link_tag('/1140/1140.css');
break;
case 'adapt' :
$styles .= stylesheet_link_tag('/adapt/master.css');
$styles .= "\t<noscript>\n";
$styles .= stylesheet_link_tag('/adapt/mobile.css', 1);
$styles .= "\t</noscript>\n";
break;
case 'foundation' :
$styles .= stylesheet_link_tag('/foundation/globals.css');
$styles .= stylesheet_link_tag('/foundation/typography.css', 1);
$styles .= stylesheet_link_tag('/foundation/grid.css', 1);
$styles .= stylesheet_link_tag('/foundation/ui.css', 1);
$styles .= stylesheet_link_tag('/foundation/forms.css', 1);
$styles .= stylesheet_link_tag('/foundation/orbit.css', 1);
$styles .= stylesheet_link_tag('/foundation/reveal.css', 1);
$styles .= stylesheet_link_tag('/foundation/mobile.css', 1);
$styles .= stylesheet_link_tag('/foundation/app.css', 1);
break;
case 'less' :
$styles .= stylesheet_link_tag('/less/less.css');
break;
case 'bootstrap' :
$styles .= stylesheet_link_tag('/bootstrap/bootstrap.css');
$styles .= stylesheet_link_tag('/bootstrap/bootstrap-responsive.css');
break;
case 'bootstrap_less' :
$styles .= stylesheet_link_tag('/bootstrap/lib/bootstrap.less', 0, true, 'stylesheet/less');
break;
}
switch ($roots_css_framework) {
case 'blueprint' :
$styles .= "\t<!--[if lt IE 8]>" . stylesheet_link_tag('/blueprint/ie.css', 0, false) . "<![endif]-->\n";
break;
case '1140' :
$styles .= "\t<!--[if lt IE 8]>" . stylesheet_link_tag('/1140/ie.css', 0, false) . "<![endif]-->\n";
break;
case 'foundation' :
$styles .= "\t<!--[if lt IE 9]>" . stylesheet_link_tag('/foundation/ie.css', 0, false) . "<![endif]-->\n";
break;
}
echo $styles;
@@ -89,12 +28,10 @@ function stylesheet_link_tag($file, $tabs = 0, $newline = true, $rel = 'styleshe
add_action('roots_footer', 'roots_google_analytics');
function roots_google_analytics() {
global $roots_options;
$roots_google_analytics_id = $roots_options['google_analytics_id'];
$get_roots_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
$roots_google_analytics_id = GOOGLE_ANALYTICS_ID;
if ($roots_google_analytics_id !== '') {
echo "\n\t<script>\n";
echo "\t\tvar _gaq=[['_setAccount','$get_roots_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
echo "\t\tvar _gaq=[['_setAccount','$roots_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];\n";
echo "\t\tg.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';\n";
echo "\t\ts.parentNode.insertBefore(g,s)}(document,'script'));\n";
@@ -102,79 +39,4 @@ function roots_google_analytics() {
}
}
// 1140 specific
if (roots_current_framework() === '1140') {
add_action('roots_header_before', 'roots_1140_header_before');
add_action('roots_header_after', 'roots_1140_header_after');
add_action('roots_footer_before', 'roots_1140_footer_before');
add_action('roots_footer_after', 'roots_1140_footer_after');
function roots_1140_header_before() {
echo '<div class="container"><div class="row">', "\n";
}
function roots_1140_header_after() {
echo "</div></div><!-- /.row /.container -->\n";
echo '<div class="container"><div class="row">', "\n";
}
function roots_1140_footer_before() {
echo "</div></div><!-- /.row /.container -->\n";
echo '<div class="container"><div class="row">', "\n";
}
function roots_1140_footer_after() {
echo "</div></div><!-- /.row /.container -->\n";
}
}
// Adapt specific
if (roots_current_framework() === 'adapt') {
add_action('roots_head', 'roots_adapt_head');
function roots_adapt_head() {
$template_uri = get_template_directory_uri();
echo "\n\t<script>\n";
echo "\t\tvar ADAPT_CONFIG = {\n";
echo "\t\t\tpath: '$template_uri/css/adapt/',\n";
echo "\t\t\tdynamic: true,\n";
echo "\t\t\trange: [\n";
echo "\t\t\t\t'0px to 760px = mobile.css',\n";
echo "\t\t\t\t'760px to 980px = 720.css',\n";
echo "\t\t\t\t'980px to 1280px = 960.css',\n";
echo "\t\t\t\t'1280px to 1600px = 1200.css',\n";
echo "\t\t\t\t'1600px to 1920px = 1560.css',\n";
echo "\t\t\t\t'1920px = fluid.css'\n";
echo "\t\t\t]\n";
echo "\t\t};\n";
echo "\t</script>\n";
}
}
// Bootstrap specific
if (roots_current_framework() === 'bootstrap' || roots_current_framework() === 'bootstrap_less') {
add_action('roots_header_before', 'roots_bootstrap_header_before');
add_action('roots_header_after', 'roots_bootstrap_header_after');
add_action('roots_footer_before', 'roots_bootstrap_footer_before');
add_action('roots_footer_after', 'roots_bootstrap_footer_after');
function roots_bootstrap_header_before() {
echo '<div class="container">', "\n";
}
function roots_bootstrap_header_after() {
echo "</div><!-- /.container -->\n";
echo '<div class="container">', "\n";
}
function roots_bootstrap_footer_before() {
echo "</div><!-- /.container -->\n";
echo '<div class="container">', "\n";
}
function roots_bootstrap_footer_after() {
echo "</div><!-- /.container -->\n";
}
}
?>

View File

@@ -37,7 +37,7 @@ function roots_theme_activation_options_add_page() {
);
} else {
if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'theme_activation_options') {
wp_redirect(admin_url('themes.php?page=theme_options'));
wp_redirect(admin_url('themes.php'));
exit;
}
}
@@ -121,15 +121,15 @@ function roots_theme_activation_options_render_page() { ?>
</td>
</tr>
<tr valign="top"><th scope="row"><?php _e('Create navigation menus?', 'roots'); ?></th>
<tr valign="top"><th scope="row"><?php _e('Create navigation menu?', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Create navigation menus?', 'roots'); ?></span></legend>
<fieldset><legend class="screen-reader-text"><span><?php _e('Create navigation menu?', 'roots'); ?></span></legend>
<select name="roots_theme_activation_options[create_navigation_menus]" id="create_navigation_menus">
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
<option value="no"><?php echo _e('No', 'roots'); ?></option>
</select>
<br />
<small class="description"><?php printf(__('Create the Primary and Utility Navigation menus and set their locations', 'roots')); ?></small>
<small class="description"><?php printf(__('Create the Primary Navigation menu and set the location', 'roots')); ?></small>
</fieldset>
</td>
</tr>
@@ -285,11 +285,6 @@ function roots_theme_activation_action() {
$roots_nav_theme_mod['primary_navigation'] = $primary_nav_id;
}
if (!has_nav_menu('utility_navigation')) {
$utility_nav_id = wp_create_nav_menu('Utility Navigation', array('slug' => 'utility_navigation'));
$roots_nav_theme_mod['utility_navigation'] = $utility_nav_id;
}
if ($roots_nav_theme_mod) {
set_theme_mod('nav_menu_locations', $roots_nav_theme_mod);
}
@@ -326,4 +321,4 @@ function roots_deactivation_action() {
add_action('switch_theme', 'roots_deactivation_action');
?>
?>

View File

@@ -1,7 +1,5 @@
<?php
$roots_options = roots_get_theme_options();
// redirect /?s to /search/
// http://txfx.net/wordpress-plugins/nice-search/
function roots_nice_search_redirect() {
@@ -67,7 +65,7 @@ function roots_fix_duplicate_subfolder_urls($input) {
return $output;
}
if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) && $roots_options['root_relative_urls']) {
if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
add_filter('bloginfo_url', 'roots_root_relative_url');
add_filter('theme_root_uri', 'roots_root_relative_url');
add_filter('stylesheet_directory_uri', 'roots_root_relative_url');
@@ -92,8 +90,7 @@ if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-regi
// remove root relative URLs on any attachments in the feed
function roots_root_relative_attachment_urls() {
global $roots_options;
if (!is_feed() && $roots_options['root_relative_urls']) {
if (!is_feed()) {
add_filter('wp_get_attachment_url', 'roots_root_relative_url');
add_filter('wp_get_attachment_link', 'roots_root_relative_url');
}
@@ -182,11 +179,6 @@ function roots_head_cleanup() {
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')) {
update_option('rg_gforms_disable_css', 1);
}
// deregister l10n.js (new since WordPress 3.1)
// why you might want to keep it: http://wordpress.stackexchange.com/questions/5451/what-does-l10n-js-do-in-wordpress-3-1-and-how-do-i-remove-it/5484#5484
// don't load jQuery through WordPress since it's linked in header.php
@@ -224,8 +216,8 @@ function roots_gallery_shortcode($attr) {
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'icontag' => 'figure',
'captiontag' => 'figcaption',
'icontag' => 'li',
'captiontag' => 'p',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
@@ -275,23 +267,20 @@ function roots_gallery_shortcode($attr) {
$gallery_style = "";
}
$size_class = sanitize_html_class($size);
$gallery_div = "<section id='$selector' class='clearfix gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
$gallery_div = "<ul id='$selector' class='thumbnails gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
$output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
$i = 0;
foreach ($attachments as $id => $attachment) {
// make the gallery link to the file by default instead of the attachment
// thanks to Matt Price (countingrows.com)
$link = isset($attr['link']) && $attr['link'] === 'attachment' ?
wp_get_attachment_link($id, $size, true, false) :
wp_get_attachment_link($id, $size, false, false);
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
$output .= "
<{$icontag} class=\"gallery-item\">
$link
";
if ($captiontag && trim($attachment->post_excerpt)) {
$output .= "
<{$captiontag} class=\"gallery-caption\">
<{$captiontag} class=\"gallery-caption hidden\">
" . wptexturize($attachment->post_excerpt) . "
</{$captiontag}>";
}
@@ -301,7 +290,7 @@ function roots_gallery_shortcode($attr) {
}
}
$output .= "</section>\n";
$output .= "</ul>\n";
return $output;
}
@@ -309,6 +298,60 @@ function roots_gallery_shortcode($attr) {
remove_shortcode('gallery');
add_shortcode('gallery', 'roots_gallery_shortcode');
function roots_attachment_link_class($html) {
$postid = get_the_ID();
$html = str_replace('<a', '<a class="thumbnail"', $html);
return $html;
}
add_filter('wp_get_attachment_link', 'roots_attachment_link_class', 10, 1);
// http://justintadlock.com/archives/2011/07/01/captions-in-wordpress
function roots_caption($output, $attr, $content) {
/* We're not worried abut captions in feeds, so just return the output here. */
if ( is_feed()) {
return $output;
}
/* Set up the default arguments. */
$defaults = array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
);
/* Merge the defaults with user input. */
$attr = shortcode_atts($defaults, $attr);
/* If the width is less than 1 or there is no caption, return the content wrapped between the [caption]< tags. */
if (1 > $attr['width'] || empty($attr['caption'])) {
return $content;
}
/* Set up the attributes for the caption <div>. */
$attributes = (!empty($attr['id']) ? ' id="' . esc_attr($attr['id']) . '"' : '' );
$attributes .= ' class="thumbnail wp-caption ' . esc_attr($attr['align']) . '"';
$attributes .= ' style="width: ' . esc_attr($attr['width']) . 'px"';
/* Open the caption <div>. */
$output = '<div' . $attributes .'>';
/* Allow shortcodes for the content the caption was created for. */
$output .= do_shortcode($content);
/* Append the caption text. */
$output .= '<div class="caption"><p class="wp-caption-text">' . $attr['caption'] . '</p></div>';
/* Close the caption </div>. */
$output .= '</div>';
/* Return the formatted, clean caption. */
return $output;
}
add_filter('img_caption_shortcode', 'roots_caption', 10, 3);
// 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');
@@ -321,7 +364,7 @@ add_action('admin_init', 'roots_remove_dashboard_widgets');
// excerpt cleanup
function roots_excerpt_length($length) {
return 40;
return POST_EXCERPT_LENGTH;
}
function roots_excerpt_more($more) {
@@ -331,19 +374,11 @@ function roots_excerpt_more($more) {
add_filter('excerpt_length', 'roots_excerpt_length');
add_filter('excerpt_more', 'roots_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');
function roots_check_current($val) {
return preg_match('/current-/', $val);
}
class Roots_Nav_Walker extends Walker_Nav_Menu {
function check_current($val) {
return preg_match('/(current-)/', $val);
}
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ($depth) ? str_repeat("\t", $depth) : '';
@@ -353,7 +388,7 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
$class_names = $value = '';
$classes = empty($item->classes) ? array() : (array) $item->classes;
$classes = array_filter($classes, 'roots_check_current');
$classes = array_filter($classes, array(&$this, 'check_current'));
$class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
@@ -378,15 +413,108 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
}
}
// use the clean nav menu walker for all nav menus if the option is set
function roots_default_wp_nav_menu_walker($args = '') {
global $roots_options;
if ($roots_options['clean_menu']) {
class Roots_Navbar_Nav_Walker extends Walker_Nav_Menu {
function check_current($val) {
return preg_match('/(current-)|active|dropdown/', $val);
}
function start_lvl(&$output, $depth) {
$output .= "\n<ul class=\"dropdown-menu\">\n";
}
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ($depth) ? str_repeat("\t", $depth) : '';
$slug = sanitize_title($item->title);
$li_attributes = '';
$class_names = $value = '';
$classes = empty($item->classes) ? array() : (array) $item->classes;
if ($args->has_children) {
$classes[] = 'dropdown';
$li_attributes .= 'data-dropdown="dropdown"';
}
$classes[] = ($item->current) ? 'active' : '';
$classes = array_filter($classes, array(&$this, 'check_current'));
$class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
$id = apply_filters('nav_menu_item_id', 'menu-' . $slug, $item, $args);
$id = strlen($id) ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $class_names . $li_attributes . '>';
$attributes = ! empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) .'"' : '';
$attributes .= ! empty($item->target) ? ' target="' . esc_attr($item->target ) .'"' : '';
$attributes .= ! empty($item->xfn) ? ' rel="' . esc_attr($item->xfn ) .'"' : '';
$attributes .= ! empty($item->url) ? ' href="' . esc_attr($item->url ) .'"' : '';
$attributes .= ($args->has_children) ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
$item_output .= ($args->has_children) ? ' <b class="caret"></b>' : '';
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
if (!$element) { return; }
$id_field = $this->db_fields['id'];
// display this element
if (is_array($args[0])) {
$args[0]['has_children'] = !empty($children_elements[$element->$id_field]);
} elseif (is_object($args[0])) {
$args[0]->has_children = !empty($children_elements[$element->$id_field]);
}
$cb_args = array_merge(array(&$output, $element, $depth), $args);
call_user_func_array(array(&$this, 'start_el'), $cb_args);
$id = $element->$id_field;
// descend only when the depth is right and there are childrens for this element
if (($max_depth == 0 || $max_depth > $depth+1) && isset($children_elements[$id])) {
foreach ($children_elements[$id] as $child) {
if (!isset($newlevel)) {
$newlevel = true;
// start the child delimiter
$cb_args = array_merge(array(&$output, $depth), $args);
call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
}
$this->display_element($child, $children_elements, $max_depth, $depth + 1, $args, $output);
}
unset($children_elements[$id]);
}
if (isset($newlevel) && $newlevel) {
// end the child delimiter
$cb_args = array_merge(array(&$output, $depth), $args);
call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
}
// end this element
$cb_args = array_merge(array(&$output, $element, $depth), $args);
call_user_func_array(array(&$this, 'end_el'), $cb_args);
}
}
function roots_nav_menu_args($args = '') {
$args['container'] = false;
$args['depth'] = 2;
$args['items_wrap'] = '<ul class="nav">%3$s</ul>';
if (!$args['walker']) {
$args['walker'] = new Roots_Nav_Walker();
}
return $args;
}
add_filter('wp_nav_menu_args', 'roots_default_wp_nav_menu_walker');
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
// add to robots.txt
// http://codex.wordpress.org/Search_Engine_Optimization_for_WordPress#Robots.txt_Optimization
@@ -453,7 +581,7 @@ add_action('admin_init', 'roots_notice_tagline_ignore');
// set the post revisions to 5 unless the constant
// was set in wp-config.php to avoid DB bloat
if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 5);
if (!defined('WP_POST_REVISIONS')) { define('WP_POST_REVISIONS', 5); }
// allow more tags in TinyMCE including <iframe> and <script>
function roots_change_mce_options($options) {
@@ -487,11 +615,11 @@ function roots_body_class() {
if(!empty($cat)) {
return $cat[0]->slug;
} elseif(isset($term->slug)) {
} elseif (isset($term->slug)) {
return $term->slug;
} elseif(isset($term->page_name)) {
} elseif (isset($term->page_name)) {
return $term->page_name;
} elseif(isset($term->post_name)) {
} elseif (isset($term->post_name)) {
return $term->post_name;
} else {
return;
@@ -534,4 +662,33 @@ function roots_widget_first_last_classes($params) {
}
add_filter('dynamic_sidebar_params', 'roots_widget_first_last_classes');
?>
// apply Bootstrap markup/classes to Gravity Forms (in progress)
if (class_exists('RGForms')) {
update_option('rg_gforms_disable_css', 1);
// error message class
function roots_gform_validation_message($message, $form) {
$message = '<div class="alert alert-error fade in">';
$message .= '<a class="close" data-dismiss="alert">×</a>';
$message .= '<strong>There was a problem with your submission. Errors have been highlighted below.</strong>';
$message .= '</div>';
return $message;
}
add_filter('gform_validation_message', 'roots_gform_validation_message', 10, 2);
// field class
function roots_gform_field_css_class($classes, $field, $form) {
$classes .= " control-group";
return $classes;
}
add_action('gform_field_css_class', 'roots_gform_field_css_class', 10, 3);
// button class
function roots_gform_submit_button($button, $form) {
return "<button class='btn btn-primary' id='gform_submit_button_{$form["id"]}'><span>Submit</span></button>";
}
add_filter('gform_submit_button', 'roots_gform_submit_button', 10, 2);
}
?>

12
inc/roots-config.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
define('POST_EXCERPT_LENGTH', 40);
define('BOOTSTRAP_RESPONSIVE', true);
define('WRAP_CLASSES', 'container');
define('CONTAINER_CLASSES', 'row');
define('MAIN_CLASSES', 'span8');
define('SIDEBAR_CLASSES', 'span4');
define('FULLWIDTH_CLASSES', 'span12');
define('GOOGLE_ANALYTICS_ID', '');
?>

View File

@@ -8,7 +8,7 @@ function roots_header_before() { do_action('roots_header_before'); }
function roots_header_inside() { do_action('roots_header_inside'); }
function roots_header_after() { do_action('roots_header_after'); }
// 404.php, archive.php, front-page.php, index.php, loop-page.php, loop-search.php, loop-single.php,
// 404.php, archive.php, front-page.php, index.php, loop-page.php, loop-single.php,
// loop.php, page-custom.php, page-full.php, page.php, search.php, single.php
function roots_content_before() { do_action('roots_content_before'); }
function roots_content_after() { do_action('roots_content_after'); }

View File

@@ -1,442 +0,0 @@
<?php
function roots_admin_enqueue_scripts($hook_suffix) {
if ($hook_suffix !== 'appearance_page_theme_options')
return;
wp_enqueue_style('roots-theme-options', get_template_directory_uri() . '/inc/css/theme-options.css');
wp_enqueue_script('roots-theme-options', get_template_directory_uri() . '/inc/js/theme-options.js');
}
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());
register_setting(
'roots_options',
'roots_theme_options',
'roots_theme_options_validate'
);
}
add_action('admin_init', 'roots_theme_options_init');
function roots_option_page_capability($capability) {
return 'edit_theme_options';
}
add_filter('option_page_capability_roots_options', 'roots_option_page_capability');
function roots_theme_options_add_page() {
$roots_options = roots_get_theme_options();
$roots_activation_options = roots_get_theme_activation_options();
if ($roots_activation_options['first_run']) {
$theme_page = add_theme_page(
__('Theme Options', 'roots'),
__('Theme Options', 'roots'),
'edit_theme_options',
'theme_options',
'roots_theme_options_render_page'
);
}
}
add_action('admin_menu', 'roots_theme_options_add_page');
function roots_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->add_menu(array(
'parent' => 'appearance',
'id' => 'theme_options',
'title' => __('Theme Options', 'roots'),
'href' => admin_url('themes.php?page=theme_options')
));
}
add_action('wp_before_admin_bar_render', 'roots_admin_bar_render');
global $roots_css_frameworks;
$roots_css_frameworks = array(
'blueprint' => array(
'name' => 'blueprint',
'label' => __('Blueprint CSS', 'roots'),
'classes' => array(
'container' => 'span-24',
'main' => 'span-14 append-1',
'sidebar' => 'span-8 prepend-1 last',
'fullwidth' => 'span-24'
)
),
'960gs_12' => array(
'name' => '960gs_12',
'label' => __('960gs (12 cols)', 'roots'),
'classes' => array(
'container' => 'container_12',
'main' => 'grid_7 suffix_1',
'sidebar' => 'grid_4',
'fullwidth' => 'grid_12'
)
),
'960gs_16' => array(
'name' => '960gs_16',
'label' => __('960gs (16 cols)', 'roots'),
'classes' => array(
'container' => 'container_16',
'main' => 'grid_9 suffix_1',
'sidebar' => 'grid_6',
'fullwidth' => 'grid_16'
)
),
'960gs_24' => array(
'name' => '960gs_24',
'label' => __('960gs (24 cols)', 'roots'),
'classes' => array(
'container' => 'container_24',
'main' => 'grid_15 suffix_1',
'sidebar' => 'grid_8',
'fullwidth' => 'grid_24'
)
),
'1140' => array(
'name' => '1140',
'label' => __('1140', 'roots'),
'classes' => array(
'container' => 'row',
'main' => 'eightcol',
'sidebar' => 'fourcol last',
'fullwidth' => 'twelvecol'
)
),
'adapt' => array(
'name' => 'adapt',
'label' => __('Adapt.js', 'roots'),
'classes' => array(
'container' => 'container_12 clearfix',
'main' => 'grid_7 suffix_1',
'sidebar' => 'grid_4',
'fullwidth' => 'grid_12'
)
),
'less' => array(
'name' => 'less',
'label' => __('Less Framework 4', 'roots'),
'classes' => array(
'container' => 'container',
'main' => '',
'sidebar' => '',
'fullwidth' => ''
)
),
'foundation' => array(
'name' => 'foundation',
'label' => __('Foundation', 'roots'),
'classes' => array(
'container' => 'row',
'main' => 'eight columns',
'sidebar' => 'four columns',
'fullwidth' => 'twelve columns'
)
),
'bootstrap' => array(
'name' => 'bootstrap',
'label' => __('Bootstrap', 'roots'),
'classes' => array(
'container' => 'row',
'main' => 'span9',
'sidebar' => 'span3',
'fullwidth' => 'span12'
)
),
'bootstrap_less' => array(
'name' => 'bootstrap_less',
'label' => __('Bootstrap w/ Less', 'roots'),
'classes' => array(
'container' => 'row',
'main' => 'span9',
'sidebar' => 'span3',
'fullwidth' => 'span12'
)
),
'none' => array(
'name' => 'none',
'label' => __('None', 'roots'),
'classes' => array(
'container' => '',
'main' => '',
'sidebar' => '',
'fullwidth' => ''
)
)
);
// Write the above array of CSS frameworks into a script tag
function roots_add_frameworks_object_script() {
global $roots_css_frameworks;
$json = json_encode($roots_css_frameworks);
?>
<script>
var roots_css_frameworks = <?php echo $json; ?>;
</script>
<?php
}
add_action('admin_head', 'roots_add_frameworks_object_script');
function roots_get_default_theme_options($default_framework = '') {
global $roots_css_frameworks;
if ($default_framework == '') { $default_framework = apply_filters('roots_default_css_framework', 'blueprint'); }
$default_framework_settings = $roots_css_frameworks[$default_framework];
$default_theme_options = array(
'css_framework' => $default_framework,
'container_class' => $default_framework_settings['classes']['container'],
'main_class' => $default_framework_settings['classes']['main'],
'sidebar_class' => $default_framework_settings['classes']['sidebar'],
'fullwidth_class' => $default_framework_settings['classes']['fullwidth'],
'google_analytics_id' => '',
'root_relative_urls' => true,
'clean_menu' => true,
'bootstrap_javascript' => false,
'bootstrap_less_javascript' => false,
);
return apply_filters('roots_default_theme_options', $default_theme_options);
}
function roots_get_theme_options() {
return get_option('roots_theme_options', roots_get_default_theme_options());
}
function roots_theme_options_render_page() {
global $roots_css_frameworks;
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php printf(__('%s Theme Options', 'roots'), get_current_theme()); ?></h2>
<?php settings_errors(); ?>
<form method="post" action="options.php">
<?php
settings_fields('roots_options');
$roots_options = roots_get_theme_options();
$roots_default_options = roots_get_default_theme_options($roots_options['css_framework']);
?>
<input type="hidden" value="1" name="roots_theme_options[first_run]" />
<table class="form-table">
<tr valign="top" class="radio-option"><th scope="row"><?php _e('CSS Grid Framework', 'roots'); ?></th>
<td>
<fieldset class="roots_css_frameworks"><legend class="screen-reader-text"><span><?php _e('CSS Grid Framework', 'roots'); ?></span></legend>
<select name="roots_theme_options[css_framework]" id="roots_theme_options[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>
<?php } ?>
</select>
</fieldset>
</td>
</tr>
<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[main_class]" id="main_class" value="<?php echo esc_attr($roots_options['main_class']); ?>" class="regular-text" />
<br />
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['main_class']; ?></span></small>
</fieldset>
</td>
</tr>
<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[sidebar_class]" id="sidebar_class" value="<?php echo esc_attr($roots_options['sidebar_class']); ?>" class="regular-text" />
<br />
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['sidebar_class']; ?></span></small>
</fieldset>
</td>
</tr>
<tr valign="top"><th scope="row"><?php _e('Full Width CSS Classes', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('#fullwidth CSS Classes', 'roots'); ?></span></legend>
<input type="text" name="roots_theme_options[fullwidth_class]" id="fullwidth_class" value="<?php echo esc_attr($roots_options['fullwidth_class']); ?>" class="regular-text" />
<br />
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['fullwidth_class']; ?></span></small>
</fieldset>
</td>
</tr>
<?php if($roots_options['css_framework'] == 'bootstrap') { ?>
<tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th>
<td>
<fieldset class="roots_bootstrap_js"><legend class="screen-reader-text"><span><?php _e('Enable Bootstrap Javascript', 'roots'); ?></span></legend>
<select name="roots_theme_options[bootstrap_javascript]" id="roots_theme_options[bootstrap_javascript]">
<option value="yes" <?php selected($roots_options['bootstrap_javascript'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
<option value="no" <?php selected($roots_options['bootstrap_javascript'], false); ?>><?php echo _e('No', 'roots'); ?></option>
</select>
</fieldset>
</td>
</tr>
<?php } ?>
<?php if($roots_options['css_framework'] == 'bootstrap_less') { ?>
<tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th>
<td>
<fieldset class="roots_bootstrap_js"><legend class="screen-reader-text"><span><?php _e('Enable Bootstrap Javascript', 'roots'); ?></span></legend>
<select name="roots_theme_options[bootstrap_less_javascript]" id="roots_theme_options[bootstrap_less_javascript]">
<option value="yes" <?php selected($roots_options['bootstrap_less_javascript'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
<option value="no" <?php selected($roots_options['bootstrap_less_javascript'], false); ?>><?php echo _e('No', 'roots'); ?></option>
</select>
</fieldset>
</td>
</tr>
<?php } ?>
<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($roots_options['google_analytics_id']); ?>" />
<br />
<small class="description"><?php printf(__('Enter your UA-XXXXX-X ID', 'roots')); ?></small>
</fieldset>
</td>
</tr>
<tr valign="top"><th scope="row"><?php _e('Enable Root Relative URLs', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable Root Relative URLs', 'roots'); ?></span></legend>
<select name="roots_theme_options[root_relative_urls]" id="roots_theme_options[root_relative_urls]">
<option value="yes" <?php selected($roots_options['root_relative_urls'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
<option value="no" <?php selected($roots_options['root_relative_urls'], false); ?>><?php echo _e('No', 'roots'); ?></option>
</select>
</fieldset>
</td>
</tr>
<tr valign="top"><th scope="row"><?php _e('Cleanup Menu Output', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Cleanup Menu Output', 'roots'); ?></span></legend>
<select name="roots_theme_options[clean_menu]" id="roots_theme_options[clean_menu]">
<option value="yes" <?php selected($roots_options['clean_menu'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
<option value="no" <?php selected($roots_options['clean_menu'], false); ?>><?php echo _e('No', 'roots'); ?></option>
</select>
</fieldset>
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
}
function roots_theme_options_validate($input) {
global $roots_css_frameworks;
$output = $defaults = roots_get_default_theme_options();
if (isset($input['css_framework']) && array_key_exists($input['css_framework'], $roots_css_frameworks))
$output['css_framework'] = $input['css_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'];
if (isset($input['main_class'])) {
$output['main_class'] = wp_filter_nohtml_kses($input['main_class']);
}
if (isset($input['sidebar_class'])) {
$output['sidebar_class'] = wp_filter_nohtml_kses($input['sidebar_class']);
}
if (isset($input['fullwidth_class'])) {
$output['fullwidth_class'] = wp_filter_nohtml_kses($input['fullwidth_class']);
}
if (isset($input['google_analytics_id'])) {
if (preg_match('/^ua-\d{4,9}-\d{1,4}$/i', $input['google_analytics_id'])) {
$output['google_analytics_id'] = $input['google_analytics_id'];
}
}
if (isset($input['root_relative_urls'])) {
if ($input['root_relative_urls'] === 'yes') {
$input['root_relative_urls'] = true;
}
if ($input['root_relative_urls'] === 'no') {
$input['root_relative_urls'] = false;
}
$output['root_relative_urls'] = $input['root_relative_urls'];
}
if (isset($input['clean_menu'])) {
if ($input['clean_menu'] === 'yes') {
$input['clean_menu'] = true;
}
if ($input['clean_menu'] === 'no') {
$input['clean_menu'] = false;
}
$output['clean_menu'] = $input['clean_menu'];
}
if (isset($input['bootstrap_javascript'])) {
if ($input['bootstrap_javascript'] === 'yes') {
$input['bootstrap_javascript'] = true;
}
if ($input['bootstrap_javascript'] === 'no') {
$input['bootstrap_javascript'] = false;
}
$output['bootstrap_javascript'] = $input['bootstrap_javascript'];
}
if (isset($input['bootstrap_less_javascript'])) {
if ($input['bootstrap_less_javascript'] === 'yes') {
$input['bootstrap_less_javascript'] = true;
}
if ($input['bootstrap_less_javascript'] === 'no') {
$input['bootstrap_less_javascript'] = false;
}
$output['bootstrap_less_javascript'] = $input['bootstrap_less_javascript'];
}
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
}
function roots_current_framework() {
global $roots_options;
switch ($roots_options['css_framework']) {
case 'blueprint' :
return 'blueprint';
break;
case '960gs_12' :
return '960gs_12';
break;
case '960gs_16' :
return '960gs_16';
break;
case '960gs_24' :
return '960gs_24';
break;
case '1140' :
return '1140';
break;
case 'adapt' :
return 'adapt';
break;
case 'foundation' :
return 'foundation';
break;
case 'less' :
return 'less';
break;
case 'bootstrap' :
return 'bootstrap';
break;
case 'bootstrap_less' :
return 'bootstrap_less';
break;
}
}
?>

View File

@@ -6,71 +6,6 @@ function roots_scripts() {
wp_register_script('roots_script', ''.$template_uri.'/js/script.js', false, null, false);
wp_enqueue_script('roots_plugins');
wp_enqueue_script('roots_script');
if (roots_current_framework() === '1140') {
wp_register_script('css3-mediaqueries', ''.$template_uri.'/js/libs/css3-mediaqueries.js', false, null, false);
wp_enqueue_script('css3-mediaqueries');
}
if (roots_current_framework() === 'adapt') {
wp_register_script('adapt', ''.$template_uri.'/js/libs/adapt.min.js', false, null, false);
wp_enqueue_script('adapt');
}
if (roots_current_framework() === 'foundation') {
wp_register_script('foundation-jquery-reveal', ''.$template_uri.'/js/foundation/jquery.reveal.js', false, null, false);
wp_register_script('foundation-jquery-orbit', ''.$template_uri.'/js/foundation/jquery.orbit-1.3.0.js', false, null, false);
wp_register_script('foundation-forms-jquery', ''.$template_uri.'/js/foundation/forms.jquery.js', false, null, false);
wp_register_script('foundation-jquery-customforms', ''.$template_uri.'/js/foundation/jquery.customforms.js', false, null, false);
wp_register_script('foundation-jquery-placeholder', ''.$template_uri.'/js/foundation/jquery.placeholder.min.js', false, null, false);
wp_register_script('foundation-app', ''.$template_uri.'/js/foundation/app.js', false, null, false);
wp_enqueue_script('foundation-jquery-reveal');
wp_enqueue_script('foundation-jquery-orbit');
wp_enqueue_script('foundation-forms-jquery');
wp_enqueue_script('foundation-jquery-customforms');
wp_enqueue_script('foundation-jquery-placeholder');
wp_enqueue_script('foundation-app');
}
if (roots_current_framework() === 'bootstrap' || roots_current_framework() === 'bootstrap_less') {
global $roots_options;
$roots_bootstrap_js = $roots_options['bootstrap_javascript'];
$roots_bootstrap_less_js = $roots_options['bootstrap_less_javascript'];
$template_uri = get_template_directory_uri();
if (roots_current_framework() === 'bootstrap_less') {
wp_register_script('bootstrap-less', ''.$template_uri.'/js/bootstrap/less-1.2.1.min.js', false, null, false);
wp_enqueue_script('bootstrap-less');
}
if ($roots_bootstrap_js === true || $roots_bootstrap_less_js === true) {
$roots_options['bootstrap_less_javascript'] = false;
$roots_options['bootstrap_javascript'] = false;
wp_register_script('bootstrap-transition', ''.$template_uri.'/js/bootstrap/bootstrap-transition.js', false, null, false);
wp_register_script('bootstrap-alert', ''.$template_uri.'/js/bootstrap/bootstrap-alert.js', false, null, false);
wp_register_script('bootstrap-modal', ''.$template_uri.'/js/bootstrap/bootstrap-modal.js', false, null, false);
wp_register_script('bootstrap-dropdown', ''.$template_uri.'/js/bootstrap/bootstrap-dropdown.js', false, null, false);
wp_register_script('bootstrap-scrollspy', ''.$template_uri.'/js/bootstrap/bootstrap-scrollspy.js', false, null, false);
wp_register_script('bootstrap-tab', ''.$template_uri.'/js/bootstrap/bootstrap-tab.js', false, null, false);
wp_register_script('bootstrap-tooltip', ''.$template_uri.'/js/bootstrap/bootstrap-tooltip.js', false, null, false);
wp_register_script('bootstrap-popover', ''.$template_uri.'/js/bootstrap/bootstrap-popover.js', false, null, false);
wp_register_script('bootstrap-button', ''.$template_uri.'/js/bootstrap/bootstrap-button.js', false, null, false);
wp_register_script('bootstrap-collapse', ''.$template_uri.'/js/bootstrap/bootstrap-collapse.js', false, null, false);
wp_register_script('bootstrap-carousel', ''.$template_uri.'/js/bootstrap/bootstrap-carousel.js', false, null, false);
wp_register_script('bootstrap-typehead', ''.$template_uri.'/js/bootstrap/bootstrap-typehead.js', false, null, false);
wp_enqueue_script('bootstrap-modal');
wp_enqueue_script('bootstrap-alert');
wp_enqueue_script('bootstrap-modal');
wp_enqueue_script('bootstrap-dropdown');
wp_enqueue_script('bootstrap-scrollspy');
wp_enqueue_script('bootstrap-tab');
wp_enqueue_script('bootstrap-tooltip');
wp_enqueue_script('bootstrap-popover');
wp_enqueue_script('bootstrap-button');
wp_enqueue_script('bootstrap-collapse');
wp_enqueue_script('bootstrap-carousel');
wp_enqueue_script('bootstrap-typehead');
}
}
}
add_action('wp_enqueue_scripts', 'roots_scripts');
@@ -99,8 +34,8 @@ function roots_print_scripts() {
echo "\t" . implode("\n\t", $scripts) . "\n";
$template_uri = get_template_directory_uri();
echo "\t<script defer src=\"$template_uri/js/plugins.js\"></script>\n";
echo "\t<script defer src=\"$template_uri/js/script.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/plugins.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/script.js\"></script>\n";
$wp_scripts->reset();
return $wp_scripts->done;