wpcom-editor-colors.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <?php
  2. /*
  3. * Custom Colors: Seedlet
  4. */
  5. // Background Color
  6. // --global--color-background
  7. add_color_rule( 'bg', '#FFFFFF', array(
  8. // Background-color
  9. array( '.primary-navigation > div,
  10. .screen-reader-text:focus,
  11. .woo-navigation > div,
  12. .wp-block-navigation > .wp-block-navigation__container > .has-child > .wp-block-navigation__container,
  13. body,
  14. .primary-navigation > div > ul > li > .sub-menu,
  15. .woo-navigation > div > ul > li > .sub-menu', 'background-color' ),
  16. // Text-color
  17. array( '.a8c-posts-list-item__featured span,
  18. .a8c-posts-list__view-all,
  19. .a8c-posts-list__view-all:active,
  20. .a8c-posts-list__view-all:focus,
  21. .a8c-posts-list__view-all:hover,
  22. .button,
  23. .button:active,
  24. .button:focus,
  25. .button:hover,
  26. .has-focus.a8c-posts-list__view-all,
  27. .has-focus.button,
  28. .has-focus.wp-block-button__link,
  29. .reply a,
  30. .reply a.has-focus,
  31. .reply a:focus,
  32. .reply a:hover,
  33. .sticky-post,
  34. .wp-block-button__link,
  35. .wp-block-button__link:active,
  36. .wp-block-button__link:focus,
  37. .wp-block-button__link:hover,
  38. .wp-block-file .has-focus.wp-block-file__button,
  39. .wp-block-file .wp-block-file__button,
  40. .wp-block-file .wp-block-file__button:active,
  41. .wp-block-file .wp-block-file__button:focus,
  42. .wp-block-file .wp-block-file__button:hover,
  43. .wp-block-file a.wp-block-file__button:active,
  44. .wp-block-file a.wp-block-file__button:focus,
  45. .wp-block-file a.wp-block-file__button:hover,
  46. .wp-block-file a.wp-block-file__button:visited,
  47. .wp-block-pullquote.is-style-solid-color,
  48. button,
  49. button.has-focus,
  50. button:active,
  51. button:focus,
  52. button:hover,
  53. button[data-load-more-btn],
  54. input.has-focus[type="submit"],
  55. input:active[type="submit"],
  56. input:focus[type="submit"],
  57. input:hover[type="submit"],
  58. input[type="submit"]', 'color' ),
  59. // Text-shadow
  60. array( '.site-title a', 'text-shadow' ),
  61. /**
  62. * Utility Classes
  63. */
  64. // Text-color
  65. array( '.has-primary-background-color[class],
  66. .has-secondary-background-color[class],
  67. .has-foreground-background-color[class],
  68. .has-foreground-dark-background-color[class],
  69. .has-foreground-light-background-color[class],
  70. .has-background-color[class]', 'color' ),
  71. // Border-bottom-color
  72. array( '.has-secondary-background-color[class] a', 'border-bottom-color' ),
  73. // Background-color
  74. array( '.has-background-background-color[class]', 'background-color' ),
  75. // Text-color darkened
  76. array( '.has-background-dark-color[class]', 'color', '-1' ),
  77. // Background-color darkened
  78. array( '.has-background-dark-background-color[class]', 'background-color', '-1' ),
  79. ), __( 'Background Color' ) );
  80. // Foreground Color
  81. // --global--color-background
  82. add_color_rule( 'txt', '#444444', array(
  83. // Text-color
  84. array( '.comment-meta .comment-metadata,
  85. .entry-footer,
  86. .entry-meta,
  87. .has-background-background-color[class],
  88. .has-background-dark-background-color[class],
  89. .has-foreground-color[class],
  90. .has-tertiary-background-color[class],
  91. .has-tertiary-background-color[class]:not(.has-text-color),
  92. .navigation,
  93. .pagination .nav-links > *,
  94. .post-navigation .meta-nav,
  95. .primary-navigation,
  96. .screen-reader-text:focus,
  97. .site-branding,
  98. .site-footer > .footer-navigation .footer-menu,
  99. .site-footer > .site-info,
  100. .social-navigation a,
  101. .social-navigation a:active,
  102. .woo-navigation,
  103. .wp-block-code,
  104. .wp-block-code pre,
  105. .wp-block-pullquote,
  106. .wp-block-search .wp-block-search__input,
  107. .wp-block-search .wp-block-search__input:focus,
  108. .wp-block-latest-posts .wp-block-latest-posts__post-author,
  109. .wp-block-latest-posts .wp-block-latest-posts__post-date,
  110. body,
  111. input[type="color"],
  112. input[type="color"]:focus,
  113. input[type="date"],
  114. input[type="date"]:focus,
  115. input[type="datetime"],
  116. input[type="datetime"]:focus,
  117. input[type="datetime-local"],
  118. input[type="datetime-local"]:focus,
  119. input[type="email"],
  120. input[type="email"]:focus,
  121. input[type="month"],
  122. input[type="month"]:focus,
  123. input[type="number"],
  124. input[type="number"]:focus,
  125. input[type="password"],
  126. input[type="password"]:focus,
  127. input[type="range"],
  128. input[type="range"]:focus,
  129. input[type="search"],
  130. input[type="search"]:focus,
  131. input[type="tel"],
  132. input[type="tel"]:focus,
  133. input[type="text"],
  134. input[type="text"]:focus,
  135. input[type="time"],
  136. input[type="time"]:focus,
  137. input[type="url"],
  138. input[type="url"]:focus,
  139. input[type="week"],
  140. input[type="week"]:focus,
  141. textarea,
  142. textarea:focus', 'color' ),
  143. // Background-color
  144. array( '.wp-block-pullquote.is-style-solid-color,
  145. .wp-block-cover-image.has-background-dim,
  146. .wp-block-cover.has-background-dim', 'background-color' ),
  147. // Border-bottom-color
  148. array( '.pagination .nav-links > *.current', 'border-bottom-color' ),
  149. /**
  150. * Utility Classes
  151. */
  152. // Foreground
  153. array( '.has-foreground-color[class],
  154. .has-background-background-color[class],
  155. .has-background-dark-background-color[class],
  156. .has-background-light-background-color[class]', 'color' ),
  157. // Background
  158. array( '.has-foreground-background-color[class]', 'background-color' ),
  159. // Text-color darkened
  160. array( '.has-foreground-dark-color[class]', 'color', '-1' ),
  161. // Background-color darkened
  162. array( '.has-foreground-dark-background-color[class]', 'background-color', '-1' ),
  163. // Text-color brightened
  164. array( '.has-foreground-light-color[class]', 'color', '+2' ),
  165. // Background-color brightened
  166. array( '.has-foreground-light-background-color[class]', 'background-color', '+2' ),
  167. ), __( 'Foreground Color' ) );
  168. // Primary Color
  169. // --global--color-primary
  170. add_color_rule( 'link', '#000000', array(
  171. // Text-color
  172. array( '.entry-title,
  173. .navigation a,
  174. .navigation a:active,
  175. .primary-navigation .menu-item > a,
  176. .primary-navigation .menu-item > a:active,
  177. .primary-navigation > .button,
  178. .site-footer > .site-info a:focus,
  179. .site-footer > .site-info a:hover,
  180. .site-title,
  181. .woo-navigation .menu-item > a,
  182. .woo-navigation .menu-item > a:active,
  183. .woo-navigation > .button,
  184. .wp-block-a8c-blog-posts article .entry-title a,
  185. .wp-block-a8c-blog-posts article .entry-title a:active,
  186. .wp-block-newspack-blocks-homepage-articles article .entry-title a,
  187. .wp-block-newspack-blocks-homepage-articles article .entry-title a:active,
  188. a,
  189. a:active', 'color' ),
  190. // Background-color
  191. array( '.a8c-posts-list-item__featured span,
  192. .a8c-posts-list__view-all:active,
  193. .button:active,
  194. .wp-block-button__link:active,
  195. .wp-block-cover,
  196. .wp-block-cover-image,
  197. .wp-block-file .wp-block-file__button:active,
  198. button:active,
  199. input:active[type="submit"]', 'background-color' ),
  200. /**
  201. * Utility Classes
  202. */
  203. // Background-color
  204. array( '.has-primary-background-color[class]', 'background-color' ),
  205. // Text-color
  206. array( '.has-black-background-color[class],
  207. .has-primary-color[class]', 'color' ),
  208. ), __( 'Primary Color' ) );
  209. // Secondary Color
  210. // --global--color-secondary
  211. add_color_rule( 'fg1', '#3C8067', array(
  212. // Text-color
  213. array( '.a8c-posts-list__item .a8c-posts-list-item__meta a:active,
  214. .a8c-posts-list__item .a8c-posts-list-item__meta a:hover,
  215. .comment-meta .comment-metadata a:focus,
  216. .comment-meta .comment-metadata a:hover,
  217. .entry-footer a:focus,
  218. .entry-footer a:hover,
  219. .entry-meta a:focus,
  220. .entry-meta a:hover,
  221. .entry-title a:focus,
  222. .entry-title a:hover,
  223. .navigation a:focus,
  224. .navigation a:hover,
  225. .pagination .nav-links > a:hover,
  226. .site-footer > .footer-navigation .footer-menu a:focus,
  227. .site-footer > .footer-navigation .footer-menu a:hover,
  228. .site-title a:focus,
  229. .site-title a:hover,
  230. .social-navigation a:focus,
  231. .social-navigation a:hover,
  232. .woo-navigation .menu-item > a:focus,
  233. .woo-navigation .menu-item > a:hover,
  234. .woo-navigation .primary-menu > .menu-item:hover > a,
  235. .woo-navigation > .button:hover,
  236. .wp-block-a8c-blog-posts article .cat-links a:active,
  237. .wp-block-a8c-blog-posts article .cat-links a:hover,
  238. .wp-block-a8c-blog-posts article .entry-meta a:active,
  239. .wp-block-a8c-blog-posts article .entry-meta a:hover,
  240. .wp-block-a8c-blog-posts article .entry-title a:focus,
  241. .wp-block-a8c-blog-posts article .entry-title a:hover,
  242. .wp-block-button.is-style-outline .wp-block-button__link,
  243. .wp-block-button.is-style-outline .wp-block-button__link:active,
  244. .wp-block-button.is-style-outline.wp-block-button__link,
  245. .wp-block-button.is-style-outline.wp-block-button__link:active,
  246. .wp-block-navigation:not(.has-text-color) .wp-block-navigation-link > a:focus,
  247. .wp-block-navigation:not(.has-text-color) .wp-block-navigation-link > a:hover,
  248. .wp-block-newspack-blocks-homepage-articles article .cat-links a:active,
  249. .wp-block-newspack-blocks-homepage-articles article .cat-links a:hover,
  250. .wp-block-newspack-blocks-homepage-articles article .entry-meta a:active,
  251. .wp-block-newspack-blocks-homepage-articles article .entry-meta a:hover,
  252. .wp-block-newspack-blocks-homepage-articles article .entry-title a:focus,
  253. .wp-block-newspack-blocks-homepage-articles article .entry-title a:hover,
  254. .primary-navigation .menu-item > a:focus,
  255. .primary-navigation .menu-item > a:hover,
  256. .primary-navigation .primary-menu > .menu-item:hover > a,
  257. .primary-navigation > .button:hover,
  258. a:focus,
  259. a:hover,
  260. .site-footer > .footer-navigation .footer-menu .menu-item a:hover', 'color' ),
  261. // Background-color
  262. array( '.a8c-posts-list__view-all,
  263. .button,
  264. .has-secondary-background-color[class],
  265. .reply a,
  266. .sticky-post,
  267. .wp-block-button__link,
  268. .wp-block-file .wp-block-file__button,
  269. button,
  270. button[data-load-more-btn],
  271. input[type="submit"]', 'background-color' ),
  272. // Border-color
  273. array( '.primary-navigation .menu-item > a:hover,
  274. .woo-navigation .menu-item > a:hover,
  275. .entry-meta a:hover,
  276. .entry-footer a:hover,
  277. .site-footer > .footer-navigation .footer-menu .menu-item a:hover', 'border-color' ),
  278. // Border-bottom-color
  279. array( 'a', 'border-bottom-color' ),
  280. // Border-left-color
  281. array( '.wp-block-pullquote.is-style-large,
  282. .wp-block-quote', 'border-left-color' ),
  283. // Border-right-color
  284. array( '.wp-block-quote.has-text-align-right', 'border-right-color' ),
  285. // Outline-color
  286. array( '.site :focus', 'outline-color' ),
  287. // Background-image
  288. array( '.site-title a', 'Background-image' ),
  289. // Text-decoration-color
  290. array( '.site-title > a', 'text-decoration-color' ),
  291. /**
  292. * Utility Classes
  293. */
  294. // Background-color
  295. array( '.has-secondary-background-color[class]', 'background-color' ),
  296. // Text-color
  297. array( '.has-secondary-color[class],
  298. .has-white-background-color[class],', 'color' ),
  299. /**
  300. * Button Hover Colors
  301. */
  302. // Background Color
  303. array( '.a8c-posts-list__view-all:focus,
  304. .a8c-posts-list__view-all:hover,
  305. .button:focus,
  306. .button:hover,
  307. .has-focus.a8c-posts-list__view-all,
  308. .has-focus.button,
  309. .has-focus.wp-block-button__link,
  310. .reply a.has-focus,
  311. .reply a:focus,
  312. .reply a:hover,
  313. .wp-block-button__link:focus,
  314. .wp-block-button__link:hover,
  315. .wp-block-file .has-focus.wp-block-file__button,
  316. .wp-block-file .wp-block-file__button:focus,
  317. .wp-block-file .wp-block-file__button:hover,
  318. button.has-focus,
  319. button:focus,
  320. button:hover,
  321. input.has-focus[type="submit"],
  322. input:focus[type="submit"],
  323. input:hover[type="submit"]', 'background-color', '-1' ),
  324. // Text Color
  325. array( '.wp-block-button.is-style-outline .wp-block-button__link.has-focus,
  326. .wp-block-button.is-style-outline .wp-block-button__link:focus,
  327. .wp-block-button.is-style-outline .wp-block-button__link:hover,
  328. .wp-block-button.is-style-outline.wp-block-button__link.has-focus,
  329. .wp-block-button.is-style-outline.wp-block-button__link:focus,
  330. .wp-block-button.is-style-outline.wp-block-button__link:hover', 'color', '-1' ),
  331. ), __( 'Secondary Color' ) );
  332. // Tertiary Color
  333. // --global--color-tertiary
  334. add_color_rule( 'fg2', '#FAFBF6', array(
  335. // Text-color
  336. array( '.wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-image-text,
  337. .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-text,
  338. .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover__inner-container,
  339. .wp-block-cover:not([class*="background-color"]) .wp-block-cover-image-text,
  340. .wp-block-cover:not([class*="background-color"]) .wp-block-cover-text,
  341. .wp-block-cover:not([class*="background-color"]) .wp-block-cover__inner-container', 'color' ),
  342. /**
  343. * Utility Classes
  344. */
  345. // Background-color
  346. array( '.has-tertiary-background-color[class],
  347. .has-background-light-background-color[class]', 'background-color' ),
  348. // Text-color
  349. array( '.has-tertiary-color[class],
  350. .has-background-light-color[class]', 'color' ),
  351. /**
  352. * Border Colors
  353. * --global--color-border
  354. */
  355. // Border-color
  356. array( '.comment-meta .comment-author .avatar,
  357. .wp-block-code,
  358. .wp-block-search .wp-block-search__input,
  359. .wp-block-search .wp-block-search__input:focus,
  360. input[type="color"],
  361. input[type="color"]:focus,
  362. input[type="date"],
  363. input[type="date"]:focus,
  364. input[type="datetime"],
  365. input[type="datetime"]:focus,
  366. input[type="datetime-local"],
  367. input[type="datetime-local"]:focus,
  368. input[type="email"],
  369. input[type="email"]:focus,
  370. input[type="month"],
  371. input[type="month"]:focus,
  372. input[type="number"],
  373. input[type="number"]:focus,
  374. input[type="password"],
  375. input[type="password"]:focus,
  376. input[type="range"],
  377. input[type="range"]:focus,
  378. input[type="search"],
  379. input[type="search"]:focus,
  380. input[type="tel"],
  381. input[type="tel"]:focus,
  382. input[type="text"],
  383. input[type="text"]:focus,
  384. input[type="time"],
  385. input[type="time"]:focus,
  386. input[type="url"],
  387. input[type="url"]:focus,
  388. input[type="week"],
  389. input[type="week"]:focus,
  390. select,
  391. textarea,
  392. textarea:focus', 'border-color' ),
  393. // Border-bottom-color
  394. array( '.comment-list > li:not(first-child),
  395. hr,
  396. hr.wp-block-separator', 'border-bottom-color' ),
  397. // Border-top-color
  398. array( '.comment-list .children > li,
  399. .site-main > article > .entry-footer', 'border-top-color' ),
  400. // Color
  401. array( 'hr.wp-block-separator.is-style-dots:before', 'color' ),
  402. ), __( 'Tertiary Color' ) );
  403. /**
  404. * Custom CSS.
  405. * The plugin takes the body of this function and applies it in a style tag in the document head.
  406. */
  407. function seedlet_custom_colors_extra_css() {
  408. $colors_array = get_theme_mod( 'colors_manager' );
  409. $color_bg = $colors_array['colors']['bg'];
  410. $color_fg1 = $colors_array['colors']['fg1'];
  411. $color_fg2 = $colors_array['colors']['fg2']; ?>
  412. /*
  413. * Site title text shadow.
  414. */
  415. .site-title a {
  416. background-image: linear-gradient(to right, <?php echo $color_fg1; ?> 100%, transparent 100%);
  417. text-shadow: 1px 0px <?php echo $color_bg; ?>,
  418. -1px 0px <?php echo $color_bg; ?>,
  419. -2px 0px <?php echo $color_bg; ?>,
  420. 2px 0px <?php echo $color_bg; ?>,
  421. -3px 0px <?php echo $color_bg; ?>,
  422. 3px 0px <?php echo $color_bg; ?>,
  423. -4px 0px <?php echo $color_bg; ?>,
  424. 4px 0px <?php echo $color_bg; ?>,
  425. -5px 0px <?php echo $color_bg; ?>,
  426. 5px 0px <?php echo $color_bg; ?>;
  427. }
  428. /*
  429. * Custom gradients.
  430. */
  431. .has-hard-diagonal-gradient-background {
  432. background: linear-gradient(to bottom right, <?php echo $color_fg1; ?> 49.9%, <?php echo $color_fg2; ?> 50%);
  433. }
  434. .has-hard-diagonal-inverted-gradient-background {
  435. background: linear-gradient(to top left, <?php echo $color_fg1; ?> 49.9%, <?php echo $color_fg2; ?> 50%);
  436. }
  437. .has-diagonal-gradient-background {
  438. background: linear-gradient(to bottom right, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  439. }
  440. .has-diagonal-inverted-gradient-background {
  441. background: linear-gradient(to top left, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  442. }
  443. .has-hard-horizontal-gradient-background {
  444. background: linear-gradient(to bottom, <?php echo $color_fg1; ?> 50%, <?php echo $color_fg2; ?> 50%);
  445. }
  446. .has-hard-horizontal-inverted-gradient-background {
  447. background: linear-gradient(to top, <?php echo $color_fg1; ?> 50%, <?php echo $color_fg2; ?> 50%);
  448. }
  449. .has-horizontal-gradient-background {
  450. background: linear-gradient(to bottom, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  451. }
  452. .has-horizontal-inverted-gradient-background {
  453. background: linear-gradient(to top, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  454. }
  455. .has-stripe-gradient-background {
  456. background: linear-gradient(to bottom, transparent 20%, <?php echo $color_fg1; ?> 20%, <?php echo $color_fg1; ?> 80%, transparent 80%);
  457. }
  458. <?php }
  459. add_theme_support( 'custom_colors_extra_css', 'seedlet_custom_colors_extra_css' );