adding option for fout-b-gone

This commit is contained in:
Ben Word
2011-06-26 20:24:55 -06:00
parent a088b21d9c
commit a05ede6ca5
3 changed files with 125 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
<?php
add_action('roots_head', 'roots_google_analytics');
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_header_before', 'roots_1140_header_before');
@@ -11,11 +12,11 @@ add_action('roots_post_inside_before', 'roots_page_breadcrumb');
function roots_google_analytics() {
global $roots_options;
$google_analytics_id = $roots_options['google_analytics_id'];
$get_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
if ($google_analytics_id !== '') {
$roots_google_analytics_id = $roots_options['google_analytics_id'];
$get_roots_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
if ($roots_google_analytics_id !== '') {
echo "\n\t<script>\n";
echo "\t\tvar _gaq=[['_setAccount','$get_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
echo "\t\tvar _gaq=[['_setAccount','$get_roots_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;\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";
@@ -23,6 +24,18 @@ function roots_google_analytics() {
}
}
function roots_fout_b_gone() {
global $roots_options;
$roots_fout_b_gone = $roots_options['fout_b_gone'];
$template_uri = get_template_directory_uri();
if ($roots_fout_b_gone === true) {
echo "\t<script src=\"$template_uri/js/libs/foutbgone.min.js\"></script>\n";
echo "\t<script>\n";
echo "\t\tfbg.hideFOUT('asap', 100);\n";
echo "\t</script>";
}
}
function roots_1140_head() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];

View File

@@ -81,7 +81,8 @@ function roots_get_default_theme_options() {
'main_class' => 'span-14 append-1',
'sidebar_class' => 'span-8 prepend-1 last',
'google_analytics_id' => '',
'clean_menu' => true
'clean_menu' => true,
'fout_b_gone' => false
);
return apply_filters('roots_default_theme_options', $default_theme_options);
@@ -161,25 +162,40 @@ function theme_options_render_page() {
<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>
<div class="layout">
<label class="description">
<input type="radio" name="roots_theme_options[clean_menu]" value="yes" <?php checked($roots_options['clean_menu'], true); ?> />
<span>
<?php echo _e('Yes', 'roots'); ?>
</span>
</label>
</div>
<div class="layout">
<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>
<div>
<label class="description">
<input type="radio" name="roots_theme_options[clean_menu]" value="yes" <?php checked($roots_options['clean_menu'], true); ?> />
<span><?php echo _e('Yes', 'roots'); ?></span>
</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>
</td>
</tr>
</tr>
<tr valign="top"><th scope="row"><?php _e('Enable FOUT-B-Gone', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable FOUT-B-Gone', 'roots'); ?></span></legend>
<div>
<label class="description">
<input type="radio" name="roots_theme_options[fout_b_gone]" value="yes" <?php checked($roots_options['fout_b_gone'], true); ?> />
<span><?php echo _e('Yes', 'roots'); ?></span>
</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>
</td>
</tr>
</table>
@@ -216,7 +232,10 @@ function roots_theme_options_validate($input) {
$output['google_analytics_id'] = $input['google_analytics_id'];
if (isset($input['clean_menu']))
$output['clean_menu'] = ($input['clean_menu'] === 'yes') ? true : false;
$output['clean_menu'] = ($input['clean_menu'] === 'yes') ? true : false;
if (isset($input['fout_b_gone']))
$output['fout_b_gone'] = ($input['fout_b_gone'] === 'yes') ? true : false;
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
}