- Timestamp:
- 04/27/2011 11:03:27 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyeleven/inc/theme-options/theme-options.php
r17721 r17732 77 77 78 78 /** 79 * Return the current Twenty Eleven theme options, with default values as fallback80 */ 81 function twentyeleven_get_ theme_options() {82 $defaults =array(79 * Return the default Twenty Eleven theme option values 80 */ 81 function twentyeleven_get_default_theme_options() { 82 return array( 83 83 'color_scheme' => 'light', 84 'link_color' => ' 1b8be0',84 'link_color' => '#1b8be0', 85 85 'theme_layout' => 'content-sidebar', 86 86 ); 87 } 88 89 /** 90 * Return the current Twenty Eleven theme options, with default values as fallback 91 */ 92 function twentyeleven_get_theme_options() { 93 $defaults = twentyeleven_get_default_theme_options(); 87 94 $options = get_option( 'twentyeleven_theme_options', $defaults ); 88 95 … … 206 213 207 214 <p class="submit"> 208 <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'twentyeleven' ); ?>" />215 <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Options', 'twentyeleven' ); ?>" /> 209 216 </p> 210 217 </form> … … 215 222 /** 216 223 * Sanitize and validate input. Accepts an array, return a sanitized array. 224 * 225 * todo set up Reset Options action 217 226 */ 218 227 function twentyeleven_theme_options_validate( $input ) { 219 // todo get defaults, and use insteadd of null for fallback 220 // could also be used to trigger a Reset Options action 221 222 // Our color scheme option must actually be in our array of color scheme options 223 if ( ! isset( $input['color_scheme'] ) ) 224 $input['color_scheme'] = null; 225 if ( ! array_key_exists( $input['color_scheme'], twentyeleven_color_schemes() ) ) 226 $input['color_scheme'] = null; 227 228 // Our link color option must be safe text with no HTML tags 229 $input['link_color'] = wp_filter_nohtml_kses( $input['link_color'] ); 230 231 // Our theme layout option must actually be in our array of theme layout options 232 if ( ! isset( $input['theme_layout'] ) ) 233 $input['theme_layout'] = null; 234 if ( ! array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) ) 235 $input['theme_layout'] = null; 228 $defaults = twentyeleven_get_default_theme_options(); 229 230 // Color scheme must be in our array of color scheme options 231 if ( ! isset( $input['color_scheme'] ) || ! array_key_exists( $input['color_scheme'], twentyeleven_color_schemes() ) ) 232 $input['color_scheme'] = $defaults['color_scheme']; 233 234 // Link color must be 3 or 6 hexadecimal characters 235 if ( ! isset( $input[ 'link_color' ] ) ) { 236 $input['link_color'] = $defaults['link_color']; 237 } else { 238 if ( preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'] ) ) { 239 $link_color = $input['link_color']; 240 // If color value doesn't have a preceding hash, add it 241 if ( false === strpos( $link_color, '#' ) ) 242 $link_color = '#' . $link_color; 243 } else { 244 $input['link_color'] = $defaults['link_color']; 245 } 246 } 247 248 // Theme layout must be in our array of theme layout options 249 if ( ! isset( $input['theme_layout'] ) || ! array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) ) 250 $input['theme_layout'] = $defaults['theme_layout']; 236 251 237 252 return $input; … … 287 302 288 303 // Is the link color just the default color? 289 if ( ' 1b8be0' == $current_link_color ) :304 if ( '#1b8be0' == $current_link_color ) : 290 305 return; // we don't need to do anything then 291 292 306 else : 293 307 ?> … … 296 310 a, 297 311 .entry-title a:hover { 298 color: <?php echo $current_link_color ?>;312 color: <?php echo $current_link_color; ?>; 299 313 } 300 314 </style>
Note: See TracChangeset
for help on using the changeset viewer.