Ticket #25580: 25580.diff
| File 25580.diff, 4.3 KB (added by , 13 years ago) |
|---|
-
wp-content/themes/twentyfourteen/inc/customizer.php
20 20 21 21 $wp_customize->add_setting( 'accent_color', array( 22 22 'default' => '#24890d', 23 'sanitize_callback' => ' twentyfourteen_generate_accent_colors',23 'sanitize_callback' => 'sanitize_hex_color', 24 24 ) ); 25 25 26 26 $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'accent_color', array( … … 28 28 'section' => 'colors', 29 29 'settings' => 'accent_color', 30 30 ) ) ); 31 32 add_filter( 'theme_mod_accent_hover', 'twentyfourteen_accent_hover' ); 33 add_filter( 'theme_mod_accent_active', 'twentyfourteen_accent_active' ); 31 34 } 32 35 add_action( 'customize_register', 'twentyfourteen_customize_register' ); 33 36 … … 42 45 add_action( 'customize_preview_init', 'twentyfourteen_customize_preview_js' ); 43 46 44 47 /** 45 * Generate two variants of the accent color, return the original, and46 * save the others as theme mods.47 *48 * @since Twenty Fourteen 1.049 *50 * @param string $color The original color.51 * @return string $color The original color, sanitized.52 */53 function twentyfourteen_generate_accent_colors( $color ) {54 $color = sanitize_hex_color( $color );55 56 set_theme_mod( 'accent_lighter', twentyfourteen_adjust_color( $color, 14 ) );57 set_theme_mod( 'accent_much_lighter', twentyfourteen_adjust_color( $color, 71 ) );58 59 return $color;60 }61 62 /**63 48 * Tweak the brightness of a color by adjusting the RGB values by the given interval. 64 49 * 65 50 * Use positive values of $steps to brighten the color and negative values to darken the color. … … 96 81 } 97 82 98 83 /** 84 * Returns a slightly lighter color than what is set as the theme's 85 * accent color. 86 * 87 * @since Twenty Fourteen 1.0 88 * 89 * @return string 90 */ 91 function twentyfourteen_accent_hover() { 92 return twentyfourteen_adjust_color( get_theme_mod( 'accent_color' ), 14 ); 93 } 94 95 /** 96 * Returns a lighter color than what is set as the theme's accent color. 97 * 98 * @since Twenty Fourteen 1.0 99 * 100 * @return string 101 */ 102 function twentyfourteen_accent_active() { 103 return twentyfourteen_adjust_color( get_theme_mod( 'accent_color' ), 71 ); 104 } 105 106 /** 107 * Caches the secondary colors for the theme's accent color. 108 * 109 * @since Twenty Fourteen 1.0 110 * 111 * @return void 112 */ 113 function twentyfourteen_rebuild_accent_colors() { 114 set_theme_mod( 'accent_hover', twentyfourteen_accent_hover() ); 115 set_theme_mod( 'accent_active', twentyfourteen_accent_active() ); 116 } 117 add_action( 'update_option_theme_mods_twentyfourteen', 'twentyfourteen_rebuild_accent_colors' ); 118 119 /** 99 120 * Output the CSS for the Theme Customizer options. 100 121 * 101 122 * @since Twenty Fourteen 1.0 … … 103 124 * @return void 104 125 */ 105 126 function twentyfourteen_customizer_styles() { 106 $accent_color = get_theme_mod( 'accent_color' );127 $accent_color = get_theme_mod( 'accent_color', '#24890d' ); 107 128 108 129 // Don't do anything if the current color is the default. 109 130 if ( '#24890d' === $accent_color ) 110 131 return; 111 132 112 $accent_ lighter = get_theme_mod( 'accent_lighter');113 $accent_ much_lighter = get_theme_mod( 'accent_much_lighter' );133 $accent_hover = get_theme_mod( 'accent_hover' ); 134 $accent_active = get_theme_mod( 'accent_active' ); 114 135 115 136 $css = '<style type="text/css" id="twentyfourteen-accent-color"> 116 137 /* Custom accent color. */ … … 175 196 input[type="reset"]:focus, 176 197 input[type="submit"]:focus, 177 198 .widget_calendar tbody a:hover { 178 background-color: ' . $accent_ lighter . ';199 background-color: ' . $accent_hover . '; 179 200 } 180 201 181 202 /* Generated variant of custom accent color: much lighter. */ … … 183 204 html input[type="button"]:active, 184 205 input[type="reset"]:active, 185 206 input[type="submit"]:active { 186 background-color: ' . $accent_ much_lighter. ';207 background-color: ' . $accent_active . '; 187 208 } 188 209 189 210 a:hover, … … 196 217 #secondary .current-menu-item > a, 197 218 .featured-content a:hover, 198 219 .featured-content .more-link, 199 .widget-area a:hover { 200 color: ' . $accent_much_lighter . '; 220 .widget-area a:hover, 221 .content-sidebar .widget_twentyfourteen_ephemera .post-format-archive-link:hover { 222 color: ' . $accent_active . '; 201 223 } 202 224 </style>'; 203 225