wpcom-editor-colors.php 13 KB

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