wpcom-editor-colors.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. // Text-color
  12. array(
  13. '#editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color',
  14. 'color',
  15. ),
  16. // Background-color
  17. array(
  18. '#editor .editor-styles-wrapper,
  19. #editor .editor-styles-wrapper .fse-template-part .main-navigation > div > ul > li > .sub-menu',
  20. 'background-color',
  21. ),
  22. // Text-color darkened
  23. array( '#editor .editor-styles-wrapper .wp-block-separator.is-style-dots', 'color', '-1' ),
  24. // Border-color darkened
  25. array( '#editor .editor-styles-wrapper .wp-block-code', 'border-color', '-1' ),
  26. // Border-top-color darkened
  27. array( '#editor .editor-styles-wrapper .wp-block-pullquote', 'border-top-color', '-1' ),
  28. // Border-bottom-color darkened
  29. array(
  30. '#editor .editor-styles-wrapper .wp-block-pullquote,
  31. #editor .editor-styles-wrapper .wp-block-separator',
  32. 'border-bottom-color',
  33. '-1',
  34. ),
  35. // Background-color darkened
  36. array(
  37. '#editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  38. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd)',
  39. 'color',
  40. '-1',
  41. ),
  42. /**
  43. * Utility Classes
  44. */
  45. // Text-color
  46. array(
  47. '#editor .editor-styles-wrapper .has-primary-background-color[class],
  48. #editor .editor-styles-wrapper .wp-block .has-primary-background-color[class],
  49. #editor .editor-styles-wrapper .has-secondary-background-color[class],
  50. #editor .editor-styles-wrapper .wp-block .has-secondary-background-color[class],
  51. #editor .editor-styles-wrapper .has-foreground-background-color[class],
  52. #editor .editor-styles-wrapper .wp-block .has-foreground-background-color[class],
  53. #editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  54. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-background-color[class],
  55. #editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  56. #editor .editor-styles-wrapper .wp-block .has-foreground-light-background-color[class],
  57. #editor .editor-styles-wrapper .has-background-color[class],
  58. #editor .editor-styles-wrapper .wp-block .has-background-color[class]',
  59. 'color',
  60. ),
  61. // Background-color
  62. array(
  63. '#editor .editor-styles-wrapper .has-background-background-color[class],
  64. #editor .editor-styles-wrapper .wp-block .has-background-background-color[class]',
  65. 'background-color',
  66. ),
  67. // Text-color darkened
  68. array(
  69. '#editor .editor-styles-wrapper .has-background-dark-color[class],
  70. #editor .editor-styles-wrapper .wp-block .has-background-dark-color[class]',
  71. 'color',
  72. '-1',
  73. ),
  74. // Background-color darkened
  75. array(
  76. '#editor .editor-styles-wrapper .has-background-dark-background-color[class],
  77. #editor .editor-styles-wrapper .wp-block .has-background-dark-background-color[class]',
  78. 'background-color',
  79. '-1',
  80. ),
  81. // Text-color lightened
  82. array(
  83. '#editor .editor-styles-wrapper .has-background-light-color[class],
  84. #editor .editor-styles-wrapper .wp-block .has-background-light-color[class]',
  85. 'color',
  86. '+1',
  87. ),
  88. // Background-color lightened
  89. array(
  90. '#editor .editor-styles-wrapper .has-background-light-background-color[class],
  91. #editor .editor-styles-wrapper .wp-block .has-background-light-background-color[class]',
  92. 'background-color',
  93. '+1',
  94. ),
  95. ),
  96. __( 'Background Color' )
  97. );
  98. // Link Color
  99. // $config-global--color-primary-default
  100. add_editor_color_rule(
  101. 'link',
  102. '#897248',
  103. array(
  104. // Text-color
  105. array(
  106. '#editor .editor-styles-wrapper .fse-template-part .main-navigation a:hover,
  107. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a,
  108. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link,
  109. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline,
  110. #editor .editor-styles-wrapper a',
  111. 'color',
  112. ),
  113. // Background-color
  114. array(
  115. '#editor .editor-styles-wrapper .button,
  116. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button,
  117. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:hover,
  118. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:not(.has-background):hover,
  119. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:focus,
  120. #editor .editor-styles-wrapper .fse-template-part .main-navigation #toggle:focus + #toggle-menu,
  121. #editor .editor-styles-wrapper .fse-template-part .main-navigation .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,
  124. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color',
  125. 'background-color',
  126. ),
  127. // Border color left
  128. array( '#editor .editor-styles-wrapper .wp-block-quote', 'border-left-color' ),
  129. // Border color right
  130. array(
  131. '#editor .editor-styles-wrapper .wp-block-quote[style*="text-align: right"],
  132. #editor .editor-styles-wrapper .wp-block-quote[style*="text-align:right"]',
  133. 'border-right-color',
  134. ),
  135. // Text-color darkened
  136. array(
  137. '#editor .editor-styles-wrapper .is-style-outline .wp-block-button__link.has-focus,
  138. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link:focus,
  139. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link:hover,
  140. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:active,
  141. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:hover,
  142. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:active,
  143. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:hover,
  144. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:hover,
  145. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:active,
  146. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:hover,
  147. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline.has-focus,
  148. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline:focus,
  149. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline:hover,
  150. #editor .editor-styles-wrapper a:hover',
  151. 'color',
  152. '-1',
  153. ),
  154. // Background-color darkened
  155. array(
  156. '#editor .editor-styles-wrapper .button.has-focus,
  157. #editor .editor-styles-wrapper .button:focus,
  158. #editor .editor-styles-wrapper .button:hover,
  159. #editor .editor-styles-wrapper .fse-template-part .main-navigation .button:focus,
  160. #editor .editor-styles-wrapper .fse-template-part .main-navigation .button:hover,
  161. #editor .editor-styles-wrapper .fse-template-part .main-navigation .has-focus.button,
  162. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:focus,
  163. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:hover,
  164. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .has-focus.button,
  165. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link.has-focus,
  166. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:focus,
  167. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover',
  168. 'background-color',
  169. '-1',
  170. ),
  171. /**
  172. * Utility Classes
  173. */
  174. // Text-color
  175. array(
  176. '#editor .editor-styles-wrapper .has-primary-color[class],
  177. #editor .editor-styles-wrapper .wp-block .has-primary-color[class]',
  178. 'color',
  179. ),
  180. // Background-color
  181. array(
  182. '#editor .editor-styles-wrapper .has-primary-background-color[class],
  183. #editor .editor-styles-wrapper .wp-block .has-primary-background-color[class]',
  184. 'background-color',
  185. ),
  186. ),
  187. __( 'Link Color' )
  188. );
  189. // Text Color
  190. // $config-global--color-foreground-default
  191. add_editor_color_rule(
  192. 'txt',
  193. '#181818',
  194. array(
  195. // Text-color
  196. array(
  197. '#editor .editor-styles-wrapper,
  198. #editor .editor-styles-wrapper .a8c-posts-list__item .a8c-posts-list-item__meta,
  199. #editor .editor-styles-wrapper .wp-block-image figcaption,
  200. #editor .editor-styles-wrapper .wp-block-latest-comments .wp-block-latest-comments__comment-date,
  201. #editor .editor-styles-wrapper .wp-block-latest-posts .wp-block-latest-posts__post-date,
  202. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .cat-links,
  203. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .entry-meta,
  204. #editor .editor-styles-wrapper .wp-block-pullquote .wp-block-pullquote__citation,
  205. #editor .editor-styles-wrapper .wp-block-pullquote cite,
  206. #editor .editor-styles-wrapper .wp-block-pullquote footer,
  207. #editor .editor-styles-wrapper .wp-block-quote .wp-block-quote__citation,
  208. #editor .editor-styles-wrapper .wp-block-quote cite,
  209. #editor .editor-styles-wrapper .wp-block-quote footer,
  210. #editor .editor-styles-wrapper .wp-block-quote.is-large .wp-block-quote__citation,
  211. #editor .editor-styles-wrapper .wp-block-quote.is-large cite,
  212. #editor .editor-styles-wrapper .wp-block-quote.is-large footer,
  213. #editor .editor-styles-wrapper .wp-block-quote.is-style-large .wp-block-quote__citation,
  214. #editor .editor-styles-wrapper .wp-block-quote.is-style-large cite,
  215. #editor .editor-styles-wrapper .wp-block-quote.is-style-large footer,
  216. #editor .editor-styles-wrapper .wp-block-video figcaption,
  217. #editor .editor-styles-wrapper figcaption,
  218. #editor .editor-styles-wrapper .wp-block-pullquote,
  219. #editor .editor-styles-wrapper .wp-block-pullquote,
  220. #editor .editor-styles-wrapper .wp-block-code > code,
  221. #editor .editor-styles-wrapper .wp-block-verse,
  222. #editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  223. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd),
  224. #editor .editor-styles-wrapper .editor-post-title__block .editor-post-title__input,
  225. #editor .editor-styles-wrapper .fse-template-part .main-navigation,
  226. #editor .editor-styles-wrapper .fse-template-part .main-navigation a,
  227. #editor .editor-styles-wrapper .fse-template-part .main-navigation a:link,
  228. #editor .editor-styles-wrapper .fse-template-part .main-navigation a:visited',
  229. 'color',
  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. ),
  281. __( 'Text Color' )
  282. );
  283. // Accent Color (Red)
  284. // $config-global--color-secondary-default
  285. add_editor_color_rule(
  286. 'fg1',
  287. '#c4493f',
  288. array(
  289. /**
  290. * Utility Classes
  291. */
  292. // Text-color
  293. array(
  294. '#editor .editor-styles-wrapper .has-secondary-color[class],
  295. #editor .editor-styles-wrapper .wp-block .has-secondary-color[class]',
  296. 'color',
  297. ),
  298. // Background-color
  299. array(
  300. '#editor .editor-styles-wrapper .has-secondary-background-color[class],
  301. #editor .editor-styles-wrapper .wp-block .has-secondary-background-color[class]',
  302. 'background-color',
  303. ),
  304. ),
  305. __( 'Secondary Color' )
  306. );
  307. /**
  308. * Custom CSS
  309. */
  310. function maywood_custom_editor_colors_extra_css() {
  311. $colors_array = get_theme_mod( 'colors_manager' );
  312. $txt = $colors_array['colors']['txt'];
  313. ?>
  314. #editor .editor-styles-wrapper .block-editor-default-block-appender textarea.block-editor-default-block-appender__content,
  315. #editor .editor-styles-wrapper .wp-block .editor-post-title__input::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
  316. color: <?php echo $txt; ?>;
  317. opacity: 0.66; /* Firefox */
  318. }
  319. #editor .editor-styles-wrapper .wp-block .editor-post-title__input:-ms-input-placeholder { /* Internet Explorer 10-11 */
  320. color: <?php echo $txt; ?>;
  321. opacity: 0.66;
  322. }
  323. #editor .editor-styles-wrapper .wp-block .editor-post-title__input::-ms-input-placeholder { /* Microsoft Edge */
  324. color: <?php echo $txt; ?>;
  325. opacity: 0.66;
  326. }
  327. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline.has-background[class],
  328. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link.has-background[class] {
  329. background: transparent !important;
  330. }
  331. #editor .editor-styles-wrapper .has-background:not(.has-background-background-color) a:not(.wp-block-button__link),
  332. #editor .editor-styles-wrapper p.has-text-color a,
  333. #editor .editor-styles-wrapper .has-background-dim a {
  334. color: currentColor;
  335. }
  336. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h1,
  337. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h2,
  338. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h3,
  339. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h4,
  340. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h5,
  341. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h6,
  342. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h1,
  343. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h2,
  344. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h3,
  345. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h4,
  346. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h5,
  347. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h6,
  348. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h1,
  349. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h2,
  350. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h3,
  351. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h4,
  352. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h5,
  353. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h6,
  354. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h1,
  355. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h2,
  356. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h3,
  357. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h4,
  358. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h5,
  359. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h6 {
  360. text-shadow: none;
  361. }
  362. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] p,
  363. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container p,
  364. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] p,
  365. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container p {
  366. text-shadow: none;
  367. }
  368. <?php
  369. }
  370. add_theme_support( 'custom_colors_extra_css', 'maywood_custom_editor_colors_extra_css' );