wpcom-editor-colors.php 13 KB

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