Adding Twitter bootstrap support
This commit is contained in:
@@ -5,11 +5,16 @@ add_action('roots_head', 'roots_fout_b_gone');
|
||||
add_action('roots_head', 'roots_1140_head');
|
||||
add_action('roots_head', 'roots_adapt_head');
|
||||
add_action('roots_head', 'roots_foundation_head');
|
||||
add_action('roots_head', 'roots_bootstrap_head');
|
||||
add_action('roots_stylesheets', 'roots_get_stylesheets');
|
||||
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');
|
||||
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');
|
||||
add_action('roots_post_inside_before', 'roots_page_breadcrumb');
|
||||
|
||||
function roots_google_analytics() {
|
||||
@@ -90,6 +95,49 @@ function roots_foundation_head() {
|
||||
}
|
||||
}
|
||||
|
||||
function roots_bootstrap_head() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
$roots_bootstrap_js = $roots_options['bootstrap_javascript'];
|
||||
$roots_bootstrap_less_js = $roots_options['bootstrap_less_javascript'];
|
||||
$template_uri = get_template_directory_uri();
|
||||
if ($roots_css_framework === 'bootstrap') {
|
||||
echo "\t<!--[if lt IE 9]>\n";
|
||||
echo "\t\t<script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\"></script>\n";
|
||||
echo "\t<![endif]-->\n";
|
||||
}
|
||||
if ($roots_css_framework === 'bootstrap_less') {
|
||||
echo "\t<!--[if lt IE 9]>\n";
|
||||
echo "\t\t<script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\"></script>\n";
|
||||
echo "\t<![endif]-->\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/less-1.1.3.min.js\"></script>\n";
|
||||
}
|
||||
if ($roots_bootstrap_js === true) {
|
||||
$roots_options['bootstrap_less_javascript'] = false;
|
||||
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-alerts.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-buttons.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-dropdown.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-modal.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-popover.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-scrollspy.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-tabs.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-twipsy.js\"></script>\n";
|
||||
}
|
||||
if ($roots_bootstrap_less_js === true) {
|
||||
$roots_options['bootstrap_javascript'] = false;
|
||||
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-alerts.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-buttons.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-dropdown.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-modal.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-popover.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-scrollspy.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-tabs.js\"></script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-twipsy.js\"></script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_get_stylesheets() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
@@ -134,6 +182,12 @@ function roots_get_stylesheets() {
|
||||
case 'less' :
|
||||
$styles .= stylesheet_link_tag('/less/less.css');
|
||||
break;
|
||||
case 'bootstrap' :
|
||||
$styles .= stylesheet_link_tag('/bootstrap/bootstrap.css');
|
||||
break;
|
||||
case 'bootstrap_less' :
|
||||
$styles .= stylesheet_link_tag_boostrap_less('/bootstrap/lib/bootstrap.less');
|
||||
break;
|
||||
}
|
||||
|
||||
if (class_exists('RGForms')) {
|
||||
@@ -167,6 +221,11 @@ function stylesheet_link_tag($file, $tabs = 0, $newline = true) {
|
||||
return $indent . '<link rel="stylesheet" href="' . get_template_directory_uri() . '/css' . $file . '">' . ($newline ? "\n" : "");
|
||||
}
|
||||
|
||||
function stylesheet_link_tag_boostrap_less($file, $tabs = 0, $newline = true) {
|
||||
$indent = str_repeat("\t", $tabs);
|
||||
return $indent . '<link rel="stylesheet/less" media="all" href="' . get_template_directory_uri() . '/css' . $file . '">' . ($newline ? "\n" : "");
|
||||
}
|
||||
|
||||
function roots_1140_header_before() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
@@ -200,6 +259,39 @@ function roots_1140_footer_after() {
|
||||
echo "</div></div><!-- /.row /.container -->\n";
|
||||
}
|
||||
}
|
||||
function roots_bootstrap_header_before() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
|
||||
echo '<div class="container">', "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_bootstrap_header_after() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
|
||||
echo "</div><!-- /.container -->\n";
|
||||
echo '<div class="container">', "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_bootstrap_footer_before() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
|
||||
echo "</div><!-- /.container -->\n";
|
||||
echo '<div class="container">', "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_bootstrap_footer_after() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
|
||||
echo "</div><!-- /.container -->\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_page_breadcrumb() {
|
||||
global $post;
|
||||
|
||||
@@ -125,7 +125,25 @@ $roots_css_frameworks = array(
|
||||
'main' => 'eight columns',
|
||||
'sidebar' => 'four columns'
|
||||
)
|
||||
),
|
||||
),
|
||||
'bootstrap' => array(
|
||||
'name' => 'bootstrap',
|
||||
'label' => __('Bootstrap', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'row',
|
||||
'main' => 'span11',
|
||||
'sidebar' => 'span5'
|
||||
)
|
||||
),
|
||||
'bootstrap_less' => array(
|
||||
'name' => 'bootstrap_less',
|
||||
'label' => __('Bootstrap w/ Less', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'row',
|
||||
'main' => 'span11',
|
||||
'sidebar' => 'span5'
|
||||
)
|
||||
),
|
||||
'none' => array(
|
||||
'name' => 'none',
|
||||
'label' => __('None', 'roots'),
|
||||
@@ -161,7 +179,9 @@ function roots_get_default_theme_options($default_framework = '') {
|
||||
'google_analytics_id' => '',
|
||||
'root_relative_urls' => true,
|
||||
'clean_menu' => true,
|
||||
'fout_b_gone' => false
|
||||
'fout_b_gone' => false,
|
||||
'bootstrap_javascript' => false,
|
||||
'bootstrap_less_javascript' => false
|
||||
);
|
||||
|
||||
return apply_filters('roots_default_theme_options', $default_theme_options);
|
||||
@@ -219,7 +239,33 @@ function roots_theme_options_render_page() {
|
||||
</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>
|
||||
@@ -325,6 +371,26 @@ function roots_theme_options_validate($input) {
|
||||
}
|
||||
$output['fout_b_gone'] = $input['fout_b_gone'];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user