wpcom-editor-colors.php 13 KB

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