<!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>[17735] trunk/wp-content/themes/twentyeleven: Move files in inc/
theme-options up one level.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17735">17735</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2011-04-28 08:59:42 +0000 (Thu, 28 Apr 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move files in inc/theme-options up one level. see <a href="http://trac.wordpress.org/ticket/17198">#17198</a>.</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/inc/images/</li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionscss">trunk/wp-content/themes/twentyeleven/inc/theme-options.css</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsjs">trunk/wp-content/themes/twentyeleven/inc/theme-options.js</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsphp">trunk/wp-content/themes/twentyeleven/inc/theme-options.php</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li>trunk/wp-content/themes/twentyeleven/inc/theme-options/</li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentyelevenfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/functions.php (17734 => 17735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/functions.php        2011-04-28 08:52:37 UTC (rev 17734)
+++ trunk/wp-content/themes/twentyeleven/functions.php        2011-04-28 08:59:42 UTC (rev 17735)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx">         /**
</span><span class="cx">          * Load up our theme options page
</span><span class="cx">          */
</span><del>-        require( dirname( __FILE__ ) . '/inc/theme-options/theme-options.php' );
</del><ins>+        require( dirname( __FILE__ ) . '/inc/theme-options.php' );
</ins><span class="cx">
</span><span class="cx">         /**
</span><span class="cx">          * Grab Twenty Eleven's Custom Widgets
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenincimagesfromrev17734trunkwpcontentthemestwentyelevenincthemeoptionsimages"></a>
<div class="copfile"><h4>Copied: trunk/wp-content/themes/twentyeleven/inc/images (from rev 17734, trunk/wp-content/themes/twentyeleven/inc/theme-options/images)</h4></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionscssfromrev17734trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionscss"></a>
<div class="copfile"><h4>Copied: trunk/wp-content/themes/twentyeleven/inc/theme-options.css (from rev 17734, trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.css) (0 => 17735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options.css         (rev 0)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options.css        2011-04-28 08:59:42 UTC (rev 17735)
</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></pre></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsjsfromrev17734trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsjs"></a>
<div class="copfile"><h4>Copied: trunk/wp-content/themes/twentyeleven/inc/theme-options.js (from rev 17734, trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.js) (0 => 17735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options.js         (rev 0)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options.js        2011-04-28 08:59:42 UTC (rev 17735)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+var farbtastic;
+function pickColor(a) {
+        farbtastic.setColor(a);
+        jQuery("#link-color").val(a);
+        jQuery("#link-color").css("background-color", a);
+}
+jQuery(document).ready(function() {
+        jQuery("#pickcolor").click(function() {
+                jQuery("#colorPickerDiv").show();
+                return false;
+        });
+        jQuery("#link-color").keyup(function() {
+                var b = jQuery("#link-color").val(),
+                a = b;
+                if (a.charAt(0) != "#") {
+                        a = "#" + a;
+                }
+                a = a.replace(/[^#a-fA-F0-9]+/, "");
+                if (a != b) {
+                        jQuery("#link-color").val(a);
+                }
+                if (a.length == 4 || a.length == 7) {
+                        pickColor(a);
+                }
+        });
+        farbtastic = jQuery.farbtastic("#colorPickerDiv",
+        function(a) {
+                pickColor(a);
+        });
+        pickColor(jQuery("#link-color").val());
+        jQuery(document).mousedown(function() {
+                jQuery("#colorPickerDiv").each(function() {
+                        var a = jQuery(this).css("display");
+                        if (a == "block") {
+                                jQuery(this).fadeOut(2);
+                        }
+                });
+        });
+});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsphpfromrev17734trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsphp"></a>
<div class="copfile"><h4>Copied: trunk/wp-content/themes/twentyeleven/inc/theme-options.php (from rev 17734, trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php) (0 => 17735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options.php         (rev 0)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options.php        2011-04-28 08:59:42 UTC (rev 17735)
</span><span class="lines">@@ -0,0 +1,327 @@
</span><ins>+<?php
+/**
+ * Twenty Eleven Theme Options
+ *
+ * @package WordPress
+ * @subpackage Twenty Eleven
+ * @since Twenty Eleven 1.0
+ */
+
+/**
+ * Properly enqueue styles and scripts for our theme options page.
+ *
+ * This function is attached to the admin_enqueue_scripts action hook.
+ *
+ * @since Twenty Eleven 1.0
+ *
+ * @param string $hook_suffix The action passes the current page to the function. We don't
+ *         do anything if we're not on our theme options page.
+ */
+function twentyeleven_admin_enqueue_scripts( $hook_suffix ) {
+        if ( $hook_suffix != 'appearance_page_theme_options' )
+                return;
+
+        wp_enqueue_style( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.css', '', '0.1' );
+        wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js' );
+        wp_enqueue_style( 'farbtastic' );
+        wp_enqueue_script( 'farbtastic' );
+}
+add_action( 'admin_enqueue_scripts', 'twentyeleven_admin_enqueue_scripts' );
+
+/**
+ * Register the form setting for our twentyeleven_options array.
+ *
+ * This function is attached to the admin_init action hook.
+ *
+ * This call to register_setting() registers a validation callback, twentyeleven_theme_options_validate(),
+ * which is used when the option is saved, to ensure that our option values are complete, properly
+ * formatted, and safe.
+ *
+ * We also use this function to add our theme option if it doesn't already exist.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_theme_options_init() {
+
+        // If we have no options in the database, let's add them now.
+        if ( false === twentyeleven_get_theme_options() )
+                add_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() );
+
+        register_setting(
+                'twentyeleven_options', // Options group, see settings_fields() call in theme_options_render_page()
+                'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options()
+                'twentyeleven_theme_options_validate' // The sanitization callback, see twentyeleven_theme_options_validate()
+        );
+}
+add_action( 'admin_init', 'twentyeleven_theme_options_init' );
+
+/**
+ * Add our theme options page to the admin menu.
+ *
+ * This function is attached to the admin_menu action hook.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_theme_options_add_page() {
+        add_theme_page(
+                __( 'Theme Options', 'twentyeleven' ), // Name of page
+                __( 'Theme Options', 'twentyeleven' ), // Label in menu
+                'edit_theme_options', // Capability required
+                'theme_options', // Menu slug, used to uniquely identify the page
+                'theme_options_render_page' // Function that renders the options page
+        );
+}
+add_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );
+
+/**
+ * Returns an array of color schemes registered for Twenty Eleven.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_color_schemes() {
+        $color_scheme_options = array(
+                'light' => array(
+                        'value' => 'light',
+                        'label' => __( 'Light', 'twentyeleven' ),
+                        'thumbnail' => get_template_directory_uri() . '/inc/images/light.png',
+                ),
+                'dark' => array(
+                        'value' => 'dark',
+                        'label' => __( 'Dark', 'twentyeleven' ),
+                        'thumbnail' => get_template_directory_uri() . '/inc/images/dark.png',
+                ),
+        );
+
+        return apply_filters( 'twentyeleven_color_schemes', $color_scheme_options );
+}
+
+/**
+ * Returns an array of layout options registered for Twenty Eleven.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_layouts() {
+        $layout_options = array(
+                'content-sidebar' => array(
+                        'value' => 'content-sidebar',
+                        'label' => __( 'Content on left', 'twentyeleven' ),
+                        'thumbnail' => get_template_directory_uri() . '/inc/images/content-sidebar.png',
+                ),
+                'sidebar-content' => array(
+                        'value' => 'sidebar-content',
+                        'label' => __( 'Content on right', 'twentyeleven' ),
+                        'thumbnail' => get_template_directory_uri() . '/inc/images/sidebar-content.png',
+                ),
+                'content' => array(
+                        'value' => 'content',
+                        'label' => __( 'One-column, no Sidebar', 'twentyeleven' ),
+                        'thumbnail' => get_template_directory_uri() . '/inc/images/content.png',
+                ),
+        );
+
+        return apply_filters( 'twentyeleven_layouts', $layout_options );
+}
+
+/**
+ * Returns the default options for Twenty Eleven.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_get_default_theme_options() {
+        $default_theme_options = array(
+                'color_scheme' => 'light',
+                'link_color' => '#1b8be0',
+                'theme_layout' => 'content-sidebar',
+        );
+
+        return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );
+}
+
+/**
+ * Returns the options array for Twenty Eleven.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_get_theme_options() {
+        return get_option( 'twentyeleven_theme_options' );
+}
+
+/**
+ * Returns the options array for Twenty Eleven.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function theme_options_render_page() {
+        ?>
+        <div class="wrap">
+                <?php screen_icon(); ?>
+                <h2><?php printf( __( '%s Theme Options', 'twentyeleven' ), get_current_theme() ); ?></h2>
+                <?php settings_errors(); ?>
+
+                <form method="post" action="options.php">
+                        <?php
+                                settings_fields( 'twentyeleven_options' );
+                                $options = twentyeleven_get_theme_options();
+                                $default_options = twentyeleven_get_default_theme_options();
+                        ?>
+
+                        <table class="form-table">
+
+                                <tr valign="top" class="image-radio-option"><th scope="row"><?php _e( 'Color Scheme', 'twentyeleven' ); ?></th>
+                                        <td>
+                                                <fieldset><legend class="screen-reader-text"><span><?php _e( 'Color Scheme', 'twentyeleven' ); ?></span></legend>
+                                                <?php
+                                                        foreach ( twentyeleven_color_schemes() as $color ) {
+                                                                ?>
+                                                                <div class="layout">
+                                                                <label class="description">
+                                                                        <input type="radio" name="twentyeleven_theme_options[color_scheme]" value="<?php echo esc_attr( $color['value'] ); ?>" <?php checked( $options['color_scheme'], $color['value'] ); ?> />
+                                                                        <span>
+                                                                                <img src="<?php echo esc_url( $color['thumbnail'] ); ?>"/>
+                                                                                <?php echo $color['label']; ?>
+                                                                        </span>
+                                                                </label>
+                                                                </div>
+                                                                <?php
+                                                        }
+                                                ?>
+                                                </fieldset>
+                                        </td>
+                                </tr>
+
+                                <tr valign="top"><th scope="row"><?php _e( 'Link Color', 'twentyeleven' ); ?></th>
+                                        <td>
+                                                <fieldset><legend class="screen-reader-text"><span><?php _e( 'Link Color', 'twentyeleven' ); ?></span></legend>
+                                                        <input type="text" name="twentyeleven_theme_options[link_color]" id="link-color" value="<?php echo esc_attr( $options['link_color'] ); ?>" />
+                                                        <a class="hide-if-no-js" href="#" id="pickcolor"><?php _e( 'Select a Color', 'twentyeleven' ); ?></a>
+                                                        <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
+                                                        <br />
+                                                        <small class="description"><?php printf( __( 'Default color: %s', 'twentyeleven' ), $default_options['link_color'] ); ?></small>
+                                                </fieldset>
+                                        </td>
+                                </tr>
+
+                                <tr valign="top" class="image-radio-option"><th scope="row"><?php _e( 'Layout', 'twentyeleven' ); ?></th>
+                                        <td>
+                                                <fieldset><legend class="screen-reader-text"><span><?php _e( 'Color Scheme', 'twentyeleven' ); ?></span></legend>
+                                                <?php
+                                                        foreach ( twentyeleven_layouts() as $layout ) {
+                                                                ?>
+                                                                <div class="layout">
+                                                                <label class="description">
+                                                                        <input type="radio" name="twentyeleven_theme_options[theme_layout]" value="<?php echo esc_attr( $layout['value'] ); ?>" <?php checked( $options['theme_layout'], $layout['value'] ); ?> />
+                                                                        <span>
+                                                                                <img src="<?php echo esc_url( $layout['thumbnail'] ); ?>"/>
+                                                                                <?php echo $layout['label']; ?>
+                                                                        </span>
+                                                                </label>
+                                                                </div>
+                                                                <?php
+                                                        }
+                                                ?>
+                                                </fieldset>
+                                        </td>
+                                </tr>
+                        </table>
+
+                        <?php submit_button(); ?>
+                </form>
+        </div>
+        <?php
+}
+
+/**
+ * Sanitize and validate form input. Accepts an array, return a sanitized array.
+ *
+ * @see twentyeleven_theme_options_init()
+ * @todo set up Reset Options action
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_theme_options_validate( $input ) {
+        $output = $defaults = twentyeleven_get_default_theme_options();
+
+        // Color scheme must be in our array of color scheme options
+        if ( isset( $input['color_scheme'] ) && array_key_exists( $input['color_scheme'], twentyeleven_color_schemes() ) )
+                $output['color_scheme'] = $input['color_scheme'];
+
+        // 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'], '#' ) );
+
+        // Theme layout must be in our array of theme layout options
+        if ( isset( $input['theme_layout'] ) && array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) )
+                $output['theme_layout'] = $input['theme_layout'];
+
+        return apply_filters( 'twentyeleven_theme_options_validate', $output, $input, $defaults );
+}
+
+/**
+ * Enqueue the styles for the current color scheme.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_color_styles() {
+        $options = twentyeleven_get_theme_options();
+        $color_scheme = $options['color_scheme'];
+
+        if ( 'dark' == $color_scheme )
+                wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', null, null );
+
+        do_action( 'twentyeleven_color_schemes', $color_scheme );
+}
+add_action( 'wp_enqueue_scripts', 'twentyeleven_color_styles' );
+
+/**
+ * Add a style block to the theme for the current link color.
+ *
+ * This function is attached to the wp_head action hook.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_link_color() {
+        $options = twentyeleven_get_theme_options();
+        $link_color = $options['link_color'];
+
+        $default_options = twentyeleven_get_default_theme_options();
+        
+        // Don't do anything if the current link color is the default.
+        if ( $default_options['link_color'] == $link_color )
+                return;
+?>
+        <style>
+                /* Link color */
+                a,
+                .entry-title a:hover {
+                        color: <?php echo $link_color; ?>;
+                }
+        </style>
+<?php
+}
+add_action( 'wp_head', 'twentyeleven_link_color' );
+
+/**
+ * Adds Twenty Eleven layout classes to the array of body classes.
+ *
+ * @since Twenty Eleven 1.0
+ */
+function twentyeleven_layout_classes( $classes ) {
+        $options = twentyeleven_get_theme_options();
+        $current_layout = $options['theme_layout'];
+
+        $twentyeleven_classes = array();
+
+        $two_column_layouts = array( 'content-sidebar', 'sidebar-content' );
+
+        if ( in_array( $current_layout, $two_column_layouts ) )
+                $twentyeleven_classes[] = 'two-column';
+        else
+                $twentyeleven_classes[] = 'one-column';
+
+        $twentyeleven_classes[] = $current_layout;
+
+        $twentyeleven_classes = apply_filters( 'twentyeleven_layout_classes', $twentyeleven_classes, $current_layout );
+
+        return array_merge( $classes, $twentyeleven_classes );
+}
+add_filter( 'body_class', 'twentyeleven_layout_classes' );
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>