<!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>[17732] trunk/wp-content/themes/twentyeleven: Twenty Eleven:
  theme options - see #17198</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17732">17732</a></dd>
<dt>Author</dt> <dd>lancewillett</dd>
<dt>Date</dt> <dd>2011-04-27 23:03:27 +0000 (Wed, 27 Apr 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Twenty Eleven: theme options - see <a href="http://trac.wordpress.org/ticket/17198">#17198</a>

 * First pass at Link Color CSS rules
 * Add new function to return default values
 * Implement better validation for hex color value
 * Fix missing esc_attr()</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsphp">trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenstylecss">trunk/wp-content/themes/twentyeleven/style.css</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsthemeoptionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php (17731 => 17732)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php        2011-04-27 22:06:01 UTC (rev 17731)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php        2011-04-27 23:03:27 UTC (rev 17732)
</span><span class="lines">@@ -76,14 +76,21 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- *  Return the current Twenty Eleven theme options, with default values as fallback
</del><ins>+ *  Return the default Twenty Eleven theme option values
</ins><span class="cx">  */
</span><del>-function twentyeleven_get_theme_options() {
-        $defaults = array(
</del><ins>+function twentyeleven_get_default_theme_options() {
+        return array(
</ins><span class="cx">                 'color_scheme' =&gt; 'light',
</span><del>-                'link_color' =&gt; '1b8be0',
</del><ins>+                'link_color' =&gt; '#1b8be0',
</ins><span class="cx">                 'theme_layout' =&gt; 'content-sidebar',
</span><span class="cx">         );
</span><ins>+}
+
+/**
+ *  Return the current Twenty Eleven theme options, with default values as fallback
+ */
+function twentyeleven_get_theme_options() {
+        $defaults = twentyeleven_get_default_theme_options();
</ins><span class="cx">         $options = get_option( 'twentyeleven_theme_options', $defaults );
</span><span class="cx"> 
</span><span class="cx">         return $options;
</span><span class="lines">@@ -205,7 +212,7 @@
</span><span class="cx">                         &lt;/table&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;p class=&quot;submit&quot;&gt;
</span><del>-                                &lt;input type=&quot;submit&quot; class=&quot;button-primary&quot; value=&quot;&lt;?php _e( 'Save Options', 'twentyeleven' ); ?&gt;&quot; /&gt;
</del><ins>+                                &lt;input type=&quot;submit&quot; class=&quot;button-primary&quot; value=&quot;&lt;?php esc_attr_e( 'Save Options', 'twentyeleven' ); ?&gt;&quot; /&gt;
</ins><span class="cx">                         &lt;/p&gt;
</span><span class="cx">                 &lt;/form&gt;
</span><span class="cx">         &lt;/div&gt;
</span><span class="lines">@@ -214,25 +221,33 @@
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Sanitize and validate input. Accepts an array, return a sanitized array.
</span><ins>+ *
+ * todo set up Reset Options action
</ins><span class="cx">  */
</span><span class="cx"> function twentyeleven_theme_options_validate( $input ) {
</span><del>-        // todo get defaults, and use insteadd of null for fallback
-        // could also be used to trigger a Reset Options action
</del><ins>+        $defaults = twentyeleven_get_default_theme_options();
</ins><span class="cx"> 
</span><del>-        // 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;
</del><ins>+        // 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() ) )
+                $input['color_scheme'] = $defaults['color_scheme'];
</ins><span class="cx"> 
</span><del>-        // Our link color option must be safe text with no HTML tags
-        $input['link_color'] = wp_filter_nohtml_kses( $input['link_color'] );
</del><ins>+        // Link color must be 3 or 6 hexadecimal characters
+        if ( ! isset( $input[ 'link_color' ] ) ) {
+                $input['link_color'] = $defaults['link_color'];
+        } else {
+                if ( preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'] ) ) {
+                        $link_color = $input['link_color'];
+                        // If color value doesn't have a preceding hash, add it
+                        if ( false === strpos( $link_color, '#' ) )
+                                $link_color = '#' . $link_color;
+                } else {
+                        $input['link_color'] = $defaults['link_color'];
+                }
+        }
</ins><span class="cx"> 
</span><del>-        // 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;
</del><ins>+        // Theme layout must be in our array of theme layout options
+        if ( ! isset( $input['theme_layout'] ) || ! array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) )
+                $input['theme_layout'] = $defaults['theme_layout'];
</ins><span class="cx"> 
</span><span class="cx">         return $input;
</span><span class="cx"> }
</span><span class="lines">@@ -286,16 +301,15 @@
</span><span class="cx">         $current_link_color = $options['link_color'];
</span><span class="cx"> 
</span><span class="cx">         // Is the link color just the default color?
</span><del>-        if ( '1b8be0' == $current_link_color ) :
</del><ins>+        if ( '#1b8be0' == $current_link_color ) :
</ins><span class="cx">                 return; // we don't need to do anything then
</span><del>-
</del><span class="cx">         else :
</span><span class="cx">                 ?&gt;
</span><span class="cx">                         &lt;style&gt;
</span><span class="cx">                                 /* Link color */
</span><span class="cx">                                 a,
</span><span class="cx">                                 .entry-title a:hover {
</span><del>-                                    color: &lt;?php echo $current_link_color ?&gt;;
</del><ins>+                                    color: &lt;?php echo $current_link_color; ?&gt;;
</ins><span class="cx">                                 }
</span><span class="cx">                         &lt;/style&gt;
</span><span class="cx">                 &lt;?php
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenstylecss"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/style.css (17731 => 17732)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/style.css        2011-04-27 22:06:01 UTC (rev 17731)
+++ trunk/wp-content/themes/twentyeleven/style.css        2011-04-27 23:03:27 UTC (rev 17732)
</span><span class="lines">@@ -310,15 +310,15 @@
</span><span class="cx"> 
</span><span class="cx"> /* Links */
</span><span class="cx"> a {
</span><del>-        color: #444;
</del><ins>+        color: #1B8BE0;
+        text-decoration: none;
</ins><span class="cx"> }
</span><span class="cx"> a:visited {
</span><del>-        color: #444;
</del><span class="cx"> }
</span><span class="cx"> a:focus,
</span><span class="cx"> a:active,
</span><span class="cx"> a:hover {
</span><del>-        color: #1b8be0;
</del><ins>+        text-decoration: underline;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -454,6 +454,8 @@
</span><span class="cx"> }
</span><span class="cx"> #branding #s {
</span><span class="cx">         background: url(images/search.png) no-repeat 5px 6px;
</span><ins>+        -moz-border-radius: 2px;
+        border-radius: 2px;
</ins><span class="cx">         float: right;
</span><span class="cx">         font-size: 14px;
</span><span class="cx">         height: 22px;
</span><span class="lines">@@ -515,7 +517,6 @@
</span><span class="cx">         font-size: 12px;
</span><span class="cx">         font-weight: bold;
</span><span class="cx">         letter-spacing: 0;
</span><del>-        text-decoration: none;
</del><span class="cx">         text-transform: none;
</span><span class="cx"> }
</span><span class="cx"> .hentry {
</span><span class="lines">@@ -556,14 +557,11 @@
</span><span class="cx">         line-height: 18px;
</span><span class="cx"> }
</span><span class="cx"> .entry-meta a {
</span><del>-        color: #222;
</del><span class="cx">         font-weight: bold;
</span><del>-        text-decoration: none;
</del><span class="cx"> }
</span><span class="cx"> .entry-meta a:focus,
</span><span class="cx"> .entry-meta a:active,
</span><span class="cx"> .entry-meta a:hover {
</span><del>-        color: #1b8be0;
</del><span class="cx"> }
</span><span class="cx"> .entry-content,
</span><span class="cx"> .entry-summary {
</span><span class="lines">@@ -585,10 +583,8 @@
</span><span class="cx">         text-transform: uppercase;
</span><span class="cx"> }
</span><span class="cx"> .entry-content a {
</span><del>-        color: #1b8be0;
</del><span class="cx"> }
</span><span class="cx"> .entry-content a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> .entry-content table,
</span><span class="cx"> .comment-content table {
</span><span class="lines">@@ -642,8 +638,8 @@
</span><span class="cx">         text-decoration: none;
</span><span class="cx"> }
</span><span class="cx"> .page-link a:hover {
</span><del>-        background: #1b8be0;
-        color: #bfddf3;
</del><ins>+        background: #777;
+        color: #fff;
</ins><span class="cx">         font-weight: bold;
</span><span class="cx"> }
</span><span class="cx"> .page-link span {
</span><span class="lines">@@ -729,9 +725,9 @@
</span><span class="cx">         line-height: 46px;
</span><span class="cx"> }
</span><span class="cx"> .entry-header .comments-link a:hover {
</span><del>-        background: #1b8be0;
-        border-color: #0861a5;
-        color: #bfddf3;
</del><ins>+        background: #777;
+        color: #fff;
+        border-color: #555;
</ins><span class="cx"> }
</span><span class="cx"> .entry-header .comments-link .leave-reply {
</span><span class="cx">         font-size: 14px;
</span><span class="lines">@@ -766,10 +762,8 @@
</span><span class="cx">         left: 0;
</span><span class="cx"> }
</span><span class="cx"> .singular .entry-header a {
</span><del>-        color: #1b8be0;
</del><span class="cx"> }
</span><span class="cx"> .singular .entry-header a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> .singular footer.entry-meta {
</span><span class="cx"> }
</span><span class="lines">@@ -790,6 +784,7 @@
</span><span class="cx">         width: 33%;
</span><span class="cx"> }
</span><span class="cx"> .singular .entry-meta .edit-link a {
</span><ins>+        color: #fff;
</ins><span class="cx">         position: absolute;
</span><span class="cx">         bottom: auto;
</span><span class="cx">         left: 50px;
</span><span class="lines">@@ -1218,16 +1213,13 @@
</span><span class="cx">         padding: 0 0 1.625em;
</span><span class="cx"> }
</span><span class="cx"> #content nav a {
</span><del>-        color: #1b8be0;
</del><span class="cx">         font-size: 12px;
</span><span class="cx">         font-weight: bold;
</span><span class="cx">         line-height: 2.2em;
</span><del>-        text-decoration: none;
</del><span class="cx"> }
</span><span class="cx"> #content nav a:focus,
</span><span class="cx"> #content nav a:active,
</span><span class="cx"> #content nav a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> #nav-above {
</span><span class="cx">         padding: 0 0 1.625em;
</span><span class="lines">@@ -1292,12 +1284,11 @@
</span><span class="cx">         font-size: 13px;
</span><span class="cx"> }
</span><span class="cx"> .widget a {
</span><del>-        color: #1b8be0;
</del><span class="cx">         font-weight: bold;
</span><span class="cx">         text-decoration: none;
</span><span class="cx"> }
</span><span class="cx"> .widget a:hover {
</span><del>-        color: #ff4b33;
</del><ins>+        text-decoration: underline;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Search Widget */
</span><span class="lines">@@ -1473,14 +1464,11 @@
</span><span class="cx">         margin: 1.625em 0 0;
</span><span class="cx"> }
</span><span class="cx"> .comment-meta a {
</span><del>-        color: #1b8be0;
-        text-decoration: none;
</del><span class="cx">         font-weight: bold;
</span><span class="cx"> }
</span><span class="cx"> .comment-meta a:focus,
</span><span class="cx"> .comment-meta a:active,
</span><span class="cx"> .comment-meta a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> .commentlist .avatar {
</span><span class="cx">         -moz-border-radius: 3px;
</span><span class="lines">@@ -1512,13 +1500,13 @@
</span><span class="cx"> }
</span><span class="cx"> .commentlist .children .bypostauthor &gt; article .comment-meta .vcard .avatar {
</span><span class="cx"> }
</span><del>-.comment-reply-link {
-        color: #1778c2;
</del><ins>+a.comment-reply-link {
</ins><span class="cx">         font-size: 12px;
</span><span class="cx">         font-weight: bold;
</span><del>-        text-decoration: none;
</del><span class="cx"> }
</span><del>-.comment-reply-link:hover {
</del><ins>+.comment-reply-link:hover,
+.comment-reply-link:active,
+.comment-reply-link:focus {
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Post author highlighting */
</span><span class="lines">@@ -1531,33 +1519,26 @@
</span><span class="cx">         color: #ccc;
</span><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-meta a {
</span><del>-        color: #ccc;
-        text-decoration: none;
</del><span class="cx">         font-weight: bold;
</span><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-meta a:focus,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-meta a:active,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-meta a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor:before {
</span><span class="cx">         content: url(images/comment-arrow-bypostauthor.png);
</span><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-content a {
</span><del>-        color: #1b8be0;
</del><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-content a:focus,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-content a:active,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-content a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-reply-link {
</span><del>-        color: #ccc;
</del><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-reply-link:focus,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-reply-link:active,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .comment-reply-link:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Post Author threaded comments */
</span><span class="lines">@@ -1565,12 +1546,10 @@
</span><span class="cx"> .commentlist &gt; li.bypostauthor .children .comment-meta,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .children .comment-meta a,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .children .comment-reply-link {
</span><del>-        color: #333;
</del><span class="cx"> }
</span><span class="cx"> .commentlist &gt; li.bypostauthor .children .comment-meta a:focus,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .children .comment-meta a:active,
</span><span class="cx"> .commentlist &gt; li.bypostauthor .children .comment-meta a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor {
</span><span class="cx">         background: #222;
</span><span class="lines">@@ -1581,8 +1560,6 @@
</span><span class="cx">         color: #ccc;
</span><span class="cx"> }
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-meta a {
</span><del>-        color: #ccc;
-        text-decoration: none;
</del><span class="cx">         font-weight: bold;
</span><span class="cx"> }
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-reply-link {
</span><span class="lines">@@ -1594,7 +1571,6 @@
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-reply-link:focus,
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-reply-link:active,
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-reply-link:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-content a {
</span><span class="cx">         color: #1b8be0;
</span><span class="lines">@@ -1602,7 +1578,6 @@
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-content a:focus,
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-content a:active,
</span><span class="cx"> .commentlist .children &gt; li.bypostauthor &gt; article .comment-content a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* Comment Form */
</span><span class="lines">@@ -1618,12 +1593,10 @@
</span><span class="cx">         width: 68.9%;
</span><span class="cx"> }
</span><span class="cx"> #respond a {
</span><del>-        color: #ccc;
</del><span class="cx"> }
</span><span class="cx"> #respond a:focus,
</span><span class="cx"> #respond a:active,
</span><span class="cx"> #respond a:hover {
</span><del>-        color: #ff4b33;
</del><span class="cx"> }
</span><span class="cx"> #respond input[type=&quot;text&quot;],
</span><span class="cx"> #respond textarea {
</span><span class="lines">@@ -1686,9 +1659,6 @@
</span><span class="cx">         font-size: 13px;
</span><span class="cx"> }
</span><span class="cx"> #respond .logged-in-as a {
</span><del>-        color: #478fa2;
-        font-weight: bold;
-        text-decoration: none;
</del><span class="cx"> }
</span><span class="cx"> #respond p {
</span><span class="cx">         margin: 10px 0;
</span><span class="lines">@@ -1816,7 +1786,6 @@
</span><span class="cx">         text-align: center;
</span><span class="cx"> }
</span><span class="cx"> #site-generator a {
</span><del>-        text-decoration: none;
</del><span class="cx">         font-weight: bold;
</span><span class="cx"> }
</span><span class="cx"> #site-generator a:focus,
</span></span></pre>
</div>
</div>

</body>
</html>