customizer.php 21 KB

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