wpcom-editor-colors.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <?php
  2. /*
  3. * Custom Editor Colors
  4. */
  5. // Background Color
  6. // $config-global--color-background-default
  7. add_editor_color_rule(
  8. 'bg',
  9. '#FFFFFF',
  10. array(
  11. // Background-color
  12. array( '#editor .editor-styles-wrapper', 'background-color' ),
  13. // Text-color
  14. array(
  15. '#editor .editor-styles-wrapper .button,
  16. #editor .editor-styles-wrapper .button.has-focus,
  17. #editor .editor-styles-wrapper .button:focus,
  18. #editor .editor-styles-wrapper .button:hover,
  19. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  20. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:focus,
  21. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:hover,
  22. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .has-focus.button,
  23. #editor .editor-styles-wrapper .wp-block-button__link,
  24. #editor .editor-styles-wrapper .wp-block-button__link.has-focus,
  25. #editor .editor-styles-wrapper .wp-block-button__link:focus,
  26. #editor .editor-styles-wrapper .wp-block-button__link:hover,
  27. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button,
  28. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color',
  29. 'color',
  30. ),
  31. // Text-color darkened
  32. array( '#editor .editor-styles-wrapper .wp-block-separator.is-style-dots', 'color', '-1' ),
  33. // Background color darkened
  34. array(
  35. '#editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  36. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd)',
  37. 'background-color',
  38. '-1',
  39. ),
  40. // Border-color darkened
  41. array( '#editor .editor-styles-wrapper .wp-block-code', 'border-color', '-1' ),
  42. // Border-top-color darkened
  43. array( '#editor .editor-styles-wrapper .wp-block-pullquote', 'border-top-color', '-1' ),
  44. // Border-bottom-color darkened
  45. array(
  46. '#editor .editor-styles-wrapper .wp-block-pullquote,
  47. #editor .editor-styles-wrapper .wp-block-separator',
  48. 'border-bottom-color',
  49. '-1',
  50. ),
  51. /**
  52. * Utility Classes
  53. */
  54. // Text-color
  55. array(
  56. '#editor .editor-styles-wrapper .has-primary-background-color[class],
  57. #editor .editor-styles-wrapper .has-secondary-background-color[class],
  58. #editor .editor-styles-wrapper .has-foreground-background-color[class],
  59. #editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  60. #editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  61. #editor .editor-styles-wrapper .has-background-color[class]',
  62. 'color',
  63. ),
  64. // Background-color
  65. array(
  66. '#editor .editor-styles-wrapper .has-background-background-color[class],
  67. #editor .editor-styles-wrapper .wp-block .has-background-background-color[class]',
  68. 'background-color',
  69. ),
  70. // Text-color darkened
  71. array(
  72. '#editor .editor-styles-wrapper .has-background-dark-color[class],
  73. #editor .editor-styles-wrapper .wp-block .has-background-dark-color[class]',
  74. 'color',
  75. '-1',
  76. ),
  77. // Background-color darkened
  78. array(
  79. '#editor .editor-styles-wrapper .has-background-dark-background-color[class],
  80. #editor .editor-styles-wrapper .wp-block .has-background-dark-background-color[class]',
  81. 'background-color',
  82. '-1',
  83. ),
  84. // Text-color lightened
  85. array(
  86. '#editor .editor-styles-wrapper .has-background-light-color[class],
  87. #editor .editor-styles-wrapper .wp-block .has-background-light-color[class]',
  88. 'color',
  89. '+1',
  90. ),
  91. // Background-color lightened
  92. array(
  93. '#editor .editor-styles-wrapper .has-background-light-background-color[class],
  94. #editor .editor-styles-wrapper .wp-block .has-background-light-background-color[class]',
  95. 'background-color',
  96. '+1',
  97. ),
  98. ),
  99. __( 'Background Color' )
  100. );
  101. // Link Color
  102. // $config-global--color-primary-default
  103. add_editor_color_rule(
  104. 'link',
  105. '#CA2017',
  106. array(
  107. // Text-color
  108. array(
  109. '#editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link:not(.has-text-color),
  110. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a,
  111. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:active,
  112. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:focus,
  113. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:hover,
  114. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline,
  115. #editor .editor-styles-wrapper a',
  116. 'color',
  117. ),
  118. // Background-color
  119. array(
  120. '#editor .editor-styles-wrapper .button,
  121. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  122. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:not(.has-background),
  123. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button,
  124. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:focus,
  125. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:hover,
  126. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color',
  127. 'background-color',
  128. ),
  129. // Border color left
  130. array( '#editor .editor-styles-wrapper .wp-block-quote', 'border-left-color' ),
  131. // Border color right
  132. array(
  133. '#editor .editor-styles-wrapper .wp-block-quote[style*="text-align: right"],
  134. #editor .editor-styles-wrapper .wp-block-quote[style*="text-align:right"]',
  135. 'border-right-color',
  136. ),
  137. // Border-color (forms)
  138. array(
  139. '#editor .editor-styles-wrapper .wp-block-search .wp-block-search__input:focus,
  140. textarea:focus',
  141. 'border-color',
  142. ),
  143. /**
  144. * Utility Classes
  145. */
  146. // Text-color
  147. array(
  148. '#editor .editor-styles-wrapper .has-primary-color[class],
  149. #editor .editor-styles-wrapper .wp-block .has-primary-color[class]',
  150. 'color',
  151. ),
  152. // Background-color
  153. array(
  154. '#editor .editor-styles-wrapper .has-primary-background-color[class],
  155. #editor .editor-styles-wrapper .wp-block .has-primary-background-color[class]',
  156. 'background-color',
  157. ),
  158. ),
  159. __( 'Link Color' )
  160. );
  161. // Text Color
  162. // $config-global--color-foreground-default
  163. add_editor_color_rule(
  164. 'txt',
  165. '#222222',
  166. array(
  167. // Text-color
  168. array(
  169. '#editor .editor-styles-wrapper .editor-post-title__block .editor-post-title__input,
  170. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link.has-focus,
  171. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link:focus,
  172. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link:hover,
  173. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:active,
  174. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:hover,
  175. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:active,
  176. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:hover,
  177. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:hover,
  178. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:active,
  179. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:hover,
  180. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline.has-focus,
  181. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline:focus,
  182. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline:hover,
  183. #editor .editor-styles-wrapper .wp-block-pullquote,
  184. #editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  185. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd),
  186. #editor .editor-styles-wrapper a:hover,
  187. #editor .editor-styles-wrapper',
  188. 'color',
  189. ),
  190. // Background-color
  191. array(
  192. '#editor .editor-styles-wrapper .button.has-focus,
  193. #editor .editor-styles-wrapper .button:focus,
  194. #editor .editor-styles-wrapper .button:hover,
  195. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:focus,
  196. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:hover,
  197. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .has-focus.button,
  198. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link.has-focus,
  199. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:focus,
  200. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover',
  201. 'background-color',
  202. ),
  203. // Text-color brightened
  204. array(
  205. '#editor .editor-styles-wrapper .a8c-posts-list__item .a8c-posts-list-item__meta,
  206. #editor .editor-styles-wrapper .wp-block-image figcaption,
  207. #editor .editor-styles-wrapper .wp-block-latest-comments .wp-block-latest-comments__comment-date,
  208. #editor .editor-styles-wrapper .wp-block-latest-posts .wp-block-latest-posts__post-date,
  209. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .cat-links,
  210. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .entry-meta,
  211. #editor .editor-styles-wrapper .wp-block-pullquote .wp-block-pullquote__citation,
  212. #editor .editor-styles-wrapper .wp-block-pullquote cite,
  213. #editor .editor-styles-wrapper .wp-block-pullquote footer,
  214. #editor .editor-styles-wrapper .wp-block-quote .wp-block-quote__citation,
  215. #editor .editor-styles-wrapper .wp-block-quote cite,
  216. #editor .editor-styles-wrapper .wp-block-quote footer,
  217. #editor .editor-styles-wrapper .wp-block-quote.is-large .wp-block-quote__citation,
  218. #editor .editor-styles-wrapper .wp-block-quote.is-large cite,
  219. #editor .editor-styles-wrapper .wp-block-quote.is-large footer,
  220. #editor .editor-styles-wrapper .wp-block-quote.is-style-large .wp-block-quote__citation,
  221. #editor .editor-styles-wrapper .wp-block-quote.is-style-large cite,
  222. #editor .editor-styles-wrapper .wp-block-quote.is-style-large footer,
  223. #editor .editor-styles-wrapper .wp-block-video figcaption,
  224. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links,
  225. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta,
  226. #editor .editor-styles-wrapper figcaption',
  227. 'color',
  228. '+2',
  229. ),
  230. /**
  231. * Utility Classes
  232. */
  233. // Text-color
  234. array(
  235. '#editor .editor-styles-wrapper .has-background-background-color[class],
  236. #editor .editor-styles-wrapper .wp-block .has-background-background-color[class],
  237. #editor .editor-styles-wrapper .has-background-dark-background-color[class],
  238. #editor .editor-styles-wrapper .wp-block .has-background-dark-background-color[class],
  239. #editor .editor-styles-wrapper .has-background-light-background-color[class],
  240. #editor .editor-styles-wrapper .wp-block .has-background-light-background-color[class],
  241. #editor .editor-styles-wrapper .has-foreground-color[class],
  242. #editor .editor-styles-wrapper .wp-block .has-foreground-color[class]',
  243. 'color',
  244. ),
  245. // Background-color
  246. array(
  247. '#editor .editor-styles-wrapper .has-foreground-background-color[class],
  248. #editor .editor-styles-wrapper .wp-block .has-foreground-background-color[class]',
  249. 'background-color',
  250. ),
  251. // Text-color darkened
  252. array(
  253. '#editor .editor-styles-wrapper .has-foreground-dark-color[class],
  254. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-color[class]',
  255. 'color',
  256. '-1',
  257. ),
  258. // Background-color darkened
  259. array(
  260. '#editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  261. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-background-color[class]',
  262. 'background-color',
  263. '-1',
  264. ),
  265. // Text-color brightened
  266. array(
  267. '#editor .editor-styles-wrapper .has-foreground-light-color[class],
  268. #editor .editor-styles-wrapper .wp-block .has-foreground-light-color[class]',
  269. 'color',
  270. '+2',
  271. ),
  272. // Background-color brightened
  273. array(
  274. '#editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  275. #editor .editor-styles-wrapper .wp-block .has-foreground-light-background-color[class]',
  276. 'background-color',
  277. '+2',
  278. ),
  279. // Border-color with less opacity (dim)
  280. array(
  281. '#editor .editor-styles-wrapper .wp-block-code,
  282. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__input',
  283. 'border-color',
  284. 0.8,
  285. ),
  286. ),
  287. __( 'Text Color' )
  288. );
  289. // Accent Color (Red)
  290. // $config-global--color-secondary-default
  291. add_editor_color_rule(
  292. 'fg1',
  293. '#007FDB',
  294. array(
  295. /**
  296. * Utility Classes
  297. */
  298. // Text-color
  299. array(
  300. '#editor .editor-styles-wrapper .has-secondary-color[class],
  301. #editor .editor-styles-wrapper .wp-block .has-secondary-color[class]',
  302. 'color',
  303. ),
  304. // Background-color
  305. array(
  306. '#editor .editor-styles-wrapper .has-secondary-background-color[class],
  307. #editor .editor-styles-wrapper .wp-block .has-secondary-background-color[class]',
  308. 'background-color',
  309. ),
  310. ),
  311. __( 'Secondary Color' )
  312. );
  313. /**
  314. * Custom CSS
  315. */
  316. function redhill_editor_custom_colors_extra_css() {
  317. $colors_array = get_theme_mod( 'colors_manager' );
  318. $bg = $colors_array['colors']['bg'];
  319. $txt = $colors_array['colors']['txt'];
  320. ?>
  321. #editor .editor-styles-wrapper .has-background:not(.has-background-background-color) a:not(.wp-block-button__link),
  322. #editor .editor-styles-wrapper p.has-text-color a {
  323. color: currentColor;
  324. }
  325. <?php
  326. }
  327. add_theme_support( 'custom_colors_extra_css', 'redhill_editor_custom_colors_extra_css' );