wpcom-editor-colors.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. #editor .editor-styles-wrapper .wp-block-cover.has-background-dim,
  15. #editor .editor-styles-wrapper .wp-block-cover-image.has-background-dim,
  16. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .block-editor-block-list__block',
  17. 'color',
  18. ),
  19. // Background-color
  20. array(
  21. '#editor .editor-styles-wrapper,
  22. #editor .editor-styles-wrapper .fse-template-part .main-navigation > div > ul > li > .sub-menu',
  23. 'background-color',
  24. ),
  25. // Text-color darkened
  26. array( '#editor .editor-styles-wrapper .wp-block-separator.is-style-dots', 'color', '-1' ),
  27. // Border-color darkened
  28. array( '#editor .editor-styles-wrapper .wp-block-code', 'border-color', '-1' ),
  29. // Border-top-color darkened
  30. array( '#editor .editor-styles-wrapper .wp-block-pullquote', 'border-top-color', '-1' ),
  31. // Border-bottom-color darkened
  32. array(
  33. '#editor .editor-styles-wrapper .wp-block-pullquote,
  34. #editor .editor-styles-wrapper .wp-block-separator',
  35. 'border-bottom-color',
  36. '-1',
  37. ),
  38. // Background-color darkened
  39. array(
  40. '#editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  41. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd)',
  42. 'color',
  43. '-1',
  44. ),
  45. /**
  46. * Utility Classes
  47. */
  48. // Text-color
  49. array(
  50. '#editor .editor-styles-wrapper .has-primary-background-color[class],
  51. #editor .editor-styles-wrapper .wp-block .has-primary-background-color[class],
  52. #editor .editor-styles-wrapper .has-secondary-background-color[class],
  53. #editor .editor-styles-wrapper .wp-block .has-secondary-background-color[class],
  54. #editor .editor-styles-wrapper .has-foreground-background-color[class],
  55. #editor .editor-styles-wrapper .wp-block .has-foreground-background-color[class],
  56. #editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  57. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-background-color[class],
  58. #editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  59. #editor .editor-styles-wrapper .wp-block .has-foreground-light-background-color[class],
  60. #editor .editor-styles-wrapper .has-background-color[class],
  61. #editor .editor-styles-wrapper .wp-block .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. '#897248',
  106. array(
  107. // Text-color
  108. array(
  109. '#editor .editor-styles-wrapper .fse-template-part .main-navigation a:hover,
  110. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a,
  111. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link,
  112. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline,
  113. #editor .editor-styles-wrapper a',
  114. 'color',
  115. ),
  116. // Background-color
  117. array(
  118. '#editor .editor-styles-wrapper .button,
  119. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button,
  120. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:hover,
  121. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:not(.has-background):hover,
  122. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:focus,
  123. #editor .editor-styles-wrapper .fse-template-part .main-navigation #toggle:focus + #toggle-menu,
  124. #editor .editor-styles-wrapper .fse-template-part .main-navigation .button,
  125. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  126. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link,
  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. // Text-color darkened
  139. array(
  140. '#editor .editor-styles-wrapper .is-style-outline .wp-block-button__link.has-focus,
  141. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link:focus,
  142. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link:hover,
  143. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:active,
  144. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:hover,
  145. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:active,
  146. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:hover,
  147. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:hover,
  148. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:active,
  149. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:hover,
  150. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline.has-focus,
  151. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline:focus,
  152. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline:hover,
  153. #editor .editor-styles-wrapper a:hover',
  154. 'color',
  155. '-1',
  156. ),
  157. // Background-color darkened
  158. array(
  159. '#editor .editor-styles-wrapper .button.has-focus,
  160. #editor .editor-styles-wrapper .button:focus,
  161. #editor .editor-styles-wrapper .button:hover,
  162. #editor .editor-styles-wrapper .fse-template-part .main-navigation .button:focus,
  163. #editor .editor-styles-wrapper .fse-template-part .main-navigation .button:hover,
  164. #editor .editor-styles-wrapper .fse-template-part .main-navigation .has-focus.button,
  165. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:focus,
  166. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:hover,
  167. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .has-focus.button,
  168. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link.has-focus,
  169. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:focus,
  170. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover',
  171. 'background-color',
  172. '-1',
  173. ),
  174. /**
  175. * Utility Classes
  176. */
  177. // Text-color
  178. array(
  179. '#editor .editor-styles-wrapper .has-primary-color[class],
  180. #editor .editor-styles-wrapper .wp-block .has-primary-color[class]',
  181. 'color',
  182. ),
  183. // Background-color
  184. array(
  185. '#editor .editor-styles-wrapper .has-primary-background-color[class],
  186. #editor .editor-styles-wrapper .wp-block .has-primary-background-color[class]',
  187. 'background-color',
  188. ),
  189. ),
  190. __( 'Link Color' )
  191. );
  192. // Text Color
  193. // $config-global--color-foreground-default
  194. add_editor_color_rule(
  195. 'txt',
  196. '#181818',
  197. array(
  198. // Text-color
  199. array(
  200. '#editor .editor-styles-wrapper,
  201. #editor .editor-styles-wrapper .a8c-posts-list__item .a8c-posts-list-item__meta,
  202. #editor .editor-styles-wrapper .wp-block-image figcaption,
  203. #editor .editor-styles-wrapper .wp-block-latest-comments .wp-block-latest-comments__comment-date,
  204. #editor .editor-styles-wrapper .wp-block-latest-posts .wp-block-latest-posts__post-date,
  205. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .cat-links,
  206. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .entry-meta,
  207. #editor .editor-styles-wrapper .wp-block-pullquote .wp-block-pullquote__citation,
  208. #editor .editor-styles-wrapper .wp-block-pullquote cite,
  209. #editor .editor-styles-wrapper .wp-block-pullquote footer,
  210. #editor .editor-styles-wrapper .wp-block-quote .wp-block-quote__citation,
  211. #editor .editor-styles-wrapper .wp-block-quote cite,
  212. #editor .editor-styles-wrapper .wp-block-quote footer,
  213. #editor .editor-styles-wrapper .wp-block-quote.is-large .wp-block-quote__citation,
  214. #editor .editor-styles-wrapper .wp-block-quote.is-large cite,
  215. #editor .editor-styles-wrapper .wp-block-quote.is-large footer,
  216. #editor .editor-styles-wrapper .wp-block-quote.is-style-large .wp-block-quote__citation,
  217. #editor .editor-styles-wrapper .wp-block-quote.is-style-large cite,
  218. #editor .editor-styles-wrapper .wp-block-quote.is-style-large footer,
  219. #editor .editor-styles-wrapper .wp-block-video figcaption,
  220. #editor .editor-styles-wrapper figcaption,
  221. #editor .editor-styles-wrapper .wp-block-pullquote,
  222. #editor .editor-styles-wrapper .wp-block-pullquote,
  223. #editor .editor-styles-wrapper .wp-block-code > code,
  224. #editor .editor-styles-wrapper .wp-block-verse,
  225. #editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  226. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd),
  227. #editor .editor-styles-wrapper .editor-post-title__block .editor-post-title__input,
  228. #editor .editor-styles-wrapper .fse-template-part .main-navigation,
  229. #editor .editor-styles-wrapper .fse-template-part .main-navigation a,
  230. #editor .editor-styles-wrapper .fse-template-part .main-navigation a:link,
  231. #editor .editor-styles-wrapper .fse-template-part .main-navigation a:visited',
  232. 'color',
  233. ),
  234. // Background-color
  235. array(
  236. '#editor .editor-styles-wrapper .wp-block-cover.has-background-dim,
  237. #editor .editor-styles-wrapper .wp-block-cover-image.has-background-dim',
  238. 'background-color',
  239. ),
  240. /**
  241. * Utility Classes
  242. */
  243. // Text-color
  244. array(
  245. '#editor .editor-styles-wrapper .has-background-background-color[class],
  246. #editor .editor-styles-wrapper .wp-block .has-background-background-color[class],
  247. #editor .editor-styles-wrapper .has-background-dark-background-color[class],
  248. #editor .editor-styles-wrapper .wp-block .has-background-dark-background-color[class],
  249. #editor .editor-styles-wrapper .has-background-light-background-color[class],
  250. #editor .editor-styles-wrapper .wp-block .has-background-light-background-color[class],
  251. #editor .editor-styles-wrapper .has-foreground-color[class],
  252. #editor .editor-styles-wrapper .wp-block .has-foreground-color[class]',
  253. 'color',
  254. ),
  255. // Background-color
  256. array(
  257. '#editor .editor-styles-wrapper .has-foreground-background-color[class],
  258. #editor .editor-styles-wrapper .wp-block .has-foreground-background-color[class]',
  259. 'background-color',
  260. ),
  261. // Text-color darkened
  262. array(
  263. '#editor .editor-styles-wrapper .has-foreground-dark-color[class],
  264. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-color[class]',
  265. 'color',
  266. '-1',
  267. ),
  268. // Background-color darkened
  269. array(
  270. '#editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  271. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-background-color[class]',
  272. 'background-color',
  273. '-1',
  274. ),
  275. // Text-color brightened
  276. array(
  277. '#editor .editor-styles-wrapper .has-foreground-light-color[class],
  278. #editor .editor-styles-wrapper .wp-block .has-foreground-light-color[class]',
  279. 'color',
  280. '+2',
  281. ),
  282. // Background-color brightened
  283. array(
  284. '#editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  285. #editor .editor-styles-wrapper .wp-block .has-foreground-light-background-color[class]',
  286. 'background-color',
  287. '+2',
  288. ),
  289. ),
  290. __( 'Text Color' )
  291. );
  292. // Accent Color (Red)
  293. // $config-global--color-secondary-default
  294. add_editor_color_rule(
  295. 'fg1',
  296. '#c4493f',
  297. array(
  298. /**
  299. * Utility Classes
  300. */
  301. // Text-color
  302. array(
  303. '#editor .editor-styles-wrapper .has-secondary-color[class],
  304. #editor .editor-styles-wrapper .wp-block .has-secondary-color[class]',
  305. 'color',
  306. ),
  307. // Background-color
  308. array(
  309. '#editor .editor-styles-wrapper .has-secondary-background-color[class],
  310. #editor .editor-styles-wrapper .wp-block .has-secondary-background-color[class]',
  311. 'background-color',
  312. ),
  313. ),
  314. __( 'Secondary Color' )
  315. );
  316. /**
  317. * Custom CSS
  318. */
  319. function maywood_custom_editor_colors_extra_css() {
  320. $colors_array = get_theme_mod( 'colors_manager' );
  321. $txt = $colors_array['colors']['txt'];
  322. ?>
  323. #editor .editor-styles-wrapper .block-editor-default-block-appender textarea.block-editor-default-block-appender__content,
  324. #editor .editor-styles-wrapper .wp-block .editor-post-title__input::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
  325. color: <?php echo $txt; ?>;
  326. opacity: 0.66; /* Firefox */
  327. }
  328. #editor .editor-styles-wrapper .wp-block .editor-post-title__input:-ms-input-placeholder { /* Internet Explorer 10-11 */
  329. color: <?php echo $txt; ?>;
  330. opacity: 0.66;
  331. }
  332. #editor .editor-styles-wrapper .wp-block .editor-post-title__input::-ms-input-placeholder { /* Microsoft Edge */
  333. color: <?php echo $txt; ?>;
  334. opacity: 0.66;
  335. }
  336. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline.has-background[class],
  337. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link.has-background[class] {
  338. background: transparent !important;
  339. }
  340. #editor .editor-styles-wrapper .has-background:not(.has-background-background-color) a:not(.wp-block-button__link),
  341. #editor .editor-styles-wrapper p.has-text-color a,
  342. #editor .editor-styles-wrapper .has-background-dim a {
  343. color: currentColor;
  344. }
  345. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h1,
  346. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h2,
  347. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h3,
  348. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h4,
  349. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h5,
  350. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] h6,
  351. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h1,
  352. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h2,
  353. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h3,
  354. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h4,
  355. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h5,
  356. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container h6,
  357. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h1,
  358. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h2,
  359. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h3,
  360. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h4,
  361. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h5,
  362. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] h6,
  363. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h1,
  364. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h2,
  365. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h3,
  366. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h4,
  367. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h5,
  368. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container h6 {
  369. text-shadow: none;
  370. }
  371. #editor .editor-styles-wrapper .wp-block-cover[style*="background-image"] p,
  372. #editor .editor-styles-wrapper .wp-block-cover video + .wp-block-cover__inner-container p,
  373. #editor .editor-styles-wrapper .wp-block-cover-image[style*="background-image"] p,
  374. #editor .editor-styles-wrapper .wp-block-cover-image video + .wp-block-cover__inner-container p {
  375. text-shadow: none;
  376. }
  377. <?php
  378. }
  379. add_theme_support( 'custom_colors_extra_css', 'maywood_custom_editor_colors_extra_css' );