wpcom-editor-colors.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. /*
  3. * Custom Editor Colors: Varia
  4. */
  5. // Background Color
  6. // $config-global--color-background-default
  7. add_editor_color_rule( 'bg', '#f7f7f6', array(
  8. // Background-color
  9. array( '#editor .editor-styles-wrapper', 'background-color' ),
  10. // Text-color
  11. array( '#editor .editor-styles-wrapper .wp-block-button__link:not(.has-text-color),
  12. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:not(.has-text-color),
  13. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button,
  14. #editor .editor-styles-wrapper .wp-block-cover,
  15. #editor .editor-styles-wrapper .wp-block-cover-image,
  16. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .block-editor-block-list__block,
  17. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-image-text,
  18. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-text,
  19. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover__inner-container,
  20. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .block-editor-block-list__block,
  21. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover-image-text,
  22. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover-text,
  23. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover__inner-container,
  24. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color', 'color' ),
  25. // Lighten bg-color
  26. array( '#editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  27. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd)', 'background-color', '+1' ),
  28. // Darken text-color
  29. array( '#editor .editor-styles-wrapper .wp-block-separator.is-style-dots:before,
  30. #editor .editor-styles-wrapper hr.is-style-dots:before', 'color', '-1' ),
  31. // Darken border-color
  32. array( '#editor .editor-styles-wrapper .wp-block-separator[style*="text-align: right"],
  33. #editor .editor-styles-wrapper .wp-block-separator[style*="text-align:right"],
  34. #editor .editor-styles-wrapper hr[style*="text-align: right"],
  35. #editor .editor-styles-wrapper hr[style*="text-align:right"]', 'border-right-color', '-1' ),
  36. /**
  37. * Utility Classes
  38. */
  39. // Text-color
  40. array( '#editor .editor-styles-wrapper .has-primary-background-color[class],
  41. #editor .editor-styles-wrapper .wp-block .has-primary-background-color[class],
  42. #editor .editor-styles-wrapper .has-secondary-background-color[class],
  43. #editor .editor-styles-wrapper .wp-block .has-secondary-background-color[class],
  44. #editor .editor-styles-wrapper .has-foreground-background-color[class],
  45. #editor .editor-styles-wrapper .wp-block .has-foreground-background-color[class],
  46. #editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  47. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-background-color[class],
  48. #editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  49. #editor .editor-styles-wrapper .wp-block .has-foreground-light-background-color[class],
  50. #editor .editor-styles-wrapper .has-background-color[class],
  51. #editor .editor-styles-wrapper .wp-block .has-background-color[class]', 'color' ),
  52. // Background-color
  53. array( '#editor .editor-styles-wrapper .has-background-background-color[class],
  54. #editor .editor-styles-wrapper .wp-block .has-background-background-color[class]', 'background-color' ),
  55. // Text-color darkened
  56. array( '#editor .editor-styles-wrapper .has-background-dark-color[class],
  57. #editor .editor-styles-wrapper .wp-block .has-background-dark-color[class]', 'color', '-1' ),
  58. // Background-color darkened
  59. array( '#editor .editor-styles-wrapper .has-background-dark-background-color[class],
  60. #editor .editor-styles-wrapper .wp-block .has-background-dark-background-color[class]', 'background-color', '-1' ),
  61. // Text-color lightened
  62. array( '#editor .editor-styles-wrapper .has-background-light-color[class],
  63. #editor .editor-styles-wrapper .wp-block .has-background-light-color[class]', 'color', '+1' ),
  64. // Background-color lightened
  65. array( '#editor .editor-styles-wrapper .has-background-light-background-color[class],
  66. #editor .editor-styles-wrapper .wp-block .has-background-light-background-color[class]', 'background-color', '+1' ),
  67. /**
  68. * Grays
  69. * Uses a slightly darker color
  70. */
  71. // Color
  72. array( '#editor .editor-styles-wrapper .wp-block-separator.is-style-dots', 'color', '-1' ),
  73. // Border-color
  74. array( '#editor .editor-styles-wrapper .wp-block-code', 'border-color', '-1' ),
  75. // Border-top-color
  76. array( '#editor .editor-styles-wrapper .wp-block-pullquote', 'border-top-color', '-1' ),
  77. // Border-bottom-color
  78. array( '#editor .editor-styles-wrapper .wp-block-pullquote,
  79. #editor .editor-styles-wrapper .wp-block-separator', 'border-bottom-color', '-1' ),
  80. ), __( 'Background Color' ) );
  81. // Link Color
  82. // $config-global--color-primary-default
  83. add_editor_color_rule( 'link', '#ff302c', array(
  84. // Background-color
  85. array( '#editor .editor-styles-wrapper .button,
  86. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button,
  87. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:hover,
  88. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:not(.has-background):hover,
  89. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:focus,
  90. #editor .editor-styles-wrapper .fse-template-part .main-navigation .button,
  91. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  92. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link,
  93. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color', 'background-color' ),
  94. // Text-color
  95. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a,
  96. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link,
  97. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline,
  98. #editor .editor-styles-wrapper a', 'color' ),
  99. // Border color left
  100. array( '#editor .editor-styles-wrapper .wp-block-quote', 'border-left-color' ),
  101. // Border color right
  102. array( '#editor .editor-styles-wrapper .wp-block-quote[style*="text-align: right"],
  103. #editor .editor-styles-wrapper .wp-block-quote[style*="text-align:right"]', 'border-right-color' ),
  104. // Background-color
  105. array( '#editor .editor-styles-wrapper .button,
  106. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  107. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link,
  108. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color', 'background-color', 0.8 ),
  109. /**
  110. * Utility Classes
  111. */
  112. // Background-color
  113. array( '#editor .editor-styles-wrapper .has-primary-background-color[class],
  114. #editor .editor-styles-wrapper .wp-block .has-primary-background-color[class]', 'background-color' ),
  115. // Text-color
  116. array( '#editor .editor-styles-wrapper .has-primary-color[class],
  117. #editor .editor-styles-wrapper .wp-block .has-primary-color[class]', 'color' ),
  118. ), __( 'Link Color' ) );
  119. // Text Color
  120. // $config-global--color-foreground-default
  121. add_editor_color_rule( 'txt', '#444444', array(
  122. // Text-color
  123. array( '#editor .editor-styles-wrapper,
  124. #editor .editor-styles-wrapper .editor-post-title__block .editor-post-title__input,
  125. #editor .editor-styles-wrapper .wp-block-pullquote,
  126. #editor .editor-styles-wrapper table.is-style-stripes tbody tr:nth-child(odd),
  127. #editor .editor-styles-wrapper .wp-block-table.is-style-stripes tbody tr:nth-child(odd),
  128. #editor .editor-styles-wrapper .a8c-posts-list__item .a8c-posts-list-item__meta,
  129. #editor .editor-styles-wrapper .wp-block-image figcaption,
  130. #editor .editor-styles-wrapper .wp-block-latest-comments .wp-block-latest-comments__comment-date,
  131. #editor .editor-styles-wrapper .wp-block-latest-posts .wp-block-latest-posts__post-date,
  132. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .cat-links,
  133. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .entry-meta,
  134. #editor .editor-styles-wrapper .wp-block-pullquote .wp-block-pullquote__citation,
  135. #editor .editor-styles-wrapper .wp-block-pullquote cite,
  136. #editor .editor-styles-wrapper .wp-block-pullquote footer,
  137. #editor .editor-styles-wrapper .wp-block-quote .wp-block-quote__citation,
  138. #editor .editor-styles-wrapper .wp-block-quote cite,
  139. #editor .editor-styles-wrapper .wp-block-quote footer,
  140. #editor .editor-styles-wrapper .wp-block-quote.is-large .wp-block-quote__citation,
  141. #editor .editor-styles-wrapper .wp-block-quote.is-large cite,
  142. #editor .editor-styles-wrapper .wp-block-quote.is-large footer,
  143. #editor .editor-styles-wrapper .wp-block-quote.is-style-large .wp-block-quote__citation,
  144. #editor .editor-styles-wrapper .wp-block-quote.is-style-large cite,
  145. #editor .editor-styles-wrapper .wp-block-quote.is-style-large footer,
  146. #editor .editor-styles-wrapper .wp-block-video figcaption,
  147. #editor .editor-styles-wrapper figcaption,
  148. #editor .editor-styles-wrapper .wp-block-code', 'color' ),
  149. // Lighten text-color
  150. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links,
  151. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta,
  152. #editor .editor-styles-wrapper .wp-block-latest-posts .wp-block-latest-posts__post-date,
  153. #editor .editor-styles-wrapper .wp-block-pullquote .wp-block-pullquote__citation,
  154. #editor .editor-styles-wrapper .wp-block-pullquote cite,
  155. #editor .editor-styles-wrapper .wp-block-pullquote footer,
  156. #editor .editor-styles-wrapper .wp-block-quote .wp-block-quote__citation,
  157. #editor .editor-styles-wrapper figcaption', 'color', '+2' ),
  158. // Background-color
  159. array( '#editor .editor-styles-wrapper .wp-block-cover,
  160. #editor .editor-styles-wrapper .wp-block-cover.has-background-dim,
  161. #editor .editor-styles-wrapper .wp-block-cover-image,
  162. #editor .editor-styles-wrapper .wp-block-cover-image.has-background-dim', 'background-color' ),
  163. /**
  164. * Utility Classes
  165. */
  166. // Text-color
  167. array( '#editor .editor-styles-wrapper .has-background-background-color[class],
  168. #editor .editor-styles-wrapper .wp-block .has-background-background-color[class],
  169. #editor .editor-styles-wrapper .has-background-dark-background-color[class],
  170. #editor .editor-styles-wrapper .wp-block .has-background-dark-background-color[class],
  171. #editor .editor-styles-wrapper .has-background-light-background-color[class],
  172. #editor .editor-styles-wrapper .wp-block .has-background-light-background-color[class],
  173. #editor .editor-styles-wrapper .has-foreground-color[class],
  174. #editor .editor-styles-wrapper .wp-block .has-foreground-color[class]', 'color' ),
  175. // Background-color
  176. array( '#editor .editor-styles-wrapper .has-foreground-background-color[class],
  177. #editor .editor-styles-wrapper .wp-block .has-foreground-background-color[class]', 'background-color' ),
  178. // Text-color darkened
  179. array( '#editor .editor-styles-wrapper .has-foreground-dark-color[class],
  180. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-color[class]', 'color', '-1' ),
  181. // Background-color darkened
  182. array( '#editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  183. #editor .editor-styles-wrapper .wp-block .has-foreground-dark-background-color[class]', 'background-color', '-1' ),
  184. // Text-color brightened
  185. array( '#editor .editor-styles-wrapper .has-foreground-light-color[class],
  186. #editor .editor-styles-wrapper .wp-block .has-foreground-light-color[class]', 'color', '+2' ),
  187. // Background-color brightened
  188. array( '#editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  189. #editor .editor-styles-wrapper .wp-block .has-foreground-light-background-color[class]', 'background-color', '+2' ),
  190. ), __( 'Text Color' ) );
  191. // Accent Color (Red)
  192. // $config-global--color-secondary-default
  193. add_editor_color_rule( 'fg1', '#1285ce', array(
  194. // Text-color
  195. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:active,
  196. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:hover,
  197. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:active,
  198. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:hover,
  199. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:hover,
  200. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:active,
  201. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:hover,
  202. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link.has-focus,
  203. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link:focus,
  204. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link:hover,
  205. #editor .editor-styles-wrapper .wp-block-button .wp-block-button__link.is-style-outline.has-focus,
  206. #editor .editor-styles-wrapper .wp-block-button .wp-block-button__link.is-style-outline:focus,
  207. #editor .editor-styles-wrapper .wp-block-button .wp-block-button__link.is-style-outline:hover,
  208. #editor .editor-styles-wrapper a:hover', 'color' ),
  209. // Background-color
  210. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:focus,
  211. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:hover,
  212. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .has-focus.button,
  213. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .button.has-focus,
  214. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .button:focus,
  215. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .button:hover,
  216. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link.has-focus,
  217. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:focus,
  218. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover', 'background-color' ),
  219. /**
  220. * Utility Classes
  221. */
  222. // Text-color
  223. array( '#editor .editor-styles-wrapper .has-secondary-color[class],
  224. #editor .editor-styles-wrapper .wp-block .has-secondary-color[class]', 'color' ),
  225. // Background-color
  226. array( '#editor .editor-styles-wrapper .has-secondary-background-color[class],
  227. #editor .editor-styles-wrapper .wp-block .has-secondary-background-color[class]', 'background-color' ),
  228. ), __( 'Secondary Color' ) );
  229. /**
  230. * Custom CSS
  231. */
  232. function leven_editor_custom_colors_extra_css() { ?>
  233. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline.has-background[class],
  234. #editor .editor-styles-wrapper .is-style-outline .wp-block-button__link.has-background[class] {
  235. background: transparent !important;
  236. }
  237. #editor .editor-styles-wrapper .has-text-color a,
  238. #editor .editor-styles-wrapper .has-background a {
  239. color: currentColor;
  240. }
  241. <?php }
  242. add_theme_support( 'custom_colors_extra_css', 'leven_editor_custom_colors_extra_css' );