wpcom-editor-colors.php 14 KB

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