wpcom-editor-colors.php 14 KB

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