customizer.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. <?php
  2. /**
  3. * Twenty Fifteen Customizer functionality
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Fifteen
  7. * @since Twenty Fifteen 1.0
  8. */
  9. /**
  10. * Add postMessage support for site title and description for the Customizer.
  11. *
  12. * @since Twenty Fifteen 1.0
  13. *
  14. * @param WP_Customize_Manager $wp_customize Customizer object.
  15. */
  16. function twentyfifteen_customize_register( $wp_customize ) {
  17. $color_scheme = twentyfifteen_get_color_scheme();
  18. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
  19. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
  20. // Add color scheme setting and control.
  21. $wp_customize->add_setting( 'color_scheme', array(
  22. 'default' => 'default',
  23. 'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme',
  24. 'transport' => 'postMessage',
  25. ) );
  26. $wp_customize->add_control( 'color_scheme', array(
  27. 'label' => __( 'Base Color Scheme', 'twentyfifteen' ),
  28. 'section' => 'colors',
  29. 'type' => 'select',
  30. 'choices' => twentyfifteen_get_color_scheme_choices(),
  31. 'priority' => 1,
  32. ) );
  33. // Add custom header and sidebar text color setting and control.
  34. $wp_customize->add_setting( 'sidebar_textcolor', array(
  35. 'default' => $color_scheme[4],
  36. 'sanitize_callback' => 'sanitize_hex_color',
  37. 'transport' => 'postMessage',
  38. ) );
  39. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sidebar_textcolor', array(
  40. 'label' => __( 'Header and Sidebar Text Color', 'twentyfifteen' ),
  41. 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
  42. 'section' => 'colors',
  43. ) ) );
  44. // Remove the core header textcolor control, as it shares the sidebar text color.
  45. $wp_customize->remove_control( 'header_textcolor' );
  46. // Add custom header and sidebar background color setting and control.
  47. $wp_customize->add_setting( 'header_background_color', array(
  48. 'default' => $color_scheme[1],
  49. 'sanitize_callback' => 'sanitize_hex_color',
  50. 'transport' => 'postMessage',
  51. ) );
  52. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background_color', array(
  53. 'label' => __( 'Header and Sidebar Background Color', 'twentyfifteen' ),
  54. 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
  55. 'section' => 'colors',
  56. ) ) );
  57. // Add an additional description to the header image section.
  58. $wp_customize->get_section( 'header_image' )->description = __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' );
  59. }
  60. add_action( 'customize_register', 'twentyfifteen_customize_register', 11 );
  61. /**
  62. * Register color schemes for Twenty Fifteen.
  63. *
  64. * Can be filtered with {@see 'twentyfifteen_color_schemes'}.
  65. *
  66. * The order of colors in a colors array:
  67. * 1. Main Background Color.
  68. * 2. Sidebar Background Color.
  69. * 3. Box Background Color.
  70. * 4. Main Text and Link Color.
  71. * 5. Sidebar Text and Link Color.
  72. * 6. Meta Box Background Color.
  73. *
  74. * @since Twenty Fifteen 1.0
  75. *
  76. * @return array An associative array of color scheme options.
  77. */
  78. function twentyfifteen_get_color_schemes() {
  79. return apply_filters( 'twentyfifteen_color_schemes', array(
  80. 'default' => array(
  81. 'label' => __( 'Default', 'twentyfifteen' ),
  82. 'colors' => array(
  83. '#f1f1f1',
  84. '#ffffff',
  85. '#ffffff',
  86. '#333333',
  87. '#333333',
  88. '#f7f7f7',
  89. ),
  90. ),
  91. 'dark' => array(
  92. 'label' => __( 'Dark', 'twentyfifteen' ),
  93. 'colors' => array(
  94. '#111111',
  95. '#202020',
  96. '#202020',
  97. '#bebebe',
  98. '#bebebe',
  99. '#1b1b1b',
  100. ),
  101. ),
  102. 'yellow' => array(
  103. 'label' => __( 'Yellow', 'twentyfifteen' ),
  104. 'colors' => array(
  105. '#f4ca16',
  106. '#ffdf00',
  107. '#ffffff',
  108. '#111111',
  109. '#111111',
  110. '#f1f1f1',
  111. ),
  112. ),
  113. 'pink' => array(
  114. 'label' => __( 'Pink', 'twentyfifteen' ),
  115. 'colors' => array(
  116. '#ffe5d1',
  117. '#e53b51',
  118. '#ffffff',
  119. '#352712',
  120. '#ffffff',
  121. '#f1f1f1',
  122. ),
  123. ),
  124. 'purple' => array(
  125. 'label' => __( 'Purple', 'twentyfifteen' ),
  126. 'colors' => array(
  127. '#674970',
  128. '#2e2256',
  129. '#ffffff',
  130. '#2e2256',
  131. '#ffffff',
  132. '#f1f1f1',
  133. ),
  134. ),
  135. 'blue' => array(
  136. 'label' => __( 'Blue', 'twentyfifteen' ),
  137. 'colors' => array(
  138. '#e9f2f9',
  139. '#55c3dc',
  140. '#ffffff',
  141. '#22313f',
  142. '#ffffff',
  143. '#f1f1f1',
  144. ),
  145. ),
  146. ) );
  147. }
  148. if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ) :
  149. /**
  150. * Get the current Twenty Fifteen color scheme.
  151. *
  152. * @since Twenty Fifteen 1.0
  153. *
  154. * @return array An associative array of either the current or default color scheme hex values.
  155. */
  156. function twentyfifteen_get_color_scheme() {
  157. $color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
  158. $color_schemes = twentyfifteen_get_color_schemes();
  159. if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
  160. return $color_schemes[ $color_scheme_option ]['colors'];
  161. }
  162. return $color_schemes['default']['colors'];
  163. }
  164. endif; // twentyfifteen_get_color_scheme
  165. if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) :
  166. /**
  167. * Returns an array of color scheme choices registered for Twenty Fifteen.
  168. *
  169. * @since Twenty Fifteen 1.0
  170. *
  171. * @return array Array of color schemes.
  172. */
  173. function twentyfifteen_get_color_scheme_choices() {
  174. $color_schemes = twentyfifteen_get_color_schemes();
  175. $color_scheme_control_options = array();
  176. foreach ( $color_schemes as $color_scheme => $value ) {
  177. $color_scheme_control_options[ $color_scheme ] = $value['label'];
  178. }
  179. return $color_scheme_control_options;
  180. }
  181. endif; // twentyfifteen_get_color_scheme_choices
  182. if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) :
  183. /**
  184. * Sanitization callback for color schemes.
  185. *
  186. * @since Twenty Fifteen 1.0
  187. *
  188. * @param string $value Color scheme name value.
  189. * @return string Color scheme name.
  190. */
  191. function twentyfifteen_sanitize_color_scheme( $value ) {
  192. $color_schemes = twentyfifteen_get_color_scheme_choices();
  193. if ( ! array_key_exists( $value, $color_schemes ) ) {
  194. $value = 'default';
  195. }
  196. return $value;
  197. }
  198. endif; // twentyfifteen_sanitize_color_scheme
  199. /**
  200. * Enqueues front-end CSS for color scheme.
  201. *
  202. * @since Twenty Fifteen 1.0
  203. *
  204. * @see wp_add_inline_style()
  205. */
  206. function twentyfifteen_color_scheme_css() {
  207. $color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
  208. // Don't do anything if the default color scheme is selected.
  209. if ( 'default' === $color_scheme_option ) {
  210. return;
  211. }
  212. $color_scheme = twentyfifteen_get_color_scheme();
  213. // Convert main and sidebar text hex color to rgba.
  214. $color_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[3] );
  215. $color_sidebar_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[4] );
  216. $colors = array(
  217. 'background_color' => $color_scheme[0],
  218. 'header_background_color' => $color_scheme[1],
  219. 'box_background_color' => $color_scheme[2],
  220. 'textcolor' => $color_scheme[3],
  221. 'secondary_textcolor' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_textcolor_rgb ),
  222. 'border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_textcolor_rgb ),
  223. 'border_focus_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_textcolor_rgb ),
  224. 'sidebar_textcolor' => $color_scheme[4],
  225. 'sidebar_border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_sidebar_textcolor_rgb ),
  226. 'sidebar_border_focus_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_sidebar_textcolor_rgb ),
  227. 'secondary_sidebar_textcolor' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_sidebar_textcolor_rgb ),
  228. 'meta_box_background_color' => $color_scheme[5],
  229. );
  230. $color_scheme_css = twentyfifteen_get_color_scheme_css( $colors );
  231. wp_add_inline_style( 'twentyfifteen-style', $color_scheme_css );
  232. }
  233. add_action( 'wp_enqueue_scripts', 'twentyfifteen_color_scheme_css' );
  234. /**
  235. * Binds JS listener to make Customizer color_scheme control.
  236. *
  237. * Passes color scheme data as colorScheme global.
  238. *
  239. * @since Twenty Fifteen 1.0
  240. */
  241. function twentyfifteen_customize_control_js() {
  242. wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20141216', true );
  243. wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() );
  244. }
  245. add_action( 'customize_controls_enqueue_scripts', 'twentyfifteen_customize_control_js' );
  246. /**
  247. * Binds JS handlers to make the Customizer preview reload changes asynchronously.
  248. *
  249. * @since Twenty Fifteen 1.0
  250. */
  251. function twentyfifteen_customize_preview_js() {
  252. wp_enqueue_script( 'twentyfifteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20141216', true );
  253. }
  254. add_action( 'customize_preview_init', 'twentyfifteen_customize_preview_js' );
  255. /**
  256. * Returns CSS for the color schemes.
  257. *
  258. * @since Twenty Fifteen 1.0
  259. *
  260. * @param array $colors Color scheme colors.
  261. * @return string Color scheme CSS.
  262. */
  263. function twentyfifteen_get_color_scheme_css( $colors ) {
  264. $colors = wp_parse_args( $colors, array(
  265. 'background_color' => '',
  266. 'header_background_color' => '',
  267. 'box_background_color' => '',
  268. 'textcolor' => '',
  269. 'secondary_textcolor' => '',
  270. 'border_color' => '',
  271. 'border_focus_color' => '',
  272. 'sidebar_textcolor' => '',
  273. 'sidebar_border_color' => '',
  274. 'sidebar_border_focus_color' => '',
  275. 'secondary_sidebar_textcolor' => '',
  276. 'meta_box_background_color' => '',
  277. ) );
  278. $css = <<<CSS
  279. /* Color Scheme */
  280. /* Background Color */
  281. body {
  282. background-color: {$colors['background_color']};
  283. }
  284. /* Sidebar Background Color */
  285. body:before,
  286. .site-header {
  287. background-color: {$colors['header_background_color']};
  288. }
  289. /* Box Background Color */
  290. .post-navigation,
  291. .pagination,
  292. .secondary,
  293. .site-footer,
  294. .hentry,
  295. .page-header,
  296. .page-content,
  297. .comments-area,
  298. .widecolumn {
  299. background-color: {$colors['box_background_color']};
  300. }
  301. /* Box Background Color */
  302. button,
  303. input[type="button"],
  304. input[type="reset"],
  305. input[type="submit"],
  306. .pagination .prev,
  307. .pagination .next,
  308. .widget_calendar tbody a,
  309. .widget_calendar tbody a:hover,
  310. .widget_calendar tbody a:focus,
  311. .page-links a,
  312. .page-links a:hover,
  313. .page-links a:focus,
  314. .sticky-post {
  315. color: {$colors['box_background_color']};
  316. }
  317. /* Main Text Color */
  318. button,
  319. input[type="button"],
  320. input[type="reset"],
  321. input[type="submit"],
  322. .pagination .prev,
  323. .pagination .next,
  324. .widget_calendar tbody a,
  325. .page-links a,
  326. .sticky-post {
  327. background-color: {$colors['textcolor']};
  328. }
  329. /* Main Text Color */
  330. body,
  331. blockquote cite,
  332. blockquote small,
  333. a,
  334. .dropdown-toggle:after,
  335. .image-navigation a:hover,
  336. .image-navigation a:focus,
  337. .comment-navigation a:hover,
  338. .comment-navigation a:focus,
  339. .widget-title,
  340. .entry-footer a:hover,
  341. .entry-footer a:focus,
  342. .comment-metadata a:hover,
  343. .comment-metadata a:focus,
  344. .pingback .edit-link a:hover,
  345. .pingback .edit-link a:focus,
  346. .comment-list .reply a:hover,
  347. .comment-list .reply a:focus,
  348. .site-info a:hover,
  349. .site-info a:focus {
  350. color: {$colors['textcolor']};
  351. }
  352. /* Main Text Color */
  353. .entry-content a,
  354. .entry-summary a,
  355. .page-content a,
  356. .comment-content a,
  357. .pingback .comment-body > a,
  358. .author-description a,
  359. .taxonomy-description a,
  360. .textwidget a,
  361. .entry-footer a:hover,
  362. .comment-metadata a:hover,
  363. .pingback .edit-link a:hover,
  364. .comment-list .reply a:hover,
  365. .site-info a:hover {
  366. border-color: {$colors['textcolor']};
  367. }
  368. /* Secondary Text Color */
  369. button:hover,
  370. button:focus,
  371. input[type="button"]:hover,
  372. input[type="button"]:focus,
  373. input[type="reset"]:hover,
  374. input[type="reset"]:focus,
  375. input[type="submit"]:hover,
  376. input[type="submit"]:focus,
  377. .pagination .prev:hover,
  378. .pagination .prev:focus,
  379. .pagination .next:hover,
  380. .pagination .next:focus,
  381. .widget_calendar tbody a:hover,
  382. .widget_calendar tbody a:focus,
  383. .page-links a:hover,
  384. .page-links a:focus {
  385. background-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
  386. background-color: {$colors['secondary_textcolor']};
  387. }
  388. /* Secondary Text Color */
  389. blockquote,
  390. a:hover,
  391. a:focus,
  392. .main-navigation .menu-item-description,
  393. .post-navigation .meta-nav,
  394. .post-navigation a:hover .post-title,
  395. .post-navigation a:focus .post-title,
  396. .image-navigation,
  397. .image-navigation a,
  398. .comment-navigation,
  399. .comment-navigation a,
  400. .widget,
  401. .author-heading,
  402. .entry-footer,
  403. .entry-footer a,
  404. .taxonomy-description,
  405. .page-links > .page-links-title,
  406. .entry-caption,
  407. .comment-author,
  408. .comment-metadata,
  409. .comment-metadata a,
  410. .pingback .edit-link,
  411. .pingback .edit-link a,
  412. .post-password-form label,
  413. .comment-form label,
  414. .comment-notes,
  415. .comment-awaiting-moderation,
  416. .logged-in-as,
  417. .form-allowed-tags,
  418. .no-comments,
  419. .site-info,
  420. .site-info a,
  421. .wp-caption-text,
  422. .gallery-caption,
  423. .comment-list .reply a,
  424. .widecolumn label,
  425. .widecolumn .mu_register label {
  426. color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
  427. color: {$colors['secondary_textcolor']};
  428. }
  429. /* Secondary Text Color */
  430. blockquote,
  431. .logged-in-as a:hover,
  432. .comment-author a:hover {
  433. border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
  434. border-color: {$colors['secondary_textcolor']};
  435. }
  436. /* Border Color */
  437. hr,
  438. .dropdown-toggle:hover,
  439. .dropdown-toggle:focus {
  440. background-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
  441. background-color: {$colors['border_color']};
  442. }
  443. /* Border Color */
  444. pre,
  445. abbr[title],
  446. table,
  447. th,
  448. td,
  449. input,
  450. textarea,
  451. .main-navigation ul,
  452. .main-navigation li,
  453. .post-navigation,
  454. .post-navigation div + div,
  455. .pagination,
  456. .comment-navigation,
  457. .widget li,
  458. .widget_categories .children,
  459. .widget_nav_menu .sub-menu,
  460. .widget_pages .children,
  461. .site-header,
  462. .site-footer,
  463. .hentry + .hentry,
  464. .author-info,
  465. .entry-content .page-links a,
  466. .page-links > span,
  467. .page-header,
  468. .comments-area,
  469. .comment-list + .comment-respond,
  470. .comment-list article,
  471. .comment-list .pingback,
  472. .comment-list .trackback,
  473. .comment-list .reply a,
  474. .no-comments {
  475. border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
  476. border-color: {$colors['border_color']};
  477. }
  478. /* Border Focus Color */
  479. a:focus,
  480. button:focus,
  481. input:focus {
  482. outline-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
  483. outline-color: {$colors['border_focus_color']};
  484. }
  485. input:focus,
  486. textarea:focus {
  487. border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */
  488. border-color: {$colors['border_focus_color']};
  489. }
  490. /* Sidebar Link Color */
  491. .secondary-toggle:before {
  492. color: {$colors['sidebar_textcolor']};
  493. }
  494. .site-title a,
  495. .site-description {
  496. color: {$colors['sidebar_textcolor']};
  497. }
  498. /* Sidebar Text Color */
  499. .site-title a:hover,
  500. .site-title a:focus {
  501. color: {$colors['secondary_sidebar_textcolor']};
  502. }
  503. /* Sidebar Border Color */
  504. .secondary-toggle {
  505. border-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */
  506. border-color: {$colors['sidebar_border_color']};
  507. }
  508. /* Sidebar Border Focus Color */
  509. .secondary-toggle:hover,
  510. .secondary-toggle:focus {
  511. border-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */
  512. border-color: {$colors['sidebar_border_focus_color']};
  513. }
  514. .site-title a {
  515. outline-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */
  516. outline-color: {$colors['sidebar_border_focus_color']};
  517. }
  518. /* Meta Background Color */
  519. .entry-footer {
  520. background-color: {$colors['meta_box_background_color']};
  521. }
  522. @media screen and (min-width: 38.75em) {
  523. /* Main Text Color */
  524. .page-header {
  525. border-color: {$colors['textcolor']};
  526. }
  527. }
  528. @media screen and (min-width: 59.6875em) {
  529. /* Make sure its transparent on desktop */
  530. .site-header,
  531. .secondary {
  532. background-color: transparent;
  533. }
  534. /* Sidebar Background Color */
  535. .widget button,
  536. .widget input[type="button"],
  537. .widget input[type="reset"],
  538. .widget input[type="submit"],
  539. .widget_calendar tbody a,
  540. .widget_calendar tbody a:hover,
  541. .widget_calendar tbody a:focus {
  542. color: {$colors['header_background_color']};
  543. }
  544. /* Sidebar Link Color */
  545. .secondary a,
  546. .dropdown-toggle:after,
  547. .widget-title,
  548. .widget blockquote cite,
  549. .widget blockquote small {
  550. color: {$colors['sidebar_textcolor']};
  551. }
  552. .widget button,
  553. .widget input[type="button"],
  554. .widget input[type="reset"],
  555. .widget input[type="submit"],
  556. .widget_calendar tbody a {
  557. background-color: {$colors['sidebar_textcolor']};
  558. }
  559. .textwidget a {
  560. border-color: {$colors['sidebar_textcolor']};
  561. }
  562. /* Sidebar Text Color */
  563. .secondary a:hover,
  564. .secondary a:focus,
  565. .main-navigation .menu-item-description,
  566. .widget,
  567. .widget blockquote,
  568. .widget .wp-caption-text,
  569. .widget .gallery-caption {
  570. color: {$colors['secondary_sidebar_textcolor']};
  571. }
  572. .widget button:hover,
  573. .widget button:focus,
  574. .widget input[type="button"]:hover,
  575. .widget input[type="button"]:focus,
  576. .widget input[type="reset"]:hover,
  577. .widget input[type="reset"]:focus,
  578. .widget input[type="submit"]:hover,
  579. .widget input[type="submit"]:focus,
  580. .widget_calendar tbody a:hover,
  581. .widget_calendar tbody a:focus {
  582. background-color: {$colors['secondary_sidebar_textcolor']};
  583. }
  584. .widget blockquote {
  585. border-color: {$colors['secondary_sidebar_textcolor']};
  586. }
  587. /* Sidebar Border Color */
  588. .main-navigation ul,
  589. .main-navigation li,
  590. .widget input,
  591. .widget textarea,
  592. .widget table,
  593. .widget th,
  594. .widget td,
  595. .widget pre,
  596. .widget li,
  597. .widget_categories .children,
  598. .widget_nav_menu .sub-menu,
  599. .widget_pages .children,
  600. .widget abbr[title] {
  601. border-color: {$colors['sidebar_border_color']};
  602. }
  603. .dropdown-toggle:hover,
  604. .dropdown-toggle:focus,
  605. .widget hr {
  606. background-color: {$colors['sidebar_border_color']};
  607. }
  608. .widget input:focus,
  609. .widget textarea:focus {
  610. border-color: {$colors['sidebar_border_focus_color']};
  611. }
  612. .sidebar a:focus,
  613. .dropdown-toggle:focus {
  614. outline-color: {$colors['sidebar_border_focus_color']};
  615. }
  616. }
  617. CSS;
  618. return $css;
  619. }
  620. /**
  621. * Output an Underscore template for generating CSS for the color scheme.
  622. *
  623. * The template generates the css dynamically for instant display in the Customizer
  624. * preview.
  625. *
  626. * @since Twenty Fifteen 1.0
  627. */
  628. function twentyfifteen_color_scheme_css_template() {
  629. $colors = array(
  630. 'background_color' => '{{ data.background_color }}',
  631. 'header_background_color' => '{{ data.header_background_color }}',
  632. 'box_background_color' => '{{ data.box_background_color }}',
  633. 'textcolor' => '{{ data.textcolor }}',
  634. 'secondary_textcolor' => '{{ data.secondary_textcolor }}',
  635. 'border_color' => '{{ data.border_color }}',
  636. 'border_focus_color' => '{{ data.border_focus_color }}',
  637. 'sidebar_textcolor' => '{{ data.sidebar_textcolor }}',
  638. 'sidebar_border_color' => '{{ data.sidebar_border_color }}',
  639. 'sidebar_border_focus_color' => '{{ data.sidebar_border_focus_color }}',
  640. 'secondary_sidebar_textcolor' => '{{ data.secondary_sidebar_textcolor }}',
  641. 'meta_box_background_color' => '{{ data.meta_box_background_color }}',
  642. );
  643. ?>
  644. <script type="text/html" id="tmpl-twentyfifteen-color-scheme">
  645. <?php echo twentyfifteen_get_color_scheme_css( $colors ); ?>
  646. </script>
  647. <?php
  648. }
  649. add_action( 'customize_controls_print_footer_scripts', 'twentyfifteen_color_scheme_css_template' );