wpcom-editor-colors.php 13 KB

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