From 91d81ddb6e4c8127b2bebabd029eccb59312e558 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Mon, 30 May 2011 01:33:28 -0600 Subject: [PATCH] complete rewrite of theme options, based on twentyeleven (in progress) --- css/style.css | 7 - footer.php | 20 -- functions.php | 7 +- header.php | 8 +- inc/css/options.css | 29 --- inc/css/theme-options.css | 0 inc/js/{options.js => theme-options.js} | 1 - inc/roots-actions.php | 20 +- inc/roots-options.php | 293 ++++++++++++++---------- loop-search.php | 6 +- loop-single.php | 5 - loop.php | 12 +- 12 files changed, 198 insertions(+), 210 deletions(-) delete mode 100644 inc/css/options.css create mode 100644 inc/css/theme-options.css rename inc/js/{options.js => theme-options.js} (73%) diff --git a/css/style.css b/css/style.css index 9d38df1..6ce2d26 100644 --- a/css/style.css +++ b/css/style.css @@ -161,7 +161,6 @@ input::-moz-focus-inner, button::-moz-focus-inner { border: 0; padding: 0; } .hentry h1 { line-height: 1.2em; margin-bottom: 0.2em; } .hentry h2:first-child { line-height: 1.2em; margin-bottom: 0; } .hentry h2 a { text-decoration: none; } -.hentry iframe.twitter-share-button { position: absolute; top: 0; right: 0; width: 110px; height: 20px; } .hentry time { display: block; font-size: 1.2em; position: relative; } .hentry p.byline { } @@ -219,12 +218,6 @@ figure.gallery-item figcaption { display: none; } #content-info p.copy small { font-size: 1em; } -#content-info p.social .twitter-share-button { float: left; } -#content-info p.social .fb_iframe_widget { float: left; } - -#content-info p.vcard { position: absolute; top: 0; right: 0; margin: 0; text-align: right; } -#content-info p.vcard a.fn { font-size: 14px; } - /* WIDGETS & PLUGINS --------------------------------------------------------------------------------------------------------------------------------------------------- */ diff --git a/footer.php b/footer.php index 67cdca6..6442a6f 100644 --- a/footer.php +++ b/footer.php @@ -4,27 +4,7 @@
-

©

- - - - -

-
- -
- , - -
-
-
- -

-
diff --git a/functions.php b/functions.php index 6cb6add..208d0f4 100644 --- a/functions.php +++ b/functions.php @@ -14,7 +14,8 @@ include_once('inc/roots-custom.php'); // custom functions $theme_name = next(explode('/themes/', get_template_directory())); // set the value of the main container class depending on the selected grid framework -$roots_css_framework = get_option('roots_css_framework'); +$options = roots_get_theme_options(); +$roots_css_framework = $options['css_grid_framework']; if (!defined('roots_container_class')) { switch ($roots_css_framework) { case 'blueprint': define('roots_container_class', 'span-24'); break; @@ -27,7 +28,9 @@ if (!defined('roots_container_class')) { } function get_roots_stylesheets() { - $roots_css_framework = get_option('roots_css_framework'); + $options = roots_get_theme_options(); + $roots_css_framework = $options['css_grid_framework']; + $template_uri = get_template_directory_uri(); $styles = ''; diff --git a/header.php b/header.php index 0c84499..4c7868a 100644 --- a/header.php +++ b/header.php @@ -23,9 +23,13 @@ - + + "; } } function roots_1140_header_before() { - if (get_option('roots_css_framework') === '1140') { + $options = roots_get_theme_options(); + $roots_css_framework = $options['css_grid_framework']; + if ($roots_css_framework === '1140') { echo "
"; } } function roots_1140_header_after() { - if (get_option('roots_css_framework') === '1140') { + $options = roots_get_theme_options(); + $roots_css_framework = $options['css_grid_framework']; + if ($roots_css_framework === '1140') { echo "
"; echo "
"; } } function roots_1140_footer_before() { - if (get_option('roots_css_framework') === '1140') { + $options = roots_get_theme_options(); + $roots_css_framework = $options['css_grid_framework']; + if ($roots_css_framework === '1140') { echo "
"; echo "
"; } } function roots_1140_footer_after() { - if (get_option('roots_css_framework') === '1140') { + $options = roots_get_theme_options(); + $roots_css_framework = $options['css_grid_framework']; + if ($roots_css_framework === '1140') { echo "
"; } } diff --git a/inc/roots-options.php b/inc/roots-options.php index ae66cea..4ddf47f 100644 --- a/inc/roots-options.php +++ b/inc/roots-options.php @@ -1,145 +1,186 @@ - array( + 'value' => 'blueprint', + 'label' => __('Blueprint CSS', 'roots'), + ), + '960gs_12' => array( + 'value' => '960gs_12', + 'label' => __('960gs (12 cols)', 'roots'), + ), + '960gs_16' => array( + 'value' => '960gs_16', + 'label' => __('960gs (16 cols)', 'roots'), + ), + '960gs_24' => array( + 'value' => '960gs_24', + 'label' => __('960gs (24 cols)', 'roots'), + ), + '1140' => array( + 'value' => '1140', + 'label' => __('1140', 'roots'), + ), + ); + + return apply_filters('roots_grid_framework', $grid_options); } -function roots_admin_styles() { - $home_url = home_url(); - $theme_name = next(explode('/themes/', get_template_directory())); +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', + 'google_analytics_id' => '' + ); - wp_register_style('roots_options_css', "$home_url/wp-content/themes/$theme_name/inc/css/options.css"); - wp_enqueue_style('roots_options_css'); - - wp_register_script('roots_options_js', "$home_url/wp-content/themes/$theme_name/inc/js/options.js"); - wp_enqueue_script('roots_options_js'); - - wp_register_style('jquery-ui-css', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/smoothness/jquery-ui.css"); - wp_enqueue_style('jquery-ui-css'); + return apply_filters('roots_default_theme_options', $default_theme_options); } -function roots_register_settings() { - // register our settings - register_setting('roots-settings-group', 'roots_css_framework'); - register_setting('roots-settings-group', 'roots_main_class'); - register_setting('roots-settings-group', 'roots_sidebar_class'); - register_setting('roots-settings-group', 'roots_google_analytics'); - register_setting('roots-settings-group', 'roots_post_author'); - register_setting('roots-settings-group', 'roots_post_tweet'); - register_setting('roots-settings-group', 'roots_footer_social_share'); - register_setting('roots-settings-group', 'roots_vcard_street-address'); - register_setting('roots-settings-group', 'roots_vcard_locality'); - register_setting('roots-settings-group', 'roots_vcard_region'); - register_setting('roots-settings-group', 'roots_vcard_postal-code'); - register_setting('roots-settings-group', 'roots_vcard_tel'); - register_setting('roots-settings-group', 'roots_vcard_email'); - register_setting('roots-settings-group', 'roots_footer_vcard'); - - // add default settings - add_option('roots_css_framework', 'blueprint'); - add_option('roots_main_class', 'span-14 append-1'); - add_option('roots_sidebar_class', 'span-8 prepend-1 last'); - add_option('roots_google_analytics', ''); +function roots_get_theme_options() { + return get_option('roots_theme_options'); } -function roots_settings_page() { ?> +function theme_options_render_page() { + ?> +
+ +

+ -
-
-

Settings

+
+ + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+
- -

Settings saved.

- + - - + if (isset( $input['css_grid_framework']) && array_key_exists($input['css_grid_framework'], roots_grid_framework())) + $output['css_grid_framework'] = $input['css_grid_framework']; -
- -
-
    -
  • - -
    - value="blueprint" />
    - value="960gs_12" />
    - value="960gs_16" />
    - value="960gs_24" />
    - value="1140" /> -
    -
  • -
  • - - - Enter your grid classes -
  • -
  • - - - Enter your grid classes -
  • -
  • - - - Enter your UA-XXXXX-X ID -
  • -
  • - - value="checked" /> -
  • -
  • - - value="checked" /> -
  • -
  • - - value="checked" /> -
  • -
  • - - value="checked" /> -
  • -
  • - -
    - - - - - - -
    -
  • -
-
-
+ 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['google_analytics_id'])) + $output['google_analytics_id'] = $input['google_analytics_id']; - -
- + // Link color must be 3 or 6 hexadecimal characters +// if ( isset( $input['link_color'] ) && preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'] ) ) +// $output['link_color'] = '#' . strtolower( ltrim( $input['link_color'], '#' ) ); + + + + return apply_filters('roots_theme_options_validate', $output, $input, $defaults); +} + +?> \ No newline at end of file diff --git a/loop-search.php b/loop-search.php index 2a33b51..6c158a6 100644 --- a/loop-search.php +++ b/loop-search.php @@ -14,11 +14,7 @@

- - - +
diff --git a/loop-single.php b/loop-single.php index fb54b87..b12bf68 100644 --- a/loop-single.php +++ b/loop-single.php @@ -6,14 +6,9 @@

- - - - -
diff --git a/loop.php b/loop.php index 34a51ec..fa44343 100644 --- a/loop.php +++ b/loop.php @@ -14,18 +14,14 @@

- - - +
- + - + - +