<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[17721] trunk/wp-content/themes/twentyeleven: Twenty Eleven: functions.
 php cleanup and introduction of theme options; see #17198</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17721">17721</a></dd>
<dt>Author</dt> <dd>iandstewart</dd>
<dt>Date</dt> <dd>2011-04-26 22:52:18 +0000 (Tue, 26 Apr 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Twenty Eleven: functions.php cleanup and introduction of theme options; see <a href="http://trac.wordpress.org/ticket/17198">#17198</a>

* Cleanup functions.php, adding comments and function_exists() checks following Twenty Ten's example
* Theme option for choosing an alternate (dark) color scheme. It currently only loads a placeholder CSS file with dark styles to follow.
* Theme option for selecting a link color that loads an internal style block for resetting link colors. An updated style.css will follow to take advantage of this.
* Theme options for selecting an alternate layout. Adds a class to the body element. An updated style.css will follow to take advantage of this.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentyelevenfunctionsphp">trunk/wp-content/themes/twentyeleven/functions.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/wp-content/themes/twentyeleven/colors/</li>
<li><a href="#trunkwpcontentthemestwentyelevencolorsdarkcss">trunk/wp-content/themes/twentyeleven/colors/dark.css</a></li>
<li>trunk/wp-content/themes/twentyeleven/inc/theme-options/</li>
<li>trunk/wp-content/themes/twentyeleven/inc/theme-options/images/</li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsimagescontentsidebarpng">trunk/wp-content/themes/twentyeleven/inc/theme-options/images/content-sidebar.png</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsimagescontentpng">trunk/wp-content/themes/twentyeleven/inc/theme-options/images/content.png</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsimagesdarkpng">trunk/wp-content/themes/twentyeleven/inc/theme-options/images/dark.png</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsimageslightpng">trunk/wp-content/themes/twentyeleven/inc/theme-options/images/light.png</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsimagessidebarcontentpng">trunk/wp-content/themes/twentyeleven/inc/theme-options/images/sidebar-content.png</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionscss">trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.css</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsjs">trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.js</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsphp">trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentyelevencolorsdarkcss"></a>
<div class="addfile"><h4>Added: trunk/wp-content/themes/twentyeleven/colors/dark.css (0 => 17721)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/colors/dark.css                                (rev 0)
+++ trunk/wp-content/themes/twentyeleven/colors/dark.css        2011-04-26 22:52:18 UTC (rev 17721)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+/* Placeholder for a Twenty Eleven dark color scheme */
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/colors/dark.css
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/functions.php (17720 => 17721)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/functions.php        2011-04-26 21:05:43 UTC (rev 17720)
+++ trunk/wp-content/themes/twentyeleven/functions.php        2011-04-26 22:52:18 UTC (rev 17721)
</span><span class="lines">@@ -1,77 +1,155 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> /**
</span><ins>+ * Twenty Eleven functions and definitions
+ *
+ * Sets up the theme and provides some helper functions. Some helper functions
+ * are used in the theme as custom template tags. Others are attached to action and
+ * filter hooks in WordPress to change core functionality.
+ *
+ * The first function, twentyeleven_setup(), sets up the theme by registering support
+ * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
+ *
+ * When using a child theme (see http://codex.wordpress.org/Theme_Development and
+ * http://codex.wordpress.org/Child_Themes), you can override certain functions
+ * (those wrapped in a function_exists() call) by defining them first in your child theme's
+ * functions.php file. The child theme's functions.php file is included before the parent
+ * theme's file, so the child theme functions would be used.
+ *
+ * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
+ * to a filter or action hook. The hook can be removed by using remove_action() or
+ * remove_filter() and you can attach your own function to the hook.
+ *
+ * We can remove the parent theme's hook only after it is attached, which means we need to
+ * wait until setting up the child theme:
+ *
+ * &lt;code&gt;
+ * add_action( 'after_setup_theme', 'my_child_theme_setup' );
+ * function my_child_theme_setup() {
+ *     // We are providing our own filter for excerpt_length (or using the unfiltered value)
+ *     remove_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
+ *     ...
+ * }
+ * &lt;/code&gt;
+ *
+ * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
+ *
</ins><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Twenty Eleven
</span><ins>+ * @since Twenty Eleven 1.0
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Make theme available for translation
- * Translations can be filed in the /languages/ directory
- * If you're building a theme based on Twenty Eleven, use a find and replace
- * to change 'twentyeleven' to the name of your theme in all the template files
- */
-load_theme_textdomain( 'twentyeleven', TEMPLATEPATH . '/languages' );
-
-$locale = get_locale();
-$locale_file = TEMPLATEPATH . &quot;/languages/$locale.php&quot;;
-if ( is_readable( $locale_file ) )
-        require_once( $locale_file );
-
-/**
</del><span class="cx">  * Set the content width based on the theme's design and stylesheet.
</span><span class="cx">  */
</span><span class="cx"> if ( ! isset( $content_width ) )
</span><span class="cx">         $content_width = 584;
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * This theme uses wp_nav_menu() in one location.
</del><ins>+ * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run.
</ins><span class="cx">  */
</span><del>-register_nav_menus( array(
-        'primary' =&gt; __( 'Primary Menu', 'twentyeleven' ),
-) );
</del><ins>+add_action( 'after_setup_theme', 'twentyeleven_setup' );
</ins><span class="cx"> 
</span><ins>+if ( ! function_exists( 'twentyeleven_setup' ) ):
</ins><span class="cx"> /**
</span><del>- * Add default posts and comments RSS feed links to head
</del><ins>+ * Sets up theme defaults and registers support for various WordPress features.
+ *
+ * Note that this function is hooked into the after_setup_theme hook, which runs
+ * before the init hook. The init hook is too late for some features, such as indicating
+ * support post thumbnails.
+ *
+ * To override twentyeleven_setup() in a child theme, add your own twentyeleven_setup to your child theme's
+ * functions.php file.
+ *
+ * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
+ * @uses register_nav_menus() To add support for navigation menus.
+ * @uses add_custom_background() To add support for a custom background.
+ * @uses load_theme_textdomain() For translation/localization support.
+ * @uses add_custom_image_header() To add support for a custom header.
+ * @uses register_default_headers() To register the default custom header images provided with the theme.
+ * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
+ *
+ * @since Twenty Eleven 1.0
</ins><span class="cx">  */
</span><del>-add_theme_support( 'automatic-feed-links' );
</del><ins>+function twentyeleven_setup() {
</ins><span class="cx"> 
</span><del>-/**
- * Add support for an Aside Post Format
- */
-add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote' ) );
</del><ins>+        /**
+         * Make theme available for translation
+         * Translations can be filed in the /languages/ directory
+         * If you're building a theme based on Twenty Eleven, use a find and replace
+         * to change 'twentyeleven' to the name of your theme in all the template files
+         */
+        load_theme_textdomain( 'twentyeleven', TEMPLATEPATH . '/languages' );
</ins><span class="cx"> 
</span><del>-/**
- * Add support for custom backgrounds
- */
-add_custom_background();
</del><ins>+        $locale = get_locale();
+        $locale_file = TEMPLATEPATH . &quot;/languages/$locale.php&quot;;
+        if ( is_readable( $locale_file ) )
+                require_once( $locale_file );
</ins><span class="cx"> 
</span><del>-// This theme uses Feature Images for per-post/per-page Custom Header images
-add_theme_support( 'post-thumbnails' );
</del><ins>+        /**
+         * Load up our theme options page
+         */
+        require( dirname( __FILE__ ) . '/inc/theme-options/theme-options.php' );
</ins><span class="cx"> 
</span><del>-/**
- * Add support for Custom Headers
- */
-define( 'HEADER_TEXTCOLOR', '000' );
</del><ins>+        /**
+         * Grab Twenty Eleven's Custom Widgets
+         */
+        require( dirname( __FILE__ ) . '/inc/widgets.php' );
</ins><span class="cx"> 
</span><del>-// No CSS, just an IMG call. The %s is a placeholder for the theme template directory URI.
-define( 'HEADER_IMAGE', '%s/images/headers/default.jpg' );
</del><ins>+        /**
+         * Add default posts and comments RSS feed links to head
+         */
+        add_theme_support( 'automatic-feed-links' );
</ins><span class="cx"> 
</span><del>-// The height and width of your custom header. You can hook into the theme's own filters to change these values.
-// Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
-define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
-define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 300 ) );
</del><ins>+        /**
+         * This theme uses wp_nav_menu() in one location.
+         */
+        register_nav_menus( array(
+                'primary' =&gt; __( 'Primary Menu', 'twentyeleven' ),
+        ) );
</ins><span class="cx"> 
</span><del>-// We'll be using post thumbnails for custom header images on posts and pages.
-// We want them to be 940 pixels wide by 198 pixels tall.
-// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
-set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
</del><ins>+        /**
+         * Add support for an Aside Post Format
+         */
+        add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote' ) );
</ins><span class="cx"> 
</span><del>-// Add a way for the custom header to be styled in the admin panel that controls
-// custom headers. See twentyeleven_admin_header_style(), below.
-add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' );
</del><ins>+        /**
+         * Add support for custom backgrounds
+         */
+        add_custom_background();
</ins><span class="cx"> 
</span><del>-// ... and thus ends the changeable header business.
</del><ins>+        // This theme uses Feature Images for per-post/per-page Custom Header images
+        add_theme_support( 'post-thumbnails' );
</ins><span class="cx"> 
</span><ins>+        /**
+         * Add support for Custom Headers
+         */
+        define( 'HEADER_TEXTCOLOR', '000' );
+
+        // No CSS, just an IMG call. The %s is a placeholder for the theme template directory URI.
+        define( 'HEADER_IMAGE', '%s/images/headers/default.jpg' );
+
+        // The height and width of your custom header. You can hook into the theme's own filters to change these values.
+        // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
+        define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
+        define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 300 ) );
+
+        // We'll be using post thumbnails for custom header images on posts and pages.
+        // We want them to be 940 pixels wide by 198 pixels tall.
+        // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
+        set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
+
+        // Add Twenty Eleven's custom image sizes
+        add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, 500, true ); // Used for large feature images
+        add_image_size( 'small-feature', 500, 500 ); // Used for featured posts if a large-feature doesn't exist
+
+        // Add a way for the custom header to be styled in the admin panel that controls
+        // custom headers. See twentyeleven_admin_header_style(), below.
+        add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' );
+
+        // ... and thus ends the changeable header business.
+}
+endif; // twentyeleven_setup
+
</ins><span class="cx"> if ( ! function_exists( 'twentyeleven_header_style' ) ) :
</span><span class="cx"> /**
</span><span class="cx">  * Styles the header image and text displayed on the blog
</span><span class="lines">@@ -79,6 +157,7 @@
</span><span class="cx">  * @since Twenty Eleven 1.0
</span><span class="cx">  */
</span><span class="cx"> function twentyeleven_header_style() {
</span><ins>+
</ins><span class="cx">         // If no custom options for text are set, let's bail
</span><span class="cx">         // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
</span><span class="cx">         if ( HEADER_TEXTCOLOR == get_header_textcolor() )
</span><span class="lines">@@ -108,7 +187,7 @@
</span><span class="cx">         &lt;/style&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx"> }
</span><del>-endif;
</del><ins>+endif; // twentyeleven_header_style
</ins><span class="cx"> 
</span><span class="cx"> if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
</span><span class="cx"> /**
</span><span class="lines">@@ -158,7 +237,7 @@
</span><span class="cx">         &lt;/style&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><del>-endif;
</del><ins>+endif; // twentyeleven_admin_header_style
</ins><span class="cx"> 
</span><span class="cx"> if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
</span><span class="cx"> /**
</span><span class="lines">@@ -181,7 +260,7 @@
</span><span class="cx">                 &lt;img src=&quot;&lt;?php esc_url ( header_image() ); ?&gt;&quot; alt=&quot;&quot; /&gt;
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx"> &lt;?php }
</span><del>-endif;
</del><ins>+endif; // twentyeleven_admin_header_image
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Sets the post excerpt length to 40 characters.
</span><span class="lines">@@ -226,23 +305,16 @@
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> /**
</span><del>- * Add Twenty Eleven's custom image sizes
- */
-add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, 500, true ); // Used for large feature images
-add_image_size( 'small-feature', 500, 500 ); // Used for featured posts if a large-feature doesn't exist
-
-/**
</del><span class="cx">  * Add custom body classes
</span><span class="cx">  */
</span><del>-function twentyeleven_body_class($classes) {
</del><ins>+function twentyeleven_singular_class( $classes ) {
</ins><span class="cx">         if ( is_singular() &amp;&amp; ! is_home() &amp;&amp; ! is_page_template( 'showcase.php' ) )
</span><span class="cx">                 $classes[] = 'singular';
</span><span class="cx"> 
</span><span class="cx">         return $classes;
</span><span class="cx"> }
</span><del>-add_filter( 'body_class', 'twentyeleven_body_class' );
</del><ins>+add_filter( 'body_class', 'twentyeleven_singular_class' );
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
</span><span class="lines">@@ -309,14 +381,9 @@
</span><span class="cx"> add_action( 'init', 'twentyeleven_widgets_init' );
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Grab Twenty Eleven's Custom Widgets
- */
-require( dirname( __FILE__ ) . '/inc/widgets.php' );
-
-/**
</del><span class="cx">  * Display navigation to next/previous pages when applicable
</span><span class="cx">  */
</span><del>-function twentyeleven_content_nav($nav_id) {
</del><ins>+function twentyeleven_content_nav( $nav_id ) {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         if ( $wp_query-&gt;max_num_pages &gt; 1 ) : ?&gt;
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsimagescontentsidebarpng"></a>
<div class="binary"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/content-sidebar.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/content-sidebar.png
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx">   + application/octet-stream
</span><a id="trunkwpcontentthemestwentyelevenincthemeoptionsimagescontentpng"></a>
<div class="binary"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/content.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/content.png
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx">   + application/octet-stream
</span><a id="trunkwpcontentthemestwentyelevenincthemeoptionsimagesdarkpng"></a>
<div class="binary"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/dark.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/dark.png
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx">   + application/octet-stream
</span><a id="trunkwpcontentthemestwentyelevenincthemeoptionsimageslightpng"></a>
<div class="binary"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/light.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/light.png
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx">   + application/octet-stream
</span><a id="trunkwpcontentthemestwentyelevenincthemeoptionsimagessidebarcontentpng"></a>
<div class="binary"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/sidebar-content.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/images/sidebar-content.png
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx">   + application/octet-stream
</span><a id="trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionscss"></a>
<div class="addfile"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.css (0 => 17721)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.css                                (rev 0)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.css        2011-04-26 22:52:18 UTC (rev 17721)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+#wpcontent select option {
+        padding-right: 5px;
+}
+.image-radio-option td {
+        padding-top: 15px;
+}
+.image-radio-option label {
+        display: block;
+        float: left;
+        margin: 0 30px 20px 2px;
+        position: relative;
+}
+.image-radio-option input {
+        margin: 0 0 10px;
+}
+.image-radio-option span {
+        display: block;
+        width: 136px;
+}
+.image-radio-option img {
+        margin: 0 0 0 -2px;
+}
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.css
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsjs"></a>
<div class="addfile"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.js (0 => 17721)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.js                                (rev 0)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.js        2011-04-26 22:52:18 UTC (rev 17721)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+var farbtastic;
+function pickColor(a) {
+        farbtastic.setColor(a);
+        jQuery(&quot;#link-color&quot;).val(a);
+        jQuery(&quot;#link-color&quot;).css(&quot;background-color&quot;, a);
+}
+jQuery(document).ready(function() {
+        jQuery(&quot;#pickcolor&quot;).click(function() {
+                jQuery(&quot;#colorPickerDiv&quot;).show();
+                return false;
+        });
+        jQuery(&quot;#link-color&quot;).keyup(function() {
+                var b = jQuery(&quot;#link-color&quot;).val(),
+                a = b;
+                if (a.charAt(0) != &quot;#&quot;) {
+                        a = &quot;#&quot; + a;
+                }
+                a = a.replace(/[^#a-fA-F0-9]+/, &quot;&quot;);
+                if (a != b) {
+                        jQuery(&quot;#link-color&quot;).val(a);
+                }
+                if (a.length == 4 || a.length == 7) {
+                        pickColor(a);
+                }
+        });
+        farbtastic = jQuery.farbtastic(&quot;#colorPickerDiv&quot;,
+        function(a) {
+                pickColor(a);
+        });
+        pickColor(jQuery(&quot;#link-color&quot;).val());
+        jQuery(document).mousedown(function() {
+                jQuery(&quot;#colorPickerDiv&quot;).each(function() {
+                        var a = jQuery(this).css(&quot;display&quot;);
+                        if (a == &quot;block&quot;) {
+                                jQuery(this).fadeOut(2);
+                        }
+                });
+        });
+});
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.js
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsphp"></a>
<div class="addfile"><h4>Added: trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php (0 => 17721)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php                                (rev 0)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php        2011-04-26 22:52:18 UTC (rev 17721)
</span><span class="lines">@@ -0,0 +1,316 @@
</span><ins>+&lt;?php
+/**
+ * Twenty Eleven Theme Options
+ *
+ * @package WordPress
+ * @subpackage Twenty Eleven
+ */
+
+add_action( 'admin_init', 'theme_options_init' );
+add_action( 'admin_menu', 'theme_options_add_page' );
+
+/**
+ * Add theme options page styles and scripts
+ */
+wp_register_style( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options/theme-options.css', '', '0.1' );
+wp_register_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options/theme-options.js' );
+if ( isset( $_GET['page'] ) &amp;&amp; $_GET['page'] == 'theme_options' ) {
+        wp_enqueue_style( 'twentyeleven-theme-options' );
+        wp_enqueue_script( 'twentyeleven-theme-options' );
+        wp_enqueue_script( 'farbtastic' );
+        wp_enqueue_style( 'farbtastic' );
+}
+
+/**
+ * Init plugin options to white list our options
+ */
+function theme_options_init(){
+        register_setting( 'twentyeleven_options', 'twentyeleven_theme_options', 'twentyeleven_theme_options_validate' );
+}
+
+/**
+ * Load up the menu page
+ */
+function theme_options_add_page() {
+        add_theme_page( __( 'Theme Options', 'twentyeleven' ), __( 'Theme Options', 'twentyeleven' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' );
+}
+
+/**
+ * Return array for our color schemes
+ */
+function twentyeleven_color_schemes() {
+        $color_scheme_options = array(
+                'light' =&gt; array(
+                        'value' =&gt; 'light',
+                        'label' =&gt; __( 'Light', 'twentyeleven' )
+                ),
+                'dark' =&gt; array(
+                        'value' =&gt; 'dark',
+                        'label' =&gt; __( 'Dark', 'twentyeleven' )
+                ),
+        );
+
+        return $color_scheme_options;
+}
+
+/**
+ * Return array for our layout options
+ */
+function twentyeleven_layouts() {
+        $layout_options = array(
+                'content-sidebar' =&gt; array(
+                        'value' =&gt; 'content-sidebar',
+                        'label' =&gt; __( 'Content on left', 'twentyeleven' ),
+                ),
+                'sidebar-content' =&gt; array(
+                        'value' =&gt; 'sidebar-content',
+                        'label' =&gt; __( 'Content on right', 'twentyeleven' )
+                ),
+                'content' =&gt; array(
+                        'value' =&gt; 'content',
+                        'label' =&gt; __( 'One-column, no Sidebar', 'twentyeleven' )
+                ),
+        );
+
+        return $layout_options;
+}
+
+/**
+ *  Return the current Twenty Eleven theme options, with default values as fallback
+ */
+function twentyeleven_get_theme_options() {
+        $defaults = array(
+                'color_scheme' =&gt; 'light',
+                'link_color' =&gt; '1b8be0',
+                'theme_layout' =&gt; 'content-sidebar',
+        );
+        $options = get_option( 'twentyeleven_theme_options', $defaults );
+
+        return $options;
+}
+
+/**
+ * Create the options page
+ */
+function theme_options_do_page() {
+        if ( ! isset( $_REQUEST['settings-updated'] ) )
+                $_REQUEST['settings-updated'] = false;
+
+        ?&gt;
+        &lt;div class=&quot;wrap&quot;&gt;
+                &lt;?php screen_icon(); echo &quot;&lt;h2&gt;&quot; . get_current_theme() . __( ' Theme Options', 'twentyeleven' ) . &quot;&lt;/h2&gt;&quot;; ?&gt;
+
+                &lt;?php if ( false !== $_REQUEST['settings-updated'] ) : ?&gt;
+                &lt;div class=&quot;updated fade&quot;&gt;&lt;p&gt;&lt;strong&gt;&lt;?php _e( 'Options saved', 'twentyeleven' ); ?&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;
+                &lt;?php endif; ?&gt;
+
+                &lt;form method=&quot;post&quot; action=&quot;options.php&quot;&gt;
+                        &lt;?php settings_fields( 'twentyeleven_options' ); ?&gt;
+                        &lt;?php $options = twentyeleven_get_theme_options(); ?&gt;
+
+                        &lt;table class=&quot;form-table&quot;&gt;
+
+                                &lt;?php
+                                /**
+                                 * Color Scheme Options
+                                 */
+                                ?&gt;
+                                &lt;tr valign=&quot;top&quot; class=&quot;image-radio-option&quot;&gt;&lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Color Scheme', 'twentyeleven' ); ?&gt;&lt;/th&gt;
+                                        &lt;td&gt;
+                                                &lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Color Scheme', 'twentyeleven' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
+                                                &lt;?php
+                                                        if ( ! isset( $checked ) )
+                                                                $checked = '';
+                                                        foreach ( twentyeleven_color_schemes() as $option ) {
+                                                                $radio_setting = $options['color_scheme'];
+
+                                                                if ( '' != $radio_setting ) {
+                                                                        if ( $options['color_scheme'] == $option['value'] ) {
+                                                                                $checked = &quot;checked=\&quot;checked\&quot;&quot;;
+                                                                        } else {
+                                                                                $checked = '';
+                                                                        }
+                                                                }
+                                                                ?&gt;
+                                                                &lt;div class=&quot;layout&quot;&gt;
+                                                                &lt;label class=&quot;description&quot;&gt;
+                                                                        &lt;input type=&quot;radio&quot; name=&quot;twentyeleven_theme_options[color_scheme]&quot; value=&quot;&lt;?php esc_attr_e( $option['value'] ); ?&gt;&quot; &lt;?php echo $checked; ?&gt; /&gt;
+                                                                        &lt;span&gt;
+                                                                                &lt;img src=&quot;&lt;?php echo get_template_directory_uri(); ?&gt;/inc/theme-options/images/&lt;?php echo $option['value']; ?&gt;.png&quot;/&gt;
+                                                                                &lt;?php echo $option['label']; ?&gt;
+                                                                        &lt;/span&gt;
+                                                                &lt;/label&gt;
+                                                                &lt;/div&gt;
+                                                                &lt;?php
+                                                        }
+                                                ?&gt;
+                                                &lt;/fieldset&gt;
+                                        &lt;/td&gt;
+                                &lt;/tr&gt;
+
+                                &lt;?php
+                                /**
+                                 * Link Color Options
+                                 */
+                                ?&gt;
+                                &lt;tr valign=&quot;top&quot;&gt;&lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Link Color', 'twentyeleven' ); ?&gt;&lt;/th&gt;
+                                        &lt;td&gt;
+                                                &lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Link Color', 'twentyeleven' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
+                                                        &lt;input type=&quot;text&quot; name=&quot;twentyeleven_theme_options[link_color]&quot; id=&quot;link-color&quot; value=&quot;&lt;?php esc_attr_e( $options['link_color'] ); ?&gt;&quot; /&gt;
+                                                        &lt;a class=&quot;hide-if-no-js&quot; href=&quot;#&quot; id=&quot;pickcolor&quot;&gt;&lt;?php _e( 'Select a Color', 'twentyeleven' ); ?&gt;&lt;/a&gt;
+                                                        &lt;div id=&quot;colorPickerDiv&quot; style=&quot;z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;&quot;&gt;&lt;/div&gt;
+                                                        &lt;br /&gt;
+                                                        &lt;small class=&quot;description&quot;&gt;&lt;?php printf( __( 'Default color: %s', 'twentyeleven' ), '#1b8be0' ); ?&gt;&lt;/small&gt;
+                                                &lt;/fieldset&gt;
+                                        &lt;/td&gt;
+                                &lt;/tr&gt;
+
+                                &lt;?php
+                                /**
+                                 * Layout Options
+                                 */
+                                ?&gt;
+                                &lt;tr valign=&quot;top&quot; class=&quot;image-radio-option&quot;&gt;&lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Layout', 'twentyeleven' ); ?&gt;&lt;/th&gt;
+                                        &lt;td&gt;
+                                                &lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Color Scheme', 'twentyeleven' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
+                                                &lt;?php
+                                                        if ( ! isset( $checked ) )
+                                                                $checked = '';
+                                                        foreach ( twentyeleven_layouts() as $option ) {
+                                                                $radio_setting = $options['theme_layout'];
+
+                                                                if ( '' != $radio_setting ) {
+                                                                        if ( $options['theme_layout'] == $option['value'] ) {
+                                                                                $checked = &quot;checked=\&quot;checked\&quot;&quot;;
+                                                                        } else {
+                                                                                $checked = '';
+                                                                        }
+                                                                }
+                                                                ?&gt;
+                                                                &lt;div class=&quot;layout&quot;&gt;
+                                                                &lt;label class=&quot;description&quot;&gt;
+                                                                        &lt;input type=&quot;radio&quot; name=&quot;twentyeleven_theme_options[theme_layout]&quot; value=&quot;&lt;?php esc_attr_e( $option['value'] ); ?&gt;&quot; &lt;?php echo $checked; ?&gt; /&gt;
+                                                                        &lt;span&gt;
+                                                                                &lt;img src=&quot;&lt;?php echo get_template_directory_uri(); ?&gt;/inc/theme-options/images/&lt;?php echo $option['value']; ?&gt;.png&quot;/&gt;
+                                                                                &lt;?php echo $option['label']; ?&gt;
+                                                                        &lt;/span&gt;
+                                                                &lt;/label&gt;
+                                                                &lt;/div&gt;
+                                                                &lt;?php
+                                                        }
+                                                ?&gt;
+                                                &lt;/fieldset&gt;
+                                        &lt;/td&gt;
+                                &lt;/tr&gt;
+                        &lt;/table&gt;
+
+                        &lt;p class=&quot;submit&quot;&gt;
+                                &lt;input type=&quot;submit&quot; class=&quot;button-primary&quot; value=&quot;&lt;?php _e( 'Save Options', 'twentyeleven' ); ?&gt;&quot; /&gt;
+                        &lt;/p&gt;
+                &lt;/form&gt;
+        &lt;/div&gt;
+        &lt;?php
+}
+
+/**
+ * Sanitize and validate input. Accepts an array, return a sanitized array.
+ */
+function twentyeleven_theme_options_validate( $input ) {
+        // todo get defaults, and use insteadd of null for fallback
+        // could also be used to trigger a Reset Options action
+
+        // Our color scheme option must actually be in our array of color scheme options
+        if ( ! isset( $input['color_scheme'] ) )
+                $input['color_scheme'] = null;
+        if ( ! array_key_exists( $input['color_scheme'], twentyeleven_color_schemes() ) )
+                $input['color_scheme'] = null;
+
+        // Our link color option must be safe text with no HTML tags
+        $input['link_color'] = wp_filter_nohtml_kses( $input['link_color'] );
+
+        // Our theme layout option must actually be in our array of theme layout options
+        if ( ! isset( $input['theme_layout'] ) )
+                $input['theme_layout'] = null;
+        if ( ! array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) )
+                $input['theme_layout'] = null;
+
+        return $input;
+}
+
+/**
+ *  Returns the current Twenty Eleven color scheme as selected in the theme options
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_current_color_scheme() {
+        $options = twentyeleven_get_theme_options();
+        return $options['color_scheme'];
+}
+
+/**
+ * Register our color schemes and add them to the queue
+ */
+function twentyeleven_color_registrar() {
+        $color_scheme = twentyeleven_current_color_scheme();
+
+        if ( 'dark' == $color_scheme ) {
+                wp_register_style( 'dark', get_template_directory_uri() . '/colors/dark.css', null, null );
+                wp_enqueue_style( 'dark' );
+        }
+}
+if ( ! is_admin() )
+        add_action( 'wp_print_styles', 'twentyeleven_color_registrar' );
+
+/**
+ *  Returns the current Twenty Eleven layout as selected in the theme options
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_current_layout() {
+        $options = twentyeleven_get_theme_options();
+        $current_layout = $options['theme_layout'];
+
+        $two_columns = array( 'content-sidebar', 'sidebar-content' );
+
+        if ( in_array( $current_layout, $two_columns ) )
+                return 'two-column ' . $current_layout;
+        else
+                return 'one-column ' . $current_layout;
+}
+
+/**
+ * Add an internal style block for the link color to wp_head()
+ */
+function twentyeleven_link_color() {
+        $options = twentyeleven_get_theme_options();
+        $current_link_color = $options['link_color'];
+
+        // Is the link color just the default color?
+        if ( '1b8be0' == $current_link_color ) :
+                return; // we don't need to do anything then
+
+        else :
+                ?&gt;
+                        &lt;style&gt;
+                                /* Link color */
+                                a,
+                                .entry-title a:hover {
+                                    color: &lt;?php echo $current_link_color ?&gt;;
+                                }
+                        &lt;/style&gt;
+                &lt;?php
+        endif;
+}
+add_action( 'wp_head', 'twentyeleven_link_color' );
+
+/**
+ *  Adds twentyeleven_current_layout() to the array of body classes
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_layout_class( $classes ) {
+        $classes[] = twentyeleven_current_layout();
+
+        return $classes;
+}
+add_filter( 'body_class', 'twentyeleven_layout_class' );
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre>
</div>
</div>

</body>
</html>