diff --git a/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php b/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php index 6f576838f..7b414c895 100644 --- a/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php +++ b/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php @@ -75,15 +75,22 @@ function twentyeleven_layouts() { return $layout_options; } +/** + * Return the default Twenty Eleven theme option values + */ +function twentyeleven_get_default_theme_options() { + return array( + 'color_scheme' => 'light', + 'link_color' => '#1b8be0', + 'theme_layout' => 'content-sidebar', + ); +} + /** * Return the current Twenty Eleven theme options, with default values as fallback */ function twentyeleven_get_theme_options() { - $defaults = array( - 'color_scheme' => 'light', - 'link_color' => '1b8be0', - 'theme_layout' => 'content-sidebar', - ); + $defaults = twentyeleven_get_default_theme_options(); $options = get_option( 'twentyeleven_theme_options', $defaults ); return $options; @@ -205,7 +212,7 @@ function theme_options_do_page() {

- +

@@ -214,25 +221,33 @@ function theme_options_do_page() { /** * Sanitize and validate input. Accepts an array, return a sanitized array. + * + * todo set up Reset Options action */ 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 + $defaults = twentyeleven_get_default_theme_options(); - // 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; + // 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']; - // Our link color option must be safe text with no HTML tags - $input['link_color'] = wp_filter_nohtml_kses( $input['link_color'] ); + // 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']; + } + } - // 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; + // 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']; return $input; } @@ -286,16 +301,15 @@ function twentyeleven_link_color() { $current_link_color = $options['link_color']; // Is the link color just the default color? - if ( '1b8be0' == $current_link_color ) : + if ( '#1b8be0' == $current_link_color ) : return; // we don't need to do anything then - else : ?> article .comment-meta .vcard .avatar { } -.comment-reply-link { - color: #1778c2; +a.comment-reply-link { font-size: 12px; font-weight: bold; - text-decoration: none; } -.comment-reply-link:hover { +.comment-reply-link:hover, +.comment-reply-link:active, +.comment-reply-link:focus { } /* Post author highlighting */ @@ -1531,33 +1519,26 @@ section.ephemera .entry-title a span { color: #ccc; } .commentlist > li.bypostauthor .comment-meta a { - color: #ccc; - text-decoration: none; font-weight: bold; } .commentlist > li.bypostauthor .comment-meta a:focus, .commentlist > li.bypostauthor .comment-meta a:active, .commentlist > li.bypostauthor .comment-meta a:hover { - color: #ff4b33; } .commentlist > li.bypostauthor:before { content: url(images/comment-arrow-bypostauthor.png); } .commentlist > li.bypostauthor .comment-content a { - color: #1b8be0; } .commentlist > li.bypostauthor .comment-content a:focus, .commentlist > li.bypostauthor .comment-content a:active, .commentlist > li.bypostauthor .comment-content a:hover { - color: #ff4b33; } .commentlist > li.bypostauthor .comment-reply-link { - color: #ccc; } .commentlist > li.bypostauthor .comment-reply-link:focus, .commentlist > li.bypostauthor .comment-reply-link:active, .commentlist > li.bypostauthor .comment-reply-link:hover { - color: #ff4b33; } /* Post Author threaded comments */ @@ -1565,12 +1546,10 @@ section.ephemera .entry-title a span { .commentlist > li.bypostauthor .children .comment-meta, .commentlist > li.bypostauthor .children .comment-meta a, .commentlist > li.bypostauthor .children .comment-reply-link { - color: #333; } .commentlist > li.bypostauthor .children .comment-meta a:focus, .commentlist > li.bypostauthor .children .comment-meta a:active, .commentlist > li.bypostauthor .children .comment-meta a:hover { - color: #ff4b33; } .commentlist .children > li.bypostauthor { background: #222; @@ -1581,8 +1560,6 @@ section.ephemera .entry-title a span { color: #ccc; } .commentlist .children > li.bypostauthor > article .comment-meta a { - color: #ccc; - text-decoration: none; font-weight: bold; } .commentlist .children > li.bypostauthor > article .comment-reply-link { @@ -1594,7 +1571,6 @@ section.ephemera .entry-title a span { .commentlist .children > li.bypostauthor > article .comment-reply-link:focus, .commentlist .children > li.bypostauthor > article .comment-reply-link:active, .commentlist .children > li.bypostauthor > article .comment-reply-link:hover { - color: #ff4b33; } .commentlist .children > li.bypostauthor > article .comment-content a { color: #1b8be0; @@ -1602,7 +1578,6 @@ section.ephemera .entry-title a span { .commentlist .children > li.bypostauthor > article .comment-content a:focus, .commentlist .children > li.bypostauthor > article .comment-content a:active, .commentlist .children > li.bypostauthor > article .comment-content a:hover { - color: #ff4b33; } /* Comment Form */ @@ -1618,12 +1593,10 @@ section.ephemera .entry-title a span { width: 68.9%; } #respond a { - color: #ccc; } #respond a:focus, #respond a:active, #respond a:hover { - color: #ff4b33; } #respond input[type="text"], #respond textarea { @@ -1686,9 +1659,6 @@ section.ephemera .entry-title a span { font-size: 13px; } #respond .logged-in-as a { - color: #478fa2; - font-weight: bold; - text-decoration: none; } #respond p { margin: 10px 0; @@ -1816,7 +1786,6 @@ p.comment-form-comment { text-align: center; } #site-generator a { - text-decoration: none; font-weight: bold; } #site-generator a:focus,